feat(no_std): Add no_std support for reth-payload-primitives (#13922)

This commit is contained in:
Emilia Hane
2025-01-22 21:12:36 +01:00
committed by GitHub
parent 5238486882
commit 3e961806b6
6 changed files with 75 additions and 53 deletions

View File

@ -35,4 +35,16 @@ tokio = { workspace = true, default-features = false, features = ["sync"] }
assert_matches.workspace = true
[features]
default = ["std"]
std = [
"reth-chainspec/std",
"reth-primitives/std",
"revm-primitives/std",
"alloy-eips/std",
"alloy-primitives/std",
"alloy-rpc-types-engine/std",
"op-alloy-rpc-types-engine?/std",
"serde/std",
"thiserror/std",
]
op = ["dep:op-alloy-rpc-types-engine"]

View File

@ -1,5 +1,6 @@
//! Error types emitted by types or implementations of this crate.
use alloc::boxed::Box;
use alloy_primitives::B256;
use alloy_rpc_types_engine::ForkchoiceUpdateError;
use reth_errors::{ProviderError, RethError};

View File

@ -7,7 +7,11 @@
)]
#![cfg_attr(not(test), warn(unused_crate_dependencies))]
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
#![cfg_attr(not(feature = "std"), no_std)]
extern crate alloc;
use crate::alloc::string::ToString;
use alloy_primitives::Bytes;
use reth_chainspec::EthereumHardforks;

View File

@ -1,4 +1,5 @@
use crate::{MessageValidationKind, PayloadAttributes};
use alloc::vec::Vec;
use alloy_eips::eip4895::Withdrawal;
use alloy_primitives::B256;
use alloy_rpc_types_engine::ExecutionPayload;

View File

@ -1,15 +1,17 @@
use alloc::vec::Vec;
use alloy_eips::{
eip4895::{Withdrawal, Withdrawals},
eip7685::Requests,
};
use alloy_primitives::{Address, B256, U256};
use alloy_rpc_types_engine::{PayloadAttributes as EthPayloadAttributes, PayloadId};
use core::fmt;
use reth_chain_state::ExecutedBlock;
use reth_primitives::{NodePrimitives, SealedBlock};
/// Represents a built payload type that contains a built `SealedBlock` and can be converted into
/// engine API execution payloads.
pub trait BuiltPayload: Send + Sync + std::fmt::Debug {
pub trait BuiltPayload: Send + Sync + fmt::Debug {
/// The node's primitive types
type Primitives: NodePrimitives;
@ -32,7 +34,7 @@ pub trait BuiltPayload: Send + Sync + std::fmt::Debug {
///
/// This is used as a conversion type, transforming a payload attributes type that the engine API
/// receives, into a type that the payload builder can use.
pub trait PayloadBuilderAttributes: Send + Sync + std::fmt::Debug {
pub trait PayloadBuilderAttributes: Send + Sync + fmt::Debug {
/// The payload attributes that can be used to construct this type. Used as the argument in
/// [`PayloadBuilderAttributes::try_new`].
type RpcPayloadAttributes;
@ -77,7 +79,7 @@ pub trait PayloadBuilderAttributes: Send + Sync + std::fmt::Debug {
///
/// This type is emitted as part of the forkchoiceUpdated call
pub trait PayloadAttributes:
serde::de::DeserializeOwned + serde::Serialize + std::fmt::Debug + Clone + Send + Sync + 'static
serde::de::DeserializeOwned + serde::Serialize + fmt::Debug + Clone + Send + Sync + 'static
{
/// Returns the timestamp to be used in the payload job.
fn timestamp(&self) -> u64;