Commit 570941d7 authored by Matthew Slipper's avatar Matthew Slipper Committed by GitHub

Merge pull request #2816 from ethereum-optimism/develop

Develop -> Master
parents 645d26a7 00443af1
---
'@eth-optimism/common-ts': minor
---
Make typescript type more permissive for MetricsV2
---
'@eth-optimism/contracts-bedrock': patch
---
bedrock: ProxyAdmin rename OpenZeppelin proxy to ERC1967
---
'@eth-optimism/drippie-mon': patch
---
Fix release
---
'@eth-optimism/contracts-bedrock': patch
---
OZ Audit fixes with a Low or informational severity:
- Hardcode constant values
- Require that msg.value == \_amount on ETH withdrawals
- use \_from in place of msg.sender when applicable in internal functions
---
'@eth-optimism/common-ts': patch
---
Fix potential metrics DoS vector in recent commit to BSV2
---
'@eth-optimism/contracts-bedrock': patch
---
bedrock: Simplify ProxyAdmin static calls
---
'@eth-optimism/proxyd': patch
---
Use canned response for eth_accounts
---
'@eth-optimism/contracts-bedrock': minor
---
Replaces L2 timestamps with block numbers as the key in mapping(uint => OutputProposal).
---
'@eth-optimism/contracts-periphery': patch
---
Deploy NFT bridge contracts
---
'@eth-optimism/contracts-bedrock': patch
---
Fixes to medium severity OZ findings
- Disallow reentrant withdrawals
- remove donateEth
- Correct ordering of \_from and \_to arguments on refunds of failed deposits
---
'@eth-optimism/contracts-bedrock': patch
---
Have contracts-bedrock properly include contract sources in npm package
......@@ -226,7 +226,7 @@ jobs:
with:
context: .
file: ./ops/docker/Dockerfile.packages
target: relayer
target: fault-detector
push: true
tags: ethereumoptimism/fault-detector:${{ needs.canary-publish.outputs.canary-docker-tag }}
......@@ -253,7 +253,7 @@ jobs:
with:
context: .
file: ./ops/docker/Dockerfile.packages
target: relayer
target: drippie-mon
push: true
tags: ethereumoptimism/drippie-mon:${{ needs.canary-publish.outputs.canary-docker-tag }}
......
......@@ -18,7 +18,7 @@ use (
./state-surgery
)
replace github.com/ethereum/go-ethereum v1.10.17 => github.com/ethereum-optimism/reference-optimistic-geth v0.0.0-20220602230953-dd2e24b3359f
replace github.com/ethereum/go-ethereum v1.10.17 => github.com/ethereum-optimism/reference-optimistic-geth v0.0.0-20220616183505-9a67f31e4592
// For local debugging:
//replace github.com/ethereum/go-ethereum v1.10.17 => ../go-ethereum
github.com/btcsuite/btcd/btcec/v2 v2.1.3/go.mod h1:ctjw4H1kknNJmRN4iP1R7bTQ+v3GJkZBd6mui8ZsAZE=
github.com/coreos/go-systemd v0.0.0-20181012123002-c6f51f82210d h1:t5Wuyh53qYyg9eqn4BbnlIT+vmhyww0TatL+zT3uWgI=
github.com/ethereum-optimism/reference-optimistic-geth v0.0.0-20220602230953-dd2e24b3359f h1:Ad47wE5WEFzyOaaLff7LTRh79mUgWHKuYe4fpGOG23k=
github.com/ethereum-optimism/reference-optimistic-geth v0.0.0-20220602230953-dd2e24b3359f/go.mod h1:RD3NhcSBjZpj3k+SnQq24wBrmnmie78P5R/P62iNBD8=
github.com/ethereum-optimism/reference-optimistic-geth v0.0.0-20220616183505-9a67f31e4592 h1:o0iObEB8uMXiu0XdeODWsqbg5MSNhsFoM/a37szPVXs=
github.com/ethereum-optimism/reference-optimistic-geth v0.0.0-20220616183505-9a67f31e4592/go.mod h1:8AfU1epKggKxDt9wr7rH5KmCeiT3yT0sEvroru1mO6Q=
github.com/klauspost/cpuid v0.0.0-20170728055534-ae7887de9fa5 h1:2U0HzY8BJ8hVwDKIzp7y4voR9CX/nvcfymLmg2UiOio=
github.com/klauspost/cpuid v1.2.1 h1:vJi+O/nMdFt0vqm8NZBI6wzALWdA2X+egi0ogNyrC/w=
github.com/libp2p/go-yamux v1.4.1 h1:P1Fe9vF4th5JOxxgQvfbOHkrGqIZniTLf+ddhZp8YTI=
......@@ -160,4 +160,4 @@ replace (
github.com/ethereum-optimism/optimism/op-proposer v0.0.0 => ../op-proposer
)
replace github.com/ethereum/go-ethereum v1.10.17 => github.com/ethereum-optimism/reference-optimistic-geth v0.0.0-20220602230953-dd2e24b3359f
replace github.com/ethereum/go-ethereum v1.10.17 => github.com/ethereum-optimism/reference-optimistic-geth v0.0.0-20220616183505-9a67f31e4592
......@@ -205,7 +205,6 @@ github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 h1:YLtO71vCjJRCBcrPMtQ9nqBsqpA1
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeCxkaw7y45JueMRL4DIyJDKs=
github.com/decred/dcrd/lru v1.0.0/go.mod h1:mxKOwFd7lFjN2GZYsiz/ecgqR6kkYAl+0pz0tEMk218=
github.com/deepmap/oapi-codegen v1.6.0/go.mod h1:ryDa9AgbELGeB+YEXE1dR53yAjHwFvE9iAUlWl9Al3M=
github.com/deepmap/oapi-codegen v1.8.2/go.mod h1:YLgSKSDv/bZQB7N4ws6luhozi3cEdRktEqrX88CvjIw=
github.com/dgraph-io/badger v1.6.2 h1:mNw0qs90GVgGGWylh0umH5iag1j6n/PeJtNvL6KY/x8=
github.com/dgraph-io/badger v1.6.2/go.mod h1:JW2yswe3V058sS0kZ2h/AXeDSqFjxnZcRrVH//y2UQE=
github.com/dgraph-io/ristretto v0.0.2 h1:a5WaUrDa0qm0YrAAS1tUykT5El3kt62KNZZeMxQn3po=
......@@ -234,6 +233,7 @@ github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFP
github.com/eclipse/paho.mqtt.golang v1.2.0/go.mod h1:H9keYFcgq3Qr5OUJm/JZI/i6U7joQ8SYLhZwfeOo6Ts=
github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M=
github.com/edsrzf/mmap-go v1.1.0 h1:6EUwBLQ/Mcr1EYLE4Tn1VdW1A4ckqCQWZBw8Hr0kjpQ=
github.com/edsrzf/mmap-go v1.1.0/go.mod h1:19H/e8pUPLicwkyNgOykDXkJ9F0MHE+Z52B8EIth78Q=
github.com/elastic/gosigar v0.12.0 h1:AsdhYCJlTudhfOYQyFNgx+fIVTfrDO0V1ST0vHgiapU=
github.com/elastic/gosigar v0.12.0/go.mod h1:iXRIGg2tLnu7LBdpqzyQfGDEidKCfWcCMS0WKyPWoMs=
github.com/envoyproxy/go-control-plane v0.6.9/go.mod h1:SBwIajubJHhxtWwsL9s8ss4safvEdbitLhGGK48rN6g=
......@@ -243,8 +243,9 @@ github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1m
github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk=
github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.mod h1:hliV/p42l8fGbc6Y9bQ70uLwIvmJyVE5k4iMKlh8wCQ=
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/ethereum-optimism/reference-optimistic-geth v0.0.0-20220602230953-dd2e24b3359f h1:Ad47wE5WEFzyOaaLff7LTRh79mUgWHKuYe4fpGOG23k=
github.com/ethereum-optimism/reference-optimistic-geth v0.0.0-20220602230953-dd2e24b3359f/go.mod h1:RD3NhcSBjZpj3k+SnQq24wBrmnmie78P5R/P62iNBD8=
github.com/ethereum-optimism/optimism/op-bindings v0.0.0-20220614233543-0d8fa52afca2/go.mod h1:e9mMYiVsdJf9BI//FdaA77BwNNgNMR043JtB7CPXNxY=
github.com/ethereum-optimism/reference-optimistic-geth v0.0.0-20220616183505-9a67f31e4592 h1:o0iObEB8uMXiu0XdeODWsqbg5MSNhsFoM/a37szPVXs=
github.com/ethereum-optimism/reference-optimistic-geth v0.0.0-20220616183505-9a67f31e4592/go.mod h1:8AfU1epKggKxDt9wr7rH5KmCeiT3yT0sEvroru1mO6Q=
github.com/ethereum/go-ethereum v1.10.4/go.mod h1:nEE0TP5MtxGzOMd7egIrbPJMQBnhVU3ELNxhBglIzhg=
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
github.com/fjl/gencodec v0.0.0-20220412091415-8bb9e558978c/go.mod h1:AzA8Lj6YtixmJWL+wkKoBGsLWy9gFrAzi4g+5bCKwpY=
......@@ -266,7 +267,6 @@ github.com/garslo/gogen v0.0.0-20170306192744-1d203ffc1f61/go.mod h1:Q0X6pkwTILD
github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff/go.mod h1:x7DCsMOv1taUwEWCzT4cmDeAkigA5/QCwUodaVOe8Ww=
github.com/gballet/go-libpcsclite v0.0.0-20191108122812-4678299bea08 h1:f6D9Hr8xV8uYKlyuj8XIruxlh9WjVjdh1gIicAS7ays=
github.com/getkin/kin-openapi v0.53.0/go.mod h1:7Yn5whZr5kJi6t+kShccXS8ae1APpYTW6yheSwk8Yi4=
github.com/getkin/kin-openapi v0.61.0/go.mod h1:7Yn5whZr5kJi6t+kShccXS8ae1APpYTW6yheSwk8Yi4=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/gliderlabs/ssh v0.1.1/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0=
github.com/glycerine/go-unsnap-stream v0.0.0-20180323001048-9f0cb55181dd/go.mod h1:/20jfyN9Y5QPEAprSgKAUr+glWDY39ZiUEAYOEv5dsE=
......@@ -386,7 +386,6 @@ github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.1.5/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.2.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/googleapis/gax-go v2.0.0+incompatible/go.mod h1:SFVmujtThgffbyetf+mdk2eWhX2bMyUtNHzFKcPA9HY=
......@@ -462,7 +461,6 @@ github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod
github.com/influxdata/influxql v1.1.1-0.20200828144457-65d3ef77d385/go.mod h1:gHp9y86a/pxhjJ+zMjNXiQAA197Xk9wLxaz+fGG+kWk=
github.com/influxdata/line-protocol v0.0.0-20180522152040-32c6aa80de5e/go.mod h1:4kt73NQhadE3daL3WhR5EJ/J2ocX0PZzwxQ0gXJ7oFE=
github.com/influxdata/line-protocol v0.0.0-20200327222509-2487e7298839/go.mod h1:xaLFMmpvUxqXtVkUJfg9QmT88cDaCJ3ZKgdZ78oO8Qo=
github.com/influxdata/line-protocol v0.0.0-20210311194329-9aa0e372d097/go.mod h1:xaLFMmpvUxqXtVkUJfg9QmT88cDaCJ3ZKgdZ78oO8Qo=
github.com/influxdata/promql/v2 v2.12.0/go.mod h1:fxOPu+DY0bqCTCECchSRtWfc+0X19ybifQhZoQNF5D8=
github.com/influxdata/roaring v0.4.13-0.20180809181101-fc520f41fab6/go.mod h1:bSgUQ7q5ZLSO+bKBGqJiCBGAl+9DxyW63zLTujjUlOE=
github.com/influxdata/tdigest v0.0.0-20181121200506-bf2b5ad3c0a9/go.mod h1:Js0mqiSBE6Ffsg94weZZ2c+v/ciT8QRHFOap7EKDrR0=
......@@ -1365,6 +1363,7 @@ golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20210816183151-1e6c022a8912/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220204135822-1c1b9b1eba6a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220310020820-b874c991c1a5 h1:y/woIyUBFbpQGKS0u1aHF/40WUDnek3fPOyD08H5Vng=
......
SHELL := /bin/bash
all: bindings deployed
all: mkdir bindings deployed
bindings: l1block-bindings l2-to-l1-message-passer-bindings optimism-portal-bindings l2-output-oracle-bindings
deployed: l1-block-deployed optimism-portal-deployed l2-to-l1-message-passer-deployed
bindings: l1block-bindings l2-to-l1-message-passer-bindings optimism-portal-bindings l2-output-oracle-bindings gas-price-oracle-bindings
deployed: l1-block-deployed optimism-portal-deployed l2-to-l1-message-passer-deployed gas-price-oracle-deployed
l1-block-deployed: l1block-bindings
......@@ -15,6 +15,9 @@ optimism-portal-deployed: optimism-portal-bindings
l2-to-l1-message-passer-deployed: l2-to-l1-message-passer-bindings
./gen_deployed_bytecode.sh L2ToL1MessagePasser bindings
gas-price-oracle-deployed: gas-price-oracle-bindings
./gen_deployed_bytecode.sh GasPriceOracle bindings
l1block-bindings:
./gen_bindings.sh L1Block bindings
......@@ -27,3 +30,11 @@ optimism-portal-bindings:
l2-output-oracle-bindings:
./gen_bindings.sh L2OutputOracle bindings
gas-price-oracle-bindings:
./gen_bindings.sh GasPriceOracle bindings
mkdir:
mkdir -p bin bindings
clean:
rm -rf bin bindings
This diff is collapsed.
// Code generated - DO NOT EDIT.
// This file is a generated binding and any manual changes will be lost.
package bindings
var GasPriceOracleDeployedBin = "0x608060405234801561001057600080fd5b50600436106100ea5760003560e01c8063715018a61161008c578063de26c4a111610066578063de26c4a1146101a0578063f2fde38b146101b3578063f45e65d8146101c6578063fe173b971461014457600080fd5b8063715018a61461015d5780638c8885c8146101655780638da5cb5b1461017857600080fd5b806349948e0e116100c857806349948e0e14610129578063519b4bd31461013c5780636ef25c3a14610144578063704655971461014a57600080fd5b80630c18c162146100ef578063313ce5671461010b5780633577afc514610114575b600080fd5b6100f860035481565b6040519081526020015b60405180910390f35b6100f860055481565b6101276101223660046107c1565b6101cf565b005b6100f8610137366004610809565b610291565b6100f86102f1565b486100f8565b6101276101583660046107c1565b61037b565b610127610431565b6101276101733660046107c1565b6104be565b60005460405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610102565b6100f86101ae366004610809565b610574565b6101276101c13660046108d8565b61061c565b6100f860045481565b60005473ffffffffffffffffffffffffffffffffffffffff163314610255576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064015b60405180910390fd5b60038190556040518181527f32740b35c0ea213650f60d44366b4fb211c9033b50714e4a1d34e65d5beb9bb4906020015b60405180910390a150565b60008061029d83610574565b905060006102a96102f1565b6102b39083610944565b90506000600554600a6102c69190610aa3565b90506000600454836102d89190610944565b905060006102e68383610aaf565b979650505050505050565b600073420000000000000000000000000000000000001573ffffffffffffffffffffffffffffffffffffffff16635cf249696040518163ffffffff1660e01b8152600401602060405180830381865afa158015610352573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103769190610aea565b905090565b60005473ffffffffffffffffffffffffffffffffffffffff1633146103fc576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161024c565b60048190556040518181527f3336cd9708eaf2769a0f0dc0679f30e80f15dcd88d1921b5a16858e8b85c591a90602001610286565b60005473ffffffffffffffffffffffffffffffffffffffff1633146104b2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161024c565b6104bc600061074c565b565b60005473ffffffffffffffffffffffffffffffffffffffff16331461053f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161024c565b60058190556040518181527fd68112a8707e326d08be3656b528c1bcc5bbbfc47f4177e2179b14d8640838c190602001610286565b80516000908190815b818110156105f45784818151811061059757610597610b03565b01602001517fff00000000000000000000000000000000000000000000000000000000000000166105d4576105cd600484610b32565b92506105e2565b6105df601084610b32565b92505b806105ec81610b4a565b91505061057d565b506000600354836106059190610b32565b905061061381610440610b32565b95945050505050565b60005473ffffffffffffffffffffffffffffffffffffffff16331461069d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161024c565b73ffffffffffffffffffffffffffffffffffffffff8116610740576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015260840161024c565b6107498161074c565b50565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000602082840312156107d357600080fd5b5035919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60006020828403121561081b57600080fd5b813567ffffffffffffffff8082111561083357600080fd5b818401915084601f83011261084757600080fd5b813581811115610859576108596107da565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f0116810190838211818310171561089f5761089f6107da565b816040528281528760208487010111156108b857600080fd5b826020860160208301376000928101602001929092525095945050505050565b6000602082840312156108ea57600080fd5b813573ffffffffffffffffffffffffffffffffffffffff8116811461090e57600080fd5b9392505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff048311821515161561097c5761097c610915565b500290565b600181815b808511156109da57817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff048211156109c0576109c0610915565b808516156109cd57918102915b93841c9390800290610986565b509250929050565b6000826109f157506001610a9d565b816109fe57506000610a9d565b8160018114610a145760028114610a1e57610a3a565b6001915050610a9d565b60ff841115610a2f57610a2f610915565b50506001821b610a9d565b5060208310610133831016604e8410600b8410161715610a5d575081810a610a9d565b610a678383610981565b807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04821115610a9957610a99610915565b0290505b92915050565b600061090e83836109e2565b600082610ae5577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b600060208284031215610afc57600080fd5b5051919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60008219821115610b4557610b45610915565b500190565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415610b7c57610b7c610915565b506001019056fea164736f6c634300080a000a"
This diff is collapsed.
This diff is collapsed.
......@@ -5,18 +5,14 @@ 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.2.0 // 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
......@@ -27,4 +23,4 @@ require (
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-20220602230953-dd2e24b3359f
replace github.com/ethereum/go-ethereum v1.10.17 => github.com/ethereum-optimism/reference-optimistic-geth v0.0.0-20220616183505-9a67f31e4592
This diff is collapsed.
package predeploys
import "github.com/ethereum/go-ethereum/common"
const (
L2ToL1MessagePasser = "0x4200000000000000000000000000000000000000"
OVM_DeployerWhitelist = "0x4200000000000000000000000000000000000002"
......@@ -14,3 +16,18 @@ const (
L1Block = "0x4200000000000000000000000000000000000015"
GovernanceToken = "0x4200000000000000000000000000000000000042"
)
var (
L2ToL1MessagePasserAddr = common.HexToAddress(L2ToL1MessagePasser)
OVM_DeployerWhitelistAddr = common.HexToAddress(OVM_DeployerWhitelist)
OVM_ETHAddr = common.HexToAddress(OVM_ETH)
WETH9Addr = common.HexToAddress(WETH9)
L2CrossDomainMessengerAddr = common.HexToAddress(L2CrossDomainMessenger)
L2StandardBridgeAddr = common.HexToAddress(L2StandardBridge)
SequencerFeeVaultAddr = common.HexToAddress(SequencerFeeVault)
OptimismMintableTokenFactoryAddr = common.HexToAddress(OptimismMintableTokenFactory)
L1BlockNumberAddr = common.HexToAddress(L1BlockNumber)
OVM_GasPriceOracleAddr = common.HexToAddress(OVM_GasPriceOracle)
L1BlockAddr = common.HexToAddress(L1Block)
GovernanceTokenAddr = common.HexToAddress(GovernanceToken)
)
......@@ -167,4 +167,4 @@ replace (
github.com/ethereum-optimism/optimism/op-proposer v0.0.0 => ../op-proposer
)
replace github.com/ethereum/go-ethereum v1.10.17 => github.com/ethereum-optimism/reference-optimistic-geth v0.0.0-20220602230953-dd2e24b3359f
replace github.com/ethereum/go-ethereum v1.10.17 => github.com/ethereum-optimism/reference-optimistic-geth v0.0.0-20220616183505-9a67f31e4592
......@@ -205,7 +205,6 @@ github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 h1:YLtO71vCjJRCBcrPMtQ9nqBsqpA1
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeCxkaw7y45JueMRL4DIyJDKs=
github.com/decred/dcrd/lru v1.0.0/go.mod h1:mxKOwFd7lFjN2GZYsiz/ecgqR6kkYAl+0pz0tEMk218=
github.com/deepmap/oapi-codegen v1.6.0/go.mod h1:ryDa9AgbELGeB+YEXE1dR53yAjHwFvE9iAUlWl9Al3M=
github.com/deepmap/oapi-codegen v1.8.2/go.mod h1:YLgSKSDv/bZQB7N4ws6luhozi3cEdRktEqrX88CvjIw=
github.com/dgraph-io/badger v1.6.2 h1:mNw0qs90GVgGGWylh0umH5iag1j6n/PeJtNvL6KY/x8=
github.com/dgraph-io/badger v1.6.2/go.mod h1:JW2yswe3V058sS0kZ2h/AXeDSqFjxnZcRrVH//y2UQE=
github.com/dgraph-io/ristretto v0.0.2 h1:a5WaUrDa0qm0YrAAS1tUykT5El3kt62KNZZeMxQn3po=
......@@ -244,8 +243,9 @@ github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1m
github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk=
github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.mod h1:hliV/p42l8fGbc6Y9bQ70uLwIvmJyVE5k4iMKlh8wCQ=
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/ethereum-optimism/reference-optimistic-geth v0.0.0-20220602230953-dd2e24b3359f h1:Ad47wE5WEFzyOaaLff7LTRh79mUgWHKuYe4fpGOG23k=
github.com/ethereum-optimism/reference-optimistic-geth v0.0.0-20220602230953-dd2e24b3359f/go.mod h1:RD3NhcSBjZpj3k+SnQq24wBrmnmie78P5R/P62iNBD8=
github.com/ethereum-optimism/optimism/op-bindings v0.0.0-20220614233543-0d8fa52afca2/go.mod h1:e9mMYiVsdJf9BI//FdaA77BwNNgNMR043JtB7CPXNxY=
github.com/ethereum-optimism/reference-optimistic-geth v0.0.0-20220616183505-9a67f31e4592 h1:o0iObEB8uMXiu0XdeODWsqbg5MSNhsFoM/a37szPVXs=
github.com/ethereum-optimism/reference-optimistic-geth v0.0.0-20220616183505-9a67f31e4592/go.mod h1:8AfU1epKggKxDt9wr7rH5KmCeiT3yT0sEvroru1mO6Q=
github.com/ethereum/go-ethereum v1.10.4/go.mod h1:nEE0TP5MtxGzOMd7egIrbPJMQBnhVU3ELNxhBglIzhg=
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
github.com/fjl/gencodec v0.0.0-20220412091415-8bb9e558978c/go.mod h1:AzA8Lj6YtixmJWL+wkKoBGsLWy9gFrAzi4g+5bCKwpY=
......@@ -268,7 +268,6 @@ github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff/go.mod h1:x
github.com/gballet/go-libpcsclite v0.0.0-20191108122812-4678299bea08 h1:f6D9Hr8xV8uYKlyuj8XIruxlh9WjVjdh1gIicAS7ays=
github.com/gballet/go-libpcsclite v0.0.0-20191108122812-4678299bea08/go.mod h1:x7DCsMOv1taUwEWCzT4cmDeAkigA5/QCwUodaVOe8Ww=
github.com/getkin/kin-openapi v0.53.0/go.mod h1:7Yn5whZr5kJi6t+kShccXS8ae1APpYTW6yheSwk8Yi4=
github.com/getkin/kin-openapi v0.61.0/go.mod h1:7Yn5whZr5kJi6t+kShccXS8ae1APpYTW6yheSwk8Yi4=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/gliderlabs/ssh v0.1.1/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0=
github.com/glycerine/go-unsnap-stream v0.0.0-20180323001048-9f0cb55181dd/go.mod h1:/20jfyN9Y5QPEAprSgKAUr+glWDY39ZiUEAYOEv5dsE=
......@@ -388,7 +387,6 @@ github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.1.5/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.2.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/googleapis/gax-go v2.0.0+incompatible/go.mod h1:SFVmujtThgffbyetf+mdk2eWhX2bMyUtNHzFKcPA9HY=
......@@ -464,7 +462,6 @@ github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod
github.com/influxdata/influxql v1.1.1-0.20200828144457-65d3ef77d385/go.mod h1:gHp9y86a/pxhjJ+zMjNXiQAA197Xk9wLxaz+fGG+kWk=
github.com/influxdata/line-protocol v0.0.0-20180522152040-32c6aa80de5e/go.mod h1:4kt73NQhadE3daL3WhR5EJ/J2ocX0PZzwxQ0gXJ7oFE=
github.com/influxdata/line-protocol v0.0.0-20200327222509-2487e7298839/go.mod h1:xaLFMmpvUxqXtVkUJfg9QmT88cDaCJ3ZKgdZ78oO8Qo=
github.com/influxdata/line-protocol v0.0.0-20210311194329-9aa0e372d097/go.mod h1:xaLFMmpvUxqXtVkUJfg9QmT88cDaCJ3ZKgdZ78oO8Qo=
github.com/influxdata/promql/v2 v2.12.0/go.mod h1:fxOPu+DY0bqCTCECchSRtWfc+0X19ybifQhZoQNF5D8=
github.com/influxdata/roaring v0.4.13-0.20180809181101-fc520f41fab6/go.mod h1:bSgUQ7q5ZLSO+bKBGqJiCBGAl+9DxyW63zLTujjUlOE=
github.com/influxdata/tdigest v0.0.0-20181121200506-bf2b5ad3c0a9/go.mod h1:Js0mqiSBE6Ffsg94weZZ2c+v/ciT8QRHFOap7EKDrR0=
......@@ -1368,6 +1365,7 @@ golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20210816183151-1e6c022a8912/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220204135822-1c1b9b1eba6a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220310020820-b874c991c1a5 h1:y/woIyUBFbpQGKS0u1aHF/40WUDnek3fPOyD08H5Vng=
......
......@@ -52,10 +52,11 @@ func deriveAccount(w accounts.Wallet, path string) accounts.Account {
type L2OOContractConfig struct {
SubmissionFrequency *big.Int
L2StartTime *big.Int
L2BlockTime *big.Int
L2StartingBlock *big.Int
GenesisL2Output [32]byte
HistoricalTotalBlocks *big.Int
L2StartingTimeStamp *big.Int
L2BlockTime *big.Int
}
type DepositContractConfig struct {
......@@ -82,9 +83,11 @@ type SystemConfig struct {
JWTFilePath string
JWTSecret [32]byte
Nodes map[string]*rollupNode.Config // Per node config. Don't use populate rollup.Config
Loggers map[string]log.Logger
RollupConfig rollup.Config // Shared rollup configs
Nodes map[string]*rollupNode.Config // Per node config. Don't use populate rollup.Config
Loggers map[string]log.Logger
ProposerLogger log.Logger
BatcherLogger log.Logger
RollupConfig rollup.Config // Shared rollup configs
L1BlockTime uint64
......@@ -92,6 +95,9 @@ type SystemConfig struct {
// A nil map disables P2P completely.
// Any node name not in the topology will not have p2p enabled.
P2PTopology map[string][]string
BaseFeeRecipient common.Address
L1FeeRecipient common.Address
}
type System struct {
......@@ -234,7 +240,11 @@ func (cfg SystemConfig) start() (*System, error) {
}
l2Alloc[cfg.L1InfoPredeployAddress] = core.GenesisAccount{Code: common.FromHex(bindings.L1BlockDeployedBin), Balance: common.Big0}
l2Alloc[common.HexToAddress(predeploys.L2ToL1MessagePasser)] = core.GenesisAccount{Code: common.FromHex(bindings.L2ToL1MessagePasserDeployedBin), Balance: common.Big0}
l2Alloc[predeploys.L2ToL1MessagePasserAddr] = core.GenesisAccount{Code: common.FromHex(bindings.L2ToL1MessagePasserDeployedBin), Balance: common.Big0}
l2Alloc[predeploys.OVM_GasPriceOracleAddr] = core.GenesisAccount{Code: common.FromHex(bindings.GasPriceOracleDeployedBin), Balance: common.Big0, Storage: map[common.Hash]common.Hash{
// storage for GasPriceOracle to have transctorPath wallet as owner
common.BigToHash(big.NewInt(0)): common.HexToHash("0x8A0A996b22B103B500Cd0F20d62dF2Ba3364D295"),
}}
genesisTimestamp := uint64(time.Now().Unix())
......@@ -279,6 +289,11 @@ func (cfg SystemConfig) start() (*System, error) {
LondonBlock: common.Big0,
MergeForkBlock: common.Big0,
TerminalTotalDifficulty: common.Big0,
Optimism: &params.OptimismConfig{
Enabled: true,
BaseFeeRecipient: cfg.BaseFeeRecipient,
L1FeeRecipient: cfg.L1FeeRecipient,
},
},
Alloc: l2Alloc,
Difficulty: common.Big1,
......@@ -380,7 +395,9 @@ func (cfg SystemConfig) start() (*System, error) {
sys.cfg.RollupConfig.Genesis = sys.RolupGenesis
sys.cfg.RollupConfig.BatchSenderAddress = batchSubmitterAddr
sys.cfg.RollupConfig.P2PSequencerAddress = p2pSignerAddr
sys.cfg.L2OOCfg.L2StartTime = new(big.Int).SetUint64(l2GenesisTime)
sys.cfg.L2OOCfg.L2StartingBlock = new(big.Int).SetUint64(l2GenesisID.Number)
sys.cfg.L2OOCfg.L2StartingTimeStamp = new(big.Int).SetUint64(l2Genesis.Timestamp)
sys.cfg.L2OOCfg.L2BlockTime = new(big.Int).SetUint64(2)
// Deploy Deposit Contract
deployerPrivKey, err := sys.wallet.PrivateKey(accounts.Account{
......@@ -402,10 +419,11 @@ func (cfg SystemConfig) start() (*System, error) {
opts,
l1Client,
sys.cfg.L2OOCfg.SubmissionFrequency,
sys.cfg.L2OOCfg.L2BlockTime,
sys.cfg.L2OOCfg.GenesisL2Output,
sys.cfg.L2OOCfg.HistoricalTotalBlocks,
sys.cfg.L2OOCfg.L2StartTime,
sys.cfg.L2OOCfg.L2StartingBlock,
sys.cfg.L2OOCfg.L2StartingTimeStamp,
sys.cfg.L2OOCfg.L2BlockTime,
l2OutputSubmitterAddr,
)
sys.cfg.DepositCFG.L2Oracle = sys.L2OOContractAddr
......@@ -542,7 +560,7 @@ func (cfg SystemConfig) start() (*System, error) {
LogTerminal: true,
Mnemonic: sys.cfg.Mnemonic,
L2OutputHDPath: sys.cfg.L2OutputHDPath,
}, "", log.New())
}, "", cfg.ProposerLogger)
if err != nil {
return nil, fmt.Errorf("unable to setup l2 output submitter: %w", err)
}
......@@ -578,7 +596,7 @@ func (cfg SystemConfig) start() (*System, error) {
SequencerHistoryDBFilename: sys.sequencerHistoryDBFileName,
SequencerGenesisHash: sys.RolupGenesis.L2.Hash.String(),
SequencerBatchInboxAddress: sys.cfg.RollupConfig.BatchInboxAddress.String(),
}, "", log.New())
}, "", cfg.BatcherLogger)
if err != nil {
return nil, fmt.Errorf("failed to setup batch submitter: %w", err)
}
......
This diff is collapsed.
......@@ -172,7 +172,7 @@ require (
replace github.com/ethereum-optimism/optimism/op-bindings v0.0.0 => ../op-bindings
replace github.com/ethereum/go-ethereum v1.10.17 => github.com/ethereum-optimism/reference-optimistic-geth v0.0.0-20220602230953-dd2e24b3359f
replace github.com/ethereum/go-ethereum v1.10.17 => github.com/ethereum-optimism/reference-optimistic-geth v0.0.0-20220616183505-9a67f31e4592
replace github.com/ethereum-optimism/optimism/op-proposer v0.0.0 => ../op-proposer
......
This diff is collapsed.
......@@ -62,7 +62,7 @@ func (n *nodeAPI) OutputAtBlock(ctx context.Context, number rpc.BlockNumber) ([]
return nil, ethereum.NotFound
}
proof, err := n.client.GetProof(ctx, common.HexToAddress(predeploys.L2ToL1MessagePasser), toBlockNumArg(number))
proof, err := n.client.GetProof(ctx, predeploys.L2ToL1MessagePasserAddr, toBlockNumArg(number))
if err != nil {
n.log.Error("failed to get contract proof", "err", err)
return nil, err
......
......@@ -84,7 +84,7 @@ func TestOutputAtBlock(t *testing.T) {
l2Client := &mockL2Client{}
l2Client.mock.On("GetBlockHeader", "latest").Return(&header)
l2Client.mock.On("GetProof", common.HexToAddress(predeploys.L2ToL1MessagePasser), "latest").Return(&result)
l2Client.mock.On("GetProof", predeploys.L2ToL1MessagePasserAddr, "latest").Return(&result)
server, err := newRPCServer(context.Background(), rpcCfg, rollupCfg, l2Client, log, "0.0")
assert.NoError(t, err)
......
......@@ -17,7 +17,7 @@ var (
L1InfoFuncSignature = "setL1BlockValues(uint64,uint64,uint256,bytes32,uint64)"
L1InfoFuncBytes4 = crypto.Keccak256([]byte(L1InfoFuncSignature))[:4]
L1InfoDepositerAddress = common.HexToAddress("0xdeaddeaddeaddeaddeaddeaddeaddeaddead0001")
L1BlockAddress = common.HexToAddress(predeploys.L1Block)
L1BlockAddress = predeploys.L1BlockAddr
)
type L1Info interface {
......
......@@ -20,13 +20,13 @@ import (
"github.com/ethereum/go-ethereum/rpc"
)
// WaitForFinalizationPeriod waits until the timestamp has been submitted to the L2 Output Oracle on L1 and
// then waits for the finalization period to be up.
// WaitForFinalizationPeriod waits until there is OutputProof for an L2 block number larger than the supplied l2BlockNumber
// and that the output is finalized.
// This functions polls and can block for a very long time if used on mainnet.
// This returns the timestamp to use for the proof generation.
func WaitForFinalizationPeriod(ctx context.Context, client *ethclient.Client, portalAddr common.Address, timestamp uint64) (uint64, error) {
// This returns the block number to use for the proof generation.
func WaitForFinalizationPeriod(ctx context.Context, client *ethclient.Client, portalAddr common.Address, l2BlockNumber *big.Int) (uint64, error) {
l2BlockNumber = new(big.Int).Set(l2BlockNumber) // Don't clobber caller owned l2BlockNumber
opts := &bind.CallOpts{Context: ctx}
timestampBig := new(big.Int).SetUint64(timestamp)
portal, err := bindings.NewOptimismPortalCaller(portalAddr, client)
if err != nil {
......@@ -40,21 +40,32 @@ func WaitForFinalizationPeriod(ctx context.Context, client *ethclient.Client, po
if err != nil {
return 0, err
}
submissionInterval, err := l2OO.SUBMISSIONINTERVAL(opts)
if err != nil {
return 0, err
}
// Convert blockNumber to submission interval boundary
rem := new(big.Int)
l2BlockNumber, rem = l2BlockNumber.DivMod(l2BlockNumber, submissionInterval, rem)
if rem.Cmp(common.Big0) != 0 {
l2BlockNumber = l2BlockNumber.Add(l2BlockNumber, common.Big1)
}
l2BlockNumber = l2BlockNumber.Mul(l2BlockNumber, submissionInterval)
finalizationPeriod, err := portal.FINALIZATIONPERIODSECONDS(opts)
if err != nil {
return 0, err
}
next, err := l2OO.LatestBlockTimestamp(opts)
latest, err := l2OO.LatestBlockNumber(opts)
if err != nil {
return 0, err
}
// Now poll
// Now poll for the output to be submitted on chain
var ticker *time.Ticker
diff := new(big.Int).Sub(timestampBig, next)
if diff.Cmp(big.NewInt(60)) > 0 {
diff := new(big.Int).Sub(l2BlockNumber, latest)
if diff.Cmp(big.NewInt(10)) > 0 {
ticker = time.NewTicker(time.Minute)
} else {
ticker = time.NewTicker(time.Second)
......@@ -64,12 +75,12 @@ loop:
for {
select {
case <-ticker.C:
next, err = l2OO.LatestBlockTimestamp(opts)
latest, err = l2OO.LatestBlockNumber(opts)
if err != nil {
return 0, err
}
// Already passed next
if next.Cmp(timestampBig) > 0 {
// Already passed the submitted block (likely just equals rather than >= here).
if latest.Cmp(l2BlockNumber) >= 0 {
break loop
}
case <-ctx.Done():
......@@ -78,10 +89,13 @@ loop:
}
// Now wait for it to be finalized
output, err := l2OO.GetL2Output(opts, next)
output, err := l2OO.GetL2Output(opts, l2BlockNumber)
if err != nil {
return 0, err
}
if output.OutputRoot == [32]byte{} {
return 0, errors.New("empty output root. likely no proposal at timestamp")
}
targetTimestamp := new(big.Int).Add(output.Timestamp, finalizationPeriod)
targetTime := time.Unix(targetTimestamp.Int64(), 0)
// Assume clock is relatively correct
......@@ -96,7 +110,7 @@ loop:
return 0, err
}
if header.Time > targetTimestamp.Uint64() {
return next.Uint64(), nil
return l2BlockNumber.Uint64(), nil
}
case <-ctx.Done():
return 0, ctx.Err()
......@@ -131,21 +145,21 @@ func NewClient(client *rpc.Client) *Client {
}
// FinalizedWithdrawalParameters is the set of paramets to pass to the FinalizedWithdrawal function
// FinalizedWithdrawalParameters is the set of parameters to pass to the FinalizedWithdrawal function
type FinalizedWithdrawalParameters struct {
Nonce *big.Int
Sender common.Address
Target common.Address
Value *big.Int
GasLimit *big.Int
Timestamp *big.Int
BlockNumber *big.Int
Data []byte
OutputRootProof bindings.WithdrawalVerifierOutputRootProof
WithdrawalProof []byte // RLP Encoded list of trie nodes to prove L2 storage
}
// FinalizeWithdrawalParameters queries L2 to generate all withdrawal parameters and proof necessary to finalize an withdrawal on L1.
// The header provided is very imporant. It should be a block (timestamp) for which there is a submitted output in the L2 Output Oracle
// The header provided is very important. It should be a block (timestamp) for which there is a submitted output in the L2 Output Oracle
// contract. If not, the withdrawal will fail as it the storage proof cannot be verified if there is no submitted state root.
func FinalizeWithdrawalParameters(ctx context.Context, l2client ProofClient, txHash common.Hash, header *types.Header) (FinalizedWithdrawalParameters, error) {
// Transaction receipt
......@@ -164,7 +178,7 @@ func FinalizeWithdrawalParameters(ctx context.Context, l2client ProofClient, txH
return FinalizedWithdrawalParameters{}, err
}
slot := StorageSlotOfWithdrawalHash(withdrawalHash)
p, err := l2client.GetProof(ctx, common.HexToAddress(predeploys.L2ToL1MessagePasser), []string{slot.String()}, header.Number)
p, err := l2client.GetProof(ctx, predeploys.L2ToL1MessagePasserAddr, []string{slot.String()}, header.Number)
if err != nil {
return FinalizedWithdrawalParameters{}, err
}
......@@ -189,13 +203,13 @@ func FinalizeWithdrawalParameters(ctx context.Context, l2client ProofClient, txH
}
return FinalizedWithdrawalParameters{
Nonce: ev.Nonce,
Sender: ev.Sender,
Target: ev.Target,
Value: ev.Value,
GasLimit: ev.GasLimit,
Timestamp: new(big.Int).SetUint64(header.Time),
Data: ev.Data,
Nonce: ev.Nonce,
Sender: ev.Sender,
Target: ev.Target,
Value: ev.Value,
GasLimit: ev.GasLimit,
BlockNumber: new(big.Int).Set(header.Number),
Data: ev.Data,
OutputRootProof: bindings.WithdrawalVerifierOutputRootProof{
Version: [32]byte{}, // Empty for version 1
StateRoot: header.Root,
......
......@@ -95,58 +95,41 @@ func (d *Driver) GetBlockRange(
Context: ctx,
}
// Determine the next uncommitted L2 block number. We do so by transforming
// the timestamp of the latest committed L2 block into its block number and
// adding one.
l2ooTimestamp, err := d.l2ooContract.LatestBlockTimestamp(callOpts)
// Determine the last committed L2 Block Number
start, err := d.l2ooContract.LatestBlockNumber(callOpts)
if err != nil {
d.l.Error(name+" unable to get latest block timestamp", "err", err)
return nil, nil, err
}
start, err := d.l2ooContract.ComputeL2BlockNumber(callOpts, l2ooTimestamp)
if err != nil {
d.l.Error(name+" unable to compute latest l2 block number", "err", err)
d.l.Error(name+" unable to get latest block number", "err", err)
return nil, nil, err
}
start.Add(start, bigOne)
// Next we need to obtain the current timestamp and the next timestamp at
// which we will need to submit an L2 output. The former is done by simply
// adding the submission interval to the latest committed block's timestamp;
// the latter inspects the timestamp of the latest block.
nextTimestamp, err := d.l2ooContract.NextTimestamp(callOpts)
// Next determine the L2 block that we need to commit
nextBlockNumber, err := d.l2ooContract.NextBlockNumber(callOpts)
if err != nil {
d.l.Error(name+" unable to get next block timestamp", "err", err)
d.l.Error(name+" unable to get next block number", "err", err)
return nil, nil, err
}
latestHeader, err := d.cfg.L1Client.HeaderByNumber(ctx, nil)
latestHeader, err := d.cfg.L2Client.HeaderByNumber(ctx, nil)
if err != nil {
d.l.Error(name+" unable to retrieve latest header", "err", err)
return nil, nil, err
}
currentTimestamp := big.NewInt(int64(latestHeader.Time))
currentBlockNumber := big.NewInt(latestHeader.Number.Int64())
// If the submission window has yet to elapsed, we must wait before
// submitting our L2 output commitment. Return start as the end value which
// will signal that there is no work to be done.
if currentTimestamp.Cmp(nextTimestamp) < 0 {
// If we do not have the new L2 Block number
if currentBlockNumber.Cmp(nextBlockNumber) < 0 {
d.l.Info(name+" submission interval has not elapsed",
"currentTimestamp", currentTimestamp, "nextTimestamp", nextTimestamp)
"currentBlockNumber", currentBlockNumber, "nextBlockNumber", nextBlockNumber)
return start, start, nil
}
d.l.Info(name+" submission interval has elapsed",
"currentTimestamp", currentTimestamp, "nextTimestamp", nextTimestamp)
"currentBlockNumber", currentBlockNumber, "nextBlockNumber", nextBlockNumber)
// Otherwise the submission interval has elapsed. Transform the next
// expected timestamp into its L2 block number, and add one since end is
// exclusive.
end, err := d.l2ooContract.ComputeL2BlockNumber(callOpts, nextTimestamp)
if err != nil {
d.l.Error(name+" unable to compute next l2 block number", "err", err)
return nil, nil, err
}
end.Add(end, bigOne)
end := new(big.Int).Add(nextBlockNumber, bigOne)
return start, end, nil
}
......@@ -174,35 +157,11 @@ func (d *Driver) CraftTx(
return nil, err
}
// Fetch the next expected timestamp that we will submit along with the
// L2Output.
callOpts := &bind.CallOpts{
Pending: false,
Context: ctx,
}
timestamp, err := d.l2ooContract.NextTimestamp(callOpts)
if err != nil {
return nil, err
}
// Sanity check that we are submitting against the same expected timestamp.
expCheckpointBlock, err := d.l2ooContract.ComputeL2BlockNumber(
callOpts, timestamp,
)
if err != nil {
return nil, err
}
if nextCheckpointBlock.Cmp(expCheckpointBlock) != 0 {
return nil, fmt.Errorf("expected next checkpoint block to be %d, "+
"found %d", nextCheckpointBlock.Uint64(),
expCheckpointBlock.Uint64())
}
numElements := new(big.Int).Sub(start, end).Uint64()
d.l.Info(name+" checkpoint constructed", "start", start, "end", end,
"nonce", nonce, "blocks_committed", numElements, "checkpoint_block", nextCheckpointBlock)
header, err := d.cfg.L1Client.HeaderByNumber(ctx, nil)
l1Header, err := d.cfg.L1Client.HeaderByNumber(ctx, nil)
if err != nil {
return nil, fmt.Errorf("error resolving checkpoint block: %v", err)
}
......@@ -212,8 +171,8 @@ func (d *Driver) CraftTx(
return nil, fmt.Errorf("error resolving checkpoint block: %v", err)
}
if l2Header.Time != timestamp.Uint64() {
return nil, fmt.Errorf("invalid timestamp: next timestamp is %v, timestamp of block is %v", timestamp, l2Header.Time)
if l2Header.Number.Cmp(nextCheckpointBlock) != 0 {
return nil, fmt.Errorf("invalid blockNumber: next blockNumber is %v, blockNumber of block is %v", nextCheckpointBlock, l2Header.Number)
}
opts, err := bind.NewKeyedTransactorWithChainID(
......@@ -226,7 +185,7 @@ func (d *Driver) CraftTx(
opts.Nonce = nonce
opts.NoSend = true
return d.l2ooContract.AppendL2Output(opts, l2OutputRoot, timestamp, header.Hash(), header.Number)
return d.l2ooContract.AppendL2Output(opts, l2OutputRoot, nextCheckpointBlock, l1Header.Hash(), l1Header.Number)
}
// UpdateGasPrice signs an otherwise identical txn to the one provided but with
......
......@@ -158,4 +158,4 @@ replace github.com/ethereum-optimism/optimism/op-node v0.0.0 => ../op-node
replace github.com/ethereum-optimism/optimism/op-bindings v0.0.0 => ../op-bindings
replace github.com/ethereum/go-ethereum v1.10.17 => github.com/ethereum-optimism/reference-optimistic-geth v0.0.0-20220602230953-dd2e24b3359f
replace github.com/ethereum/go-ethereum v1.10.17 => github.com/ethereum-optimism/reference-optimistic-geth v0.0.0-20220616183505-9a67f31e4592
......@@ -205,7 +205,6 @@ github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 h1:YLtO71vCjJRCBcrPMtQ9nqBsqpA1
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeCxkaw7y45JueMRL4DIyJDKs=
github.com/decred/dcrd/lru v1.0.0/go.mod h1:mxKOwFd7lFjN2GZYsiz/ecgqR6kkYAl+0pz0tEMk218=
github.com/deepmap/oapi-codegen v1.6.0/go.mod h1:ryDa9AgbELGeB+YEXE1dR53yAjHwFvE9iAUlWl9Al3M=
github.com/deepmap/oapi-codegen v1.8.2/go.mod h1:YLgSKSDv/bZQB7N4ws6luhozi3cEdRktEqrX88CvjIw=
github.com/dgraph-io/badger v1.6.2 h1:mNw0qs90GVgGGWylh0umH5iag1j6n/PeJtNvL6KY/x8=
github.com/dgraph-io/badger v1.6.2/go.mod h1:JW2yswe3V058sS0kZ2h/AXeDSqFjxnZcRrVH//y2UQE=
github.com/dgraph-io/ristretto v0.0.2 h1:a5WaUrDa0qm0YrAAS1tUykT5El3kt62KNZZeMxQn3po=
......@@ -234,6 +233,7 @@ github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFP
github.com/eclipse/paho.mqtt.golang v1.2.0/go.mod h1:H9keYFcgq3Qr5OUJm/JZI/i6U7joQ8SYLhZwfeOo6Ts=
github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M=
github.com/edsrzf/mmap-go v1.1.0 h1:6EUwBLQ/Mcr1EYLE4Tn1VdW1A4ckqCQWZBw8Hr0kjpQ=
github.com/edsrzf/mmap-go v1.1.0/go.mod h1:19H/e8pUPLicwkyNgOykDXkJ9F0MHE+Z52B8EIth78Q=
github.com/elastic/gosigar v0.12.0 h1:AsdhYCJlTudhfOYQyFNgx+fIVTfrDO0V1ST0vHgiapU=
github.com/elastic/gosigar v0.12.0/go.mod h1:iXRIGg2tLnu7LBdpqzyQfGDEidKCfWcCMS0WKyPWoMs=
github.com/envoyproxy/go-control-plane v0.6.9/go.mod h1:SBwIajubJHhxtWwsL9s8ss4safvEdbitLhGGK48rN6g=
......@@ -243,8 +243,9 @@ github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1m
github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk=
github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.mod h1:hliV/p42l8fGbc6Y9bQ70uLwIvmJyVE5k4iMKlh8wCQ=
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/ethereum-optimism/reference-optimistic-geth v0.0.0-20220602230953-dd2e24b3359f h1:Ad47wE5WEFzyOaaLff7LTRh79mUgWHKuYe4fpGOG23k=
github.com/ethereum-optimism/reference-optimistic-geth v0.0.0-20220602230953-dd2e24b3359f/go.mod h1:RD3NhcSBjZpj3k+SnQq24wBrmnmie78P5R/P62iNBD8=
github.com/ethereum-optimism/optimism/op-bindings v0.0.0-20220614233543-0d8fa52afca2/go.mod h1:e9mMYiVsdJf9BI//FdaA77BwNNgNMR043JtB7CPXNxY=
github.com/ethereum-optimism/reference-optimistic-geth v0.0.0-20220616183505-9a67f31e4592 h1:o0iObEB8uMXiu0XdeODWsqbg5MSNhsFoM/a37szPVXs=
github.com/ethereum-optimism/reference-optimistic-geth v0.0.0-20220616183505-9a67f31e4592/go.mod h1:8AfU1epKggKxDt9wr7rH5KmCeiT3yT0sEvroru1mO6Q=
github.com/ethereum/go-ethereum v1.10.4/go.mod h1:nEE0TP5MtxGzOMd7egIrbPJMQBnhVU3ELNxhBglIzhg=
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
github.com/fjl/gencodec v0.0.0-20220412091415-8bb9e558978c/go.mod h1:AzA8Lj6YtixmJWL+wkKoBGsLWy9gFrAzi4g+5bCKwpY=
......@@ -266,7 +267,6 @@ github.com/garslo/gogen v0.0.0-20170306192744-1d203ffc1f61/go.mod h1:Q0X6pkwTILD
github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff/go.mod h1:x7DCsMOv1taUwEWCzT4cmDeAkigA5/QCwUodaVOe8Ww=
github.com/gballet/go-libpcsclite v0.0.0-20191108122812-4678299bea08 h1:f6D9Hr8xV8uYKlyuj8XIruxlh9WjVjdh1gIicAS7ays=
github.com/getkin/kin-openapi v0.53.0/go.mod h1:7Yn5whZr5kJi6t+kShccXS8ae1APpYTW6yheSwk8Yi4=
github.com/getkin/kin-openapi v0.61.0/go.mod h1:7Yn5whZr5kJi6t+kShccXS8ae1APpYTW6yheSwk8Yi4=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/gliderlabs/ssh v0.1.1/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0=
github.com/glycerine/go-unsnap-stream v0.0.0-20180323001048-9f0cb55181dd/go.mod h1:/20jfyN9Y5QPEAprSgKAUr+glWDY39ZiUEAYOEv5dsE=
......@@ -386,7 +386,6 @@ github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.1.5/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.2.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/googleapis/gax-go v2.0.0+incompatible/go.mod h1:SFVmujtThgffbyetf+mdk2eWhX2bMyUtNHzFKcPA9HY=
......@@ -462,7 +461,6 @@ github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod
github.com/influxdata/influxql v1.1.1-0.20200828144457-65d3ef77d385/go.mod h1:gHp9y86a/pxhjJ+zMjNXiQAA197Xk9wLxaz+fGG+kWk=
github.com/influxdata/line-protocol v0.0.0-20180522152040-32c6aa80de5e/go.mod h1:4kt73NQhadE3daL3WhR5EJ/J2ocX0PZzwxQ0gXJ7oFE=
github.com/influxdata/line-protocol v0.0.0-20200327222509-2487e7298839/go.mod h1:xaLFMmpvUxqXtVkUJfg9QmT88cDaCJ3ZKgdZ78oO8Qo=
github.com/influxdata/line-protocol v0.0.0-20210311194329-9aa0e372d097/go.mod h1:xaLFMmpvUxqXtVkUJfg9QmT88cDaCJ3ZKgdZ78oO8Qo=
github.com/influxdata/promql/v2 v2.12.0/go.mod h1:fxOPu+DY0bqCTCECchSRtWfc+0X19ybifQhZoQNF5D8=
github.com/influxdata/roaring v0.4.13-0.20180809181101-fc520f41fab6/go.mod h1:bSgUQ7q5ZLSO+bKBGqJiCBGAl+9DxyW63zLTujjUlOE=
github.com/influxdata/tdigest v0.0.0-20181121200506-bf2b5ad3c0a9/go.mod h1:Js0mqiSBE6Ffsg94weZZ2c+v/ciT8QRHFOap7EKDrR0=
......@@ -1366,6 +1364,7 @@ golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20210816183151-1e6c022a8912/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220204135822-1c1b9b1eba6a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220310020820-b874c991c1a5 h1:y/woIyUBFbpQGKS0u1aHF/40WUDnek3fPOyD08H5Vng=
......
......@@ -28,6 +28,7 @@ COPY packages/hardhat-deploy-config/package.json ./packages/hardhat-deploy-confi
COPY packages/message-relayer/package.json ./packages/message-relayer/package.json
COPY packages/fault-detector/package.json ./packages/fault-detector/package.json
COPY packages/replica-healthcheck/package.json ./packages/replica-healthcheck/package.json
COPY packages/drippie-mon/package.json ./packages/drippie-mon/package.json
COPY integration-tests/package.json ./integration-tests/package.json
RUN yarn install --frozen-lockfile && yarn cache clean
......@@ -72,3 +73,7 @@ CMD ["npm", "run", "start"]
FROM base as replica-healthcheck
WORKDIR /opt/optimism/packages/replica-healthcheck
ENTRYPOINT ["npm", "run", "start"]
FROM base as drippie-mon
WORKDIR /opt/optimism/packages/drippie-mon
ENTRYPOINT ["npm", "run", "start"]
......@@ -34,9 +34,7 @@ export type OptionsSpec<TOptions extends Options> = {
}
}
export type MetricsV2 = {
[key: string]: Metric
}
export type MetricsV2 = Record<any, Metric>
export type StandardMetrics = {
metadata: Gauge
......@@ -402,6 +400,19 @@ export abstract class BaseServiceV2<
})
)
// Health status.
app.get('/healthz', async (req, res) => {
return res.json({
ok: this.healthy,
})
})
// Register user routes.
const router = express.Router()
if (this.routes) {
this.routes(router)
}
// Metrics.
// Will expose a /metrics endpoint by default.
app.use(
......@@ -410,22 +421,19 @@ export abstract class BaseServiceV2<
includeMethod: true,
includePath: true,
includeStatusCode: true,
normalizePath: (req) => {
for (const layer of router.stack) {
if (layer.route && req.path.match(layer.regexp)) {
return layer.route.path
}
}
return '/invalid_path_not_a_real_route'
}
})
)
// Health status.
app.get('/healthz', async (req, res) => {
return res.json({
ok: this.healthy,
})
})
// Registery user routes.
if (this.routes) {
const router = express.Router()
this.routes(router)
app.use('/api', router)
}
app.use('/api', router)
// Wait for server to come up.
await new Promise((resolve) => {
......
This diff is collapsed.
......@@ -67,6 +67,16 @@ contract OptimismPortal is ResourceMetering {
*/
address public l2Sender = DEFAULT_L2_SENDER;
/**
* @notice The L2 gas limit set when eth is deposited using the receive() function.
*/
uint64 internal constant RECEIVE_DEFAULT_GAS_LIMIT = 100_000;
/**
* @notice Additional gas reserved for clean up after finalizing a transaction withdrawal.
*/
uint256 internal constant FINALIZE_GAS_BUFFER = 20_000;
/**
* @notice A list of withdrawal hashes which have been successfully finalized.
*/
......@@ -84,10 +94,11 @@ contract OptimismPortal is ResourceMetering {
/**
* @notice Accepts value so that users can send ETH directly to this contract and have the
* funds be deposited to their address on L2. This is intended as a convenience
* function for EOAs. Contracts should call the depositTransaction() function directly.
* function for EOAs. Contracts should call the depositTransaction() function directly
* otherwise any deposited funds will be lost due to address aliasing.
*/
receive() external payable {
depositTransaction(msg.sender, msg.value, 100000, false, bytes(""));
depositTransaction(msg.sender, msg.value, RECEIVE_DEFAULT_GAS_LIMIT, false, bytes(""));
}
/**
......@@ -139,7 +150,7 @@ contract OptimismPortal is ResourceMetering {
* @param _value ETH to send to the target.
* @param _gasLimit Minumum gas to be forwarded to the target.
* @param _data Data to send to the target.
* @param _l2Timestamp L2 timestamp of the outputRoot.
* @param _l2BlockNumber L2 block number of the outputRoot.
* @param _outputRootProof Inclusion proof of the withdrawer contracts storage root.
* @param _withdrawalProof Inclusion proof for the given withdrawal in the withdrawer contract.
*/
......@@ -150,11 +161,11 @@ contract OptimismPortal is ResourceMetering {
uint256 _value,
uint256 _gasLimit,
bytes calldata _data,
uint256 _l2Timestamp,
uint256 _l2BlockNumber,
WithdrawalVerifier.OutputRootProof calldata _outputRootProof,
bytes calldata _withdrawalProof
) external payable {
// Prevent reentrancy.
// Prevent nested withdrawals within withdrawals.
require(
l2Sender == DEFAULT_L2_SENDER,
"OptimismPortal: can only trigger one withdrawal per transaction"
......@@ -168,7 +179,7 @@ contract OptimismPortal is ResourceMetering {
);
// Get the output root.
L2OutputOracle.OutputProposal memory proposal = L2_ORACLE.getL2Output(_l2Timestamp);
L2OutputOracle.OutputProposal memory proposal = L2_ORACLE.getL2Output(_l2BlockNumber);
// Ensure that enough time has passed since the proposal was submitted before allowing a
// withdrawal. Under the assumption that the fault proof mechanism is operating correctly,
......@@ -221,7 +232,7 @@ contract OptimismPortal is ResourceMetering {
// target contract is at least the gas limit specified by the user. We can do this by
// enforcing that, at this point in time, we still have gaslimit + buffer gas available.
require(
gasleft() >= _gasLimit + 20000,
gasleft() >= _gasLimit + FINALIZE_GAS_BUFFER,
"OptimismPortal: insufficient gas to finalize withdrawal"
);
......
......@@ -11,18 +11,23 @@ import { OptimismMintableERC20 } from "../universal/OptimismMintableERC20.sol";
* @title L2StandardBridge
* @notice The L2StandardBridge is responsible for transfering ETH and ERC20 tokens between L1 and
* L2. ERC20 tokens sent to L1 are escrowed within this contract.
* Note that this contract is not intended to support all variations of ERC20 tokens.
* Examples of some token types that may not be properly supported by this contract include,
* but are not limited to: tokens with transfer fees, rebasing tokens, and
* tokens with blocklists.
* TODO: ensure that this has 1:1 backwards compatibility
*/
contract L2StandardBridge is StandardBridge {
/**
* @custom:legacy
* @notice Emitted whenever a withdrawal from L2 to L1 is initiated.
*
* @param _l1Token Address of the token on L1.
* @param _l2Token Address of the corresponding token on L2.
* @param _from Address of the withdrawer.
* @param _to Address of the recipient on L1.
* @param _amount Amount of the ERC20 withdrawn.
* @param _data Extra data attached to the withdrawal.
* @param _l1Token Address of the token on L1.
* @param _l2Token Address of the corresponding token on L2.
* @param _from Address of the withdrawer.
* @param _to Address of the recipient on L1.
* @param _amount Amount of the ERC20 withdrawn.
* @param _extraData Extra data attached to the withdrawal.
*/
event WithdrawalInitiated(
address indexed _l1Token,
......@@ -30,19 +35,19 @@ contract L2StandardBridge is StandardBridge {
address indexed _from,
address _to,
uint256 _amount,
bytes _data
bytes _extraData
);
/**
* @custom:legacy
* @notice Emitted whenever an ERC20 deposit is finalized.
*
* @param _l1Token Address of the token on L1.
* @param _l2Token Address of the corresponding token on L2.
* @param _from Address of the depositor.
* @param _to Address of the recipient on L2.
* @param _amount Amount of the ERC20 deposited.
* @param _data Extra data attached to the deposit.
* @param _l1Token Address of the token on L1.
* @param _l2Token Address of the corresponding token on L2.
* @param _from Address of the depositor.
* @param _to Address of the recipient on L2.
* @param _amount Amount of the ERC20 deposited.
* @param _extraData Extra data attached to the deposit.
*/
event DepositFinalized(
address indexed _l1Token,
......@@ -50,19 +55,19 @@ contract L2StandardBridge is StandardBridge {
address indexed _from,
address _to,
uint256 _amount,
bytes _data
bytes _extraData
);
/**
* @custom:legacy
* @notice Emitted whenever a deposit fails.
*
* @param _l1Token Address of the token on L1.
* @param _l2Token Address of the corresponding token on L2.
* @param _from Address of the depositor.
* @param _to Address of the recipient on L2.
* @param _amount Amount of the ERC20 deposited.
* @param _data Extra data attached to the deposit.
* @param _l1Token Address of the token on L1.
* @param _l2Token Address of the corresponding token on L2.
* @param _from Address of the depositor.
* @param _to Address of the recipient on L2.
* @param _amount Amount of the ERC20 deposited.
* @param _extraData Extra data attached to the deposit.
*/
event DepositFailed(
address indexed _l1Token,
......@@ -70,7 +75,7 @@ contract L2StandardBridge is StandardBridge {
address indexed _from,
address _to,
uint256 _amount,
bytes _data
bytes _extraData
);
/**
......@@ -89,47 +94,51 @@ contract L2StandardBridge is StandardBridge {
* @param _l2Token Address of the L2 token to withdraw.
* @param _amount Amount of the L2 token to withdraw.
* @param _minGasLimit Minimum gas limit to use for the transaction.
* @param _data Extra data attached to the withdrawal.
* @param _extraData Extra data attached to the withdrawal.
*/
function withdraw(
address _l2Token,
uint256 _amount,
uint32 _minGasLimit,
bytes calldata _data
) external payable virtual {
_initiateWithdrawal(_l2Token, msg.sender, msg.sender, _amount, _minGasLimit, _data);
bytes calldata _extraData
) external payable virtual onlyEOA {
_initiateWithdrawal(_l2Token, msg.sender, msg.sender, _amount, _minGasLimit, _extraData);
}
/**
* @custom:legacy
* @notice Initiates a withdrawal from L2 to L1 to a target account on L1.
* Note that if ETH is sent to a contract on L1 and the call fails, then that ETH will
* be locked in the L1StandardBridge. ETH may be recoverable if the call can be
* successfully replayed by increasing the amount of gas supplied to the call. If the
* call will fail for any amount of gas, then the ETH will be locked permanently.
*
* @param _l2Token Address of the L2 token to withdraw.
* @param _to Recipient account on L1.
* @param _amount Amount of the L2 token to withdraw.
* @param _minGasLimit Minimum gas limit to use for the transaction.
* @param _data Extra data attached to the withdrawal.
* @param _extraData Extra data attached to the withdrawal.
*/
function withdrawTo(
address _l2Token,
address _to,
uint256 _amount,
uint32 _minGasLimit,
bytes calldata _data
bytes calldata _extraData
) external payable virtual {
_initiateWithdrawal(_l2Token, msg.sender, _to, _amount, _minGasLimit, _data);
_initiateWithdrawal(_l2Token, msg.sender, _to, _amount, _minGasLimit, _extraData);
}
/**
* @custom:legacy
* @notice Finalizes a deposit from L1 to L2.
*
* @param _l1Token Address of the L1 token to deposit.
* @param _l2Token Address of the corresponding L2 token.
* @param _from Address of the depositor.
* @param _to Address of the recipient.
* @param _amount Amount of the tokens being deposited.
* @param _data Extra data attached to the deposit.
* @param _l1Token Address of the L1 token to deposit.
* @param _l2Token Address of the corresponding L2 token.
* @param _from Address of the depositor.
* @param _to Address of the recipient.
* @param _amount Amount of the tokens being deposited.
* @param _extraData Extra data attached to the deposit.
*/
function finalizeDeposit(
address _l1Token,
......@@ -137,14 +146,14 @@ contract L2StandardBridge is StandardBridge {
address _from,
address _to,
uint256 _amount,
bytes calldata _data
bytes calldata _extraData
) external payable virtual {
if (_l1Token == address(0) && _l2Token == Lib_PredeployAddresses.OVM_ETH) {
finalizeBridgeETH(_from, _to, _amount, _data);
finalizeBridgeETH(_from, _to, _amount, _extraData);
} else {
finalizeBridgeERC20(_l2Token, _l1Token, _from, _to, _amount, _data);
finalizeBridgeERC20(_l2Token, _l1Token, _from, _to, _amount, _extraData);
}
emit DepositFinalized(_l1Token, _l2Token, _from, _to, _amount, _data);
emit DepositFinalized(_l1Token, _l2Token, _from, _to, _amount, _extraData);
}
/**
......@@ -156,7 +165,7 @@ contract L2StandardBridge is StandardBridge {
* @param _to Recipient account on L1.
* @param _amount Amount of the L2 token to withdraw.
* @param _minGasLimit Minimum gas limit to use for the transaction.
* @param _data Extra data attached to the withdrawal.
* @param _extraData Extra data attached to the withdrawal.
*/
function _initiateWithdrawal(
address _l2Token,
......@@ -164,14 +173,15 @@ contract L2StandardBridge is StandardBridge {
address _to,
uint256 _amount,
uint32 _minGasLimit,
bytes calldata _data
bytes calldata _extraData
) internal {
address l1Token = OptimismMintableERC20(_l2Token).l1Token();
if (_l2Token == Lib_PredeployAddresses.OVM_ETH) {
_initiateBridgeETH(_from, _to, _amount, _minGasLimit, _data);
require(msg.value == _amount, "ETH withdrawals must include sufficient ETH value.");
_initiateBridgeETH(_from, _to, _amount, _minGasLimit, _extraData);
} else {
_initiateBridgeERC20(_l2Token, l1Token, _from, _to, _amount, _minGasLimit, _data);
_initiateBridgeERC20(_l2Token, l1Token, _from, _to, _amount, _minGasLimit, _extraData);
}
emit WithdrawalInitiated(l1Token, _l2Token, msg.sender, _to, _amount, _data);
emit WithdrawalInitiated(l1Token, _l2Token, _from, _to, _amount, _extraData);
}
}
......@@ -39,6 +39,19 @@ contract L2ToL1MessagePasser {
*/
event WithdrawerBalanceBurnt(uint256 indexed amount);
/*************
* Constants *
*************/
/**
* @notice The L1 gas limit set when eth is withdrawn using the receive() function.
*/
uint256 internal constant RECEIVE_DEFAULT_GAS_LIMIT = 100_000;
/*************
* Variables *
*************/
/**
* @notice Includes the message hashes for all withdrawals
*/
......@@ -53,7 +66,7 @@ contract L2ToL1MessagePasser {
* @notice Allows users to withdraw ETH by sending directly to this contract.
*/
receive() external payable {
initiateWithdrawal(msg.sender, 100000, bytes(""));
initiateWithdrawal(msg.sender, RECEIVE_DEFAULT_GAS_LIMIT, bytes(""));
}
/**
......
......@@ -47,33 +47,35 @@ contract L2OutputOracle_Initializer is CommonTest {
L2OutputOracle oracle;
// Constructor arguments
address sequencer = 0x000000000000000000000000000000000000AbBa;
uint256 submissionInterval = 1800;
uint256 l2BlockTime = 2;
uint256 submissionInterval = 42;
bytes32 genesisL2Output = keccak256(abi.encode(0));
uint256 historicalTotalBlocks = 100;
// Cache of the initial L2 timestamp
uint256 startingBlockTimestamp;
uint256 historicalTotalBlocks = 199;
uint256 startingBlockNumber = 200;
uint256 startingTimestamp = 1000;
uint256 l2BlockTime = 2;
address sequencer = 0x000000000000000000000000000000000000AbBa;
// By default the first block has timestamp zero, which will cause underflows in the tests
uint256 initTime = 1000;
// Test data
uint256 initL1Time;
function setUp() public virtual {
_setUp();
// Move time forward so we have a non-zero starting timestamp
vm.warp(initTime);
// By default the first block has timestamp and number zero, which will cause underflows in the
// tests, so we'll move forward to these block values.
initL1Time = startingTimestamp + 1;
vm.warp(initL1Time);
vm.roll(startingBlockNumber);
// Deploy the L2OutputOracle and transfer owernship to the sequencer
oracle = new L2OutputOracle(
submissionInterval,
l2BlockTime,
genesisL2Output,
historicalTotalBlocks,
initTime,
startingBlockNumber,
startingTimestamp,
l2BlockTime,
sequencer
);
startingBlockTimestamp = block.timestamp;
}
}
......
......@@ -42,6 +42,21 @@ contract L1CrossDomainMessenger_Test is Messenger_Initializer {
L1Messenger.pause();
}
// unpause: should unpause the contract when called by the current owner
function test_L1MessengerUnpause() external {
L1Messenger.pause();
assert(L1Messenger.paused());
L1Messenger.unpause();
assert(!L1Messenger.paused());
}
// unpause: should not unpause the contract when called by account other than the owner
function testCannot_L1MessengerUnpause() external {
vm.expectRevert("Ownable: caller is not the owner");
vm.prank(address(0xABBA));
L1Messenger.unpause();
}
// the version is encoded in the nonce
function test_L1MessengerMessageVersion() external {
assertEq(
......
......@@ -390,13 +390,4 @@ contract L1StandardBridge_Test is Bridge_Initializer {
hex""
);
}
// donateETH
// - can send ETH to the contract
function test_donateETH() external {
assertEq(address(L1Bridge).balance, 0);
vm.prank(alice);
L1Bridge.donateETH{ value: 1000 }();
assertEq(address(L1Bridge).balance, 1000);
}
}
......@@ -4,6 +4,7 @@ pragma solidity 0.8.10;
import { Bridge_Initializer } from "./CommonTest.t.sol";
import { stdStorage, StdStorage } from "forge-std/Test.sol";
import { CrossDomainMessenger } from "../universal/CrossDomainMessenger.sol";
import { Lib_PredeployAddresses } from "../libraries/Lib_PredeployAddresses.sol";
import { console } from "forge-std/console.sol";
contract L2StandardBridge_Test is Bridge_Initializer {
......@@ -43,6 +44,21 @@ contract L2StandardBridge_Test is Bridge_Initializer {
assertEq(address(messagePasser).balance, 100);
}
// withrdraw
// - requires amount == msg.value
function test_cannotWithdrawEthWithoutSendingIt() external {
assertEq(address(messagePasser).balance, 0);
vm.expectRevert("ETH withdrawals must include sufficient ETH value.");
vm.prank(alice, alice);
L2Bridge.withdraw(
address(Lib_PredeployAddresses.OVM_ETH),
100,
1000,
hex""
);
}
// withdraw
// - token is burned
// - emits WithdrawalInitiated
......@@ -65,6 +81,19 @@ contract L2StandardBridge_Test is Bridge_Initializer {
assertEq(L2Token.balanceOf(alice), 0);
}
function test_withdraw_onlyEOA() external {
// This contract has 100 L2Token
deal(address(L2Token), address(this), 100, true);
vm.expectRevert("Account not EOA");
L2Bridge.withdraw(
address(L2Token),
100,
1000,
hex""
);
}
// withdrawTo
// - token is burned
// - emits WithdrawalInitiated w/ correct recipient
......@@ -117,13 +146,12 @@ contract L2StandardBridge_Test is Bridge_Initializer {
// - invalid deposit calls Withdrawer.initiateWithdrawal
function test_finalizeDeposit_failsToCompleteOutboundTransfer() external {
// TODO: events and calls
address invalidL2Token = address(0x1234);
vm.mockCall(
address(L2Bridge.messenger()),
abi.encodeWithSelector(CrossDomainMessenger.xDomainMessageSender.selector),
abi.encode(address(L2Bridge.otherBridge()))
);
address invalidL2Token = address(0x1234);
vm.prank(address(L2Messenger));
vm.expectEmit(true, true, true, true);
emit ERC20BridgeInitiated(
......@@ -152,5 +180,21 @@ contract L2StandardBridge_Test is Bridge_Initializer {
hex""
);
}
// finalizeBridgeERC20
// - fails when the local token's address equals bridge address
function test_ERC20BridgeFailed_whenLocalTokenIsBridge() external {
vm.mockCall(
address(L2Bridge.messenger()),
abi.encodeWithSelector(CrossDomainMessenger.xDomainMessageSender.selector),
abi.encode(address(L2Bridge.otherBridge()))
);
// fails when the local token's address equals bridge address
vm.expectEmit(true, true, true, true);
emit ERC20BridgeFailed(address(L2Bridge), address(L1Token), alice, bob, 100, hex"");
vm.prank(address(L2Messenger));
L2Bridge.finalizeDeposit(address(L1Token), address(L2Bridge), alice, bob, 100, hex"");
}
}
......@@ -2,6 +2,7 @@
pragma solidity ^0.8.9;
import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "./SupportedInterfaces.sol";
/**
* @title OptimismMintableERC20
......@@ -72,10 +73,10 @@ contract OptimismMintableERC20 is ERC20 {
*/
// slither-disable-next-line external-function
function supportsInterface(bytes4 _interfaceId) public pure returns (bool) {
bytes4 iface1 = bytes4(keccak256("supportsInterface(bytes4)")); // ERC165
bytes4 iface2 = this.l1Token.selector ^ this.mint.selector ^ this.burn.selector;
bytes4 iface3 = this.remoteToken.selector ^ this.mint.selector ^ this.burn.selector;
return _interfaceId == iface1 || _interfaceId == iface3 || _interfaceId == iface2;
bytes4 iface1 = type(IERC165).interfaceId;
bytes4 iface2 = type(IL1Token).interfaceId;
bytes4 iface3 = type(IRemoteToken).interfaceId;
return _interfaceId == iface1 || _interfaceId == iface2 || _interfaceId == iface3;
}
/**
......
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.
This diff is collapsed.
This diff is collapsed.
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