Commit 713e73a7 authored by clabby's avatar clabby

Add `BlockHashOracle` binding

parent a0dbcce7
......@@ -33,6 +33,7 @@
"CrossDomainMessenger",
"MIPS",
"PreimageOracle",
"BlockHashOracle",
"EAS",
"SchemaRegistry"
]
// Code generated - DO NOT EDIT.
// This file is a generated binding and any manual changes will be lost.
package bindings
import (
"errors"
"math/big"
"strings"
ethereum "github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/accounts/abi"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/event"
)
// Reference imports to suppress errors if they are not otherwise used.
var (
_ = errors.New
_ = big.NewInt
_ = strings.NewReader
_ = ethereum.NotFound
_ = bind.Bind
_ = common.Big1
_ = types.BloomLookup
_ = event.NewSubscription
)
// BlockHashOracleMetaData contains all meta data concerning the BlockHashOracle contract.
var BlockHashOracleMetaData = &bind.MetaData{
ABI: "[{\"inputs\":[],\"name\":\"BlockHashNotPresent\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"BlockNumberOOB\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_blockNumber\",\"type\":\"uint256\"}],\"name\":\"load\",\"outputs\":[{\"internalType\":\"Hash\",\"name\":\"blockHash_\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_blockNumber\",\"type\":\"uint256\"}],\"name\":\"store\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]",
Bin: "0x608060405234801561001057600080fd5b50610134806100206000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c80636057361d1461003b57806399d548aa14610050575b600080fd5b61004e61004936600461010e565b610075565b005b61006361005e36600461010e565b6100c0565b60405190815260200160405180910390f35b8040806100ae576040517fd82756d800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60009182526020829052604090912055565b60008181526020819052604081205490819003610109576040517f37cf270500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b919050565b60006020828403121561012057600080fd5b503591905056fea164736f6c634300080f000a",
}
// BlockHashOracleABI is the input ABI used to generate the binding from.
// Deprecated: Use BlockHashOracleMetaData.ABI instead.
var BlockHashOracleABI = BlockHashOracleMetaData.ABI
// BlockHashOracleBin is the compiled bytecode used for deploying new contracts.
// Deprecated: Use BlockHashOracleMetaData.Bin instead.
var BlockHashOracleBin = BlockHashOracleMetaData.Bin
// DeployBlockHashOracle deploys a new Ethereum contract, binding an instance of BlockHashOracle to it.
func DeployBlockHashOracle(auth *bind.TransactOpts, backend bind.ContractBackend) (common.Address, *types.Transaction, *BlockHashOracle, error) {
parsed, err := BlockHashOracleMetaData.GetAbi()
if err != nil {
return common.Address{}, nil, nil, err
}
if parsed == nil {
return common.Address{}, nil, nil, errors.New("GetABI returned nil")
}
address, tx, contract, err := bind.DeployContract(auth, *parsed, common.FromHex(BlockHashOracleBin), backend)
if err != nil {
return common.Address{}, nil, nil, err
}
return address, tx, &BlockHashOracle{BlockHashOracleCaller: BlockHashOracleCaller{contract: contract}, BlockHashOracleTransactor: BlockHashOracleTransactor{contract: contract}, BlockHashOracleFilterer: BlockHashOracleFilterer{contract: contract}}, nil
}
// BlockHashOracle is an auto generated Go binding around an Ethereum contract.
type BlockHashOracle struct {
BlockHashOracleCaller // Read-only binding to the contract
BlockHashOracleTransactor // Write-only binding to the contract
BlockHashOracleFilterer // Log filterer for contract events
}
// BlockHashOracleCaller is an auto generated read-only Go binding around an Ethereum contract.
type BlockHashOracleCaller struct {
contract *bind.BoundContract // Generic contract wrapper for the low level calls
}
// BlockHashOracleTransactor is an auto generated write-only Go binding around an Ethereum contract.
type BlockHashOracleTransactor struct {
contract *bind.BoundContract // Generic contract wrapper for the low level calls
}
// BlockHashOracleFilterer is an auto generated log filtering Go binding around an Ethereum contract events.
type BlockHashOracleFilterer struct {
contract *bind.BoundContract // Generic contract wrapper for the low level calls
}
// BlockHashOracleSession is an auto generated Go binding around an Ethereum contract,
// with pre-set call and transact options.
type BlockHashOracleSession struct {
Contract *BlockHashOracle // Generic contract binding to set the session for
CallOpts bind.CallOpts // Call options to use throughout this session
TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session
}
// BlockHashOracleCallerSession is an auto generated read-only Go binding around an Ethereum contract,
// with pre-set call options.
type BlockHashOracleCallerSession struct {
Contract *BlockHashOracleCaller // Generic contract caller binding to set the session for
CallOpts bind.CallOpts // Call options to use throughout this session
}
// BlockHashOracleTransactorSession is an auto generated write-only Go binding around an Ethereum contract,
// with pre-set transact options.
type BlockHashOracleTransactorSession struct {
Contract *BlockHashOracleTransactor // Generic contract transactor binding to set the session for
TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session
}
// BlockHashOracleRaw is an auto generated low-level Go binding around an Ethereum contract.
type BlockHashOracleRaw struct {
Contract *BlockHashOracle // Generic contract binding to access the raw methods on
}
// BlockHashOracleCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract.
type BlockHashOracleCallerRaw struct {
Contract *BlockHashOracleCaller // Generic read-only contract binding to access the raw methods on
}
// BlockHashOracleTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract.
type BlockHashOracleTransactorRaw struct {
Contract *BlockHashOracleTransactor // Generic write-only contract binding to access the raw methods on
}
// NewBlockHashOracle creates a new instance of BlockHashOracle, bound to a specific deployed contract.
func NewBlockHashOracle(address common.Address, backend bind.ContractBackend) (*BlockHashOracle, error) {
contract, err := bindBlockHashOracle(address, backend, backend, backend)
if err != nil {
return nil, err
}
return &BlockHashOracle{BlockHashOracleCaller: BlockHashOracleCaller{contract: contract}, BlockHashOracleTransactor: BlockHashOracleTransactor{contract: contract}, BlockHashOracleFilterer: BlockHashOracleFilterer{contract: contract}}, nil
}
// NewBlockHashOracleCaller creates a new read-only instance of BlockHashOracle, bound to a specific deployed contract.
func NewBlockHashOracleCaller(address common.Address, caller bind.ContractCaller) (*BlockHashOracleCaller, error) {
contract, err := bindBlockHashOracle(address, caller, nil, nil)
if err != nil {
return nil, err
}
return &BlockHashOracleCaller{contract: contract}, nil
}
// NewBlockHashOracleTransactor creates a new write-only instance of BlockHashOracle, bound to a specific deployed contract.
func NewBlockHashOracleTransactor(address common.Address, transactor bind.ContractTransactor) (*BlockHashOracleTransactor, error) {
contract, err := bindBlockHashOracle(address, nil, transactor, nil)
if err != nil {
return nil, err
}
return &BlockHashOracleTransactor{contract: contract}, nil
}
// NewBlockHashOracleFilterer creates a new log filterer instance of BlockHashOracle, bound to a specific deployed contract.
func NewBlockHashOracleFilterer(address common.Address, filterer bind.ContractFilterer) (*BlockHashOracleFilterer, error) {
contract, err := bindBlockHashOracle(address, nil, nil, filterer)
if err != nil {
return nil, err
}
return &BlockHashOracleFilterer{contract: contract}, nil
}
// bindBlockHashOracle binds a generic wrapper to an already deployed contract.
func bindBlockHashOracle(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) {
parsed, err := abi.JSON(strings.NewReader(BlockHashOracleABI))
if err != nil {
return nil, err
}
return bind.NewBoundContract(address, parsed, caller, transactor, filterer), nil
}
// Call invokes the (constant) contract method with params as input values and
// sets the output to result. The result type might be a single field for simple
// returns, a slice of interfaces for anonymous returns and a struct for named
// returns.
func (_BlockHashOracle *BlockHashOracleRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error {
return _BlockHashOracle.Contract.BlockHashOracleCaller.contract.Call(opts, result, method, params...)
}
// Transfer initiates a plain transaction to move funds to the contract, calling
// its default method if one is available.
func (_BlockHashOracle *BlockHashOracleRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) {
return _BlockHashOracle.Contract.BlockHashOracleTransactor.contract.Transfer(opts)
}
// Transact invokes the (paid) contract method with params as input values.
func (_BlockHashOracle *BlockHashOracleRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) {
return _BlockHashOracle.Contract.BlockHashOracleTransactor.contract.Transact(opts, method, params...)
}
// Call invokes the (constant) contract method with params as input values and
// sets the output to result. The result type might be a single field for simple
// returns, a slice of interfaces for anonymous returns and a struct for named
// returns.
func (_BlockHashOracle *BlockHashOracleCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error {
return _BlockHashOracle.Contract.contract.Call(opts, result, method, params...)
}
// Transfer initiates a plain transaction to move funds to the contract, calling
// its default method if one is available.
func (_BlockHashOracle *BlockHashOracleTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) {
return _BlockHashOracle.Contract.contract.Transfer(opts)
}
// Transact invokes the (paid) contract method with params as input values.
func (_BlockHashOracle *BlockHashOracleTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) {
return _BlockHashOracle.Contract.contract.Transact(opts, method, params...)
}
// Load is a free data retrieval call binding the contract method 0x99d548aa.
//
// Solidity: function load(uint256 _blockNumber) view returns(bytes32 blockHash_)
func (_BlockHashOracle *BlockHashOracleCaller) Load(opts *bind.CallOpts, _blockNumber *big.Int) ([32]byte, error) {
var out []interface{}
err := _BlockHashOracle.contract.Call(opts, &out, "load", _blockNumber)
if err != nil {
return *new([32]byte), err
}
out0 := *abi.ConvertType(out[0], new([32]byte)).(*[32]byte)
return out0, err
}
// Load is a free data retrieval call binding the contract method 0x99d548aa.
//
// Solidity: function load(uint256 _blockNumber) view returns(bytes32 blockHash_)
func (_BlockHashOracle *BlockHashOracleSession) Load(_blockNumber *big.Int) ([32]byte, error) {
return _BlockHashOracle.Contract.Load(&_BlockHashOracle.CallOpts, _blockNumber)
}
// Load is a free data retrieval call binding the contract method 0x99d548aa.
//
// Solidity: function load(uint256 _blockNumber) view returns(bytes32 blockHash_)
func (_BlockHashOracle *BlockHashOracleCallerSession) Load(_blockNumber *big.Int) ([32]byte, error) {
return _BlockHashOracle.Contract.Load(&_BlockHashOracle.CallOpts, _blockNumber)
}
// Store is a paid mutator transaction binding the contract method 0x6057361d.
//
// Solidity: function store(uint256 _blockNumber) returns()
func (_BlockHashOracle *BlockHashOracleTransactor) Store(opts *bind.TransactOpts, _blockNumber *big.Int) (*types.Transaction, error) {
return _BlockHashOracle.contract.Transact(opts, "store", _blockNumber)
}
// Store is a paid mutator transaction binding the contract method 0x6057361d.
//
// Solidity: function store(uint256 _blockNumber) returns()
func (_BlockHashOracle *BlockHashOracleSession) Store(_blockNumber *big.Int) (*types.Transaction, error) {
return _BlockHashOracle.Contract.Store(&_BlockHashOracle.TransactOpts, _blockNumber)
}
// Store is a paid mutator transaction binding the contract method 0x6057361d.
//
// Solidity: function store(uint256 _blockNumber) returns()
func (_BlockHashOracle *BlockHashOracleTransactorSession) Store(_blockNumber *big.Int) (*types.Transaction, error) {
return _BlockHashOracle.Contract.Store(&_BlockHashOracle.TransactOpts, _blockNumber)
}
// 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
return common.Address{}, nil, nil, nil, err
}
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(
opts,
backend,
......@@ -35,6 +41,7 @@ func setupFaultDisputeGame() (common.Address, *bind.TransactOpts, *backends.Simu
uint64(604800), // 7 days
common.Address{0xdd}, // VM
common.Address{0xee}, // L2OutputOracle (Not used in Alphabet Game)
blockHashOracle, // Block hash oracle
)
if err != nil {
return common.Address{}, nil, nil, nil, err
......
......@@ -50,8 +50,20 @@ func deployDisputeGameContracts(require *require.Assertions, ctx context.Context
alphaVMAddr, err := bind.WaitDeployed(ctx, client, tx)
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
_, 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)
faultDisputeGameAddr, err := bind.WaitDeployed(ctx, client, tx)
require.NoError(err)
......
......@@ -33,7 +33,7 @@ const (
StatusDefenderWins
)
var alphaExtraData = common.Hex2Bytes("1000000000000000000000000000000000000000000000000000000000000000")
var alphaExtraData = common.Hex2Bytes("0x00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000")
var alphabetVMAbsolutePrestate = common.Hex2Bytes("0000000000000000000000000000000000000000000000000000000000000060")
var alphabetVMAbsolutePrestateClaim = crypto.Keccak256Hash(alphabetVMAbsolutePrestate)
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