mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat: move calculate_intrinsic_gas_after_merge to tx pool (#8914)
Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -7742,7 +7742,6 @@ dependencies = [
|
||||
"reth-primitives-traits",
|
||||
"reth-static-file-types",
|
||||
"reth-trie-common",
|
||||
"revm",
|
||||
"revm-primitives",
|
||||
"roaring",
|
||||
"secp256k1",
|
||||
@ -8334,6 +8333,7 @@ dependencies = [
|
||||
"reth-provider",
|
||||
"reth-tasks",
|
||||
"reth-tracing",
|
||||
"revm",
|
||||
"rustc-hash",
|
||||
"schnellru",
|
||||
"serde",
|
||||
|
||||
@ -40,4 +40,5 @@ optimism = [
|
||||
"reth-primitives/optimism",
|
||||
"reth-provider/optimism",
|
||||
"reth-optimism-consensus/optimism",
|
||||
"reth-revm/optimism",
|
||||
]
|
||||
|
||||
@ -66,4 +66,5 @@ optimism = [
|
||||
"reth-evm-optimism/optimism",
|
||||
"reth-optimism-payload-builder/optimism",
|
||||
"reth-beacon-consensus/optimism",
|
||||
"reth-revm/optimism",
|
||||
]
|
||||
|
||||
@ -42,4 +42,5 @@ optimism = [
|
||||
"reth-provider/optimism",
|
||||
"reth-rpc-types-compat/optimism",
|
||||
"reth-evm-optimism/optimism",
|
||||
]
|
||||
"reth-revm/optimism",
|
||||
]
|
||||
|
||||
@ -19,7 +19,6 @@ reth-ethereum-forks.workspace = true
|
||||
reth-static-file-types.workspace = true
|
||||
reth-trie-common.workspace = true
|
||||
reth-chainspec.workspace = true
|
||||
revm.workspace = true
|
||||
revm-primitives = { workspace = true, features = ["serde"] }
|
||||
|
||||
# ethereum
|
||||
@ -48,7 +47,7 @@ once_cell.workspace = true
|
||||
rayon.workspace = true
|
||||
serde.workspace = true
|
||||
tempfile = { workspace = true, optional = true }
|
||||
thiserror-no-std = { workspace = true , default-features = false }
|
||||
thiserror-no-std = { workspace = true, default-features = false }
|
||||
zstd = { version = "0.13", features = ["experimental"], optional = true }
|
||||
roaring = "0.10.2"
|
||||
|
||||
@ -103,24 +102,15 @@ arbitrary = [
|
||||
"dep:proptest-derive",
|
||||
"zstd-codec",
|
||||
]
|
||||
c-kzg = [
|
||||
"dep:c-kzg",
|
||||
"revm/c-kzg",
|
||||
"revm-primitives/c-kzg",
|
||||
"dep:tempfile",
|
||||
"alloy-eips/kzg",
|
||||
]
|
||||
c-kzg = ["dep:c-kzg", "revm-primitives/c-kzg", "dep:tempfile", "alloy-eips/kzg"]
|
||||
zstd-codec = ["dep:zstd"]
|
||||
optimism = [
|
||||
"reth-chainspec/optimism",
|
||||
"reth-codecs/optimism",
|
||||
"reth-ethereum-forks/optimism",
|
||||
"revm/optimism",
|
||||
]
|
||||
alloy-compat = [
|
||||
"reth-primitives-traits/alloy-compat",
|
||||
"alloy-rpc-types",
|
||||
"revm-primitives/optimism",
|
||||
]
|
||||
alloy-compat = ["reth-primitives-traits/alloy-compat", "dep:alloy-rpc-types"]
|
||||
std = ["thiserror-no-std/std"]
|
||||
test-utils = ["reth-primitives-traits/test-utils"]
|
||||
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
use crate::{revm_primitives::AccountInfo, Account, Address, TxKind, KECCAK_EMPTY, U256};
|
||||
use revm::{interpreter::gas::validate_initial_tx_gas, primitives::SpecId};
|
||||
use crate::{revm_primitives::AccountInfo, Account, KECCAK_EMPTY};
|
||||
|
||||
#[cfg(not(feature = "std"))]
|
||||
use alloc::vec::Vec;
|
||||
@ -27,17 +26,3 @@ pub fn into_revm_acc(reth_acc: Account) -> AccountInfo {
|
||||
code: None,
|
||||
}
|
||||
}
|
||||
|
||||
/// Calculates the Intrinsic Gas usage for a Transaction
|
||||
///
|
||||
/// Caution: This only checks past the Merge hardfork.
|
||||
#[inline]
|
||||
pub fn calculate_intrinsic_gas_after_merge(
|
||||
input: &[u8],
|
||||
kind: &TxKind,
|
||||
access_list: &[(Address, Vec<U256>)],
|
||||
is_shanghai: bool,
|
||||
) -> u64 {
|
||||
let spec_id = if is_shanghai { SpecId::SHANGHAI } else { SpecId::MERGE };
|
||||
validate_initial_tx_gas(spec_id, input, kind.is_create(), access_list)
|
||||
}
|
||||
|
||||
@ -36,6 +36,8 @@ tracing.workspace = true
|
||||
reth-trie.workspace = true
|
||||
|
||||
[features]
|
||||
default = ["std"]
|
||||
default = ["std", "c-kzg"]
|
||||
std = []
|
||||
c-kzg = ["revm/c-kzg"]
|
||||
test-utils = ["dep:reth-trie"]
|
||||
optimism = ["revm/optimism"]
|
||||
|
||||
@ -96,4 +96,5 @@ optimism = [
|
||||
"reth-provider/optimism",
|
||||
"dep:reth-evm-optimism",
|
||||
"reth-evm-optimism/optimism",
|
||||
"reth-revm/optimism",
|
||||
]
|
||||
|
||||
@ -19,6 +19,7 @@ reth-primitives.workspace = true
|
||||
reth-fs-util.workspace = true
|
||||
reth-provider.workspace = true
|
||||
reth-tasks.workspace = true
|
||||
revm.workspace = true
|
||||
|
||||
# ethereum
|
||||
alloy-rlp.workspace = true
|
||||
|
||||
@ -16,12 +16,12 @@ use reth_primitives::{
|
||||
ETHEREUM_BLOCK_GAS_LIMIT,
|
||||
},
|
||||
kzg::KzgSettings,
|
||||
revm::compat::calculate_intrinsic_gas_after_merge,
|
||||
GotExpected, InvalidTransactionError, SealedBlock, EIP1559_TX_TYPE_ID, EIP2930_TX_TYPE_ID,
|
||||
EIP4844_TX_TYPE_ID, LEGACY_TX_TYPE_ID,
|
||||
Address, GotExpected, InvalidTransactionError, SealedBlock, TxKind, EIP1559_TX_TYPE_ID,
|
||||
EIP2930_TX_TYPE_ID, EIP4844_TX_TYPE_ID, LEGACY_TX_TYPE_ID, U256,
|
||||
};
|
||||
use reth_provider::{AccountReader, BlockReaderIdExt, StateProviderFactory};
|
||||
use reth_tasks::TaskSpawner;
|
||||
use revm::{interpreter::gas::validate_initial_tx_gas, primitives::SpecId};
|
||||
use std::{
|
||||
marker::PhantomData,
|
||||
sync::{atomic::AtomicBool, Arc},
|
||||
@ -728,6 +728,20 @@ pub fn ensure_intrinsic_gas<T: PoolTransaction>(
|
||||
}
|
||||
}
|
||||
|
||||
/// Calculates the Intrinsic Gas usage for a Transaction
|
||||
///
|
||||
/// Caution: This only checks past the Merge hardfork.
|
||||
#[inline]
|
||||
pub fn calculate_intrinsic_gas_after_merge(
|
||||
input: &[u8],
|
||||
kind: &TxKind,
|
||||
access_list: &[(Address, Vec<U256>)],
|
||||
is_shanghai: bool,
|
||||
) -> u64 {
|
||||
let spec_id = if is_shanghai { SpecId::SHANGHAI } else { SpecId::MERGE };
|
||||
validate_initial_tx_gas(spec_id, input, kind.is_create(), access_list)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
Reference in New Issue
Block a user