Skip to content

Commit

Permalink
chore(deps): bumps alloy, revm, fork-db (#9150)
Browse files Browse the repository at this point in the history
* chore(deps): bump alloy, revm, fork-db

* fix: chain_id u64

* use SpecId::Osaka in place of PragueEOF

* fix(`anvil`): test state files - tackle alloy breaking change alloy-rs/alloy#1486

* fix test

* minify state json
  • Loading branch information
yash-atreya authored Oct 23, 2024
1 parent 3b2e57a commit 7b118fa
Show file tree
Hide file tree
Showing 23 changed files with 316 additions and 205 deletions.
309 changes: 173 additions & 136 deletions Cargo.lock

Large diffs are not rendered by default.

54 changes: 27 additions & 27 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -170,39 +170,39 @@ foundry-linking = { path = "crates/linking" }
# solc & compilation utilities
foundry-block-explorers = { version = "0.7.3", default-features = false }
foundry-compilers = { version = "0.11.6", default-features = false }
foundry-fork-db = "0.4.0"
foundry-fork-db = "0.5.0"
solang-parser = "=0.3.3"

## revm
revm = { version = "14.0.3", default-features = false }
revm-primitives = { version = "10.0.0", default-features = false }
revm-inspectors = { version = "0.8.0", features = ["serde"] }
revm = { version = "16.0.0", default-features = false }
revm-primitives = { version = "12.0.0", default-features = false }
revm-inspectors = { version = "0.9.0", features = ["serde"] }

## ethers
ethers-contract-abigen = { version = "2.0.14", default-features = false }

## alloy
alloy-consensus = { version = "0.4.2", default-features = false }
alloy-contract = { version = "0.4.2", default-features = false }
alloy-eips = { version = "0.4.2", default-features = false }
alloy-genesis = { version = "0.4.2", default-features = false }
alloy-json-rpc = { version = "0.4.2", default-features = false }
alloy-network = { version = "0.4.2", default-features = false }
alloy-provider = { version = "0.4.2", default-features = false }
alloy-pubsub = { version = "0.4.2", default-features = false }
alloy-rpc-client = { version = "0.4.2", default-features = false }
alloy-rpc-types = { version = "0.4.2", default-features = true }
alloy-serde = { version = "0.4.2", default-features = false }
alloy-signer = { version = "0.4.2", default-features = false }
alloy-signer-aws = { version = "0.4.2", default-features = false }
alloy-signer-gcp = { version = "0.4.2", default-features = false }
alloy-signer-ledger = { version = "0.4.2", default-features = false }
alloy-signer-local = { version = "0.4.2", default-features = false }
alloy-signer-trezor = { version = "0.4.2", default-features = false }
alloy-transport = { version = "0.4.2", default-features = false }
alloy-transport-http = { version = "0.4.2", default-features = false }
alloy-transport-ipc = { version = "0.4.2", default-features = false }
alloy-transport-ws = { version = "0.4.2", default-features = false }
alloy-consensus = { version = "0.5.2", default-features = false }
alloy-contract = { version = "0.5.2", default-features = false }
alloy-eips = { version = "0.5.2", default-features = false }
alloy-genesis = { version = "0.5.2", default-features = false }
alloy-json-rpc = { version = "0.5.2", default-features = false }
alloy-network = { version = "0.5.2", default-features = false }
alloy-provider = { version = "0.5.2", default-features = false }
alloy-pubsub = { version = "0.5.2", default-features = false }
alloy-rpc-client = { version = "0.5.2", default-features = false }
alloy-rpc-types = { version = "0.5.2", default-features = true }
alloy-serde = { version = "0.5.2", default-features = false }
alloy-signer = { version = "0.5.2", default-features = false }
alloy-signer-aws = { version = "0.5.2", default-features = false }
alloy-signer-gcp = { version = "0.5.2", default-features = false }
alloy-signer-ledger = { version = "0.5.2", default-features = false }
alloy-signer-local = { version = "0.5.2", default-features = false }
alloy-signer-trezor = { version = "0.5.2", default-features = false }
alloy-transport = { version = "0.5.2", default-features = false }
alloy-transport-http = { version = "0.5.2", default-features = false }
alloy-transport-ipc = { version = "0.5.2", default-features = false }
alloy-transport-ws = { version = "0.5.2", default-features = false }

## alloy-core
alloy-dyn-abi = "0.8.5"
Expand All @@ -222,8 +222,8 @@ alloy-rlp = "0.3"
alloy-trie = "0.6.0"

## op-alloy
op-alloy-rpc-types = "0.3.3"
op-alloy-consensus = "0.3.3"
op-alloy-rpc-types = "0.5.0"
op-alloy-consensus = "0.5.0"

# macros
proc-macro2 = "1.0.82"
Expand Down
10 changes: 5 additions & 5 deletions crates/anvil/core/src/eth/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ impl Block {
parent_beacon_block_root: partial_header.parent_beacon_block_root,
nonce: partial_header.nonce,
base_fee_per_gas: partial_header.base_fee,
requests_root: None,
requests_hash: None,
},
transactions,
ommers,
Expand Down Expand Up @@ -160,7 +160,7 @@ mod tests {
excess_blob_gas: Default::default(),
parent_beacon_block_root: Default::default(),
base_fee_per_gas: None,
requests_root: None,
requests_hash: None,
};

let encoded = alloy_rlp::encode(&header);
Expand Down Expand Up @@ -201,7 +201,7 @@ mod tests {
parent_beacon_block_root: None,
nonce: B64::ZERO,
base_fee_per_gas: None,
requests_root: None,
requests_hash: None,
};

header.encode(&mut data);
Expand Down Expand Up @@ -234,7 +234,7 @@ mod tests {
excess_blob_gas: None,
parent_beacon_block_root: None,
base_fee_per_gas: None,
requests_root: None,
requests_hash: None,
};
let header = Header::decode(&mut data.as_slice()).unwrap();
assert_eq!(header, expected);
Expand Down Expand Up @@ -266,7 +266,7 @@ mod tests {
blob_gas_used: None,
excess_blob_gas: None,
parent_beacon_block_root: None,
requests_root: None,
requests_hash: None,
};
assert_eq!(header.hash_slow(), expected_hash);
}
Expand Down
26 changes: 24 additions & 2 deletions crates/anvil/core/src/eth/transaction/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1637,7 +1637,6 @@ pub fn convert_to_anvil_receipt(receipt: AnyTransactionReceipt) -> Option<Receip
to,
blob_gas_price,
blob_gas_used,
state_root,
inner: AnyReceiptEnvelope { inner: receipt_with_bloom, r#type },
authorization_list,
},
Expand All @@ -1656,7 +1655,6 @@ pub fn convert_to_anvil_receipt(receipt: AnyTransactionReceipt) -> Option<Receip
to,
blob_gas_price,
blob_gas_used,
state_root,
authorization_list,
inner: match r#type {
0x00 => TypedReceipt::Legacy(receipt_with_bloom),
Expand Down Expand Up @@ -1896,4 +1894,28 @@ mod tests {

assert_eq!(receipt, expected);
}

#[test]
fn deser_to_type_tx() {
let tx = r#"
{
"EIP1559": {
"chainId": "0x7a69",
"nonce": "0x0",
"gas": "0x5209",
"maxFeePerGas": "0x77359401",
"maxPriorityFeePerGas": "0x1",
"to": "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266",
"value": "0x0",
"accessList": [],
"input": "0x",
"r": "0x85c2794a580da137e24ccc823b45ae5cea99371ae23ee13860fcc6935f8305b0",
"s": "0x41de7fa4121dab284af4453d30928241208bafa90cdb701fe9bc7054759fe3cd",
"yParity": "0x0",
"hash": "0x8c9b68e8947ace33028dba167354fde369ed7bbe34911b772d09b3c64b861515"
}
}"#;

let _typed_tx: TypedTransaction = serde_json::from_str(tx).unwrap();
}
}
54 changes: 54 additions & 0 deletions crates/anvil/src/eth/backend/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -559,3 +559,57 @@ impl IntoIterator for SerializableHistoricalStates {
self.0.into_iter()
}
}

#[cfg(test)]
mod test {
use super::*;

#[test]
fn test_deser_block() {
let block = r#"{
"header": {
"parentHash": "0xceb0fe420d6f14a8eeec4319515b89acbb0bb4861cad9983d529ab4b1e4af929",
"ommersHash": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
"beneficiary": "0x0000000000000000000000000000000000000000",
"stateRoot": "0xe1423fd180478ab4fd05a7103277d64496b15eb914ecafe71eeec871b552efd1",
"transactionsRoot": "0x2b5598ef261e5f88e4303bb2b3986b3d5c0ebf4cd9977daebccae82a6469b988",
"receiptsRoot": "0xf78dfb743fbd92ade140711c8bbc542b5e307f0ab7984eff35d751969fe57efa",
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"difficulty": "0x0",
"number": "0x2",
"gasLimit": "0x1c9c380",
"gasUsed": "0x5208",
"timestamp": "0x66cdc823",
"mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"nonce": "0x0000000000000000",
"baseFeePerGas": "0x342a1c58",
"blobGasUsed": "0x0",
"excessBlobGas": "0x0",
"extraData": "0x"
},
"transactions": [
{
"EIP1559": {
"chainId": "0x7a69",
"nonce": "0x0",
"gas": "0x5209",
"maxFeePerGas": "0x77359401",
"maxPriorityFeePerGas": "0x1",
"to": "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266",
"value": "0x0",
"accessList": [],
"input": "0x",
"r": "0x85c2794a580da137e24ccc823b45ae5cea99371ae23ee13860fcc6935f8305b0",
"s": "0x41de7fa4121dab284af4453d30928241208bafa90cdb701fe9bc7054759fe3cd",
"yParity": "0x0",
"hash": "0x8c9b68e8947ace33028dba167354fde369ed7bbe34911b772d09b3c64b861515"
}
}
],
"ommers": []
}
"#;

let _block: SerializableBlock = serde_json::from_str(block).unwrap();
}
}
5 changes: 2 additions & 3 deletions crates/anvil/src/eth/backend/mem/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1868,7 +1868,7 @@ impl Backend {
gas_limit,
gas_used,
timestamp,
requests_root,
requests_hash,
extra_data,
mix_hash,
nonce,
Expand Down Expand Up @@ -1903,7 +1903,7 @@ impl Backend {
blob_gas_used,
excess_blob_gas,
parent_beacon_block_root,
requests_root,
requests_hash,
},
size: Some(size),
transactions: alloy_rpc_types::BlockTransactions::Hashes(
Expand Down Expand Up @@ -2415,7 +2415,6 @@ impl Backend {
block_hash: Some(block_hash),
from: info.from,
to: info.to,
state_root: None,
blob_gas_price: Some(blob_gas_price),
blob_gas_used: blob_gas_used.map(|g| g as u128),
authorization_list: None,
Expand Down
3 changes: 2 additions & 1 deletion crates/anvil/src/hardfork.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ impl From<EthereumHardfork> for SpecId {
EthereumHardfork::Cancun | EthereumHardfork::Latest => Self::CANCUN,
EthereumHardfork::Prague => Self::PRAGUE,
// TODO: switch to latest after activation
EthereumHardfork::PragueEOF => Self::PRAGUE_EOF,
// EOF is included in OSAKA from Revm 16.0.0
EthereumHardfork::PragueEOF => Self::OSAKA,
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/anvil/test-data/state-dump-legacy-stress.json

Large diffs are not rendered by default.

Loading

0 comments on commit 7b118fa

Please sign in to comment.