Skip to content

Commit

Permalink
chore: remove OpExecutionPayloadV4
Browse files Browse the repository at this point in the history
There is no longer a V4 execution payload in Pectra,
so it does not make sense that there would be one for
Optimism. The v4 payload envelope still exists,
but it now wraps a v3 payload.
  • Loading branch information
onbjerg committed Oct 18, 2024
1 parent 65254cf commit 4b3874b
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 21 deletions.
22 changes: 11 additions & 11 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,14 @@ c-kzg = { version = "1.0", default-features = false }
k256 = { version = "0.13", default-features = false, features = ["ecdsa"] }

[patch.crates-io]
alloy-consensus = { git = "https://github.com/alloy-rs/alloy", rev = "b63a2c7" }
alloy-network = { git = "https://github.com/alloy-rs/alloy", rev = "b63a2c7" }
alloy-network-primitives = { git = "https://github.com/alloy-rs/alloy", rev = "b63a2c7" }
alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy", rev = "b63a2c7" }
alloy-rpc-types-eth = { git = "https://github.com/alloy-rs/alloy", rev = "b63a2c7" }
alloy-rpc-types-engine = { git = "https://github.com/alloy-rs/alloy", rev = "b63a2c7" }
alloy-eips = { git = "https://github.com/alloy-rs/alloy", rev = "b63a2c7" }
alloy-serde = { git = "https://github.com/alloy-rs/alloy", rev = "b63a2c7" }
alloy-signer = { git = "https://github.com/alloy-rs/alloy", rev = "b63a2c7" }
alloy-provider = { git = "https://github.com/alloy-rs/alloy", rev = "b63a2c7" }
alloy-transport = { git = "https://github.com/alloy-rs/alloy", rev = "b63a2c7" }
alloy-consensus = { git = "https://github.com/alloy-rs/alloy", rev = "e2e6581" }
alloy-network = { git = "https://github.com/alloy-rs/alloy", rev = "e2e6581" }
alloy-network-primitives = { git = "https://github.com/alloy-rs/alloy", rev = "e2e6581" }
alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy", rev = "e2e6581" }
alloy-rpc-types-eth = { git = "https://github.com/alloy-rs/alloy", rev = "e2e6581" }
alloy-rpc-types-engine = { git = "https://github.com/alloy-rs/alloy", rev = "e2e6581" }
alloy-eips = { git = "https://github.com/alloy-rs/alloy", rev = "e2e6581" }
alloy-serde = { git = "https://github.com/alloy-rs/alloy", rev = "e2e6581" }
alloy-signer = { git = "https://github.com/alloy-rs/alloy", rev = "e2e6581" }
alloy-provider = { git = "https://github.com/alloy-rs/alloy", rev = "e2e6581" }
alloy-transport = { git = "https://github.com/alloy-rs/alloy", rev = "e2e6581" }
16 changes: 10 additions & 6 deletions crates/provider/src/ext/engine.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
use alloy_network::Network;
use alloy_primitives::{BlockHash, B256};
use alloy_primitives::{BlockHash, Bytes, B256};
use alloy_provider::Provider;
use alloy_rpc_types_engine::{
ClientVersionV1, ExecutionPayloadBodiesV1, ExecutionPayloadEnvelopeV2, ExecutionPayloadInputV2,
ExecutionPayloadV3, ExecutionPayloadV4, ForkchoiceState, ForkchoiceUpdated, PayloadId,
PayloadStatus,
ExecutionPayloadV3, ForkchoiceState, ForkchoiceUpdated, PayloadId, PayloadStatus,
};
use alloy_transport::{Transport, TransportResult};
use op_alloy_rpc_types_engine::{
Expand Down Expand Up @@ -54,8 +53,9 @@ pub trait OpEngineApi<N, T>: Send + Sync {
/// OP modifications: TODO
async fn new_payload_v4(
&self,
payload: ExecutionPayloadV4,
payload: ExecutionPayloadV3,
parent_beacon_block_root: B256,
execution_requests: Vec<Bytes>,
) -> TransportResult<PayloadStatus>;

/// Updates the execution layer client with the given fork choice, as specified for the Shanghai
Expand Down Expand Up @@ -218,14 +218,18 @@ where

async fn new_payload_v4(
&self,
payload: ExecutionPayloadV4,
payload: ExecutionPayloadV3,
parent_beacon_block_root: B256,
execution_requests: Vec<Bytes>,
) -> TransportResult<PayloadStatus> {
// Note: The `versioned_hashes` parameter is always an empty array for OP chains.
let versioned_hashes: Vec<B256> = vec![];

self.client()
.request("engine_newPayloadV4", (payload, versioned_hashes, parent_beacon_block_root))
.request(
"engine_newPayloadV4",
(payload, versioned_hashes, parent_beacon_block_root, execution_requests),
)
.await
}

Expand Down
13 changes: 9 additions & 4 deletions crates/rpc-types-engine/src/payload_v4.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
//! Optimism execution payload envelope V3.

use alloy_primitives::{B256, U256};
use alloy_rpc_types_engine::{BlobsBundleV1, ExecutionPayloadV4};
use alloc::vec::Vec;
use alloy_primitives::{Bytes, B256, U256};
use alloy_rpc_types_engine::{BlobsBundleV1, ExecutionPayloadV3};

/// This structure maps for the return value of `engine_getPayload` of the beacon chain spec, for
/// V4.
Expand All @@ -13,7 +14,7 @@ use alloy_rpc_types_engine::{BlobsBundleV1, ExecutionPayloadV4};
#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))]
pub struct OpExecutionPayloadEnvelopeV4 {
/// Execution payload V4
pub execution_payload: ExecutionPayloadV4,
pub execution_payload: ExecutionPayloadV3,
/// The expected value to be received by the feeRecipient in wei
pub block_value: U256,
/// The blobs, commitments, and proofs associated with the executed payload.
Expand All @@ -23,6 +24,10 @@ pub struct OpExecutionPayloadEnvelopeV4 {
pub should_override_builder: bool,
/// Ecotone parent beacon block root
pub parent_beacon_block_root: B256,
/// A list of opaque [EIP-7685][eip7685] requests.
///
/// [eip7685]: https://eips.ethereum.org/EIPS/eip-7685
pub execution_requests: Vec<Bytes>,
}

#[cfg(test)]
Expand All @@ -34,7 +39,7 @@ mod tests {
fn serde_roundtrip_execution_payload_envelope_v4() {
// modified execution payload envelope v3 with empty deposit, withdrawal, and consolidation
// requests.
let response = r#"{"executionPayload":{"parentHash":"0xe927a1448525fb5d32cb50ee1408461a945ba6c39bd5cf5621407d500ecc8de9","feeRecipient":"0x0000000000000000000000000000000000000000","stateRoot":"0x10f8a0830000e8edef6d00cc727ff833f064b1950afd591ae41357f97e543119","receiptsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","prevRandao":"0xe0d8b4521a7da1582a713244ffb6a86aa1726932087386e2dc7973f43fc6cb24","blockNumber":"0x1","gasLimit":"0x2ffbd2","gasUsed":"0x0","timestamp":"0x1235","extraData":"0xd883010d00846765746888676f312e32312e30856c696e7578","baseFeePerGas":"0x342770c0","blockHash":"0x44d0fa5f2f73a938ebb96a2a21679eb8dea3e7b7dd8fd9f35aa756dda8bf0a8a","transactions":[],"withdrawals":[],"blobGasUsed":"0x0","excessBlobGas":"0x0","depositRequests":[],"withdrawalRequests":[],"consolidationRequests":[]},"blockValue":"0x0","blobsBundle":{"commitments":[],"proofs":[],"blobs":[]},"shouldOverrideBuilder":false,"parentBeaconBlockRoot":"0xdead00000000000000000000000000000000000000000000000000000000beef"}"#;
let response = r#"{"executionPayload":{"parentHash":"0xe927a1448525fb5d32cb50ee1408461a945ba6c39bd5cf5621407d500ecc8de9","feeRecipient":"0x0000000000000000000000000000000000000000","stateRoot":"0x10f8a0830000e8edef6d00cc727ff833f064b1950afd591ae41357f97e543119","receiptsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","prevRandao":"0xe0d8b4521a7da1582a713244ffb6a86aa1726932087386e2dc7973f43fc6cb24","blockNumber":"0x1","gasLimit":"0x2ffbd2","gasUsed":"0x0","timestamp":"0x1235","extraData":"0xd883010d00846765746888676f312e32312e30856c696e7578","baseFeePerGas":"0x342770c0","blockHash":"0x44d0fa5f2f73a938ebb96a2a21679eb8dea3e7b7dd8fd9f35aa756dda8bf0a8a","transactions":[],"withdrawals":[],"blobGasUsed":"0x0","excessBlobGas":"0x0"},"blockValue":"0x0","blobsBundle":{"commitments":[],"proofs":[],"blobs":[]},"shouldOverrideBuilder":false,"parentBeaconBlockRoot":"0xdead00000000000000000000000000000000000000000000000000000000beef","executionRequests":["0xdeadbeef"]}"#;
let envelope: OpExecutionPayloadEnvelopeV4 = serde_json::from_str(response).unwrap();
assert_eq!(serde_json::to_string(&envelope).unwrap(), response);
}
Expand Down

0 comments on commit 4b3874b

Please sign in to comment.