Skip to content

Commit 8681d37

Browse files
committed
Merge branch 'main' into feat/bump-reth
2 parents ed9e074 + 6fdb2fb commit 8681d37

File tree

16 files changed

+580
-131
lines changed

16 files changed

+580
-131
lines changed

.github/workflows/sync.yaml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: sync
2+
3+
on:
4+
push:
5+
branches: [main]
6+
7+
concurrency:
8+
group: ${{ github.workflow }}-${{ github.ref }}
9+
cancel-in-progress: true
10+
11+
env:
12+
CARGO_TERM_COLOR: always
13+
14+
jobs:
15+
sync:
16+
runs-on: ubuntu-latest
17+
timeout-minutes: 25
18+
env:
19+
RUST_BACKTRACE: 1
20+
steps:
21+
- uses: actions/checkout@v4
22+
- uses: rui314/setup-mold@v1
23+
- uses: dtolnay/rust-toolchain@stable
24+
- uses: Swatinem/rust-cache@v2
25+
with:
26+
cache-on-failure: true
27+
- name: Run consolidation test
28+
env:
29+
ALCHEMY_KEY: ${{ secrets.ALCHEMY_KEY }}
30+
RUST_LOG: "sqlx=off,info,scroll::engine=debug"
31+
run: |
32+
cargo test --release -p rollup-node test_should_consolidate_to_block_15k

.github/workflows/test.yaml

Lines changed: 3 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -51,40 +51,7 @@ jobs:
5151
with:
5252
5353
- name: Run integration tests
54-
run: cargo nextest run --all-features --workspace --locked --no-tests=pass -E 'kind(test)'
55-
56-
sync:
57-
runs-on: ubuntu-latest
58-
timeout-minutes: 15
59-
env:
60-
RUST_BACKTRACE: 1
61-
steps:
62-
- uses: actions/checkout@v4
63-
- uses: rui314/setup-mold@v1
64-
- uses: dtolnay/rust-toolchain@stable
65-
- uses: Swatinem/rust-cache@v2
66-
with:
67-
cache-on-failure: true
68-
- uses: foundry-rs/foundry-toolchain@v1
69-
- name: Start rollup node
70-
env:
71-
ALCHEMY_KEY: ${{ secrets.ALCHEMY_KEY }}
72-
run: |
73-
cargo run --bin rollup-node --release -- \
74-
node --chain scroll-sepolia --datadir=./l2reth --disable-discovery \
75-
--http --http.addr=0.0.0.0 --http.port=8545 --http.api eth \
76-
--trusted-peers enode://29cee709c400533ae038a875b9ca975c8abef9eade956dcf3585e940acd5c0ae916968f514bd37d1278775aad1b7db30f7032a70202a87fd7365bd8de3c9f5fc@44.242.39.33:30303 \
77-
--log.stdout.format log-fmt -vvv \
78-
--l1.url "https://eth-sepolia.g.alchemy.com/v2/$ALCHEMY_KEY" --l1.cups 500 \
79-
--beacon.url https://eth-beacon-chain.drpc.org/rest/ --beacon.cups 100 --engine.en-sync-trigger 10000000000 \
80-
--engine.sync-at-startup=false --engine.always-process-payload-attributes-on-canonical-head &
81-
- name: Get hash for block 50000
8254
run: |
83-
echo "Waiting for block 50000..."
84-
while ! cast block 50000 --rpc-url http://localhost:8545 2>/dev/null | grep -q hash; do
85-
sleep 10
86-
done
87-
echo "Block 50000 found!"
88-
89-
EXPECTED_HASH="0x8333d8cd1274d49dcf9b130971d1b485a01f2a2604e73ea7caf9d721fbdf5859"
90-
cast block 50000 --rpc-url http://localhost:8545 | grep -q "$EXPECTED_HASH"
55+
cargo nextest run --all-features --workspace --locked \
56+
--no-tests=pass -E 'kind(test)' \
57+
-- --skip test_should_consolidate_to_block_15k

Cargo.lock

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

crates/derivation-pipeline/Cargo.toml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,12 @@ tracing.workspace = true
3535

3636
[dev-dependencies]
3737
async-trait.workspace = true
38+
alloy-primitives = { workspace = true, features = ["getrandom"] }
39+
criterion = { version = "0.6", features = ["async", "async_tokio"] }
3840
eyre.workspace = true
3941
scroll-db = { workspace = true, features = ["test-utils"] }
4042
scroll-codec = { workspace = true, features = ["test-utils"] }
41-
tokio = { workspace = true, features = ["macros"] }
43+
tokio = { workspace = true, features = ["macros", "rt-multi-thread"] }
4244

4345
[features]
4446
default = ["std"]
@@ -52,3 +54,7 @@ std = [
5254
"scroll-alloy-rpc-types-engine/std",
5355
"futures/std",
5456
]
57+
58+
[[bench]]
59+
name = "pipeline"
60+
harness = false
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
//! Benchmarks for the derivation pipeline.
2+
3+
#![allow(missing_docs)]
4+
5+
use std::sync::Arc;
6+
7+
use alloy_primitives::{address, b256, bytes, U256};
8+
use criterion::{criterion_group, criterion_main, Criterion};
9+
use futures::StreamExt;
10+
use rollup_node_primitives::{BatchCommitData, BatchInfo, L1MessageEnvelope};
11+
use rollup_node_providers::{test_utils::NoBlobProvider, DatabaseL1MessageProvider};
12+
use scroll_alloy_consensus::TxL1Message;
13+
use scroll_codec::decoding::test_utils::read_to_bytes;
14+
use scroll_db::{test_utils::setup_test_db, Database, DatabaseOperations};
15+
use scroll_derivation_pipeline::DerivationPipeline;
16+
use tokio::runtime::{Handle, Runtime};
17+
18+
async fn setup_pipeline(
19+
) -> DerivationPipeline<NoBlobProvider<DatabaseL1MessageProvider<Arc<Database>>>> {
20+
// load batch data in the db.
21+
let db = Arc::new(setup_test_db().await);
22+
let raw_calldata = read_to_bytes("./testdata/calldata_v0.bin").unwrap();
23+
let batch_data = BatchCommitData {
24+
hash: b256!("7f26edf8e3decbc1620b4d2ba5f010a6bdd10d6bb16430c4f458134e36ab3961"),
25+
index: 12,
26+
block_number: 18319648,
27+
block_timestamp: 1696935971,
28+
calldata: Arc::new(raw_calldata),
29+
blob_versioned_hash: None,
30+
finalized_block_number: None,
31+
};
32+
db.insert_batch(batch_data).await.unwrap();
33+
34+
// load messages in db.
35+
let l1_messages = vec![
36+
L1MessageEnvelope {
37+
l1_block_number: 717,
38+
l2_block_number: None,
39+
queue_hash: None,
40+
transaction: TxL1Message {
41+
queue_index: 33,
42+
gas_limit: 168000,
43+
to: address!("781e90f1c8Fc4611c9b7497C3B47F99Ef6969CbC"),
44+
value: U256::ZERO,
45+
sender: address!("7885BcBd5CeCEf1336b5300fb5186A12DDD8c478"),
46+
input: bytes!("8ef1332e0000000000000000000000007f2b8c31f88b6006c382775eea88297ec1e3e9050000000000000000000000006ea73e05adc79974b931123675ea8f78ffdacdf0000000000000000000000000000000000000000000000000006a94d74f430000000000000000000000000000000000000000000000000000000000000000002100000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000a4232e8748000000000000000000000000ca266224613396a0e8d4c2497dbc4f33dd6cdeff000000000000000000000000ca266224613396a0e8d4c2497dbc4f33dd6cdeff000000000000000000000000000000000000000000000000006a94d74f4300000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"),
47+
},
48+
},
49+
L1MessageEnvelope {
50+
l1_block_number: 717,
51+
l2_block_number: None,
52+
queue_hash: None,
53+
transaction: TxL1Message {
54+
queue_index: 34,
55+
gas_limit: 168000,
56+
to: address!("781e90f1c8fc4611c9b7497c3b47f99ef6969cbc"),
57+
value: U256::ZERO,
58+
sender: address!("7885BcBd5CeCEf1336b5300fb5186A12DDD8c478"),
59+
input: bytes!("8ef1332e0000000000000000000000007f2b8c31f88b6006c382775eea88297ec1e3e9050000000000000000000000006ea73e05adc79974b931123675ea8f78ffdacdf000000000000000000000000000000000000000000000000000470de4df820000000000000000000000000000000000000000000000000000000000000000002200000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000a4232e8748000000000000000000000000982fe4a7cbd74bb3422ebe46333c3e8046c12c7f000000000000000000000000982fe4a7cbd74bb3422ebe46333c3e8046c12c7f00000000000000000000000000000000000000000000000000470de4df8200000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"),
60+
},
61+
},
62+
];
63+
for message in l1_messages {
64+
db.insert_l1_message(message).await.unwrap();
65+
}
66+
67+
// construct the pipeline.
68+
let l1_messages_provider = DatabaseL1MessageProvider::new(db.clone(), 0);
69+
let mock_l1_provider = NoBlobProvider { l1_messages_provider };
70+
DerivationPipeline::new(mock_l1_provider, db)
71+
}
72+
73+
fn benchmark_pipeline_derivation(c: &mut Criterion) {
74+
let rt = Runtime::new().unwrap();
75+
76+
c.bench_function("pipeline_derive_1000_batches", |b| {
77+
b.to_async(&rt).iter_batched(
78+
|| {
79+
let (tx, rx) = std::sync::mpsc::channel();
80+
Handle::current().spawn(async move {
81+
// setup (not measured): create fresh pipeline with 1000 committed batches
82+
let mut pipeline = setup_pipeline().await;
83+
let batch_info = BatchInfo { index: 12, hash: Default::default() };
84+
85+
// commit 1000 batches.
86+
for _ in 0..1000 {
87+
pipeline.handle_batch_commit(batch_info, 0);
88+
}
89+
90+
tx.send(pipeline).unwrap();
91+
});
92+
rx.recv().unwrap()
93+
},
94+
|mut pipeline| async move {
95+
// measured work: derive 1000 batches.
96+
for _ in 0..1000 {
97+
let _ = pipeline.next().await.unwrap();
98+
}
99+
},
100+
criterion::BatchSize::SmallInput,
101+
)
102+
});
103+
}
104+
105+
criterion_group!(benches, benchmark_pipeline_derivation);
106+
criterion_main!(benches);

0 commit comments

Comments
 (0)