Skip to content

Commit

Permalink
Scaffold out FaultDisputeGame trait
Browse files Browse the repository at this point in the history
  • Loading branch information
clabby committed Sep 9, 2023
1 parent 42d0bb5 commit 9437298
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
11 changes: 10 additions & 1 deletion crates/primitives/src/fault/traits.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
//! This module holds traits related to the FaultDisputeGame
//! This module holds traits related to the [FaultDisputeGame]

use crate::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> {
/* todo */
}

/// The [Position] trait defines the interface of a generalized index within a binary tree.
/// A "Generalized Index" is calculated as `2^{depth} + index_at_depth`.
Expand Down
23 changes: 20 additions & 3 deletions crates/primitives/src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,20 @@ use alloy_primitives::Bytes;
/// The [DisputeGame] trait is the highest level trait in the library, describing
/// a simple primitive dispute. It has several key properties:
///
/// - It houses
pub trait DisputeGame {
/// - It houses a root [Claim], a 32 byte commitment, which is the claim being
/// disputed.
/// - It has a [GameType], which indicates the type of dispute game being played.
/// - It has a [GameStatus], which indicates the current status of the dispute.
/// - It has a method to resolve the dispute, which returns the [GameStatus]
/// after resolution. The resolution mechanism can be anything - a fault proof,
/// a validity proof, a multisig, etc. It is up to the implementation of the
/// dispute game to determine the resolution mechanism.
///
/// TODO: This trait should be generic over the backend that the game is being played on,
/// 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> {
/// Returns the root claim of the dispute game. The root claim is a 32 byte
/// commitment to what is being disputed.
///
Expand All @@ -31,11 +43,16 @@ pub trait DisputeGame {
/// data is generic and it is up to the implementation of the game to
/// determine its decoding.
fn extra_data(&self) -> Bytes;

/// Resolves the dispute game, returning the [GameStatus] after resolution.
fn resolve(&self) -> GameStatus;
}

/// The [DisputeAgent] trait describes the base functionality of a dispute agent
/// for any given [DisputeGame]. It serves as the highest level agent trait, and
/// only enforces functionality that is common to all dispute agents.
///
/// All other agent traits should be subtraits of the [DisputeAgent].
pub trait DisputeAgent<DG: DisputeGame> {}
pub trait DisputeAgent<BE, DG: DisputeGame<BE>> {
/* todo */
}

0 comments on commit 9437298

Please sign in to comment.