Skip to content

Commit

Permalink
Migrate fault crate
Browse files Browse the repository at this point in the history
  • Loading branch information
clabby committed Sep 9, 2023
1 parent 9437298 commit c15b203
Show file tree
Hide file tree
Showing 11 changed files with 66 additions and 55 deletions.
54 changes: 9 additions & 45 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[workspace]
resolver = "2"
members = ["crates/primitives"]
members = ["crates/*"]

[workspace.package]
edition = "2021"
Expand Down
31 changes: 30 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,35 @@

# `durin`[![ci](https://github.com/anton-rs/durin/actions/workflows/ci.yaml/badge.svg?label=ci)](https://github.com/anton-rs/durin/actions/workflows/ci.yaml) ![license](https://img.shields.io/badge/License-MIT-green.svg?label=license)

A framework for building agents that participate in the [OP Stack][op-stack]'s dispute protocol.
A framework for building solvers for the [OP Stack][op-stack]'s dispute protocol.

## Overview

* [`durin-primitives`](./crates/primitives) - Contains primitive types and traits used by other solvers within `durin` as well as agents utilizing the solvers.
* [`durin-fault`](./crates/fault) - Contains an implementation of a solver for Optimism's `FaultDisputeGame`.

## What's a Solver?

The OP Stack contains a dispute protocol that allows developers to implement `Dispute Game`s, simple primitives that
allow the creation of a `Claim`, a 32-byte commitment to a piece of information, and a method to resolve this `Claim`
to `true` or `false`.

A `Dispute Game` has many possible implementations - for Optimism's purposes, the primary usecase for such a game is
to dispute claims about the state of an OP Stack chain on L1. The solution for this was the `FaultDisputeGame`, an
implementation of a `Dispute Game` that allows participants to bisect an instruction trace to find the exact instruction
that they and their opponent diverge, and execute a single instruction on-chain via an emulated VM (such as MIPS for
[Cannon][cannon] or RISC-V for [Asterisc][asterisc]) to prove their opponent wrong.

This is only one possible implementation of a `Dispute Game` - the OP Stack's dispute protocol allows for arbitrary
implementations of this primitive. The `durin` framework allows developers to create solvers for their own
implementation of a `Dispute Game` and use them within simulations, challenge agents, testing, and more.

## Creating a Solver

*todo*

<!-- LINKS -->
[op-stack]: https://github.com/ethereum-optimism/optimism
[cannon]: https://github.com/ethereum-optimism/optimism/tree/develop/cannon
[asterisc]: https://github.com/protolambda/asterisc
[galadriel]: https://github.com/anton-rs/galadriel
14 changes: 14 additions & 0 deletions crates/fault/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[package]
name = "durin-fault"
description = "Game solver for the OP Stack's FaultDisputeGame"
authors = ["clabby"]

version.workspace = true

[dependencies]
# Internal
durin-primitives = { path = "../primitives" }

# External
alloy-primitives = { git = "https://github.com/alloy-rs/core.git" }
anyhow = "1.0.75"
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
//! The fault module contains types and traits related to the FaultDisputeGame.

extern crate durin_primitives;

mod position;
mod traits;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! The position module holds the [Position] trait and its implementations.

use crate::Position;
use crate::prelude::Position;

/// Computes a generalized index from a depth and index at depth.
///
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
//! This module holds traits related to the [FaultDisputeGame]

use crate::DisputeGame;
use durin_primitives::DisputeGame;

/// A [FaultDisputeGame] is a [DisputeGame] that is played over a [FaultVM] backend. This
/// trait extends the [DisputeGame] trait with functionality that is specific to the
/// fault [crate::dispute_game::GameType] variants.
pub trait FaultDisputeGame<BE>: DisputeGame<BE> {
pub trait FaultDisputeGame: DisputeGame {
/* todo */
}

Expand Down
1 change: 0 additions & 1 deletion crates/primitives/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,3 @@ version.workspace = true
[dependencies]
alloy-primitives = { git = "https://github.com/alloy-rs/core.git" }
anyhow = "1.0.75"
tracing = "0.1.37"
3 changes: 3 additions & 0 deletions crates/primitives/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
`durin-primitives`

This crate contains primitive types and traits used by other solvers within `durin`.
4 changes: 2 additions & 2 deletions crates/primitives/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ pub use dispute_game::{Claim, GameStatus, GameType};
mod traits;
pub use traits::{DisputeAgent, DisputeGame};

mod fault;
pub use fault::prelude::*;
// Re-export alloy primitives
pub use alloy_primitives::*;
4 changes: 2 additions & 2 deletions crates/primitives/src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use alloy_primitives::Bytes;
/// i.e. onchain vs. local vs. arbiter, etc. We'll need another trait that describes
/// the generic interaction with the backend for a [DisputeGame], and another for
/// a [crate::FaultDisputeGame].
pub trait DisputeGame<BE> {
pub trait DisputeGame {
/// Returns the root claim of the dispute game. The root claim is a 32 byte
/// commitment to what is being disputed.
///
Expand Down Expand Up @@ -53,6 +53,6 @@ pub trait DisputeGame<BE> {
/// only enforces functionality that is common to all dispute agents.
///
/// All other agent traits should be subtraits of the [DisputeAgent].
pub trait DisputeAgent<BE, DG: DisputeGame<BE>> {
pub trait DisputeAgent<DG: DisputeGame> {
/* todo */
}

0 comments on commit c15b203

Please sign in to comment.