Skip to content

Commit

Permalink
chore: replace ExitV1 with WithdrawalRequest (alloy-rs#672)
Browse files Browse the repository at this point in the history
* chore: replace `ExitV1` with `WithdrawalRequest`

EIP-7002 has been changed to work with EIP-7685,
so the exit type no longer exists and is instead a
`WithdrawalRequest` object.

In the engine API spec this is called `WithdrawalRequestV1`,
which is why it is re-exported as such from `alloy-eips`

* fix: cfg attr for serde

* chore: correct field name

* chore: cfg attr _-_

* chore: delete `exit` module (unused)
  • Loading branch information
onbjerg authored and ben186 committed Jul 27, 2024
1 parent 1010660 commit 4225947
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 27 deletions.
25 changes: 25 additions & 0 deletions crates/eips/src/eip7002.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//! Contains WithdrawalRequest types, first introduced in the [Prague hardfork](https://github.com/ethereum/execution-apis/blob/main/src/engine/prague.md).
//!
//! See also [EIP-7002](https://eips.ethereum.org/EIPS/eip-7002): Execution layer triggerable withdrawals

use alloy_primitives::{Address, FixedBytes};

/// Represents an execution layer triggerable withdrawal request.
///
/// See [EIP-7002](https://eips.ethereum.org/EIPS/eip-7002).
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))]
#[cfg_attr(
any(test, feature = "arbitrary"),
derive(proptest_derive::Arbitrary, arbitrary::Arbitrary)
)]
pub struct WithdrawalRequest {
/// Address of the source of the exit.
pub source_address: Address,
/// Validator public key.
pub validator_public_key: FixedBytes<48>,
/// Amount of withdrawn ether in gwei.
#[cfg_attr(feature = "serde", serde(with = "alloy_serde::u64_via_ruint"))]
pub amount: u64,
}
4 changes: 3 additions & 1 deletion crates/eips/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,12 @@ pub mod eip2930;

pub mod eip4788;

pub mod eip4895;

pub mod eip4844;
pub use eip4844::{calc_blob_gasprice, calc_excess_blob_gas};

pub mod eip6110;
pub mod merge;

pub mod eip4895;
pub mod eip7002;
19 changes: 0 additions & 19 deletions crates/rpc-types-engine/src/exit.rs

This file was deleted.

7 changes: 4 additions & 3 deletions crates/rpc-types-engine/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]

mod cancun;
mod exit;
mod forkchoice;
mod identification;
mod jwt;
Expand All @@ -30,13 +29,15 @@ pub mod payload;
mod transition;

pub use self::{
cancun::*, exit::*, forkchoice::*, identification::*, jwt::*, optimism::*, payload::*,
transition::*,
cancun::*, forkchoice::*, identification::*, jwt::*, optimism::*, payload::*, transition::*,
};

#[doc(inline)]
pub use alloy_eips::eip6110::DepositReceipt;

#[doc(inline)]
pub use alloy_eips::eip7002::WithdrawalRequest as WithdrawalRequestV1;

/// The list of all supported Engine capabilities available over the engine endpoint.
pub const CAPABILITIES: [&str; 12] = [
"engine_forkchoiceUpdatedV1",
Expand Down
9 changes: 5 additions & 4 deletions crates/rpc-types-engine/src/payload.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//! Payload types.
use crate::ExitV1;
use alloy_consensus::{Blob, Bytes48};
use alloy_eips::eip6110::DepositReceipt;
use alloy_eips::{eip6110::DepositReceipt, eip7002::WithdrawalRequest};
use alloy_primitives::{Address, Bloom, Bytes, B256, B64, U256};
use alloy_rpc_types::{transaction::BlobTransactionSidecar, Withdrawal};
use serde::{ser::SerializeMap, Deserialize, Deserializer, Serialize, Serializer};
Expand Down Expand Up @@ -417,8 +416,10 @@ pub struct ExecutionPayloadV4 {
///
/// This maps directly to the Deposits defined in [EIP-6110](https://eips.ethereum.org/EIPS/eip-6110).
pub deposit_receipts: Vec<DepositReceipt>,
/// Array of exits
pub exits: Vec<ExitV1>,
/// Array of execution layer triggerable withdrawal requests.
///
/// See [EIP-7002](https://eips.ethereum.org/EIPS/eip-7002).
pub withdrawal_requests: Vec<WithdrawalRequest>,
}

impl ExecutionPayloadV4 {
Expand Down

0 comments on commit 4225947

Please sign in to comment.