Skip to content

Commit 95b2762

Browse files
authored
feat: feynman base fee (#273)
* feat: add base fee params and l2 system contract address Signed-off-by: Gregory Edison <[email protected]> * feat: update base fee to Feynman Signed-off-by: Gregory Edison <[email protected]> * feat: propagate the base fee provider in the pool Signed-off-by: Gregory Edison <[email protected]> * fix: lints Signed-off-by: Gregory Edison <[email protected]> * fix: make clippy happy Signed-off-by: Gregory Edison <[email protected]> * fix: riscv Signed-off-by: Gregory Edison <[email protected]> * test: fix Signed-off-by: Gregory Edison <[email protected]> * fix: doc tests Signed-off-by: Gregory Edison <[email protected]> * fix: answer comments Signed-off-by: Gregory Edison <[email protected]> * fix: constant naming Signed-off-by: Gregory Edison <[email protected]> * fix: reorder SCROLL_SEPOLIA_L1_CONFIG Signed-off-by: Gregory Edison <[email protected]> --------- Signed-off-by: Gregory Edison <[email protected]>
1 parent 1686397 commit 95b2762

File tree

28 files changed

+532
-181
lines changed

28 files changed

+532
-181
lines changed

Cargo.lock

Lines changed: 3 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/ethereum/node/tests/e2e/pool.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ async fn maintain_txpool_stale_eviction() -> eyre::Result<()> {
4545
.build(),
4646
);
4747
let node_config = NodeConfig::test()
48-
.with_chain(chain_spec)
48+
.with_chain(chain_spec.clone())
4949
.with_unused_ports()
5050
.with_rpc(RpcServerArgs::default().with_unused_ports().with_http());
5151
let NodeHandle { node, node_exit_future: _ } = NodeBuilder::new(node_config.clone())
@@ -67,6 +67,7 @@ async fn maintain_txpool_stale_eviction() -> eyre::Result<()> {
6767
"txpool maintenance task",
6868
reth_transaction_pool::maintain::maintain_transaction_pool_future(
6969
node.inner.provider.clone(),
70+
chain_spec,
7071
txpool.clone(),
7172
node.inner.provider.clone().canonical_state_stream(),
7273
executor.clone(),
@@ -120,7 +121,7 @@ async fn maintain_txpool_reorg() -> eyre::Result<()> {
120121
);
121122
let genesis_hash = chain_spec.genesis_hash();
122123
let node_config = NodeConfig::test()
123-
.with_chain(chain_spec)
124+
.with_chain(chain_spec.clone())
124125
.with_unused_ports()
125126
.with_rpc(RpcServerArgs::default().with_unused_ports().with_http());
126127
let NodeHandle { node, node_exit_future: _ } = NodeBuilder::new(node_config.clone())
@@ -139,6 +140,7 @@ async fn maintain_txpool_reorg() -> eyre::Result<()> {
139140
"txpool maintenance task",
140141
reth_transaction_pool::maintain::maintain_transaction_pool_future(
141142
node.inner.provider.clone(),
143+
chain_spec,
142144
txpool.clone(),
143145
node.inner.provider.clone().canonical_state_stream(),
144146
executor.clone(),
@@ -269,6 +271,7 @@ async fn maintain_txpool_commit() -> eyre::Result<()> {
269271
"txpool maintenance task",
270272
reth_transaction_pool::maintain::maintain_transaction_pool_future(
271273
node.inner.provider.clone(),
274+
MAINNET.clone(),
272275
txpool.clone(),
273276
node.inner.provider.clone().canonical_state_stream(),
274277
executor.clone(),

crates/node/builder/src/components/pool.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
//! Pool component for the node builder.
22
3+
use crate::{BuilderContext, FullNodeTypes};
4+
35
use alloy_primitives::Address;
46
use reth_chain_state::CanonStateSubscriptions;
7+
use reth_chainspec::ChainSpecProvider;
58
use reth_node_api::TxTy;
69
use reth_transaction_pool::{
710
blobstore::DiskFileBlobStore, CoinbaseTipOrdering, PoolConfig, PoolTransaction, SubPoolLimit,
811
TransactionPool, TransactionValidationTaskExecutor, TransactionValidator,
912
};
1013
use std::{collections::HashSet, future::Future};
1114

12-
use crate::{BuilderContext, FullNodeTypes};
13-
1415
/// A type that knows how to build the transaction pool.
1516
pub trait PoolBuilder<Node: FullNodeTypes>: Send {
1617
/// The transaction pool to build.
@@ -236,11 +237,13 @@ where
236237
{
237238
let chain_events = ctx.provider().canonical_state_stream();
238239
let client = ctx.provider().clone();
240+
let chain_spec = client.chain_spec();
239241

240242
ctx.task_executor().spawn_critical(
241243
"txpool maintenance task",
242244
reth_transaction_pool::maintain::maintain_transaction_pool_future(
243245
client,
246+
chain_spec,
244247
pool,
245248
chain_events,
246249
ctx.task_executor().clone(),

crates/scroll/alloy/evm/src/tx/compression.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@ use alloy_eips::{Encodable2718, Typed2718};
55
use alloy_evm::{IntoTxEnv, RecoveredTx};
66
use alloy_primitives::{Address, Bytes, TxKind, U256};
77
use revm::context::TxEnv;
8-
use revm_scroll::l1block::TX_L1_FEE_PRECISION_U256;
98
use scroll_alloy_consensus::{ScrollTxEnvelope, TxL1Message};
109
pub use zstd_compression::compute_compression_ratio;
1110

1211
#[cfg(feature = "zstd_compression")]
1312
mod zstd_compression {
1413
use super::*;
1514
use std::io::Write;
15+
16+
use revm_scroll::l1block::TX_L1_FEE_PRECISION_U256;
1617
use zstd::{
1718
stream::Encoder,
1819
zstd_safe::{CParameter, ParamSwitch},

crates/scroll/alloy/hardforks/src/hardfork.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ impl ScrollHardfork {
3737
(Self::Euclid, ForkCondition::Timestamp(1744815600)),
3838
(Self::EuclidV2, ForkCondition::Timestamp(1745305200)),
3939
// TODO: update
40-
(Self::Feynman, ForkCondition::Timestamp(u64::MAX)),
40+
(Self::Feynman, ForkCondition::Timestamp(6000000000)),
4141
]
4242
}
4343

crates/scroll/alloy/rpc-types/src/transaction.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ impl Transaction {
3535
// For l1 messages, we set the `gasPrice` field to 0 in rpc
3636
0
3737
} else {
38+
// TODO: should we get the pool base fee in the case where the transaction is a pending
39+
// transaction here?
3840
base_fee
3941
.map(|base_fee| {
4042
tx.effective_tip_per_gas(base_fee).unwrap_or_default() + base_fee as u128

crates/scroll/chainspec/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ serde_json = { workspace = true, default-features = false }
3636
serde = { workspace = true, default-features = false, features = ["derive"] }
3737

3838
# misc
39+
auto_impl.workspace = true
3940
derive_more = { workspace = true, default-features = false }
4041
once_cell = { workspace = true, default-features = false }
4142

crates/scroll/chainspec/src/constants.rs

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,24 @@
11
use crate::genesis::L1Config;
2+
use alloy_eips::eip1559::BaseFeeParams;
23
use alloy_primitives::{address, b256, Address, B256};
34

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

8+
/// The system contract on L2 mainnet.
9+
pub const SCROLL_MAINNET_L2_SYSTEM_CONFIG_CONTRACT_ADDRESS: Address =
10+
address!("331A873a2a85219863d80d248F9e2978fE88D0Ea");
11+
712
/// The L1 message queue address for Scroll mainnet.
813
/// <https://etherscan.io/address/0x0d7E906BD9cAFa154b048cFa766Cc1E54E39AF9B>.
914
pub const SCROLL_MAINNET_L1_MESSAGE_QUEUE_ADDRESS: Address =
1015
address!("0d7E906BD9cAFa154b048cFa766Cc1E54E39AF9B");
1116

17+
/// The L1 message queue v2 address for Scroll mainnet.
18+
/// <https://etherscan.io/address/0x56971da63A3C0205184FEF096E9ddFc7A8C2D18a>.
19+
pub const SCROLL_MAINNET_L1_MESSAGE_QUEUE_V2_ADDRESS: Address =
20+
address!("56971da63A3C0205184FEF096E9ddFc7A8C2D18a");
21+
1222
/// The L1 proxy address for Scroll mainnet.
1323
/// <https://etherscan.io/address/0xa13BAF47339d63B743e7Da8741db5456DAc1E556>.
1424
pub const SCROLL_MAINNET_L1_PROXY_ADDRESS: Address =
@@ -21,6 +31,8 @@ pub const SCROLL_MAINNET_MAX_L1_MESSAGES: u64 = 10;
2131
pub const SCROLL_MAINNET_L1_CONFIG: L1Config = L1Config {
2232
l1_chain_id: alloy_chains::NamedChain::Mainnet as u64,
2333
l1_message_queue_address: SCROLL_MAINNET_L1_MESSAGE_QUEUE_ADDRESS,
34+
l1_message_queue_v2_address: SCROLL_MAINNET_L1_MESSAGE_QUEUE_V2_ADDRESS,
35+
l2_system_config_address: SCROLL_MAINNET_L2_SYSTEM_CONFIG_CONTRACT_ADDRESS,
2436
scroll_chain_address: SCROLL_MAINNET_L1_PROXY_ADDRESS,
2537
num_l1_messages_per_block: SCROLL_MAINNET_MAX_L1_MESSAGES,
2638
};
@@ -29,11 +41,20 @@ pub const SCROLL_MAINNET_L1_CONFIG: L1Config = L1Config {
2941
pub const SCROLL_MAINNET_GENESIS_HASH: B256 =
3042
b256!("bbc05efd412b7cd47a2ed0e5ddfcf87af251e414ea4c801d78b6784513180a80");
3143

44+
/// The system contract on L2 sepolia.
45+
pub const SCROLL_SEPOLIA_L2_SYSTEM_CONFIG_CONTRACT_ADDRESS: Address =
46+
address!("F444cF06A3E3724e20B35c2989d3942ea8b59124");
47+
3248
/// The L1 message queue address for Scroll sepolia.
3349
/// <https://sepolia.etherscan.io/address/0xF0B2293F5D834eAe920c6974D50957A1732de763>.
3450
pub const SCROLL_SEPOLIA_L1_MESSAGE_QUEUE_ADDRESS: Address =
3551
address!("F0B2293F5D834eAe920c6974D50957A1732de763");
3652

53+
/// The L1 message queue address v2 for Scroll sepolia.
54+
/// <https://sepolia.etherscan.io/address/0xA0673eC0A48aa924f067F1274EcD281A10c5f19F>.
55+
pub const SCROLL_SEPOLIA_L1_MESSAGE_QUEUE_V2_ADDRESS: Address =
56+
address!("A0673eC0A48aa924f067F1274EcD281A10c5f19F");
57+
3758
/// The L1 proxy address for Scroll sepolia.
3859
/// <https://sepolia.etherscan.io/address/0x2D567EcE699Eabe5afCd141eDB7A4f2D0D6ce8a0>
3960
pub const SCROLL_SEPOLIA_L1_PROXY_ADDRESS: Address =
@@ -46,14 +67,24 @@ pub const SCROLL_SEPOLIA_MAX_L1_MESSAGES: u64 = 10;
4667
pub const SCROLL_SEPOLIA_L1_CONFIG: L1Config = L1Config {
4768
l1_chain_id: alloy_chains::NamedChain::Sepolia as u64,
4869
l1_message_queue_address: SCROLL_SEPOLIA_L1_MESSAGE_QUEUE_ADDRESS,
70+
l1_message_queue_v2_address: SCROLL_SEPOLIA_L1_MESSAGE_QUEUE_V2_ADDRESS,
71+
l2_system_config_address: SCROLL_SEPOLIA_L2_SYSTEM_CONFIG_CONTRACT_ADDRESS,
4972
scroll_chain_address: SCROLL_SEPOLIA_L1_PROXY_ADDRESS,
5073
num_l1_messages_per_block: SCROLL_SEPOLIA_MAX_L1_MESSAGES,
5174
};
5275

76+
/// The system contract on devnet.
77+
pub const SCROLL_DEV_L2_SYSTEM_CONFIG_CONTRACT_ADDRESS: Address =
78+
address!("0000000000000000000000000000000000000000");
79+
5380
/// The L1 message queue address for Scroll dev.
5481
pub const SCROLL_DEV_L1_MESSAGE_QUEUE_ADDRESS: Address =
5582
address!("0000000000000000000000000000000000000000");
5683

84+
/// The L1 message queue v2 address for Scroll dev.
85+
pub const SCROLL_DEV_L1_MESSAGE_QUEUE_V2_ADDRESS: Address =
86+
address!("0000000000000000000000000000000000000000");
87+
5788
/// The L1 proxy address for Scroll dev.
5889
pub const SCROLL_DEV_L1_PROXY_ADDRESS: Address =
5990
address!("0000000000000000000000000000000000000000");
@@ -65,10 +96,24 @@ pub const SCROLL_DEV_MAX_L1_MESSAGES: u64 = 10;
6596
pub const SCROLL_DEV_L1_CONFIG: L1Config = L1Config {
6697
l1_chain_id: alloy_chains::NamedChain::Goerli as u64,
6798
l1_message_queue_address: SCROLL_DEV_L1_MESSAGE_QUEUE_ADDRESS,
99+
l1_message_queue_v2_address: SCROLL_DEV_L1_MESSAGE_QUEUE_V2_ADDRESS,
68100
scroll_chain_address: SCROLL_DEV_L1_PROXY_ADDRESS,
101+
l2_system_config_address: SCROLL_DEV_L2_SYSTEM_CONFIG_CONTRACT_ADDRESS,
69102
num_l1_messages_per_block: SCROLL_DEV_MAX_L1_MESSAGES,
70103
};
71104

72105
/// The Scroll Sepolia genesis hash
73106
pub const SCROLL_SEPOLIA_GENESIS_HASH: B256 =
74107
b256!("aa62d1a8b2bffa9e5d2368b63aae0d98d54928bd713125e3fd9e5c896c68592c");
108+
109+
/// The base fee params for Feynman.
110+
pub const SCROLL_BASE_FEE_PARAMS_FEYNMAN: BaseFeeParams = BaseFeeParams::new(
111+
SCROLL_EIP1559_BASE_FEE_MAX_CHANGE_DENOMINATOR_FEYNMAN,
112+
SCROLL_EIP1559_DEFAULT_ELASTICITY_MULTIPLIER_FEYNMAN,
113+
);
114+
115+
/// The scroll EIP1559 max change denominator for Feynman.
116+
pub const SCROLL_EIP1559_BASE_FEE_MAX_CHANGE_DENOMINATOR_FEYNMAN: u128 = 8;
117+
118+
/// The scroll EIP1559 default elasticity multiplier for Feynman.
119+
pub const SCROLL_EIP1559_DEFAULT_ELASTICITY_MULTIPLIER_FEYNMAN: u128 = 2;

crates/scroll/chainspec/src/dev.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
//! Chain specification in dev mode for custom chain.
22
3-
use alloc::sync::Arc;
3+
use crate::{
4+
constants::SCROLL_BASE_FEE_PARAMS_FEYNMAN, make_genesis_header, LazyLock, ScrollChainConfig,
5+
ScrollChainSpec,
6+
};
7+
use alloc::{sync::Arc, vec};
48

59
use alloy_chains::Chain;
610
use alloy_primitives::U256;
7-
use reth_chainspec::{BaseFeeParams, BaseFeeParamsKind, ChainSpec};
11+
use reth_chainspec::{BaseFeeParamsKind, ChainSpec, Hardfork};
812
use reth_primitives_traits::SealedHeader;
913
use reth_scroll_forks::DEV_HARDFORKS;
10-
11-
use crate::{make_genesis_header, LazyLock, ScrollChainConfig, ScrollChainSpec};
14+
use scroll_alloy_hardforks::ScrollHardfork;
1215

1316
/// Scroll dev testnet specification
1417
///
@@ -24,7 +27,9 @@ pub static SCROLL_DEV: LazyLock<Arc<ScrollChainSpec>> = LazyLock::new(|| {
2427
genesis,
2528
paris_block_and_final_difficulty: Some((0, U256::from(0))),
2629
hardforks: DEV_HARDFORKS.clone(),
27-
base_fee_params: BaseFeeParamsKind::Constant(BaseFeeParams::ethereum()),
30+
base_fee_params: BaseFeeParamsKind::Variable(
31+
vec![(ScrollHardfork::Feynman.boxed(), SCROLL_BASE_FEE_PARAMS_FEYNMAN)].into(),
32+
),
2833
..Default::default()
2934
},
3035
config: ScrollChainConfig::dev(),

crates/scroll/chainspec/src/genesis.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,14 @@ pub struct L1Config {
9191
/// The L1 contract address of the contract that handles the message queue targeting the Scroll
9292
/// rollup.
9393
pub l1_message_queue_address: Address,
94+
/// The L1 contract address of the contract that handles the message queue v2 targeting the
95+
/// Scroll rollup, used post Euclid fork.
96+
pub l1_message_queue_v2_address: Address,
9497
/// The L1 contract address of the proxy contract which is responsible for Scroll rollup
9598
/// settlement.
9699
pub scroll_chain_address: Address,
100+
/// The address of the L2 system contract.
101+
pub l2_system_config_address: Address,
97102
/// The maximum number of L1 messages to be consumed per L2 rollup block.
98103
pub num_l1_messages_per_block: u64,
99104
}
@@ -157,6 +162,8 @@ impl TryFrom<&OtherFields> for ScrollChainConfig {
157162
#[cfg(test)]
158163
mod tests {
159164
use super::*;
165+
use crate::SCROLL_MAINNET_L2_SYSTEM_CONFIG_CONTRACT_ADDRESS;
166+
160167
use alloy_primitives::address;
161168

162169
#[test]
@@ -205,6 +212,8 @@ mod tests {
205212
"l1Config": {
206213
"l1ChainId": 1,
207214
"l1MessageQueueAddress": "0x0d7E906BD9cAFa154b048cFa766Cc1E54E39AF9B",
215+
"l1MessageQueueV2Address": "0x56971da63A3C0205184FEF096E9ddFc7A8C2D18a",
216+
"l2SystemConfigAddress": "0x331A873a2a85219863d80d248F9e2978fE88D0Ea",
208217
"scrollChainAddress": "0xa13BAF47339d63B743e7Da8741db5456DAc1E556",
209218
"numL1MessagesPerBlock": 10
210219
}
@@ -231,6 +240,10 @@ mod tests {
231240
l1_config: L1Config {
232241
l1_chain_id: 1,
233242
l1_message_queue_address: address!("0d7E906BD9cAFa154b048cFa766Cc1E54E39AF9B"),
243+
l1_message_queue_v2_address: address!(
244+
"56971da63A3C0205184FEF096E9ddFc7A8C2D18a"
245+
),
246+
l2_system_config_address: SCROLL_MAINNET_L2_SYSTEM_CONFIG_CONTRACT_ADDRESS,
234247
scroll_chain_address: address!("a13BAF47339d63B743e7Da8741db5456DAc1E556"),
235248
num_l1_messages_per_block: 10,
236249
},

0 commit comments

Comments
 (0)