Commit 65b163c1 authored by refcell's avatar refcell

fix(ctb): alphabet vm for output bisection

port alphabet changes to a new contract

bindings

fix: bindings
parent dac58779
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
"FaultDisputeGame", "FaultDisputeGame",
"OutputBisectionGame", "OutputBisectionGame",
"AlphabetVM", "AlphabetVM",
"AlphabetVM2",
"StandardBridge", "StandardBridge",
"CrossDomainMessenger", "CrossDomainMessenger",
"MIPS", "MIPS",
......
This diff is collapsed.
// Code generated - DO NOT EDIT.
// This file is a generated binding and any manual changes will be lost.
package bindings
import (
"encoding/json"
"github.com/ethereum-optimism/optimism/op-bindings/solc"
)
const AlphabetVM2StorageLayoutJSON = "{\"storage\":[{\"astId\":1000,\"contract\":\"test/mocks/AlphabetVM2.sol:AlphabetVM2\",\"label\":\"oracle\",\"offset\":0,\"slot\":\"0\",\"type\":\"t_contract(IPreimageOracle)1001\"}],\"types\":{\"t_contract(IPreimageOracle)1001\":{\"encoding\":\"inplace\",\"label\":\"contract IPreimageOracle\",\"numberOfBytes\":\"20\"}}}"
var AlphabetVM2StorageLayout = new(solc.StorageLayout)
var AlphabetVM2DeployedBin = "0x608060405234801561001057600080fd5b50600436106100365760003560e01c80637dc0d1d01461003b578063e14ced3214610085575b600080fd5b60005461005b9073ffffffffffffffffffffffffffffffffffffffff1681565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020015b60405180910390f35b6100986100933660046102d2565b6100a6565b60405190815260200161007c565b600080600060087f0000000000000000000000000000000000000000000000000000000000000000901b600889896040516100e2929190610346565b6040518091039020901b036101c7576000915061010187890189610356565b600080546040517f52f0f3ad000000000000000000000000000000000000000000000000000000008152600480820152602481018890526044810183905260206064820152608481019290925291925073ffffffffffffffffffffffffffffffffffffffff909116906352f0f3ad9060a4016020604051808303816000875af1158015610192573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101b6919061036f565b6101c090826103b7565b90506101e6565b6101d3878901896103cf565b9092509050816101e2816103f1565b9250505b816101f28260016103b7565b604080516020810193909352820152606001604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe081840301815291905280516020909101207effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f01000000000000000000000000000000000000000000000000000000000000001798975050505050505050565b60008083601f84011261029b57600080fd5b50813567ffffffffffffffff8111156102b357600080fd5b6020830191508360208285010111156102cb57600080fd5b9250929050565b6000806000806000606086880312156102ea57600080fd5b853567ffffffffffffffff8082111561030257600080fd5b61030e89838a01610289565b9097509550602088013591508082111561032757600080fd5b5061033488828901610289565b96999598509660400135949350505050565b8183823760009101908152919050565b60006020828403121561036857600080fd5b5035919050565b60006020828403121561038157600080fd5b5051919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600082198211156103ca576103ca610388565b500190565b600080604083850312156103e257600080fd5b50508035926020909101359150565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff820361042257610422610388565b506001019056fea164736f6c634300080f000a"
func init() {
if err := json.Unmarshal([]byte(AlphabetVM2StorageLayoutJSON), AlphabetVM2StorageLayout); err != nil {
panic(err)
}
layouts["AlphabetVM2"] = AlphabetVM2StorageLayout
deployedBytecodes["AlphabetVM2"] = AlphabetVM2DeployedBin
immutableReferences["AlphabetVM2"] = true
}
This diff is collapsed.
This diff is collapsed.
...@@ -43,6 +43,7 @@ import { Chains } from "scripts/Chains.sol"; ...@@ -43,6 +43,7 @@ import { Chains } from "scripts/Chains.sol";
import { IBigStepper } from "src/dispute/interfaces/IBigStepper.sol"; import { IBigStepper } from "src/dispute/interfaces/IBigStepper.sol";
import { IPreimageOracle } from "src/cannon/interfaces/IPreimageOracle.sol"; import { IPreimageOracle } from "src/cannon/interfaces/IPreimageOracle.sol";
import { AlphabetVM } from "test/mocks/AlphabetVM.sol"; import { AlphabetVM } from "test/mocks/AlphabetVM.sol";
import { AlphabetVM2 } from "test/mocks/AlphabetVM2.sol";
import "src/libraries/DisputeTypes.sol"; import "src/libraries/DisputeTypes.sol";
import { ChainAssertions } from "scripts/ChainAssertions.sol"; import { ChainAssertions } from "scripts/ChainAssertions.sol";
import { Types } from "scripts/Types.sol"; import { Types } from "scripts/Types.sol";
...@@ -1052,7 +1053,7 @@ contract Deploy is Deployer { ...@@ -1052,7 +1053,7 @@ contract Deploy is Deployer {
_factory: factory, _factory: factory,
_gameType: GameTypes.OUTPUT_ALPHABET, _gameType: GameTypes.OUTPUT_ALPHABET,
_absolutePrestate: outputAbsolutePrestate, _absolutePrestate: outputAbsolutePrestate,
_faultVm: IBigStepper(new AlphabetVM(outputAbsolutePrestate)), _faultVm: IBigStepper(new AlphabetVM2(outputAbsolutePrestate)),
_maxGameDepth: cfg.faultGameMaxDepth() _maxGameDepth: cfg.faultGameMaxDepth()
}); });
} }
......
...@@ -17,7 +17,7 @@ import { Types } from "src/libraries/Types.sol"; ...@@ -17,7 +17,7 @@ import { Types } from "src/libraries/Types.sol";
import { LibClock } from "src/dispute/lib/LibClock.sol"; import { LibClock } from "src/dispute/lib/LibClock.sol";
import { LibPosition } from "src/dispute/lib/LibPosition.sol"; import { LibPosition } from "src/dispute/lib/LibPosition.sol";
import { IBigStepper, IPreimageOracle } from "src/dispute/interfaces/IBigStepper.sol"; import { IBigStepper, IPreimageOracle } from "src/dispute/interfaces/IBigStepper.sol";
import { AlphabetVM } from "test/mocks/AlphabetVM.sol"; import { AlphabetVM2 } from "test/mocks/AlphabetVM2.sol";
contract OutputBisectionGame_Init is DisputeGameFactory_Init { contract OutputBisectionGame_Init is DisputeGameFactory_Init {
/// @dev The type of the game being tested. /// @dev The type of the game being tested.
...@@ -47,7 +47,7 @@ contract OutputBisectionGame_Init is DisputeGameFactory_Init { ...@@ -47,7 +47,7 @@ contract OutputBisectionGame_Init is DisputeGameFactory_Init {
// Set the extra data for the game creation // Set the extra data for the game creation
extraData = abi.encode(L2_BLOCK_NUMBER); extraData = abi.encode(L2_BLOCK_NUMBER);
AlphabetVM _vm = new AlphabetVM(absolutePrestate); AlphabetVM2 _vm = new AlphabetVM2(absolutePrestate);
// Deploy an implementation of the fault game // Deploy an implementation of the fault game
gameImpl = new OutputBisectionGame({ gameImpl = new OutputBisectionGame({
...@@ -100,7 +100,7 @@ contract OutputBisectionGame_Test is OutputBisectionGame_Init { ...@@ -100,7 +100,7 @@ contract OutputBisectionGame_Test is OutputBisectionGame_Init {
/// 1. Greater than or equal to the `MAX_GAME_DEPTH` /// 1. Greater than or equal to the `MAX_GAME_DEPTH`
/// 2. Odd /// 2. Odd
function test_constructor_wrongArgs_reverts(uint256 _splitDepth) public { function test_constructor_wrongArgs_reverts(uint256 _splitDepth) public {
AlphabetVM alphabetVM = new AlphabetVM(ABSOLUTE_PRESTATE); AlphabetVM2 alphabetVM = new AlphabetVM2(ABSOLUTE_PRESTATE);
// Test that the constructor reverts when the `_splitDepth` parameter is greater than or equal // Test that the constructor reverts when the `_splitDepth` parameter is greater than or equal
// to the `MAX_GAME_DEPTH` parameter. // to the `MAX_GAME_DEPTH` parameter.
......
...@@ -29,6 +29,7 @@ contract AlphabetVM is IBigStepper { ...@@ -29,6 +29,7 @@ contract AlphabetVM is IBigStepper {
(traceIndex, claim) = abi.decode(_stateData, (uint256, uint256)); (traceIndex, claim) = abi.decode(_stateData, (uint256, uint256));
traceIndex++; traceIndex++;
} }
// STF: n -> n + 1 // STF: n -> n + 1
postState_ = keccak256(abi.encode(traceIndex, claim + 1)); postState_ = keccak256(abi.encode(traceIndex, claim + 1));
assembly { assembly {
......
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.15;
import { IBigStepper, IPreimageOracle } from "src/dispute/interfaces/IBigStepper.sol";
import { PreimageOracle } from "src/cannon/PreimageOracle.sol";
import "src/libraries/DisputeTypes.sol";
/// @title AlphabetVM2
/// @dev A mock VM for the purpose of testing the dispute game infrastructure.
contract AlphabetVM2 is IBigStepper {
Claim internal immutable ABSOLUTE_PRESTATE;
IPreimageOracle public oracle;
constructor(Claim _absolutePrestate) {
ABSOLUTE_PRESTATE = _absolutePrestate;
oracle = new PreimageOracle();
}
/// @inheritdoc IBigStepper
function step(
bytes calldata _stateData,
bytes calldata,
bytes32 _localContext
)
external
returns (bytes32 postState_)
{
uint256 traceIndex;
uint256 claim;
if ((keccak256(_stateData) << 8) == (Claim.unwrap(ABSOLUTE_PRESTATE) << 8)) {
// If the state data is empty, then the absolute prestate is the claim.
traceIndex = 0;
(claim) = abi.decode(_stateData, (uint256));
claim = claim + uint256(oracle.loadLocalData(4, _localContext, 0, 32, 0));
} else {
// Otherwise, decode the state data.
(traceIndex, claim) = abi.decode(_stateData, (uint256, uint256));
traceIndex++;
}
// STF: n -> n + 1
postState_ = keccak256(abi.encode(traceIndex, claim + 1));
assembly {
postState_ := or(and(postState_, not(shl(248, 0xFF))), shl(248, 1))
}
}
}
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