Skip to content

Commit

Permalink
op-bindings: bedrock go bindings (ethereum-optimism#2571)
Browse files Browse the repository at this point in the history
  • Loading branch information
protolambda authored May 17, 2022
1 parent ad6b5de commit a655fea
Show file tree
Hide file tree
Showing 32 changed files with 711 additions and 57 deletions.
11 changes: 10 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -385,13 +385,22 @@ jobs:
name: gas snapshot
command: forge snapshot
working_directory: contracts-bedrock

- run:
name: check go bindings
command: |
make && git diff --exit-code
working_directory: op-bindings

bedrock-go-tests:
docker:
- image: ethereumoptimism/go-builder:latest
steps:
- checkout
- run:
name: lint op-bindings
command: |
golangci-lint run -E goimports,sqlclosecheck,bodyclose,asciicheck,misspell ./...
working_directory: op-bindings
- run:
name: lint op-node
command: |
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,6 @@ packages/integration-tests-bedrock/artifacts
**/testdata/fuzz/

coverage.out

# Ignore bedrock go bindings local output files
op-bindings/bin
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ submodules:
fi
.PHONY: submodules

op-bindings:
make -C ./op-bindings
.PHONY: op-bindings

op-node:
make -C ./op-node op-node
.PHONY: op-node
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ root

~~ BEDROCK upgrade - Not production-ready yet, part of next major upgrade ~~
├── <a href="./contracts-bedrock">contracts-bedrock</a>: Bedrock smart contracts. To be merged with ./packages/contracts.
├── <a href="./op-bindings">op-bindings</a>: Go bindings for Bedrock smart contracts.
├── <a href="./op-batcher">op-batcher</a>: L2-Batch Submitter, submits bundles of batches to L1
├── <a href="./op-e2e">op-e2e</a>: End-to-End testing of all bedrock components in Go
├── <a href="./op-node">op-node</a>: rollup consensus-layer client.
Expand Down
8 changes: 4 additions & 4 deletions go.work
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use (
./l2geth
./l2geth-exporter
./op-batcher
./op-bindings
./op-e2e
./op-exporter
./op-node
Expand All @@ -16,8 +17,7 @@ use (
./teleportr
)

replace github.com/ethereum-optimism/optimism/bss-core v0.0.0 => ./bss-core
replace github.com/ethereum/go-ethereum v1.10.17 => github.com/ethereum-optimism/reference-optimistic-geth v0.0.0-20220512193241-32ef0bba48ce

replace github.com/ethereum-optimism/optimism/l2geth v0.0.0 => ./l2geth

replace github.com/ethereum/go-ethereum v1.10.16 => github.com/ethereum-optimism/reference-optimistic-geth v0.0.0-20220512193241-32ef0bba48ce
// For local debugging:
// replace github.com/ethereum/go-ethereum v1.10.17 => ../go-ethereum
12 changes: 10 additions & 2 deletions go.work.sum
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.0 h1:MSskdM4/xJYcFzy0altH/C/xHopifpWzHUi1JeVI34Q=
github.com/coreos/go-systemd v0.0.0-20181012123002-c6f51f82210d h1:t5Wuyh53qYyg9eqn4BbnlIT+vmhyww0TatL+zT3uWgI=
github.com/golang-jwt/jwt v3.2.2+incompatible h1:IfV12K8xAKAnZqdXVzCZ+TOjboZ2keLg81eXfW3O+oY=
github.com/cpuguy83/go-md2man v1.0.10 h1:BSKMNlYxDvnunlTymqtgONjNnaRV1sTpcovwwjF22jk=
github.com/ethereum-optimism/reference-optimistic-geth v0.0.0-20220512193241-32ef0bba48ce h1:Wa0BVNdeyzIoJkrZtI7o2NEw8F98vVIzkPpiFACbdCA=
github.com/ethereum-optimism/reference-optimistic-geth v0.0.0-20220512193241-32ef0bba48ce/go.mod h1:zwRwhzbX7GhQgG12DdrLr9aRGGLObKwmZxYrCLICIRc=
github.com/fjl/gencodec v0.0.0-20220412091415-8bb9e558978c/go.mod h1:AzA8Lj6YtixmJWL+wkKoBGsLWy9gFrAzi4g+5bCKwpY=
github.com/garslo/gogen v0.0.0-20170306192744-1d203ffc1f61/go.mod h1:Q0X6pkwTILDlzrGEckF6HKjXe48EgsY/l7K7vhY4MW8=
github.com/klauspost/cpuid v0.0.0-20170728055534-ae7887de9fa5 h1:2U0HzY8BJ8hVwDKIzp7y4voR9CX/nvcfymLmg2UiOio=
github.com/kylelemons/godebug v0.0.0-20170224010052-a616ab194758/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k=
github.com/libp2p/go-yamux v1.4.1 h1:P1Fe9vF4th5JOxxgQvfbOHkrGqIZniTLf+ddhZp8YTI=
github.com/onsi/ginkgo v1.10.3/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/russross/blackfriday v1.5.2 h1:HyvC0ARfnZBqnXwABFeSZHpKvJHJJfPz81GNueLj0oo=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/tools v0.0.0-20191126055441-b0650ceb63d9/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
6 changes: 4 additions & 2 deletions op-batcher/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.18
require (
github.com/ethereum-optimism/optimism/op-node v0.0.0
github.com/ethereum-optimism/optimism/op-proposer v0.0.0
github.com/ethereum/go-ethereum v1.10.16
github.com/ethereum/go-ethereum v1.10.17
github.com/miguelmota/go-ethereum-hdwallet v0.1.1
github.com/stretchr/testify v1.7.0
github.com/urfave/cli v1.22.5
Expand All @@ -29,6 +29,7 @@ require (
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect
github.com/docker/go-units v0.4.0 // indirect
github.com/elastic/gosigar v0.12.0 // indirect
github.com/ethereum-optimism/optimism/op-bindings v0.0.0 // indirect
github.com/fjl/memsize v0.0.1 // indirect
github.com/flynn/noise v1.0.0 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
Expand Down Expand Up @@ -154,8 +155,9 @@ require (
)

replace (
github.com/ethereum-optimism/optimism/op-bindings v0.0.0 => ../op-bindings
github.com/ethereum-optimism/optimism/op-node v0.0.0 => ../op-node
github.com/ethereum-optimism/optimism/op-proposer v0.0.0 => ../op-proposer
)

replace github.com/ethereum/go-ethereum v1.10.16 => github.com/ethereum-optimism/reference-optimistic-geth v0.0.0-20220427171107-d0070e0a6ead
replace github.com/ethereum/go-ethereum v1.10.17 => github.com/ethereum-optimism/reference-optimistic-geth v0.0.0-20220427171107-d0070e0a6ead
20 changes: 18 additions & 2 deletions op-node/contracts/Makefile → op-bindings/Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
SHELL := /bin/bash
CONTRACTS_PATH := "../../packages/contracts/"
CONTRACTS_PATH := "../contracts-bedrock/"


all: bindings deployed

bindings: bindings-l1-block-info bindings-optimism-portal bindings-L2ToL1MessagePasser
bindings: bindings-l1-block-info bindings-optimism-portal bindings-L2ToL1MessagePasser bindings-l2-output-oracle
deployed: deployed-bin-l1-block-info deployed-bin-optimism-portal deployed-bin-L2ToL1MessagePasser

# Deployed bindings are split because they depend on the bin file
Expand Down Expand Up @@ -83,3 +83,19 @@ bindings-optimism-portal:
--type OptimismPortal \
--out ./deposit/deposit_feed_raw.go



bindings-l2-output-oracle:
$(eval temp := $(shell mktemp -d))
$(eval cwd := $(shell pwd))
cd $(CONTRACTS_PATH); \
forge build \
&& forge inspect L2OutputOracle abi > $(temp)/L2OutputOracle.abi \
&& forge inspect L2OutputOracle bytecode > $(temp)/L2OutputOracle.bin \
&& forge inspect L2OutputOracle deployedBytecode > $(cwd)/bin/l2_output_oracle_deployed.hex
abigen \
--abi $(temp)/L2OutputOracle.abi \
--bin $(temp)/L2OutputOracle.bin \
--pkg l2oo \
--type L2OutputOracle \
--out ./l2oo/l2_output_oracle.go
File renamed without changes.
2 changes: 1 addition & 1 deletion op-node/contracts/doc.go → op-bindings/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ To regenerate the bindings, run `make`
The following programs are required: `jq`, `abigen`, and `solc` (at version 0.8.10)
*/

package contracts
package op_bindings
30 changes: 30 additions & 0 deletions op-bindings/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
module github.com/ethereum-optimism/optimism/op-bindings

go 1.18

require github.com/ethereum/go-ethereum v1.10.17

require (
github.com/VictoriaMetrics/fastcache v1.9.0 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.1.3 // indirect
github.com/deckarep/golang-set v1.8.0 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect
github.com/edsrzf/mmap-go v1.1.0 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/go-stack/stack v1.8.1 // indirect
github.com/golang-jwt/jwt/v4 v4.3.0 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/gorilla/websocket v1.5.0 // indirect
github.com/mattn/go-runewidth v0.0.13 // indirect
github.com/prometheus/tsdb v0.10.0 // indirect
github.com/rjeczalik/notify v0.9.2 // indirect
github.com/shirou/gopsutil v3.21.11+incompatible // indirect
github.com/tklauser/go-sysconf v0.3.10 // indirect
github.com/tklauser/numcpus v0.4.0 // indirect
github.com/yusufpapurcu/wmi v1.2.2 // indirect
golang.org/x/crypto v0.0.0-20220307211146-efcb8507fb70 // indirect
golang.org/x/sys v0.0.0-20220310020820-b874c991c1a5 // indirect
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect
)

replace github.com/ethereum/go-ethereum v1.10.17 => github.com/ethereum-optimism/reference-optimistic-geth v0.0.0-20220512193241-32ef0bba48ce
Loading

0 comments on commit a655fea

Please sign in to comment.