⚠ This page is served via a proxy. Original site: https://github.com
This service does not collect credentials or authentication data.
Skip to content
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
29 changes: 15 additions & 14 deletions Cargo.lock

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

28 changes: 14 additions & 14 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -487,18 +487,18 @@ reth-ress-protocol = { path = "crates/ress/protocol" }
reth-ress-provider = { path = "crates/ress/provider" }

# revm
revm = { git = "https://github.com/scroll-tech/revm", tag = "scroll-v91", default-features = false, features = ["enable_eip7702", "enable_eip7623"] }
revm-bytecode = { git = "https://github.com/scroll-tech/revm", tag = "scroll-v91", default-features = false }
revm-database = { git = "https://github.com/scroll-tech/revm", tag = "scroll-v91", default-features = false }
revm-state = { git = "https://github.com/scroll-tech/revm", tag = "scroll-v91", default-features = false }
revm-primitives = { git = "https://github.com/scroll-tech/revm", tag = "scroll-v91", default-features = false }
revm-interpreter = { git = "https://github.com/scroll-tech/revm", tag = "scroll-v91", default-features = false }
revm-inspector = { git = "https://github.com/scroll-tech/revm", tag = "scroll-v91", default-features = false }
revm-context = { git = "https://github.com/scroll-tech/revm", tag = "scroll-v91", default-features = false }
revm-context-interface = { git = "https://github.com/scroll-tech/revm", tag = "scroll-v91", default-features = false }
revm-database-interface = { git = "https://github.com/scroll-tech/revm", tag = "scroll-v91", default-features = false }
op-revm = { git = "https://github.com/scroll-tech/revm", tag = "scroll-v91", default-features = false }
revm-scroll = { git = "https://github.com/scroll-tech/scroll-revm", tag = "scroll-v91", default-features = false }
revm = { git = "https://github.com/scroll-tech/revm", tag = "scroll-v91.1", default-features = false, features = ["enable_eip7702", "enable_eip7623"] }
revm-bytecode = { git = "https://github.com/scroll-tech/revm", tag = "scroll-v91.1", default-features = false }
revm-database = { git = "https://github.com/scroll-tech/revm", tag = "scroll-v91.1", default-features = false }
revm-state = { git = "https://github.com/scroll-tech/revm", tag = "scroll-v91.1", default-features = false }
revm-primitives = { git = "https://github.com/scroll-tech/revm", tag = "scroll-v91.1", default-features = false }
revm-interpreter = { git = "https://github.com/scroll-tech/revm", tag = "scroll-v91.1", default-features = false }
revm-inspector = { git = "https://github.com/scroll-tech/revm", tag = "scroll-v91.1", default-features = false }
revm-context = { git = "https://github.com/scroll-tech/revm", tag = "scroll-v91.1", default-features = false }
revm-context-interface = { git = "https://github.com/scroll-tech/revm", tag = "scroll-v91.1", default-features = false }
revm-database-interface = { git = "https://github.com/scroll-tech/revm", tag = "scroll-v91.1", default-features = false }
op-revm = { git = "https://github.com/scroll-tech/revm", tag = "scroll-v91.1", default-features = false }
revm-scroll = { git = "https://github.com/scroll-tech/scroll-revm", tag = "scroll-v91.1", default-features = false }
revm-inspectors = "0.31.0"

# eth
Expand Down Expand Up @@ -771,8 +771,8 @@ walkdir = "2.3.3"
vergen-git2 = "1.0.5"

[patch.crates-io]
revm = { git = "https://github.com/scroll-tech/revm", tag = "scroll-v91" }
op-revm = { git = "https://github.com/scroll-tech/revm", tag = "scroll-v91" }
revm = { git = "https://github.com/scroll-tech/revm", tag = "scroll-v91.1" }
op-revm = { git = "https://github.com/scroll-tech/revm", tag = "scroll-v91.1" }
# alloy-consensus = { git = "https://github.com/alloy-rs/alloy", rev = "cfb13aa" }
# alloy-contract = { git = "https://github.com/alloy-rs/alloy", rev = "cfb13aa" }
# alloy-eips = { git = "https://github.com/alloy-rs/alloy", rev = "cfb13aa" }
Expand Down
129 changes: 126 additions & 3 deletions crates/scroll/node/src/builder/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,21 @@ use scroll_alloy_hardforks::ScrollHardforks;
pub struct ScrollPoolBuilder<T = reth_scroll_txpool::ScrollPooledTransaction> {
/// Enforced overrides that are applied to the pool config.
pub pool_config_overrides: PoolBuilderConfigOverrides,

/// Require L1 data fee buffer in balance check.
/// When enabled, validates balance >= `L2_cost` + 2*`L1_cost` but only charges `L2_cost` +
/// 1*`L1_cost`.
pub require_l1_data_fee_buffer: bool,
/// Marker for the pooled transaction type.
_pd: core::marker::PhantomData<T>,
}

impl<T> Default for ScrollPoolBuilder<T> {
fn default() -> Self {
Self { pool_config_overrides: Default::default(), _pd: Default::default() }
Self {
pool_config_overrides: Default::default(),
require_l1_data_fee_buffer: false,
_pd: Default::default(),
}
}
}

Expand All @@ -44,6 +51,14 @@ impl<T> ScrollPoolBuilder<T> {
self.pool_config_overrides = pool_config_overrides;
self
}

/// Sets the require L1 data fee buffer flag.
/// When enabled, validates balance >= `L2_cost` + 2*`L1_cost` but only charges `L2_cost` +
/// 1*`L1_cost`. This matches geth's block validation behavior.
pub const fn with_require_l1_data_fee_buffer(mut self, require: bool) -> Self {
self.require_l1_data_fee_buffer = require;
self
}
}

impl<Node, T> PoolBuilder<Node> for ScrollPoolBuilder<T>
Expand All @@ -58,7 +73,7 @@ where
type Pool = ScrollTransactionPool<Node::Provider, DiskFileBlobStore, T>;

async fn build_pool(self, ctx: &BuilderContext<Node>) -> eyre::Result<Self::Pool> {
let Self { pool_config_overrides, .. } = self;
let Self { pool_config_overrides, require_l1_data_fee_buffer, .. } = self;
let data_dir = ctx.config().datadir();
let blob_store = DiskFileBlobStore::open(data_dir.blobstore(), Default::default())?;

Expand All @@ -81,6 +96,7 @@ where
// In --dev mode we can't require gas fees because we're unable to decode
// the L1 block info
.require_l1_data_gas_fee(!ctx.config().dev.dev)
.require_l1_data_fee_buffer(require_l1_data_fee_buffer)
});

let transaction_pool = reth_transaction_pool::Pool::new(
Expand Down Expand Up @@ -379,4 +395,111 @@ mod tests {
// drop all validation tasks.
drop(manager);
}

#[test]
fn test_pool_builder_with_require_l1_data_fee_buffer() {
// Test that the builder method correctly sets the flag
let pool_builder = ScrollPoolBuilder::<ScrollPooledTransaction>::default();
assert!(!pool_builder.require_l1_data_fee_buffer);

let pool_builder = pool_builder.with_require_l1_data_fee_buffer(true);
assert!(pool_builder.require_l1_data_fee_buffer);

let pool_builder = pool_builder.with_require_l1_data_fee_buffer(false);
assert!(!pool_builder.require_l1_data_fee_buffer);
}

#[tokio::test]
async fn test_l1_data_fee_buffer_validation() {
// Test that the L1 data fee buffer feature correctly validates transactions:
// - With buffer enabled: rejects when balance < L2_cost + 2*L1_cost
// - With buffer disabled: accepts when balance >= L2_cost + 1*L1_cost
//
// Both scenarios use identical setup to prove only the buffer flag differs.

// Shared test constants
let signer: alloy_primitives::Address = Default::default();
let balance = U256::from(500_000_000_000_000u64); // 500 Twei
let gas_limit = 55_000u64;
let gas_price = 7u128;
let tx_input = Bytes::from(random_iter::<u8>().take(100).collect::<Vec<_>>());

// Helper to create a client with identical state
let client =
MockEthProvider::<ScrollPrimitives, _>::new().with_chain_spec(SCROLL_DEV.clone());
let hash = B256::random();
client.add_header(hash, Header::default());
client.add_block(hash, ScrollBlock::default());
// Balance covers L2_cost + 1*L1_cost but NOT L2_cost + 2*L1_cost
// With u32::MAX storage values, L1 cost is ~483 Twei.
// max L2_cost = 55,000 * 7 = 385,000 Wei.
client.add_account(signer, ExtendedAccount::new(0, balance));
client.add_account(
L1_GAS_PRICE_ORACLE_ADDRESS,
ExtendedAccount::new(0, U256::ZERO).extend_storage(
(0u8..8).map(|k| (B256::from(U256::from(k)), U256::from(u32::MAX))),
),
);

// Helper to create a transaction with identical parameters
let tx = ScrollTxEnvelope::Legacy(Signed::new_unchecked(
TxLegacy { gas_limit, gas_price, input: tx_input.clone(), ..Default::default() },
Signature::new(U256::ZERO, U256::ZERO, false),
Default::default(),
));
let tx = ScrollPooledTransaction::new(Recovered::new_unchecked(tx, signer), 200);

let handle = tokio::runtime::Handle::current();
let manager = TaskManager::new(handle);

// Test 1: With L1 data fee buffer ENABLED - should reject (requires 2x L1 cost)
let validator = TransactionValidationTaskExecutor::eth_builder(client.clone())
.no_eip4844()
.build_with_tasks(manager.executor(), NoopBlobStore::default())
.map(|validator| {
ScrollTransactionValidator::new(validator)
.require_l1_data_gas_fee(true)
.require_l1_data_fee_buffer(true)
});

let pool = ScrollTransactionPool::new(
validator,
CoinbaseTipOrdering::<ScrollPooledTransaction>::default(),
NoopBlobStore::default(),
PoolConfig::default(),
);

let err = pool.add_transaction(TransactionOrigin::Local, tx.clone()).await.unwrap_err();
assert!(matches!(
err.kind,
PoolErrorKind::InvalidTransaction(
InvalidPoolTransactionError::Consensus(InvalidTransactionError::InsufficientFunds(GotExpectedBoxed(expected)))
) if *expected == GotExpected{ got: balance, expected: U256::from(967347259159872u64) }
));

// Test 2: With L1 data fee buffer DISABLED - should accept (only requires 1x L1 cost)
let validator = TransactionValidationTaskExecutor::eth_builder(client)
.no_eip4844()
.build_with_tasks(manager.executor(), NoopBlobStore::default())
.map(|validator| {
ScrollTransactionValidator::new(validator)
.require_l1_data_gas_fee(true)
.require_l1_data_fee_buffer(false)
});

let pool = ScrollTransactionPool::new(
validator,
CoinbaseTipOrdering::<ScrollPooledTransaction>::default(),
NoopBlobStore::default(),
PoolConfig::default(),
);

let result = pool.add_transaction(TransactionOrigin::Local, tx).await;
assert!(
result.is_ok(),
"Expected transaction to be accepted without buffer, got: {result:?}"
);

drop(manager);
}
}
2 changes: 1 addition & 1 deletion crates/scroll/openvm-compat/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ scroll-alloy-consensus = { path = "../alloy/consensus", default-features = false
scroll-alloy-rpc-types = { path = "../alloy/rpc-types", default-features = false }

[patch.crates-io]
revm = { git = "https://github.com/scroll-tech/revm", tag = "scroll-v91" }
revm = { git = "https://github.com/scroll-tech/revm", tag = "scroll-v91.1" }
1 change: 1 addition & 0 deletions crates/scroll/txpool/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,4 @@ tracing.workspace = true
[dev-dependencies]
reth-scroll-chainspec.workspace = true
reth-provider = { workspace = true, features = ["test-utils"] }
scroll-alloy-evm.workspace = true
Loading
Loading