Commit e61a90c6 authored by Adrian Sutton's avatar Adrian Sutton

PreImageOracle: Change local context to bytes32

The value being set is a hash not a number so simpler to work with as bytes32.
parent 8809a31f
This diff is collapsed.
...@@ -13,7 +13,7 @@ const AlphabetVMStorageLayoutJSON = "{\"storage\":[{\"astId\":1000,\"contract\": ...@@ -13,7 +13,7 @@ const AlphabetVMStorageLayoutJSON = "{\"storage\":[{\"astId\":1000,\"contract\":
var AlphabetVMStorageLayout = new(solc.StorageLayout) var AlphabetVMStorageLayout = new(solc.StorageLayout)
var AlphabetVMDeployedBin = "0x608060405234801561001057600080fd5b50600436106100365760003560e01c80637dc0d1d01461003b578063836e7b3214610085575b600080fd5b60005461005b9073ffffffffffffffffffffffffffffffffffffffff1681565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020015b60405180910390f35b610098610093366004610213565b6100a6565b60405190815260200161007c565b600080600060087f0000000000000000000000000000000000000000000000000000000000000000901b600889896040516100e2929190610287565b6040518091039020901b03610108576000915061010187890189610297565b9050610127565b610114878901896102b0565b90925090508161012381610301565b9250505b81610133826001610339565b604080516020810193909352820152606001604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe081840301815291905280516020909101207effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f01000000000000000000000000000000000000000000000000000000000000001798975050505050505050565b60008083601f8401126101dc57600080fd5b50813567ffffffffffffffff8111156101f457600080fd5b60208301915083602082850101111561020c57600080fd5b9250929050565b60008060008060006060868803121561022b57600080fd5b853567ffffffffffffffff8082111561024357600080fd5b61024f89838a016101ca565b9097509550602088013591508082111561026857600080fd5b50610275888289016101ca565b96999598509660400135949350505050565b8183823760009101908152919050565b6000602082840312156102a957600080fd5b5035919050565b600080604083850312156102c357600080fd5b50508035926020909101359150565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203610332576103326102d2565b5060010190565b6000821982111561034c5761034c6102d2565b50019056fea164736f6c634300080f000a" var AlphabetVMDeployedBin = "0x608060405234801561001057600080fd5b50600436106100365760003560e01c80637dc0d1d01461003b578063e14ced3214610085575b600080fd5b60005461005b9073ffffffffffffffffffffffffffffffffffffffff1681565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020015b60405180910390f35b610098610093366004610213565b6100a6565b60405190815260200161007c565b600080600060087f0000000000000000000000000000000000000000000000000000000000000000901b600889896040516100e2929190610287565b6040518091039020901b03610108576000915061010187890189610297565b9050610127565b610114878901896102b0565b90925090508161012381610301565b9250505b81610133826001610339565b604080516020810193909352820152606001604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe081840301815291905280516020909101207effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f01000000000000000000000000000000000000000000000000000000000000001798975050505050505050565b60008083601f8401126101dc57600080fd5b50813567ffffffffffffffff8111156101f457600080fd5b60208301915083602082850101111561020c57600080fd5b9250929050565b60008060008060006060868803121561022b57600080fd5b853567ffffffffffffffff8082111561024357600080fd5b61024f89838a016101ca565b9097509550602088013591508082111561026857600080fd5b50610275888289016101ca565b96999598509660400135949350505050565b8183823760009101908152919050565b6000602082840312156102a957600080fd5b5035919050565b600080604083850312156102c357600080fd5b50508035926020909101359150565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203610332576103326102d2565b5060010190565b6000821982111561034c5761034c6102d2565b50019056fea164736f6c634300080f000a"
func init() { func init() {
if err := json.Unmarshal([]byte(AlphabetVMStorageLayoutJSON), AlphabetVMStorageLayout); err != nil { if err := json.Unmarshal([]byte(AlphabetVMStorageLayoutJSON), AlphabetVMStorageLayout); err != nil {
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -232,7 +232,7 @@ func (f *FaultDisputeGameContract) addLocalDataTx(data *types.PreimageOracleData ...@@ -232,7 +232,7 @@ func (f *FaultDisputeGameContract) addLocalDataTx(data *types.PreimageOracleData
call := f.contract.Call( call := f.contract.Call(
methodAddLocalData, methodAddLocalData,
data.GetIdent(), data.GetIdent(),
new(big.Int).SetBytes(data.LocalContext.Bytes()), data.LocalContext,
new(big.Int).SetUint64(uint64(data.OracleOffset)), new(big.Int).SetUint64(uint64(data.OracleOffset)),
) )
return call.ToTxCandidate() return call.ToTxCandidate()
......
...@@ -260,7 +260,7 @@ func TestUpdateOracleTx(t *testing.T) { ...@@ -260,7 +260,7 @@ func TestUpdateOracleTx(t *testing.T) {
} }
stubRpc.SetResponse(fdgAddr, methodAddLocalData, batching.BlockLatest, []interface{}{ stubRpc.SetResponse(fdgAddr, methodAddLocalData, batching.BlockLatest, []interface{}{
data.GetIdent(), data.GetIdent(),
new(big.Int).SetBytes(data.LocalContext.Bytes()), data.LocalContext,
new(big.Int).SetUint64(uint64(data.OracleOffset)), new(big.Int).SetUint64(uint64(data.OracleOffset)),
}, nil) }, nil)
tx, err := game.UpdateOracleTx(context.Background(), data) tx, err := game.UpdateOracleTx(context.Background(), data)
......
...@@ -99,34 +99,34 @@ FaultDisputeGame_ResolvesCorrectly_IncorrectRoot2:test_resolvesCorrectly_succeed ...@@ -99,34 +99,34 @@ FaultDisputeGame_ResolvesCorrectly_IncorrectRoot2:test_resolvesCorrectly_succeed
FaultDisputeGame_ResolvesCorrectly_IncorrectRoot3:test_resolvesCorrectly_succeeds() (gas: 655638) FaultDisputeGame_ResolvesCorrectly_IncorrectRoot3:test_resolvesCorrectly_succeeds() (gas: 655638)
FaultDisputeGame_ResolvesCorrectly_IncorrectRoot4:test_resolvesCorrectly_succeeds() (gas: 656576) FaultDisputeGame_ResolvesCorrectly_IncorrectRoot4:test_resolvesCorrectly_succeeds() (gas: 656576)
FaultDisputeGame_ResolvesCorrectly_IncorrectRoot5:test_resolvesCorrectly_succeeds() (gas: 656027) FaultDisputeGame_ResolvesCorrectly_IncorrectRoot5:test_resolvesCorrectly_succeeds() (gas: 656027)
FaultDisputeGame_Test:test_addLocalData_static_succeeds() (gas: 642366) FaultDisputeGame_Test:test_addLocalData_static_succeeds() (gas: 641986)
FaultDisputeGame_Test:test_createdAt_succeeds() (gas: 10461) FaultDisputeGame_Test:test_createdAt_succeeds() (gas: 10461)
FaultDisputeGame_Test:test_extraData_succeeds() (gas: 32407) FaultDisputeGame_Test:test_extraData_succeeds() (gas: 32407)
FaultDisputeGame_Test:test_gameData_succeeds() (gas: 32857) FaultDisputeGame_Test:test_gameData_succeeds() (gas: 32835)
FaultDisputeGame_Test:test_gameType_succeeds() (gas: 8287) FaultDisputeGame_Test:test_gameType_succeeds() (gas: 8287)
FaultDisputeGame_Test:test_initialize_correctData_succeeds() (gas: 57761) FaultDisputeGame_Test:test_initialize_correctData_succeeds() (gas: 57805)
FaultDisputeGame_Test:test_initialize_firstOutput_reverts() (gas: 213868) FaultDisputeGame_Test:test_initialize_firstOutput_reverts() (gas: 213868)
FaultDisputeGame_Test:test_initialize_l1HeadTooOld_reverts() (gas: 228482) FaultDisputeGame_Test:test_initialize_l1HeadTooOld_reverts() (gas: 228460)
FaultDisputeGame_Test:test_move_clockCorrectness_succeeds() (gas: 594223) FaultDisputeGame_Test:test_move_clockCorrectness_succeeds() (gas: 594267)
FaultDisputeGame_Test:test_move_clockTimeExceeded_reverts() (gas: 23197) FaultDisputeGame_Test:test_move_clockTimeExceeded_reverts() (gas: 23175)
FaultDisputeGame_Test:test_move_defendRoot_reverts() (gas: 13322) FaultDisputeGame_Test:test_move_defendRoot_reverts() (gas: 13367)
FaultDisputeGame_Test:test_move_duplicateClaim_reverts() (gas: 147390) FaultDisputeGame_Test:test_move_duplicateClaim_reverts() (gas: 147368)
FaultDisputeGame_Test:test_move_duplicateClaimsDifferentSubgames_succeeds() (gas: 556832) FaultDisputeGame_Test:test_move_duplicateClaimsDifferentSubgames_succeeds() (gas: 556865)
FaultDisputeGame_Test:test_move_gameDepthExceeded_reverts() (gas: 585875) FaultDisputeGame_Test:test_move_gameDepthExceeded_reverts() (gas: 585875)
FaultDisputeGame_Test:test_move_gameNotInProgress_reverts() (gas: 11010) FaultDisputeGame_Test:test_move_gameNotInProgress_reverts() (gas: 10988)
FaultDisputeGame_Test:test_move_nonExistentParent_reverts() (gas: 24668) FaultDisputeGame_Test:test_move_nonExistentParent_reverts() (gas: 24668)
FaultDisputeGame_Test:test_move_simpleAttack_succeeds() (gas: 152008) FaultDisputeGame_Test:test_move_simpleAttack_succeeds() (gas: 152008)
FaultDisputeGame_Test:test_resolve_challengeContested_succeeds() (gas: 269473) FaultDisputeGame_Test:test_resolve_challengeContested_succeeds() (gas: 269456)
FaultDisputeGame_Test:test_resolve_claimAlreadyResolved_reverts() (gas: 272356) FaultDisputeGame_Test:test_resolve_claimAlreadyResolved_reverts() (gas: 272356)
FaultDisputeGame_Test:test_resolve_claimAtMaxDepthAlreadyResolved_reverts() (gas: 586606) FaultDisputeGame_Test:test_resolve_claimAtMaxDepthAlreadyResolved_reverts() (gas: 586606)
FaultDisputeGame_Test:test_resolve_notInProgress_reverts() (gas: 9776) FaultDisputeGame_Test:test_resolve_notInProgress_reverts() (gas: 9776)
FaultDisputeGame_Test:test_resolve_outOfOrderResolution_reverts() (gas: 309015) FaultDisputeGame_Test:test_resolve_outOfOrderResolution_reverts() (gas: 308993)
FaultDisputeGame_Test:test_resolve_rootContested_succeeds() (gas: 139119) FaultDisputeGame_Test:test_resolve_rootContested_succeeds() (gas: 139164)
FaultDisputeGame_Test:test_resolve_rootUncontestedButUnresolved_reverts() (gas: 15935) FaultDisputeGame_Test:test_resolve_rootUncontestedButUnresolved_reverts() (gas: 15935)
FaultDisputeGame_Test:test_resolve_rootUncontestedClockNotExpired_succeeds() (gas: 18428) FaultDisputeGame_Test:test_resolve_rootUncontestedClockNotExpired_succeeds() (gas: 18428)
FaultDisputeGame_Test:test_resolve_rootUncontested_succeeds() (gas: 51484) FaultDisputeGame_Test:test_resolve_rootUncontested_succeeds() (gas: 51462)
FaultDisputeGame_Test:test_resolve_stepReached_succeeds() (gas: 498448) FaultDisputeGame_Test:test_resolve_stepReached_succeeds() (gas: 498448)
FaultDisputeGame_Test:test_resolve_teamDeathmatch_succeeds() (gas: 443399) FaultDisputeGame_Test:test_resolve_teamDeathmatch_succeeds() (gas: 443381)
FaultDisputeGame_Test:test_rootClaim_succeeds() (gas: 8232) FaultDisputeGame_Test:test_rootClaim_succeeds() (gas: 8232)
FeeVault_Test:test_constructor_baseFeeVault_succeeds() (gas: 17450) FeeVault_Test:test_constructor_baseFeeVault_succeeds() (gas: 17450)
FeeVault_Test:test_constructor_l1FeeVault_succeeds() (gas: 17418) FeeVault_Test:test_constructor_l1FeeVault_succeeds() (gas: 17418)
...@@ -383,7 +383,7 @@ MIPS_Test:test_multu_succeeds() (gas: 123018) ...@@ -383,7 +383,7 @@ MIPS_Test:test_multu_succeeds() (gas: 123018)
MIPS_Test:test_nor_succeeds() (gas: 123109) MIPS_Test:test_nor_succeeds() (gas: 123109)
MIPS_Test:test_or_succeeds() (gas: 123024) MIPS_Test:test_or_succeeds() (gas: 123024)
MIPS_Test:test_ori_succeeds() (gas: 123026) MIPS_Test:test_ori_succeeds() (gas: 123026)
MIPS_Test:test_preimage_read_succeeds() (gas: 235502) MIPS_Test:test_preimage_read_succeeds() (gas: 235458)
MIPS_Test:test_preimage_write_succeeds() (gas: 127574) MIPS_Test:test_preimage_write_succeeds() (gas: 127574)
MIPS_Test:test_prestate_exited_succeeds() (gas: 113835) MIPS_Test:test_prestate_exited_succeeds() (gas: 113835)
MIPS_Test:test_sb_succeeds() (gas: 161547) MIPS_Test:test_sb_succeeds() (gas: 161547)
...@@ -545,10 +545,10 @@ OptimistTest:test_tokenURI_returnsCorrectTokenURI_succeeds() (gas: 195905) ...@@ -545,10 +545,10 @@ OptimistTest:test_tokenURI_returnsCorrectTokenURI_succeeds() (gas: 195905)
OptimistTest:test_transferFrom_soulbound_reverts() (gas: 75512) OptimistTest:test_transferFrom_soulbound_reverts() (gas: 75512)
PreimageOracle_Test:test_keccak256PreimageKey_succeeds() (gas: 342) PreimageOracle_Test:test_keccak256PreimageKey_succeeds() (gas: 342)
PreimageOracle_Test:test_loadKeccak256PreimagePart_outOfBoundsOffset_reverts() (gas: 8971) PreimageOracle_Test:test_loadKeccak256PreimagePart_outOfBoundsOffset_reverts() (gas: 8971)
PreimageOracle_Test:test_loadKeccak256PreimagePart_succeeds() (gas: 76076) PreimageOracle_Test:test_loadKeccak256PreimagePart_succeeds() (gas: 76120)
PreimageOracle_Test:test_loadLocalData_multipleContexts_succeeds() (gas: 147718) PreimageOracle_Test:test_loadLocalData_multipleContexts_succeeds() (gas: 147718)
PreimageOracle_Test:test_loadLocalData_onePart_succeeds() (gas: 75905) PreimageOracle_Test:test_loadLocalData_onePart_succeeds() (gas: 75905)
PreimageOracle_Test:test_loadLocalData_outOfBoundsOffset_reverts() (gas: 8882) PreimageOracle_Test:test_loadLocalData_outOfBoundsOffset_reverts() (gas: 8861)
ProtocolVersions_Initialize_Test:test_initialize_events_succeeds() (gas: 41623) ProtocolVersions_Initialize_Test:test_initialize_events_succeeds() (gas: 41623)
ProtocolVersions_Initialize_Test:test_initialize_values_succeeds() (gas: 45046) ProtocolVersions_Initialize_Test:test_initialize_values_succeeds() (gas: 45046)
ProtocolVersions_Setters_TestFail:test_setRecommended_notOwner_reverts() (gas: 15553) ProtocolVersions_Setters_TestFail:test_setRecommended_notOwner_reverts() (gas: 15553)
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
"src/Safe/LivenessModule.sol": "0x45621d74ea464c75064f9194261d29d47552cf4a9c4f4b3a733f5df5803fc0dd", "src/Safe/LivenessModule.sol": "0x45621d74ea464c75064f9194261d29d47552cf4a9c4f4b3a733f5df5803fc0dd",
"src/dispute/BlockOracle.sol": "0x7e724b1ee0116dfd744f556e6237af449c2f40c6426d6f1462ae2a47589283bb", "src/dispute/BlockOracle.sol": "0x7e724b1ee0116dfd744f556e6237af449c2f40c6426d6f1462ae2a47589283bb",
"src/dispute/DisputeGameFactory.sol": "0xfdfa141408d7f8de7e230ff4bef088e30d0e4d569ca743d60d292abdd21ff270", "src/dispute/DisputeGameFactory.sol": "0xfdfa141408d7f8de7e230ff4bef088e30d0e4d569ca743d60d292abdd21ff270",
"src/dispute/FaultDisputeGame.sol": "0x0766707ab32338a6586c2340ddfbfd4e9023eeb9dfa3ef87e4b404fb0260479f", "src/dispute/FaultDisputeGame.sol": "0x7ac7553a47d96a4481a6b95363458bed5f160112b647829c4defc134fa178d9a",
"src/legacy/DeployerWhitelist.sol": "0x0a6840074734c9d167321d3299be18ef911a415e4c471fa92af7d6cfaa8336d4", "src/legacy/DeployerWhitelist.sol": "0x0a6840074734c9d167321d3299be18ef911a415e4c471fa92af7d6cfaa8336d4",
"src/legacy/L1BlockNumber.sol": "0x20d83a636c5e2067fca8c0ed505b295174e6eddb25960d8705e6b6fea8e77fa6", "src/legacy/L1BlockNumber.sol": "0x20d83a636c5e2067fca8c0ed505b295174e6eddb25960d8705e6b6fea8e77fa6",
"src/legacy/LegacyMessagePasser.sol": "0x80f355c9710af586f58cf6a86d1925e0073d1e504d0b3d814284af1bafe4dece", "src/legacy/LegacyMessagePasser.sol": "0x80f355c9710af586f58cf6a86d1925e0073d1e504d0b3d814284af1bafe4dece",
......
...@@ -143,7 +143,7 @@ contract MIPS { ...@@ -143,7 +143,7 @@ contract MIPS {
/// @notice Handles a syscall. /// @notice Handles a syscall.
/// @param _localContext The local key context for the preimage oracle. /// @param _localContext The local key context for the preimage oracle.
/// @return out_ The hashed MIPS state. /// @return out_ The hashed MIPS state.
function handleSyscall(uint256 _localContext) internal returns (bytes32 out_) { function handleSyscall(bytes32 _localContext) internal returns (bytes32 out_) {
unchecked { unchecked {
// Load state from memory // Load state from memory
State memory state; State memory state;
...@@ -626,7 +626,7 @@ contract MIPS { ...@@ -626,7 +626,7 @@ contract MIPS {
/// @param _proof The encoded proof data for leaves within the MIPS VM's memory. /// @param _proof The encoded proof data for leaves within the MIPS VM's memory.
/// @param _localContext The local key context for the preimage oracle. Optional, can be set as a constant /// @param _localContext The local key context for the preimage oracle. Optional, can be set as a constant
/// if the caller only requires one set of local keys. /// if the caller only requires one set of local keys.
function step(bytes calldata _stateData, bytes calldata _proof, uint256 _localContext) public returns (bytes32) { function step(bytes calldata _stateData, bytes calldata _proof, bytes32 _localContext) public returns (bytes32) {
unchecked { unchecked {
State memory state; State memory state;
......
...@@ -9,7 +9,7 @@ library PreimageKeyLib { ...@@ -9,7 +9,7 @@ library PreimageKeyLib {
/// @param _ident The identifier of the local data. [0, 32) bytes in size. /// @param _ident The identifier of the local data. [0, 32) bytes in size.
/// @param _localContext The local context for the key. /// @param _localContext The local context for the key.
/// @return key_ The context-specific local key. /// @return key_ The context-specific local key.
function localizeIdent(uint256 _ident, uint256 _localContext) internal view returns (bytes32 key_) { function localizeIdent(uint256 _ident, bytes32 _localContext) internal view returns (bytes32 key_) {
assembly { assembly {
// Set the type byte in the given identifier to `1` (Local). We only care about // Set the type byte in the given identifier to `1` (Local). We only care about
// the [1, 32) bytes in this value. // the [1, 32) bytes in this value.
...@@ -26,7 +26,7 @@ library PreimageKeyLib { ...@@ -26,7 +26,7 @@ library PreimageKeyLib {
/// @param _key The local data key to localize. /// @param _key The local data key to localize.
/// @param _localContext The local context for the key. /// @param _localContext The local context for the key.
/// @return localizedKey_ The localized local data key. /// @return localizedKey_ The localized local data key.
function localize(bytes32 _key, uint256 _localContext) internal view returns (bytes32 localizedKey_) { function localize(bytes32 _key, bytes32 _localContext) internal view returns (bytes32 localizedKey_) {
assembly { assembly {
// Grab the current free memory pointer to restore later. // Grab the current free memory pointer to restore later.
let ptr := mload(0x40) let ptr := mload(0x40)
......
...@@ -34,7 +34,7 @@ contract PreimageOracle is IPreimageOracle { ...@@ -34,7 +34,7 @@ contract PreimageOracle is IPreimageOracle {
/// @inheritdoc IPreimageOracle /// @inheritdoc IPreimageOracle
function loadLocalData( function loadLocalData(
uint256 _ident, uint256 _ident,
uint256 _localContext, bytes32 _localContext,
bytes32 _word, bytes32 _word,
uint256 _size, uint256 _size,
uint256 _partOffset uint256 _partOffset
......
...@@ -34,7 +34,7 @@ interface IPreimageOracle { ...@@ -34,7 +34,7 @@ interface IPreimageOracle {
/// └────────────┴────────────────────────┘ /// └────────────┴────────────────────────┘
function loadLocalData( function loadLocalData(
uint256 _ident, uint256 _ident,
uint256 _localContext, bytes32 _localContext,
bytes32 _word, bytes32 _word,
uint256 _size, uint256 _size,
uint256 _partOffset uint256 _partOffset
......
...@@ -82,8 +82,8 @@ contract FaultDisputeGame is IFaultDisputeGame, Clone, ISemver { ...@@ -82,8 +82,8 @@ contract FaultDisputeGame is IFaultDisputeGame, Clone, ISemver {
bool internal subgameAtRootResolved; bool internal subgameAtRootResolved;
/// @notice Semantic version. /// @notice Semantic version.
/// @custom:semver 0.0.11 /// @custom:semver 0.0.12
string public constant version = "0.0.11"; string public constant version = "0.0.12";
/// @param _gameType The type ID of the game. /// @param _gameType The type ID of the game.
/// @param _absolutePrestate The absolute prestate of the instruction trace. /// @param _absolutePrestate The absolute prestate of the instruction trace.
...@@ -281,7 +281,7 @@ contract FaultDisputeGame is IFaultDisputeGame, Clone, ISemver { ...@@ -281,7 +281,7 @@ contract FaultDisputeGame is IFaultDisputeGame, Clone, ISemver {
} }
/// @inheritdoc IFaultDisputeGame /// @inheritdoc IFaultDisputeGame
function addLocalData(uint256 _ident, uint256 _l2BlockNumber, uint256 _partOffset) external { function addLocalData(uint256 _ident, bytes32 _localContext, uint256 _partOffset) external {
// INVARIANT: Local data can only be added if the game is currently in progress. // INVARIANT: Local data can only be added if the game is currently in progress.
if (status != GameStatus.IN_PROGRESS) revert GameNotInProgress(); if (status != GameStatus.IN_PROGRESS) revert GameNotInProgress();
...@@ -293,7 +293,7 @@ contract FaultDisputeGame is IFaultDisputeGame, Clone, ISemver { ...@@ -293,7 +293,7 @@ contract FaultDisputeGame is IFaultDisputeGame, Clone, ISemver {
// Store the `_ident` argument // Store the `_ident` argument
mstore(0x20, _ident) mstore(0x20, _ident)
// Store the `_localContext` argument // Store the `_localContext` argument
mstore(0x40, _l2BlockNumber) mstore(0x40, _localContext)
// Store the data to load // Store the data to load
let data let data
switch _ident switch _ident
......
...@@ -35,7 +35,7 @@ interface IBigStepper { ...@@ -35,7 +35,7 @@ interface IBigStepper {
function step( function step(
bytes calldata _stateData, bytes calldata _stateData,
bytes calldata _proof, bytes calldata _proof,
uint256 _localContext bytes32 _localContext
) )
external external
returns (bytes32 postState_); returns (bytes32 postState_);
......
...@@ -70,10 +70,9 @@ interface IFaultDisputeGame is IDisputeGame { ...@@ -70,10 +70,9 @@ interface IFaultDisputeGame is IDisputeGame {
/// @notice Posts the requested local data to the VM's `PreimageOralce`. /// @notice Posts the requested local data to the VM's `PreimageOralce`.
/// @param _ident The local identifier of the data to post. /// @param _ident The local identifier of the data to post.
/// @param _l2BlockNumber The L2 block number being disputed. This serves as the local context for the /// @param _localContext The local context for the `PreimageOracle` key.
/// `PreimageOracle` key.
/// @param _partOffset The offset of the data to post. /// @param _partOffset The offset of the data to post.
function addLocalData(uint256 _ident, uint256 _l2BlockNumber, uint256 _partOffset) external; function addLocalData(uint256 _ident, bytes32 _localContext, uint256 _partOffset) external;
/// @notice Resolves the subgame rooted at the given claim index. /// @notice Resolves the subgame rooted at the given claim index.
/// @dev This function must be called bottom-up in the DAG /// @dev This function must be called bottom-up in the DAG
......
...@@ -484,7 +484,7 @@ contract FaultDisputeGame_Test is FaultDisputeGame_Init { ...@@ -484,7 +484,7 @@ contract FaultDisputeGame_Test is FaultDisputeGame_Init {
} }
/// @dev Tests that adding local data with an out of bounds identifier reverts. /// @dev Tests that adding local data with an out of bounds identifier reverts.
function testFuzz_addLocalData_oob_reverts(uint256 _ident, uint256 _localContext) public { function testFuzz_addLocalData_oob_reverts(uint256 _ident, bytes32 _localContext) public {
// [1, 5] are valid local data identifiers. // [1, 5] are valid local data identifiers.
if (_ident <= 5) _ident = 0; if (_ident <= 5) _ident = 0;
...@@ -529,7 +529,7 @@ contract FaultDisputeGame_Test is FaultDisputeGame_Init { ...@@ -529,7 +529,7 @@ contract FaultDisputeGame_Test is FaultDisputeGame_Init {
} }
/// @dev Helper to get the localized key for an identifier in the context of the game proxy. /// @dev Helper to get the localized key for an identifier in the context of the game proxy.
function _getKey(uint256 _ident, uint256 _localContext) internal view returns (bytes32) { function _getKey(uint256 _ident, bytes32 _localContext) internal view returns (bytes32) {
bytes32 h = keccak256(abi.encode(_ident | (1 << 248), address(gameProxy), _localContext)); bytes32 h = keccak256(abi.encode(_ident | (1 << 248), address(gameProxy), _localContext));
return bytes32((uint256(h) & ~uint256(0xFF << 248)) | (1 << 248)); return bytes32((uint256(h) & ~uint256(0xFF << 248)) | (1 << 248));
} }
......
...@@ -60,7 +60,7 @@ contract PreimageOracle_Test is Test { ...@@ -60,7 +60,7 @@ contract PreimageOracle_Test is Test {
for (uint256 i; i < words.length; i++) { for (uint256 i; i < words.length; i++) {
// Load the local data into the preimage oracle under the test contract's context // Load the local data into the preimage oracle under the test contract's context
// and the given local context. // and the given local context.
bytes32 contextKey = oracle.loadLocalData(ident, i, words[i], size, partOffset); bytes32 contextKey = oracle.loadLocalData(ident, bytes32(i), words[i], size, partOffset);
// Validate that the pre-image part is set // Validate that the pre-image part is set
bool ok = oracle.preimagePartOk(contextKey, partOffset); bool ok = oracle.preimagePartOk(contextKey, partOffset);
...@@ -79,7 +79,7 @@ contract PreimageOracle_Test is Test { ...@@ -79,7 +79,7 @@ contract PreimageOracle_Test is Test {
/// @notice Tests that context-specific data [0, 32] bytes in length can be loaded correctly. /// @notice Tests that context-specific data [0, 32] bytes in length can be loaded correctly.
function testFuzz_loadLocalData_varyingLength_succeeds( function testFuzz_loadLocalData_varyingLength_succeeds(
uint256 ident, uint256 ident,
uint256 localContext, bytes32 localContext,
bytes32 word, bytes32 word,
uint256 size, uint256 size,
uint256 partOffset uint256 partOffset
......
...@@ -17,7 +17,7 @@ contract AlphabetVM is IBigStepper { ...@@ -17,7 +17,7 @@ contract AlphabetVM is IBigStepper {
} }
/// @inheritdoc IBigStepper /// @inheritdoc IBigStepper
function step(bytes calldata _stateData, bytes calldata, uint256) external view returns (bytes32 postState_) { function step(bytes calldata _stateData, bytes calldata, bytes32) external view returns (bytes32 postState_) {
uint256 traceIndex; uint256 traceIndex;
uint256 claim; uint256 claim;
if ((keccak256(_stateData) << 8) == (Claim.unwrap(ABSOLUTE_PRESTATE) << 8)) { if ((keccak256(_stateData) << 8) == (Claim.unwrap(ABSOLUTE_PRESTATE) << 8)) {
......
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