mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-01-10 07:48:19 -05:00
chore: Make reth-ethereum-consensus no_std compatible (#15821)
Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
1
.github/assets/check_rv32imac.sh
vendored
1
.github/assets/check_rv32imac.sh
vendored
@@ -25,6 +25,7 @@ crates_to_check=(
|
||||
reth-evm-ethereum
|
||||
reth-ethereum-forks
|
||||
reth-ethereum-primitives
|
||||
reth-ethereum-consensus
|
||||
|
||||
## optimism
|
||||
reth-optimism-chainspec
|
||||
|
||||
@@ -349,7 +349,7 @@ reth-era-downloader = { path = "crates/era-downloader" }
|
||||
reth-eth-wire = { path = "crates/net/eth-wire" }
|
||||
reth-eth-wire-types = { path = "crates/net/eth-wire-types" }
|
||||
reth-ethereum-cli = { path = "crates/ethereum/cli" }
|
||||
reth-ethereum-consensus = { path = "crates/ethereum/consensus" }
|
||||
reth-ethereum-consensus = { path = "crates/ethereum/consensus", default-features = false }
|
||||
reth-ethereum-engine-primitives = { path = "crates/ethereum/engine-primitives", default-features = false }
|
||||
reth-ethereum-forks = { path = "crates/ethereum-forks", default-features = false }
|
||||
reth-ethereum-payload-builder = { path = "crates/ethereum/payload" }
|
||||
|
||||
@@ -25,6 +25,21 @@ alloy-consensus.workspace = true
|
||||
|
||||
tracing.workspace = true
|
||||
|
||||
[features]
|
||||
default = ["std"]
|
||||
std = [
|
||||
"alloy-consensus/std",
|
||||
"alloy-eips/std",
|
||||
"alloy-primitives/std",
|
||||
"reth-chainspec/std",
|
||||
"reth-consensus/std",
|
||||
"reth-consensus-common/std",
|
||||
"reth-ethereum-primitives/std",
|
||||
"reth-execution-types/std",
|
||||
"reth-primitives-traits/std",
|
||||
"tracing/std",
|
||||
]
|
||||
|
||||
[dev-dependencies]
|
||||
reth-ethereum-primitives.workspace = true
|
||||
alloy-primitives = { workspace = true, features = ["getrandom"] }
|
||||
|
||||
@@ -7,9 +7,13 @@
|
||||
)]
|
||||
#![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 alloc::{fmt::Debug, sync::Arc};
|
||||
use alloy_consensus::EMPTY_OMMER_ROOT_HASH;
|
||||
use alloy_eips::{eip7840::BlobParams, merge::ALLOWED_FUTURE_BLOCK_TIME_SECONDS};
|
||||
use alloy_eips::eip7840::BlobParams;
|
||||
use alloy_primitives::U256;
|
||||
use reth_chainspec::{EthChainSpec, EthereumHardforks};
|
||||
use reth_consensus::{Consensus, ConsensusError, FullConsensus, HeaderValidator};
|
||||
@@ -24,7 +28,6 @@ use reth_primitives_traits::{
|
||||
constants::{GAS_LIMIT_BOUND_DIVISOR, MINIMUM_GAS_LIMIT},
|
||||
Block, BlockHeader, NodePrimitives, RecoveredBlock, SealedBlock, SealedHeader,
|
||||
};
|
||||
use std::{fmt::Debug, sync::Arc, time::SystemTime};
|
||||
|
||||
mod validation;
|
||||
pub use validation::validate_block_post_execution;
|
||||
@@ -241,14 +244,20 @@ where
|
||||
// order, making those checks obsolete.
|
||||
|
||||
// Check if timestamp is in the future. Clock can drift but this can be consensus issue.
|
||||
let present_timestamp =
|
||||
SystemTime::now().duration_since(SystemTime::UNIX_EPOCH).unwrap().as_secs();
|
||||
|
||||
if header.timestamp() > present_timestamp + ALLOWED_FUTURE_BLOCK_TIME_SECONDS {
|
||||
return Err(ConsensusError::TimestampIsInFuture {
|
||||
timestamp: header.timestamp(),
|
||||
present_timestamp,
|
||||
})
|
||||
#[cfg(feature = "std")]
|
||||
{
|
||||
let present_timestamp = std::time::SystemTime::now()
|
||||
.duration_since(std::time::SystemTime::UNIX_EPOCH)
|
||||
.unwrap()
|
||||
.as_secs();
|
||||
if header.timestamp() >
|
||||
present_timestamp + alloy_eips::merge::ALLOWED_FUTURE_BLOCK_TIME_SECONDS
|
||||
{
|
||||
return Err(ConsensusError::TimestampIsInFuture {
|
||||
timestamp: header.timestamp(),
|
||||
present_timestamp,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
validate_header_extra_data(header)?;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
use alloc::vec::Vec;
|
||||
use alloy_consensus::{proofs::calculate_receipt_root, BlockHeader, TxReceipt};
|
||||
use alloy_eips::eip7685::Requests;
|
||||
use alloy_primitives::{Bloom, B256};
|
||||
|
||||
@@ -49,6 +49,7 @@ default = ["std"]
|
||||
std = [
|
||||
"reth-chainspec/std",
|
||||
"reth-ethereum-primitives/std",
|
||||
"reth-ethereum-consensus/std",
|
||||
"reth-primitives-traits/std",
|
||||
"reth-consensus?/std",
|
||||
"reth-consensus-common?/std",
|
||||
@@ -84,7 +85,17 @@ test-utils = [
|
||||
"reth-transaction-pool?/test-utils",
|
||||
]
|
||||
|
||||
full = ["consensus", "evm", "node", "provider", "rpc", "exex", "trie", "pool", "network"]
|
||||
full = [
|
||||
"consensus",
|
||||
"evm",
|
||||
"node",
|
||||
"provider",
|
||||
"rpc",
|
||||
"exex",
|
||||
"trie",
|
||||
"pool",
|
||||
"network",
|
||||
]
|
||||
|
||||
alloy-compat = ["reth-ethereum-primitives/alloy-compat"]
|
||||
cli = ["dep:reth-ethereum-cli"]
|
||||
|
||||
Reference in New Issue
Block a user