mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
chore: update holocene fns (#13366)
This commit is contained in:
29
Cargo.lock
generated
29
Cargo.lock
generated
@ -5411,9 +5411,9 @@ checksum = "b410bbe7e14ab526a0e86877eb47c6996a2bd7746f027ba551028c925390e4e9"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "op-alloy-consensus"
|
name = "op-alloy-consensus"
|
||||||
version = "0.8.1"
|
version = "0.8.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e5085cc8be65a2da9c04e9a904eccfe38eb69ecc3bc6c6485ce0f1af879f3abe"
|
checksum = "24aaf487dd59beed72931e31b11b305cdcb6a20651a1cccf992a20706a54cc3b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"alloy-consensus",
|
"alloy-consensus",
|
||||||
"alloy-eips",
|
"alloy-eips",
|
||||||
@ -5429,9 +5429,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "op-alloy-genesis"
|
name = "op-alloy-genesis"
|
||||||
version = "0.8.1"
|
version = "0.8.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "64f5aa1201d83af3b0ebffbfc28fdc7e772d7e44f4dea9e41c51162f84412edf"
|
checksum = "42ad6c33c2711611e19092a7d17c076542e27687ef975f67bf57039fa3d57e06"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"alloy-consensus",
|
"alloy-consensus",
|
||||||
"alloy-eips",
|
"alloy-eips",
|
||||||
@ -5444,9 +5444,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "op-alloy-network"
|
name = "op-alloy-network"
|
||||||
version = "0.8.1"
|
version = "0.8.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9d12eafaad5b89792de75f1344d42634dd5271945fd36256e4e5d766cf32107e"
|
checksum = "8273ddf3a0a8cb891abbc625289f8094fbeab1329e0874b38e14bf1670402b7c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"alloy-consensus",
|
"alloy-consensus",
|
||||||
"alloy-network",
|
"alloy-network",
|
||||||
@ -5459,9 +5459,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "op-alloy-protocol"
|
name = "op-alloy-protocol"
|
||||||
version = "0.8.1"
|
version = "0.8.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "2cf8c05e1b7ed20c4af6f72a54cc389225d2c6af6fcf932ef6481cfdfcb540ac"
|
checksum = "ccb98f90d0101cdaabb739c44f4d4b2d0ad0ad1a3dd68ce525683ffafd97dd13"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"alloc-no-stdlib",
|
"alloc-no-stdlib",
|
||||||
"alloy-consensus",
|
"alloy-consensus",
|
||||||
@ -5483,9 +5483,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "op-alloy-rpc-jsonrpsee"
|
name = "op-alloy-rpc-jsonrpsee"
|
||||||
version = "0.8.1"
|
version = "0.8.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "3b6edd6fb56f23ab45c704ad0c598641086e07b3a55d74890acaa01226ffc3e2"
|
checksum = "44a41095f6aa4f39e3d8927ac8a903a45e76ddb533f466ef592853f9a49fe8cf"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"alloy-eips",
|
"alloy-eips",
|
||||||
"alloy-primitives",
|
"alloy-primitives",
|
||||||
@ -5496,9 +5496,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "op-alloy-rpc-types"
|
name = "op-alloy-rpc-types"
|
||||||
version = "0.8.1"
|
version = "0.8.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b44194f44faef3db1edd17fc8e0b1309d377c6c7a4ba74a02d78c13d5f2ed90d"
|
checksum = "21d0ada6356ac7818d4b1ba48c37116662732b97f18a3684f08727dafbef2437"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"alloy-consensus",
|
"alloy-consensus",
|
||||||
"alloy-eips",
|
"alloy-eips",
|
||||||
@ -5515,9 +5515,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "op-alloy-rpc-types-engine"
|
name = "op-alloy-rpc-types-engine"
|
||||||
version = "0.8.1"
|
version = "0.8.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c005d0a4431fbd9cd16eb0c2f67306de4245f76f311fa1628a68b79e7ea5aa0e"
|
checksum = "7c63ba3f50dba410d1ce18aa16242c198f91ad44da5221f7347c1525958a9b09"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"alloy-eips",
|
"alloy-eips",
|
||||||
"alloy-primitives",
|
"alloy-primitives",
|
||||||
@ -8362,6 +8362,7 @@ dependencies = [
|
|||||||
"alloy-primitives",
|
"alloy-primitives",
|
||||||
"derive_more",
|
"derive_more",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
|
"op-alloy-consensus",
|
||||||
"op-alloy-rpc-types",
|
"op-alloy-rpc-types",
|
||||||
"reth-chainspec",
|
"reth-chainspec",
|
||||||
"reth-ethereum-forks",
|
"reth-ethereum-forks",
|
||||||
|
|||||||
10
Cargo.toml
10
Cargo.toml
@ -477,11 +477,11 @@ alloy-transport-ipc = { version = "0.8.0", default-features = false }
|
|||||||
alloy-transport-ws = { version = "0.8.0", default-features = false }
|
alloy-transport-ws = { version = "0.8.0", default-features = false }
|
||||||
|
|
||||||
# op
|
# op
|
||||||
op-alloy-rpc-types = "0.8.1"
|
op-alloy-rpc-types = "0.8.2"
|
||||||
op-alloy-rpc-types-engine = "0.8.1"
|
op-alloy-rpc-types-engine = "0.8.2"
|
||||||
op-alloy-rpc-jsonrpsee = "0.8.1"
|
op-alloy-rpc-jsonrpsee = "0.8.2"
|
||||||
op-alloy-network = "0.8.1"
|
op-alloy-network = "0.8.2"
|
||||||
op-alloy-consensus = "0.8.1"
|
op-alloy-consensus = "0.8.2"
|
||||||
|
|
||||||
# misc
|
# misc
|
||||||
aquamarine = "0.6"
|
aquamarine = "0.6"
|
||||||
|
|||||||
@ -30,6 +30,7 @@ alloy-eips.workspace = true
|
|||||||
|
|
||||||
# op
|
# op
|
||||||
op-alloy-rpc-types.workspace = true
|
op-alloy-rpc-types.workspace = true
|
||||||
|
op-alloy-consensus.workspace = true
|
||||||
|
|
||||||
# io
|
# io
|
||||||
serde_json.workspace = true
|
serde_json.workspace = true
|
||||||
|
|||||||
@ -29,6 +29,7 @@ pub use dev::OP_DEV;
|
|||||||
#[cfg(not(feature = "std"))]
|
#[cfg(not(feature = "std"))]
|
||||||
pub(crate) use once_cell::sync::Lazy as LazyLock;
|
pub(crate) use once_cell::sync::Lazy as LazyLock;
|
||||||
pub use op::OP_MAINNET;
|
pub use op::OP_MAINNET;
|
||||||
|
use op_alloy_consensus::{decode_holocene_extra_data, EIP1559ParamError};
|
||||||
pub use op_sepolia::OP_SEPOLIA;
|
pub use op_sepolia::OP_SEPOLIA;
|
||||||
use reth_chainspec::{
|
use reth_chainspec::{
|
||||||
BaseFeeParams, BaseFeeParamsKind, ChainSpec, ChainSpecBuilder, DepositContract, EthChainSpec,
|
BaseFeeParams, BaseFeeParamsKind, ChainSpec, ChainSpecBuilder, DepositContract, EthChainSpec,
|
||||||
@ -201,8 +202,8 @@ impl OpChainSpec {
|
|||||||
&self,
|
&self,
|
||||||
parent: &Header,
|
parent: &Header,
|
||||||
timestamp: u64,
|
timestamp: u64,
|
||||||
) -> Result<u64, DecodeError> {
|
) -> Result<u64, EIP1559ParamError> {
|
||||||
let (denominator, elasticity) = decode_holocene_1559_params(&parent.extra_data)?;
|
let (denominator, elasticity) = decode_holocene_extra_data(&parent.extra_data)?;
|
||||||
let base_fee = if elasticity == 0 && denominator == 0 {
|
let base_fee = if elasticity == 0 && denominator == 0 {
|
||||||
parent
|
parent
|
||||||
.next_block_base_fee(self.base_fee_params_at_timestamp(timestamp))
|
.next_block_base_fee(self.base_fee_params_at_timestamp(timestamp))
|
||||||
@ -221,13 +222,11 @@ impl OpChainSpec {
|
|||||||
&self,
|
&self,
|
||||||
parent: &Header,
|
parent: &Header,
|
||||||
timestamp: u64,
|
timestamp: u64,
|
||||||
) -> Result<U256, DecodeError> {
|
) -> Result<U256, EIP1559ParamError> {
|
||||||
// > if Holocene is active in parent_header.timestamp, then the parameters from
|
// > if Holocene is active in parent_header.timestamp, then the parameters from
|
||||||
// > parent_header.extraData are used.
|
// > parent_header.extraData are used.
|
||||||
let is_holocene_activated = self.inner.is_fork_active_at_timestamp(
|
let is_holocene_activated =
|
||||||
reth_optimism_forks::OpHardfork::Holocene,
|
self.inner.is_fork_active_at_timestamp(OpHardfork::Holocene, parent.timestamp);
|
||||||
parent.timestamp,
|
|
||||||
);
|
|
||||||
|
|
||||||
// If we are in the Holocene, we need to use the base fee params
|
// If we are in the Holocene, we need to use the base fee params
|
||||||
// from the parent block's extra data.
|
// from the parent block's extra data.
|
||||||
@ -244,40 +243,6 @@ impl OpChainSpec {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Display, Eq, PartialEq)]
|
|
||||||
/// Error type for decoding Holocene 1559 parameters
|
|
||||||
pub enum DecodeError {
|
|
||||||
#[display("Insufficient data to decode")]
|
|
||||||
/// Insufficient data to decode
|
|
||||||
InsufficientData,
|
|
||||||
#[display("Invalid denominator parameter")]
|
|
||||||
/// Invalid denominator parameter
|
|
||||||
InvalidDenominator,
|
|
||||||
#[display("Invalid elasticity parameter")]
|
|
||||||
/// Invalid elasticity parameter
|
|
||||||
InvalidElasticity,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl core::error::Error for DecodeError {
|
|
||||||
fn source(&self) -> Option<&(dyn core::error::Error + 'static)> {
|
|
||||||
// None of the errors have sub-errors
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Extracts the Holcene 1599 parameters from the encoded form:
|
|
||||||
/// <https://github.com/ethereum-optimism/specs/blob/main/specs/protocol/holocene/exec-engine.md#eip1559params-encoding>
|
|
||||||
pub fn decode_holocene_1559_params(extra_data: &[u8]) -> Result<(u32, u32), DecodeError> {
|
|
||||||
if extra_data.len() < 9 {
|
|
||||||
return Err(DecodeError::InsufficientData);
|
|
||||||
}
|
|
||||||
let denominator: [u8; 4] =
|
|
||||||
extra_data[1..5].try_into().map_err(|_| DecodeError::InvalidDenominator)?;
|
|
||||||
let elasticity: [u8; 4] =
|
|
||||||
extra_data[5..9].try_into().map_err(|_| DecodeError::InvalidElasticity)?;
|
|
||||||
Ok((u32::from_be_bytes(denominator), u32::from_be_bytes(elasticity)))
|
|
||||||
}
|
|
||||||
|
|
||||||
impl EthChainSpec for OpChainSpec {
|
impl EthChainSpec for OpChainSpec {
|
||||||
type Header = Header;
|
type Header = Header;
|
||||||
|
|
||||||
|
|||||||
@ -15,8 +15,9 @@ extern crate alloc;
|
|||||||
use alloc::{sync::Arc, vec::Vec};
|
use alloc::{sync::Arc, vec::Vec};
|
||||||
use alloy_consensus::Header;
|
use alloy_consensus::Header;
|
||||||
use alloy_primitives::{Address, U256};
|
use alloy_primitives::{Address, U256};
|
||||||
|
use op_alloy_consensus::EIP1559ParamError;
|
||||||
use reth_evm::{ConfigureEvm, ConfigureEvmEnv, NextBlockEnvAttributes};
|
use reth_evm::{ConfigureEvm, ConfigureEvmEnv, NextBlockEnvAttributes};
|
||||||
use reth_optimism_chainspec::{DecodeError, OpChainSpec};
|
use reth_optimism_chainspec::OpChainSpec;
|
||||||
use reth_primitives::{transaction::FillTxEnv, Head, TransactionSigned};
|
use reth_primitives::{transaction::FillTxEnv, Head, TransactionSigned};
|
||||||
use reth_revm::{
|
use reth_revm::{
|
||||||
inspector_handle_register,
|
inspector_handle_register,
|
||||||
@ -58,7 +59,7 @@ impl OpEvmConfig {
|
|||||||
impl ConfigureEvmEnv for OpEvmConfig {
|
impl ConfigureEvmEnv for OpEvmConfig {
|
||||||
type Header = Header;
|
type Header = Header;
|
||||||
type Transaction = TransactionSigned;
|
type Transaction = TransactionSigned;
|
||||||
type Error = DecodeError;
|
type Error = EIP1559ParamError;
|
||||||
|
|
||||||
fn fill_tx_env(&self, tx_env: &mut TxEnv, transaction: &TransactionSigned, sender: Address) {
|
fn fill_tx_env(&self, tx_env: &mut TxEnv, transaction: &TransactionSigned, sender: Address) {
|
||||||
transaction.fill_tx_env(tx_env, sender);
|
transaction.fill_tx_env(tx_env, sender);
|
||||||
|
|||||||
@ -7,7 +7,7 @@ use alloy_eips::{
|
|||||||
use alloy_primitives::{keccak256, Address, Bytes, B256, B64, U256};
|
use alloy_primitives::{keccak256, Address, Bytes, B256, B64, U256};
|
||||||
use alloy_rlp::Encodable;
|
use alloy_rlp::Encodable;
|
||||||
use alloy_rpc_types_engine::{ExecutionPayloadEnvelopeV2, ExecutionPayloadV1, PayloadId};
|
use alloy_rpc_types_engine::{ExecutionPayloadEnvelopeV2, ExecutionPayloadV1, PayloadId};
|
||||||
use op_alloy_consensus::{decode_holocene_extra_data, EIP1559ParamError};
|
use op_alloy_consensus::{encode_holocene_extra_data, EIP1559ParamError};
|
||||||
/// Re-export for use in downstream arguments.
|
/// Re-export for use in downstream arguments.
|
||||||
pub use op_alloy_rpc_types_engine::OpPayloadAttributes;
|
pub use op_alloy_rpc_types_engine::OpPayloadAttributes;
|
||||||
use op_alloy_rpc_types_engine::{OpExecutionPayloadEnvelopeV3, OpExecutionPayloadEnvelopeV4};
|
use op_alloy_rpc_types_engine::{OpExecutionPayloadEnvelopeV3, OpExecutionPayloadEnvelopeV4};
|
||||||
@ -45,7 +45,7 @@ impl OpPayloadBuilderAttributes {
|
|||||||
default_base_fee_params: BaseFeeParams,
|
default_base_fee_params: BaseFeeParams,
|
||||||
) -> Result<Bytes, EIP1559ParamError> {
|
) -> Result<Bytes, EIP1559ParamError> {
|
||||||
self.eip_1559_params
|
self.eip_1559_params
|
||||||
.map(|params| decode_holocene_extra_data(params, default_base_fee_params))
|
.map(|params| encode_holocene_extra_data(params, default_base_fee_params))
|
||||||
.ok_or(EIP1559ParamError::NoEIP1559Params)?
|
.ok_or(EIP1559ParamError::NoEIP1559Params)?
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user