Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
94c0531
feat: feynman compression
frisitano Jun 23, 2025
c1f6bb2
Merge branch 'scroll' into feat/feynman-compression
frisitano Jun 23, 2025
2848551
update feynman compression
frisitano Jun 24, 2025
1b3e1e9
make no_std compat
frisitano Jun 25, 2025
730332e
lint
frisitano Jun 25, 2025
6a86b0d
disable unit book github workflow
frisitano Jun 25, 2025
8359a9f
Merge branch 'scroll' into feat/feynman-compression
frisitano Jun 25, 2025
6da4f89
update Cargo.lock
frisitano Jun 25, 2025
c01e6b9
migrate to zstd-safe
frisitano Jun 25, 2025
c7af59c
fix CI
frisitano Jun 25, 2025
bbec513
set zstd-safe default-features = false
frisitano Jun 25, 2025
f7df34c
lint
frisitano Jun 25, 2025
444f636
repoint scroll-revm dep
frisitano Jun 25, 2025
d73e95b
Merge branch 'scroll' into feat/feynman-compression
frisitano Jun 25, 2025
1ab4fb6
use U256 for compression ratio calculation
frisitano Jun 25, 2025
cbc6502
revert to using zstd library
frisitano Jun 26, 2025
0a1080f
cleanup
frisitano Jun 26, 2025
7fd42bb
disable unit book github workflow
frisitano Jun 26, 2025
0af3bc8
cleanup
frisitano Jun 26, 2025
5db5c3b
Merge branch 'scroll' into feat/feynman-compression
Thegaram Jun 26, 2025
094530a
fix naming
Thegaram Jun 26, 2025
89d2bf0
add comment
Thegaram Jun 26, 2025
f6ed73e
fix compression and add test cases
Thegaram Jun 26, 2025
44c1faa
renamings
Thegaram Jun 26, 2025
c4c493d
use exact zstd version
Thegaram Jun 26, 2025
bb61d77
update scroll-revm version
Thegaram Jun 26, 2025
50e514e
add missing comment
Thegaram Jun 26, 2025
29ed160
update tests
Thegaram Jun 26, 2025
acccef6
update tests
Thegaram Jun 26, 2025
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
1 change: 1 addition & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ jobs:
- features
- feature-propagation
- deny
- openvm
timeout-minutes: 30
steps:
- name: Decide whether the needed jobs succeeded or failed
Expand Down
3 changes: 2 additions & 1 deletion Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ revm-context = { git = "https://github.com/scroll-tech/revm", branch = "feat/ret
revm-context-interface = { git = "https://github.com/scroll-tech/revm", branch = "feat/reth-v74", default-features = false }
revm-database-interface = { git = "https://github.com/scroll-tech/revm", branch = "feat/reth-v74", default-features = false }
op-revm = { git = "https://github.com/scroll-tech/revm", branch = "feat/reth-v74", default-features = false }
revm-scroll = { git = "https://github.com/scroll-tech/scroll-revm", default-features = false }
revm-scroll = { git = "https://github.com/scroll-tech/scroll-revm", rev = "6ccb897197d7ed319463df487f428fce0a77b47f", default-features = false }
revm-inspectors = "0.23.0"

# eth
Expand Down
3 changes: 3 additions & 0 deletions crates/scroll/alloy/evm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ scroll-alloy-hardforks = { workspace = true, default-features = false }
# misc
auto_impl = { workspace = true, default-features = false }
serde = { workspace = true, default-features = false, features = ["derive"], optional = true }
zstd = { version = "=0.13.3", features = ["experimental"], default-features = false, optional = true }

[dev-dependencies]
alloy-hardforks.workspace = true
Expand All @@ -54,6 +55,7 @@ std = [
"reth-evm/std",
"reth-scroll-chainspec/std",
"reth-scroll-evm/std",
"zstd_compression",
]
serde = [
"dep:serde",
Expand All @@ -66,3 +68,4 @@ serde = [
"scroll-alloy-hardforks/serde",
"alloy-hardforks/serde",
]
zstd_compression = ["zstd"]
6 changes: 3 additions & 3 deletions crates/scroll/alloy/evm/src/block/feynman.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ use super::curie::L1_GAS_PRICE_ORACLE_ADDRESS;
const FEYNMAN_L1_GAS_PRICE_ORACLE_BYTECODE: Bytes = bytes!("608060405234801561000f575f80fd5b50600436106101a1575f3560e01c806384189161116100f3578063c63b9e2d11610093578063e88a60ad1161006e578063e88a60ad1461032e578063f2fde38b14610341578063f45e65d814610354578063fe5b04151461035d575f80fd5b8063c63b9e2d146102ff578063c91e514914610312578063de26c4a11461031b575f80fd5b8063944b247f116100ce578063944b247f146102be578063a911d77f146102d1578063aa5e9334146102d9578063bede39b5146102ec575f80fd5b806384189161146102785780638da5cb5b1461028157806393e59dc1146102ab575f80fd5b80633d0f963e1161015e5780636112d6db116101395780636112d6db1461024b5780636a5e67e514610254578063704655971461025d578063715018a614610270575f80fd5b80633d0f963e1461021c57806349948e0e1461022f578063519b4bd314610242575f80fd5b80630c18c162146101a557806313dad5be146101c157806323e524ac146101de5780633577afc5146101e757806339455d3a146101fc5780633b7656bb1461020f575b5f80fd5b6101ae60025481565b6040519081526020015b60405180910390f35b6008546101ce9060ff1681565b60405190151581526020016101b8565b6101ae60065481565b6101fa6101f5366004610c73565b610365565b005b6101fa61020a366004610c8a565b6103f7565b600b546101ce9060ff1681565b6101fa61022a366004610caa565b6104f4565b6101ae61023d366004610ceb565b610577565b6101ae60015481565b6101ae600a5481565b6101ae60075481565b6101fa61026b366004610c73565b6105b0565b6101fa61063e565b6101ae60055481565b5f54610293906001600160a01b031681565b6040516001600160a01b0390911681526020016101b8565b600454610293906001600160a01b031681565b6101fa6102cc366004610c73565b610672565b6101fa6106fe565b6101fa6102e7366004610c73565b61075a565b6101fa6102fa366004610c73565b6107f4565b6101fa61030d366004610c73565b6108b1565b6101ae60095481565b6101ae610329366004610ceb565b61094a565b6101fa61033c366004610c73565b610974565b6101fa61034f366004610caa565b610a00565b6101ae60035481565b6101fa610a8b565b5f546001600160a01b031633146103975760405162461bcd60e51b815260040161038e90610d96565b60405180910390fd5b621c9c388111156103bb57604051635742c80560e11b815260040160405180910390fd5b60028190556040518181527f32740b35c0ea213650f60d44366b4fb211c9033b50714e4a1d34e65d5beb9bb4906020015b60405180910390a150565b6004805460405163efc7840160e01b815233928101929092526001600160a01b03169063efc7840190602401602060405180830381865afa15801561043e573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906104629190610dcd565b61047f576040516326b3506d60e11b815260040160405180910390fd5b600182905560058190556040518281527f351fb23757bb5ea0546c85b7996ddd7155f96b939ebaa5ff7bc49c75f27f2c449060200160405180910390a16040518181527f9a14bfb5d18c4c3cf14cae19c23d7cf1bcede357ea40ca1f75cd49542c71c214906020015b60405180910390a15050565b5f546001600160a01b0316331461051d5760405162461bcd60e51b815260040161038e90610d96565b600480546001600160a01b038381166001600160a01b031983168117909355604080519190921680825260208201939093527f22d1c35fe072d2e42c3c8f9bd4a0d34aa84a0101d020a62517b33fdb3174e5f791016104e8565b600b545f9060ff16156105935761058d82610ae7565b92915050565b60085460ff16156105a75761058d82610b45565b61058d82610b81565b5f546001600160a01b031633146105d95760405162461bcd60e51b815260040161038e90610d96565b6105e9633b9aca006103e8610e00565b81111561060957604051631e44fdeb60e11b815260040160405180910390fd5b60038190556040518181527f3336cd9708eaf2769a0f0dc0679f30e80f15dcd88d1921b5a16858e8b85c591a906020016103ec565b5f546001600160a01b031633146106675760405162461bcd60e51b815260040161038e90610d96565b6106705f610bc4565b565b5f546001600160a01b0316331461069b5760405162461bcd60e51b815260040161038e90610d96565b6106a9633b9aca0080610e00565b8111156106c95760405163874f603160e01b815260040160405180910390fd5b60068190556040518181527f2ab3f5a4ebbcbf3c24f62f5454f52f10e1a8c9dcc5acac8f19199ce881a6a108906020016103ec565b5f546001600160a01b031633146107275760405162461bcd60e51b815260040161038e90610d96565b60085460ff161561074b576040516379f9c57560e01b815260040160405180910390fd5b6008805460ff19166001179055565b5f546001600160a01b031633146107835760405162461bcd60e51b815260040161038e90610d96565b633b9aca008110806107a1575061079e633b9aca0080610e00565b81115b156107bf5760405163d9b5dcdf60e01b815260040160405180910390fd5b60098190556040518181527fd50d3079c77df569cd58d55d4e5614bfe7066449009425d22bde8e75242f50bb906020016103ec565b6004805460405163efc7840160e01b815233928101929092526001600160a01b03169063efc7840190602401602060405180830381865afa15801561083b573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061085f9190610dcd565b61087c576040516326b3506d60e11b815260040160405180910390fd5b60018190556040518181527f351fb23757bb5ea0546c85b7996ddd7155f96b939ebaa5ff7bc49c75f27f2c44906020016103ec565b5f546001600160a01b031633146108da5760405162461bcd60e51b815260040161038e90610d96565b633b9aca008110806108f857506108f5633b9aca0080610e00565b81115b156109155760405162ae184360e01b815260040160405180910390fd5b600a8190556040518181527f8647cebb7e57360673a28415c0bed2f68c42a86c5035f1c9b2eda2b09509288a906020016103ec565b600b545f9060ff168061095f575060085460ff165b1561096b57505f919050565b61058d82610c13565b5f546001600160a01b0316331461099d5760405162461bcd60e51b815260040161038e90610d96565b6109ab633b9aca0080610e00565b8111156109cb5760405163f37ec21560e01b815260040160405180910390fd5b60078190556040518181527f6b332a036d8c3ead57dcb06c87243bd7a2aed015ddf2d0528c2501dae56331aa906020016103ec565b5f546001600160a01b03163314610a295760405162461bcd60e51b815260040161038e90610d96565b6001600160a01b038116610a7f5760405162461bcd60e51b815260206004820152601d60248201527f6e6577206f776e657220697320746865207a65726f2061646472657373000000604482015260640161038e565b610a8881610bc4565b50565b5f546001600160a01b03163314610ab45760405162461bcd60e51b815260040161038e90610d96565b600b5460ff1615610ad857604051631a7c228b60e21b815260040160405180910390fd5b600b805460ff19166001179055565b5f633b9aca0080600a548451600554600754610b039190610e00565b600154600654610b139190610e00565b610b1d9190610e17565b610b279190610e00565b610b319190610e00565b610b3b9190610e2a565b61058d9190610e2a565b5f633b9aca006005548351600754610b5d9190610e00565b610b679190610e00565b600154600654610b779190610e00565b610b3b9190610e17565b5f80610b8c83610c13565b90505f60015482610b9d9190610e00565b9050633b9aca0060035482610bb29190610e00565b610bbc9190610e2a565b949350505050565b5f80546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b80515f908190815b81811015610c6457848181518110610c3557610c35610e49565b01602001516001600160f81b0319165f03610c5557600483019250610c5c565b6010830192505b600101610c1b565b50506002540160400192915050565b5f60208284031215610c83575f80fd5b5035919050565b5f8060408385031215610c9b575f80fd5b50508035926020909101359150565b5f60208284031215610cba575f80fd5b81356001600160a01b0381168114610cd0575f80fd5b9392505050565b634e487b7160e01b5f52604160045260245ffd5b5f60208284031215610cfb575f80fd5b813567ffffffffffffffff80821115610d12575f80fd5b818401915084601f830112610d25575f80fd5b813581811115610d3757610d37610cd7565b604051601f8201601f19908116603f01168101908382118183101715610d5f57610d5f610cd7565b81604052828152876020848701011115610d77575f80fd5b826020860160208301375f928101602001929092525095945050505050565b60208082526017908201527f63616c6c6572206973206e6f7420746865206f776e6572000000000000000000604082015260600190565b5f60208284031215610ddd575f80fd5b81518015158114610cd0575f80fd5b634e487b7160e01b5f52601160045260245ffd5b808202811582820484141761058d5761058d610dec565b8082018082111561058d5761058d610dec565b5f82610e4457634e487b7160e01b5f52601260045260245ffd5b500490565b634e487b7160e01b5f52603260045260245ffdfea164736f6c6343000818000a");

/// L1 gas price oracle compression penalty threshold slot. Added in the Feynman fork.
const PENALTY_THRESHOLD_SLOT: U256 = U256::from_limbs([9, 0, 0, 0]);
pub const PENALTY_THRESHOLD_SLOT: U256 = U256::from_limbs([9, 0, 0, 0]);
/// L1 gas price oracle compression penalty factor slot. Added in the Feynman fork.
const PENALTY_FACTOR_SLOT: U256 = U256::from_limbs([10, 0, 0, 0]);
pub const PENALTY_FACTOR_SLOT: U256 = U256::from_limbs([10, 0, 0, 0]);
/// L1 gas price oracle "is Feynman" slot. Added in the Feynman fork.
const IS_FEYNMAN_SLOT: U256 = U256::from_limbs([11, 0, 0, 0]);
pub const IS_FEYNMAN_SLOT: U256 = U256::from_limbs([11, 0, 0, 0]);

/// The initial compression penalty threshold used by the oracle contract.
const INITIAL_PENALTY_THRESHOLD: U256 = U256::from_limbs([1_000_000_000, 0, 0, 0]);
Expand Down
53 changes: 50 additions & 3 deletions crates/scroll/alloy/evm/src/block/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pub mod curie;
mod feynman;
pub mod feynman;

pub use receipt_builder::{ReceiptBuilderCtx, ScrollReceiptBuilder};
mod receipt_builder;
Expand All @@ -10,7 +10,8 @@ use crate::{
feynman::apply_feynman_hard_fork,
},
system_caller::ScrollSystemCaller,
ScrollEvm, ScrollEvmFactory, ScrollTransactionIntoTxEnv,
FromTxWithCompressionRatio, ScrollEvm, ScrollEvmFactory, ScrollTransactionIntoTxEnv,
ToTxWithCompressionRatio,
};
use alloc::{boxed::Box, format, vec::Vec};

Expand Down Expand Up @@ -38,6 +39,9 @@ use revm_scroll::builder::ScrollContext;
use scroll_alloy_consensus::L1_MESSAGE_TRANSACTION_TYPE;
use scroll_alloy_hardforks::{ScrollHardfork, ScrollHardforks};

/// A cache for transaction compression ratios.
pub type ScrollTxCompressionRatios = Vec<U256>;

/// Context for Scroll Block Execution.
#[derive(Debug, Default, Clone)]
pub struct ScrollBlockExecutionCtx {
Expand Down Expand Up @@ -91,6 +95,44 @@ where
}
}

impl<'db, DB, E, R, Spec> ScrollBlockExecutor<E, R, Spec>
where
DB: Database + 'db,
E: EvmExt<
DB = &'db mut State<DB>,
Tx: FromRecoveredTx<R::Transaction>
+ FromTxWithEncoded<R::Transaction>
+ FromTxWithCompressionRatio<R::Transaction>,
>,
R: ScrollReceiptBuilder<Transaction: Transaction + Encodable2718, Receipt: TxReceipt>,
Spec: ScrollHardforks,
{
/// Executes all transactions in a block, applying pre and post execution changes. The provided
/// transaction compression ratios are expected to be in the same order as the
/// transactions.
pub fn execute_block_with_compression_cache(
mut self,
transactions: impl IntoIterator<
Item = impl ExecutableTx<Self>
+ ToTxWithCompressionRatio<<Self as BlockExecutor>::Transaction>,
>,
compression_ratios: ScrollTxCompressionRatios,
) -> Result<BlockExecutionResult<R::Receipt>, BlockExecutionError>
where
Self: Sized,
{
self.apply_pre_execution_changes()?;

for (tx, compression_ratio) in transactions.into_iter().zip(compression_ratios.into_iter())
{
let tx = tx.with_compression_ratio(compression_ratio);
self.execute_transaction(&tx)?;
}

self.apply_post_execution_changes()
}
}

impl<'db, DB, E, R, Spec> BlockExecutor for ScrollBlockExecutor<E, R, Spec>
where
DB: Database + 'db,
Expand Down Expand Up @@ -285,7 +327,12 @@ where
fn l1_fee(&self) -> Option<U256> {
let l1_block_info = &self.ctx().chain;
let transaction_rlp_bytes = self.ctx().tx.rlp_bytes.as_ref()?;
Some(l1_block_info.calculate_tx_l1_cost(transaction_rlp_bytes, self.ctx().cfg.spec))
let compression_ratio = self.ctx().tx.compression_ratio;
Some(l1_block_info.calculate_tx_l1_cost(
transaction_rlp_bytes,
self.ctx().cfg.spec,
compression_ratio,
))
}
}

Expand Down
15 changes: 12 additions & 3 deletions crates/scroll/alloy/evm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@

mod block;
pub use block::{
curie, EvmExt, ReceiptBuilderCtx, ScrollBlockExecutionCtx, ScrollBlockExecutor,
ScrollBlockExecutorFactory, ScrollReceiptBuilder,
curie, feynman, EvmExt, ReceiptBuilderCtx, ScrollBlockExecutionCtx, ScrollBlockExecutor,
ScrollBlockExecutorFactory, ScrollReceiptBuilder, ScrollTxCompressionRatios,
};

mod tx;
pub use tx::ScrollTransactionIntoTxEnv;
pub use tx::{
compute_compression_ratio, FromTxWithCompressionRatio, ScrollTransactionIntoTxEnv,
ToTxWithCompressionRatio, WithCompressionRatio,
};

mod system_caller;

Expand Down Expand Up @@ -42,6 +45,9 @@ use revm_scroll::{
ScrollSpecId, ScrollTransaction,
};

/// Re-export `TX_L1_FEE_PRECISION_U256` from `revm-scroll` for convenience.
pub use revm_scroll::l1block::TX_L1_FEE_PRECISION_U256;

/// Scroll EVM implementation.
#[allow(missing_debug_implementations)]
pub struct ScrollEvm<DB: Database, I, P = ScrollPrecompileProvider> {
Expand Down Expand Up @@ -148,6 +154,9 @@ where
authorization_list: Default::default(),
},
rlp_bytes: Some(Default::default()),

Choose a reason for hiding this comment

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

Not related to this PR, but could it cause any issues that tx.base.data and tx.rlp_bytes don't match?

Choose a reason for hiding this comment

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

// System transactions (similar to L1MessageTx) do not pay a rollup fee,
// so this field is not used; we just set it to the default value.
compression_ratio: Some(TX_L1_FEE_PRECISION_U256),
};

let mut gas_limit = tx.base.gas_limit;
Expand Down
Loading
Loading