Skip to content

Commit

Permalink
refactor test
Browse files Browse the repository at this point in the history
  • Loading branch information
MdTeach committed Dec 19, 2024
1 parent 0ebec7a commit c7303fb
Show file tree
Hide file tree
Showing 18 changed files with 190 additions and 180 deletions.
2 changes: 1 addition & 1 deletion 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 bin/prover-client/src/proving_ops/el_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ impl ElOperations {

#[async_trait]
impl ProvingOperations for ElOperations {
/// Used serialized [`EvmBlockStfInput`] because [`EvmBlockStfInput::parent_state_trie`]
/// Used serialized [`EvmBlockStfInput`] because [`EvmBlockStfInput::pre_state_trie`]
/// contains RefCell, which is not Sync or Send
type Input = Vec<u8>;
type Params = (u64, u64);
Expand Down
6 changes: 3 additions & 3 deletions crates/proof-impl/evm-ee-stf/src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ impl InMemoryDBHelper for InMemoryDB {

// For each account, load the information into the database.
let mut accounts = HashMap::with_capacity_and_hasher(
input.parent_storage.len(),
input.pre_state_storage.len(),
DefaultHashBuilder::default(),
);
for (address, (storage_trie, slots)) in &mut input.parent_storage {
for (address, (storage_trie, slots)) in &mut input.pre_state_storage {
let state_account = input
.parent_state_trie
.pre_state_trie
.get_rlp::<StateAccount>(&keccak(address))?
.unwrap_or_default();

Expand Down
10 changes: 6 additions & 4 deletions crates/proof-impl/evm-ee-stf/src/primitives.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,13 @@ pub struct EvmBlockStfInput {
/// computation has been carried out on this block.
pub mix_hash: B256,

/// The state trie of the parent block.
pub parent_state_trie: MptNode,
/// Represents the pre-state trie containing account states
/// expected to be accessed or modified during execution.
pub pre_state_trie: MptNode,

/// The storage of the parent block.
pub parent_storage: HashMap<Address, StorageEntry>,
/// Represents the pre-state storage containing entries
/// expected to be accessed or modified during execution.
pub pre_state_storage: HashMap<Address, StorageEntry>,

/// The relevant contracts for the block.
pub contracts: Vec<Bytes>,
Expand Down
4 changes: 2 additions & 2 deletions crates/proof-impl/evm-ee-stf/src/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ impl EvmProcessor<InMemoryDB> {
pub fn finalize(&mut self) {
let db = self.db.take().expect("DB not initialized");

let mut state_trie = mem::take(&mut self.input.parent_state_trie);
let mut state_trie = mem::take(&mut self.input.pre_state_trie);
for (address, account) in &db.accounts {
// Ignore untouched accounts.
if account.account_state == AccountState::None {
Expand All @@ -291,7 +291,7 @@ impl EvmProcessor<InMemoryDB> {
// Update storage root for account.
let state_storage = &account.storage;
let storage_root = {
let (storage_trie, _) = self.input.parent_storage.get_mut(address).unwrap();
let (storage_trie, _) = self.input.pre_state_storage.get_mut(address).unwrap();
// If the account has been cleared, clear the storage trie.
if account.account_state == AccountState::StorageCleared {
storage_trie.clear();
Expand Down
2 changes: 1 addition & 1 deletion crates/proof-impl/evm-ee-stf/src/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ impl ZkVmProver for EvmEeProver {
ProofType::Compressed
}

fn prepare_input<'a, B>(el_inputs: &'a Self::Input) -> ZkVmResult<B::Input>
fn prepare_input<'a, B>(el_inputs: &'a Self::Input) -> ZkVmInputResult<B::Input>
where
B: strata_zkvm::ZkVmInputBuilder<'a>,
{
Expand Down
6 changes: 3 additions & 3 deletions crates/proof-impl/evm-ee-stf/test_data/witness_params.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"timestamp": 1727003743,
"extra_data": "0x726574682f76312e302e332f6d61636f73",
"mix_hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"parent_state_trie": {
"pre_state_trie": {
"data": {
"Leaf": [
[
Expand Down Expand Up @@ -151,7 +151,7 @@
]
}
},
"parent_storage": {
"pre_state_storage": {
"0x0000000000000000000000000000000000000000": [
{
"data": "Null"
Expand Down Expand Up @@ -217,4 +217,4 @@
],
"deposit_requests": []
}
}
}
6 changes: 3 additions & 3 deletions crates/reth/db/test_data/witness_params.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"timestamp": 1727003743,
"extra_data": "0x726574682f76312e302e332f6d61636f73",
"mix_hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"parent_state_trie": {
"pre_state_trie": {
"data": {
"Leaf": [
[
Expand Down Expand Up @@ -151,7 +151,7 @@
]
}
},
"parent_storage": {
"pre_state_storage": {
"0x0000000000000000000000000000000000000000": [
{
"data": "Null"
Expand Down Expand Up @@ -217,4 +217,4 @@
],
"deposit_requests": []
}
}
}
4 changes: 2 additions & 2 deletions crates/reth/exex/src/prover_exex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,8 @@ fn extract_zkvm_input<Node: FullNodeComponents>(
mix_hash: current_block.header.mix_hash,
transactions: current_block_txns,
withdrawals,
parent_state_trie: state_trie,
parent_storage: storage,
pre_state_trie: state_trie,
pre_state_storage: storage,

Check warning on line 201 in crates/reth/exex/src/prover_exex.rs

View check run for this annotation

Codecov / codecov/patch

crates/reth/exex/src/prover_exex.rs#L200-L201

Added lines #L200 - L201 were not covered by tests
contracts,
parent_header: prev_block.header,
// NOTE: using default to save prover cost.
Expand Down
74 changes: 37 additions & 37 deletions crates/test-utils/data/evm_ee/witness_1.json
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
{
"parent_header": {
"parent_hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"ommers_hash": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
"beneficiary": "0x0000000000000000000000000000000000000000",
"state_root": "0x351714af72d74259f45cd7eab0b04527cd40e74836a45abcae50f92d919d988f",
"transactions_root": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"receipts_root": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"withdrawals_root": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"logs_bloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"difficulty": "0x0",
"number": 0,
"parent_header": {
"parent_hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"ommers_hash": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
"beneficiary": "0x0000000000000000000000000000000000000000",
"state_root": "0x351714af72d74259f45cd7eab0b04527cd40e74836a45abcae50f92d919d988f",
"transactions_root": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"receipts_root": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"withdrawals_root": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"logs_bloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"difficulty": "0x0",
"number": 0,
"gas_limit": 30000000,
"gas_used": 0,
"timestamp": 0,
"mix_hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"nonce": "0x0000000000000042",
"base_fee_per_gas": 1000000000,
"blob_gas_used": null,
"excess_blob_gas": null,
"parent_beacon_block_root": null,
"requests_root": null,
"extra_data": "0x5343"
},
"beneficiary": "0x5400000000000000000000000000000000000011",
"gas_limit": 30000000,
"gas_used": 0,
"timestamp": 0,
"timestamp": 1728049633,
"extra_data": "0x726574682f76312e302e332f6d61636f73",
"mix_hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"nonce": "0x0000000000000042",
"base_fee_per_gas": 1000000000,
"blob_gas_used": null,
"excess_blob_gas": null,
"parent_beacon_block_root": null,
"requests_root": null,
"extra_data": "0x5343"
},
"beneficiary": "0x5400000000000000000000000000000000000011",
"gas_limit": 30000000,
"timestamp": 1728049633,
"extra_data": "0x726574682f76312e302e332f6d61636f73",
"mix_hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"parent_state_trie": {
"data": {
"Digest": "0x351714af72d74259f45cd7eab0b04527cd40e74836a45abcae50f92d919d988f"
}
},
"parent_storage": {},
"contracts": [],
"ancestor_headers": [],
"transactions": [],
"withdrawals": []
}
"pre_state_trie": {
"data": {
"Digest": "0x351714af72d74259f45cd7eab0b04527cd40e74836a45abcae50f92d919d988f"
}
},
"pre_state_storage": {},
"contracts": [],
"ancestor_headers": [],
"transactions": [],
"withdrawals": []
}
72 changes: 36 additions & 36 deletions crates/test-utils/data/evm_ee/witness_2.json
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
{
"parent_header": {
"parent_hash": "0x37ad61cff1367467a98cf7c54c4ac99e989f1fbb1bc1e646235e90c065c565ba",
"ommers_hash": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
"parent_header": {
"parent_hash": "0x37ad61cff1367467a98cf7c54c4ac99e989f1fbb1bc1e646235e90c065c565ba",
"ommers_hash": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
"beneficiary": "0x5400000000000000000000000000000000000011",
"state_root": "0x351714af72d74259f45cd7eab0b04527cd40e74836a45abcae50f92d919d988f",
"transactions_root": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"receipts_root": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"withdrawals_root": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"logs_bloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"difficulty": "0x0",
"number": 1,
"gas_limit": 30000000,
"gas_used": 0,
"timestamp": 1728049633,
"mix_hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"nonce": "0x0000000000000000",
"base_fee_per_gas": 875000000,
"blob_gas_used": null,
"excess_blob_gas": null,
"parent_beacon_block_root": null,
"requests_root": null,
"extra_data": "0x726574682f76312e302e332f6d61636f73"
},
"beneficiary": "0x5400000000000000000000000000000000000011",
"state_root": "0x351714af72d74259f45cd7eab0b04527cd40e74836a45abcae50f92d919d988f",
"transactions_root": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"receipts_root": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"withdrawals_root": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"logs_bloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"difficulty": "0x0",
"number": 1,
"gas_limit": 30000000,
"gas_used": 0,
"timestamp": 1728049633,
"timestamp": 1728049634,
"extra_data": "0x726574682f76312e302e332f6d61636f73",
"mix_hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"nonce": "0x0000000000000000",
"base_fee_per_gas": 875000000,
"blob_gas_used": null,
"excess_blob_gas": null,
"parent_beacon_block_root": null,
"requests_root": null,
"extra_data": "0x726574682f76312e302e332f6d61636f73"
},
"beneficiary": "0x5400000000000000000000000000000000000011",
"gas_limit": 30000000,
"timestamp": 1728049634,
"extra_data": "0x726574682f76312e302e332f6d61636f73",
"mix_hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"parent_state_trie": {
"data": {
"Digest": "0x351714af72d74259f45cd7eab0b04527cd40e74836a45abcae50f92d919d988f"
}
},
"parent_storage": {},
"contracts": [],
"ancestor_headers": [],
"transactions": [],
"withdrawals": []
}
"pre_state_trie": {
"data": {
"Digest": "0x351714af72d74259f45cd7eab0b04527cd40e74836a45abcae50f92d919d988f"
}
},
"pre_state_storage": {},
"contracts": [],
"ancestor_headers": [],
"transactions": [],
"withdrawals": []
}
72 changes: 36 additions & 36 deletions crates/test-utils/data/evm_ee/witness_3.json
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
{
"parent_header": {
"parent_hash": "0x14b2fbd209d6c9334b71596e6207ada9042ba9e738259e1e6a4b1ea5faa71794",
"ommers_hash": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
"parent_header": {
"parent_hash": "0x14b2fbd209d6c9334b71596e6207ada9042ba9e738259e1e6a4b1ea5faa71794",
"ommers_hash": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
"beneficiary": "0x5400000000000000000000000000000000000011",
"state_root": "0x351714af72d74259f45cd7eab0b04527cd40e74836a45abcae50f92d919d988f",
"transactions_root": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"receipts_root": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"withdrawals_root": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"logs_bloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"difficulty": "0x0",
"number": 2,
"gas_limit": 30000000,
"gas_used": 0,
"timestamp": 1728049634,
"mix_hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"nonce": "0x0000000000000000",
"base_fee_per_gas": 765625000,
"blob_gas_used": null,
"excess_blob_gas": null,
"parent_beacon_block_root": null,
"requests_root": null,
"extra_data": "0x726574682f76312e302e332f6d61636f73"
},
"beneficiary": "0x5400000000000000000000000000000000000011",
"state_root": "0x351714af72d74259f45cd7eab0b04527cd40e74836a45abcae50f92d919d988f",
"transactions_root": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"receipts_root": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"withdrawals_root": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"logs_bloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"difficulty": "0x0",
"number": 2,
"gas_limit": 30000000,
"gas_used": 0,
"timestamp": 1728049634,
"timestamp": 1728049635,
"extra_data": "0x726574682f76312e302e332f6d61636f73",
"mix_hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"nonce": "0x0000000000000000",
"base_fee_per_gas": 765625000,
"blob_gas_used": null,
"excess_blob_gas": null,
"parent_beacon_block_root": null,
"requests_root": null,
"extra_data": "0x726574682f76312e302e332f6d61636f73"
},
"beneficiary": "0x5400000000000000000000000000000000000011",
"gas_limit": 30000000,
"timestamp": 1728049635,
"extra_data": "0x726574682f76312e302e332f6d61636f73",
"mix_hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"parent_state_trie": {
"data": {
"Digest": "0x351714af72d74259f45cd7eab0b04527cd40e74836a45abcae50f92d919d988f"
}
},
"parent_storage": {},
"contracts": [],
"ancestor_headers": [],
"transactions": [],
"withdrawals": []
}
"pre_state_trie": {
"data": {
"Digest": "0x351714af72d74259f45cd7eab0b04527cd40e74836a45abcae50f92d919d988f"
}
},
"pre_state_storage": {},
"contracts": [],
"ancestor_headers": [],
"transactions": [],
"withdrawals": []
}
Loading

0 comments on commit c7303fb

Please sign in to comment.