mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
dev: add requests to EthBuiltPayload (#12072)
This commit is contained in:
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -8373,6 +8373,7 @@ dependencies = [
|
||||
name = "reth-payload-primitives"
|
||||
version = "1.1.0"
|
||||
dependencies = [
|
||||
"alloy-eips",
|
||||
"alloy-primitives",
|
||||
"alloy-rpc-types",
|
||||
"async-trait",
|
||||
|
||||
@ -62,14 +62,7 @@ impl<E: EngineTypes, ChainSpec: EthereumHardforks> EngineApiTestContext<E, Chain
|
||||
.chain_spec
|
||||
.is_prague_active_at_timestamp(payload_builder_attributes.timestamp())
|
||||
{
|
||||
let requests = payload
|
||||
.executed_block()
|
||||
.unwrap()
|
||||
.execution_outcome()
|
||||
.requests
|
||||
.first()
|
||||
.unwrap()
|
||||
.clone();
|
||||
let requests = payload.requests().unwrap();
|
||||
let envelope: <E as EngineTypes>::ExecutionPayloadEnvelopeV4 = payload.into();
|
||||
EngineApiClient::<E>::new_payload_v4(
|
||||
&self.engine_api_client,
|
||||
|
||||
@ -33,6 +33,8 @@ pub struct EthBuiltPayload {
|
||||
/// The blobs, proofs, and commitments in the block. If the block is pre-cancun, this will be
|
||||
/// empty.
|
||||
pub(crate) sidecars: Vec<BlobTransactionSidecar>,
|
||||
/// The requests of the payload
|
||||
pub(crate) requests: Option<Requests>,
|
||||
}
|
||||
|
||||
// === impl BuiltPayload ===
|
||||
@ -46,8 +48,9 @@ impl EthBuiltPayload {
|
||||
block: SealedBlock,
|
||||
fees: U256,
|
||||
executed_block: Option<ExecutedBlock>,
|
||||
requests: Option<Requests>,
|
||||
) -> Self {
|
||||
Self { id, block, executed_block, fees, sidecars: Vec::new() }
|
||||
Self { id, block, executed_block, fees, sidecars: Vec::new(), requests }
|
||||
}
|
||||
|
||||
/// Returns the identifier of the payload.
|
||||
@ -97,6 +100,10 @@ impl BuiltPayload for EthBuiltPayload {
|
||||
fn executed_block(&self) -> Option<ExecutedBlock> {
|
||||
self.executed_block.clone()
|
||||
}
|
||||
|
||||
fn requests(&self) -> Option<Requests> {
|
||||
self.requests.clone()
|
||||
}
|
||||
}
|
||||
|
||||
impl BuiltPayload for &EthBuiltPayload {
|
||||
@ -111,6 +118,10 @@ impl BuiltPayload for &EthBuiltPayload {
|
||||
fn executed_block(&self) -> Option<ExecutedBlock> {
|
||||
self.executed_block.clone()
|
||||
}
|
||||
|
||||
fn requests(&self) -> Option<Requests> {
|
||||
self.requests.clone()
|
||||
}
|
||||
}
|
||||
|
||||
// V1 engine_getPayloadV1 response
|
||||
@ -152,15 +163,8 @@ impl From<EthBuiltPayload> for ExecutionPayloadEnvelopeV3 {
|
||||
|
||||
impl From<EthBuiltPayload> for ExecutionPayloadEnvelopeV4 {
|
||||
fn from(value: EthBuiltPayload) -> Self {
|
||||
let EthBuiltPayload { block, fees, sidecars, executed_block, .. } = value;
|
||||
let EthBuiltPayload { block, fees, sidecars, requests, .. } = value;
|
||||
|
||||
// if we have an executed block, we pop off the first set of requests from the execution
|
||||
// outcome. the assumption here is that there will always only be one block in the execution
|
||||
// outcome.
|
||||
let execution_requests = executed_block
|
||||
.and_then(|block| block.execution_outcome().requests.first().cloned())
|
||||
.map(Requests::take)
|
||||
.unwrap_or_default();
|
||||
Self {
|
||||
execution_payload: block_to_payload_v3(block),
|
||||
block_value: fees,
|
||||
@ -174,7 +178,7 @@ impl From<EthBuiltPayload> for ExecutionPayloadEnvelopeV4 {
|
||||
// <https://github.com/ethereum/execution-apis/blob/fe8e13c288c592ec154ce25c534e26cb7ce0530d/src/engine/cancun.md#specification-2>
|
||||
should_override_builder: false,
|
||||
blobs_bundle: sidecars.into_iter().map(Into::into).collect::<Vec<_>>().into(),
|
||||
execution_requests,
|
||||
execution_requests: requests.unwrap_or_default().take(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -360,7 +360,7 @@ where
|
||||
db.take_bundle(),
|
||||
vec![receipts].into(),
|
||||
block_number,
|
||||
vec![requests.unwrap_or_default()],
|
||||
vec![requests.clone().unwrap_or_default()],
|
||||
);
|
||||
let receipts_root =
|
||||
execution_outcome.receipts_root_slow(block_number).expect("Number is in range");
|
||||
@ -449,7 +449,8 @@ where
|
||||
trie: Arc::new(trie_output),
|
||||
};
|
||||
|
||||
let mut payload = EthBuiltPayload::new(attributes.id, sealed_block, total_fees, Some(executed));
|
||||
let mut payload =
|
||||
EthBuiltPayload::new(attributes.id, sealed_block, total_fees, Some(executed), requests);
|
||||
|
||||
// extend the payload with the blob sidecars from the executed txs
|
||||
payload.extend_sidecars(blob_sidecars);
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
//! Optimism builder support
|
||||
|
||||
use alloy_eips::eip2718::Decodable2718;
|
||||
use alloy_eips::{eip2718::Decodable2718, eip7685::Requests};
|
||||
use alloy_primitives::{Address, B256, U256};
|
||||
use alloy_rlp::Encodable;
|
||||
use alloy_rpc_types_engine::{ExecutionPayloadEnvelopeV2, ExecutionPayloadV1, PayloadId};
|
||||
@ -178,6 +178,10 @@ impl BuiltPayload for OptimismBuiltPayload {
|
||||
fn executed_block(&self) -> Option<ExecutedBlock> {
|
||||
self.executed_block.clone()
|
||||
}
|
||||
|
||||
fn requests(&self) -> Option<Requests> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl BuiltPayload for &OptimismBuiltPayload {
|
||||
@ -192,6 +196,10 @@ impl BuiltPayload for &OptimismBuiltPayload {
|
||||
fn executed_block(&self) -> Option<ExecutedBlock> {
|
||||
self.executed_block.clone()
|
||||
}
|
||||
|
||||
fn requests(&self) -> Option<Requests> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
// V1 engine_getPayloadV1 response
|
||||
|
||||
@ -65,7 +65,7 @@
|
||||
//! },
|
||||
//! ..Default::default()
|
||||
//! };
|
||||
//! let payload = EthBuiltPayload::new(self.attributes.id, payload.seal_slow(), U256::ZERO, None);
|
||||
//! let payload = EthBuiltPayload::new(self.attributes.id, payload.seal_slow(), U256::ZERO, None, None);
|
||||
//! Ok(payload)
|
||||
//! }
|
||||
//!
|
||||
|
||||
@ -89,6 +89,7 @@ impl PayloadJob for TestPayloadJob {
|
||||
Block::default().seal_slow(),
|
||||
U256::ZERO,
|
||||
Some(ExecutedBlock::default()),
|
||||
Some(Default::default()),
|
||||
))
|
||||
}
|
||||
|
||||
|
||||
@ -20,6 +20,7 @@ reth-transaction-pool.workspace = true
|
||||
reth-chain-state.workspace = true
|
||||
|
||||
# alloy
|
||||
alloy-eips.workspace = true
|
||||
alloy-primitives.workspace = true
|
||||
alloy-rpc-types = { workspace = true, features = ["engine"] }
|
||||
op-alloy-rpc-types-engine.workspace = true
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
use crate::{PayloadEvents, PayloadKind, PayloadTypes};
|
||||
use alloy_eips::eip7685::Requests;
|
||||
use alloy_primitives::{Address, B256, U256};
|
||||
use alloy_rpc_types::{
|
||||
engine::{PayloadAttributes as EthPayloadAttributes, PayloadId},
|
||||
@ -65,6 +66,9 @@ pub trait BuiltPayload: Send + Sync + std::fmt::Debug {
|
||||
fn executed_block(&self) -> Option<ExecutedBlock> {
|
||||
None
|
||||
}
|
||||
|
||||
/// Returns the EIP-7865 requests for the payload if any.
|
||||
fn requests(&self) -> Option<Requests>;
|
||||
}
|
||||
|
||||
/// This can be implemented by types that describe a currently running payload job.
|
||||
|
||||
Reference in New Issue
Block a user