Skip to content

feat: suggest gas price based on latest block's transactions #220

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

Merged
merged 9 commits into from
Jul 31, 2025
Merged
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
332 changes: 167 additions & 165 deletions Cargo.lock

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ reth-primitives-traits = { git = "https://github.com/scroll-tech/reth.git", defa
reth-provider = { git = "https://github.com/scroll-tech/reth.git", default-features = false }
reth-rpc-builder = { git = "https://github.com/scroll-tech/reth.git", default-features = false }
reth-rpc-server-types = { git = "https://github.com/scroll-tech/reth.git", default-features = false }
reth-storage-api = { git = "https://github.com/scroll-tech/reth.git", default-features = false }
reth-tasks = { git = "https://github.com/scroll-tech/reth.git", default-features = false }
reth-tokio-util = { git = "https://github.com/scroll-tech/reth.git", default-features = false }
reth-tracing = { git = "https://github.com/scroll-tech/reth.git", default-features = false }
Expand Down
2 changes: 1 addition & 1 deletion crates/network/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ reth-network-api.workspace = true
reth-network-types = { git = "https://github.com/scroll-tech/reth.git", default-features = false }
reth-network-peers.workspace = true
reth-primitives-traits.workspace = true
reth-storage-api = { workspace = true, default-features = false }
reth-storage-api = { git = "https://github.com/scroll-tech/reth.git", default-features = false }

# scroll
reth-scroll-chainspec.workspace = true
Expand Down
6 changes: 6 additions & 0 deletions crates/node/src/add_ons/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
//! The [`ScrollRollupNodeAddOns`] implementation for the Scroll rollup node.

use crate::constants;

use super::args::ScrollRollupNodeConfig;
use reth_evm::{ConfigureEvm, EvmFactory, EvmFactoryFor};
use reth_network::NetworkProtocols;
Expand Down Expand Up @@ -65,6 +67,10 @@ where
) -> Self {
let rpc_add_ons = RpcAddOns::new(
ScrollEthApiBuilder::default()
.with_min_suggested_priority_fee(
config.gas_price_oracle_args.default_suggested_priority_fee,
)
.with_payload_size_limit(constants::DEFAULT_PAYLOAD_SIZE_LIMIT)
.with_sequencer(config.network_args.sequencer_url.clone()),
Default::default(),
Default::default(),
Expand Down
18 changes: 18 additions & 0 deletions crates/node/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ pub struct ScrollRollupNodeConfig {
/// The signer arguments
#[command(flatten)]
pub signer_args: SignerArgs,
/// The gas price oracle args
#[command(flatten)]
pub gas_price_oracle_args: GasPriceOracleArgs,
}

impl ScrollRollupNodeConfig {
Expand Down Expand Up @@ -483,6 +486,15 @@ impl SignerArgs {
}
}

/// The arguments for the sequencer.
#[derive(Debug, Default, Clone, clap::Args)]
pub struct GasPriceOracleArgs {
/// Minimum suggested priority fee (tip) in wei, default `100`
#[arg(long, default_value_t = 100)]
#[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)]
pub default_suggested_priority_fee: u64,
}

#[cfg(test)]
mod tests {
use super::*;
Expand All @@ -499,6 +511,7 @@ mod tests {
l1_provider_args: L1ProviderArgs::default(),
beacon_provider_args: BeaconProviderArgs::default(),
network_args: NetworkArgs::default(),
gas_price_oracle_args: GasPriceOracleArgs::default(),
};

let result = config.validate();
Expand All @@ -522,6 +535,7 @@ mod tests {
l1_provider_args: L1ProviderArgs::default(),
beacon_provider_args: BeaconProviderArgs::default(),
network_args: NetworkArgs::default(),
gas_price_oracle_args: GasPriceOracleArgs::default(),
};

let result = config.validate();
Expand All @@ -545,6 +559,7 @@ mod tests {
l1_provider_args: L1ProviderArgs::default(),
beacon_provider_args: BeaconProviderArgs::default(),
network_args: NetworkArgs::default(),
gas_price_oracle_args: GasPriceOracleArgs::default(),
};

assert!(config.validate().is_ok());
Expand All @@ -561,6 +576,7 @@ mod tests {
l1_provider_args: L1ProviderArgs::default(),
beacon_provider_args: BeaconProviderArgs::default(),
network_args: NetworkArgs::default(),
gas_price_oracle_args: GasPriceOracleArgs::default(),
};

assert!(config.validate().is_ok());
Expand All @@ -577,6 +593,7 @@ mod tests {
l1_provider_args: L1ProviderArgs::default(),
beacon_provider_args: BeaconProviderArgs::default(),
network_args: NetworkArgs::default(),
gas_price_oracle_args: GasPriceOracleArgs::default(),
};

assert!(config.validate().is_ok());
Expand All @@ -593,6 +610,7 @@ mod tests {
l1_provider_args: L1ProviderArgs::default(),
beacon_provider_args: BeaconProviderArgs::default(),
network_args: NetworkArgs::default(),
gas_price_oracle_args: GasPriceOracleArgs::default(),
};

assert!(config.validate().is_ok());
Expand Down
3 changes: 3 additions & 0 deletions crates/node/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,6 @@ pub(crate) const DEFAULT_MAX_L1_MESSAGES_PER_BLOCK: u64 = 4;

/// The gap in blocks between the P2P and EN which triggers sync.
pub(crate) const BLOCK_GAP_TRIGGER: u64 = 500_000;

/// The default suggested priority fee for the gas price oracle.
pub(crate) const DEFAULT_SUGGEST_PRIORITY_FEE: u64 = 100;
4 changes: 4 additions & 0 deletions crates/node/src/test_utils.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
//! This crate contains utilities for running end-to-end tests for the scroll reth node.

use crate::GasPriceOracleArgs;

use super::{
BeaconProviderArgs, DatabaseArgs, EngineDriverArgs, L1ProviderArgs, ScrollRollupNode,
ScrollRollupNodeConfig, SequencerArgs,
Expand Down Expand Up @@ -149,6 +151,7 @@ pub fn default_test_scroll_rollup_node_config() -> ScrollRollupNodeConfig {
..Default::default()
},
signer_args: Default::default(),
gas_price_oracle_args: GasPriceOracleArgs::default(),
}
}

Expand All @@ -173,5 +176,6 @@ pub fn default_sequencer_test_scroll_rollup_node_config() -> ScrollRollupNodeCon
..Default::default()
},
signer_args: Default::default(),
gas_price_oracle_args: GasPriceOracleArgs::default(),
}
}
4 changes: 3 additions & 1 deletion crates/node/tests/e2e.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use rollup_node::{
default_sequencer_test_scroll_rollup_node_config, default_test_scroll_rollup_node_config,
generate_tx, setup_engine,
},
BeaconProviderArgs, DatabaseArgs, EngineDriverArgs, L1ProviderArgs,
BeaconProviderArgs, DatabaseArgs, EngineDriverArgs, GasPriceOracleArgs, L1ProviderArgs,
NetworkArgs as ScrollNetworkArgs, ScrollRollupNodeConfig, SequencerArgs,
};
use rollup_node_manager::{RollupManagerCommand, RollupManagerEvent, RollupManagerHandle};
Expand Down Expand Up @@ -52,6 +52,7 @@ async fn can_bridge_l1_messages() -> eyre::Result<()> {
..Default::default()
},
signer_args: Default::default(),
gas_price_oracle_args: GasPriceOracleArgs::default(),
};
let (mut nodes, _tasks, _wallet) = setup_engine(node_args, 1, chain_spec, false, false).await?;
let node = nodes.pop().unwrap();
Expand Down Expand Up @@ -121,6 +122,7 @@ async fn can_sequence_and_gossip_blocks() {
..Default::default()
},
signer_args: Default::default(),
gas_price_oracle_args: GasPriceOracleArgs::default(),
};

let (nodes, _tasks, wallet) =
Expand Down
5 changes: 3 additions & 2 deletions crates/node/tests/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ use rollup_node::{
default_sequencer_test_scroll_rollup_node_config, default_test_scroll_rollup_node_config,
setup_engine,
},
BeaconProviderArgs, DatabaseArgs, EngineDriverArgs, L1ProviderArgs, NetworkArgs,
ScrollRollupNode, ScrollRollupNodeConfig, SequencerArgs,
BeaconProviderArgs, DatabaseArgs, EngineDriverArgs, GasPriceOracleArgs, L1ProviderArgs,
NetworkArgs, ScrollRollupNode, ScrollRollupNodeConfig, SequencerArgs,
};
use rollup_node_manager::{RollupManagerCommand, RollupManagerEvent};
use rollup_node_providers::BlobSource;
Expand Down Expand Up @@ -58,6 +58,7 @@ async fn test_should_consolidate_to_block_15k() -> eyre::Result<()> {
blob_source: BlobSource::Beacon,
},
signer_args: Default::default(),
gas_price_oracle_args: GasPriceOracleArgs::default(),
};

let chain_spec = (*SCROLL_SEPOLIA).clone();
Expand Down
6 changes: 4 additions & 2 deletions crates/sequencer/tests/e2e.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ use reth_scroll_chainspec::SCROLL_DEV;
use reth_scroll_node::test_utils::setup;
use rollup_node::{
test_utils::{default_test_scroll_rollup_node_config, setup_engine},
BeaconProviderArgs, DatabaseArgs, EngineDriverArgs, L1ProviderArgs, NetworkArgs,
ScrollRollupNodeConfig, SequencerArgs, SignerArgs,
BeaconProviderArgs, DatabaseArgs, EngineDriverArgs, GasPriceOracleArgs, L1ProviderArgs,
NetworkArgs, ScrollRollupNodeConfig, SequencerArgs, SignerArgs,
};
use rollup_node_manager::RollupManagerEvent;
use rollup_node_primitives::{sig_encode_hash, BlockInfo, L1MessageEnvelope};
Expand Down Expand Up @@ -454,6 +454,7 @@ async fn can_sequence_blocks_with_private_key_file() -> eyre::Result<()> {
key_file: Some(temp_file.path().to_path_buf()),
aws_kms_key_id: None,
},
gas_price_oracle_args: GasPriceOracleArgs::default(),
};

let (nodes, _tasks, wallet) =
Expand Down Expand Up @@ -542,6 +543,7 @@ async fn can_sequence_blocks_with_hex_key_file_without_prefix() -> eyre::Result<
key_file: Some(temp_file.path().to_path_buf()),
aws_kms_key_id: None,
},
gas_price_oracle_args: GasPriceOracleArgs::default(),
};

let (nodes, _tasks, wallet) =
Expand Down