From 8e6235d7a75524faa49f80d386ae96dc9d912996 Mon Sep 17 00:00:00 2001 From: Wolfgang Welz Date: Mon, 28 Aug 2023 10:23:41 -0400 Subject: [PATCH] upgrade alloy-primitives --- Cargo.lock | 5 +++-- guests/eth-block/Cargo.lock | 5 +++-- lib/src/input.rs | 4 ++-- primitives/Cargo.toml | 2 +- primitives/src/access_list.rs | 4 ++-- primitives/src/block.rs | 6 +++--- primitives/src/ethers.rs | 6 +++--- primitives/src/receipt.rs | 4 ++-- primitives/src/revm.rs | 12 ++++++------ primitives/src/signature.rs | 6 +++--- primitives/src/transaction.rs | 12 ++++++------ primitives/src/withdrawal.rs | 6 +++--- testing/ef-tests/src/ethers.rs | 8 ++++---- testing/ef-tests/src/lib.rs | 10 +++++----- testing/ef-tests/testguest/Cargo.lock | 5 +++-- 15 files changed, 49 insertions(+), 46 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0dcd3613..3434f73a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -56,8 +56,9 @@ dependencies = [ [[package]] name = "alloy-primitives" -version = "0.3.1" -source = "git+https://github.com/alloy-rs/core.git?rev=58e2259#58e2259a858f9a1ac7ebb0eb421dce5bb6305850" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e416903084d3392ebd32d94735c395d6709415b76c7728e594d3f996f2b03e65" dependencies = [ "alloy-rlp", "bytes", diff --git a/guests/eth-block/Cargo.lock b/guests/eth-block/Cargo.lock index 6462dc5a..24a96841 100644 --- a/guests/eth-block/Cargo.lock +++ b/guests/eth-block/Cargo.lock @@ -39,8 +39,9 @@ dependencies = [ [[package]] name = "alloy-primitives" -version = "0.3.1" -source = "git+https://github.com/alloy-rs/core.git?rev=58e2259#58e2259a858f9a1ac7ebb0eb421dce5bb6305850" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e416903084d3392ebd32d94735c395d6709415b76c7728e594d3f996f2b03e65" dependencies = [ "alloy-rlp", "bytes", diff --git a/lib/src/input.rs b/lib/src/input.rs index 1de56d5d..ddd8fb18 100644 --- a/lib/src/input.rs +++ b/lib/src/input.rs @@ -18,7 +18,7 @@ use hashbrown::HashMap; use revm::primitives::B160 as RevmB160; use serde::{Deserialize, Serialize}; use zeth_primitives::{ - block::Header, transaction::Transaction, trie::MptNode, withdrawal::Withdrawal, Bytes, B160, + block::Header, transaction::Transaction, trie::MptNode, withdrawal::Withdrawal, Address, Bytes, B256, U256, }; @@ -30,7 +30,7 @@ pub struct Input { /// Previous block header pub parent_header: Header, /// Address to which all priority fees in this block are transferred. - pub beneficiary: B160, + pub beneficiary: Address, /// Scalar equal to the current limit of gas expenditure per block. pub gas_limit: U256, /// Scalar corresponding to the seconds since Epoch at this block's inception. diff --git a/primitives/Cargo.toml b/primitives/Cargo.toml index bfc005c3..8774b9cb 100644 --- a/primitives/Cargo.toml +++ b/primitives/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" edition = "2021" [dependencies] -alloy-primitives = { git = "https://github.com/alloy-rs/core.git", rev = "58e2259", features = ["rlp", "serde"] } +alloy-primitives = { version = "0.3", features = ["rlp", "serde"] } alloy-rlp = { version = "0.3", default-features = false } alloy-rlp-derive = { version = "0.3", default-features = false } anyhow = "1.0" diff --git a/primitives/src/access_list.rs b/primitives/src/access_list.rs index 79b371b3..906ce34b 100644 --- a/primitives/src/access_list.rs +++ b/primitives/src/access_list.rs @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -use alloy_primitives::{StorageKey, B160}; +use alloy_primitives::{Address, StorageKey}; use alloy_rlp_derive::{RlpEncodable, RlpEncodableWrapper}; use serde::{Deserialize, Serialize}; @@ -32,7 +32,7 @@ pub struct AccessList(pub Vec); #[derive(Debug, Clone, PartialEq, Eq, Default, RlpEncodable, Serialize, Deserialize)] pub struct AccessListItem { /// The Ethereum address that the transaction will access. - pub address: B160, + pub address: Address, /// A list of storage keys associated with the given address that the transaction will /// access. pub storage_keys: Vec, diff --git a/primitives/src/block.rs b/primitives/src/block.rs index c8b3022f..ae7375d7 100644 --- a/primitives/src/block.rs +++ b/primitives/src/block.rs @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -use alloy_primitives::{b256, BlockHash, BlockNumber, Bloom, Bytes, B160, B256, B64, U256}; +use alloy_primitives::{b256, Address, BlockHash, BlockNumber, Bloom, Bytes, B256, B64, U256}; use alloy_rlp_derive::RlpEncodable; use serde::{Deserialize, Serialize}; @@ -30,7 +30,7 @@ pub struct Header { /// Unused 256-bit hash, always [EMPTY_LIST_HASH]. pub ommers_hash: B256, /// Address that receives the priority fees of each transaction in the block. - pub beneficiary: B160, + pub beneficiary: Address, /// Root hash of the state trie after all transactions in the block are executed. pub state_root: B256, /// Root hash of the trie containing all transactions in the block. @@ -69,7 +69,7 @@ impl Default for Header { Header { parent_hash: B256::ZERO, ommers_hash: EMPTY_LIST_HASH, - beneficiary: B160::ZERO, + beneficiary: Address::ZERO, state_root: EMPTY_ROOT, transactions_root: EMPTY_ROOT, receipts_root: EMPTY_ROOT, diff --git a/primitives/src/ethers.rs b/primitives/src/ethers.rs index 1f833f6c..919e590c 100644 --- a/primitives/src/ethers.rs +++ b/primitives/src/ethers.rs @@ -14,7 +14,7 @@ //! Convert from Ethers types. -use alloy_primitives::{Bloom, B160, B256, U256}; +use alloy_primitives::{Address, Bloom, B256, U256}; use anyhow::{anyhow, Context}; use ethers_core::types::{ transaction::eip2930::{ @@ -41,9 +41,9 @@ pub fn from_ethers_u256(v: EthersU256) -> U256 { U256::from_limbs(v.0) } -/// Convert an `EthersH160` type to the `B160` type. +/// Convert an `EthersH160` type to the `Address` type. #[inline] -pub fn from_ethers_h160(v: EthersH160) -> B160 { +pub fn from_ethers_h160(v: EthersH160) -> Address { v.0.into() } diff --git a/primitives/src/receipt.rs b/primitives/src/receipt.rs index 073d3ded..5b641d25 100644 --- a/primitives/src/receipt.rs +++ b/primitives/src/receipt.rs @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -use alloy_primitives::{Bloom, BloomInput, Bytes, B160, B256, U256}; +use alloy_primitives::{Address, Bloom, BloomInput, Bytes, B256, U256}; use alloy_rlp::Encodable; use alloy_rlp_derive::RlpEncodable; use serde::{Deserialize, Serialize}; @@ -21,7 +21,7 @@ use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, PartialEq, Eq, Default, Serialize, Deserialize, RlpEncodable)] pub struct Log { /// Contract that emitted this log. - pub address: B160, + pub address: Address, /// Topics of the log. The number of logs depend on what `LOG` opcode is used. pub topics: Vec, /// Arbitrary length data. diff --git a/primitives/src/revm.rs b/primitives/src/revm.rs index 6ed743ae..f6b7b3ff 100644 --- a/primitives/src/revm.rs +++ b/primitives/src/revm.rs @@ -14,7 +14,7 @@ //! Convert to revm types. -use alloy_primitives::{B160, B256}; +use alloy_primitives::{Address, B256}; use revm_primitives::{Log as RevmLog, B160 as RevmB160, B256 as RevmB256, U256 as RevmU256}; use crate::{ @@ -22,10 +22,10 @@ use crate::{ receipt::Log, }; -/// Converts a `B160` type to its corresponding `RevmB160` representation. +/// Converts a `Address` type to its corresponding `RevmB160` representation. #[inline] -pub fn to_revm_b160(v: B160) -> RevmB160 { - v.0.into() +pub fn to_revm_b160(v: Address) -> RevmB160 { + v.0 .0.into() } /// Converts a `B256` type to its corresponding `RevmB256` representation. @@ -34,9 +34,9 @@ pub fn to_revm_b256(v: B256) -> RevmB256 { v.0.into() } -/// Converts a `RevmB160` type to its corresponding `B160` representation. +/// Converts a `RevmB160` type to its corresponding `Address` representation. #[inline] -pub fn from_revm_b160(v: RevmB160) -> B160 { +pub fn from_revm_b160(v: RevmB160) -> Address { v.0.into() } diff --git a/primitives/src/signature.rs b/primitives/src/signature.rs index d7a3748d..b3b13562 100644 --- a/primitives/src/signature.rs +++ b/primitives/src/signature.rs @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -use alloy_primitives::{B160, U256}; +use alloy_primitives::{Address, U256}; use alloy_rlp_derive::{RlpEncodable, RlpMaxEncodedLen}; use anyhow::Context; use k256::{ @@ -52,7 +52,7 @@ impl Transaction { /// This method uses the ECDSA recovery mechanism to derive the sender's public key /// and subsequently their Ethereum address. If the recovery is unsuccessful, an /// error is returned. - pub fn recover_from(&self) -> anyhow::Result { + pub fn recover_from(&self) -> anyhow::Result
{ let is_y_odd = self.is_y_odd().context("v invalid")?; let signature = K256Signature::from_scalars( self.signature.r.to_be_bytes(), @@ -73,7 +73,7 @@ impl Transaction { debug_assert_eq!(public_key[0], 0x04); let hash = keccak(&public_key[1..]); - Ok(B160::from_slice(&hash[12..])) + Ok(Address::from_slice(&hash[12..])) } /// Determines whether the y-coordinate of the ECDSA signature's associated public key diff --git a/primitives/src/transaction.rs b/primitives/src/transaction.rs index 84a5b571..614d0599 100644 --- a/primitives/src/transaction.rs +++ b/primitives/src/transaction.rs @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -use alloy_primitives::{Bytes, ChainId, TxHash, TxNumber, B160, B256, U256}; +use alloy_primitives::{Address, Bytes, ChainId, TxHash, TxNumber, B256, U256}; use alloy_rlp::{Encodable, EMPTY_STRING_CODE}; use alloy_rlp_derive::RlpEncodable; use serde::{Deserialize, Serialize}; @@ -312,16 +312,16 @@ pub enum TransactionKind { Create, /// Indicates that the transaction is a call to an existing contract, identified by /// its 160-bit address. - Call(B160), + Call(Address), } -/// Provides a conversion from [TransactionKind] to `Option`. +/// Provides a conversion from [TransactionKind] to `Option
`. /// /// This implementation allows for a straightforward extraction of the Ethereum address /// from a [TransactionKind]. If the transaction kind is a `Call`, the address is wrapped /// in a `Some`. If it's a `Create`, the result is `None`. -impl From for Option { - /// Converts a [TransactionKind] into an `Option`. +impl From for Option
{ + /// Converts a [TransactionKind] into an `Option
`. /// /// - If the transaction kind is `Create`, this returns `None`. /// - If the transaction kind is `Call`, this returns the address wrapped in a `Some`. @@ -461,7 +461,7 @@ impl Transaction { /// /// For contract creation transactions, this method returns `None` as there's no /// recipient address. - pub fn to(&self) -> Option { + pub fn to(&self) -> Option
{ match &self.essence { TxEssence::Legacy(tx) => tx.to.into(), TxEssence::Eip2930(tx) => tx.to.into(), diff --git a/primitives/src/withdrawal.rs b/primitives/src/withdrawal.rs index 2644943e..56421fc4 100644 --- a/primitives/src/withdrawal.rs +++ b/primitives/src/withdrawal.rs @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -use alloy_primitives::B160; +use alloy_primitives::Address; use alloy_rlp_derive::{RlpEncodable, RlpMaxEncodedLen}; use serde::{Deserialize, Serialize}; @@ -32,9 +32,9 @@ pub struct Withdrawal { pub index: u64, /// The distinct index of the validator initiating this withdrawal. pub validator_index: u64, - /// The Ethereum address, encapsulated as a `B160` type, where the withdrawn ether + /// The Ethereum address, encapsulated as a `Address` type, where the withdrawn ether /// will be sent. - pub address: B160, + pub address: Address, /// The total withdrawal amount, denominated in gwei. pub amount: u64, } diff --git a/testing/ef-tests/src/ethers.rs b/testing/ef-tests/src/ethers.rs index 48d3e895..d138a7d3 100644 --- a/testing/ef-tests/src/ethers.rs +++ b/testing/ef-tests/src/ethers.rs @@ -43,7 +43,7 @@ impl Provider for TestProvider { Ok(Block:: { parent_hash: self.header.parent_hash.0.into(), uncles_hash: self.header.ommers_hash.0.into(), - author: Some(self.header.beneficiary.0.into()), + author: Some(self.header.beneficiary.0 .0.into()), state_root: self.header.state_root.0.into(), transactions_root: self.header.transactions_root.0.into(), receipts_root: self.header.receipts_root.0.into(), @@ -126,7 +126,7 @@ impl Provider for TestProvider { } } -fn build_tries(state: &TestState) -> (MptNode, HashMap) { +fn build_tries(state: &TestState) -> (MptNode, HashMap) { let mut state_trie = MptNode::default(); let mut storage_tries = HashMap::new(); for (address, account) in &state.0 { @@ -157,7 +157,7 @@ fn build_tries(state: &TestState) -> (MptNode, HashMap) { } fn get_proof( - address: B160, + address: Address, indices: impl IntoIterator, state: &TestState, ) -> Result { @@ -189,7 +189,7 @@ fn get_proof( } Ok(EIP1186ProofResponse { - address: address.0.into(), + address: address.0 .0.into(), balance: account.balance.to_be_bytes().into(), code_hash: keccak(account.code).into(), nonce: account.nonce.to_be_bytes().into(), diff --git a/testing/ef-tests/src/lib.rs b/testing/ef-tests/src/lib.rs index b8b13803..e134305b 100644 --- a/testing/ef-tests/src/lib.rs +++ b/testing/ef-tests/src/lib.rs @@ -44,7 +44,7 @@ use zeth_primitives::{ }, trie::{self, MptNode, MptNodeData, StateAccount}, withdrawal::Withdrawal, - Bloom, Bytes, RlpBytes, StorageKey, B160, B256, B64, U256, U64, + Address, Bloom, Bytes, RlpBytes, StorageKey, B256, B64, U256, U64, }; use crate::ethers::{get_state_update_proofs, TestProvider}; @@ -106,7 +106,7 @@ impl From for TestAccount { #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] #[serde(rename_all = "camelCase")] -pub struct TestState(pub HashMap); +pub struct TestState(pub HashMap); impl From<&MemDb> for TestState { fn from(db: &MemDb) -> Self { @@ -130,7 +130,7 @@ impl From<&ProviderDb> for TestState { pub struct TestHeader { pub base_fee_per_gas: Option, pub bloom: Bloom, - pub coinbase: B160, + pub coinbase: Address, pub extra_data: Bytes, pub difficulty: U256, pub gas_limit: U256, @@ -184,7 +184,7 @@ pub struct TestTransaction { pub max_priority_fee_per_gas: Option, pub value: U256, #[serde_as(as = "NoneAsEmptyString")] - pub to: Option, + pub to: Option
, pub nonce: U64, pub v: U64, pub r: U256, @@ -252,7 +252,7 @@ pub struct TestAccessList(pub Vec); #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct TestAccessListItem { - pub address: B160, + pub address: Address, pub storage_keys: Vec, } diff --git a/testing/ef-tests/testguest/Cargo.lock b/testing/ef-tests/testguest/Cargo.lock index 6d50255e..03d0f09b 100644 --- a/testing/ef-tests/testguest/Cargo.lock +++ b/testing/ef-tests/testguest/Cargo.lock @@ -39,8 +39,9 @@ dependencies = [ [[package]] name = "alloy-primitives" -version = "0.3.1" -source = "git+https://github.com/alloy-rs/core.git?rev=58e2259#58e2259a858f9a1ac7ebb0eb421dce5bb6305850" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e416903084d3392ebd32d94735c395d6709415b76c7728e594d3f996f2b03e65" dependencies = [ "alloy-rlp", "bytes",