Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

State bypass & other fixes for release 1.0.0 #73

Merged
merged 37 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
34b2985
Add tests to trigger panics on compare_state_diffs function
guilledk Oct 15, 2024
f81ec7f
Fix test suite HashMap::default and finish clean impl of MockDBError …
guilledk Oct 15, 2024
1b59f02
Add state override mechanism for most cases, need to finish storage
guilledk Oct 16, 2024
7db24f0
Add code override based on original_size and separate override code test
guilledk Oct 16, 2024
3162f0d
Changes to make all tests pass except the one commented out due to hi…
guilledk Oct 16, 2024
4c8af52
Bring amirs rebase fixes in execute.rs
guilledk Oct 16, 2024
a0bde85
Reverting unnecesary changes
guilledk Oct 17, 2024
c5e4871
Load account into cache before we attempt to read/write it's storage
poplexity Oct 17, 2024
c450dc5
More strict on cache loading so we don't think we are writing to stor…
poplexity Oct 17, 2024
9c3c2ca
Disambiguate error messages and fix Option/Result for cached account …
poplexity Oct 17, 2024
8621882
If the account is not in reth_db then set status to Created|Touched
poplexity Oct 18, 2024
7140959
Adding the start of a storage compare script
poplexity Oct 19, 2024
4cd6a5c
Starting of compare_account
poplexity Oct 19, 2024
bc434d9
A little more on compare_account function
poplexity Oct 20, 2024
e93c822
Almost working storage_compare
poplexity Oct 21, 2024
e70287b
Fix for Packer trait mismatch with dependency versions, still not wor…
poplexity Oct 21, 2024
a1150f0
Bumping version of antelope-rs
poplexity Oct 21, 2024
e389b48
Moving to use latest master of antelope-client
poplexity Oct 21, 2024
9fd65d2
Refactor and fix for storage comparision logic
aamirpashaa Oct 22, 2024
c1640ac
Modifications to storage_compare
poplexity Oct 22, 2024
05e5941
Cleanup compare function
poplexity Oct 23, 2024
fe9843c
Add block number to print output
poplexity Oct 23, 2024
766632f
Set correct original_value while overriding storage
aamirpashaa Oct 23, 2024
9fd0003
Refactor code compraison by size
guilledk Oct 25, 2024
ced4d2d
Add back in search by code hash for case where we hit the de-duplicator
guilledk Oct 25, 2024
ae4a3b7
Add two-way storage compare
aamirpashaa Nov 7, 2024
ebfd5f4
Dont call compare function due to bugs on it and new two-way-compare …
guilledk Nov 7, 2024
ca62b6a
Fix getTransactionByhash
poplexity Nov 12, 2024
2e91fe1
Add more checks to two-way storage compare
aamirpashaa Nov 13, 2024
200948c
Fill missing telos args
aamirpashaa Nov 13, 2024
582b0bc
Fix override_code function for the case telos account has empty array…
guilledk Nov 12, 2024
4bc3e67
Try setting code to None instead of Some(Bytecode::default())
guilledk Nov 12, 2024
f2a613a
Use KECCAK_EMPTY for account override as well as code override
poplexity Nov 13, 2024
0ddf5cd
Enabling live comparison for account table only
aamirpashaa Nov 14, 2024
5205146
Adding TryFrom for ExEx support and adding key to logging of account …
poplexity Nov 15, 2024
bef87d6
Update revm to get latest patch for deposit to address 0
aamirpashaa Nov 16, 2024
3c7112e
Update revm to get latest patch for pre-charge of address 0
aamirpashaa Nov 17, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 50 additions & 10 deletions 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 Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ reth-node-telos = { path = "crates/telos/node" }
reth-telos-rpc = { path = "crates/telos/rpc" }
reth-telos-primitives-traits = { path = "crates/telos/primitives-traits" }
reth-telos-rpc-engine-api = { path = "crates/telos/rpc-engine-api" }
antelope-client = { git = "https://github.com/telosnetwork/antelope-rs", branch = "development" }
antelope-client = { git = "https://github.com/telosnetwork/antelope-rs", branch = "master" }

[patch.crates-io]
#alloy-consensus = { git = "https://github.com/alloy-rs/alloy", rev = "8c499409"}
Expand Down
1 change: 1 addition & 0 deletions crates/ethereum/evm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ reth-revm.workspace = true
reth-ethereum-consensus.workspace = true
reth-prune-types.workspace = true
reth-execution-types.workspace = true
sha2.workspace = true

# Ethereum
revm-primitives.workspace = true
Expand Down
89 changes: 72 additions & 17 deletions crates/ethereum/evm/src/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ use reth_telos_rpc_engine_api::compare::compare_state_diffs;
use revm_primitives::{Address, Account, AccountInfo, AccountStatus, Bytecode, HashMap, KECCAK_EMPTY};
#[cfg(feature = "telos")]
use alloy_primitives::B256;
#[cfg(feature = "telos")]
use sha2::{Sha256, Digest};

/// Provides executors to execute regular ethereum blocks
#[derive(Debug, Clone)]
Expand Down Expand Up @@ -192,6 +194,7 @@ where

// execute transactions
let mut cumulative_gas_used = 0;
#[cfg(not(feature = "telos"))]
let mut receipts = Vec::with_capacity(block.body.transactions.len());
for (sender, transaction) in block.transactions_with_sender() {
#[cfg(feature = "telos")]
Expand Down Expand Up @@ -233,6 +236,7 @@ where
// append gas used
cumulative_gas_used += result.gas_used();

#[cfg(not(feature = "telos"))]
// Push transaction changeset and calculate header bloom filter for receipt.
receipts.push(
#[allow(clippy::needless_update)] // side-effect of optimism fields
Expand All @@ -259,23 +263,32 @@ where
new_addresses_using_create_iter.next();
}

#[cfg(feature = "telos")] {
// Perform state diff comparision
let revm_state_diffs = evm.db_mut().transition_state.clone().unwrap_or_default().transitions;
let block_num = block.block.header.number;
println!(
"Compare: block {block_num} {}",
compare_state_diffs(
&mut evm,
revm_state_diffs,
unwrapped_telos_extra_fields.statediffs_account.unwrap_or_default(),
unwrapped_telos_extra_fields.statediffs_accountstate.unwrap_or_default(),
unwrapped_telos_extra_fields.new_addresses_using_create.unwrap_or_default(),
unwrapped_telos_extra_fields.new_addresses_using_openwallet.unwrap_or_default()
)
);
// #[cfg(feature = "telos")]
{
// Perform state diff comparision
let revm_state_diffs = evm.db_mut().transition_state.clone().unwrap_or_default().transitions;
let block_num = block.block.header.number;
println!(
"Compare: block {block_num} {}",
compare_state_diffs(
&mut evm,
revm_state_diffs,
unwrapped_telos_extra_fields.statediffs_account.clone().unwrap_or_default(),
unwrapped_telos_extra_fields.statediffs_accountstate.clone().unwrap_or_default(),
unwrapped_telos_extra_fields.new_addresses_using_create.clone().unwrap_or_default(),
unwrapped_telos_extra_fields.new_addresses_using_openwallet.clone().unwrap_or_default(),
false
)
);
}

#[cfg(feature = "telos")]
let receipts = if unwrapped_telos_extra_fields.receipts.is_some() {
unwrapped_telos_extra_fields.receipts.clone().unwrap()
} else {
vec![]
};

let requests = if self.chain_spec.is_prague_active_at_timestamp(block.timestamp) {
// Collect all EIP-6110 deposits
let deposit_requests =
Expand All @@ -288,7 +301,44 @@ where
vec![]
};

Ok(EthExecuteOutput { receipts, requests, gas_used: cumulative_gas_used })
// #[cfg(feature = "telos")]
// {
// let mut addr_to_accstate: HashMap<Address, HashMap<U256, EvmStorageSlot>> = HashMap::new();

// for sdiff_accstate in unwrapped_telos_extra_fields.clone().statediffs_accountstate.unwrap_or(vec![]) {
// if !addr_to_accstate.contains_key(&sdiff_accstate.address) {
// addr_to_accstate.insert(sdiff_accstate.address, HashMap::new());
// }
// let mut acc_storage = addr_to_accstate.get_mut(&sdiff_accstate.address).unwrap();
// acc_storage.insert(sdiff_accstate.key, EvmStorageSlot { original_value: Default::default(), present_value: sdiff_accstate.value, is_cold: false });
// }

// let mut state: HashMap<Address, Account> = HashMap::new();

// for sdiff_acc in unwrapped_telos_extra_fields.clone().statediffs_account.unwrap_or(vec![]) {
// state.insert(
// sdiff_acc.address,
// Account {
// info: AccountInfo {
// balance: sdiff_acc.balance,
// nonce: sdiff_acc.nonce,
// code_hash: B256::from(Sha256::digest(sdiff_acc.code.as_ref()).as_ref()),
// code: Some(Bytecode::LegacyRaw(sdiff_acc.code)),
// },
// storage: addr_to_accstate.get(&sdiff_acc.address).unwrap_or(&HashMap::new()).clone(),
// status: AccountStatus::Touched | AccountStatus::LoadedAsNotExisting,
// }
// );
// }

// evm.db_mut().commit(state);
// }

Ok(EthExecuteOutput {
receipts,
requests,
gas_used: cumulative_gas_used
})
}
}

Expand Down Expand Up @@ -366,7 +416,12 @@ where
let env = self.evm_env_for_block(&block.header, total_difficulty);
let output = {
let evm = self.executor.evm_config.evm_with_env(&mut self.state, env);
self.executor.execute_state_transitions(block, evm, #[cfg(feature = "telos")] telos_extra_fields)
self.executor.execute_state_transitions(
block,
evm,
#[cfg(feature = "telos")]
telos_extra_fields
)
}?;

// 3. apply post execution changes
Expand Down
2 changes: 2 additions & 0 deletions crates/telos/bin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ reth-chainspec.workspace = true
reth-provider.workspace = true
reth-node-telos.workspace = true
reth-telos-rpc.workspace = true
reth-db.workspace = true
alloy-primitives.workspace = true


clap = { workspace = true, features = ["derive", "env"] }
Expand Down
Loading
Loading