-
Notifications
You must be signed in to change notification settings - Fork 870
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
feat: Eip 6110 #8204
feat: Eip 6110 #8204
Changes from 1 commit
ace5ef7
46aa6a2
d9e16ef
938ae94
0da8fef
2162971
70e1094
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -106,6 +106,24 @@ where | |||||
} | ||||||
} | ||||||
} | ||||||
// EIP-6110 | ||||||
use alloy_eips::eip6110::{DepositRequest, MAINNET_DEPOSIT_CONTRACT_ADDRESS}; | ||||||
use alloy_rlp::Decodable; | ||||||
|
||||||
fn parse_deposits_from_receipts( | ||||||
receipts: &[Receipt], | ||||||
) -> Result<Vec<Request>, BlockValidationError> { | ||||||
let res = receipts | ||||||
.iter() | ||||||
.flat_map(|receipt| receipt.logs.iter()) | ||||||
.filter(|log| log.address == MAINNET_DEPOSIT_CONTRACT_ADDRESS) | ||||||
.map(|log| DepositRequest::decode(&mut log.data.data.as_ref())) | ||||||
.map(|res| res.map(Request::DepositRequest)) | ||||||
.collect::<Result<Vec<_>, _>>() | ||||||
// ugly | ||||||
.map_err(|err| BlockValidationError::DepositRequestDecode(err.to_string()))?; | ||||||
Ok(res) | ||||||
} | ||||||
|
||||||
/// Helper type for the output of executing a block. | ||||||
#[derive(Debug, Clone)] | ||||||
|
@@ -168,7 +186,7 @@ where | |||||
transaction_gas_limit: transaction.gas_limit(), | ||||||
block_available_gas, | ||||||
} | ||||||
.into()) | ||||||
.into()); | ||||||
} | ||||||
|
||||||
EvmConfig::fill_tx_env(evm.tx_mut(), transaction, *sender); | ||||||
|
@@ -209,13 +227,17 @@ where | |||||
gas: GotExpected { got: cumulative_gas_used, expected: block.gas_used }, | ||||||
gas_spent_by_tx: receipts.gas_spent_by_tx()?, | ||||||
} | ||||||
.into()) | ||||||
.into()); | ||||||
} | ||||||
|
||||||
// Collect all EIP-6110 deposits | ||||||
let deposits = parse_deposits_from_receipts(&receipts)?; | ||||||
|
||||||
// Collect all EIP-7685 requests | ||||||
let withdrawal_requests = | ||||||
post_block_withdrawal_requests(&self.chain_spec, block.timestamp, &mut evm)?; | ||||||
let requests = withdrawal_requests; | ||||||
// TODO: Does order matter? | ||||||
let requests = [deposits, withdrawal_requests].concat(); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes and this is the correct order
gakonst marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
||||||
Ok(EthExecuteOutput { receipts, requests, gas_used: cumulative_gas_used }) | ||||||
} | ||||||
|
@@ -311,7 +333,7 @@ where | |||||
receipts.iter(), | ||||||
) { | ||||||
debug!(target: "evm", %error, ?receipts, "receipts verification failed"); | ||||||
return Err(error) | ||||||
return Err(error); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hehe
Suggested change
|
||||||
}; | ||||||
} | ||||||
|
||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -88,12 +88,21 @@ pub enum BlockValidationError { | |
/// The error message. | ||
message: String, | ||
}, | ||
/// EVM error during withdrawal requests contract call | ||
/// EVM error during withdrawal requests contract call [EIP-7002] | ||
/// | ||
/// [EIP-7002]: https://eips.ethereum.org/EIPS/eip-7002 | ||
#[error("failed to apply withdrawal requests contract call: {message}")] | ||
WithdrawalRequestsContractCall { | ||
/// The error message. | ||
message: String, | ||
}, | ||
/// Error when decoding deposit requests from receipts [EIP-6110] | ||
/// | ||
/// [EIP-6110]: https://eips.ethereum.org/EIPS/eip-6110 | ||
// TODO(gakonst): This is an RLP decoding error but we don't import alloy_rlp here, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why not? It should be in reth_primitives already |
||
// do we want to? | ||
#[error("could not decode deposit request: {0}")] | ||
DepositRequestDecode(String), | ||
} | ||
|
||
/// BlockExecutor Errors | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should accumulate, extending a vector, rather than two vecs and concatenating after. Can be done with &mut Vec as argument and transforming the iterator into a for loop
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The withdrawal function returns a
Vec<Request>
viaVec<Request>::decode
and I cannot break out of the iterator without collecting so not sure how to do that here, also prob not big perf given smol listThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i see, what about moving the parse_deposits to after post_block and extending that list?