Commit bcfbee52 authored by clabby's avatar clabby Committed by GitHub

Merge pull request #6909 from ethereum-optimism/clabby/ctb/game-type-parity

feat(ctb): Preserve prod game type space
parents d2b14ac9 f791445c
...@@ -35,27 +35,19 @@ const ( ...@@ -35,27 +35,19 @@ const (
TraceTypeAlphabet TraceType = "alphabet" TraceTypeAlphabet TraceType = "alphabet"
TraceTypeCannon TraceType = "cannon" TraceTypeCannon TraceType = "cannon"
// Devnet game IDs // Mainnet games
DevnetGameIDAlphabet = uint8(0) CannonFaultGameID = 0
DevnetGameIDCannon = uint8(1)
// Mainnet game IDs // Devnet games
MainnetGameIDFault = uint8(0) AlphabetFaultGameID = 255
) )
var TraceTypes = []TraceType{TraceTypeAlphabet, TraceTypeCannon} var TraceTypes = []TraceType{TraceTypeAlphabet, TraceTypeCannon}
// GameIdToString maps game IDs to their string representation on a per-network basis. // GameIdToString maps game IDs to their string representation.
var GameIdToString = map[uint64]map[uint8]string{ var GameIdToString = map[uint8]string{
// Mainnet CannonFaultGameID: "Cannon",
1: { AlphabetFaultGameID: "Alphabet",
MainnetGameIDFault: "fault-cannon",
},
// Devnet
900: {
DevnetGameIDAlphabet: "fault-alphabet",
DevnetGameIDCannon: "fault-cannon",
},
} }
func (t TraceType) String() string { func (t TraceType) String() string {
......
...@@ -78,8 +78,8 @@ cast call $L2_OUTPUT_ORACLE_PROXY "getL2Output(uint256)" $PRIOR_INDEX ...@@ -78,8 +78,8 @@ cast call $L2_OUTPUT_ORACLE_PROXY "getL2Output(uint256)" $PRIOR_INDEX
echo "Getting the l2 output at index $INDEX" echo "Getting the l2 output at index $INDEX"
cast call $L2_OUTPUT_ORACLE_PROXY "getL2Output(uint256)" $INDEX cast call $L2_OUTPUT_ORACLE_PROXY "getL2Output(uint256)" $INDEX
# (Alphabet) Fault game type = 0 # (Alphabet) Fault game type = 255
GAME_TYPE=0 GAME_TYPE=255
# Root claim commits to the entire trace. # Root claim commits to the entire trace.
# Alphabet game claim construction: keccak256(abi.encode(trace_index, trace[trace_index])) # Alphabet game claim construction: keccak256(abi.encode(trace_index, trace[trace_index]))
......
...@@ -26,8 +26,8 @@ import ( ...@@ -26,8 +26,8 @@ import (
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )
const alphabetGameType uint8 = 0 const alphabetGameType uint8 = 255
const cannonGameType uint8 = 1 const cannonGameType uint8 = 0
const alphabetGameDepth = 4 const alphabetGameDepth = 4
const lastAlphabetTraceIndex = 1<<alphabetGameDepth - 1 const lastAlphabetTraceIndex = 1<<alphabetGameDepth - 1
......
...@@ -76,7 +76,8 @@ contract Deploy is Deployer { ...@@ -76,7 +76,8 @@ contract Deploy is Deployer {
initializeL2OutputOracle(); initializeL2OutputOracle();
initializeOptimismPortal(); initializeOptimismPortal();
setFaultGameImplementation(); setAlphabetFaultGameImplementation();
setCannonFaultGameImplementation();
transferProxyAdminOwnership(); transferProxyAdminOwnership();
transferDisputeGameFactoryOwnership(); transferDisputeGameFactoryOwnership();
...@@ -759,47 +760,89 @@ contract Deploy is Deployer { ...@@ -759,47 +760,89 @@ contract Deploy is Deployer {
} }
/// @notice Sets the implementation for the `FAULT` game type in the `DisputeGameFactory` /// @notice Sets the implementation for the `FAULT` game type in the `DisputeGameFactory`
function setFaultGameImplementation() public onlyDevnet broadcast { function setCannonFaultGameImplementation() public onlyDevnet broadcast {
// Create the absolute prestate dump DisputeGameFactory factory = DisputeGameFactory(mustGetAddress("DisputeGameFactoryProxy"));
string memory filePath = string.concat(vm.projectRoot(), "/../../op-program/bin/prestate-proof.json");
bytes32 mipsAbsolutePrestate; Claim mipsAbsolutePrestate;
string[] memory commands = new string[](3); if (block.chainid == Chains.LocalDevnet || block.chainid == Chains.GethDevnet) {
commands[0] = "bash"; // Fetch the absolute prestate dump
commands[1] = "-c"; string memory filePath = string.concat(vm.projectRoot(), "/../../op-program/bin/prestate-proof.json");
commands[2] = string.concat("[[ -f ", filePath, " ]] && echo \"present\""); string[] memory commands = new string[](3);
if (vm.ffi(commands).length == 0) { commands[0] = "bash";
revert("Cannon prestate dump not found, generate it with `make cannon-prestate` in the monorepo root."); commands[1] = "-c";
commands[2] = string.concat("[[ -f ", filePath, " ]] && echo \"present\"");
if (vm.ffi(commands).length == 0) {
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");
mipsAbsolutePrestate = Claim.wrap(abi.decode(vm.ffi(commands), (bytes32)));
console.log(
"[Cannon Dispute Game] Using devnet MIPS Absolute prestate: %s",
vm.toString(Claim.unwrap(mipsAbsolutePrestate))
);
} else {
console.log(
"[Cannon Dispute Game] Using absolute prestate from config: %s", cfg.faultGameAbsolutePrestate()
);
mipsAbsolutePrestate = Claim.wrap(bytes32(cfg.faultGameAbsolutePrestate()));
} }
commands[2] = string.concat("cat ", filePath, " | jq -r .pre");
mipsAbsolutePrestate = abi.decode(vm.ffi(commands), (bytes32));
console.log("Absolute prestate: %s", vm.toString(mipsAbsolutePrestate));
// Set the Cannon FaultDisputeGame implementation in the factory.
_setFaultGameImplementation(
factory, GameTypes.FAULT, mipsAbsolutePrestate, IBigStepper(mustGetAddress("Mips")), cfg.faultGameMaxDepth()
);
}
/// @notice Sets the implementation for the alphabet game type in the `DisputeGameFactory`
function setAlphabetFaultGameImplementation() public onlyDevnet broadcast {
DisputeGameFactory factory = DisputeGameFactory(mustGetAddress("DisputeGameFactoryProxy")); DisputeGameFactory factory = DisputeGameFactory(mustGetAddress("DisputeGameFactoryProxy"));
for (uint8 i; i < 2; i++) {
Claim absolutePrestate = // Set the Alphabet FaultDisputeGame implementation in the factory.
Claim.wrap(i == 0 ? bytes32(cfg.faultGameAbsolutePrestate()) : mipsAbsolutePrestate); Claim alphabetAbsolutePrestate = Claim.wrap(bytes32(cfg.faultGameAbsolutePrestate()));
IBigStepper faultVm = _setFaultGameImplementation(
IBigStepper(i == 0 ? address(new AlphabetVM(absolutePrestate)) : mustGetAddress("Mips")); factory,
GameType gameType = GameType.wrap(i); GameType.wrap(255),
if (address(factory.gameImpls(gameType)) == address(0)) { alphabetAbsolutePrestate,
factory.setImplementation( IBigStepper(new AlphabetVM(alphabetAbsolutePrestate)),
gameType, 4 // The max game depth of the alphabet game is always 4.
new FaultDisputeGame({ );
_gameType: gameType, }
_absolutePrestate: absolutePrestate,
_maxGameDepth: i == 0 ? 4 : cfg.faultGameMaxDepth(), // The max depth of the alphabet game is always 4 /// @notice Sets the implementation for the given fault game type in the `DisputeGameFactory`.
function _setFaultGameImplementation(
DisputeGameFactory _factory,
GameType _gameType,
Claim _absolutePrestate,
IBigStepper _faultVm,
uint256 _maxGameDepth
)
internal
{
if (address(_factory.gameImpls(_gameType)) == address(0)) {
_factory.setImplementation(
_gameType,
new FaultDisputeGame({
_gameType: _gameType,
_absolutePrestate: _absolutePrestate,
_maxGameDepth: _maxGameDepth,
_gameDuration: Duration.wrap(uint64(cfg.faultGameMaxDuration())), _gameDuration: Duration.wrap(uint64(cfg.faultGameMaxDuration())),
_vm: faultVm, _vm: _faultVm,
_l2oo: L2OutputOracle(mustGetAddress("L2OutputOracleProxy")), _l2oo: L2OutputOracle(mustGetAddress("L2OutputOracleProxy")),
_blockOracle: BlockOracle(mustGetAddress("BlockOracle")) _blockOracle: BlockOracle(mustGetAddress("BlockOracle"))
}) })
); );
console.log(
"DisputeGameFactoryProxy: set `FaultDisputeGame` implementation (Backend: %s | GameType: %s)", uint8 rawGameType = GameType.unwrap(_gameType);
i == 0 ? "AlphabetVM" : "MIPS", console.log(
vm.toString(i) "DisputeGameFactoryProxy: set `FaultDisputeGame` implementation (Backend: %s | GameType: %s)",
); rawGameType == 0 ? "Cannon" : "Alphabet",
} vm.toString(rawGameType)
);
} else {
console.log(
"[WARN] DisputeGameFactoryProxy: `FaultDisputeGame` implementation already set for game type: %s",
vm.toString(GameType.unwrap(_gameType))
);
} }
} }
} }
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