Skip to content
Closed
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.24;

import { IKailuaTournament } from "interfaces/dispute/zk/IKailuaTournament.sol";
import { Claim, Duration, Hash, GameStatus, GameType, Timestamp } from "src/dispute/lib/Types.sol";

interface IKailuaGame is IKailuaTournament {
function GENESIS_TIME_STAMP() external view returns (uint64);
function L2_BLOCK_TIME() external view returns (uint64);
function MAX_CLOCK_DURATION() external view returns (Duration);
function duplicationCounter() external pure returns (uint64 duplicationCounter_);
function parentGameIndex() external pure returns (uint64 parentGameIndex_);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.24;

import { IOptimismPortal2 } from "interfaces/L1/IOptimismPortal2.sol";
import { Claim, Duration, GameStatus, GameType, Hash, Timestamp } from "src/dispute/lib/Types.sol";
import { IDisputeGame } from "interfaces/dispute/IDisputeGame.sol";
import { IDisputeGameFactory } from "interfaces/dispute/IDisputeGameFactory.sol";
import { IKailuaVerifier } from "interfaces/dispute/zk/IKailuaVerifier.sol";
import { ISemver } from "interfaces/universal/ISemver.sol";
import { IAnchorStateRegistry } from "interfaces/dispute/IAnchorStateRegistry.sol";

interface IKailuaTournament is IDisputeGame, ISemver {
/// @notice Denotes the proven status of the game
enum ProofStatus {
NONE,
FAULT,
VALIDITY
}

/// @notice Emitted when a proof is submitted.
event Proven(bytes32 indexed signature, ProofStatus indexed status);

function DISPUTE_GAME_FACTORY() external view returns (IDisputeGameFactory);
function GAME_TYPE() external view returns (GameType);
function KAILUA_TREASURY() external view returns (IKailuaTournament);
function KAILUA_VERIFIER() external view returns (IKailuaVerifier);
function OPTIMISM_PORTAL() external view returns (IOptimismPortal2);
function OUTPUT_BLOCK_SPAN() external view returns (uint64);
function PROPOSAL_BLOBS() external view returns (uint64);
function PROPOSAL_OUTPUT_COUNT() external view returns (uint64);
function anchorStateRegistry() external view returns (IAnchorStateRegistry registry_);
function appendChild() external;
function blobsHash() external view returns (bytes32 blobsHash_);
function childCount() external view returns (uint256 count_);
function children(uint256) external view returns (IKailuaTournament);
function contenderDuplicates(uint256) external view returns (uint64);
function contenderIndex() external view returns (uint64);
function gameIndex() external view returns (uint256);
function getChallengerDuration(uint64 asOfTimestamp) external view returns (Duration duration_);
function initialize() external payable;
function isViableSignature(bytes32 childSignature) external view returns (bool isViableSignature_);
function minCreationTime() external view returns (Timestamp minCreationTime_);
function opponentIndex() external view returns (uint64);
function parentGame() external view returns (IKailuaTournament parentGame_);
function proofStatus(bytes32) external view returns (ProofStatus);
function proposalBlobHashes(uint256) external view returns (Hash);
function proposer() external view returns (address proposer_);
function proveOutputFault(
address[2] memory prHs,
uint64[2] memory co,
bytes memory encodedSeal,
bytes32[2] memory ac,
uint256 proposedOutputFe,
bytes[][2] memory kzgCommitmentsProofs
)
external;
function proveTrailFault(
address payoutRecipient,
uint64[2] memory co,
uint256 proposedOutputFe,
bytes memory blobCommitment,
bytes memory kzgProof
)
external;
function proveValidity(
address payoutRecipient,
address l1HeadSource,
uint64 childIndex,
bytes memory encodedSeal
)
external;
function provenAt(bytes32) external view returns (Timestamp);
function prover(bytes32) external view returns (address);
function pruneChildren(uint256 stepLimit) external returns (IKailuaTournament);
function signature() external view returns (bytes32 signature_);
function validChildSignature() external view returns (bytes32);
function verifyIntermediateOutput(
uint64 outputNumber,
uint256 outputFe,
bytes memory blobCommitment,
bytes memory kzgProof
)
external
returns (bool success);
function version() external view returns (string memory);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.24;

import { IKailuaTournament } from "interfaces/dispute/zk/IKailuaTournament.sol";
import { Claim, Duration, GameStatus, GameType, Timestamp } from "src/dispute/lib/Types.sol";

interface IKailuaTreasury is IKailuaTournament {
/// @notice Emitted when the participation bond is updated
/// @param amount The new required bond amount
event BondUpdated(uint256 amount);

function ELIMINATION_SPLIT_DENOM() external view returns (uint256);
function ELIMINATION_SPLIT_PROVER_NUM() external view returns (uint256);
function ELIMINATION_SPLIT_WINNER_NUM() external view returns (uint256);
function L2_BLOCK_NUMBER() external view returns (uint64);
function ROOT_CLAIM() external view returns (Claim);
function assignVanguard(address _vanguard, Duration _vanguardAdvantage) external;
function claimEliminationRewards() external;
function claimProposerBond() external;
function eliminate(address _child, address prover) external;
function eliminationRewards(address) external view returns (uint256);
function eliminationRound(address) external view returns (uint256);
function isProposing() external view returns (bool);
function lastProposal(address) external view returns (IKailuaTournament);
function lastResolved() external view returns (address);
function paidBonds(address) external view returns (uint256);
function participationBond() external view returns (uint256);
function propose(Claim _rootClaim, bytes memory _extraData) external payable returns (IKailuaTournament tournament);
function proposerOf(address) external view returns (address);
function setParticipationBond(uint256 amount) external;
function treasuryAddress() external pure returns (IKailuaTreasury treasuryAddress_);
function updateLastResolved() external;
function vanguard() external view returns (address);
function vanguardAdvantage() external view returns (Duration);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.24;

import { IKailuaTournament } from "interfaces/dispute/zk/IKailuaTournament.sol";
import {
AlreadyEliminated,
BadTarget,
BondTransferFailed,
ClockNotExpired,
IncorrectBondAmount,
NoCreditToClaim,
NotProven,
ProvenFaulty
} from "src/dispute/lib/Errors.sol";
import { Duration } from "src/dispute/lib/Types.sol";
import { IRiscZeroVerifier } from "interfaces/dispute/zk/IRiscZeroVerifier.sol";
import { ISemver } from "interfaces/universal/ISemver.sol";

interface IKailuaVerifier is ISemver {
function FPVM_IMAGE_ID() external view returns (bytes32);
function PERMIT_DURATION() external view returns (Duration);
function RISC_ZERO_VERIFIER() external view returns (IRiscZeroVerifier);
function ROLLUP_CONFIG_HASH() external view returns (bytes32);
function acquireFaultProofPermit(
IKailuaTournament proposalParent,
bytes32 proposalSignature,
uint64 numExpiredPermits,
address payoutRecipient
)
external
payable
returns (uint256 totalPermitsIssued_);
function countExpiredPermits(
bytes32 proposalKey,
uint64 numExpiredPermits,
uint64 timestamp
)
external
view
returns (uint64, uint256, uint64);
function faultProofPermitBeneficiary(
IKailuaTournament proposalParent,
bytes32 proposalSignature
)
external
view
returns (address);
function faultProofPermitBond(address treasury) external view returns (uint256 bond);
function faultProofPermitKey(
IKailuaTournament proposalParent,
bytes32 proposalSignature
)
external
pure
returns (bytes32);
function faultProofPermitProvenAt(
IKailuaTournament proposalParent,
bytes32 proposalSignature
)
external
view
returns (uint64);
function faultProofPermits(
bytes32,
uint256
)
external
view
returns (uint256 aggregateCollateral, address recipient, uint64 timestamp, bool released);
function releaseFaultProofPermit(
IKailuaTournament proposalParent,
bytes32 proposalSignature,
uint64 numExpiredPermits,
uint64 permitIndex
)
external;
function verify(
address payoutRecipient,
bytes32 preconditionHash,
bytes32 l1Head,
bytes32 agreedL2OutputRoot,
bytes32 claimedL2OutputRoot,
uint64 claimedL2BlockNumber,
bytes memory encodedSeal
)
external
view;
function version() external view returns (string memory);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// Copyright 2025 RISC Zero, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// SPDX-License-Identifier: Apache-2.0

pragma solidity ^0.8.9;

/// @notice A receipt attesting to a claim using the RISC Zero proof system.
/// @dev A receipt contains two parts: a seal and a claim.
///
/// The seal is a zero-knowledge proof attesting to knowledge of a witness for the claim. The claim
/// is a set of public outputs, and for zkVM execution is the hash of a `ReceiptClaim` struct.
///
/// IMPORTANT: The `claimDigest` field must be a hash computed by the caller for verification to
/// have meaningful guarantees. Treat this similar to verifying an ECDSA signature, in that hashing
/// is a key operation in verification. The most common way to calculate this hash is to use the
/// `ReceiptClaimLib.ok(imageId, journalDigest).digest()` for successful executions.
struct Receipt {
bytes seal;
bytes32 claimDigest;
}

/// @notice Verifier interface for RISC Zero receipts of execution.
interface IRiscZeroVerifier {
/// @notice Verify that the given seal is a valid RISC Zero proof of execution with the
/// given image ID and journal digest. Reverts on failure.
/// @dev This method additionally ensures that the input hash is all-zeros (i.e. no
/// committed input), the exit code is (Halted, 0), and there are no assumptions (i.e. the
/// receipt is unconditional).
/// @param seal The encoded cryptographic proof (i.e. SNARK).
/// @param imageId The identifier for the guest program.
/// @param journalDigest The SHA-256 digest of the journal bytes.
function verify(bytes calldata seal, bytes32 imageId, bytes32 journalDigest) external view;

/// @notice Verify that the given receipt is a valid RISC Zero receipt, ensuring the `seal` is
/// valid a cryptographic proof of the execution with the given `claim`. Reverts on failure.
/// @param receipt The receipt to be verified.
function verifyIntegrity(Receipt calldata receipt) external view;
}
52 changes: 52 additions & 0 deletions packages/contracts-bedrock/src/dispute/lib/Errors.sol
Original file line number Diff line number Diff line change
Expand Up @@ -180,3 +180,55 @@ error InvalidProposalStatus();

/// @notice Thrown when the game is initialized by an incorrect factory.
error IncorrectDisputeGameFactory();

////////////////////////////////////////////////////////////////
// `Kailua` Errors //
////////////////////////////////////////////////////////////////

/// @notice Thrown when a blacklisted address attempts to interact with the game.
error Blacklisted(address source, address expected);

/// @notice Thrown when a child from an unknown source appends itself to a tournament
error UnknownGame();

/// @notice Thrown when eliminating an already removed child
error AlreadyEliminated();

/// @notice Thrown when a proof is submitted for an already proven game
error AlreadyProven();

/// @notice Thrown when a resolution is attempted for an unproven claim
error NotProven();

/// @notice Thrown when resolving a faulty proposal
error ProvenFaulty();

/// @notice Thrown when pruning is attempted with no children
error NotProposed();

/// @notice Thrown when proving is attempted with two agreeing outputs
error NoConflict();

/// @notice Thrown when proposing before the minimum creation time
error ProposalGapRemaining(uint256 currentTime, uint256 minCreationTime);

/// @notice Thrown when a blob hash is missing
error BlobHashMissing(uint256 index, uint256 count);

/// @notice Occurs when the duplication counter is wrong
error InvalidDuplicationCounter();

/// @notice Occurs when the anchored game block number is different
/// @param anchored The L2 block number of the anchored game
/// @param initialized This game's l2 block number
error BlockNumberMismatch(uint256 anchored, uint256 initialized);

/// @notice Occurs when a proposer attempts to extend the chain before the vanguard
/// @param parentGame The address of the parent proposal being extended
error VanguardError(address parentGame);

/// @notice Thrown when a non-factory owner calls an owner-only function.
error NotFactoryOwner();

/// @notice Error for when a deposit or withdrawal is to a bad target.
error BadTarget();
Loading