Skip to content

Commit

Permalink
fix(kdn): Updates kdn with op-test-vectors Generic Typing (#444)
Browse files Browse the repository at this point in the history
* fix(kdn): Update with test vector types

* feat(ci): derivation fixture action

* feat(ci): derivation fixture action

* fix(ci): add just

* fix(kdn): doc comments
  • Loading branch information
refcell authored Aug 22, 2024
1 parent 4bdb187 commit 8812cf8
Show file tree
Hide file tree
Showing 10 changed files with 94 additions and 168 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/fixtures.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Test Fixtures

on:
pull_request:
push:
branches: main

env:
CARGO_TERM_COLOR: always

jobs:
derivation:
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Checkout sources
uses: actions/checkout@v4
with:
submodules: true
token: ${{ secrets.PAT_TOKEN }}
- name: Install Rust stable toolchain
uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
- uses: taiki-e/install-action@just
- name: Run kdn
run: just test-derivation
132 changes: 12 additions & 120 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions bin/kdn/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,4 @@ color-eyre = "0.6" # For op-test-vector dependency
clap = { version = "4", features = ["derive", "env"] }
op-test-vectors = { git = "https://github.com/ethereum-optimism/tests", branch = "main" }
include_directory = "0.1.1"
kona-derive = { path = "../../crates/derive", version = "0.0.2", features = ["online"] }
15 changes: 6 additions & 9 deletions bin/kdn/src/blobs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,19 @@
use anyhow::{anyhow, Result};
use async_trait::async_trait;
use op_test_vectors::{
derivation::DerivationFixture,
kona_derive::{
traits::BlobProvider,
types::{Blob, BlobProviderError, BlockInfo, IndexedBlobHash},
},
use kona_derive::{
traits::BlobProvider,
types::{Blob, BlobProviderError, BlockInfo, IndexedBlobHash},
};

/// A blob fixture provider.
#[derive(Debug, Clone)]
pub struct BlobFixtureProvider {
inner: DerivationFixture,
inner: crate::LocalDerivationFixture,
}

impl From<DerivationFixture> for BlobFixtureProvider {
fn from(inner: DerivationFixture) -> Self {
impl From<crate::LocalDerivationFixture> for BlobFixtureProvider {
fn from(inner: crate::LocalDerivationFixture) -> Self {
Self { inner }
}
}
Expand Down
9 changes: 4 additions & 5 deletions bin/kdn/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
use anyhow::{anyhow, Result};
use clap::{ArgAction, Parser};
use include_directory::{include_directory, Dir, DirEntry, File};
use op_test_vectors::derivation::DerivationFixture;
use tracing::{debug, error, info, trace, warn, Level};

static TEST_FIXTURES: Dir<'_> =
Expand Down Expand Up @@ -50,7 +49,7 @@ impl Cli {
}

/// Executes a given derivation test fixture.
pub async fn exec(&self, name: String, fixture: DerivationFixture) -> Result<()> {
pub async fn exec(&self, name: String, fixture: crate::LocalDerivationFixture) -> Result<()> {
info!(target: "exec", "Running test: {}", name);
let pipeline = crate::pipeline::new_runner_pipeline(fixture.clone()).await?;
match crate::runner::run(pipeline, fixture).await {
Expand All @@ -65,8 +64,8 @@ impl Cli {
}
}

/// Get [DerivationFixture]s to run.
pub fn get_fixtures(&self) -> Result<Vec<(String, DerivationFixture)>> {
/// Get [crate::LocalDerivationFixture]s to run.
pub fn get_fixtures(&self) -> Result<Vec<(String, crate::LocalDerivationFixture)>> {
// Get available derivation test fixtures
let available_tests = Self::get_tests()?;
trace!("Available tests: {:?}", available_tests);
Expand All @@ -82,7 +81,7 @@ impl Cli {
debug!("Parsing test fixture: {}", path);
Ok((
path.to_string(),
serde_json::from_str::<DerivationFixture>(fixture_str)
serde_json::from_str::<crate::LocalDerivationFixture>(fixture_str)
.map_err(|e| anyhow!(e))?,
))
})
Expand Down
11 changes: 11 additions & 0 deletions bin/kdn/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@
#![deny(unused_must_use, rust_2018_idioms)]
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]

use kona_derive::types::{Blob, L2BlockInfo, L2PayloadAttributes, RollupConfig, SystemConfig};

/// A local derivation fixture typed with `kona_derive` types.
pub type LocalDerivationFixture = op_test_vectors::derivation::DerivationFixture<
RollupConfig,
L2PayloadAttributes,
SystemConfig,
L2BlockInfo,
Blob,
>;

pub mod cli;
pub use cli::Cli;

Expand Down
Loading

0 comments on commit 8812cf8

Please sign in to comment.