Skip to content

feat: feynman base fee #273

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: scroll
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions crates/ethereum/node/tests/e2e/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ async fn maintain_txpool_stale_eviction() -> eyre::Result<()> {
.build(),
);
let node_config = NodeConfig::test()
.with_chain(chain_spec)
.with_chain(chain_spec.clone())
.with_unused_ports()
.with_rpc(RpcServerArgs::default().with_unused_ports().with_http());
let NodeHandle { node, node_exit_future: _ } = NodeBuilder::new(node_config.clone())
Expand All @@ -67,6 +67,7 @@ async fn maintain_txpool_stale_eviction() -> eyre::Result<()> {
"txpool maintenance task",
reth_transaction_pool::maintain::maintain_transaction_pool_future(
node.inner.provider.clone(),
chain_spec,
txpool.clone(),
node.inner.provider.clone().canonical_state_stream(),
executor.clone(),
Expand Down Expand Up @@ -120,7 +121,7 @@ async fn maintain_txpool_reorg() -> eyre::Result<()> {
);
let genesis_hash = chain_spec.genesis_hash();
let node_config = NodeConfig::test()
.with_chain(chain_spec)
.with_chain(chain_spec.clone())
.with_unused_ports()
.with_rpc(RpcServerArgs::default().with_unused_ports().with_http());
let NodeHandle { node, node_exit_future: _ } = NodeBuilder::new(node_config.clone())
Expand All @@ -139,6 +140,7 @@ async fn maintain_txpool_reorg() -> eyre::Result<()> {
"txpool maintenance task",
reth_transaction_pool::maintain::maintain_transaction_pool_future(
node.inner.provider.clone(),
chain_spec,
txpool.clone(),
node.inner.provider.clone().canonical_state_stream(),
executor.clone(),
Expand Down Expand Up @@ -269,6 +271,7 @@ async fn maintain_txpool_commit() -> eyre::Result<()> {
"txpool maintenance task",
reth_transaction_pool::maintain::maintain_transaction_pool_future(
node.inner.provider.clone(),
MAINNET.clone(),
txpool.clone(),
node.inner.provider.clone().canonical_state_stream(),
executor.clone(),
Expand Down
7 changes: 5 additions & 2 deletions crates/node/builder/src/components/pool.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
//! Pool component for the node builder.

use crate::{BuilderContext, FullNodeTypes};

use alloy_primitives::Address;
use reth_chain_state::CanonStateSubscriptions;
use reth_chainspec::ChainSpecProvider;
use reth_node_api::TxTy;
use reth_transaction_pool::{
blobstore::DiskFileBlobStore, CoinbaseTipOrdering, PoolConfig, PoolTransaction, SubPoolLimit,
TransactionPool, TransactionValidationTaskExecutor, TransactionValidator,
};
use std::{collections::HashSet, future::Future};

use crate::{BuilderContext, FullNodeTypes};

/// A type that knows how to build the transaction pool.
pub trait PoolBuilder<Node: FullNodeTypes>: Send {
/// The transaction pool to build.
Expand Down Expand Up @@ -236,11 +237,13 @@ where
{
let chain_events = ctx.provider().canonical_state_stream();
let client = ctx.provider().clone();
let chain_spec = client.chain_spec();

ctx.task_executor().spawn_critical(
"txpool maintenance task",
reth_transaction_pool::maintain::maintain_transaction_pool_future(
client,
chain_spec,
pool,
chain_events,
ctx.task_executor().clone(),
Expand Down
3 changes: 2 additions & 1 deletion crates/scroll/alloy/evm/src/tx/compression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ use alloy_eips::{Encodable2718, Typed2718};
use alloy_evm::{IntoTxEnv, RecoveredTx};
use alloy_primitives::{Address, Bytes, TxKind, U256};
use revm::context::TxEnv;
use revm_scroll::l1block::TX_L1_FEE_PRECISION_U256;
use scroll_alloy_consensus::{ScrollTxEnvelope, TxL1Message};
pub use zstd_compression::compute_compression_ratio;

#[cfg(feature = "zstd_compression")]
mod zstd_compression {
use super::*;
use std::io::Write;

use revm_scroll::l1block::TX_L1_FEE_PRECISION_U256;
use zstd::{
stream::Encoder,
zstd_safe::{CParameter, ParamSwitch},
Expand Down
4 changes: 2 additions & 2 deletions crates/scroll/alloy/hardforks/src/hardfork.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ impl ScrollHardfork {
(Self::Euclid, ForkCondition::Timestamp(1744815600)),
(Self::EuclidV2, ForkCondition::Timestamp(1745305200)),
// TODO: update
(Self::Feynman, ForkCondition::Timestamp(u64::MAX)),
(Self::Feynman, ForkCondition::Timestamp(6000000000)),
]
}

Expand All @@ -52,7 +52,7 @@ impl ScrollHardfork {
(Self::Euclid, ForkCondition::Timestamp(1741680000)),
(Self::EuclidV2, ForkCondition::Timestamp(1741852800)),
// TODO: update
(Self::Feynman, ForkCondition::Timestamp(u64::MAX)),
(Self::Feynman, ForkCondition::Timestamp(6000000000)),
]
}
}
Expand Down
2 changes: 2 additions & 0 deletions crates/scroll/alloy/rpc-types/src/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ impl Transaction {
// For l1 messages, we set the `gasPrice` field to 0 in rpc
0
} else {
// TODO: should we get the pool base fee in the case where the transaction is a pending
// transaction here?
Comment on lines +38 to +39
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is one of the points that I'm not sure about: should the base fee from the transaction pool be fetched and used here?

For context, this type is used in the RpcConverter and builds a RPC transaction from a recovered tx and the scroll transaction info (which contains the L1 fee and the block context info). For now, afaiu, the RpcConverter uses empty block context for pending pool transaction (see here) but from what I understand in l2geth, the pending base fee is used to compute the effective_gas_price for pool transactions.

base_fee
.map(|base_fee| {
tx.effective_tip_per_gas(base_fee).unwrap_or_default() + base_fee as u128
Expand Down
1 change: 1 addition & 0 deletions crates/scroll/chainspec/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ serde_json = { workspace = true, default-features = false }
serde = { workspace = true, default-features = false, features = ["derive"] }

# misc
auto_impl.workspace = true
derive_more = { workspace = true, default-features = false }
once_cell = { workspace = true, default-features = false }

Expand Down
25 changes: 25 additions & 0 deletions crates/scroll/chainspec/src/constants.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
use crate::genesis::L1Config;
use alloy_eips::eip1559::BaseFeeParams;
use alloy_primitives::{address, b256, Address, B256};

/// The transaction fee recipient on the L2.
pub const SCROLL_FEE_VAULT_ADDRESS: Address = address!("5300000000000000000000000000000000000005");

/// The system contract on L2 mainnet.
pub const SCROLL_MAINNET_SYSTEM_CONTRACT_ADDRESS: Address =
address!("331A873a2a85219863d80d248F9e2978fE88D0Ea");

/// The L1 message queue address for Scroll mainnet.
/// <https://etherscan.io/address/0x0d7E906BD9cAFa154b048cFa766Cc1E54E39AF9B>.
pub const SCROLL_MAINNET_L1_MESSAGE_QUEUE_ADDRESS: Address =
Expand All @@ -29,6 +34,10 @@ pub const SCROLL_MAINNET_L1_CONFIG: L1Config = L1Config {
pub const SCROLL_MAINNET_GENESIS_HASH: B256 =
b256!("bbc05efd412b7cd47a2ed0e5ddfcf87af251e414ea4c801d78b6784513180a80");

/// The system contract on L2 sepolia.
pub const SCROLL_SEPOLIA_SYSTEM_CONTRACT_ADDRESS: Address =
address!("F444cF06A3E3724e20B35c2989d3942ea8b59124");

/// The L1 message queue address for Scroll sepolia.
/// <https://sepolia.etherscan.io/address/0xF0B2293F5D834eAe920c6974D50957A1732de763>.
pub const SCROLL_SEPOLIA_L1_MESSAGE_QUEUE_ADDRESS: Address =
Expand All @@ -50,6 +59,10 @@ pub const SCROLL_SEPOLIA_L1_CONFIG: L1Config = L1Config {
num_l1_messages_per_block: SCROLL_SEPOLIA_MAX_L1_MESSAGES,
};

/// The system contract on devnet.
pub const SCROLL_DEV_SYSTEM_CONTRACT_ADDRESS: Address =
address!("0000000000000000000000000000000000000000");

/// The L1 message queue address for Scroll dev.
pub const SCROLL_DEV_L1_MESSAGE_QUEUE_ADDRESS: Address =
address!("0000000000000000000000000000000000000000");
Expand All @@ -72,3 +85,15 @@ pub const SCROLL_DEV_L1_CONFIG: L1Config = L1Config {
/// The Scroll Sepolia genesis hash
pub const SCROLL_SEPOLIA_GENESIS_HASH: B256 =
b256!("aa62d1a8b2bffa9e5d2368b63aae0d98d54928bd713125e3fd9e5c896c68592c");

/// The base fee params for Feynman.
pub const SCROLL_BASE_FEE_PARAMS_FEYNMAN: BaseFeeParams = BaseFeeParams::new(
SCROLL_EIP1559_BASE_FEE_MAX_CHANGE_DENOMINATOR_FEYNMAN,
SCROLL_EIP1559_DEFAULT_ELASTICITY_MULTIPLIER_FEYNMAN,
);

/// The scroll EIP1559 max change denominator for Feynman.
pub const SCROLL_EIP1559_BASE_FEE_MAX_CHANGE_DENOMINATOR_FEYNMAN: u128 = 8;

/// The scroll EIP1559 default elasticity multiplier for Feynman.
pub const SCROLL_EIP1559_DEFAULT_ELASTICITY_MULTIPLIER_FEYNMAN: u128 = 2;
13 changes: 9 additions & 4 deletions crates/scroll/chainspec/src/dev.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
//! Chain specification in dev mode for custom chain.

use crate::{
constants::SCROLL_BASE_FEE_PARAMS_FEYNMAN, make_genesis_header, LazyLock, ScrollChainConfig,
ScrollChainSpec,
};
use alloc::sync::Arc;

use alloy_chains::Chain;
use alloy_primitives::U256;
use reth_chainspec::{BaseFeeParams, BaseFeeParamsKind, ChainSpec};
use reth_chainspec::{BaseFeeParamsKind, ChainSpec, Hardfork};
use reth_primitives_traits::SealedHeader;
use reth_scroll_forks::DEV_HARDFORKS;

use crate::{make_genesis_header, LazyLock, ScrollChainConfig, ScrollChainSpec};
use scroll_alloy_hardforks::ScrollHardfork;

/// Scroll dev testnet specification
///
Expand All @@ -24,7 +27,9 @@ pub static SCROLL_DEV: LazyLock<Arc<ScrollChainSpec>> = LazyLock::new(|| {
genesis,
paris_block_and_final_difficulty: Some((0, U256::from(0))),
hardforks: DEV_HARDFORKS.clone(),
base_fee_params: BaseFeeParamsKind::Constant(BaseFeeParams::ethereum()),
base_fee_params: BaseFeeParamsKind::Variable(
vec![(ScrollHardfork::Feynman.boxed(), SCROLL_BASE_FEE_PARAMS_FEYNMAN)].into(),
),
..Default::default()
},
config: ScrollChainConfig::dev(),
Expand Down
18 changes: 16 additions & 2 deletions crates/scroll/chainspec/src/genesis.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
//! Scroll types for genesis data.

use crate::{
constants::{SCROLL_FEE_VAULT_ADDRESS, SCROLL_MAINNET_L1_CONFIG, SCROLL_SEPOLIA_L1_CONFIG},
constants::{
SCROLL_DEV_SYSTEM_CONTRACT_ADDRESS, SCROLL_FEE_VAULT_ADDRESS, SCROLL_MAINNET_L1_CONFIG,
SCROLL_MAINNET_SYSTEM_CONTRACT_ADDRESS, SCROLL_SEPOLIA_L1_CONFIG,
SCROLL_SEPOLIA_SYSTEM_CONTRACT_ADDRESS,
},
SCROLL_DEV_L1_CONFIG,
};
use alloy_primitives::Address;
Expand Down Expand Up @@ -108,6 +112,8 @@ pub struct ScrollChainConfig {
/// This is an optional field that, when set, specifies where L2 transaction fees
/// will be sent or stored.
pub fee_vault_address: Option<Address>,
/// The address of the L2 system contract.
pub l2_system_contract_address: Address,
/// The L1 configuration.
/// This field encapsulates specific settings and parameters required for L1
pub l1_config: L1Config,
Expand All @@ -124,6 +130,7 @@ impl ScrollChainConfig {
pub const fn mainnet() -> Self {
Self {
fee_vault_address: Some(SCROLL_FEE_VAULT_ADDRESS),
l2_system_contract_address: SCROLL_MAINNET_SYSTEM_CONTRACT_ADDRESS,
l1_config: SCROLL_MAINNET_L1_CONFIG,
}
}
Expand All @@ -132,13 +139,18 @@ impl ScrollChainConfig {
pub const fn sepolia() -> Self {
Self {
fee_vault_address: Some(SCROLL_FEE_VAULT_ADDRESS),
l2_system_contract_address: SCROLL_SEPOLIA_SYSTEM_CONTRACT_ADDRESS,
l1_config: SCROLL_SEPOLIA_L1_CONFIG,
}
}

/// Returns the [`ScrollChainConfig`] for Scroll dev.
pub const fn dev() -> Self {
Self { fee_vault_address: Some(SCROLL_FEE_VAULT_ADDRESS), l1_config: SCROLL_DEV_L1_CONFIG }
Self {
fee_vault_address: Some(SCROLL_FEE_VAULT_ADDRESS),
l2_system_contract_address: SCROLL_DEV_SYSTEM_CONTRACT_ADDRESS,
l1_config: SCROLL_DEV_L1_CONFIG,
}
}
}

Expand Down Expand Up @@ -202,6 +214,7 @@ mod tests {
"feynmanTime": 100,
"scroll": {
"feeVaultAddress": "0x5300000000000000000000000000000000000005",
"l2SystemContractAddress: "0x331A873a2a85219863d80d248F9e2978fE88D0Ea",
"l1Config": {
"l1ChainId": 1,
"l1MessageQueueAddress": "0x0d7E906BD9cAFa154b048cFa766Cc1E54E39AF9B",
Expand All @@ -228,6 +241,7 @@ mod tests {
}),
scroll_chain_config: ScrollChainConfig {
fee_vault_address: Some(address!("5300000000000000000000000000000000000005")),
l2_system_contract_address: SCROLL_MAINNET_SYSTEM_CONTRACT_ADDRESS,
l1_config: L1Config {
l1_chain_id: 1,
l1_message_queue_address: address!("0d7E906BD9cAFa154b048cFa766Cc1E54E39AF9B"),
Expand Down
16 changes: 10 additions & 6 deletions crates/scroll/chainspec/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,15 @@ extern crate alloc;

mod constants;
pub use constants::{
SCROLL_DEV_L1_CONFIG, SCROLL_DEV_L1_MESSAGE_QUEUE_ADDRESS, SCROLL_DEV_L1_PROXY_ADDRESS,
SCROLL_DEV_MAX_L1_MESSAGES, SCROLL_FEE_VAULT_ADDRESS, SCROLL_MAINNET_GENESIS_HASH,
SCROLL_MAINNET_L1_CONFIG, SCROLL_MAINNET_L1_MESSAGE_QUEUE_ADDRESS,
SCROLL_MAINNET_L1_PROXY_ADDRESS, SCROLL_MAINNET_MAX_L1_MESSAGES, SCROLL_SEPOLIA_GENESIS_HASH,
SCROLL_SEPOLIA_L1_CONFIG, SCROLL_SEPOLIA_L1_MESSAGE_QUEUE_ADDRESS,
SCROLL_SEPOLIA_L1_PROXY_ADDRESS, SCROLL_SEPOLIA_MAX_L1_MESSAGES,
SCROLL_BASE_FEE_PARAMS_FEYNMAN, SCROLL_DEV_L1_CONFIG, SCROLL_DEV_L1_MESSAGE_QUEUE_ADDRESS,
SCROLL_DEV_L1_PROXY_ADDRESS, SCROLL_DEV_MAX_L1_MESSAGES, SCROLL_DEV_SYSTEM_CONTRACT_ADDRESS,
SCROLL_EIP1559_BASE_FEE_MAX_CHANGE_DENOMINATOR_FEYNMAN,
SCROLL_EIP1559_DEFAULT_ELASTICITY_MULTIPLIER_FEYNMAN, SCROLL_FEE_VAULT_ADDRESS,
SCROLL_MAINNET_GENESIS_HASH, SCROLL_MAINNET_L1_CONFIG, SCROLL_MAINNET_L1_MESSAGE_QUEUE_ADDRESS,
SCROLL_MAINNET_L1_PROXY_ADDRESS, SCROLL_MAINNET_MAX_L1_MESSAGES,
SCROLL_MAINNET_SYSTEM_CONTRACT_ADDRESS, SCROLL_SEPOLIA_GENESIS_HASH, SCROLL_SEPOLIA_L1_CONFIG,
SCROLL_SEPOLIA_L1_MESSAGE_QUEUE_ADDRESS, SCROLL_SEPOLIA_L1_PROXY_ADDRESS,
SCROLL_SEPOLIA_MAX_L1_MESSAGES, SCROLL_SEPOLIA_SYSTEM_CONTRACT_ADDRESS,
};

mod dev;
Expand Down Expand Up @@ -180,6 +183,7 @@ impl ScrollChainSpecBuilder {
}

/// Returns the chain configuration.
#[auto_impl::auto_impl(Arc)]
pub trait ChainConfig {
/// The configuration.
type Config;
Expand Down
9 changes: 7 additions & 2 deletions crates/scroll/chainspec/src/scroll.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
//! Chain specification for the Scroll Mainnet network.

use crate::{
make_genesis_header, LazyLock, ScrollChainConfig, ScrollChainSpec, SCROLL_MAINNET_GENESIS_HASH,
constants::SCROLL_BASE_FEE_PARAMS_FEYNMAN, make_genesis_header, LazyLock, ScrollChainConfig,
ScrollChainSpec, SCROLL_MAINNET_GENESIS_HASH,
};
use alloc::sync::Arc;

use alloy_chains::{Chain, NamedChain};
use reth_chainspec::ChainSpec;
use reth_chainspec::{BaseFeeParamsKind, ChainSpec, Hardfork};
use reth_primitives_traits::SealedHeader;
use reth_scroll_forks::SCROLL_MAINNET_HARDFORKS;
use scroll_alloy_hardforks::ScrollHardfork;

/// The Scroll Mainnet spec
pub static SCROLL_MAINNET: LazyLock<Arc<ScrollChainSpec>> = LazyLock::new(|| {
Expand All @@ -24,6 +26,9 @@ pub static SCROLL_MAINNET: LazyLock<Arc<ScrollChainSpec>> = LazyLock::new(|| {
),
genesis,
hardforks: SCROLL_MAINNET_HARDFORKS.clone(),
base_fee_params: BaseFeeParamsKind::Variable(
vec![(ScrollHardfork::Feynman.boxed(), SCROLL_BASE_FEE_PARAMS_FEYNMAN)].into(),
),
..Default::default()
},
config: ScrollChainConfig::mainnet(),
Expand Down
Loading
Loading