Skip to content

Commit

Permalink
[ETH_BYTECODE_DB] Verifier alliance handle partial matches updates (#756
Browse files Browse the repository at this point in the history
)

* Add test case for second partial update

* Add partial updates processing implementation

* Extend test case to check full match addition

* Deduplicate verified alliance data insertion logic

* Refactor code, extract code verification logic from db

* Return service launcher v0.10.0

* Fix max_connections postgres workflow

* Refactor process_verifier_alliance_db_action function
  • Loading branch information
rimrakhimov authored Jan 25, 2024
1 parent 6aa1a48 commit 9239fc1
Show file tree
Hide file tree
Showing 14 changed files with 896 additions and 357 deletions.

This file was deleted.

19 changes: 14 additions & 5 deletions .github/workflows/eth-bytecode-db.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,26 @@ jobs:
--health-interval 10s
--health-timeout 5s
--health-retries 5
--name postgres
ports:
- 5432:5432
volumes:
- /tmp/docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d

steps:
- name: Checkout sources
uses: actions/checkout@v2

- name: Copy entrypoint scripts to the volume
run: sudo cp -r ../.github/volumes/docker-entrypoint-initdb.d/* /tmp/docker-entrypoint-initdb.d/
continue-on-error: false
- name: Set postgres max_connections
run: |
psql -h localhost -p 5432 -c "ALTER SYSTEM SET max_connections = 500;" -d postgres
env:
PGPASSWORD: admin
PGUSER: postgres

- name: Restart postgres
# Restart Postgres so that new system parameters to be applied
uses: docker://docker
with:
args: docker restart postgres

- name: Install deps
uses: ./.github/actions/deps
Expand Down
1 change: 1 addition & 0 deletions eth-bytecode-db/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion eth-bytecode-db/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ members = [
]

[workspace.dependencies]
blockscout-service-launcher = "0.10.0"
blockscout-service-launcher = "0.10.0"
1 change: 1 addition & 0 deletions eth-bytecode-db/eth-bytecode-db-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ verifier-alliance-migration = { path = "../eth-bytecode-db/verifier-alliance-mig

blockscout-service-launcher = { workspace = true, features = [ "test-server", "test-database", "database-0_12" ] }
bytes = "1.5.0"
futures = "0.3"
hex = "0.4.3"
mockall = "0.11"
keccak-hash = "0.10.0"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
{
"_comment": "Argument `store.num` has been updated to `store.modified_num` to change the metadata hash",

"deployed_creation_code": "0x608060405234801561001057600080fd5b50610133806100206000396000f3fe6080604052348015600f57600080fd5b506004361060325760003560e01c80636057361d1460375780638381f58a14604f575b600080fd5b604d60048036038101906049919060af565b6069565b005b60556073565b6040516060919060e4565b60405180910390f35b8060008190555050565b60005481565b600080fd5b6000819050919050565b608f81607e565b8114609957600080fd5b50565b60008135905060a9816088565b92915050565b60006020828403121560c25760c16079565b5b600060ce84828501609c565b91505092915050565b60de81607e565b82525050565b600060208201905060f7600083018460d7565b9291505056fea26469706673582212204ac0ce5f82b26331fa3e9ae959291a55624ffaf90fcd509deafcc21a5f1da21e64736f6c63430008120033",
"deployed_runtime_code": "0x6080604052348015600f57600080fd5b506004361060325760003560e01c80636057361d1460375780638381f58a14604f575b600080fd5b604d60048036038101906049919060af565b6069565b005b60556073565b6040516060919060e4565b60405180910390f35b8060008190555050565b60005481565b600080fd5b6000819050919050565b608f81607e565b8114609957600080fd5b50565b60008135905060a9816088565b92915050565b60006020828403121560c25760c16079565b5b600060ce84828501609c565b91505092915050565b60de81607e565b82525050565b600060208201905060f7600083018460d7565b9291505056fea26469706673582212204ac0ce5f82b26331fa3e9ae959291a55624ffaf90fcd509deafcc21a5f1da21e64736f6c63430008120033",

"compiled_creation_code": "0x608060405234801561001057600080fd5b50610133806100206000396000f3fe6080604052348015600f57600080fd5b506004361060325760003560e01c80636057361d1460375780638381f58a14604f575b600080fd5b604d60048036038101906049919060af565b6069565b005b60556073565b6040516060919060e4565b60405180910390f35b8060008190555050565b60005481565b600080fd5b6000819050919050565b608f81607e565b8114609957600080fd5b50565b60008135905060a9816088565b92915050565b60006020828403121560c25760c16079565b5b600060ce84828501609c565b91505092915050565b60de81607e565b82525050565b600060208201905060f7600083018460d7565b9291505056fea26469706673582212200d5e45241ace38600195972a3af9542f2a9aec3ed5a7fd2959788cc58857d43564736f6c63430008120033",
"compiled_runtime_code": "0x6080604052348015600f57600080fd5b506004361060325760003560e01c80636057361d1460375780638381f58a14604f575b600080fd5b604d60048036038101906049919060af565b6069565b005b60556073565b6040516060919060e4565b60405180910390f35b8060008190555050565b60005481565b600080fd5b6000819050919050565b608f81607e565b8114609957600080fd5b50565b60008135905060a9816088565b92915050565b60006020828403121560c25760c16079565b5b600060ce84828501609c565b91505092915050565b60de81607e565b82525050565b600060208201905060f7600083018460d7565b9291505056fea26469706673582212200d5e45241ace38600195972a3af9542f2a9aec3ed5a7fd2959788cc58857d43564736f6c63430008120033",
"compiler": "solc",
"version": "v0.8.18+commit.87f61d96",
"language": "solidity",
"name": "Storage",
"fully_qualified_name": "contracts/1_Storage.sol:Storage",
"sources": {
"contracts/1_Storage.sol": " // SPDX-License-Identifier: GPL-3.0\n\npragma solidity >=0.7.0 <0.9.0;\n\n/**\n * @title Storage\n * @dev Store & retrieve value in a variable\n */\ncontract Storage {\n uint256 public number;\n\n /**\n * @dev Store value in variable\n * @param modified_num value to store\n */\n function store(uint256 modified_num) public {\n number = modified_num;\n }\n}"
},
"compiler_settings": {
"optimizer": {
"enabled": false,
"runs": 200
},
"libraries": {},
"outputSelection": {
"*": {
"*": [
"*"
]
}
}
},
"compilation_artifacts": {
"abi": [{"inputs":[],"name":"number","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"modified_num","type":"uint256"}],"name":"store","outputs":[],"stateMutability":"nonpayable","type":"function"}],
"devdoc": {"details":"Store & retrieve value in a variable","kind":"dev","methods":{"store(uint256)":{"details":"Store value in variable","params":{"modified_num":"value to store"}}},"title":"Storage","version":1},
"userdoc": {"kind":"user","methods":{},"version":1},
"storageLayout": {"storage":[{"astId":4,"contract":"contracts/1_Storage.sol:Storage","label":"number","offset":0,"slot":"0","type":"t_uint256"}],"types":{"t_uint256":{"encoding":"inplace","label":"uint256","numberOfBytes":"32"}}},
"sources": {"contracts/1_Storage.sol": {"id": 0} }
},
"creation_code_artifacts": {
"linkReferences": {},
"sourceMap": "142:229:0:-:0;;;;;;;;;;;;;;;;;;;",
"cborAuxdata": {
"1": {
"offset": 286,
"value": "0xa26469706673582212203863ce629eb61798cd34ba5d73d729ef1f86d2529ee1bdfc20e7eda860c4260564736f6c63430008120033"
}
}
},
"runtime_code_artifacts": {
"immutableReferences": {},
"linkReferences": {},
"sourceMap": "142:229:0:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;287:82;;;;;;;;;;;;;:::i;:::-;;:::i;:::-;;165:21;;;:::i;:::-;;;;;;;:::i;:::-;;;;;;;;287:82;350:12;341:6;:21;;;;287:82;:::o;165:21::-;;;;:::o;88:117:1:-;197:1;194;187:12;334:77;371:7;400:5;389:16;;334:77;;;:::o;417:122::-;490:24;508:5;490:24;:::i;:::-;483:5;480:35;470:63;;529:1;526;519:12;470:63;417:122;:::o;545:139::-;591:5;629:6;616:20;607:29;;645:33;672:5;645:33;:::i;:::-;545:139;;;;:::o;690:329::-;749:6;798:2;786:9;777:7;773:23;769:32;766:119;;;804:79;;:::i;:::-;766:119;924:1;949:53;994:7;985:6;974:9;970:22;949:53;:::i;:::-;939:63;;895:117;690:329;;;;:::o;1025:118::-;1112:24;1130:5;1112:24;:::i;:::-;1107:3;1100:37;1025:118;;:::o;1149:222::-;1242:4;1280:2;1269:9;1265:18;1257:26;;1293:71;1361:1;1350:9;1346:17;1337:6;1293:71;:::i;:::-;1149:222;;;;:::o",
"cborAuxdata": {
"1": {
"offset": 254,
"value": "0xa26469706673582212203863ce629eb61798cd34ba5d73d729ef1f86d2529ee1bdfc20e7eda860c4260564736f6c63430008120033"
}
}
},

"creation_match": true,
"creation_values": {
"cborAuxdata": {
"1": "0xa26469706673582212204ac0ce5f82b26331fa3e9ae959291a55624ffaf90fcd509deafcc21a5f1da21e64736f6c63430008120033"
}
},
"creation_transformations": [
{
"type": "replace",
"reason": "auxdata",
"offset": 286,
"id": "1"
}
],

"runtime_match": true,
"runtime_values": {
"cborAuxdata": {
"1": "0xa26469706673582212204ac0ce5f82b26331fa3e9ae959291a55624ffaf90fcd509deafcc21a5f1da21e64736f6c63430008120033"
}
},
"runtime_transformations": [
{
"type": "replace",
"reason": "auxdata",
"offset": 254,
"id": "1"
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,17 @@ use eth_bytecode_db::verification::{BytecodeType, VerificationMetadata, Verifica
use eth_bytecode_db_proto::blockscout::eth_bytecode_db::v2 as eth_bytecode_db_v2;
use serde::Deserialize;
use smart_contract_verifier_proto::blockscout::smart_contract_verifier::v2 as smart_contract_verifier_v2;
use std::{collections::BTreeMap, path::Path, str::FromStr};
use std::{
collections::BTreeMap,
path::{Path, PathBuf},
str::FromStr,
};

#[derive(Debug, Clone, Deserialize)]
pub struct TestCase {
#[serde(skip)]
pub test_case_name: String,

pub deployed_creation_code: Option<DisplayBytes>,
pub deployed_runtime_code: DisplayBytes,

Expand Down Expand Up @@ -72,8 +79,20 @@ fn default_deployer() -> DisplayBytes {

impl TestCase {
pub fn from_file<P: AsRef<Path>>(path: P) -> Self {
// e.g. "tests/alliance_test_cases/full_match.json" => "full_match"
let test_case_name = PathBuf::from(path.as_ref())
.file_stem()
.as_ref()
.unwrap()
.to_str()
.unwrap()
.to_string();

let content = std::fs::read_to_string(path).expect("failed to read file");
serde_json::from_str(&content).expect("invalid test case format")
let mut test_case: TestCase =
serde_json::from_str(&content).expect("invalid test case format");
test_case.test_case_name = test_case_name;
test_case
}

pub fn to_test_input_data(&self) -> TestInputData {
Expand Down
Loading

0 comments on commit 9239fc1

Please sign in to comment.