Skip to content

Commit

Permalink
chore: alloy 0.4 (paradigmxyz#11334)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsse authored Sep 30, 2024
1 parent e8153e5 commit a5538bc
Show file tree
Hide file tree
Showing 80 changed files with 425 additions and 518 deletions.
156 changes: 79 additions & 77 deletions Cargo.lock

Large diffs are not rendered by default.

64 changes: 32 additions & 32 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ revm = { version = "14.0.3", features = [
"secp256k1",
"blst",
], default-features = false }
revm-inspectors = "0.7.6"
revm-inspectors = "0.8.1"
revm-primitives = { version = "10.0.0", features = [
"std",
], default-features = false }
Expand All @@ -426,45 +426,45 @@ alloy-rlp = "0.3.4"
alloy-sol-types = "0.8.0"
alloy-trie = { version = "0.6", default-features = false }

alloy-consensus = { version = "0.3.6", default-features = false }
alloy-eips = { version = "0.3.6", default-features = false }
alloy-genesis = { version = "0.3.6", default-features = false }
alloy-json-rpc = { version = "0.3.6", default-features = false }
alloy-network = { version = "0.3.6", default-features = false }
alloy-network-primitives = { version = "0.3.6", default-features = false }
alloy-node-bindings = { version = "0.3.6", default-features = false }
alloy-provider = { version = "0.3.6", features = [
alloy-consensus = { version = "0.4.0", default-features = false }
alloy-eips = { version = "0.4.0", default-features = false }
alloy-genesis = { version = "0.4.0", default-features = false }
alloy-json-rpc = { version = "0.4.0", default-features = false }
alloy-network = { version = "0.4.0", default-features = false }
alloy-network-primitives = { version = "0.4.0", default-features = false }
alloy-node-bindings = { version = "0.4.0", default-features = false }
alloy-provider = { version = "0.4.0", features = [
"reqwest",
], default-features = false }
alloy-pubsub = { version = "0.3.6", default-features = false }
alloy-rpc-client = { version = "0.3.6", default-features = false }
alloy-rpc-types = { version = "0.3.6", features = [
alloy-pubsub = { version = "0.4.0", default-features = false }
alloy-rpc-client = { version = "0.4.0", default-features = false }
alloy-rpc-types = { version = "0.4.0", features = [
"eth",
], default-features = false }
alloy-rpc-types-admin = { version = "0.3.6", default-features = false }
alloy-rpc-types-anvil = { version = "0.3.6", default-features = false }
alloy-rpc-types-beacon = { version = "0.3.6", default-features = false }
alloy-rpc-types-debug = { version = "0.3.6", default-features = false }
alloy-rpc-types-engine = { version = "0.3.6", default-features = false }
alloy-rpc-types-eth = { version = "0.3.6", default-features = false }
alloy-rpc-types-mev = { version = "0.3.6", default-features = false }
alloy-rpc-types-trace = { version = "0.3.6", default-features = false }
alloy-rpc-types-txpool = { version = "0.3.6", default-features = false }
alloy-serde = { version = "0.3.6", default-features = false }
alloy-signer = { version = "0.3.6", default-features = false }
alloy-signer-local = { version = "0.3.6", default-features = false }
alloy-transport = { version = "0.3.6" }
alloy-transport-http = { version = "0.3.6", features = [
alloy-rpc-types-admin = { version = "0.4.0", default-features = false }
alloy-rpc-types-anvil = { version = "0.4.0", default-features = false }
alloy-rpc-types-beacon = { version = "0.4.0", default-features = false }
alloy-rpc-types-debug = { version = "0.4.0", default-features = false }
alloy-rpc-types-engine = { version = "0.4.0", default-features = false }
alloy-rpc-types-eth = { version = "0.4.0", default-features = false }
alloy-rpc-types-mev = { version = "0.4.0", default-features = false }
alloy-rpc-types-trace = { version = "0.4.0", default-features = false }
alloy-rpc-types-txpool = { version = "0.4.0", default-features = false }
alloy-serde = { version = "0.4.0", default-features = false }
alloy-signer = { version = "0.4.0", default-features = false }
alloy-signer-local = { version = "0.4.0", default-features = false }
alloy-transport = { version = "0.4.0" }
alloy-transport-http = { version = "0.4.0", features = [
"reqwest-rustls-tls",
], default-features = false }
alloy-transport-ipc = { version = "0.3.6", default-features = false }
alloy-transport-ws = { version = "0.3.6", default-features = false }
alloy-transport-ipc = { version = "0.4.0", default-features = false }
alloy-transport-ws = { version = "0.4.0", default-features = false }

# op
op-alloy-rpc-types = "0.2.12"
op-alloy-rpc-types-engine = "0.2.12"
op-alloy-network = "0.2.12"
op-alloy-consensus = "0.2.12"
op-alloy-rpc-types = "0.3.1"
op-alloy-rpc-types-engine = "0.3.1"
op-alloy-network = "0.3.1"
op-alloy-consensus = "0.3.1"

# misc
aquamarine = "0.5"
Expand Down
6 changes: 2 additions & 4 deletions bin/reth-bench/src/bench/new_payload_fcu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,7 @@ impl Command {
)
.await?;

let new_payload_result =
NewPayloadResult { gas_used: gas_used as u64, latency: start.elapsed() };
let new_payload_result = NewPayloadResult { gas_used, latency: start.elapsed() };

call_forkchoice_updated(&auth_provider, message_version, forkchoice_state, None)
.await?;
Expand All @@ -120,8 +119,7 @@ impl Command {
info!(%combined_result);

// record the current result
let gas_row =
TotalGasRow { block_number, gas_used: gas_used as u64, time: current_duration };
let gas_row = TotalGasRow { block_number, gas_used, time: current_duration };
results.push((gas_row, combined_result));
}

Expand Down
6 changes: 2 additions & 4 deletions bin/reth-bench/src/bench/new_payload_only.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,14 @@ impl Command {
call_new_payload(&auth_provider, payload, parent_beacon_block_root, versioned_hashes)
.await?;

let new_payload_result =
NewPayloadResult { gas_used: gas_used as u64, latency: start.elapsed() };
let new_payload_result = NewPayloadResult { gas_used, latency: start.elapsed() };
info!(%new_payload_result);

// current duration since the start of the benchmark
let current_duration = total_benchmark_duration.elapsed();

// record the current result
let row =
TotalGasRow { block_number, gas_used: gas_used as u64, time: current_duration };
let row = TotalGasRow { block_number, gas_used, time: current_duration };
results.push((row, new_payload_result));
}

Expand Down
8 changes: 4 additions & 4 deletions crates/blockchain-tree/src/blockchain_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1568,7 +1568,7 @@ mod tests {
Transaction::Eip1559(TxEip1559 {
chain_id: chain_spec.chain.id(),
nonce,
gas_limit: MIN_TRANSACTION_GAS as u128,
gas_limit: MIN_TRANSACTION_GAS,
to: Address::ZERO.into(),
max_fee_per_gas: EIP1559_INITIAL_BASE_FEE as u128,
..Default::default()
Expand Down Expand Up @@ -1604,10 +1604,10 @@ mod tests {
let sealed = Header {
number,
parent_hash: parent.unwrap_or_default(),
gas_used: (body.len() as u64 * MIN_TRANSACTION_GAS) as u128,
gas_limit: chain_spec.max_gas_limit.into(),
gas_used: body.len() as u64 * MIN_TRANSACTION_GAS,
gas_limit: chain_spec.max_gas_limit,
mix_hash: B256::random(),
base_fee_per_gas: Some(EIP1559_INITIAL_BASE_FEE.into()),
base_fee_per_gas: Some(EIP1559_INITIAL_BASE_FEE),
transactions_root,
receipts_root,
state_root: state_root_unhashed(HashMap::from([(
Expand Down
13 changes: 2 additions & 11 deletions crates/chain-state/src/in_memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -552,18 +552,9 @@ impl CanonicalInMemoryState {
index: index as u64,
block_hash: block_state.hash(),
block_number: block_state.block().block.number,
base_fee: block_state
.block()
.block()
.header
.base_fee_per_gas
.map(|base_fee| base_fee as u64),
base_fee: block_state.block().block().header.base_fee_per_gas,
timestamp: block_state.block().block.timestamp,
excess_blob_gas: block_state
.block()
.block
.excess_blob_gas
.map(|excess_blob| excess_blob as u64),
excess_blob_gas: block_state.block().block.excess_blob_gas,
};
return Some((tx.clone(), meta))
}
Expand Down
8 changes: 4 additions & 4 deletions crates/chain-state/src/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ impl TestBlockBuilder {
let tx = Transaction::Eip1559(TxEip1559 {
chain_id: self.chain_spec.chain.id(),
nonce,
gas_limit: MIN_TRANSACTION_GAS as u128,
gas_limit: MIN_TRANSACTION_GAS,
to: Address::random().into(),
max_fee_per_gas: EIP1559_INITIAL_BASE_FEE as u128,
max_priority_fee_per_gas: 1,
Expand Down Expand Up @@ -132,10 +132,10 @@ impl TestBlockBuilder {
let header = Header {
number,
parent_hash,
gas_used: transactions.len() as u128 * MIN_TRANSACTION_GAS as u128,
gas_limit: self.chain_spec.max_gas_limit.into(),
gas_used: transactions.len() as u64 * MIN_TRANSACTION_GAS,
gas_limit: self.chain_spec.max_gas_limit,
mix_hash: B256::random(),
base_fee_per_gas: Some(EIP1559_INITIAL_BASE_FEE.into()),
base_fee_per_gas: Some(EIP1559_INITIAL_BASE_FEE),
transactions_root: calculate_transaction_root(&transactions),
receipts_root: calculate_receipt_root(&receipts),
beneficiary: Address::random(),
Expand Down
4 changes: 2 additions & 2 deletions crates/chainspec/src/spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2336,7 +2336,7 @@ Post-merge hard forks (timestamp based):

#[test]
fn test_paris_block_and_total_difficulty() {
let genesis = Genesis { gas_limit: 0x2fefd8u128, ..Default::default() };
let genesis = Genesis { gas_limit: 0x2fefd8u64, ..Default::default() };
let paris_chainspec = ChainSpecBuilder::default()
.chain(Chain::from_id(1337))
.genesis(genesis)
Expand All @@ -2348,7 +2348,7 @@ Post-merge hard forks (timestamp based):
#[test]
fn test_default_cancun_header_forkhash() {
// set the gas limit from the hive test genesis according to the hash
let genesis = Genesis { gas_limit: 0x2fefd8u128, ..Default::default() };
let genesis = Genesis { gas_limit: 0x2fefd8u64, ..Default::default() };
let default_chainspec = ChainSpecBuilder::default()
.chain(Chain::from_id(1337))
.genesis(genesis)
Expand Down
14 changes: 6 additions & 8 deletions crates/consensus/auto-seal/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ impl StorageInner {
withdrawals_root: withdrawals.map(|w| proofs::calculate_withdrawals_root(w)),
difficulty: U256::from(2),
number: self.best_block + 1,
gas_limit: chain_spec.max_gas_limit().into(),
gas_limit: chain_spec.max_gas_limit(),
timestamp,
base_fee_per_gas,
blob_gas_used: blob_gas_used.map(Into::into),
Expand All @@ -326,10 +326,8 @@ impl StorageInner {
}
_ => (0, 0),
};
header.excess_blob_gas = Some(
calc_excess_blob_gas(parent_excess_blob_gas as u64, parent_blob_gas_used as u64)
.into(),
)
header.excess_blob_gas =
Some(calc_excess_blob_gas(parent_excess_blob_gas, parent_blob_gas_used))
}

header
Expand Down Expand Up @@ -406,7 +404,7 @@ impl StorageInner {

// now we need to update certain header fields with the results of the execution
header.state_root = db.state_root(hashed_state)?;
header.gas_used = gas_used.into();
header.gas_used = gas_used;

let receipts = execution_outcome.receipts_by_block(header.number);

Expand Down Expand Up @@ -594,7 +592,7 @@ mod tests {
assert_eq!(header.parent_hash, best_block_hash);
assert_eq!(header.number, best_block_number + 1);
assert_eq!(header.timestamp, timestamp);
assert_eq!(header.gas_limit, chain_spec.max_gas_limit.into());
assert_eq!(header.gas_limit, chain_spec.max_gas_limit);
}

#[test]
Expand Down Expand Up @@ -688,7 +686,7 @@ mod tests {
withdrawals_root: None,
difficulty: U256::from(2),
number: 1,
gas_limit: chain_spec.max_gas_limit.into(),
gas_limit: chain_spec.max_gas_limit,
timestamp,
base_fee_per_gas: None,
blob_gas_used: Some(0),
Expand Down
2 changes: 1 addition & 1 deletion crates/consensus/beacon/src/engine/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ mod tests {
let client = TestFullBlockClient::default();
let sealed = Header {
base_fee_per_gas: Some(7),
gas_limit: chain_spec.max_gas_limit.into(),
gas_limit: chain_spec.max_gas_limit,
..Default::default()
}
.seal_slow();
Expand Down
32 changes: 15 additions & 17 deletions crates/consensus/common/src/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ use revm_primitives::calc_excess_blob_gas;
pub const fn validate_header_gas(header: &Header) -> Result<(), ConsensusError> {
if header.gas_used > header.gas_limit {
return Err(ConsensusError::HeaderGasUsedExceedsGasLimit {
gas_used: header.gas_used as u64,
gas_limit: header.gas_limit as u64,
gas_used: header.gas_used,
gas_limit: header.gas_limit,
})
}
Ok(())
Expand Down Expand Up @@ -66,8 +66,7 @@ pub fn validate_shanghai_withdrawals(block: &SealedBlock) -> Result<(), Consensu
pub fn validate_cancun_gas(block: &SealedBlock) -> Result<(), ConsensusError> {
// Check that the blob gas used in the header matches the sum of the blob gas used by each
// blob tx
let header_blob_gas_used =
block.blob_gas_used.ok_or(ConsensusError::BlobGasUsedMissing)? as u64;
let header_blob_gas_used = block.blob_gas_used.ok_or(ConsensusError::BlobGasUsedMissing)?;
let total_blob_gas = block.blob_gas_used();
if total_blob_gas != header_blob_gas_used {
return Err(ConsensusError::BlobGasUsedDiff(GotExpected {
Expand Down Expand Up @@ -151,25 +150,25 @@ pub fn validate_4844_header_standalone(header: &Header) -> Result<(), ConsensusE
return Err(ConsensusError::ParentBeaconBlockRootMissing)
}

if blob_gas_used as u64 > MAX_DATA_GAS_PER_BLOCK {
if blob_gas_used > MAX_DATA_GAS_PER_BLOCK {
return Err(ConsensusError::BlobGasUsedExceedsMaxBlobGasPerBlock {
blob_gas_used: blob_gas_used as u64,
blob_gas_used,
max_blob_gas_per_block: MAX_DATA_GAS_PER_BLOCK,
})
}

if blob_gas_used as u64 % DATA_GAS_PER_BLOB != 0 {
if blob_gas_used % DATA_GAS_PER_BLOB != 0 {
return Err(ConsensusError::BlobGasUsedNotMultipleOfBlobGasPerBlob {
blob_gas_used: blob_gas_used as u64,
blob_gas_used,
blob_gas_per_blob: DATA_GAS_PER_BLOB,
})
}

// `excess_blob_gas` must also be a multiple of `DATA_GAS_PER_BLOB`. This will be checked later
// (via `calc_excess_blob_gas`), but it doesn't hurt to catch the problem sooner.
if excess_blob_gas as u64 % DATA_GAS_PER_BLOB != 0 {
if excess_blob_gas % DATA_GAS_PER_BLOB != 0 {
return Err(ConsensusError::ExcessBlobGasNotMultipleOfBlobGasPerBlob {
excess_blob_gas: excess_blob_gas as u64,
excess_blob_gas,
blob_gas_per_blob: DATA_GAS_PER_BLOB,
})
}
Expand Down Expand Up @@ -225,7 +224,7 @@ pub fn validate_against_parent_eip1559_base_fee<ChainSpec: EthChainSpec + Ethere
chain_spec: &ChainSpec,
) -> Result<(), ConsensusError> {
if chain_spec.fork(EthereumHardfork::London).active_at_block(header.number) {
let base_fee = header.base_fee_per_gas.ok_or(ConsensusError::BaseFeeMissing)? as u64;
let base_fee = header.base_fee_per_gas.ok_or(ConsensusError::BaseFeeMissing)?;

let expected_base_fee =
if chain_spec.fork(EthereumHardfork::London).transitions_at_block(header.number) {
Expand All @@ -235,7 +234,7 @@ pub fn validate_against_parent_eip1559_base_fee<ChainSpec: EthChainSpec + Ethere
// them.
parent
.next_block_base_fee(chain_spec.base_fee_params_at_timestamp(header.timestamp))
.ok_or(ConsensusError::BaseFeeMissing)? as u64
.ok_or(ConsensusError::BaseFeeMissing)?
};
if expected_base_fee != base_fee {
return Err(ConsensusError::BaseFeeDiff(GotExpected {
Expand Down Expand Up @@ -277,14 +276,13 @@ pub fn validate_against_parent_4844(
// > are evaluated as 0.
//
// This means in the first post-fork block, calc_excess_blob_gas will return 0.
let parent_blob_gas_used = parent.blob_gas_used.unwrap_or(0) as u64;
let parent_excess_blob_gas = parent.excess_blob_gas.unwrap_or(0) as u64;
let parent_blob_gas_used = parent.blob_gas_used.unwrap_or(0);
let parent_excess_blob_gas = parent.excess_blob_gas.unwrap_or(0);

if header.blob_gas_used.is_none() {
return Err(ConsensusError::BlobGasUsedMissing)
}
let excess_blob_gas =
header.excess_blob_gas.ok_or(ConsensusError::ExcessBlobGasMissing)? as u64;
let excess_blob_gas = header.excess_blob_gas.ok_or(ConsensusError::ExcessBlobGasMissing)?;

let expected_excess_blob_gas =
calc_excess_blob_gas(parent_excess_blob_gas, parent_blob_gas_used);
Expand Down Expand Up @@ -540,7 +538,7 @@ mod tests {
let transaction = mock_blob_tx(1, 10);

let sealed = Header {
base_fee_per_gas: Some(1337u128),
base_fee_per_gas: Some(1337),
withdrawals_root: Some(proofs::calculate_withdrawals_root(&[])),
blob_gas_used: Some(1),
transactions_root: proofs::calculate_transaction_root(&[transaction.clone()]),
Expand Down
8 changes: 4 additions & 4 deletions crates/consensus/debug-client/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,8 @@ pub fn block_to_execution_payload_v3(block: Block) -> ExecutionNewPayload {
logs_bloom: block.header.logs_bloom,
prev_randao: block.header.mix_hash.unwrap(),
block_number: block.header.number,
gas_limit: block.header.gas_limit.try_into().unwrap(),
gas_used: block.header.gas_used.try_into().unwrap(),
gas_limit: block.header.gas_limit,
gas_used: block.header.gas_used,
timestamp: block.header.timestamp,
extra_data: block.header.extra_data.clone(),
base_fee_per_gas: block.header.base_fee_per_gas.unwrap().try_into().unwrap(),
Expand All @@ -215,8 +215,8 @@ pub fn block_to_execution_payload_v3(block: Block) -> ExecutionNewPayload {
},
withdrawals: block.withdrawals.clone().unwrap_or_default(),
},
blob_gas_used: block.header.blob_gas_used.unwrap().try_into().unwrap(),
excess_blob_gas: block.header.excess_blob_gas.unwrap().try_into().unwrap(),
blob_gas_used: block.header.blob_gas_used.unwrap(),
excess_blob_gas: block.header.excess_blob_gas.unwrap(),
};

ExecutionNewPayload {
Expand Down
Loading

0 comments on commit a5538bc

Please sign in to comment.