Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(kdn): Updates kdn with op-test-vectors Generic Typing #444

Merged
merged 5 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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