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

chore(deps): bump revm, accomodate new cancun struct changes #5858

Merged
merged 1 commit into from
Sep 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
118 changes: 114 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions crates/anvil/core/src/eth/transaction/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1209,6 +1209,7 @@ impl PendingTransaction {
gas_priority_fee: None,
gas_limit: gas_limit.as_u64(),
access_list: vec![],
..Default::default()
}
}
TypedTransaction::EIP2930(tx) => {
Expand All @@ -1234,6 +1235,7 @@ impl PendingTransaction {
gas_priority_fee: None,
gas_limit: gas_limit.as_u64(),
access_list: to_revm_access_list(access_list.0.clone()),
..Default::default()
}
}
TypedTransaction::EIP1559(tx) => {
Expand All @@ -1260,6 +1262,7 @@ impl PendingTransaction {
gas_priority_fee: Some(u256_to_ru256(*max_priority_fee_per_gas)),
gas_limit: gas_limit.as_u64(),
access_list: to_revm_access_list(access_list.0.clone()),
..Default::default()
}
}
}
Expand Down
1 change: 1 addition & 0 deletions crates/anvil/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -894,6 +894,7 @@ latest block number: {latest_block}"
// Keep previous `coinbase` and `basefee` value
coinbase: env.block.coinbase,
basefee: env.block.basefee,
..Default::default()
};

// apply changes such as difficulty -> prevrandao
Expand Down
5 changes: 5 additions & 0 deletions crates/anvil/src/eth/backend/mem/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,7 @@ impl Backend {
// Keep previous `coinbase` and `basefee` value
coinbase: env.block.coinbase,
basefee: env.block.basefee,
..Default::default()
};

self.time.reset(ru256_to_u256(env.block.timestamp).as_u64());
Expand Down Expand Up @@ -1035,6 +1036,7 @@ impl Backend {
chain_id: None,
nonce: nonce.map(|n| n.as_u64()),
access_list: to_revm_access_list(access_list.unwrap_or_default()),
..Default::default()
};

if env.block.basefee == revm::primitives::U256::ZERO {
Expand Down Expand Up @@ -1068,6 +1070,7 @@ impl Backend {
}
EVMError::PrevrandaoNotSet => return Err(BlockchainError::PrevrandaoNotSet),
EVMError::Database(e) => return Err(BlockchainError::DatabaseError(e)),
EVMError::ExcessBlobGasNotSet => return Err(BlockchainError::ExcessBlobGasNotSet),
},
};
let state = result_and_state.state;
Expand Down Expand Up @@ -1594,6 +1597,7 @@ impl Backend {
block.header.base_fee_per_gas.unwrap_or_default(),
),
gas_limit: u256_to_ru256(block.header.gas_limit),
..Default::default()
};
f(state, block)
})
Expand Down Expand Up @@ -1621,6 +1625,7 @@ impl Backend {
prevrandao: Some(block.header.mix_hash).map(h256_to_b256),
basefee: u256_to_ru256(block.header.base_fee_per_gas.unwrap_or_default()),
gas_limit: u256_to_ru256(block.header.gas_limit),
..Default::default()
};
return Ok(f(Box::new(state), block))
}
Expand Down
26 changes: 26 additions & 0 deletions crates/anvil/src/eth/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ pub enum BlockchainError {
EIP1559TransactionUnsupportedAtHardfork,
#[error("Access list received but is not supported by the current hardfork.\n\nYou can use it by running anvil with '--hardfork berlin' or later.")]
EIP2930TransactionUnsupportedAtHardfork,
#[error("Excess blob gas not set.")]
ExcessBlobGasNotSet,
}

impl From<RpcError> for BlockchainError {
Expand All @@ -98,6 +100,7 @@ where
EVMError::Transaction(err) => InvalidTransactionError::from(err).into(),
EVMError::PrevrandaoNotSet => BlockchainError::PrevrandaoNotSet,
EVMError::Database(err) => err.into(),
EVMError::ExcessBlobGasNotSet => BlockchainError::ExcessBlobGasNotSet,
}
}
}
Expand Down Expand Up @@ -184,6 +187,17 @@ pub enum InvalidTransactionError {
/// Thrown when an access list is used before the berlin hard fork.
#[error("Access lists are not supported before the Berlin hardfork")]
AccessListNotSupported,
/// Thrown when the block's `blob_gas_price` is greater than tx-specified
/// `max_fee_per_blob_gas` after Cancun.
#[error("Block `blob_gas_price` is greater than tx-specified `max_fee_per_blob_gas`")]
BlobGasPriceGreaterThanMax,
/// Thrown when we receive a tx with `blob_versioned_hashes` and we're not on the Cancun hard
/// fork.
#[error("Block `blob_versioned_hashes` is not supported before the Cancun hardfork")]
BlobVersionedHashesNotSupported,
/// Thrown when `max_fee_per_blob_gas` is not supported for blocks before the Cancun hardfork.
#[error("`max_fee_per_blob_gas` is not supported for blocks before the Cancun hardfork.")]
MaxFeePerBlobGasNotSupported,
}

impl From<revm::primitives::InvalidTransaction> for InvalidTransactionError {
Expand Down Expand Up @@ -223,6 +237,15 @@ impl From<revm::primitives::InvalidTransaction> for InvalidTransactionError {
InvalidTransaction::AccessListNotSupported => {
InvalidTransactionError::AccessListNotSupported
}
InvalidTransaction::BlobGasPriceGreaterThanMax => {
InvalidTransactionError::BlobGasPriceGreaterThanMax
}
InvalidTransaction::BlobVersionedHashesNotSupported => {
InvalidTransactionError::BlobVersionedHashesNotSupported
}
InvalidTransaction::MaxFeePerBlobGasNotSupported => {
InvalidTransactionError::MaxFeePerBlobGasNotSupported
}
}
}
}
Expand Down Expand Up @@ -374,6 +397,9 @@ impl<T: Serialize> ToRpcResponseResult for Result<T> {
err @ BlockchainError::EIP2930TransactionUnsupportedAtHardfork => {
RpcError::invalid_params(err.to_string())
}
err @ BlockchainError::ExcessBlobGasNotSet => {
RpcError::invalid_params(err.to_string())
}
}
.into(),
}
Expand Down
1 change: 1 addition & 0 deletions crates/evm/src/executor/fork/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ where
prevrandao: Some(block.mix_hash.map(h256_to_b256).unwrap_or_default()),
basefee: u256_to_ru256(block.base_fee_per_gas.unwrap_or_default()),
gas_limit: u256_to_ru256(block.gas_limit),
..Default::default()
},
tx: TxEnv {
caller: origin,
Expand Down
1 change: 1 addition & 0 deletions crates/evm/src/executor/opts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ impl EvmOpts {
prevrandao: Some(self.env.block_prevrandao),
basefee: U256::from(self.env.block_base_fee_per_gas),
gas_limit: self.gas_limit(),
..Default::default()
},
cfg,
tx: TxEnv {
Expand Down