Commit 9eb49b3c authored by clabby's avatar clabby Committed by GitHub

fix(ctb): FDG Local Keys (#9670)

* fix: FDG local keys

* @ajsutton review
Co-Authored-By: default avatarajsutton <adrian@oplabs.co>

* chore: bindings + semver

---------
Co-authored-by: default avatarajsutton <adrian@oplabs.co>
parent e2998e8f
......@@ -31,7 +31,7 @@ var (
// AlphabetVMMetaData contains all meta data concerning the AlphabetVM contract.
var AlphabetVMMetaData = &bind.MetaData{
ABI: "[{\"type\":\"constructor\",\"inputs\":[{\"name\":\"_absolutePrestate\",\"type\":\"bytes32\",\"internalType\":\"Claim\"},{\"name\":\"_oracle\",\"type\":\"address\",\"internalType\":\"contractPreimageOracle\"}],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"oracle\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"contractIPreimageOracle\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"step\",\"inputs\":[{\"name\":\"_stateData\",\"type\":\"bytes\",\"internalType\":\"bytes\"},{\"name\":\"\",\"type\":\"bytes\",\"internalType\":\"bytes\"},{\"name\":\"_localContext\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"}],\"outputs\":[{\"name\":\"postState_\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"}],\"stateMutability\":\"view\"}]",
Bin: "0x60a060405234801561001057600080fd5b506040516105b43803806105b483398101604081905261002f91610059565b608091909152600080546001600160a01b0319166001600160a01b03909216919091179055610096565b6000806040838503121561006c57600080fd5b825160208401519092506001600160a01b038116811461008b57600080fd5b809150509250929050565b6080516105046100b0600039600060af01526105046000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c80637dc0d1d01461003b578063e14ced3214610085575b600080fd5b60005461005b9073ffffffffffffffffffffffffffffffffffffffff1681565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020015b60405180910390f35b610098610093366004610395565b6100a6565b60405190815260200161007c565b600080600060087f0000000000000000000000000000000000000000000000000000000000000000901b600889896040516100e2929190610409565b6040518091039020901b036101d9576000805473ffffffffffffffffffffffffffffffffffffffff1663e03110e161011b60048861029f565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e084901b1681526004810191909152600060248201526044016040805180830381865afa158015610175573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101999190610419565b50640ffffffff0607c82901c169350905063ffffffff608082901c1660006101c38a8c018c61043d565b90506101cf8582610485565b9350505050610206565b6101e58789018961049d565b9092509050816101f4816104bf565b9250508080610202906104bf565b9150505b6040805160208101849052908101829052606001604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe081840301815291905280516020909101207effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f01000000000000000000000000000000000000000000000000000000000000001798975050505050505050565b7f01000000000000000000000000000000000000000000000000000000000000007effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff831617610345818360408051600093845233602052918152606090922091527effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f01000000000000000000000000000000000000000000000000000000000000001790565b9392505050565b60008083601f84011261035e57600080fd5b50813567ffffffffffffffff81111561037657600080fd5b60208301915083602082850101111561038e57600080fd5b9250929050565b6000806000806000606086880312156103ad57600080fd5b853567ffffffffffffffff808211156103c557600080fd5b6103d189838a0161034c565b909750955060208801359150808211156103ea57600080fd5b506103f78882890161034c565b96999598509660400135949350505050565b8183823760009101908152919050565b6000806040838503121561042c57600080fd5b505080516020909101519092909150565b60006020828403121561044f57600080fd5b5035919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000821982111561049857610498610456565b500190565b600080604083850312156104b057600080fd5b50508035926020909101359150565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82036104f0576104f0610456565b506001019056fea164736f6c634300080f000a",
Bin: "0x60a060405234801561001057600080fd5b506040516105d23803806105d283398101604081905261002f91610059565b608091909152600080546001600160a01b0319166001600160a01b03909216919091179055610096565b6000806040838503121561006c57600080fd5b825160208401519092506001600160a01b038116811461008b57600080fd5b809150509250929050565b6080516105226100b0600039600060af01526105226000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c80637dc0d1d01461003b578063e14ced3214610085575b600080fd5b60005461005b9073ffffffffffffffffffffffffffffffffffffffff1681565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020015b60405180910390f35b61009861009336600461039c565b6100a6565b60405190815260200161007c565b600080600060087f0000000000000000000000000000000000000000000000000000000000000000901b600889896040516100e2929190610410565b6040518091039020901b036101e0576000805473ffffffffffffffffffffffffffffffffffffffff1663e03110e161011b6004886102a6565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e084901b1681526004810191909152600060248201526044016040805180830381865afa158015610175573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101999190610420565b50905060006101b3600163ffffffff608085901c16610473565b600481901b9450905060006101ca8a8c018c61048a565b90506101d685826104a3565b935050505061020d565b6101ec878901896104bb565b9092509050816101fb816104dd565b9250508080610209906104dd565b9150505b6040805160208101849052908101829052606001604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe081840301815291905280516020909101207effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f01000000000000000000000000000000000000000000000000000000000000001798975050505050505050565b7f01000000000000000000000000000000000000000000000000000000000000007effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff83161761034c818360408051600093845233602052918152606090922091527effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f01000000000000000000000000000000000000000000000000000000000000001790565b9392505050565b60008083601f84011261036557600080fd5b50813567ffffffffffffffff81111561037d57600080fd5b60208301915083602082850101111561039557600080fd5b9250929050565b6000806000806000606086880312156103b457600080fd5b853567ffffffffffffffff808211156103cc57600080fd5b6103d889838a01610353565b909750955060208801359150808211156103f157600080fd5b506103fe88828901610353565b96999598509660400135949350505050565b8183823760009101908152919050565b6000806040838503121561043357600080fd5b505080516020909101519092909150565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60008282101561048557610485610444565b500390565b60006020828403121561049c57600080fd5b5035919050565b600082198211156104b6576104b6610444565b500190565b600080604083850312156104ce57600080fd5b50508035926020909101359150565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff820361050e5761050e610444565b506001019056fea164736f6c634300080f000a",
}
// AlphabetVMABI is the input ABI used to generate the binding from.
......
......@@ -13,7 +13,7 @@ const AlphabetVMStorageLayoutJSON = "{\"storage\":[{\"astId\":1000,\"contract\":
var AlphabetVMStorageLayout = new(solc.StorageLayout)
var AlphabetVMDeployedBin = "0x608060405234801561001057600080fd5b50600436106100365760003560e01c80637dc0d1d01461003b578063e14ced3214610085575b600080fd5b60005461005b9073ffffffffffffffffffffffffffffffffffffffff1681565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020015b60405180910390f35b610098610093366004610395565b6100a6565b60405190815260200161007c565b600080600060087f0000000000000000000000000000000000000000000000000000000000000000901b600889896040516100e2929190610409565b6040518091039020901b036101d9576000805473ffffffffffffffffffffffffffffffffffffffff1663e03110e161011b60048861029f565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e084901b1681526004810191909152600060248201526044016040805180830381865afa158015610175573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101999190610419565b50640ffffffff0607c82901c169350905063ffffffff608082901c1660006101c38a8c018c61043d565b90506101cf8582610485565b9350505050610206565b6101e58789018961049d565b9092509050816101f4816104bf565b9250508080610202906104bf565b9150505b6040805160208101849052908101829052606001604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe081840301815291905280516020909101207effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f01000000000000000000000000000000000000000000000000000000000000001798975050505050505050565b7f01000000000000000000000000000000000000000000000000000000000000007effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff831617610345818360408051600093845233602052918152606090922091527effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f01000000000000000000000000000000000000000000000000000000000000001790565b9392505050565b60008083601f84011261035e57600080fd5b50813567ffffffffffffffff81111561037657600080fd5b60208301915083602082850101111561038e57600080fd5b9250929050565b6000806000806000606086880312156103ad57600080fd5b853567ffffffffffffffff808211156103c557600080fd5b6103d189838a0161034c565b909750955060208801359150808211156103ea57600080fd5b506103f78882890161034c565b96999598509660400135949350505050565b8183823760009101908152919050565b6000806040838503121561042c57600080fd5b505080516020909101519092909150565b60006020828403121561044f57600080fd5b5035919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000821982111561049857610498610456565b500190565b600080604083850312156104b057600080fd5b50508035926020909101359150565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82036104f0576104f0610456565b506001019056fea164736f6c634300080f000a"
var AlphabetVMDeployedBin = "0x608060405234801561001057600080fd5b50600436106100365760003560e01c80637dc0d1d01461003b578063e14ced3214610085575b600080fd5b60005461005b9073ffffffffffffffffffffffffffffffffffffffff1681565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020015b60405180910390f35b61009861009336600461039c565b6100a6565b60405190815260200161007c565b600080600060087f0000000000000000000000000000000000000000000000000000000000000000901b600889896040516100e2929190610410565b6040518091039020901b036101e0576000805473ffffffffffffffffffffffffffffffffffffffff1663e03110e161011b6004886102a6565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e084901b1681526004810191909152600060248201526044016040805180830381865afa158015610175573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101999190610420565b50905060006101b3600163ffffffff608085901c16610473565b600481901b9450905060006101ca8a8c018c61048a565b90506101d685826104a3565b935050505061020d565b6101ec878901896104bb565b9092509050816101fb816104dd565b9250508080610209906104dd565b9150505b6040805160208101849052908101829052606001604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe081840301815291905280516020909101207effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f01000000000000000000000000000000000000000000000000000000000000001798975050505050505050565b7f01000000000000000000000000000000000000000000000000000000000000007effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff83161761034c818360408051600093845233602052918152606090922091527effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f01000000000000000000000000000000000000000000000000000000000000001790565b9392505050565b60008083601f84011261036557600080fd5b50813567ffffffffffffffff81111561037d57600080fd5b60208301915083602082850101111561039557600080fd5b9250929050565b6000806000806000606086880312156103b457600080fd5b853567ffffffffffffffff808211156103cc57600080fd5b6103d889838a01610353565b909750955060208801359150808211156103f157600080fd5b506103fe88828901610353565b96999598509660400135949350505050565b8183823760009101908152919050565b6000806040838503121561043357600080fd5b505080516020909101519092909150565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60008282101561048557610485610444565b500390565b60006020828403121561049c57600080fd5b5035919050565b600082198211156104b6576104b6610444565b500190565b600080604083850312156104ce57600080fd5b50508035926020909101359150565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff820361050e5761050e610444565b506001019056fea164736f6c634300080f000a"
func init() {
......
This diff is collapsed.
......@@ -100,8 +100,8 @@
"sourceCodeHash": "0x1e5a6deded88804971fc1847c9eac65921771bff353437c0b29ed2f55513b984"
},
"src/dispute/FaultDisputeGame.sol": {
"initCodeHash": "0xa06a5699121ff4b6f7bb89c43d56070fffee78c856363ead237e45ad6746db87",
"sourceCodeHash": "0x5f98e7357a45507c39366d3056a6c948d6be1a0b72a8758c66396041aa823fc9"
"initCodeHash": "0x73600519fd00cda111fdc811ec4e1712d599300b2fbc53c70620702653e3be3a",
"sourceCodeHash": "0x7fd6726ba22f848e6177e9413bdb2e74dacbb9ae87d57cb0c4cbd497b9a318d3"
},
"src/legacy/DeployerWhitelist.sol": {
"initCodeHash": "0x8de80fb23b26dd9d849f6328e56ea7c173cd9e9ce1f05c9beea559d1720deb3d",
......
......@@ -81,8 +81,8 @@ contract FaultDisputeGame is IFaultDisputeGame, Clone, ISemver {
bool internal initialized;
/// @notice Semantic version.
/// @custom:semver 0.6.0
string public constant version = "0.6.0";
/// @custom:semver 0.7.0
string public constant version = "0.7.0";
/// @param _gameType The type ID of the game.
/// @param _absolutePrestate The absolute prestate of the instruction trace.
......@@ -325,15 +325,12 @@ contract FaultDisputeGame is IFaultDisputeGame, Clone, ISemver {
} else if (_ident == LocalPreimageKey.DISPUTED_OUTPUT_ROOT) {
// Load the disputed proposal's output root
oracle.loadLocalData(_ident, uuid.raw(), disputed.raw(), 32, _partOffset);
} else if (_ident == LocalPreimageKey.STARTING_L2_BLOCK_NUMBER) {
// Load the starting proposal's L2 block number as a big-endian uint64 in the
} else if (_ident == LocalPreimageKey.DISPUTED_L2_BLOCK_NUMBER) {
// Load the disputed proposal's L2 block number as a big-endian uint64 in the
// high order 8 bytes of the word.
// If the starting position is 0 (invalid), the starting output root is genesis. Otherwise,
// we add the index at depth + 1 to the genesis block number to get the L2 block number.
uint256 l2Number = startingPos.raw() == 0
? GENESIS_BLOCK_NUMBER
: GENESIS_BLOCK_NUMBER + startingPos.traceIndex(SPLIT_DEPTH) + 1;
// We add the index at depth + 1 to the genesis block number to get the disputed L2 block number.
uint256 l2Number = GENESIS_BLOCK_NUMBER + disputedPos.traceIndex(SPLIT_DEPTH) + 1;
oracle.loadLocalData(_ident, uuid.raw(), bytes32(l2Number << 0xC0), 8, _partOffset);
} else if (_ident == LocalPreimageKey.CHAIN_ID) {
......
......@@ -131,8 +131,8 @@ library LocalPreimageKey {
/// @notice The identifier for the disputed output root.
uint256 internal constant DISPUTED_OUTPUT_ROOT = 0x03;
/// @notice The identifier for the starting L2 block number.
uint256 internal constant STARTING_L2_BLOCK_NUMBER = 0x04;
/// @notice The identifier for the disputed L2 block number.
uint256 internal constant DISPUTED_L2_BLOCK_NUMBER = 0x04;
/// @notice The identifier for the chain ID.
uint256 internal constant CHAIN_ID = 0x05;
......
......@@ -399,7 +399,7 @@ contract HonestDisputeActor is DisputeActor {
challengeIndex := mload(add(moveData, 0x24))
}
GAME.addLocalData({
_ident: LocalPreimageKey.STARTING_L2_BLOCK_NUMBER,
_ident: LocalPreimageKey.DISPUTED_L2_BLOCK_NUMBER,
_execLeafIdx: challengeIndex,
_partOffset: 0
});
......
......@@ -456,7 +456,7 @@ contract FaultDisputeGame_Test is FaultDisputeGame_Init {
gameProxy.attack{ value: 1 ether }(5, _dummyClaim());
gameProxy.attack{ value: 1 ether }(6, _dummyClaim());
gameProxy.attack{ value: 1 ether }(7, _dummyClaim());
gameProxy.addLocalData(LocalPreimageKey.STARTING_L2_BLOCK_NUMBER, 8, 0);
gameProxy.addLocalData(LocalPreimageKey.DISPUTED_L2_BLOCK_NUMBER, 8, 0);
gameProxy.step(8, true, absolutePrestateData, hex"");
vm.expectRevert(DuplicateStep.selector);
......@@ -630,7 +630,7 @@ contract FaultDisputeGame_Test is FaultDisputeGame_Init {
gameProxy.attack{ value: 1 ether }(5, _dummyClaim());
gameProxy.attack{ value: 1 ether }(6, _dummyClaim());
gameProxy.attack{ value: 1 ether }(7, _dummyClaim());
gameProxy.addLocalData(LocalPreimageKey.STARTING_L2_BLOCK_NUMBER, 8, 0);
gameProxy.addLocalData(LocalPreimageKey.DISPUTED_L2_BLOCK_NUMBER, 8, 0);
gameProxy.step(8, true, absolutePrestateData, hex"");
// Ensure that the step successfully countered the leaf claim.
......@@ -689,7 +689,7 @@ contract FaultDisputeGame_Test is FaultDisputeGame_Init {
vm.prank(bob);
gameProxy.attack{ value: 1 ether }(7, _dummyClaim());
gameProxy.addLocalData(LocalPreimageKey.STARTING_L2_BLOCK_NUMBER, 8, 0);
gameProxy.addLocalData(LocalPreimageKey.DISPUTED_L2_BLOCK_NUMBER, 8, 0);
gameProxy.step(8, true, absolutePrestateData, hex"");
// Ensure that the step successfully countered the leaf claim.
......@@ -848,8 +848,13 @@ contract FaultDisputeGame_Test is FaultDisputeGame_Init {
Position disputedPos = LibPosition.wrap(4, 0);
// Expected local data
bytes32[5] memory data =
[gameProxy.l1Head().raw(), startingClaim, disputedClaim, bytes32(0), bytes32(block.chainid << 0xC0)];
bytes32[5] memory data = [
gameProxy.l1Head().raw(),
startingClaim,
disputedClaim,
bytes32(uint256(1) << 0xC0),
bytes32(block.chainid << 0xC0)
];
for (uint256 i = 1; i <= 5; i++) {
uint256 expectedLen = i > 3 ? 8 : 32;
......@@ -893,7 +898,7 @@ contract FaultDisputeGame_Test is FaultDisputeGame_Init {
gameProxy.l1Head().raw(),
startingClaim,
disputedClaim,
bytes32(uint256(1) << 0xC0),
bytes32(uint256(2) << 0xC0),
bytes32(block.chainid << 0xC0)
];
......
......@@ -32,9 +32,9 @@ contract AlphabetVM is IBigStepper {
if ((keccak256(_stateData) << 8) == (Claim.unwrap(ABSOLUTE_PRESTATE) << 8)) {
// If the state data is empty, then the absolute prestate is the claim.
(bytes32 dat,) = oracle.readPreimage(
PreimageKeyLib.localizeIdent(LocalPreimageKey.STARTING_L2_BLOCK_NUMBER, _localContext), 0
PreimageKeyLib.localizeIdent(LocalPreimageKey.DISPUTED_L2_BLOCK_NUMBER, _localContext), 0
);
uint256 startingL2BlockNumber = (uint256(dat) >> 128) & 0xFFFFFFFF;
uint256 startingL2BlockNumber = ((uint256(dat) >> 128) & 0xFFFFFFFF) - 1;
traceIndex = startingL2BlockNumber << 4;
(uint256 absolutePrestateClaim) = abi.decode(_stateData, (uint256));
claim = absolutePrestateClaim + traceIndex;
......
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