mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
chore: small Requests clean up (#13374)
This commit is contained in:
@ -6,7 +6,7 @@ use crate::{
|
|||||||
};
|
};
|
||||||
use alloc::{boxed::Box, sync::Arc, vec::Vec};
|
use alloc::{boxed::Box, sync::Arc, vec::Vec};
|
||||||
use alloy_consensus::Transaction as _;
|
use alloy_consensus::Transaction as _;
|
||||||
use alloy_eips::eip7685::Requests;
|
use alloy_eips::{eip6110, eip7685::Requests};
|
||||||
use core::fmt::Display;
|
use core::fmt::Display;
|
||||||
use reth_chainspec::{ChainSpec, EthereumHardfork, EthereumHardforks, MAINNET};
|
use reth_chainspec::{ChainSpec, EthereumHardfork, EthereumHardforks, MAINNET};
|
||||||
use reth_consensus::ConsensusError;
|
use reth_consensus::ConsensusError;
|
||||||
@ -246,7 +246,7 @@ where
|
|||||||
let mut requests = Requests::default();
|
let mut requests = Requests::default();
|
||||||
|
|
||||||
if !deposit_requests.is_empty() {
|
if !deposit_requests.is_empty() {
|
||||||
requests.push_request(core::iter::once(0).chain(deposit_requests).collect());
|
requests.push_request_with_type(eip6110::DEPOSIT_REQUEST_TYPE, deposit_requests);
|
||||||
}
|
}
|
||||||
|
|
||||||
requests.extend(self.system_caller.apply_post_execution_changes(&mut evm)?);
|
requests.extend(self.system_caller.apply_post_execution_changes(&mut evm)?);
|
||||||
|
|||||||
@ -11,8 +11,7 @@
|
|||||||
|
|
||||||
use alloy_consensus::{Header, EMPTY_OMMER_ROOT_HASH};
|
use alloy_consensus::{Header, EMPTY_OMMER_ROOT_HASH};
|
||||||
use alloy_eips::{
|
use alloy_eips::{
|
||||||
eip4844::MAX_DATA_GAS_PER_BLOCK, eip7002::WITHDRAWAL_REQUEST_TYPE,
|
eip4844::MAX_DATA_GAS_PER_BLOCK, eip6110, eip7685::Requests, merge::BEACON_NONCE,
|
||||||
eip7251::CONSOLIDATION_REQUEST_TYPE, eip7685::Requests, merge::BEACON_NONCE,
|
|
||||||
};
|
};
|
||||||
use alloy_primitives::U256;
|
use alloy_primitives::U256;
|
||||||
use reth_basic_payload_builder::{
|
use reth_basic_payload_builder::{
|
||||||
@ -357,11 +356,11 @@ where
|
|||||||
executed_txs.push(tx.into_signed());
|
executed_txs.push(tx.into_signed());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Release db
|
|
||||||
drop(evm);
|
|
||||||
|
|
||||||
// check if we have a better block
|
// check if we have a better block
|
||||||
if !is_better_payload(best_payload.as_ref(), total_fees) {
|
if !is_better_payload(best_payload.as_ref(), total_fees) {
|
||||||
|
// Release db
|
||||||
|
drop(evm);
|
||||||
|
|
||||||
// can skip building the block
|
// can skip building the block
|
||||||
return Ok(BuildOutcome::Aborted { fees: total_fees, cached_reads })
|
return Ok(BuildOutcome::Aborted { fees: total_fees, cached_reads })
|
||||||
}
|
}
|
||||||
@ -370,46 +369,27 @@ where
|
|||||||
let requests = if chain_spec.is_prague_active_at_timestamp(attributes.timestamp) {
|
let requests = if chain_spec.is_prague_active_at_timestamp(attributes.timestamp) {
|
||||||
let deposit_requests = parse_deposits_from_receipts(&chain_spec, receipts.iter().flatten())
|
let deposit_requests = parse_deposits_from_receipts(&chain_spec, receipts.iter().flatten())
|
||||||
.map_err(|err| PayloadBuilderError::Internal(RethError::Execution(err.into())))?;
|
.map_err(|err| PayloadBuilderError::Internal(RethError::Execution(err.into())))?;
|
||||||
let withdrawal_requests = system_caller
|
|
||||||
.post_block_withdrawal_requests_contract_call(
|
|
||||||
&mut db,
|
|
||||||
&initialized_cfg,
|
|
||||||
&initialized_block_env,
|
|
||||||
)
|
|
||||||
.map_err(|err| PayloadBuilderError::Internal(err.into()))?;
|
|
||||||
let consolidation_requests = system_caller
|
|
||||||
.post_block_consolidation_requests_contract_call(
|
|
||||||
&mut db,
|
|
||||||
&initialized_cfg,
|
|
||||||
&initialized_block_env,
|
|
||||||
)
|
|
||||||
.map_err(|err| PayloadBuilderError::Internal(err.into()))?;
|
|
||||||
|
|
||||||
let mut requests = Requests::default();
|
let mut requests = Requests::default();
|
||||||
|
|
||||||
if !deposit_requests.is_empty() {
|
if !deposit_requests.is_empty() {
|
||||||
requests.push_request(core::iter::once(0).chain(deposit_requests).collect());
|
requests.push_request_with_type(eip6110::DEPOSIT_REQUEST_TYPE, deposit_requests);
|
||||||
}
|
}
|
||||||
|
|
||||||
if !withdrawal_requests.is_empty() {
|
requests.extend(
|
||||||
requests.push_request(
|
system_caller
|
||||||
core::iter::once(WITHDRAWAL_REQUEST_TYPE).chain(withdrawal_requests).collect(),
|
.apply_post_execution_changes(&mut evm)
|
||||||
);
|
.map_err(|err| PayloadBuilderError::Internal(err.into()))?,
|
||||||
}
|
);
|
||||||
|
|
||||||
if !consolidation_requests.is_empty() {
|
|
||||||
requests.push_request(
|
|
||||||
core::iter::once(CONSOLIDATION_REQUEST_TYPE)
|
|
||||||
.chain(consolidation_requests)
|
|
||||||
.collect(),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Some(requests)
|
Some(requests)
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Release db
|
||||||
|
drop(evm);
|
||||||
|
|
||||||
let withdrawals_root =
|
let withdrawals_root =
|
||||||
commit_withdrawals(&mut db, &chain_spec, attributes.timestamp, &attributes.withdrawals)?;
|
commit_withdrawals(&mut db, &chain_spec, attributes.timestamp, &attributes.withdrawals)?;
|
||||||
|
|
||||||
|
|||||||
@ -134,19 +134,13 @@ where
|
|||||||
// Collect all EIP-7685 requests
|
// Collect all EIP-7685 requests
|
||||||
let withdrawal_requests = self.apply_withdrawal_requests_contract_call(evm)?;
|
let withdrawal_requests = self.apply_withdrawal_requests_contract_call(evm)?;
|
||||||
if !withdrawal_requests.is_empty() {
|
if !withdrawal_requests.is_empty() {
|
||||||
requests.push_request(
|
requests.push_request_with_type(WITHDRAWAL_REQUEST_TYPE, withdrawal_requests);
|
||||||
core::iter::once(WITHDRAWAL_REQUEST_TYPE).chain(withdrawal_requests).collect(),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Collect all EIP-7251 requests
|
// Collect all EIP-7251 requests
|
||||||
let consolidation_requests = self.apply_consolidation_requests_contract_call(evm)?;
|
let consolidation_requests = self.apply_consolidation_requests_contract_call(evm)?;
|
||||||
if !consolidation_requests.is_empty() {
|
if !consolidation_requests.is_empty() {
|
||||||
requests.push_request(
|
requests.push_request_with_type(CONSOLIDATION_REQUEST_TYPE, consolidation_requests);
|
||||||
core::iter::once(CONSOLIDATION_REQUEST_TYPE)
|
|
||||||
.chain(consolidation_requests)
|
|
||||||
.collect(),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(requests)
|
Ok(requests)
|
||||||
|
|||||||
Reference in New Issue
Block a user