diff --git a/crates/rpc/rpc-types/src/eth/engine/beacon_api/events/attestation.rs b/crates/rpc/rpc-types/src/beacon/events/attestation.rs similarity index 100% rename from crates/rpc/rpc-types/src/eth/engine/beacon_api/events/attestation.rs rename to crates/rpc/rpc-types/src/beacon/events/attestation.rs diff --git a/crates/rpc/rpc-types/src/eth/engine/beacon_api/events/light_client_finality.rs b/crates/rpc/rpc-types/src/beacon/events/light_client_finality.rs similarity index 100% rename from crates/rpc/rpc-types/src/eth/engine/beacon_api/events/light_client_finality.rs rename to crates/rpc/rpc-types/src/beacon/events/light_client_finality.rs diff --git a/crates/rpc/rpc-types/src/eth/engine/beacon_api/events/light_client_optimistic.rs b/crates/rpc/rpc-types/src/beacon/events/light_client_optimistic.rs similarity index 100% rename from crates/rpc/rpc-types/src/eth/engine/beacon_api/events/light_client_optimistic.rs rename to crates/rpc/rpc-types/src/beacon/events/light_client_optimistic.rs diff --git a/crates/rpc/rpc-types/src/eth/engine/beacon_api/events/mod.rs b/crates/rpc/rpc-types/src/beacon/events/mod.rs similarity index 100% rename from crates/rpc/rpc-types/src/eth/engine/beacon_api/events/mod.rs rename to crates/rpc/rpc-types/src/beacon/events/mod.rs diff --git a/crates/rpc/rpc-types/src/beacon/mod.rs b/crates/rpc/rpc-types/src/beacon/mod.rs index c0166413ba325..7264a9036dbea 100644 --- a/crates/rpc/rpc-types/src/beacon/mod.rs +++ b/crates/rpc/rpc-types/src/beacon/mod.rs @@ -5,6 +5,8 @@ use alloy_primitives::FixedBytes; use constants::{BLS_PUBLIC_KEY_BYTES_LEN, BLS_SIGNATURE_BYTES_LEN}; pub mod constants; +/// Beacon API events support. +pub mod events; pub mod payload; pub mod withdrawals; diff --git a/crates/rpc/rpc-types/src/beacon/payload.rs b/crates/rpc/rpc-types/src/beacon/payload.rs index e92bfc14ef41f..847c66091d897 100644 --- a/crates/rpc/rpc-types/src/beacon/payload.rs +++ b/crates/rpc/rpc-types/src/beacon/payload.rs @@ -1,4 +1,4 @@ -#![allow(missing_docs, private_interfaces)] +#![allow(missing_docs)] //! Payload support for the beacon API. //! //! Internal helper module to deserialize/serialize the payload attributes for the beacon API, which @@ -9,10 +9,9 @@ //! //! See also -pub use crate::Withdrawal; use crate::{ beacon::withdrawals::BeaconWithdrawal, engine::ExecutionPayloadV3, ExecutionPayload, - ExecutionPayloadV1, ExecutionPayloadV2, + ExecutionPayloadV1, ExecutionPayloadV2, Withdrawal, }; use alloy_primitives::{Address, Bloom, Bytes, B256, U256, U64}; use serde::{Deserialize, Deserializer, Serialize, Serializer}; @@ -80,25 +79,26 @@ pub mod beacon_api_payload_attributes { #[serde_as] #[derive(Debug, Serialize, Deserialize)] -pub(crate) struct BeaconExecutionPayloadV1<'a> { - pub(crate) parent_hash: Cow<'a, B256>, - pub(crate) fee_recipient: Cow<'a, Address>, - pub(crate) state_root: Cow<'a, B256>, - pub(crate) receipts_root: Cow<'a, B256>, - pub(crate) logs_bloom: Cow<'a, Bloom>, - pub(crate) prev_randao: Cow<'a, B256>, +struct BeaconExecutionPayloadV1<'a> { + parent_hash: Cow<'a, B256>, + fee_recipient: Cow<'a, Address>, + state_root: Cow<'a, B256>, + receipts_root: Cow<'a, B256>, + logs_bloom: Cow<'a, Bloom>, + prev_randao: Cow<'a, B256>, #[serde_as(as = "DisplayFromStr")] - pub(crate) block_number: u64, + block_number: u64, #[serde_as(as = "DisplayFromStr")] - pub(crate) gas_limit: u64, + gas_limit: u64, #[serde_as(as = "DisplayFromStr")] - pub(crate) gas_used: u64, + gas_used: u64, #[serde_as(as = "DisplayFromStr")] - pub(crate) timestamp: u64, - pub(crate) extra_data: Cow<'a, Bytes>, - pub(crate) base_fee_per_gas: Cow<'a, U256>, - pub(crate) block_hash: Cow<'a, B256>, - pub(crate) transactions: Cow<'a, Vec>, + timestamp: u64, + extra_data: Cow<'a, Bytes>, + #[serde_as(as = "DisplayFromStr")] + base_fee_per_gas: U256, + block_hash: Cow<'a, B256>, + transactions: Cow<'a, Vec>, } impl<'a> From> for ExecutionPayloadV1 { @@ -131,7 +131,7 @@ impl<'a> From> for ExecutionPayloadV1 { gas_used: U64::from(gas_used), timestamp: U64::from(timestamp), extra_data: extra_data.into_owned(), - base_fee_per_gas: base_fee_per_gas.into_owned(), + base_fee_per_gas, block_hash: block_hash.into_owned(), transactions: transactions.into_owned(), } @@ -169,7 +169,7 @@ impl<'a> From<&'a ExecutionPayloadV1> for BeaconExecutionPayloadV1<'a> { gas_used: gas_used.to(), timestamp: timestamp.to(), extra_data: Cow::Borrowed(extra_data), - base_fee_per_gas: Cow::Borrowed(base_fee_per_gas), + base_fee_per_gas: *base_fee_per_gas, block_hash: Cow::Borrowed(block_hash), transactions: Cow::Borrowed(transactions), } @@ -204,14 +204,14 @@ pub mod beacon_payload_v1 { #[serde_as] #[derive(Debug, Serialize, Deserialize)] -pub(crate) struct BeaconExecutionPayloadV2<'a> { +struct BeaconExecutionPayloadV2<'a> { /// Inner V1 payload #[serde(flatten)] - pub(crate) payload_inner: BeaconExecutionPayloadV1<'a>, + payload_inner: BeaconExecutionPayloadV1<'a>, /// Array of [`Withdrawal`] enabled with V2 /// See #[serde_as(as = "Vec")] - pub(crate) withdrawals: Vec, + withdrawals: Vec, } impl<'a> From> for ExecutionPayloadV2 { @@ -259,18 +259,18 @@ pub mod beacon_payload_v2 { #[serde_as] #[derive(Debug, Serialize, Deserialize)] -pub(crate) struct BeaconExecutionPayloadV3<'a> { +struct BeaconExecutionPayloadV3<'a> { /// Inner V1 payload #[serde(flatten)] - pub(crate) payload_inner: BeaconExecutionPayloadV2<'a>, + payload_inner: BeaconExecutionPayloadV2<'a>, /// Array of [`U64`] representing blob gas used, enabled with V3 /// See #[serde_as(as = "DisplayFromStr")] - pub(crate) blob_gas_used: u64, + blob_gas_used: u64, /// Array of [`U64`] representing excess blob gas, enabled with V3 /// See #[serde_as(as = "DisplayFromStr")] - pub(crate) excess_blob_gas: u64, + excess_blob_gas: u64, } impl<'a> From> for ExecutionPayloadV3 { @@ -324,7 +324,7 @@ pub mod beacon_payload_v3 { /// Represents all possible payload versions. #[derive(Debug, Serialize)] #[serde(untagged)] -pub enum BeaconExecutionPayload<'a> { +enum BeaconExecutionPayload<'a> { /// V1 payload V1(BeaconExecutionPayloadV1<'a>), /// V2 payload diff --git a/crates/rpc/rpc-types/src/eth/engine/beacon_api/mod.rs b/crates/rpc/rpc-types/src/eth/engine/beacon_api/mod.rs deleted file mode 100644 index 0a3764a214eb2..0000000000000 --- a/crates/rpc/rpc-types/src/eth/engine/beacon_api/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -/// Beacon API events support. -pub mod events; diff --git a/crates/rpc/rpc-types/src/eth/engine/mod.rs b/crates/rpc/rpc-types/src/eth/engine/mod.rs index ead7e56a711b1..334adf0565b35 100644 --- a/crates/rpc/rpc-types/src/eth/engine/mod.rs +++ b/crates/rpc/rpc-types/src/eth/engine/mod.rs @@ -1,6 +1,5 @@ -//! Engine API types: and following the execution specs - #![allow(missing_docs)] +//! Engine API types: and following the execution specs mod cancun; mod forkchoice; @@ -8,9 +7,6 @@ pub mod payload; mod transition; pub use self::{cancun::*, forkchoice::*, payload::*, transition::*}; -/// Beacon API types -pub mod beacon_api; - /// The list of all supported Engine capabilities available over the engine endpoint. pub const CAPABILITIES: [&str; 12] = [ "engine_forkchoiceUpdatedV1", diff --git a/crates/rpc/rpc-types/src/relay.rs b/crates/rpc/rpc-types/src/relay.rs index 4dfd439562d18..d98d7e40ecc77 100644 --- a/crates/rpc/rpc-types/src/relay.rs +++ b/crates/rpc/rpc-types/src/relay.rs @@ -55,6 +55,7 @@ pub struct BidTrace { pub gas_limit: u64, #[serde_as(as = "DisplayFromStr")] pub gas_used: u64, + #[serde_as(as = "DisplayFromStr")] pub value: U256, } @@ -89,8 +90,10 @@ mod tests { #[test] fn deneb_bid_submission() { - let s = r#"{"message":{"slot":"1","parent_hash":"0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2","block_hash":"0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2","builder_pubkey":"0x93247f2209abcacf57b75a51dafae777f9dd38bc7053d1af526f220a7489a6d3a2753e5f3e8b1cfe39b56f43611df74a", "proposer_pubkey": "0x93247f2209abcacf57b75a51dafae777f9dd38bc7053d1af526f220a7489a6d3a2753e5f3e8b1cfe39b56f43611df74a","proposer_fee_recipient":"0xabcf8e0d4e9587369b2301d0790347320302cc09","gas_limit":"1","gas_used":"1","value":"1"},"execution_payload":{"parent_hash":"0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2","fee_recipient":"0xabcf8e0d4e9587369b2301d0790347320302cc09","state_root":"0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2","receipts_root":"0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2","logs_bloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","prev_randao":"0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2","block_number":"1","gas_limit":"1","gas_used":"1","timestamp":"1","extra_data":"0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2","base_fee_per_gas":"1","block_hash":"0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2","transactions":["0x02f878831469668303f51d843b9ac9f9843b9aca0082520894c93269b73096998db66be0441e836d873535cb9c8894a19041886f000080c001a031cc29234036afbf9a1fb9476b463367cb1f957ac0b919b69bbc798436e604aaa018c4e9c3914eb27aadd0b91e10b18655739fcf8c1fc398763a9f1beecb8ddc86"],"withdrawals":[{"index":"1","validator_index":"1","address":"0xabcf8e0d4e9587369b2301d0790347320302cc09","amount":"32000000000"}]},"blobs_bundle":{"commitments":["0x8dab030c51e16e84be9caab84ee3d0b8bbec1db4a0e4de76439da8424d9b957370a10a78851f97e4b54d2ce1ab0d686f"],"proofs":["0xb4021b0de10f743893d4f71e1bf830c019e832958efd6795baf2f83b8699a9eccc5dc99015d8d4d8ec370d0cc333c06a"],"blobs":["0x24564723180fcb3d994104538d351c8dcbde12d541676bb736cf678018ca4739"]},"signature":"0x1b66ac1fb663c9bc59509846d6ec05345bd908eda73e670af888da41af171505cc411d61252fb6cb3fa0017b679f8bb2305b26a285fa2737f175668d0dff91cc1b66ac1fb663c9bc59509846d6ec05345bd908eda73e670af888da41af171505"}"#; + let s = r#"{"message":{"slot":"1","parent_hash":"0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2","block_hash":"0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2","builder_pubkey":"0x93247f2209abcacf57b75a51dafae777f9dd38bc7053d1af526f220a7489a6d3a2753e5f3e8b1cfe39b56f43611df74a", "proposer_pubkey": "0x93247f2209abcacf57b75a51dafae777f9dd38bc7053d1af526f220a7489a6d3a2753e5f3e8b1cfe39b56f43611df74a","proposer_fee_recipient":"0xabcf8e0d4e9587369b2301d0790347320302cc09","gas_limit":"1","gas_used":"1","value":"1"},"execution_payload":{"parent_hash":"0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2","fee_recipient":"0xabcf8e0d4e9587369b2301d0790347320302cc09","state_root":"0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2","receipts_root":"0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2","logs_bloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","prev_randao":"0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2","block_number":"1","gas_limit":"1","gas_used":"1","timestamp":"1","extra_data":"0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2","base_fee_per_gas":"1","block_hash":"0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2","transactions":["0x02f878831469668303f51d843b9ac9f9843b9aca0082520894c93269b73096998db66be0441e836d873535cb9c8894a19041886f000080c001a031cc29234036afbf9a1fb9476b463367cb1f957ac0b919b69bbc798436e604aaa018c4e9c3914eb27aadd0b91e10b18655739fcf8c1fc398763a9f1beecb8ddc86"],"withdrawals":[{"index":"1","validator_index":"1","address":"0xabcf8e0d4e9587369b2301d0790347320302cc09","amount":"32000000000"}]},"blobs_bundle":{"commitments":[],"proofs":[],"blobs":[]},"signature":"0x1b66ac1fb663c9bc59509846d6ec05345bd908eda73e670af888da41af171505cc411d61252fb6cb3fa0017b679f8bb2305b26a285fa2737f175668d0dff91cc1b66ac1fb663c9bc59509846d6ec05345bd908eda73e670af888da41af171505"}"#; - let _bid = serde_json::from_str::(s).unwrap(); + let bid = serde_json::from_str::(s).unwrap(); + let json: serde_json::Value = serde_json::from_str(s).unwrap(); + assert_eq!(json, serde_json::to_value(bid).unwrap()); } } diff --git a/examples/beacon-api-sse/src/main.rs b/examples/beacon-api-sse/src/main.rs index 04f0be1116952..ccf3d1e5ca292 100644 --- a/examples/beacon-api-sse/src/main.rs +++ b/examples/beacon-api-sse/src/main.rs @@ -23,7 +23,7 @@ use reth::{ ext::{RethCliExt, RethNodeCommandConfig}, Cli, }, - rpc::types::engine::beacon_api::events::PayloadAttributesEvent, + rpc::types::beacon::events::PayloadAttributesEvent, tasks::TaskSpawner, }; use std::net::{IpAddr, Ipv4Addr};