refactor: rm re-exports of alloy eip 4844 constants (#12120)

This commit is contained in:
Thomas Coratger
2024-10-28 09:30:06 +01:00
committed by GitHub
parent 1c36b71612
commit 8605d04a09
16 changed files with 26 additions and 37 deletions

2
Cargo.lock generated
View File

@ -8033,6 +8033,7 @@ name = "reth-node-events"
version = "1.1.0"
dependencies = [
"alloy-consensus",
"alloy-eips",
"alloy-primitives",
"alloy-rpc-types-engine",
"futures",
@ -8041,7 +8042,6 @@ dependencies = [
"reth-beacon-consensus",
"reth-network",
"reth-network-api",
"reth-primitives",
"reth-primitives-traits",
"reth-provider",
"reth-prune",

View File

@ -1,12 +1,10 @@
//! Collection of methods for block validation.
use alloy_consensus::constants::MAXIMUM_EXTRA_DATA_SIZE;
use alloy_eips::eip4844::{DATA_GAS_PER_BLOB, MAX_DATA_GAS_PER_BLOCK};
use reth_chainspec::{EthChainSpec, EthereumHardforks};
use reth_consensus::ConsensusError;
use reth_primitives::{
constants::eip4844::{DATA_GAS_PER_BLOB, MAX_DATA_GAS_PER_BLOCK},
EthereumHardfork, GotExpected, Header, SealedBlock, SealedHeader,
};
use reth_primitives::{EthereumHardfork, GotExpected, Header, SealedBlock, SealedHeader};
use revm_primitives::calc_excess_blob_gas;
/// Gas used needs to be less than gas limit. Gas used is going to be checked after execution.

View File

@ -10,7 +10,7 @@
#![allow(clippy::useless_let_if_seq)]
use alloy_consensus::EMPTY_OMMER_ROOT_HASH;
use alloy_eips::{eip7685::Requests, merge::BEACON_NONCE};
use alloy_eips::{eip4844::MAX_DATA_GAS_PER_BLOCK, eip7685::Requests, merge::BEACON_NONCE};
use alloy_primitives::U256;
use reth_basic_payload_builder::{
commit_withdrawals, is_better_payload, BuildArguments, BuildOutcome, PayloadBuilder,
@ -25,7 +25,6 @@ use reth_execution_types::ExecutionOutcome;
use reth_payload_builder::{EthBuiltPayload, EthPayloadBuilderAttributes};
use reth_payload_primitives::{PayloadBuilderAttributes, PayloadBuilderError};
use reth_primitives::{
constants::eip4844::MAX_DATA_GAS_PER_BLOCK,
proofs::{self},
revm_primitives::{BlockEnv, CfgEnvWithHandlerCfg},
Block, BlockBody, EthereumHardforks, Header, Receipt,

View File

@ -19,13 +19,13 @@ reth-network-api.workspace = true
reth-stages.workspace = true
reth-prune.workspace = true
reth-static-file.workspace = true
reth-primitives.workspace = true
reth-primitives-traits.workspace = true
# ethereum
alloy-primitives.workspace = true
alloy-rpc-types-engine.workspace = true
alloy-consensus.workspace = true
alloy-eips.workspace = true
# async
tokio.workspace = true

View File

@ -10,7 +10,6 @@ use reth_beacon_consensus::{
};
use reth_network::NetworkEvent;
use reth_network_api::PeersInfo;
use reth_primitives::constants;
use reth_primitives_traits::{format_gas, format_gas_throughput};
use reth_prune::PrunerEvent;
use reth_stages::{EntitiesCheckpoint, ExecOutput, PipelineEvent, StageCheckpoint, StageId};
@ -265,8 +264,8 @@ impl NodeState {
gas_throughput=%format_gas_throughput(block.header.gas_used, elapsed),
full=%format!("{:.1}%", block.header.gas_used as f64 * 100.0 / block.header.gas_limit as f64),
base_fee=%format!("{:.2}gwei", block.header.base_fee_per_gas.unwrap_or(0) as f64 / GWEI_TO_WEI as f64),
blobs=block.header.blob_gas_used.unwrap_or(0) / constants::eip4844::DATA_GAS_PER_BLOB,
excess_blobs=block.header.excess_blob_gas.unwrap_or(0) / constants::eip4844::DATA_GAS_PER_BLOB,
blobs=block.header.blob_gas_used.unwrap_or(0) / alloy_eips::eip4844::DATA_GAS_PER_BLOB,
excess_blobs=block.header.excess_blob_gas.unwrap_or(0) / alloy_eips::eip4844::DATA_GAS_PER_BLOB,
?elapsed,
"Block added to canonical chain"
);

View File

@ -1,7 +0,0 @@
//! [EIP-4844](https://eips.ethereum.org/EIPS/eip-4844#parameters) protocol constants and utils for shard Blob Transactions.
pub use alloy_eips::eip4844::{
BLOB_GASPRICE_UPDATE_FRACTION, BLOB_TX_MIN_BLOB_GASPRICE, DATA_GAS_PER_BLOB,
FIELD_ELEMENTS_PER_BLOB, FIELD_ELEMENT_BYTES, MAX_BLOBS_PER_BLOCK, MAX_DATA_GAS_PER_BLOCK,
TARGET_BLOBS_PER_BLOCK, TARGET_DATA_GAS_PER_BLOCK, VERSIONED_HASH_VERSION_KZG,
};

View File

@ -1,6 +1,3 @@
//! Ethereum protocol-related constants
pub use reth_primitives_traits::constants::*;
/// [EIP-4844](https://eips.ethereum.org/EIPS/eip-4844#parameters) constants.
pub mod eip4844;

View File

@ -297,7 +297,7 @@ impl Transaction {
/// transaction.
///
/// This is the number of blobs times the
/// [`DATA_GAS_PER_BLOB`](crate::constants::eip4844::DATA_GAS_PER_BLOB) a single blob consumes.
/// [`DATA_GAS_PER_BLOB`](alloy_eips::eip4844::DATA_GAS_PER_BLOB) a single blob consumes.
pub fn blob_gas_used(&self) -> Option<u64> {
self.as_eip4844().map(TxEip4844::blob_gas)
}

View File

@ -264,7 +264,7 @@ impl PooledTransactionsElement {
/// transaction.
///
/// This is the number of blobs times the
/// [`DATA_GAS_PER_BLOB`](crate::constants::eip4844::DATA_GAS_PER_BLOB) a single blob consumes.
/// [`DATA_GAS_PER_BLOB`](alloy_eips::eip4844::DATA_GAS_PER_BLOB) a single blob consumes.
pub fn blob_gas_used(&self) -> Option<u64> {
self.as_eip4844().map(TxEip4844::blob_gas)
}

View File

@ -167,7 +167,7 @@ pub trait EthFees: LoadFee {
base_fee_per_blob_gas.push(header.blob_fee().unwrap_or_default());
blob_gas_used_ratio.push(
header.blob_gas_used.unwrap_or_default() as f64
/ reth_primitives::constants::eip4844::MAX_DATA_GAS_PER_BLOCK as f64,
/ alloy_eips::eip4844::MAX_DATA_GAS_PER_BLOCK as f64,
);
// Percentiles were specified, so we need to collect reward percentile ino

View File

@ -6,7 +6,9 @@ use std::time::{Duration, Instant};
use crate::{EthApiTypes, FromEthApiError, FromEvmError, RpcNodeCore};
use alloy_consensus::EMPTY_OMMER_ROOT_HASH;
use alloy_eips::{eip7685::EMPTY_REQUESTS_HASH, merge::BEACON_NONCE};
use alloy_eips::{
eip4844::MAX_DATA_GAS_PER_BLOCK, eip7685::EMPTY_REQUESTS_HASH, merge::BEACON_NONCE,
};
use alloy_primitives::{BlockNumber, B256, U256};
use alloy_rpc_types::BlockNumberOrTag;
use futures::Future;
@ -17,7 +19,6 @@ use reth_evm::{
};
use reth_execution_types::ExecutionOutcome;
use reth_primitives::{
constants::eip4844::MAX_DATA_GAS_PER_BLOCK,
proofs::calculate_transaction_root,
revm_primitives::{
BlockEnv, CfgEnv, CfgEnvWithHandlerCfg, EVMError, Env, ExecutionResult, InvalidTransaction,

View File

@ -366,7 +366,7 @@ impl FeeHistoryEntry {
gas_used_ratio: block.gas_used as f64 / block.gas_limit as f64,
base_fee_per_blob_gas: block.blob_fee(),
blob_gas_used_ratio: block.blob_gas_used() as f64 /
reth_primitives::constants::eip4844::MAX_DATA_GAS_PER_BLOCK as f64,
alloy_eips::eip4844::MAX_DATA_GAS_PER_BLOCK as f64,
excess_blob_gas: block.excess_blob_gas,
blob_gas_used: block.blob_gas_used,
gas_used: block.gas_used,

View File

@ -22,9 +22,11 @@ use alloy_consensus::constants::{
EIP1559_TX_TYPE_ID, EIP2930_TX_TYPE_ID, EIP4844_TX_TYPE_ID, EIP7702_TX_TYPE_ID,
LEGACY_TX_TYPE_ID,
};
use alloy_eips::eip1559::{ETHEREUM_BLOCK_GAS_LIMIT, MIN_PROTOCOL_BASE_FEE};
use alloy_eips::{
eip1559::{ETHEREUM_BLOCK_GAS_LIMIT, MIN_PROTOCOL_BASE_FEE},
eip4844::BLOB_TX_MIN_BLOB_GASPRICE,
};
use alloy_primitives::{Address, TxHash, B256};
use reth_primitives::constants::eip4844::BLOB_TX_MIN_BLOB_GASPRICE;
use rustc_hash::FxHashMap;
use smallvec::SmallVec;
use std::{

View File

@ -11,7 +11,7 @@ use alloy_consensus::{
constants::{EIP1559_TX_TYPE_ID, EIP2930_TX_TYPE_ID, EIP4844_TX_TYPE_ID, LEGACY_TX_TYPE_ID},
TxEip1559, TxEip2930, TxEip4844, TxLegacy,
};
use alloy_eips::{eip1559::MIN_PROTOCOL_BASE_FEE, eip2930::AccessList};
use alloy_eips::{eip1559::MIN_PROTOCOL_BASE_FEE, eip2930::AccessList, eip4844::DATA_GAS_PER_BLOB};
use alloy_primitives::{Address, Bytes, ChainId, TxHash, TxKind, B256, U256};
use paste::paste;
use rand::{
@ -19,9 +19,9 @@ use rand::{
prelude::Distribution,
};
use reth_primitives::{
constants::eip4844::DATA_GAS_PER_BLOB, transaction::TryFromRecoveredTransactionError,
BlobTransactionSidecar, BlobTransactionValidationError, PooledTransactionsElementEcRecovered,
Signature, Transaction, TransactionSigned, TransactionSignedEcRecovered, TxType,
transaction::TryFromRecoveredTransactionError, BlobTransactionSidecar,
BlobTransactionValidationError, PooledTransactionsElementEcRecovered, Signature, Transaction,
TransactionSigned, TransactionSignedEcRecovered, TxType,
};
use std::{ops::Range, sync::Arc, time::Instant, vec::IntoIter};

View File

@ -1484,7 +1484,8 @@ impl<Tx: PoolTransaction> Stream for NewSubpoolTransactionStream<Tx> {
mod tests {
use super::*;
use alloy_consensus::{TxEip1559, TxEip2930, TxEip4844, TxEip7702, TxLegacy};
use reth_primitives::{constants::eip4844::DATA_GAS_PER_BLOB, Signature, TransactionSigned};
use alloy_eips::eip4844::DATA_GAS_PER_BLOB;
use reth_primitives::{Signature, TransactionSigned};
#[test]
fn test_pool_size_invariants() {

View File

@ -15,10 +15,9 @@ use alloy_consensus::constants::{
EIP1559_TX_TYPE_ID, EIP2930_TX_TYPE_ID, EIP4844_TX_TYPE_ID, EIP7702_TX_TYPE_ID,
LEGACY_TX_TYPE_ID,
};
use alloy_eips::eip4844::MAX_BLOBS_PER_BLOCK;
use reth_chainspec::{ChainSpec, EthereumHardforks};
use reth_primitives::{
constants::eip4844::MAX_BLOBS_PER_BLOCK, GotExpected, InvalidTransactionError, SealedBlock,
};
use reth_primitives::{GotExpected, InvalidTransactionError, SealedBlock};
use reth_storage_api::{AccountReader, StateProviderFactory};
use reth_tasks::TaskSpawner;
use revm::{