Commit 0962461a authored by refcell's avatar refcell

feat(ctb): Cannon Output Bisection Game Implementation

fix(ctb): Concrete game types

fix(ctb): Concrete game types
parent 2c1ccf85
...@@ -289,7 +289,9 @@ contract Deploy is Deployer { ...@@ -289,7 +289,9 @@ contract Deploy is Deployer {
deployImplementations(); deployImplementations();
initializeImplementations(); initializeImplementations();
setOutputBisectionImplementation(); setCannonOutputBisectionGameImplementation();
setAlphabetOutputBisectionGameImplementation();
setAlphabetFaultGameImplementation(); setAlphabetFaultGameImplementation();
setCannonFaultGameImplementation(); setCannonFaultGameImplementation();
...@@ -985,12 +987,9 @@ contract Deploy is Deployer { ...@@ -985,12 +987,9 @@ contract Deploy is Deployer {
} }
} }
/// @notice Sets the implementation for the `FAULT` game type in the `DisputeGameFactory` /// @notice Loads the mips absolute prestate from the prestate-proof for devnets otherwise
function setCannonFaultGameImplementation() public onlyDevnet broadcast { /// from the config.
console.log("Setting Cannon FaultDisputeGame implementation"); function loadMipsAbsolutePrestate() internal returns (Claim mipsAbsolutePrestate_) {
DisputeGameFactory factory = DisputeGameFactory(mustGetAddress("DisputeGameFactoryProxy"));
Claim mipsAbsolutePrestate;
if (block.chainid == Chains.LocalDevnet || block.chainid == Chains.GethDevnet) { if (block.chainid == Chains.LocalDevnet || block.chainid == Chains.GethDevnet) {
// Fetch the absolute prestate dump // Fetch the absolute prestate dump
string memory filePath = string.concat(vm.projectRoot(), "/../../op-program/bin/prestate-proof.json"); string memory filePath = string.concat(vm.projectRoot(), "/../../op-program/bin/prestate-proof.json");
...@@ -1002,53 +1001,77 @@ contract Deploy is Deployer { ...@@ -1002,53 +1001,77 @@ contract Deploy is Deployer {
revert("Cannon prestate dump not found, generate it with `make cannon-prestate` in the monorepo root."); revert("Cannon prestate dump not found, generate it with `make cannon-prestate` in the monorepo root.");
} }
commands[2] = string.concat("cat ", filePath, " | jq -r .pre"); commands[2] = string.concat("cat ", filePath, " | jq -r .pre");
mipsAbsolutePrestate = Claim.wrap(abi.decode(vm.ffi(commands), (bytes32))); mipsAbsolutePrestate_ = Claim.wrap(abi.decode(vm.ffi(commands), (bytes32)));
console.log( console.log(
"[Cannon Dispute Game] Using devnet MIPS Absolute prestate: %s", "[Cannon Dispute Game] Using devnet MIPS Absolute prestate: %s",
vm.toString(Claim.unwrap(mipsAbsolutePrestate)) vm.toString(Claim.unwrap(mipsAbsolutePrestate_))
); );
} else { } else {
console.log( console.log(
"[Cannon Dispute Game] Using absolute prestate from config: %s", cfg.faultGameAbsolutePrestate() "[Cannon Dispute Game] Using absolute prestate from config: %s", cfg.faultGameAbsolutePrestate()
); );
mipsAbsolutePrestate = Claim.wrap(bytes32(cfg.faultGameAbsolutePrestate())); mipsAbsolutePrestate_ = Claim.wrap(bytes32(cfg.faultGameAbsolutePrestate()));
} }
}
/// @notice Sets the implementation for the `FAULT` game type in the `DisputeGameFactory`
function setCannonFaultGameImplementation() public onlyDevnet broadcast {
console.log("Setting Cannon FaultDisputeGame implementation");
DisputeGameFactory factory = DisputeGameFactory(mustGetAddress("DisputeGameFactoryProxy"));
// Set the Cannon FaultDisputeGame implementation in the factory. // Set the Cannon FaultDisputeGame implementation in the factory.
_setFaultGameImplementation( _setFaultGameImplementation({
factory, GameTypes.FAULT, mipsAbsolutePrestate, IBigStepper(mustGetAddress("Mips")), cfg.faultGameMaxDepth() _factory: factory,
); _gameType: GameTypes.FAULT,
_absolutePrestate: loadMipsAbsolutePrestate(),
_faultVm: IBigStepper(mustGetAddress("Mips")),
_maxGameDepth: cfg.faultGameMaxDepth()
});
} }
/// @notice Sets the implementation for the output bisection game type (254) in the `DisputeGameFactory` /// @notice Sets the implementation for the `OUTPUT_CANNON` game type in the `DisputeGameFactory`
function setOutputBisectionImplementation() public onlyDevnet broadcast { function setCannonOutputBisectionGameImplementation() public onlyDevnet broadcast {
console.log("Setting OutputBisectionGame implementation"); console.log("Setting Cannon OutputBisectionGame implementation");
DisputeGameFactory factory = DisputeGameFactory(mustGetAddress("DisputeGameFactoryProxy"));
_setFaultGameImplementation({
_factory: factory,
_gameType: GameTypes.OUTPUT_CANNON,
_absolutePrestate: loadMipsAbsolutePrestate(),
_faultVm: IBigStepper(mustGetAddress("Mips")),
_maxGameDepth: cfg.faultGameMaxDepth()
});
}
/// @notice Sets the implementation for the `OUTPUT_ALPHABET` game type in the `DisputeGameFactory`
function setAlphabetOutputBisectionGameImplementation() public onlyDevnet broadcast {
console.log("Setting Alphabet OutputBisectionGame implementation");
DisputeGameFactory factory = DisputeGameFactory(mustGetAddress("DisputeGameFactoryProxy")); DisputeGameFactory factory = DisputeGameFactory(mustGetAddress("DisputeGameFactoryProxy"));
Claim outputAbsolutePrestate = Claim.wrap(bytes32(cfg.faultGameAbsolutePrestate())); Claim outputAbsolutePrestate = Claim.wrap(bytes32(cfg.faultGameAbsolutePrestate()));
_setFaultGameImplementation({ _setFaultGameImplementation({
_factory: factory, _factory: factory,
_gameType: GameType.wrap(254), _gameType: GameTypes.OUTPUT_ALPHABET,
_absolutePrestate: outputAbsolutePrestate, _absolutePrestate: outputAbsolutePrestate,
_faultVm: IBigStepper(new AlphabetVM(outputAbsolutePrestate)), _faultVm: IBigStepper(new AlphabetVM(outputAbsolutePrestate)),
_maxGameDepth: cfg.faultGameMaxDepth() _maxGameDepth: cfg.faultGameMaxDepth()
}); });
} }
/// @notice Sets the implementation for the alphabet game type in the `DisputeGameFactory` /// @notice Sets the implementation for the `ALPHABET` game type in the `DisputeGameFactory`
function setAlphabetFaultGameImplementation() public onlyDevnet broadcast { function setAlphabetFaultGameImplementation() public onlyDevnet broadcast {
console.log("Setting Alphabet FaultDisputeGame implementation"); console.log("Setting Alphabet FaultDisputeGame implementation");
DisputeGameFactory factory = DisputeGameFactory(mustGetAddress("DisputeGameFactoryProxy")); DisputeGameFactory factory = DisputeGameFactory(mustGetAddress("DisputeGameFactoryProxy"));
// Set the Alphabet FaultDisputeGame implementation in the factory. // Set the Alphabet FaultDisputeGame implementation in the factory.
Claim alphabetAbsolutePrestate = Claim.wrap(bytes32(cfg.faultGameAbsolutePrestate())); Claim alphabetAbsolutePrestate = Claim.wrap(bytes32(cfg.faultGameAbsolutePrestate()));
_setFaultGameImplementation( _setFaultGameImplementation({
factory, _factory: factory,
GameType.wrap(255), _gameType: GameTypes.ALPHABET,
alphabetAbsolutePrestate, _absolutePrestate: alphabetAbsolutePrestate,
IBigStepper(new AlphabetVM(alphabetAbsolutePrestate)), _faultVm: IBigStepper(new AlphabetVM(alphabetAbsolutePrestate)),
4 // The max game depth of the alphabet game is always 4. _maxGameDepth: 4 // The max game depth of the alphabet game is always 4.
); });
} }
/// @notice Sets the implementation for the given fault game type in the `DisputeGameFactory`. /// @notice Sets the implementation for the given fault game type in the `DisputeGameFactory`.
...@@ -1070,7 +1093,10 @@ contract Deploy is Deployer { ...@@ -1070,7 +1093,10 @@ contract Deploy is Deployer {
} }
string memory deployed; string memory deployed;
if (GameType.unwrap(_gameType) == 254) { if (
GameType.unwrap(_gameType) == GameType.unwrap(GameTypes.OUTPUT_ALPHABET)
|| GameType.unwrap(_gameType) == GameType.unwrap(GameTypes.OUTPUT_CANNON)
) {
deployed = "OutputBisectionGame"; deployed = "OutputBisectionGame";
_factory.setImplementation( _factory.setImplementation(
_gameType, _gameType,
...@@ -1104,6 +1130,8 @@ contract Deploy is Deployer { ...@@ -1104,6 +1130,8 @@ contract Deploy is Deployer {
string memory gameTypeString; string memory gameTypeString;
if (rawGameType == 0) { if (rawGameType == 0) {
gameTypeString = "Cannon"; gameTypeString = "Cannon";
} else if (rawGameType == 253) {
gameTypeString = "OutputBisectionCannon";
} else if (rawGameType == 254) { } else if (rawGameType == 254) {
gameTypeString = "OutputBisectionAlphabet"; gameTypeString = "OutputBisectionAlphabet";
} else if (rawGameType == 255) { } else if (rawGameType == 255) {
......
...@@ -87,6 +87,17 @@ library GameTypes { ...@@ -87,6 +87,17 @@ library GameTypes {
/// @dev The game will use a `IDisputeGame` implementation that utilizes attestation proofs. /// @dev The game will use a `IDisputeGame` implementation that utilizes attestation proofs.
GameType internal constant ATTESTATION = GameType.wrap(2); GameType internal constant ATTESTATION = GameType.wrap(2);
/// @dev A dispute game type that performs output bisection and then uses the cannon vm.
GameType internal constant OUTPUT_CANNON = GameType.wrap(253);
/// @dev A dispute game type that performs output bisection and then uses an alphabet vm.
/// Note intended for production use.
GameType internal constant OUTPUT_ALPHABET = GameType.wrap(254);
/// @dev A dispute game type that uses an alphabet vm.
/// Note intended for production use.
GameType internal constant ALPHABET = GameType.wrap(255);
} }
/// @title VMStatuses /// @title VMStatuses
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment