Skip to content

Commit ee349a7

Browse files
yiweichigeorgehao
andauthored
feat: suggest gas price based on latest block's transactions (#220)
* feat: suggest gas price based on latest block's transactions * update dependencies * fix typos --------- Co-authored-by: georgehao <[email protected]>
1 parent c030533 commit ee349a7

File tree

10 files changed

+209
-172
lines changed

10 files changed

+209
-172
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,6 @@ reth-primitives-traits = { git = "https://github.com/scroll-tech/reth.git", defa
155155
reth-provider = { git = "https://github.com/scroll-tech/reth.git", default-features = false }
156156
reth-rpc-builder = { git = "https://github.com/scroll-tech/reth.git", default-features = false }
157157
reth-rpc-server-types = { git = "https://github.com/scroll-tech/reth.git", default-features = false }
158-
reth-storage-api = { git = "https://github.com/scroll-tech/reth.git", default-features = false }
159158
reth-tasks = { git = "https://github.com/scroll-tech/reth.git", default-features = false }
160159
reth-tokio-util = { git = "https://github.com/scroll-tech/reth.git", default-features = false }
161160
reth-tracing = { git = "https://github.com/scroll-tech/reth.git", default-features = false }

crates/network/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ reth-network-api.workspace = true
1717
reth-network-types = { git = "https://github.com/scroll-tech/reth.git", default-features = false }
1818
reth-network-peers.workspace = true
1919
reth-primitives-traits.workspace = true
20-
reth-storage-api = { workspace = true, default-features = false }
20+
reth-storage-api = { git = "https://github.com/scroll-tech/reth.git", default-features = false }
2121

2222
# scroll
2323
reth-scroll-chainspec.workspace = true

crates/node/src/add_ons/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
//! The [`ScrollRollupNodeAddOns`] implementation for the Scroll rollup node.
22
3+
use crate::constants;
4+
35
use super::args::ScrollRollupNodeConfig;
46
use reth_evm::{ConfigureEvm, EvmFactory, EvmFactoryFor};
57
use reth_network::NetworkProtocols;
@@ -65,6 +67,10 @@ where
6567
) -> Self {
6668
let rpc_add_ons = RpcAddOns::new(
6769
ScrollEthApiBuilder::default()
70+
.with_min_suggested_priority_fee(
71+
config.gas_price_oracle_args.default_suggested_priority_fee,
72+
)
73+
.with_payload_size_limit(constants::DEFAULT_PAYLOAD_SIZE_LIMIT)
6874
.with_sequencer(config.network_args.sequencer_url.clone()),
6975
Default::default(),
7076
Default::default(),

crates/node/src/args.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ pub struct ScrollRollupNodeConfig {
6666
/// The signer arguments
6767
#[command(flatten)]
6868
pub signer_args: SignerArgs,
69+
/// The gas price oracle args
70+
#[command(flatten)]
71+
pub gas_price_oracle_args: GasPriceOracleArgs,
6972
}
7073

7174
impl ScrollRollupNodeConfig {
@@ -483,6 +486,15 @@ impl SignerArgs {
483486
}
484487
}
485488

489+
/// The arguments for the sequencer.
490+
#[derive(Debug, Default, Clone, clap::Args)]
491+
pub struct GasPriceOracleArgs {
492+
/// Minimum suggested priority fee (tip) in wei, default `100`
493+
#[arg(long, default_value_t = 100)]
494+
#[arg(long = "gpo.default-suggest-priority-fee", id = "default_suggest_priority_fee", value_name = "DEFAULT_SUGGEST_PRIORITY_FEE", default_value_t = constants::DEFAULT_SUGGEST_PRIORITY_FEE)]
495+
pub default_suggested_priority_fee: u64,
496+
}
497+
486498
#[cfg(test)]
487499
mod tests {
488500
use super::*;
@@ -499,6 +511,7 @@ mod tests {
499511
l1_provider_args: L1ProviderArgs::default(),
500512
beacon_provider_args: BeaconProviderArgs::default(),
501513
network_args: NetworkArgs::default(),
514+
gas_price_oracle_args: GasPriceOracleArgs::default(),
502515
};
503516

504517
let result = config.validate();
@@ -522,6 +535,7 @@ mod tests {
522535
l1_provider_args: L1ProviderArgs::default(),
523536
beacon_provider_args: BeaconProviderArgs::default(),
524537
network_args: NetworkArgs::default(),
538+
gas_price_oracle_args: GasPriceOracleArgs::default(),
525539
};
526540

527541
let result = config.validate();
@@ -545,6 +559,7 @@ mod tests {
545559
l1_provider_args: L1ProviderArgs::default(),
546560
beacon_provider_args: BeaconProviderArgs::default(),
547561
network_args: NetworkArgs::default(),
562+
gas_price_oracle_args: GasPriceOracleArgs::default(),
548563
};
549564

550565
assert!(config.validate().is_ok());
@@ -561,6 +576,7 @@ mod tests {
561576
l1_provider_args: L1ProviderArgs::default(),
562577
beacon_provider_args: BeaconProviderArgs::default(),
563578
network_args: NetworkArgs::default(),
579+
gas_price_oracle_args: GasPriceOracleArgs::default(),
564580
};
565581

566582
assert!(config.validate().is_ok());
@@ -577,6 +593,7 @@ mod tests {
577593
l1_provider_args: L1ProviderArgs::default(),
578594
beacon_provider_args: BeaconProviderArgs::default(),
579595
network_args: NetworkArgs::default(),
596+
gas_price_oracle_args: GasPriceOracleArgs::default(),
580597
};
581598

582599
assert!(config.validate().is_ok());
@@ -593,6 +610,7 @@ mod tests {
593610
l1_provider_args: L1ProviderArgs::default(),
594611
beacon_provider_args: BeaconProviderArgs::default(),
595612
network_args: NetworkArgs::default(),
613+
gas_price_oracle_args: GasPriceOracleArgs::default(),
596614
};
597615

598616
assert!(config.validate().is_ok());

crates/node/src/constants.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,6 @@ pub(crate) const DEFAULT_MAX_L1_MESSAGES_PER_BLOCK: u64 = 4;
2121

2222
/// The gap in blocks between the P2P and EN which triggers sync.
2323
pub(crate) const BLOCK_GAP_TRIGGER: u64 = 500_000;
24+
25+
/// The default suggested priority fee for the gas price oracle.
26+
pub(crate) const DEFAULT_SUGGEST_PRIORITY_FEE: u64 = 100;

crates/node/src/test_utils.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
//! This crate contains utilities for running end-to-end tests for the scroll reth node.
22
3+
use crate::GasPriceOracleArgs;
4+
35
use super::{
46
BeaconProviderArgs, DatabaseArgs, EngineDriverArgs, L1ProviderArgs, ScrollRollupNode,
57
ScrollRollupNodeConfig, SequencerArgs,
@@ -149,6 +151,7 @@ pub fn default_test_scroll_rollup_node_config() -> ScrollRollupNodeConfig {
149151
..Default::default()
150152
},
151153
signer_args: Default::default(),
154+
gas_price_oracle_args: GasPriceOracleArgs::default(),
152155
}
153156
}
154157

@@ -173,5 +176,6 @@ pub fn default_sequencer_test_scroll_rollup_node_config() -> ScrollRollupNodeCon
173176
..Default::default()
174177
},
175178
signer_args: Default::default(),
179+
gas_price_oracle_args: GasPriceOracleArgs::default(),
176180
}
177181
}

crates/node/tests/e2e.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use rollup_node::{
1313
default_sequencer_test_scroll_rollup_node_config, default_test_scroll_rollup_node_config,
1414
generate_tx, setup_engine,
1515
},
16-
BeaconProviderArgs, DatabaseArgs, EngineDriverArgs, L1ProviderArgs,
16+
BeaconProviderArgs, DatabaseArgs, EngineDriverArgs, GasPriceOracleArgs, L1ProviderArgs,
1717
NetworkArgs as ScrollNetworkArgs, ScrollRollupNodeConfig, SequencerArgs,
1818
};
1919
use rollup_node_manager::{RollupManagerCommand, RollupManagerEvent, RollupManagerHandle};
@@ -52,6 +52,7 @@ async fn can_bridge_l1_messages() -> eyre::Result<()> {
5252
..Default::default()
5353
},
5454
signer_args: Default::default(),
55+
gas_price_oracle_args: GasPriceOracleArgs::default(),
5556
};
5657
let (mut nodes, _tasks, _wallet) = setup_engine(node_args, 1, chain_spec, false, false).await?;
5758
let node = nodes.pop().unwrap();
@@ -121,6 +122,7 @@ async fn can_sequence_and_gossip_blocks() {
121122
..Default::default()
122123
},
123124
signer_args: Default::default(),
125+
gas_price_oracle_args: GasPriceOracleArgs::default(),
124126
};
125127

126128
let (nodes, _tasks, wallet) =

crates/node/tests/sync.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ use rollup_node::{
1212
default_sequencer_test_scroll_rollup_node_config, default_test_scroll_rollup_node_config,
1313
setup_engine,
1414
},
15-
BeaconProviderArgs, DatabaseArgs, EngineDriverArgs, L1ProviderArgs, NetworkArgs,
16-
ScrollRollupNode, ScrollRollupNodeConfig, SequencerArgs,
15+
BeaconProviderArgs, DatabaseArgs, EngineDriverArgs, GasPriceOracleArgs, L1ProviderArgs,
16+
NetworkArgs, ScrollRollupNode, ScrollRollupNodeConfig, SequencerArgs,
1717
};
1818
use rollup_node_manager::{RollupManagerCommand, RollupManagerEvent};
1919
use rollup_node_providers::BlobSource;
@@ -58,6 +58,7 @@ async fn test_should_consolidate_to_block_15k() -> eyre::Result<()> {
5858
blob_source: BlobSource::Beacon,
5959
},
6060
signer_args: Default::default(),
61+
gas_price_oracle_args: GasPriceOracleArgs::default(),
6162
};
6263

6364
let chain_spec = (*SCROLL_SEPOLIA).clone();

crates/sequencer/tests/e2e.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ use reth_scroll_chainspec::SCROLL_DEV;
1010
use reth_scroll_node::test_utils::setup;
1111
use rollup_node::{
1212
test_utils::{default_test_scroll_rollup_node_config, setup_engine},
13-
BeaconProviderArgs, DatabaseArgs, EngineDriverArgs, L1ProviderArgs, NetworkArgs,
14-
ScrollRollupNodeConfig, SequencerArgs, SignerArgs,
13+
BeaconProviderArgs, DatabaseArgs, EngineDriverArgs, GasPriceOracleArgs, L1ProviderArgs,
14+
NetworkArgs, ScrollRollupNodeConfig, SequencerArgs, SignerArgs,
1515
};
1616
use rollup_node_manager::RollupManagerEvent;
1717
use rollup_node_primitives::{sig_encode_hash, BlockInfo, L1MessageEnvelope};
@@ -454,6 +454,7 @@ async fn can_sequence_blocks_with_private_key_file() -> eyre::Result<()> {
454454
key_file: Some(temp_file.path().to_path_buf()),
455455
aws_kms_key_id: None,
456456
},
457+
gas_price_oracle_args: GasPriceOracleArgs::default(),
457458
};
458459

459460
let (nodes, _tasks, wallet) =
@@ -542,6 +543,7 @@ async fn can_sequence_blocks_with_hex_key_file_without_prefix() -> eyre::Result<
542543
key_file: Some(temp_file.path().to_path_buf()),
543544
aws_kms_key_id: None,
544545
},
546+
gas_price_oracle_args: GasPriceOracleArgs::default(),
545547
};
546548

547549
let (nodes, _tasks, wallet) =

0 commit comments

Comments
 (0)