mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-01-30 09:38:24 -05:00
fix: return null withdrawals (#3762)
This commit is contained in:
@@ -2,7 +2,7 @@ use jsonrpsee::{core::RpcResult, proc_macros::rpc};
|
||||
use reth_primitives::{Address, BlockHash, BlockId, BlockNumberOrTag, Bytes, H256, U256, U64};
|
||||
use reth_rpc_types::{
|
||||
engine::{
|
||||
ExecutionPayload, ExecutionPayloadBodies, ExecutionPayloadEnvelope, ForkchoiceState,
|
||||
ExecutionPayload, ExecutionPayloadBodiesV1, ExecutionPayloadEnvelope, ForkchoiceState,
|
||||
ForkchoiceUpdated, PayloadAttributes, PayloadId, PayloadStatus, TransitionConfiguration,
|
||||
},
|
||||
state::StateOverride,
|
||||
@@ -64,7 +64,7 @@ pub trait EngineApi {
|
||||
async fn get_payload_bodies_by_hash_v1(
|
||||
&self,
|
||||
block_hashes: Vec<BlockHash>,
|
||||
) -> RpcResult<ExecutionPayloadBodies>;
|
||||
) -> RpcResult<ExecutionPayloadBodiesV1>;
|
||||
|
||||
/// See also <https://github.com/ethereum/execution-apis/blob/6452a6b194d7db269bf1dbd087a267251d3cc7f8/src/engine/shanghai.md#engine_getpayloadbodiesbyrangev1>
|
||||
///
|
||||
@@ -83,7 +83,7 @@ pub trait EngineApi {
|
||||
&self,
|
||||
start: U64,
|
||||
count: U64,
|
||||
) -> RpcResult<ExecutionPayloadBodies>;
|
||||
) -> RpcResult<ExecutionPayloadBodiesV1>;
|
||||
|
||||
/// See also <https://github.com/ethereum/execution-apis/blob/6709c2a795b707202e93c4f2867fa0bf2640a84f/src/engine/paris.md#engine_exchangetransitionconfigurationv1>
|
||||
#[method(name = "exchangeTransitionConfigurationV1")]
|
||||
|
||||
@@ -8,7 +8,7 @@ use reth_primitives::{BlockHash, BlockHashOrNumber, BlockNumber, ChainSpec, Hard
|
||||
use reth_provider::{BlockReader, EvmEnvProvider, HeaderProvider, StateProviderFactory};
|
||||
use reth_rpc_api::EngineApiServer;
|
||||
use reth_rpc_types::engine::{
|
||||
ExecutionPayload, ExecutionPayloadBodies, ExecutionPayloadEnvelope, ForkchoiceUpdated,
|
||||
ExecutionPayload, ExecutionPayloadBodiesV1, ExecutionPayloadEnvelope, ForkchoiceUpdated,
|
||||
PayloadAttributes, PayloadId, PayloadStatus, TransitionConfiguration, CAPABILITIES,
|
||||
};
|
||||
use reth_tasks::TaskSpawner;
|
||||
@@ -183,7 +183,7 @@ where
|
||||
&self,
|
||||
start: BlockNumber,
|
||||
count: u64,
|
||||
) -> EngineApiResult<ExecutionPayloadBodies> {
|
||||
) -> EngineApiResult<ExecutionPayloadBodiesV1> {
|
||||
let (tx, rx) = oneshot::channel();
|
||||
let inner = self.inner.clone();
|
||||
|
||||
@@ -223,7 +223,7 @@ where
|
||||
pub fn get_payload_bodies_by_hash(
|
||||
&self,
|
||||
hashes: Vec<BlockHash>,
|
||||
) -> EngineApiResult<ExecutionPayloadBodies> {
|
||||
) -> EngineApiResult<ExecutionPayloadBodiesV1> {
|
||||
let len = hashes.len() as u64;
|
||||
if len > MAX_PAYLOAD_BODIES_LIMIT {
|
||||
return Err(EngineApiError::PayloadRequestTooLarge { len })
|
||||
@@ -414,7 +414,7 @@ where
|
||||
async fn get_payload_bodies_by_hash_v1(
|
||||
&self,
|
||||
block_hashes: Vec<BlockHash>,
|
||||
) -> RpcResult<ExecutionPayloadBodies> {
|
||||
) -> RpcResult<ExecutionPayloadBodiesV1> {
|
||||
trace!(target: "rpc::engine", "Serving engine_getPayloadBodiesByHashV1");
|
||||
Ok(EngineApi::get_payload_bodies_by_hash(self, block_hashes)?)
|
||||
}
|
||||
@@ -432,11 +432,13 @@ where
|
||||
/// Implementors should take care when acting on the input to this method, specifically
|
||||
/// ensuring that the range is limited properly, and that the range boundaries are computed
|
||||
/// correctly and without panics.
|
||||
///
|
||||
/// Note: If a block is pre shanghai, `withdrawals` field will be `null
|
||||
async fn get_payload_bodies_by_range_v1(
|
||||
&self,
|
||||
start: U64,
|
||||
count: U64,
|
||||
) -> RpcResult<ExecutionPayloadBodies> {
|
||||
) -> RpcResult<ExecutionPayloadBodiesV1> {
|
||||
trace!(target: "rpc::engine", "Serving engine_getPayloadBodiesByRangeV1");
|
||||
Ok(EngineApi::get_payload_bodies_by_range(self, start.as_u64(), count.as_u64()).await?)
|
||||
}
|
||||
@@ -482,7 +484,7 @@ mod tests {
|
||||
let provider = Arc::new(MockEthProvider::default());
|
||||
let payload_store = spawn_test_payload_service();
|
||||
let (to_engine, engine_rx) = unbounded_channel();
|
||||
let task_executor = Box::new(TokioTaskExecutor::default());
|
||||
let task_executor = Box::<TokioTaskExecutor>::default();
|
||||
let api = EngineApi::new(
|
||||
provider.clone(),
|
||||
chain_spec.clone(),
|
||||
|
||||
@@ -8,7 +8,7 @@ use reth_rlp::Decodable;
|
||||
use serde::{ser::SerializeMap, Deserialize, Serialize, Serializer};
|
||||
|
||||
/// The execution payload body response that allows for `null` values.
|
||||
pub type ExecutionPayloadBodies = Vec<Option<ExecutionPayloadBody>>;
|
||||
pub type ExecutionPayloadBodiesV1 = Vec<Option<ExecutionPayloadBodyV1>>;
|
||||
|
||||
/// And 8-byte identifier for an execution payload.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize, Hash)]
|
||||
@@ -220,21 +220,25 @@ impl PayloadError {
|
||||
///
|
||||
/// See also: <https://github.com/ethereum/execution-apis/blob/6452a6b194d7db269bf1dbd087a267251d3cc7f8/src/engine/shanghai.md#executionpayloadbodyv1>
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct ExecutionPayloadBody {
|
||||
pub struct ExecutionPayloadBodyV1 {
|
||||
/// Enveloped encoded transactions.
|
||||
pub transactions: Vec<Bytes>,
|
||||
pub withdrawals: Vec<Withdrawal>,
|
||||
/// All withdrawals in the block.
|
||||
///
|
||||
/// Will always be `None` if pre shanghai.
|
||||
pub withdrawals: Option<Vec<Withdrawal>>,
|
||||
}
|
||||
|
||||
impl From<Block> for ExecutionPayloadBody {
|
||||
impl From<Block> for ExecutionPayloadBodyV1 {
|
||||
fn from(value: Block) -> Self {
|
||||
let transactions = value.body.into_iter().map(|tx| {
|
||||
let mut out = Vec::new();
|
||||
tx.encode_enveloped(&mut out);
|
||||
out.into()
|
||||
});
|
||||
ExecutionPayloadBody {
|
||||
ExecutionPayloadBodyV1 {
|
||||
transactions: transactions.collect(),
|
||||
withdrawals: value.withdrawals.unwrap_or_default(),
|
||||
withdrawals: value.withdrawals,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -456,7 +460,7 @@ mod tests {
|
||||
let mut rng = generators::rng();
|
||||
for block in random_block_range(&mut rng, 0..=99, H256::default(), 0..2) {
|
||||
let unsealed = block.clone().unseal();
|
||||
let payload_body: ExecutionPayloadBody = unsealed.into();
|
||||
let payload_body: ExecutionPayloadBodyV1 = unsealed.into();
|
||||
|
||||
assert_eq!(
|
||||
Ok(block.body),
|
||||
@@ -467,7 +471,7 @@ mod tests {
|
||||
.collect::<Result<Vec<_>, _>>(),
|
||||
);
|
||||
|
||||
assert_eq!(block.withdrawals.unwrap_or_default(), payload_body.withdrawals);
|
||||
assert_eq!(block.withdrawals, payload_body.withdrawals);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user