Skip to content

Commit d6c166c

Browse files
committed
kona: test non-zero SDM settlement against premium block
1 parent ca40d43 commit d6c166c

3 files changed

Lines changed: 72 additions & 2 deletions

File tree

rust/kona/crates/proof/executor/src/builder/core/tests.rs

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ use crate::{
33
test_utils::{execute_loaded_fixture, load_test_fixture, run_test_fixture},
44
};
55
use alloy_consensus::Header;
6-
use alloy_eips::Encodable2718;
7-
use op_alloy_consensus::{OpReceiptEnvelope, SDMGasEntry, build_post_exec_tx};
6+
use alloy_eips::eip2718::{Decodable2718, Encodable2718};
7+
use alloy_primitives::b256;
8+
use op_alloy_consensus::{OpReceiptEnvelope, OpTxEnvelope, SDMGasEntry, build_post_exec_tx};
89
use rstest::rstest;
910
use std::path::PathBuf;
1011

@@ -16,6 +17,11 @@ fn post_exec_fixture_path() -> PathBuf {
1617
PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("testdata/block-26207960.tar.gz")
1718
}
1819

20+
/// Premium-produced, Lagoon-active block with a non-empty `PostExec` refund payload.
21+
fn premium_sdm_fixture_path() -> PathBuf {
22+
PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("testdata/block-7-sdm-premium.tar.gz")
23+
}
24+
1925
fn fixture_block_number(parent_header: &Header) -> u64 {
2026
parent_header.number + 1
2127
}
@@ -139,6 +145,47 @@ async fn post_exec_valid_empty_payload_executes_without_state_or_gas_change() {
139145
assert_ne!(outcome.header.receipts_root, baseline.header.receipts_root);
140146
}
141147

148+
#[tokio::test]
149+
async fn post_exec_nonzero_payload_applies_refunds_and_matches_op_reth() {
150+
let loaded = load_test_fixture(premium_sdm_fixture_path()).await;
151+
let expected_block_hash = loaded.fixture.expected_block_hash;
152+
let timestamp = loaded.fixture.executing_payload.payload_attributes.timestamp;
153+
assert!(loaded.fixture.rollup_config.is_lagoon_active(timestamp));
154+
assert_eq!(
155+
expected_block_hash,
156+
b256!("a128f899f6bff19247a2656364c3e440de4bc1292347bf3b8f6f4f717765c0b2"),
157+
"fixture must remain pinned to the premium-produced block"
158+
);
159+
160+
let encoded = loaded
161+
.fixture
162+
.executing_payload
163+
.transactions
164+
.as_ref()
165+
.and_then(|transactions| transactions.last())
166+
.expect("premium fixture must contain transactions");
167+
let envelope =
168+
OpTxEnvelope::decode_2718_exact(encoded.as_ref()).expect("trailing tx must decode");
169+
let OpTxEnvelope::PostExec(post_exec) = envelope else {
170+
panic!("premium fixture must end in a PostExec transaction")
171+
};
172+
assert!(!post_exec.inner().payload.gas_refund_entries.is_empty());
173+
let refund_total: u64 =
174+
post_exec.inner().payload.gas_refund_entries.iter().map(|entry| entry.gas_refund).sum();
175+
assert!(refund_total > 0, "premium fixture refund must be non-zero");
176+
assert_eq!(refund_total, 630_000);
177+
178+
let outcome = execute_loaded_fixture(loaded, None).expect("premium SDM fixture executes");
179+
assert_eq!(outcome.header.hash(), expected_block_hash);
180+
assert_eq!(
181+
outcome.header.state_root,
182+
b256!("483d0a88146a80c0d5a592879f2d04f060b7515a1bad20f295fd4b601db20b93")
183+
);
184+
assert_eq!(outcome.execution_result.gas_used, 885_842);
185+
let evm_gas_used = 1_515_842;
186+
assert_eq!(outcome.execution_result.gas_used, evm_gas_used - refund_total);
187+
}
188+
142189
#[tokio::test]
143190
async fn post_exec_payload_rejects_deposit_target() {
144191
let mut loaded = load_test_fixture(post_exec_fixture_path()).await;
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Kona executor fixtures
2+
3+
## `block-7-sdm-premium.tar.gz`
4+
5+
This fixture pins a non-empty SDM/PostExec transition produced by
6+
`op-reth-premium`, not by the stock op-reth payload builder in this repository.
7+
8+
- Producer repository: `ethereum-optimism/optimism-premium`
9+
- Producer commit: `10c2d76` (`main`)
10+
- Producer's Optimism dependency: `dbaf2aed6a1ed52ca3bd3caba60bb896a7bf4ce1`
11+
- Producer path: premium subblocks payload builder
12+
- Capture harness: Optimism devstack at `ca40d43e51`
13+
- Ephemeral chain IDs: L1 `900`, L2 `901`
14+
- Fork schedule: Isthmus, Jovian, Karst, and Lagoon active at genesis
15+
- Block number: `7`
16+
- Block hash: `0xa128f899f6bff19247a2656364c3e440de4bc1292347bf3b8f6f4f717765c0b2`
17+
- State root: `0x483d0a88146a80c0d5a592879f2d04f060b7515a1bad20f295fd4b601db20b93`
18+
- Raw EVM gas: `1,515,842`; refund payload total: `630,000`; canonical gas: `885,842`
19+
20+
The premium sequencer built the block from the repeated-slot SDM workload. A
21+
stock op-reth verifier imported the exact block and supplied execution-witness
22+
and proof data to `execution-fixture`; the verifier did not build the block.
23+
The fixture contains a trailing `0x7D` with non-empty, non-zero refund entries.
Binary file not shown.

0 commit comments

Comments
 (0)