mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
chore: use alloy engine rpc type (#6123)
This commit is contained in:
23
Cargo.lock
generated
23
Cargo.lock
generated
@ -232,23 +232,35 @@ dependencies = [
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "alloy-rpc-trace-types"
|
||||
name = "alloy-rpc-engine-types"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/alloy-rs/alloy#50e38e845afb27fc311a74d2260dd087f8e972f3"
|
||||
source = "git+https://github.com/alloy-rs/alloy#61142b3fee367a9aee087d6cfac8e57abaaa2eb2"
|
||||
dependencies = [
|
||||
"alloy-primitives",
|
||||
"alloy-rlp",
|
||||
"alloy-rpc-types",
|
||||
"itertools 0.12.0",
|
||||
"ethereum_ssz",
|
||||
"ethereum_ssz_derive",
|
||||
"jsonrpsee-types",
|
||||
"serde",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "alloy-rpc-trace-types"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/alloy-rs/alloy#61142b3fee367a9aee087d6cfac8e57abaaa2eb2"
|
||||
dependencies = [
|
||||
"alloy-primitives",
|
||||
"alloy-rpc-types",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "alloy-rpc-types"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/alloy-rs/alloy#50e38e845afb27fc311a74d2260dd087f8e972f3"
|
||||
source = "git+https://github.com/alloy-rs/alloy#61142b3fee367a9aee087d6cfac8e57abaaa2eb2"
|
||||
dependencies = [
|
||||
"alloy-primitives",
|
||||
"alloy-rlp",
|
||||
@ -6701,6 +6713,7 @@ version = "0.1.0-alpha.15"
|
||||
dependencies = [
|
||||
"alloy-primitives",
|
||||
"alloy-rlp",
|
||||
"alloy-rpc-engine-types",
|
||||
"alloy-rpc-trace-types",
|
||||
"alloy-rpc-types",
|
||||
"arbitrary",
|
||||
|
||||
@ -171,6 +171,7 @@ alloy-sol-types = "0.6"
|
||||
alloy-rlp = "0.3"
|
||||
alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy" }
|
||||
alloy-rpc-trace-types = { git = "https://github.com/alloy-rs/alloy" }
|
||||
alloy-rpc-engine-types = { git = "https://github.com/alloy-rs/alloy" }
|
||||
alloy-trie = "0.2"
|
||||
ethers-core = { version = "2.0", default-features = false }
|
||||
ethers-providers = { version = "2.0", default-features = false }
|
||||
|
||||
@ -15,7 +15,8 @@
|
||||
//! Once traits are implemented and custom types are defined, the [EngineTypes] trait can be
|
||||
//! implemented:
|
||||
//! ```no_run
|
||||
//! # use reth_rpc_types::engine::{PayloadAttributes as EthPayloadAttributes, PayloadId, Withdrawal};
|
||||
//! # use reth_rpc_types::engine::{PayloadAttributes as EthPayloadAttributes, PayloadId};
|
||||
//! # use reth_rpc_types::Withdrawal;
|
||||
//! # use reth_primitives::{B256, ChainSpec, Address};
|
||||
//! # use reth_node_api::{EngineTypes, EngineApiMessageVersion, validate_version_specific_fields, AttributesValidationError, PayloadAttributes, PayloadBuilderAttributes, PayloadOrAttributes};
|
||||
//! # use reth_payload_builder::{EthPayloadBuilderAttributes, EthBuiltPayload};
|
||||
|
||||
@ -30,7 +30,7 @@ where
|
||||
}
|
||||
|
||||
/// Return the withdrawals for the payload or attributes.
|
||||
pub fn withdrawals(&self) -> Option<&Vec<reth_rpc_types::engine::payload::Withdrawal>> {
|
||||
pub fn withdrawals(&self) -> Option<&Vec<reth_rpc_types::withdrawal::Withdrawal>> {
|
||||
match self {
|
||||
Self::ExecutionPayload { payload, .. } => payload.withdrawals(),
|
||||
Self::PayloadAttributes(attributes) => attributes.withdrawals(),
|
||||
|
||||
@ -7,8 +7,9 @@ use reth_primitives::{
|
||||
use reth_rpc_types::{
|
||||
engine::{
|
||||
ExecutionPayloadEnvelopeV2, ExecutionPayloadEnvelopeV3, OptimismPayloadAttributes,
|
||||
PayloadAttributes as EthPayloadAttributes, PayloadId, Withdrawal,
|
||||
PayloadAttributes as EthPayloadAttributes, PayloadId,
|
||||
},
|
||||
withdrawal::Withdrawal,
|
||||
ExecutionPayloadV1,
|
||||
};
|
||||
|
||||
|
||||
@ -38,7 +38,7 @@ impl PayloadBuilderAttributes for OptimismPayloadBuilderAttributes {
|
||||
};
|
||||
|
||||
let withdraw = attributes.payload_attributes.withdrawals.map(
|
||||
|withdrawals: Vec<reth_rpc_types::engine::payload::Withdrawal>| {
|
||||
|withdrawals: Vec<reth_rpc_types::withdrawal::Withdrawal>| {
|
||||
withdrawals
|
||||
.into_iter()
|
||||
.map(convert_standalone_withdraw_to_withdrawal) // Removed the parentheses here
|
||||
|
||||
@ -177,7 +177,7 @@ impl EthPayloadBuilderAttributes {
|
||||
let id = payload_id(&parent, &attributes);
|
||||
|
||||
let withdraw = attributes.withdrawals.map(
|
||||
|withdrawals: Vec<reth_rpc_types::engine::payload::Withdrawal>| {
|
||||
|withdrawals: Vec<reth_rpc_types::withdrawal::Withdrawal>| {
|
||||
withdrawals
|
||||
.into_iter()
|
||||
.map(convert_standalone_withdraw_to_withdrawal) // Removed the parentheses here
|
||||
|
||||
@ -400,7 +400,7 @@ const _: [(); std::mem::size_of::<BlobTransactionSidecar>()] =
|
||||
[(); std::mem::size_of::<BlobTransactionSidecarRlp>()];
|
||||
|
||||
const _: [(); std::mem::size_of::<BlobTransactionSidecar>()] =
|
||||
[(); std::mem::size_of::<reth_rpc_types::transaction::BlobTransactionSidecar>()];
|
||||
[(); std::mem::size_of::<reth_rpc_types::BlobTransactionSidecar>()];
|
||||
|
||||
impl BlobTransactionSidecarRlp {
|
||||
fn wrap_ref(other: &BlobTransactionSidecar) -> &Self {
|
||||
|
||||
@ -862,7 +862,7 @@ mod tests {
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
let res = api.exchange_transition_configuration(transition_config.clone()).await;
|
||||
let res = api.exchange_transition_configuration(transition_config).await;
|
||||
|
||||
assert_matches!(
|
||||
res,
|
||||
@ -890,7 +890,7 @@ mod tests {
|
||||
};
|
||||
|
||||
// Unknown block number
|
||||
let res = api.exchange_transition_configuration(transition_config.clone()).await;
|
||||
let res = api.exchange_transition_configuration(transition_config).await;
|
||||
|
||||
assert_matches!(
|
||||
res,
|
||||
@ -904,7 +904,7 @@ mod tests {
|
||||
execution_terminal_block.clone().unseal(),
|
||||
);
|
||||
|
||||
let res = api.exchange_transition_configuration(transition_config.clone()).await;
|
||||
let res = api.exchange_transition_configuration(transition_config).await;
|
||||
|
||||
assert_matches!(
|
||||
res,
|
||||
@ -929,8 +929,7 @@ mod tests {
|
||||
|
||||
handle.provider.add_block(terminal_block.hash(), terminal_block.unseal());
|
||||
|
||||
let config =
|
||||
api.exchange_transition_configuration(transition_config.clone()).await.unwrap();
|
||||
let config = api.exchange_transition_configuration(transition_config).await.unwrap();
|
||||
assert_eq!(config, transition_config);
|
||||
}
|
||||
}
|
||||
|
||||
@ -139,7 +139,7 @@ pub fn try_block_to_payload_v2(value: SealedBlock) -> ExecutionPayloadV2 {
|
||||
encoded.into()
|
||||
})
|
||||
.collect();
|
||||
let standalone_withdrawals: Vec<reth_rpc_types::engine::payload::Withdrawal> = value
|
||||
let standalone_withdrawals: Vec<reth_rpc_types::withdrawal::Withdrawal> = value
|
||||
.withdrawals
|
||||
.clone()
|
||||
.unwrap_or_default()
|
||||
@ -180,7 +180,7 @@ pub fn block_to_payload_v3(value: SealedBlock) -> ExecutionPayloadV3 {
|
||||
})
|
||||
.collect();
|
||||
|
||||
let withdrawals: Vec<reth_rpc_types::engine::payload::Withdrawal> = value
|
||||
let withdrawals: Vec<reth_rpc_types::withdrawal::Withdrawal> = value
|
||||
.withdrawals
|
||||
.clone()
|
||||
.unwrap_or_default()
|
||||
@ -318,11 +318,11 @@ pub fn validate_block_hash(
|
||||
Ok(sealed_block)
|
||||
}
|
||||
|
||||
/// Converts [Withdrawal] to [reth_rpc_types::engine::payload::Withdrawal]
|
||||
/// Converts [Withdrawal] to [reth_rpc_types::withdrawal::Withdrawal]
|
||||
pub fn convert_withdrawal_to_standalone_withdraw(
|
||||
withdrawal: Withdrawal,
|
||||
) -> reth_rpc_types::engine::payload::Withdrawal {
|
||||
reth_rpc_types::engine::payload::Withdrawal {
|
||||
) -> reth_rpc_types::withdrawal::Withdrawal {
|
||||
reth_rpc_types::withdrawal::Withdrawal {
|
||||
index: withdrawal.index,
|
||||
validator_index: withdrawal.validator_index,
|
||||
address: withdrawal.address,
|
||||
@ -330,9 +330,9 @@ pub fn convert_withdrawal_to_standalone_withdraw(
|
||||
}
|
||||
}
|
||||
|
||||
/// Converts [reth_rpc_types::engine::payload::Withdrawal] to [Withdrawal]
|
||||
/// Converts [reth_rpc_types::withdrawal::Withdrawal] to [Withdrawal]
|
||||
pub fn convert_standalone_withdraw_to_withdrawal(
|
||||
standalone: reth_rpc_types::engine::payload::Withdrawal,
|
||||
standalone: reth_rpc_types::withdrawal::Withdrawal,
|
||||
) -> Withdrawal {
|
||||
Withdrawal {
|
||||
index: standalone.index,
|
||||
@ -349,7 +349,7 @@ pub fn convert_to_payload_body_v1(value: Block) -> ExecutionPayloadBodyV1 {
|
||||
tx.encode_enveloped(&mut out);
|
||||
out.into()
|
||||
});
|
||||
let withdraw: Option<Vec<reth_rpc_types::engine::payload::Withdrawal>> =
|
||||
let withdraw: Option<Vec<reth_rpc_types::withdrawal::Withdrawal>> =
|
||||
value.withdrawals.map(|withdrawals| {
|
||||
withdrawals
|
||||
.into_iter()
|
||||
|
||||
@ -17,6 +17,7 @@ alloy-rlp = { workspace = true, features = ["arrayvec", "derive"] }
|
||||
alloy-primitives = { workspace = true, features = ["rand", "rlp", "serde"] }
|
||||
alloy-rpc-types = { workspace = true, features = ["jsonrpsee-types"] }
|
||||
alloy-rpc-trace-types.workspace = true
|
||||
alloy-rpc-engine-types = { workspace = true, features = ["jsonrpsee-types"] }
|
||||
ethereum_ssz_derive = { version = "0.5", optional = true }
|
||||
ethereum_ssz = { version = "0.5", optional = true }
|
||||
|
||||
@ -41,7 +42,7 @@ proptest-derive = { workspace = true, optional = true }
|
||||
[features]
|
||||
default = ["jsonrpsee-types"]
|
||||
arbitrary = ["dep:arbitrary", "dep:proptest-derive", "dep:proptest", "alloy-primitives/arbitrary", "alloy-rpc-types/arbitrary"]
|
||||
ssz = ["dep:ethereum_ssz" ,"dep:ethereum_ssz_derive", "alloy-primitives/ssz", "alloy-rpc-types/ssz"]
|
||||
ssz = ["dep:ethereum_ssz" ,"dep:ethereum_ssz_derive", "alloy-primitives/ssz", "alloy-rpc-types/ssz", "alloy-rpc-engine-types/ssz"]
|
||||
optimism = []
|
||||
|
||||
|
||||
|
||||
@ -1,60 +0,0 @@
|
||||
//! Contains types related to the Cancun hardfork that will be used by RPC to communicate with the
|
||||
//! beacon consensus engine.
|
||||
|
||||
use alloy_primitives::B256;
|
||||
|
||||
/// Fields introduced in `engine_newPayloadV3` that are not present in the `ExecutionPayload` RPC
|
||||
/// object.
|
||||
///
|
||||
/// See also:
|
||||
/// <https://github.com/ethereum/execution-apis/blob/fe8e13c288c592ec154ce25c534e26cb7ce0530d/src/engine/cancun.md#request>
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash, Default, serde::Serialize, serde::Deserialize)]
|
||||
pub struct CancunPayloadFields {
|
||||
/// The parent beacon block root.
|
||||
pub parent_beacon_block_root: B256,
|
||||
|
||||
/// The expected blob versioned hashes.
|
||||
pub versioned_hashes: Vec<B256>,
|
||||
}
|
||||
|
||||
/// A container type for [CancunPayloadFields] that may or may not be present.
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash, Default)]
|
||||
pub struct MaybeCancunPayloadFields {
|
||||
fields: Option<CancunPayloadFields>,
|
||||
}
|
||||
|
||||
impl MaybeCancunPayloadFields {
|
||||
/// Returns a new `MaybeCancunPayloadFields` with no cancun fields.
|
||||
pub const fn none() -> Self {
|
||||
Self { fields: None }
|
||||
}
|
||||
|
||||
/// Returns a new `MaybeCancunPayloadFields` with the given cancun fields.
|
||||
pub fn into_inner(self) -> Option<CancunPayloadFields> {
|
||||
self.fields
|
||||
}
|
||||
|
||||
/// Returns the parent beacon block root, if any.
|
||||
pub fn parent_beacon_block_root(&self) -> Option<B256> {
|
||||
self.fields.as_ref().map(|fields| fields.parent_beacon_block_root)
|
||||
}
|
||||
|
||||
/// Returns the blob versioned hashes, if any.
|
||||
pub fn versioned_hashes(&self) -> Option<&Vec<B256>> {
|
||||
self.fields.as_ref().map(|fields| &fields.versioned_hashes)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<CancunPayloadFields> for MaybeCancunPayloadFields {
|
||||
#[inline]
|
||||
fn from(fields: CancunPayloadFields) -> Self {
|
||||
Self { fields: Some(fields) }
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Option<CancunPayloadFields>> for MaybeCancunPayloadFields {
|
||||
#[inline]
|
||||
fn from(fields: Option<CancunPayloadFields>) -> Self {
|
||||
Self { fields }
|
||||
}
|
||||
}
|
||||
@ -1,124 +0,0 @@
|
||||
use super::{PayloadStatus, PayloadStatusEnum};
|
||||
use crate::engine::PayloadId;
|
||||
use alloy_primitives::B256;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// invalid forkchoice state error code.
|
||||
pub const INVALID_FORK_CHOICE_STATE_ERROR: i32 = -38002;
|
||||
|
||||
/// invalid payload attributes error code.
|
||||
pub const INVALID_PAYLOAD_ATTRIBUTES_ERROR: i32 = -38003;
|
||||
|
||||
/// invalid forkchoice state error message.
|
||||
pub const INVALID_FORK_CHOICE_STATE_ERROR_MSG: &str = "Invalid forkchoice state";
|
||||
|
||||
/// invalid payload attributes error message.
|
||||
pub const INVALID_PAYLOAD_ATTRIBUTES_ERROR_MSG: &str = "Invalid payload attributes";
|
||||
|
||||
/// Represents possible variants of a processed forkchoice update.
|
||||
pub type ForkChoiceUpdateResult = Result<ForkchoiceUpdated, ForkchoiceUpdateError>;
|
||||
|
||||
/// This structure encapsulates the fork choice state
|
||||
#[derive(Default, Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct ForkchoiceState {
|
||||
/// Hash of the head block.
|
||||
pub head_block_hash: B256,
|
||||
/// Hash of the safe block.
|
||||
pub safe_block_hash: B256,
|
||||
/// Hash of finalized block.
|
||||
pub finalized_block_hash: B256,
|
||||
}
|
||||
|
||||
/// A standalone forkchoice update errors for RPC.
|
||||
///
|
||||
/// These are considered hard RPC errors and are _not_ returned as [PayloadStatus] or
|
||||
/// [PayloadStatusEnum::Invalid].
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, thiserror::Error)]
|
||||
pub enum ForkchoiceUpdateError {
|
||||
/// The forkchoice update has been processed, but the requested contained invalid
|
||||
/// [PayloadAttributes](crate::engine::PayloadAttributes).
|
||||
///
|
||||
/// This is returned as an error because the payload attributes are invalid and the payload is not valid, See <https://github.com/ethereum/execution-apis/blob/6709c2a795b707202e93c4f2867fa0bf2640a84f/src/engine/paris.md#engine_forkchoiceupdatedv1>
|
||||
#[error("invalid payload attributes")]
|
||||
UpdatedInvalidPayloadAttributes,
|
||||
/// The given [ForkchoiceState] is invalid or inconsistent.
|
||||
#[error("invalid forkchoice state")]
|
||||
InvalidState,
|
||||
/// Thrown when a forkchoice final block does not exist in the database.
|
||||
#[error("final block not available in database")]
|
||||
UnknownFinalBlock,
|
||||
}
|
||||
|
||||
#[cfg(feature = "jsonrpsee-types")]
|
||||
impl From<ForkchoiceUpdateError> for jsonrpsee_types::error::ErrorObject<'static> {
|
||||
fn from(value: ForkchoiceUpdateError) -> Self {
|
||||
match value {
|
||||
ForkchoiceUpdateError::UpdatedInvalidPayloadAttributes => {
|
||||
jsonrpsee_types::error::ErrorObject::owned(
|
||||
INVALID_PAYLOAD_ATTRIBUTES_ERROR,
|
||||
INVALID_PAYLOAD_ATTRIBUTES_ERROR_MSG,
|
||||
None::<()>,
|
||||
)
|
||||
}
|
||||
ForkchoiceUpdateError::InvalidState => jsonrpsee_types::error::ErrorObject::owned(
|
||||
INVALID_FORK_CHOICE_STATE_ERROR,
|
||||
INVALID_FORK_CHOICE_STATE_ERROR_MSG,
|
||||
None::<()>,
|
||||
),
|
||||
ForkchoiceUpdateError::UnknownFinalBlock => jsonrpsee_types::error::ErrorObject::owned(
|
||||
INVALID_FORK_CHOICE_STATE_ERROR,
|
||||
INVALID_FORK_CHOICE_STATE_ERROR_MSG,
|
||||
None::<()>,
|
||||
),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Represents a successfully _processed_ forkchoice state update.
|
||||
///
|
||||
/// Note: this can still be INVALID if the provided payload was invalid.
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct ForkchoiceUpdated {
|
||||
/// Represents the outcome of the validation of the payload, independently of the payload being
|
||||
/// valid or not.
|
||||
pub payload_status: PayloadStatus,
|
||||
/// The identifier of the payload build process that was successfully initiated.
|
||||
pub payload_id: Option<PayloadId>,
|
||||
}
|
||||
|
||||
impl ForkchoiceUpdated {
|
||||
pub fn new(payload_status: PayloadStatus) -> Self {
|
||||
Self { payload_status, payload_id: None }
|
||||
}
|
||||
|
||||
pub fn from_status(status: PayloadStatusEnum) -> Self {
|
||||
Self { payload_status: PayloadStatus::from_status(status), payload_id: None }
|
||||
}
|
||||
|
||||
pub fn with_latest_valid_hash(mut self, hash: B256) -> Self {
|
||||
self.payload_status.latest_valid_hash = Some(hash);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_payload_id(mut self, id: PayloadId) -> Self {
|
||||
self.payload_id = Some(id);
|
||||
self
|
||||
}
|
||||
|
||||
/// Returns true if the payload status is syncing.
|
||||
pub fn is_syncing(&self) -> bool {
|
||||
self.payload_status.is_syncing()
|
||||
}
|
||||
|
||||
/// Returns true if the payload status is valid.
|
||||
pub fn is_valid(&self) -> bool {
|
||||
self.payload_status.is_valid()
|
||||
}
|
||||
|
||||
/// Returns true if the payload status is invalid.
|
||||
pub fn is_invalid(&self) -> bool {
|
||||
self.payload_status.is_invalid()
|
||||
}
|
||||
}
|
||||
@ -1,29 +0,0 @@
|
||||
//! Engine API types:
|
||||
//! <https://github.com/ethereum/execution-apis/blob/main/src/engine/authentication.md>
|
||||
//! and <https://eips.ethereum.org/EIPS/eip-3675>,
|
||||
//! following the execution specs <https://github.com/ethereum/execution-apis/tree/6709c2a795b707202e93c4f2867fa0bf2640a84f/src/engine>.
|
||||
|
||||
#![allow(missing_docs)]
|
||||
|
||||
mod cancun;
|
||||
mod forkchoice;
|
||||
mod optimism;
|
||||
pub mod payload;
|
||||
mod transition;
|
||||
pub use self::{cancun::*, forkchoice::*, optimism::*, payload::*, transition::*};
|
||||
|
||||
/// The list of all supported Engine capabilities available over the engine endpoint.
|
||||
pub const CAPABILITIES: [&str; 12] = [
|
||||
"engine_forkchoiceUpdatedV1",
|
||||
"engine_forkchoiceUpdatedV2",
|
||||
"engine_forkchoiceUpdatedV3",
|
||||
"engine_exchangeTransitionConfigurationV1",
|
||||
"engine_getPayloadV1",
|
||||
"engine_getPayloadV2",
|
||||
"engine_getPayloadV3",
|
||||
"engine_newPayloadV1",
|
||||
"engine_newPayloadV2",
|
||||
"engine_newPayloadV3",
|
||||
"engine_getPayloadBodiesByHashV1",
|
||||
"engine_getPayloadBodiesByRangeV1",
|
||||
];
|
||||
@ -1,44 +0,0 @@
|
||||
use crate::engine::PayloadAttributes;
|
||||
use alloy_primitives::Bytes;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// Optimism Payload Attributes
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct OptimismPayloadAttributes {
|
||||
/// The payload attributes
|
||||
#[serde(flatten)]
|
||||
pub payload_attributes: PayloadAttributes,
|
||||
/// Transactions is a field for rollups: the transactions list is forced into the block
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub transactions: Option<Vec<Bytes>>,
|
||||
/// If true, the no transactions are taken out of the tx-pool, only transactions from the above
|
||||
/// Transactions list will be included.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub no_tx_pool: Option<bool>,
|
||||
/// If set, this sets the exact gas limit the block produced with.
|
||||
#[serde(
|
||||
skip_serializing_if = "Option::is_none",
|
||||
deserialize_with = "crate::serde_helpers::u64_hex_opt::deserialize"
|
||||
)]
|
||||
pub gas_limit: Option<u64>,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::engine::{ExecutionPayloadInputV2, OptimismPayloadAttributes};
|
||||
|
||||
// <https://github.com/paradigmxyz/reth/issues/6036>
|
||||
#[test]
|
||||
fn deserialize_op_base_payload() {
|
||||
let payload = r#"{"parentHash":"0x24e8df372a61cdcdb1a163b52aaa1785e0c869d28c3b742ac09e826bbb524723","feeRecipient":"0x4200000000000000000000000000000000000011","stateRoot":"0x9a5db45897f1ff1e620a6c14b0a6f1b3bcdbed59f2adc516a34c9a9d6baafa71","receiptsRoot":"0x8af6f74835d47835deb5628ca941d00e0c9fd75585f26dabdcb280ec7122e6af","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","prevRandao":"0xf37b24eeff594848072a05f74c8600001706c83e489a9132e55bf43a236e42ec","blockNumber":"0xe3d5d8","gasLimit":"0x17d7840","gasUsed":"0xb705","timestamp":"0x65a118c0","extraData":"0x","baseFeePerGas":"0x7a0ff32","blockHash":"0xf5c147b2d60a519b72434f0a8e082e18599021294dd9085d7597b0ffa638f1c0","withdrawals":[],"transactions":["0x7ef90159a05ba0034ffdcb246703298224564720b66964a6a69d0d7e9ffd970c546f7c048094deaddeaddeaddeaddeaddeaddeaddeaddead00019442000000000000000000000000000000000000158080830f424080b90104015d8eb900000000000000000000000000000000000000000000000000000000009e1c4a0000000000000000000000000000000000000000000000000000000065a11748000000000000000000000000000000000000000000000000000000000000000a4b479e5fa8d52dd20a8a66e468b56e993bdbffcccf729223aabff06299ab36db000000000000000000000000000000000000000000000000000000000000000400000000000000000000000073b4168cc87f35cc239200a20eb841cded23493b000000000000000000000000000000000000000000000000000000000000083400000000000000000000000000000000000000000000000000000000000f4240"]}"#;
|
||||
let _payload = serde_json::from_str::<ExecutionPayloadInputV2>(payload).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn deserialize_op_payload_attributes() {
|
||||
let payload = r#"{"prevRandao":"0x24e8df372a61cdcdb1a163b52aaa1785e0c869d28c3b742ac09e826bbb524723","suggestedFeeRecipient":"0x4200000000000000000000000000000000000011","timestamp":"1","gasLimit":"0x17d7840","transactions":[],"no_tx_pool":"true","withdrawals":[]}"#;
|
||||
let _payload = serde_json::from_str::<OptimismPayloadAttributes>(payload).unwrap();
|
||||
assert!(_payload.payload_attributes.withdrawals.is_some())
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,14 +0,0 @@
|
||||
use alloy_primitives::{B256, U256, U64};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// This structure contains configurable settings of the transition process.
|
||||
#[derive(Default, Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct TransitionConfiguration {
|
||||
/// Maps on the TERMINAL_TOTAL_DIFFICULTY parameter of EIP-3675
|
||||
pub terminal_total_difficulty: U256,
|
||||
/// Maps on TERMINAL_BLOCK_HASH parameter of EIP-3675
|
||||
pub terminal_block_hash: B256,
|
||||
/// Maps on TERMINAL_BLOCK_NUMBER parameter of EIP-3675
|
||||
pub terminal_block_number: U64,
|
||||
}
|
||||
@ -1,4 +1,6 @@
|
||||
//! Ethereum related types
|
||||
|
||||
pub mod engine;
|
||||
pub mod transaction;
|
||||
|
||||
// re-export
|
||||
pub use alloy_rpc_engine_types as engine;
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
use crate::{
|
||||
eth::transaction::typed::{
|
||||
BlobTransactionSidecar, EIP1559TransactionRequest, EIP2930TransactionRequest,
|
||||
EIP4844TransactionRequest, LegacyTransactionRequest, TransactionKind,
|
||||
TypedTransactionRequest,
|
||||
EIP1559TransactionRequest, EIP2930TransactionRequest, EIP4844TransactionRequest,
|
||||
LegacyTransactionRequest, TransactionKind, TypedTransactionRequest,
|
||||
},
|
||||
AccessList,
|
||||
};
|
||||
use alloy_primitives::{Address, Bytes, B256, U128, U256, U64, U8};
|
||||
use alloy_rpc_types::BlobTransactionSidecar;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// Represents _all_ transaction requests received from RPC
|
||||
|
||||
@ -4,10 +4,7 @@
|
||||
|
||||
use alloy_primitives::{Address, Bytes, B256, U128, U256, U64};
|
||||
use alloy_rlp::{BufMut, Decodable, Encodable, Error as RlpError};
|
||||
use alloy_rpc_types::{
|
||||
kzg::{Blob, Bytes48},
|
||||
AccessList,
|
||||
};
|
||||
use alloy_rpc_types::{AccessList, BlobTransactionSidecar};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// Container type for various Ethereum transaction requests
|
||||
@ -181,18 +178,6 @@ impl Decodable for TransactionKind {
|
||||
}
|
||||
}
|
||||
|
||||
/// This represents a set of blobs, and its corresponding commitments and proofs.
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Default, Serialize, Deserialize)]
|
||||
#[repr(C)]
|
||||
pub struct BlobTransactionSidecar {
|
||||
/// The blob data.
|
||||
pub blobs: Vec<Blob>,
|
||||
/// The blob commitments.
|
||||
pub commitments: Vec<Bytes48>,
|
||||
/// The blob proofs.
|
||||
pub proofs: Vec<Bytes48>,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
@ -34,9 +34,7 @@ pub use eth::{
|
||||
engine::{
|
||||
ExecutionPayload, ExecutionPayloadV1, ExecutionPayloadV2, ExecutionPayloadV3, PayloadError,
|
||||
},
|
||||
transaction::{
|
||||
self, BlobTransactionSidecar, TransactionKind, TransactionRequest, TypedTransactionRequest,
|
||||
},
|
||||
transaction::{self, TransactionKind, TransactionRequest, TypedTransactionRequest},
|
||||
};
|
||||
|
||||
pub use admin::*;
|
||||
|
||||
Reference in New Issue
Block a user