Commit 713e73a7 authored by clabby's avatar clabby

Add `BlockHashOracle` binding

parent a0dbcce7
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
"CrossDomainMessenger", "CrossDomainMessenger",
"MIPS", "MIPS",
"PreimageOracle", "PreimageOracle",
"BlockHashOracle",
"EAS", "EAS",
"SchemaRegistry" "SchemaRegistry"
] ]
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 BlockHashOracleStorageLayoutJSON = "{\"storage\":[{\"astId\":1000,\"contract\":\"src/dispute/BlockHashOracle.sol:BlockHashOracle\",\"label\":\"blockHashes\",\"offset\":0,\"slot\":\"0\",\"type\":\"t_mapping(t_uint256,t_userDefinedValueType(Hash)1001)\"}],\"types\":{\"t_mapping(t_uint256,t_userDefinedValueType(Hash)1001)\":{\"encoding\":\"mapping\",\"label\":\"mapping(uint256 =\u003e Hash)\",\"numberOfBytes\":\"32\",\"key\":\"t_uint256\",\"value\":\"t_userDefinedValueType(Hash)1001\"},\"t_uint256\":{\"encoding\":\"inplace\",\"label\":\"uint256\",\"numberOfBytes\":\"32\"},\"t_userDefinedValueType(Hash)1001\":{\"encoding\":\"inplace\",\"label\":\"Hash\",\"numberOfBytes\":\"32\"}}}"
var BlockHashOracleStorageLayout = new(solc.StorageLayout)
var BlockHashOracleDeployedBin = "0x608060405234801561001057600080fd5b50600436106100365760003560e01c80636057361d1461003b57806399d548aa14610050575b600080fd5b61004e61004936600461010e565b610075565b005b61006361005e36600461010e565b6100c0565b60405190815260200160405180910390f35b8040806100ae576040517fd82756d800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60009182526020829052604090912055565b60008181526020819052604081205490819003610109576040517f37cf270500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b919050565b60006020828403121561012057600080fd5b503591905056fea164736f6c634300080f000a"
func init() {
if err := json.Unmarshal([]byte(BlockHashOracleStorageLayoutJSON), BlockHashOracleStorageLayout); err != nil {
panic(err)
}
layouts["BlockHashOracle"] = BlockHashOracleStorageLayout
deployedBytecodes["BlockHashOracle"] = BlockHashOracleDeployedBin
}
...@@ -27,6 +27,12 @@ func setupFaultDisputeGame() (common.Address, *bind.TransactOpts, *backends.Simu ...@@ -27,6 +27,12 @@ func setupFaultDisputeGame() (common.Address, *bind.TransactOpts, *backends.Simu
return common.Address{}, nil, nil, nil, err return common.Address{}, nil, nil, nil, err
} }
backend := backends.NewSimulatedBackend(core.GenesisAlloc{from: {Balance: big.NewInt(params.Ether)}}, 50_000_000) backend := backends.NewSimulatedBackend(core.GenesisAlloc{from: {Balance: big.NewInt(params.Ether)}}, 50_000_000)
blockHashOracle, _, _, err := bindings.DeployBlockHashOracle(opts, backend)
if err != nil {
return common.Address{}, nil, nil, nil, err
}
_, _, contract, err := bindings.DeployFaultDisputeGame( _, _, contract, err := bindings.DeployFaultDisputeGame(
opts, opts,
backend, backend,
...@@ -35,6 +41,7 @@ func setupFaultDisputeGame() (common.Address, *bind.TransactOpts, *backends.Simu ...@@ -35,6 +41,7 @@ func setupFaultDisputeGame() (common.Address, *bind.TransactOpts, *backends.Simu
uint64(604800), // 7 days uint64(604800), // 7 days
common.Address{0xdd}, // VM common.Address{0xdd}, // VM
common.Address{0xee}, // L2OutputOracle (Not used in Alphabet Game) common.Address{0xee}, // L2OutputOracle (Not used in Alphabet Game)
blockHashOracle, // Block hash oracle
) )
if err != nil { if err != nil {
return common.Address{}, nil, nil, nil, err return common.Address{}, nil, nil, nil, err
......
...@@ -50,8 +50,20 @@ func deployDisputeGameContracts(require *require.Assertions, ctx context.Context ...@@ -50,8 +50,20 @@ func deployDisputeGameContracts(require *require.Assertions, ctx context.Context
alphaVMAddr, err := bind.WaitDeployed(ctx, client, tx) alphaVMAddr, err := bind.WaitDeployed(ctx, client, tx)
require.NoError(err) require.NoError(err)
// Deploy the block hash oracle
_, tx, blockHashOracle, err := bindings.DeployBlockHashOracle(opts, client)
require.NoError(err)
blockHashOracleAddr, err := bind.WaitDeployed(ctx, client, tx)
require.NoError(err)
// Store the genesis block hash in the oracle
tx, err = blockHashOracle.Store(opts, big.NewInt(0))
require.NoError(err)
_, err = utils.WaitReceiptOK(ctx, client, tx.Hash())
require.NoError(err, "failed to store genesis block hash in oracle")
// Deploy the fault dispute game implementation // Deploy the fault dispute game implementation
_, tx, _, err = bindings.DeployFaultDisputeGame(opts, client, alphabetVMAbsolutePrestateClaim, big.NewInt(alphabetGameDepth), gameDuration, alphaVMAddr, common.Address{0xBE, 0xEF}) _, tx, _, err = bindings.DeployFaultDisputeGame(opts, client, alphabetVMAbsolutePrestateClaim, big.NewInt(alphabetGameDepth), gameDuration, alphaVMAddr, common.Address{0xBE, 0xEF}, blockHashOracleAddr)
require.NoError(err) require.NoError(err)
faultDisputeGameAddr, err := bind.WaitDeployed(ctx, client, tx) faultDisputeGameAddr, err := bind.WaitDeployed(ctx, client, tx)
require.NoError(err) require.NoError(err)
......
...@@ -33,7 +33,7 @@ const ( ...@@ -33,7 +33,7 @@ const (
StatusDefenderWins StatusDefenderWins
) )
var alphaExtraData = common.Hex2Bytes("1000000000000000000000000000000000000000000000000000000000000000") var alphaExtraData = common.Hex2Bytes("0x00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000")
var alphabetVMAbsolutePrestate = common.Hex2Bytes("0000000000000000000000000000000000000000000000000000000000000060") var alphabetVMAbsolutePrestate = common.Hex2Bytes("0000000000000000000000000000000000000000000000000000000000000060")
var alphabetVMAbsolutePrestateClaim = crypto.Keccak256Hash(alphabetVMAbsolutePrestate) var alphabetVMAbsolutePrestateClaim = crypto.Keccak256Hash(alphabetVMAbsolutePrestate)
var CorrectAlphabet = "abcdefghijklmnop" var CorrectAlphabet = "abcdefghijklmnop"
......
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