Commit 4dc6aa8e authored by Mark Tyneway's avatar Mark Tyneway Committed by GitHub

op-chain-ops: decouple from bindings (#10466)

* op-chain-ops: decouple from bindings

Another commit that removes bindings from `op-chain-ops`.
The entire repo is very close to being completely decoupled
from having a global set of bindings. This does have a little
bit of code duplication, but it generally results in a more
simple layout.

Both the `crossdomain` and `upgrades` package end up with their
own `bindings` package. The `crossdomain` package is mostly
legacy but the `indexer` still depends on it. The `indexer`
is in maintenance mode, after reth exex it makes a lot of sense
to build indexers directly into reth. The `crossdomain` package
uses the bindings to migrate and serialize L1 to L2 cross domain
messages. These bindings never need to be updated.

The `upgrades` package has a justfile added that can be used to
regenerate the bindings. This makes it easier to generate bindings
based on a specific release. Previously the `upgrades` bindings
were coupled in a strange way and backwards compatibility
hacks needed to exist. Now the team working on upgrades can update
the bindings however they want so the proper upgrade can easily
be generated.

* upgrades: error case

Since the AddressList doesn't have the `DisputeGameFactory`
yet, it cannot be pulled into the upgrade scripts. Instead
return an error so that we MUST update it.

https://github.com/ethereum-optimism/superchain-registry/blob/110e744c97b4873384ad2da365c281639fc0668e/superchain/superchain.go#L194
parent 8ba51662
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
// Package crossdomain provides libraries useful for
// managing L1 <> L2 cross domain communication. This
// library is very low level and most users will not
// these abstractions directly. They were used for
// the migration to Bedrock from the legacy Optimism
// system. The bindings subpackage will never need
// to be updated as they are only used for the migration
// tooling.
package crossdomain
......@@ -6,8 +6,8 @@ import (
"fmt"
"math/big"
"github.com/ethereum-optimism/optimism/op-bindings/bindings"
"github.com/ethereum-optimism/optimism/op-bindings/predeploys"
"github.com/ethereum-optimism/optimism/op-chain-ops/crossdomain/bindings"
"github.com/ethereum/go-ethereum/accounts/abi"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
......
......@@ -9,9 +9,9 @@ import (
"strings"
"testing"
"github.com/ethereum-optimism/optimism/op-bindings/bindings"
"github.com/ethereum-optimism/optimism/op-bindings/predeploys"
"github.com/ethereum-optimism/optimism/op-chain-ops/crossdomain"
"github.com/ethereum-optimism/optimism/op-chain-ops/crossdomain/bindings"
"github.com/stretchr/testify/require"
"github.com/ethereum/go-ethereum/accounts/abi"
......
......@@ -4,8 +4,8 @@ import (
"fmt"
"math/big"
"github.com/ethereum-optimism/optimism/op-bindings/bindings"
"github.com/ethereum-optimism/optimism/op-bindings/predeploys"
"github.com/ethereum-optimism/optimism/op-chain-ops/crossdomain/bindings"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/params"
......
abis := '../packages/contracts-bedrock/snapshots/abi'
bindings-upgrades:
#!/usr/bin/env bash
set -euxo pipefail
build_abi() {
local lowercase=$(echo "$1" | awk '{print tolower($0)}')
abigen \
--abi "{{abis}}/$1.json" \
--pkg bindings \
--out "upgrades/bindings/$lowercase.go" \
--type $1
}
build_abi L1CrossDomainMessenger
build_abi L1ERC721Bridge
build_abi L1StandardBridge
build_abi L2OutputOracle
build_abi OptimismMintableERC20Factory
build_abi OptimismPortal
build_abi SystemConfig
#build_abi ISemver
build_abi ProxyAdmin
build_abi StorageSetter
// 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
)
// ISemverMetaData contains all meta data concerning the ISemver contract.
var ISemverMetaData = &bind.MetaData{
ABI: "[{\"type\":\"function\",\"name\":\"version\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"string\",\"internalType\":\"string\"}],\"stateMutability\":\"view\"}]",
}
// ISemverABI is the input ABI used to generate the binding from.
// Deprecated: Use ISemverMetaData.ABI instead.
var ISemverABI = ISemverMetaData.ABI
// ISemver is an auto generated Go binding around an Ethereum contract.
type ISemver struct {
ISemverCaller // Read-only binding to the contract
ISemverTransactor // Write-only binding to the contract
ISemverFilterer // Log filterer for contract events
}
// ISemverCaller is an auto generated read-only Go binding around an Ethereum contract.
type ISemverCaller struct {
contract *bind.BoundContract // Generic contract wrapper for the low level calls
}
// ISemverTransactor is an auto generated write-only Go binding around an Ethereum contract.
type ISemverTransactor struct {
contract *bind.BoundContract // Generic contract wrapper for the low level calls
}
// ISemverFilterer is an auto generated log filtering Go binding around an Ethereum contract events.
type ISemverFilterer struct {
contract *bind.BoundContract // Generic contract wrapper for the low level calls
}
// ISemverSession is an auto generated Go binding around an Ethereum contract,
// with pre-set call and transact options.
type ISemverSession struct {
Contract *ISemver // 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
}
// ISemverCallerSession is an auto generated read-only Go binding around an Ethereum contract,
// with pre-set call options.
type ISemverCallerSession struct {
Contract *ISemverCaller // Generic contract caller binding to set the session for
CallOpts bind.CallOpts // Call options to use throughout this session
}
// ISemverTransactorSession is an auto generated write-only Go binding around an Ethereum contract,
// with pre-set transact options.
type ISemverTransactorSession struct {
Contract *ISemverTransactor // Generic contract transactor binding to set the session for
TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session
}
// ISemverRaw is an auto generated low-level Go binding around an Ethereum contract.
type ISemverRaw struct {
Contract *ISemver // Generic contract binding to access the raw methods on
}
// ISemverCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract.
type ISemverCallerRaw struct {
Contract *ISemverCaller // Generic read-only contract binding to access the raw methods on
}
// ISemverTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract.
type ISemverTransactorRaw struct {
Contract *ISemverTransactor // Generic write-only contract binding to access the raw methods on
}
// NewISemver creates a new instance of ISemver, bound to a specific deployed contract.
func NewISemver(address common.Address, backend bind.ContractBackend) (*ISemver, error) {
contract, err := bindISemver(address, backend, backend, backend)
if err != nil {
return nil, err
}
return &ISemver{ISemverCaller: ISemverCaller{contract: contract}, ISemverTransactor: ISemverTransactor{contract: contract}, ISemverFilterer: ISemverFilterer{contract: contract}}, nil
}
// NewISemverCaller creates a new read-only instance of ISemver, bound to a specific deployed contract.
func NewISemverCaller(address common.Address, caller bind.ContractCaller) (*ISemverCaller, error) {
contract, err := bindISemver(address, caller, nil, nil)
if err != nil {
return nil, err
}
return &ISemverCaller{contract: contract}, nil
}
// NewISemverTransactor creates a new write-only instance of ISemver, bound to a specific deployed contract.
func NewISemverTransactor(address common.Address, transactor bind.ContractTransactor) (*ISemverTransactor, error) {
contract, err := bindISemver(address, nil, transactor, nil)
if err != nil {
return nil, err
}
return &ISemverTransactor{contract: contract}, nil
}
// NewISemverFilterer creates a new log filterer instance of ISemver, bound to a specific deployed contract.
func NewISemverFilterer(address common.Address, filterer bind.ContractFilterer) (*ISemverFilterer, error) {
contract, err := bindISemver(address, nil, nil, filterer)
if err != nil {
return nil, err
}
return &ISemverFilterer{contract: contract}, nil
}
// bindISemver binds a generic wrapper to an already deployed contract.
func bindISemver(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) {
parsed, err := abi.JSON(strings.NewReader(ISemverABI))
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 (_ISemver *ISemverRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error {
return _ISemver.Contract.ISemverCaller.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 (_ISemver *ISemverRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) {
return _ISemver.Contract.ISemverTransactor.contract.Transfer(opts)
}
// Transact invokes the (paid) contract method with params as input values.
func (_ISemver *ISemverRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) {
return _ISemver.Contract.ISemverTransactor.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 (_ISemver *ISemverCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error {
return _ISemver.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 (_ISemver *ISemverTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) {
return _ISemver.Contract.contract.Transfer(opts)
}
// Transact invokes the (paid) contract method with params as input values.
func (_ISemver *ISemverTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) {
return _ISemver.Contract.contract.Transact(opts, method, params...)
}
// Version is a free data retrieval call binding the contract method 0x54fd4d50.
//
// Solidity: function version() view returns(string)
func (_ISemver *ISemverCaller) Version(opts *bind.CallOpts) (string, error) {
var out []interface{}
err := _ISemver.contract.Call(opts, &out, "version")
if err != nil {
return *new(string), err
}
out0 := *abi.ConvertType(out[0], new(string)).(*string)
return out0, err
}
// Version is a free data retrieval call binding the contract method 0x54fd4d50.
//
// Solidity: function version() view returns(string)
func (_ISemver *ISemverSession) Version() (string, error) {
return _ISemver.Contract.Version(&_ISemver.CallOpts)
}
// Version is a free data retrieval call binding the contract method 0x54fd4d50.
//
// Solidity: function version() view returns(string)
func (_ISemver *ISemverCallerSession) Version() (string, error) {
return _ISemver.Contract.Version(&_ISemver.CallOpts)
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -5,7 +5,7 @@ import (
"fmt"
"strings"
"github.com/ethereum-optimism/optimism/op-bindings/bindings"
"github.com/ethereum-optimism/optimism/op-chain-ops/upgrades/bindings"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
......
// Package upgrades contains upgrade related tooling.
//
// JSON files that follow the Safe UI batch call format
// can be generated using this package. A bindings subpackage
// exists to decouple versioning of bindings with other packages.
// A just recipe exists to easily regenerate the bindings.
package upgrades
package upgrades
import (
"errors"
"fmt"
"math/big"
"os"
......@@ -9,10 +10,10 @@ import (
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum-optimism/optimism/op-bindings/bindings"
"github.com/ethereum-optimism/optimism/op-bindings/predeploys"
"github.com/ethereum-optimism/optimism/op-chain-ops/genesis"
"github.com/ethereum-optimism/optimism/op-chain-ops/safe"
"github.com/ethereum-optimism/optimism/op-chain-ops/upgrades/bindings"
"github.com/ethereum-optimism/superchain-registry/superchain"
)
......@@ -743,6 +744,10 @@ func SystemConfig(batch *safe.Batch, implementations superchain.ImplementationLi
return fmt.Errorf("DefaultResourceConfig MaximumBaseFee doesn't match contract MaximumBaseFee")
}
if true {
return errors.New("Update superchain-registry dependency to include DisputeGameFactory and GasPayingToken addresses")
}
calldata, err := systemConfigABI.Pack(
"initialize",
finalSystemOwner,
......@@ -757,6 +762,7 @@ func SystemConfig(batch *safe.Batch, implementations superchain.ImplementationLi
L1CrossDomainMessenger: common.Address(list.L1CrossDomainMessengerProxy),
L1ERC721Bridge: common.Address(list.L1ERC721BridgeProxy),
L1StandardBridge: common.Address(list.L1StandardBridgeProxy),
DisputeGameFactory: common.Address{},
OptimismPortal: common.Address(list.OptimismPortalProxy),
OptimismMintableERC20Factory: common.Address(list.OptimismMintableERC20FactoryProxy),
GasPayingToken: common.Address{},
......
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