Skip to content

Commit

Permalink
fix: regen fixture with rollup config
Browse files Browse the repository at this point in the history
  • Loading branch information
refcell committed Aug 16, 2024
1 parent 5cbe375 commit c1ecf03
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 3 deletions.
8 changes: 7 additions & 1 deletion bin/opd8n/src/cmd/from_l1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,13 @@ impl FromL1 {
)
.await?;

let fixture = DerivationFixture::new(fixture_blocks, payloads, configs, l2_block_infos);
let fixture = DerivationFixture::new(
Arc::unwrap_or_clone(cfg),
fixture_blocks,
payloads,
configs,
l2_block_infos,
);
info!(target: "from-l1", "Successfully built derivation test fixture");

// Write the derivation fixture to the specified output location.
Expand Down
8 changes: 7 additions & 1 deletion bin/opd8n/src/cmd/from_l2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,13 @@ impl FromL2 {
&mut blob_provider,
)
.await?;
let fixture = DerivationFixture::new(blocks, payloads, configs, l2_block_infos);
let fixture = DerivationFixture::new(
Arc::unwrap_or_clone(cfg),
blocks,
payloads,
configs,
l2_block_infos,
);
info!(target: TARGET, "Successfully built derivation test fixture");

// Write the derivation fixture to the specified output location.
Expand Down
11 changes: 10 additions & 1 deletion crates/op-test-vectors/src/derivation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@
use alloy_consensus::{Header, Receipt};
use alloy_primitives::Bytes;
use hashbrown::HashMap;
use kona_derive::types::{Blob, L2BlockInfo, L2PayloadAttributes, SystemConfig};
use kona_derive::types::{Blob, L2BlockInfo, L2PayloadAttributes, RollupConfig, SystemConfig};
use serde::{Deserialize, Serialize};

/// The derivation fixture is the top-level object that contains
/// everything needed to run a derivation test.
#[derive(Serialize, Deserialize, Clone, Debug, Default, Eq, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct DerivationFixture {
/// The rollup config.
pub rollup_config: RollupConfig,
/// A list of L1 Blocks to derive from.
pub l1_blocks: Vec<FixtureBlock>,
/// A map of L2 block number to l2 payload attributes.
Expand All @@ -24,12 +26,14 @@ pub struct DerivationFixture {
impl DerivationFixture {
/// Constructs a new [DerivationFixture] with the given L1 blocks and L2 Payload Attributes.
pub fn new(
rollup_config: RollupConfig,
l1_blocks: Vec<FixtureBlock>,
l2_payloads: HashMap<u64, L2PayloadAttributes>,
configs: HashMap<u64, SystemConfig>,
l2_infos: HashMap<u64, L2BlockInfo>,
) -> Self {
Self {
rollup_config,
l1_blocks,
l2_payloads,
l2_system_configs: configs,
Expand Down Expand Up @@ -334,11 +338,16 @@ mod tests {
infos
}

fn ref_rollup_config() -> RollupConfig {
RollupConfig::default()
}

#[test]
fn test_derivation_fixture() {
let fixture_str = include_str!("./testdata/derivation_fixture.json");
let fixture: DerivationFixture = serde_json::from_str(fixture_str).unwrap();
let expected = DerivationFixture {
rollup_config: ref_rollup_config(),
l1_blocks: ref_blocks(),
l2_payloads: ref_payload_attributes(),
l2_system_configs: ref_system_configs(),
Expand Down
27 changes: 27 additions & 0 deletions crates/op-test-vectors/src/testdata/derivation_fixture.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,31 @@
{
"rollupConfig": {
"genesis": {
"l1": {
"hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"number": 0
},
"l2": {
"hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"number": 0
},
"l2_time": 0
},
"block_time": 0,
"max_sequencer_drift": 0,
"seq_window_size": 0,
"channel_timeout": 0,
"l1_chain_id": 0,
"l2_chain_id": 0,
"base_fee_params": {
"max_change_denominator": 50,
"elasticity_multiplier": 6
},
"batch_inbox_address": "0x0000000000000000000000000000000000000000",
"deposit_contract_address": "0x0000000000000000000000000000000000000000",
"l1_system_config_address": "0x0000000000000000000000000000000000000000",
"protocol_versions_address": "0x0000000000000000000000000000000000000000"
},
"l2Payloads": {
"1": {
"timestamp": 1722550777,
Expand Down
46 changes: 46 additions & 0 deletions fixtures/derivation/Block123690000.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,50 @@
{
"rollupConfig": {
"genesis": {
"l1": {
"hash": "0x438335a20d98863a4c0c97999eb2481921ccd28553eac6f913af7c12aec04108",
"number": 17422590
},
"l2": {
"hash": "0xdbf6a80fef073de06add9b0d14026d6e5a86c85f6d102c36d3d8e9cf89c2afd3",
"number": 105235063
},
"l2_time": 1686068903,
"extra_data": null,
"system_config": {
"batcherAddress": "0x6887246668a3b87f54deb3b94ba47a6f63f32985",
"overhead": "0xbc",
"scalar": "0xa6fe0",
"gasLimit": 30000000,
"baseFeeScalar": null,
"blobBaseFeeScalar": null
}
},
"block_time": 2,
"max_sequencer_drift": 600,
"seq_window_size": 3600,
"channel_timeout": 300,
"l1_chain_id": 1,
"l2_chain_id": 10,
"base_fee_params": {
"max_change_denominator": "0x32",
"elasticity_multiplier": "0x6"
},
"canyon_base_fee_params": {
"max_change_denominator": "0xfa",
"elasticity_multiplier": "0x6"
},
"regolith_time": 0,
"canyon_time": 1704992401,
"delta_time": 1708560000,
"ecotone_time": 1710374401,
"fjord_time": 1720627201,
"batch_inbox_address": "0xff00000000000000000000000000000000000010",
"deposit_contract_address": "0xbeb5fc579115071764c7423a4f12edde41f106ed",
"l1_system_config_address": "0x229047fed2591dbec1ef1118d64f7af3db9eb290",
"protocol_versions_address": "0x8062abc286f5e7d9428a0ccb9abd71e50d93b935",
"superchain_config_address": "0x95703e0982140d16f8eba6d158fccede42f04a4c"
},
"l1Blocks": [
{
"header": {
Expand Down

0 comments on commit c1ecf03

Please sign in to comment.