From 8517a187e8891221c3064da067f8ac0c6eb8b5d9 Mon Sep 17 00:00:00 2001 From: Oliver Nordbjerg Date: Mon, 6 May 2024 13:51:19 +0200 Subject: [PATCH 1/5] feat: prague engine api types --- crates/engine-primitives/src/lib.rs | 43 +++++++++++--- crates/rpc/rpc-engine-api/src/engine_api.rs | 65 ++++++++++++++++++++- 2 files changed, 97 insertions(+), 11 deletions(-) diff --git a/crates/engine-primitives/src/lib.rs b/crates/engine-primitives/src/lib.rs index e144d0fcd9f1..99edf521c0b6 100644 --- a/crates/engine-primitives/src/lib.rs +++ b/crates/engine-primitives/src/lib.rs @@ -115,6 +115,29 @@ pub fn validate_payload_timestamp( // the payload does not fall within the time frame of the Cancun fork. return Err(EngineObjectValidationError::UnsupportedFork) } + + let is_prague = chain_spec.is_prague_active_at_timestamp(timestamp); + if version == EngineApiMessageVersion::V4 && !is_prague { + // From the Engine API spec: + // + // + // For `engine_getPayloadV4`: + // + // 1. Client software **MUST** return `-38005: Unsupported fork` error if the `timestamp` of + // the built payload does not fall within the time frame of the Prague fork. + // + // For `engine_forkchoiceUpdatedV4`: + // + // 2. Client software **MUST** return `-38005: Unsupported fork` error if the + // `payloadAttributes` is set and the `payloadAttributes.timestamp` does not fall within + // the time frame of the Prague fork. + // + // For `engine_newPayloadV4`: + // + // 2. Client software **MUST** return `-38005: Unsupported fork` error if the `timestamp` of + // the payload does not fall within the time frame of the Prague fork. + return Err(EngineObjectValidationError::UnsupportedFork) + } Ok(()) } @@ -128,7 +151,7 @@ pub fn validate_withdrawals_presence( timestamp: u64, has_withdrawals: bool, ) -> Result<(), EngineObjectValidationError> { - let is_shanghai = chain_spec.is_shanghai_active_at_timestamp(timestamp); + let is_shanghai_active = chain_spec.is_shanghai_active_at_timestamp(timestamp); match version { EngineApiMessageVersion::V1 => { @@ -136,17 +159,17 @@ pub fn validate_withdrawals_presence( return Err(message_validation_kind .to_error(VersionSpecificValidationError::WithdrawalsNotSupportedInV1)) } - if is_shanghai { + if is_shanghai_active { return Err(message_validation_kind .to_error(VersionSpecificValidationError::NoWithdrawalsPostShanghai)) } } - EngineApiMessageVersion::V2 | EngineApiMessageVersion::V3 => { - if is_shanghai && !has_withdrawals { + EngineApiMessageVersion::V2 | EngineApiMessageVersion::V3 | EngineApiMessageVersion::V4 => { + if is_shanghai_active && !has_withdrawals { return Err(message_validation_kind .to_error(VersionSpecificValidationError::NoWithdrawalsPostShanghai)) } - if !is_shanghai && has_withdrawals { + if !is_shanghai_active && has_withdrawals { return Err(message_validation_kind .to_error(VersionSpecificValidationError::HasWithdrawalsPreShanghai)) } @@ -237,7 +260,7 @@ pub fn validate_parent_beacon_block_root_presence( )) } } - EngineApiMessageVersion::V3 => { + EngineApiMessageVersion::V3 | EngineApiMessageVersion::V4 => { if !has_parent_beacon_block_root { return Err(validation_kind .to_error(VersionSpecificValidationError::NoParentBeaconBlockRootPostCancun)) @@ -321,10 +344,14 @@ pub enum EngineApiMessageVersion { V1, /// Version 2 /// - /// Added for shanghai hardfork. + /// Added in the Shanghai hardfork. V2, /// Version 3 /// - /// Added for cancun hardfork. + /// Added in the Cancun hardfork. V3, + /// Version 4 + /// + /// Added in the Prague hardfork. + V4, } diff --git a/crates/rpc/rpc-engine-api/src/engine_api.rs b/crates/rpc/rpc-engine-api/src/engine_api.rs index eb3b1bfc7bd8..0e4476bb71b0 100644 --- a/crates/rpc/rpc-engine-api/src/engine_api.rs +++ b/crates/rpc/rpc-engine-api/src/engine_api.rs @@ -12,8 +12,8 @@ use reth_provider::{BlockReader, EvmEnvProvider, HeaderProvider, StateProviderFa use reth_rpc_api::EngineApiServer; use reth_rpc_types::engine::{ CancunPayloadFields, ExecutionPayload, ExecutionPayloadBodiesV1, ExecutionPayloadInputV2, - ExecutionPayloadV1, ExecutionPayloadV3, ForkchoiceState, ForkchoiceUpdated, PayloadId, - PayloadStatus, TransitionConfiguration, CAPABILITIES, + ExecutionPayloadV1, ExecutionPayloadV3, ExecutionPayloadV4, ForkchoiceState, ForkchoiceUpdated, + PayloadId, PayloadStatus, TransitionConfiguration, CAPABILITIES, }; use reth_rpc_types_compat::engine::payload::{ convert_payload_input_v2_to_payload, convert_to_payload_body_v1, @@ -148,6 +148,30 @@ where Ok(self.inner.beacon_consensus.new_payload(payload, Some(cancun_fields)).await?) } + /// See also + pub async fn new_payload_v4( + &self, + payload: ExecutionPayloadV4, + versioned_hashes: Vec, + parent_beacon_block_root: B256, + ) -> EngineApiResult { + let payload = ExecutionPayload::from(payload); + let payload_or_attrs = + PayloadOrAttributes::<'_, EngineT::PayloadAttributes>::from_execution_payload( + &payload, + Some(parent_beacon_block_root), + ); + EngineT::validate_version_specific_fields( + &self.inner.chain_spec, + EngineApiMessageVersion::V4, + payload_or_attrs, + )?; + + let cancun_fields = CancunPayloadFields { versioned_hashes, parent_beacon_block_root }; + + Ok(self.inner.beacon_consensus.new_payload(payload, Some(cancun_fields)).await?) + } + /// Sends a message to the beacon consensus engine to update the fork choice _without_ /// withdrawals. /// @@ -280,7 +304,42 @@ where .map_err(|_| EngineApiError::UnknownPayload)? .try_into() .map_err(|_| { - warn!("could not transform built payload into ExecutionPayloadV2"); + warn!("could not transform built payload into ExecutionPayloadV3"); + EngineApiError::UnknownPayload + }) + } + + /// Returns the most recent version of the payload that is available in the corresponding + /// payload build process at the time of receiving this call. + /// + /// See also + /// + /// Note: + /// > Provider software MAY stop the corresponding build process after serving this call. + pub async fn get_payload_v4( + &self, + payload_id: PayloadId, + ) -> EngineApiResult { + // First we fetch the payload attributes to check the timestamp + let attributes = self.get_payload_attributes(payload_id).await?; + + // validate timestamp according to engine rules + validate_payload_timestamp( + &self.inner.chain_spec, + EngineApiMessageVersion::V4, + attributes.timestamp(), + )?; + + // Now resolve the payload + self.inner + .payload_store + .resolve(payload_id) + .await + .ok_or(EngineApiError::UnknownPayload)? + .map_err(|_| EngineApiError::UnknownPayload)? + .try_into() + .map_err(|_| { + warn!("could not transform built payload into ExecutionPayloadV4"); EngineApiError::UnknownPayload }) } From 91ab4c2f9141b6b6c833db4c1e4ed144c4db76f9 Mon Sep 17 00:00:00 2001 From: Oliver Nordbjerg Date: Mon, 6 May 2024 15:08:45 +0200 Subject: [PATCH 2/5] chore: bump alloy --- Cargo.lock | 202 ++++++++++++------ Cargo.toml | 38 ++-- .../rpc-types-compat/src/engine/payload.rs | 13 +- crates/rpc/rpc-types/src/beacon/payload.rs | 4 + 4 files changed, 179 insertions(+), 78 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 14a5dd752bbb..7a230de06743 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -71,7 +71,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" dependencies = [ "cfg-if", - "getrandom 0.2.14", + "getrandom 0.2.15", "once_cell", "version_check", "zerocopy", @@ -146,7 +146,20 @@ dependencies = [ [[package]] name = "alloy-consensus" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#0bb7604f186a78cdee911fa7fbc0ca36465a6902" +source = "git+https://github.com/alloy-rs/alloy?rev=c3ea7bc#c3ea7bce27113086030c94919954d42be5cad78a" +dependencies = [ + "alloy-eips 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=c3ea7bc)", + "alloy-primitives", + "alloy-rlp", + "alloy-serde 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=c3ea7bc)", + "c-kzg", + "serde", +] + +[[package]] +name = "alloy-consensus" +version = "0.1.0" +source = "git+https://github.com/alloy-rs/alloy#05af0de129dc0fa081b19b2f0a69b26941f8fec7" dependencies = [ "alloy-eips 0.1.0 (git+https://github.com/alloy-rs/alloy)", "alloy-primitives", @@ -171,7 +184,7 @@ dependencies = [ "itoa", "serde", "serde_json", - "winnow 0.6.7", + "winnow 0.6.8", ] [[package]] @@ -182,6 +195,20 @@ dependencies = [ "alloy-primitives", "alloy-rlp", "alloy-serde 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=17c5650)", + "c-kzg", + "once_cell", + "serde", + "sha2 0.10.8", +] + +[[package]] +name = "alloy-eips" +version = "0.1.0" +source = "git+https://github.com/alloy-rs/alloy?rev=c3ea7bc#c3ea7bce27113086030c94919954d42be5cad78a" +dependencies = [ + "alloy-primitives", + "alloy-rlp", + "alloy-serde 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=c3ea7bc)", "arbitrary", "c-kzg", "derive_more", @@ -197,7 +224,7 @@ dependencies = [ [[package]] name = "alloy-eips" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#0bb7604f186a78cdee911fa7fbc0ca36465a6902" +source = "git+https://github.com/alloy-rs/alloy#05af0de129dc0fa081b19b2f0a69b26941f8fec7" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -222,7 +249,18 @@ dependencies = [ [[package]] name = "alloy-genesis" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#0bb7604f186a78cdee911fa7fbc0ca36465a6902" +source = "git+https://github.com/alloy-rs/alloy?rev=c3ea7bc#c3ea7bce27113086030c94919954d42be5cad78a" +dependencies = [ + "alloy-primitives", + "alloy-serde 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=c3ea7bc)", + "serde", + "serde_json", +] + +[[package]] +name = "alloy-genesis" +version = "0.1.0" +source = "git+https://github.com/alloy-rs/alloy#05af0de129dc0fa081b19b2f0a69b26941f8fec7" dependencies = [ "alloy-primitives", "alloy-serde 0.1.0 (git+https://github.com/alloy-rs/alloy)", @@ -245,7 +283,7 @@ dependencies = [ [[package]] name = "alloy-json-rpc" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=17c5650#17c5650f91472b3c0e29ea5cede6ce2bc7f87018" +source = "git+https://github.com/alloy-rs/alloy?rev=c3ea7bc#c3ea7bce27113086030c94919954d42be5cad78a" dependencies = [ "alloy-primitives", "serde", @@ -257,13 +295,13 @@ dependencies = [ [[package]] name = "alloy-network" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=17c5650#17c5650f91472b3c0e29ea5cede6ce2bc7f87018" +source = "git+https://github.com/alloy-rs/alloy?rev=c3ea7bc#c3ea7bce27113086030c94919954d42be5cad78a" dependencies = [ - "alloy-consensus 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=17c5650)", - "alloy-eips 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=17c5650)", + "alloy-consensus 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=c3ea7bc)", + "alloy-eips 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=c3ea7bc)", "alloy-json-rpc", "alloy-primitives", - "alloy-rpc-types 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=17c5650)", + "alloy-rpc-types 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=c3ea7bc)", "alloy-signer", "alloy-sol-types", "async-trait", @@ -274,9 +312,9 @@ dependencies = [ [[package]] name = "alloy-node-bindings" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=17c5650#17c5650f91472b3c0e29ea5cede6ce2bc7f87018" +source = "git+https://github.com/alloy-rs/alloy?rev=c3ea7bc#c3ea7bce27113086030c94919954d42be5cad78a" dependencies = [ - "alloy-genesis 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=17c5650)", + "alloy-genesis 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=c3ea7bc)", "alloy-primitives", "k256", "serde_json", @@ -300,7 +338,7 @@ dependencies = [ "derive_arbitrary", "derive_more", "ethereum_ssz", - "getrandom 0.2.14", + "getrandom 0.2.15", "hex-literal", "itoa", "k256", @@ -316,15 +354,15 @@ dependencies = [ [[package]] name = "alloy-provider" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=17c5650#17c5650f91472b3c0e29ea5cede6ce2bc7f87018" +source = "git+https://github.com/alloy-rs/alloy?rev=c3ea7bc#c3ea7bce27113086030c94919954d42be5cad78a" dependencies = [ - "alloy-eips 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=17c5650)", + "alloy-eips 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=c3ea7bc)", "alloy-json-rpc", "alloy-network", "alloy-primitives", "alloy-rpc-client", - "alloy-rpc-types 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=17c5650)", - "alloy-rpc-types-trace", + "alloy-rpc-types 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=c3ea7bc)", + "alloy-rpc-types-trace 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=c3ea7bc)", "alloy-transport", "alloy-transport-http", "async-stream", @@ -366,7 +404,7 @@ dependencies = [ [[package]] name = "alloy-rpc-client" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=17c5650#17c5650f91472b3c0e29ea5cede6ce2bc7f87018" +source = "git+https://github.com/alloy-rs/alloy?rev=c3ea7bc#c3ea7bce27113086030c94919954d42be5cad78a" dependencies = [ "alloy-json-rpc", "alloy-transport", @@ -395,6 +433,24 @@ dependencies = [ "alloy-rlp", "alloy-serde 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=17c5650)", "alloy-sol-types", + "itertools 0.12.1", + "serde", + "serde_json", + "thiserror", +] + +[[package]] +name = "alloy-rpc-types" +version = "0.1.0" +source = "git+https://github.com/alloy-rs/alloy?rev=c3ea7bc#c3ea7bce27113086030c94919954d42be5cad78a" +dependencies = [ + "alloy-consensus 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=c3ea7bc)", + "alloy-eips 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=c3ea7bc)", + "alloy-genesis 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=c3ea7bc)", + "alloy-primitives", + "alloy-rlp", + "alloy-serde 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=c3ea7bc)", + "alloy-sol-types", "arbitrary", "itertools 0.12.1", "jsonrpsee-types", @@ -408,7 +464,7 @@ dependencies = [ [[package]] name = "alloy-rpc-types" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#0bb7604f186a78cdee911fa7fbc0ca36465a6902" +source = "git+https://github.com/alloy-rs/alloy#05af0de129dc0fa081b19b2f0a69b26941f8fec7" dependencies = [ "alloy-consensus 0.1.0 (git+https://github.com/alloy-rs/alloy)", "alloy-eips 0.1.0 (git+https://github.com/alloy-rs/alloy)", @@ -426,24 +482,24 @@ dependencies = [ [[package]] name = "alloy-rpc-types-anvil" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=17c5650#17c5650f91472b3c0e29ea5cede6ce2bc7f87018" +source = "git+https://github.com/alloy-rs/alloy?rev=c3ea7bc#c3ea7bce27113086030c94919954d42be5cad78a" dependencies = [ "alloy-primitives", - "alloy-serde 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=17c5650)", + "alloy-serde 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=c3ea7bc)", "serde", ] [[package]] name = "alloy-rpc-types-engine" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=17c5650#17c5650f91472b3c0e29ea5cede6ce2bc7f87018" +source = "git+https://github.com/alloy-rs/alloy?rev=c3ea7bc#c3ea7bce27113086030c94919954d42be5cad78a" dependencies = [ - "alloy-consensus 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=17c5650)", - "alloy-eips 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=17c5650)", + "alloy-consensus 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=c3ea7bc)", + "alloy-eips 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=c3ea7bc)", "alloy-primitives", "alloy-rlp", - "alloy-rpc-types 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=17c5650)", - "alloy-serde 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=17c5650)", + "alloy-rpc-types 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=c3ea7bc)", + "alloy-serde 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=c3ea7bc)", "ethereum_ssz", "ethereum_ssz_derive", "jsonrpsee-types", @@ -465,6 +521,18 @@ dependencies = [ "serde_json", ] +[[package]] +name = "alloy-rpc-types-trace" +version = "0.1.0" +source = "git+https://github.com/alloy-rs/alloy?rev=c3ea7bc#c3ea7bce27113086030c94919954d42be5cad78a" +dependencies = [ + "alloy-primitives", + "alloy-rpc-types 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=c3ea7bc)", + "alloy-serde 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=c3ea7bc)", + "serde", + "serde_json", +] + [[package]] name = "alloy-serde" version = "0.1.0" @@ -478,7 +546,17 @@ dependencies = [ [[package]] name = "alloy-serde" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#0bb7604f186a78cdee911fa7fbc0ca36465a6902" +source = "git+https://github.com/alloy-rs/alloy?rev=c3ea7bc#c3ea7bce27113086030c94919954d42be5cad78a" +dependencies = [ + "alloy-primitives", + "serde", + "serde_json", +] + +[[package]] +name = "alloy-serde" +version = "0.1.0" +source = "git+https://github.com/alloy-rs/alloy#05af0de129dc0fa081b19b2f0a69b26941f8fec7" dependencies = [ "alloy-primitives", "serde", @@ -488,7 +566,7 @@ dependencies = [ [[package]] name = "alloy-signer" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=17c5650#17c5650f91472b3c0e29ea5cede6ce2bc7f87018" +source = "git+https://github.com/alloy-rs/alloy?rev=c3ea7bc#c3ea7bce27113086030c94919954d42be5cad78a" dependencies = [ "alloy-primitives", "async-trait", @@ -501,9 +579,9 @@ dependencies = [ [[package]] name = "alloy-signer-wallet" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=17c5650#17c5650f91472b3c0e29ea5cede6ce2bc7f87018" +source = "git+https://github.com/alloy-rs/alloy?rev=c3ea7bc#c3ea7bce27113086030c94919954d42be5cad78a" dependencies = [ - "alloy-consensus 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=17c5650)", + "alloy-consensus 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=c3ea7bc)", "alloy-network", "alloy-primitives", "alloy-signer", @@ -557,7 +635,7 @@ version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7da8e71ea68e780cc203919e03f69f59e7afe92d2696fb1dcb6662f61e4031b6" dependencies = [ - "winnow 0.6.7", + "winnow 0.6.8", ] [[package]] @@ -576,7 +654,7 @@ dependencies = [ [[package]] name = "alloy-transport" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=17c5650#17c5650f91472b3c0e29ea5cede6ce2bc7f87018" +source = "git+https://github.com/alloy-rs/alloy?rev=c3ea7bc#c3ea7bce27113086030c94919954d42be5cad78a" dependencies = [ "alloy-json-rpc", "base64 0.22.1", @@ -594,7 +672,7 @@ dependencies = [ [[package]] name = "alloy-transport-http" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=17c5650#17c5650f91472b3c0e29ea5cede6ce2bc7f87018" +source = "git+https://github.com/alloy-rs/alloy?rev=c3ea7bc#c3ea7bce27113086030c94919954d42be5cad78a" dependencies = [ "alloy-json-rpc", "alloy-transport", @@ -1546,9 +1624,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.96" +version = "1.0.97" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "065a29261d53ba54260972629f9ca6bffa69bac13cd1fed61420f7fa68b9f8bd" +checksum = "099a5357d84c4c61eb35fc8eafa9a79a902c2f76911e5747ced4e032edd8d9b4" dependencies = [ "jobserver", "libc", @@ -2964,7 +3042,7 @@ dependencies = [ name = "exex-rollup" version = "0.0.0" dependencies = [ - "alloy-consensus 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=17c5650)", + "alloy-consensus 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=c3ea7bc)", "alloy-rlp", "alloy-sol-types", "eyre", @@ -3318,9 +3396,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.14" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94b22e06ecb0110981051723910cbf0b5f5e09a2062dd7663334ee79a9d1286c" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" dependencies = [ "cfg-if", "js-sys", @@ -4594,7 +4672,7 @@ dependencies = [ "either", "futures", "futures-timer", - "getrandom 0.2.14", + "getrandom 0.2.15", "instant", "libp2p-allow-block-list", "libp2p-connection-limits", @@ -6132,7 +6210,7 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom 0.2.14", + "getrandom 0.2.15", ] [[package]] @@ -6226,7 +6304,7 @@ version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bd283d9651eeda4b2a83a43c1c91b266c40fd76ecd39a50a8c630ae69dc72891" dependencies = [ - "getrandom 0.2.14", + "getrandom 0.2.15", "libredox", "thiserror", ] @@ -6586,8 +6664,8 @@ dependencies = [ name = "reth-codecs" version = "0.2.0-beta.6" dependencies = [ - "alloy-eips 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=17c5650)", - "alloy-genesis 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=17c5650)", + "alloy-eips 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=c3ea7bc)", + "alloy-genesis 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=c3ea7bc)", "alloy-primitives", "arbitrary", "bytes", @@ -6792,9 +6870,9 @@ dependencies = [ name = "reth-e2e-test-utils" version = "0.2.0-beta.6" dependencies = [ - "alloy-consensus 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=17c5650)", + "alloy-consensus 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=c3ea7bc)", "alloy-network", - "alloy-rpc-types 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=17c5650)", + "alloy-rpc-types 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=c3ea7bc)", "alloy-signer", "alloy-signer-wallet", "eyre", @@ -7536,8 +7614,8 @@ name = "reth-primitives" version = "0.2.0-beta.6" dependencies = [ "alloy-chains", - "alloy-eips 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=17c5650)", - "alloy-genesis 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=17c5650)", + "alloy-eips 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=c3ea7bc)", + "alloy-genesis 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=c3ea7bc)", "alloy-primitives", "alloy-rlp", "alloy-trie", @@ -7804,10 +7882,10 @@ name = "reth-rpc-types" version = "0.2.0-beta.6" dependencies = [ "alloy-primitives", - "alloy-rpc-types 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=17c5650)", + "alloy-rpc-types 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=c3ea7bc)", "alloy-rpc-types-anvil", "alloy-rpc-types-engine", - "alloy-rpc-types-trace", + "alloy-rpc-types-trace 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=c3ea7bc)", "arbitrary", "bytes", "ethereum_ssz", @@ -7828,7 +7906,7 @@ name = "reth-rpc-types-compat" version = "0.2.0-beta.6" dependencies = [ "alloy-rlp", - "alloy-rpc-types 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=17c5650)", + "alloy-rpc-types 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=c3ea7bc)", "reth-primitives", "reth-rpc-types", "serde_json", @@ -7934,7 +8012,7 @@ dependencies = [ name = "reth-testing-utils" version = "0.2.0-beta.6" dependencies = [ - "alloy-genesis 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=17c5650)", + "alloy-genesis 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=c3ea7bc)", "reth-primitives", "secp256k1", ] @@ -8072,7 +8150,7 @@ source = "git+https://github.com/paradigmxyz/evm-inspectors?rev=089efac#089efacf dependencies = [ "alloy-primitives", "alloy-rpc-types 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=17c5650)", - "alloy-rpc-types-trace", + "alloy-rpc-types-trace 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=17c5650)", "alloy-sol-types", "anstyle", "boa_engine", @@ -8173,7 +8251,7 @@ checksum = "c17fa4cb658e3583423e915b9f3acc01cceaee1860e33d59ebae66adc3a2dc0d" dependencies = [ "cc", "cfg-if", - "getrandom 0.2.14", + "getrandom 0.2.15", "libc", "spin 0.9.8", "untrusted 0.9.0", @@ -8575,11 +8653,11 @@ dependencies = [ [[package]] name = "security-framework" -version = "2.10.0" +version = "2.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "770452e37cad93e0a50d5abc3990d2bc351c36d0328f86cefec2f2fb206eaef6" +checksum = "c627723fd09706bacdb5cf41499e95098555af3c3c29d014dc3c458ef6be11c0" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.5.0", "core-foundation", "core-foundation-sys", "libc", @@ -8588,9 +8666,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.10.0" +version = "2.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41f3cc463c0ef97e11c3461a9d3787412d30e8e7eb907c79180c4a57bf7c04ef" +checksum = "317936bbbd05227752583946b9e66d7ce3b489f84e11a94a510b4437fef407d7" dependencies = [ "core-foundation-sys", "libc", @@ -9598,7 +9676,7 @@ dependencies = [ "serde", "serde_spanned", "toml_datetime", - "winnow 0.6.7", + "winnow 0.6.8", ] [[package]] @@ -10060,7 +10138,7 @@ version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a183cf7feeba97b4dd1c0d46788634f6221d87fa961b305bed08c851829efcc0" dependencies = [ - "getrandom 0.2.14", + "getrandom 0.2.15", ] [[package]] @@ -10463,9 +10541,9 @@ dependencies = [ [[package]] name = "winnow" -version = "0.6.7" +version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14b9415ee827af173ebb3f15f9083df5a122eb93572ec28741fb153356ea2578" +checksum = "c3c52e9c97a68071b23e836c9380edae937f17b9c4667bd021973efc689f618d" dependencies = [ "memchr", ] diff --git a/Cargo.toml b/Cargo.toml index dc693e94fb5f..446ecf09fce3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -278,8 +278,13 @@ reth-node-events = { path = "crates/node/events" } reth-testing-utils = { path = "testing/testing-utils" } # revm -revm = { version = "8.0.0", features = ["std", "secp256k1"], default-features = false } -revm-primitives = { version = "3.1.0", features = ["std"], default-features = false } +revm = { version = "8.0.0", features = [ + "std", + "secp256k1", +], default-features = false } +revm-primitives = { version = "3.1.0", features = [ + "std", +], default-features = false } revm-inspectors = { git = "https://github.com/paradigmxyz/evm-inspectors", rev = "089efac" } # eth @@ -289,20 +294,20 @@ alloy-dyn-abi = "0.7.2" alloy-sol-types = "0.7.2" alloy-rlp = "0.3.4" alloy-trie = "0.3.1" -alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy", rev = "17c5650" } -alloy-rpc-types-anvil = { git = "https://github.com/alloy-rs/alloy", rev = "17c5650" } -alloy-rpc-types-trace = { git = "https://github.com/alloy-rs/alloy", rev = "17c5650" } -alloy-rpc-types-engine = { git = "https://github.com/alloy-rs/alloy", rev = "17c5650" } -alloy-genesis = { git = "https://github.com/alloy-rs/alloy", rev = "17c5650" } -alloy-node-bindings = { git = "https://github.com/alloy-rs/alloy", rev = "17c5650" } -alloy-provider = { git = "https://github.com/alloy-rs/alloy", rev = "17c5650", default-features = false, features = [ +alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy", rev = "c3ea7bc" } +alloy-rpc-types-anvil = { git = "https://github.com/alloy-rs/alloy", rev = "c3ea7bc" } +alloy-rpc-types-trace = { git = "https://github.com/alloy-rs/alloy", rev = "c3ea7bc" } +alloy-rpc-types-engine = { git = "https://github.com/alloy-rs/alloy", rev = "c3ea7bc" } +alloy-genesis = { git = "https://github.com/alloy-rs/alloy", rev = "c3ea7bc" } +alloy-node-bindings = { git = "https://github.com/alloy-rs/alloy", rev = "c3ea7bc" } +alloy-provider = { git = "https://github.com/alloy-rs/alloy", rev = "c3ea7bc", default-features = false, features = [ "reqwest", ] } -alloy-eips = { git = "https://github.com/alloy-rs/alloy", default-features = false, rev = "17c5650" } -alloy-signer = { git = "https://github.com/alloy-rs/alloy", rev = "17c5650" } -alloy-signer-wallet = { git = "https://github.com/alloy-rs/alloy", rev = "17c5650" } -alloy-network = { git = "https://github.com/alloy-rs/alloy", rev = "17c5650" } -alloy-consensus = { git = "https://github.com/alloy-rs/alloy", rev = "17c5650" } +alloy-eips = { git = "https://github.com/alloy-rs/alloy", default-features = false, rev = "c3ea7bc" } +alloy-signer = { git = "https://github.com/alloy-rs/alloy", rev = "c3ea7bc" } +alloy-signer-wallet = { git = "https://github.com/alloy-rs/alloy", rev = "c3ea7bc" } +alloy-network = { git = "https://github.com/alloy-rs/alloy", rev = "c3ea7bc" } +alloy-consensus = { git = "https://github.com/alloy-rs/alloy", rev = "c3ea7bc" } # misc auto_impl = "1" @@ -377,7 +382,10 @@ secp256k1 = { version = "0.28", default-features = false, features = [ "recovery", ] } # TODO: Remove `k256` feature: https://github.com/sigp/enr/pull/74 -enr = { version = "0.12.0", default-features = false, features = ["k256", "rust-secp256k1"] } +enr = { version = "0.12.0", default-features = false, features = [ + "k256", + "rust-secp256k1", +] } # for eip-4844 c-kzg = "1.0.0" diff --git a/crates/rpc/rpc-types-compat/src/engine/payload.rs b/crates/rpc/rpc-types-compat/src/engine/payload.rs index 3ab9a74b9717..00e5c1709066 100644 --- a/crates/rpc/rpc-types-compat/src/engine/payload.rs +++ b/crates/rpc/rpc-types-compat/src/engine/payload.rs @@ -8,7 +8,8 @@ use reth_primitives::{ }; use reth_rpc_types::engine::{ payload::{ExecutionPayloadBodyV1, ExecutionPayloadFieldV2, ExecutionPayloadInputV2}, - ExecutionPayload, ExecutionPayloadV1, ExecutionPayloadV2, ExecutionPayloadV3, PayloadError, + ExecutionPayload, ExecutionPayloadV1, ExecutionPayloadV2, ExecutionPayloadV3, + ExecutionPayloadV4, PayloadError, }; /// Converts [ExecutionPayloadV1] to [Block] @@ -83,6 +84,15 @@ pub fn try_payload_v3_to_block(payload: ExecutionPayloadV3) -> Result Result { + // this performs the same conversion as the underlying V3 payload. + // + // the new request lists (`deposit_requests`, `withdrawal_requests`) are EL -> CL only, so we do + // not do anything special here to handle them + try_payload_v3_to_block(payload.payload_inner) +} + /// Converts [SealedBlock] to [ExecutionPayload] pub fn block_to_payload(value: SealedBlock) -> ExecutionPayload { if value.header.parent_beacon_block_root.is_some() { @@ -224,6 +234,7 @@ pub fn try_into_block( ExecutionPayload::V1(payload) => try_payload_v1_to_block(payload)?, ExecutionPayload::V2(payload) => try_payload_v2_to_block(payload)?, ExecutionPayload::V3(payload) => try_payload_v3_to_block(payload)?, + ExecutionPayload::V4(payload) => try_payload_v4_to_block(payload)?, }; base_payload.header.parent_beacon_block_root = parent_beacon_block_root; diff --git a/crates/rpc/rpc-types/src/beacon/payload.rs b/crates/rpc/rpc-types/src/beacon/payload.rs index a4898b723fa1..2bc4cde781b6 100644 --- a/crates/rpc/rpc-types/src/beacon/payload.rs +++ b/crates/rpc/rpc-types/src/beacon/payload.rs @@ -498,6 +498,10 @@ impl<'a> From<&'a ExecutionPayload> for BeaconExecutionPayload<'a> { ExecutionPayload::V3(payload) => { BeaconExecutionPayload::V3(BeaconExecutionPayloadV3::from(payload)) } + ExecutionPayload::V4(_payload) => { + // TODO(onbjerg): Implement `ExecutionPayloadV4` support + todo!() + } } } } From 0997809d5439a5f5a61bc887ea48583074be4e54 Mon Sep 17 00:00:00 2001 From: Oliver Nordbjerg Date: Mon, 6 May 2024 16:56:07 +0200 Subject: [PATCH 3/5] chore: bump evm-inspectors --- Cargo.lock | 88 ++++-------------------------------------------------- Cargo.toml | 2 +- 2 files changed, 6 insertions(+), 84 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7a230de06743..36fa163dde54 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -130,19 +130,6 @@ dependencies = [ "strum", ] -[[package]] -name = "alloy-consensus" -version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=17c5650#17c5650f91472b3c0e29ea5cede6ce2bc7f87018" -dependencies = [ - "alloy-eips 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=17c5650)", - "alloy-primitives", - "alloy-rlp", - "alloy-serde 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=17c5650)", - "c-kzg", - "serde", -] - [[package]] name = "alloy-consensus" version = "0.1.0" @@ -187,20 +174,6 @@ dependencies = [ "winnow 0.6.8", ] -[[package]] -name = "alloy-eips" -version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=17c5650#17c5650f91472b3c0e29ea5cede6ce2bc7f87018" -dependencies = [ - "alloy-primitives", - "alloy-rlp", - "alloy-serde 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=17c5650)", - "c-kzg", - "once_cell", - "serde", - "sha2 0.10.8", -] - [[package]] name = "alloy-eips" version = "0.1.0" @@ -235,17 +208,6 @@ dependencies = [ "sha2 0.10.8", ] -[[package]] -name = "alloy-genesis" -version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=17c5650#17c5650f91472b3c0e29ea5cede6ce2bc7f87018" -dependencies = [ - "alloy-primitives", - "alloy-serde 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=17c5650)", - "serde", - "serde_json", -] - [[package]] name = "alloy-genesis" version = "0.1.0" @@ -362,7 +324,7 @@ dependencies = [ "alloy-primitives", "alloy-rpc-client", "alloy-rpc-types 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=c3ea7bc)", - "alloy-rpc-types-trace 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=c3ea7bc)", + "alloy-rpc-types-trace", "alloy-transport", "alloy-transport-http", "async-stream", @@ -421,24 +383,6 @@ dependencies = [ "url", ] -[[package]] -name = "alloy-rpc-types" -version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=17c5650#17c5650f91472b3c0e29ea5cede6ce2bc7f87018" -dependencies = [ - "alloy-consensus 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=17c5650)", - "alloy-eips 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=17c5650)", - "alloy-genesis 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=17c5650)", - "alloy-primitives", - "alloy-rlp", - "alloy-serde 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=17c5650)", - "alloy-sol-types", - "itertools 0.12.1", - "serde", - "serde_json", - "thiserror", -] - [[package]] name = "alloy-rpc-types" version = "0.1.0" @@ -509,18 +453,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "alloy-rpc-types-trace" -version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=17c5650#17c5650f91472b3c0e29ea5cede6ce2bc7f87018" -dependencies = [ - "alloy-primitives", - "alloy-rpc-types 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=17c5650)", - "alloy-serde 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=17c5650)", - "serde", - "serde_json", -] - [[package]] name = "alloy-rpc-types-trace" version = "0.1.0" @@ -533,16 +465,6 @@ dependencies = [ "serde_json", ] -[[package]] -name = "alloy-serde" -version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=17c5650#17c5650f91472b3c0e29ea5cede6ce2bc7f87018" -dependencies = [ - "alloy-primitives", - "serde", - "serde_json", -] - [[package]] name = "alloy-serde" version = "0.1.0" @@ -7885,7 +7807,7 @@ dependencies = [ "alloy-rpc-types 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=c3ea7bc)", "alloy-rpc-types-anvil", "alloy-rpc-types-engine", - "alloy-rpc-types-trace 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=c3ea7bc)", + "alloy-rpc-types-trace", "arbitrary", "bytes", "ethereum_ssz", @@ -8146,11 +8068,11 @@ dependencies = [ [[package]] name = "revm-inspectors" version = "0.1.0" -source = "git+https://github.com/paradigmxyz/evm-inspectors?rev=089efac#089efacf72e7583630841b7027c46a3cb2f9c28b" +source = "git+https://github.com/paradigmxyz/evm-inspectors?rev=7d810bc#7d810bc44c08fe8ec90ebef556883c2531ebf111" dependencies = [ "alloy-primitives", - "alloy-rpc-types 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=17c5650)", - "alloy-rpc-types-trace 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=17c5650)", + "alloy-rpc-types 0.1.0 (git+https://github.com/alloy-rs/alloy?rev=c3ea7bc)", + "alloy-rpc-types-trace", "alloy-sol-types", "anstyle", "boa_engine", diff --git a/Cargo.toml b/Cargo.toml index 446ecf09fce3..f8d3dcac2f63 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -285,7 +285,7 @@ revm = { version = "8.0.0", features = [ revm-primitives = { version = "3.1.0", features = [ "std", ], default-features = false } -revm-inspectors = { git = "https://github.com/paradigmxyz/evm-inspectors", rev = "089efac" } +revm-inspectors = { git = "https://github.com/paradigmxyz/evm-inspectors", rev = "7d810bc" } # eth alloy-chains = "0.1.15" From bd7d70751ab95c5748be6df8c2613e2a2d311ef8 Mon Sep 17 00:00:00 2001 From: Oliver Nordbjerg Date: Mon, 6 May 2024 17:39:21 +0200 Subject: [PATCH 4/5] chore: fix optimism engine payload validation --- crates/optimism/node/src/engine.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/optimism/node/src/engine.rs b/crates/optimism/node/src/engine.rs index f5c53d98e0d8..7382d2184ded 100644 --- a/crates/optimism/node/src/engine.rs +++ b/crates/optimism/node/src/engine.rs @@ -74,7 +74,7 @@ pub fn validate_withdrawals_presence( .to_error(VersionSpecificValidationError::NoWithdrawalsPostShanghai)) } } - EngineApiMessageVersion::V2 | EngineApiMessageVersion::V3 => { + EngineApiMessageVersion::V2 | EngineApiMessageVersion::V3 | EngineApiMessageVersion::V4 => { if is_shanghai && !has_withdrawals { return Err(message_validation_kind .to_error(VersionSpecificValidationError::NoWithdrawalsPostShanghai)) From fceaba48a936b7b6600c6e898948acb6f32f371b Mon Sep 17 00:00:00 2001 From: Oliver Nordbjerg Date: Mon, 6 May 2024 18:35:56 +0200 Subject: [PATCH 5/5] chore: add note for follow up --- crates/rpc/rpc-types-compat/src/engine/payload.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/rpc/rpc-types-compat/src/engine/payload.rs b/crates/rpc/rpc-types-compat/src/engine/payload.rs index 00e5c1709066..f504c169cb7b 100644 --- a/crates/rpc/rpc-types-compat/src/engine/payload.rs +++ b/crates/rpc/rpc-types-compat/src/engine/payload.rs @@ -95,6 +95,7 @@ pub fn try_payload_v4_to_block(payload: ExecutionPayloadV4) -> Result ExecutionPayload { + // todo(onbjerg): check for requests_root here and return payload v4 if value.header.parent_beacon_block_root.is_some() { // block with parent beacon block root: V3 ExecutionPayload::V3(block_to_payload_v3(value))