mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat: add transact function to 7251 (#11158)
This commit is contained in:
@ -48,11 +48,13 @@ where
|
||||
///
|
||||
/// If Prague is not active at the given timestamp, then this is a no-op, and an empty vector is
|
||||
/// returned. Otherwise, the consolidation requests are returned.
|
||||
///
|
||||
/// Note: this does not commit the state changes to the database, it only transact the call.
|
||||
#[inline]
|
||||
pub fn apply_consolidation_requests_contract_call<EvmConfig, EXT, DB>(
|
||||
pub fn transact_consolidation_requests_contract_call<EvmConfig, EXT, DB>(
|
||||
evm_config: &EvmConfig,
|
||||
evm: &mut Evm<'_, EXT, DB>,
|
||||
) -> Result<Vec<Request>, BlockExecutionError>
|
||||
) -> Result<ResultAndState, BlockExecutionError>
|
||||
where
|
||||
DB: Database + DatabaseCommit,
|
||||
DB::Error: core::fmt::Display,
|
||||
@ -77,7 +79,7 @@ where
|
||||
Bytes::new(),
|
||||
);
|
||||
|
||||
let ResultAndState { result, mut state } = match evm.transact() {
|
||||
let mut res = match evm.transact() {
|
||||
Ok(res) => res,
|
||||
Err(e) => {
|
||||
evm.context.evm.env = previous_env;
|
||||
@ -89,13 +91,35 @@ where
|
||||
};
|
||||
|
||||
// cleanup the state
|
||||
state.remove(&alloy_eips::eip7002::SYSTEM_ADDRESS);
|
||||
state.remove(&evm.block().coinbase);
|
||||
evm.context.evm.db.commit(state);
|
||||
res.state.remove(&alloy_eips::eip7002::SYSTEM_ADDRESS);
|
||||
res.state.remove(&evm.block().coinbase);
|
||||
|
||||
// re-set the previous env
|
||||
evm.context.evm.env = previous_env;
|
||||
|
||||
Ok(res)
|
||||
}
|
||||
|
||||
/// Applies the post-block call to the EIP-7251 consolidation requests contract.
|
||||
///
|
||||
/// If Prague is not active at the given timestamp, then this is a no-op, and an empty vector is
|
||||
/// returned. Otherwise, the consolidation requests are returned.
|
||||
#[inline]
|
||||
pub fn apply_consolidation_requests_contract_call<EvmConfig, EXT, DB>(
|
||||
evm_config: &EvmConfig,
|
||||
evm: &mut Evm<'_, EXT, DB>,
|
||||
) -> Result<Vec<Request>, BlockExecutionError>
|
||||
where
|
||||
DB: Database + DatabaseCommit,
|
||||
DB::Error: core::fmt::Display,
|
||||
EvmConfig: ConfigureEvm<Header = Header>,
|
||||
{
|
||||
let ResultAndState { result, state } =
|
||||
transact_consolidation_requests_contract_call(evm_config, evm)?;
|
||||
|
||||
// commit the state
|
||||
evm.context.evm.db.commit(state);
|
||||
|
||||
let mut data = match result {
|
||||
ExecutionResult::Success { output, .. } => Ok(output.into_data()),
|
||||
ExecutionResult::Revert { output, .. } => {
|
||||
|
||||
Reference in New Issue
Block a user