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..6d85c3e083774 100644 --- a/crates/rpc/rpc-types/src/beacon/payload.rs +++ b/crates/rpc/rpc-types/src/beacon/payload.rs @@ -96,7 +96,8 @@ pub(crate) struct BeaconExecutionPayloadV1<'a> { #[serde_as(as = "DisplayFromStr")] pub(crate) timestamp: u64, pub(crate) extra_data: Cow<'a, Bytes>, - pub(crate) base_fee_per_gas: Cow<'a, U256>, + #[serde_as(as = "DisplayFromStr")] + pub(crate) base_fee_per_gas: U256, pub(crate) block_hash: Cow<'a, B256>, pub(crate) transactions: Cow<'a, Vec>, } @@ -131,7 +132,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 +170,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), } 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()); } }