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

feat(contracts): add Kroma-specific contracts #1

Open
wants to merge 16 commits into
base: feat/apply-kroma-v2.1.0
Choose a base branch
from
Open
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
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,6 @@
[submodule "packages/contracts-bedrock/lib/solady-v0.0.245"]
path = packages/contracts-bedrock/lib/solady-v0.0.245
url = https://github.com/vectorized/solady
[submodule "packages/contracts-bedrock/lib/openzeppelin-contracts-upgradeable-v4.9.3"]
path = packages/contracts-bedrock/lib/openzeppelin-contracts-upgradeable-v4.9.3
url = https://github.com/Openzeppelin/openzeppelin-contracts-upgradeable
5 changes: 4 additions & 1 deletion packages/contracts-bedrock/foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ remappings = [
'safe-contracts/=lib/safe-contracts/contracts',
'kontrol-cheatcodes/=lib/kontrol-cheatcodes/src',
'gelato/=lib/automate/contracts',
'interfaces/=interfaces'
'interfaces/=interfaces',
# [Kroma: START]
'@openzeppelin/contracts-upgradeable-v4.9.3/=lib/openzeppelin-contracts-upgradeable-v4.9.3/contracts'
# [Kroma: END]
]

fs_permissions = [
Expand Down
301 changes: 301 additions & 0 deletions packages/contracts-bedrock/interfaces/L1/IAssetManager.sol

Large diffs are not rendered by default.

107 changes: 107 additions & 0 deletions packages/contracts-bedrock/interfaces/L1/IColosseum.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import { L2OutputOracle } from "src/L1/L2OutputOracle.sol";
import { ZKProofVerifier } from "src/L1/ZKProofVerifier.sol";
import { KromaTypes } from "src/libraries/KromaTypes.sol";

enum ChallengeStatus {
NONE,
CHALLENGER_TURN,
ASSERTER_TURN,
CHALLENGER_TIMEOUT,
ASSERTER_TIMEOUT,
READY_TO_PROVE
}

interface IColosseum {
error NotAllowedCaller();
error OnlyChallengerCanCancel();
error OutputAlreadyFinalized();
error OutputAlreadyDeleted();
error ImproperValidatorStatus();
error OutputNotDeleted();
error InvalidOutputGiven();
error InvalidAddressGiven();
error NotAllowedGenesisOutput();
error ImproperChallengeStatus();
error ImproperChallengeStatusToCancel();
error CreationPeriodPassed();
error L1Reorged();
error InvalidSegmentsLength();
error FirstSegmentMismatched();
error LastSegmentMatched();
error AlreadyVerifiedPublicInput();
error InvalidPublicInputHash();
error InvalidTurn();
error CannotCancelChallenge();

event Initialized(uint8 version);
event ChallengeCreated(
uint256 indexed outputIndex, address indexed asserter, address indexed challenger, uint256 timestamp
);
event Bisected(uint256 indexed outputIndex, address indexed challenger, uint8 turn, uint256 timestamp);
event ReadyToProve(uint256 indexed outputIndex, address indexed challenger);
event Proven(uint256 indexed outputIndex, address indexed challenger, uint256 timestamp);
event ChallengeDismissed(uint256 indexed outputIndex, address indexed challenger, uint256 timestamp);
event OutputForceDeleted(uint256 indexed outputIndex, address indexed asseter, uint256 timestamp);
event ChallengeCanceled(uint256 indexed outputIndex, address indexed challenger, uint256 timestamp);
event ChallengerTimedOut(uint256 indexed outputIndex, address indexed challenger, uint256 timestamp);

function L2_ORACLE() external view returns (L2OutputOracle);
function ZK_PROOF_VERIFIER() external view returns (ZKProofVerifier);
function CREATION_PERIOD_SECONDS() external view returns (uint256);
function BISECTION_TIMEOUT() external view returns (uint256);
function PROVING_TIMEOUT() external view returns (uint256);
function L2_ORACLE_SUBMISSION_INTERVAL() external view returns (uint256);
function SECURITY_COUNCIL() external view returns (address);
function version() external view returns (string memory);

function segmentsLengths(uint256) external view returns (uint256);
function challenges(
uint256,
address
)
external
view
returns (uint8 turn, uint64 timeoutAt, address asserter, address challenger, uint256 segSize, uint256 segStart);
function verifiedPublicInputs(bytes32) external view returns (bool);
function deletedOutputs(uint256)
external
view
returns (address submitter, bytes32 outputRoot, uint128 timestamp, uint128 l2BlockNumber);
function createChallenge(
uint256 _outputIndex,
bytes32 _l1BlockHash,
uint256 _l1BlockNumber,
bytes32[] calldata _segments
)
external;
function bisect(uint256 _outputIndex, address _challenger, uint256 _pos, bytes32[] calldata _segments) external;
function proveFaultWithZkVm(
uint256 _outputIndex,
uint256 _pos,
KromaTypes.ZkVmProof calldata _zkVmProof
)
external;
seolaoh marked this conversation as resolved.
Show resolved Hide resolved
function challengerTimeout(uint256 _outputIndex, address _challenger) external;
function cancelChallenge(uint256 _outputIndex) external;
function dismissChallenge(
uint256 _outputIndex,
address _challenger,
address _asserter,
bytes32 _outputRoot,
bytes32 _publicInputHash
)
external;
function forceDeleteOutput(uint256 _outputIndex) external;
function getChallenge(
uint256 _outputIndex,
address _challenger
)
external
view
returns (KromaTypes.Challenge memory);
function getStatus(uint256 _outputIndex, address _challenger) external view returns (ChallengeStatus);
function isInCreationPeriod(uint256 _outputIndex) external view returns (bool);
}
45 changes: 45 additions & 0 deletions packages/contracts-bedrock/interfaces/L1/IKromaPortal.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import { Types } from "src/libraries/Types.sol";

interface IKromaPortal {
event TransactionDeposited(address indexed from, address indexed to, uint256 indexed version, bytes opaqueData);
event WithdrawalFinalized(bytes32 indexed withdrawalHash, bool success);
event WithdrawalProven(bytes32 indexed withdrawalHash, address indexed from, address indexed to);
seolaoh marked this conversation as resolved.
Show resolved Hide resolved
event Paused(address account);
event Unpaused(address account);

receive() external payable;

function depositTransaction(
address _to,
uint256 _value,
uint64 _gasLimit,
bool _isCreation,
bytes memory _data
)
external
payable;
function finalizeWithdrawalTransaction(Types.WithdrawalTransaction memory _tx) external;
function finalizedWithdrawals(bytes32) external view returns (bool);
seolaoh marked this conversation as resolved.
Show resolved Hide resolved
function initialize(bool paused) external;
function isOutputFinalized(uint256 _l2OutputIndex) external view returns (bool);
function l2Sender() external view returns (address);
function paused() external view returns (bool paused_);
seolaoh marked this conversation as resolved.
Show resolved Hide resolved
function proveWithdrawalTransaction(
Types.WithdrawalTransaction memory _tx,
uint256 _l2OutputIndex,
Types.OutputRootProof memory _outputRootProof,
bytes[] memory _withdrawalProof
)
external;
function provenWithdrawals(bytes32)
external
view
returns (bytes32 outputRoot, uint128 timestamp, uint128 l2OutputIndex);
function version() external pure returns (string memory);
seolaoh marked this conversation as resolved.
Show resolved Hide resolved
function setGasPayingToken(address _token, uint8 _decimals, bytes32 _name, bytes32 _symbol) external;
function pause() external;
function unpause() external;
}
51 changes: 51 additions & 0 deletions packages/contracts-bedrock/interfaces/L1/IL2OutputOracle.sol
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import { KromaTypes } from "src/libraries/KromaTypes.sol";
import { Types } from "src/libraries/Types.sol";
import { IValidatorManager } from "interfaces/L1/IValidatorManager.sol";

interface IL2OutputOracle {
// TODO(sm-stack): Remove these Optimism L2OutputOracle methods after fixing tests and deployment process.
event Initialized(uint8 version);
event OutputProposed(
bytes32 indexed outputRoot, uint256 indexed l2OutputIndex, uint256 indexed l2BlockNumber, uint256 l1Timestamp
Expand Down Expand Up @@ -52,4 +55,52 @@ interface IL2OutputOracle {
function version() external view returns (string memory);

function __constructor__() external;

// TODO(sm-stack): Uncomment this after fixing compile errors at deploy and tests.
/*
event Initialized(uint8 version);
event OutputSubmitted(
bytes32 indexed outputRoot, uint256 indexed l2OutputIndex, uint256 indexed l2BlockNumber, uint256 l1Timestamp
);
event OutputReplaced(uint256 indexed outputIndex, address indexed newSubmitter, bytes32 newOutputRoot);

function VALIDATOR_MANAGER() external view returns (IValidatorManager);
function COLOSSEUM() external view returns (address);
function SUBMISSION_INTERVAL() external view returns (uint256);
function L2_BLOCK_TIME() external view returns (uint256);
function FINALIZATION_PERIOD_SECONDS() external view returns (uint256);

function initialize(uint256 _startingBlockNumber, uint256 _startingTimestamp) external;
function replaceL2Output(uint256 _l2OutputIndex, bytes32 _newOutputRoot, address _submitter) external;
function submitL2Output(
bytes32 _outputRoot,
uint256 _l2BlockNumber,
bytes32 _l1BlockHash,
uint256 _l1BlockNumber
)
external
payable;
function setNextFinalizeOutputIndex(uint256 _outputIndex) external;

function computeL2Timestamp(uint256 _l2BlockNumber) external view returns (uint256);
function finalizationPeriodSeconds() external view returns (uint256);
function getL2Output(uint256 _l2OutputIndex) external view returns (KromaTypes.CheckpointOutput memory);
function getL2OutputAfter(uint256 _l2BlockNumber) external view returns (KromaTypes.CheckpointOutput memory);
function getL2OutputIndexAfter(uint256 _l2BlockNumber) external view returns (uint256);
function getSubmitter(uint256 _outputIndex) external view returns (address);
function isFinalized(uint256 _outputIndex) external view returns (bool);
function finalizedAt(uint256 _outputIndex) external view returns (uint256);

function latestBlockNumber() external view returns (uint256);
function latestOutputIndex() external view returns (uint256);
function nextBlockNumber() external view returns (uint256);
function nextOutputIndex() external view returns (uint256);
function nextOutputMinL2Timestamp() external view returns (uint256);
function startingBlockNumber() external view returns (uint256);
function startingTimestamp() external view returns (uint256);
function nextFinalizeOutputIndex() external view returns (uint256);
function version() external view returns (string memory);

function __constructor__() external;
*/
}
Loading