Commit 830163ef authored by mergify[bot]'s avatar mergify[bot] Committed by GitHub

Merge branch 'develop' into sc/ctb-l2oo-init-early

parents 654ea959 b3ec2877
---
'@eth-optimism/contracts-bedrock': minor
---
Change the `relayMessage` reentrancy guard in the XDMs to be per-message.
---
'@eth-optimism/contracts-bedrock': patch
---
Trigger a release including CrossDomainOwnable3
......@@ -974,6 +974,9 @@ workflows:
- go-lint:
name: op-service-lint
module: op-service
- go-lint:
name: op-wheel-lint
module: op-wheel
- go-test:
name: op-batcher-tests
module: op-batcher
......
......@@ -46,14 +46,7 @@ mod-tidy:
# can take a while to index new versions.
#
# See https://proxy.golang.org/ for more info.
export GOPRIVATE="github.com/ethereum-optimism" && \
cd ./op-service && go mod tidy && cd .. && \
cd ./op-node && go mod tidy && cd .. && \
cd ./op-proposer && go mod tidy && cd .. && \
cd ./op-batcher && go mod tidy && cd .. && \
cd ./op-bindings && go mod tidy && cd .. && \
cd ./op-chain-ops && go mod tidy && cd .. && \
cd ./op-e2e && go mod tidy && cd ..
export GOPRIVATE="github.com/ethereum-optimism" && go mod tidy
.PHONY: mod-tidy
clean:
......
......@@ -12,27 +12,27 @@ require (
github.com/ethereum/go-ethereum v1.10.26
github.com/fsnotify/fsnotify v1.6.0
github.com/golang/snappy v0.0.4
github.com/google/go-cmp v0.5.8
github.com/google/go-cmp v0.5.9
github.com/google/gofuzz v1.2.1-0.20220503160820-4a35382e8fc8
github.com/hashicorp/go-multierror v1.1.1
github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d
github.com/holiman/uint256 v1.2.0
github.com/ipfs/go-datastore v0.6.0
github.com/ipfs/go-ds-leveldb v0.5.0
github.com/libp2p/go-libp2p v0.23.3
github.com/libp2p/go-libp2p-pubsub v0.8.1
github.com/libp2p/go-libp2p v0.25.1
github.com/libp2p/go-libp2p-pubsub v0.9.0
github.com/libp2p/go-libp2p-testing v0.12.0
github.com/mattn/go-isatty v0.0.17
github.com/multiformats/go-multiaddr v0.7.0
github.com/multiformats/go-multiaddr v0.8.0
github.com/multiformats/go-multiaddr-dns v0.3.1
github.com/olekukonko/tablewriter v0.0.5
github.com/prometheus/client_golang v1.13.0
github.com/prometheus/client_golang v1.14.0
github.com/schollz/progressbar/v3 v3.13.0
github.com/stretchr/testify v1.8.1
github.com/urfave/cli v1.22.9
github.com/urfave/cli/v2 v2.17.2-0.20221006022127-8f469abc00aa
golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa
golang.org/x/term v0.4.0
golang.org/x/crypto v0.4.0
golang.org/x/term v0.5.0
)
require (
......@@ -44,9 +44,9 @@ require (
github.com/btcsuite/btcd/btcec/v2 v2.2.0 // indirect
github.com/btcsuite/btcd/btcutil v1.1.0 // indirect
github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/containerd/cgroups v1.0.4 // indirect
github.com/coreos/go-systemd/v22 v22.4.0 // indirect
github.com/coreos/go-systemd/v22 v22.5.0 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c // indirect
......@@ -57,6 +57,7 @@ require (
github.com/docker/go-units v0.5.0 // indirect
github.com/edsrzf/mmap-go v1.1.0 // indirect
github.com/elastic/gosigar v0.14.2 // indirect
github.com/emirpasic/gods v1.18.1 // indirect
github.com/fjl/memsize v0.0.1 // indirect
github.com/flynn/noise v1.0.0 // indirect
github.com/francoispqt/gojay v1.2.13 // indirect
......@@ -71,11 +72,13 @@ require (
github.com/golang/mock v1.6.0 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/gopacket v1.1.19 // indirect
github.com/google/pprof v0.0.0-20221203041831-ce31453925ec // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/gorilla/websocket v1.5.0 // indirect
github.com/graph-gophers/graphql-go v1.3.0 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-bexpr v0.1.11 // indirect
github.com/hashicorp/golang-lru/v2 v2.0.1 // indirect
github.com/holiman/big v0.0.0-20221017200358-a027dc42d04e // indirect
github.com/holiman/bloomfilter/v2 v2.0.3 // indirect
github.com/huin/goupnp v1.0.3 // indirect
......@@ -88,29 +91,24 @@ require (
github.com/jackpal/go-nat-pmp v1.0.2 // indirect
github.com/jbenet/go-temp-err-catcher v0.1.0 // indirect
github.com/jbenet/goprocess v0.1.4 // indirect
github.com/klauspost/compress v1.15.10 // indirect
github.com/klauspost/cpuid/v2 v2.1.1 // indirect
github.com/klauspost/compress v1.15.15 // indirect
github.com/klauspost/cpuid/v2 v2.2.3 // indirect
github.com/koron/go-ssdp v0.0.3 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/libp2p/go-buffer-pool v0.1.0 // indirect
github.com/libp2p/go-cidranger v1.1.0 // indirect
github.com/libp2p/go-flow-metrics v0.1.0 // indirect
github.com/libp2p/go-libp2p-asn-util v0.2.0 // indirect
github.com/libp2p/go-mplex v0.7.0 // indirect
github.com/libp2p/go-msgio v0.2.0 // indirect
github.com/libp2p/go-msgio v0.3.0 // indirect
github.com/libp2p/go-nat v0.1.0 // indirect
github.com/libp2p/go-netroute v0.2.0 // indirect
github.com/libp2p/go-openssl v0.1.0 // indirect
github.com/libp2p/go-netroute v0.2.1 // indirect
github.com/libp2p/go-reuseport v0.2.0 // indirect
github.com/libp2p/go-yamux/v4 v4.0.0 // indirect
github.com/lucas-clemente/quic-go v0.29.1 // indirect
github.com/marten-seemann/qtls-go1-18 v0.1.2 // indirect
github.com/marten-seemann/qtls-go1-19 v0.1.0 // indirect
github.com/marten-seemann/tcp v0.0.0-20210406111302-dfbc87cc63fd // indirect
github.com/mattn/go-colorable v0.1.12 // indirect
github.com/mattn/go-pointer v0.0.1 // indirect
github.com/mattn/go-runewidth v0.0.14 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/miekg/dns v1.1.50 // indirect
github.com/mikioh/tcpinfo v0.0.0-20190314235526-30a79bb1804b // indirect
github.com/mikioh/tcpopt v0.0.0-20190314235656-172688c1accc // indirect
......@@ -122,34 +120,39 @@ require (
github.com/morikuni/aec v1.0.0 // indirect
github.com/mr-tron/base58 v1.2.0 // indirect
github.com/multiformats/go-base32 v0.1.0 // indirect
github.com/multiformats/go-base36 v0.1.0 // indirect
github.com/multiformats/go-base36 v0.2.0 // indirect
github.com/multiformats/go-multiaddr-fmt v0.1.0 // indirect
github.com/multiformats/go-multibase v0.1.1 // indirect
github.com/multiformats/go-multicodec v0.6.0 // indirect
github.com/multiformats/go-multicodec v0.8.1 // indirect
github.com/multiformats/go-multihash v0.2.1 // indirect
github.com/multiformats/go-multistream v0.3.3 // indirect
github.com/multiformats/go-varint v0.0.6 // indirect
github.com/nxadm/tail v1.4.8 // indirect
github.com/onsi/ginkgo v1.16.5 // indirect
github.com/multiformats/go-multistream v0.4.1 // indirect
github.com/multiformats/go-varint v0.0.7 // indirect
github.com/onsi/ginkgo/v2 v2.8.1 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.0.2 // indirect
github.com/opencontainers/runtime-spec v1.0.2 // indirect
github.com/opentracing/opentracing-go v1.2.0 // indirect
github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 // indirect
github.com/peterh/liner v1.1.1-0.20190123174540-a2c9a5303de7 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.37.0 // indirect
github.com/prometheus/procfs v0.8.0 // indirect
github.com/prometheus/client_model v0.3.0 // indirect
github.com/prometheus/common v0.39.0 // indirect
github.com/prometheus/procfs v0.9.0 // indirect
github.com/prometheus/tsdb v0.10.0 // indirect
github.com/quic-go/qpack v0.4.0 // indirect
github.com/quic-go/qtls-go1-18 v0.2.0 // indirect
github.com/quic-go/qtls-go1-19 v0.2.0 // indirect
github.com/quic-go/qtls-go1-20 v0.1.0 // indirect
github.com/quic-go/quic-go v0.32.0 // indirect
github.com/quic-go/webtransport-go v0.5.1 // indirect
github.com/raulk/go-watchdog v1.3.0 // indirect
github.com/rivo/uniseg v0.4.3 // indirect
github.com/rjeczalik/notify v0.9.2 // indirect
github.com/rs/cors v1.8.2 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/shirou/gopsutil v3.21.11+incompatible // indirect
github.com/sirupsen/logrus v1.8.1 // indirect
github.com/spacemonkeygo/spacelog v0.0.0-20180420211403-2296661a0572 // indirect
github.com/sirupsen/logrus v1.9.0 // indirect
github.com/spaolacci/murmur3 v1.1.0 // indirect
github.com/status-im/keycard-go v0.0.0-20211109104530-b0e0482ba91d // indirect
github.com/stretchr/objx v0.5.0 // indirect
......@@ -157,27 +160,28 @@ require (
github.com/tklauser/go-sysconf v0.3.10 // indirect
github.com/tklauser/numcpus v0.5.0 // indirect
github.com/tyler-smith/go-bip39 v1.1.0 // indirect
github.com/whyrusleeping/timecache v0.0.0-20160911033111-cfcb2f1abfee // indirect
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
github.com/yusufpapurcu/wmi v1.2.2 // indirect
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/multierr v1.8.0 // indirect
go.uber.org/zap v1.23.0 // indirect
golang.org/x/exp v0.0.0-20220916125017-b168a2c6b86b // indirect
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect
golang.org/x/net v0.0.0-20220920183852-bf014ff85ad5 // indirect
go.uber.org/dig v1.16.1 // indirect
go.uber.org/fx v1.19.1 // indirect
go.uber.org/multierr v1.9.0 // indirect
go.uber.org/zap v1.24.0 // indirect
golang.org/x/exp v0.0.0-20230213192124-5e25df0256eb // indirect
golang.org/x/mod v0.8.0 // indirect
golang.org/x/net v0.7.0 // indirect
golang.org/x/sync v0.1.0 // indirect
golang.org/x/sys v0.4.0 // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/time v0.0.0-20220722155302-e5dcc9cfc0b9 // indirect
golang.org/x/tools v0.1.12 // indirect
golang.org/x/sys v0.5.0 // indirect
golang.org/x/text v0.7.0 // indirect
golang.org/x/time v0.0.0-20220922220347-f3bd1da661af // indirect
golang.org/x/tools v0.6.0 // indirect
google.golang.org/protobuf v1.28.1 // indirect
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
gotest.tools/v3 v3.4.0 // indirect
lukechampine.com/blake3 v1.1.7 // indirect
nhooyr.io/websocket v1.8.7 // indirect
)
replace github.com/ethereum/go-ethereum v1.10.26 => github.com/ethereum-optimism/op-geth v0.0.0-20230214215134-401b7fd3309b
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -415,8 +415,6 @@ func NewL2StorageConfig(config *DeployConfig, block *types.Block) (state.Storage
storage["L2CrossDomainMessenger"] = state.StorageValues{
"_initialized": 1,
"_owner": config.ProxyAdminOwner,
// re-entrency lock
"_status": 1,
"_initializing": false,
"_paused": false,
"xDomainMsgSender": "0x000000000000000000000000000000000000dEaD",
......
......@@ -13,7 +13,6 @@ import (
ds "github.com/ipfs/go-datastore"
"github.com/ipfs/go-datastore/sync"
leveldb "github.com/ipfs/go-ds-leveldb"
lconf "github.com/libp2p/go-libp2p/config"
"github.com/libp2p/go-libp2p/core/crypto"
"github.com/multiformats/go-multiaddr"
......@@ -171,27 +170,19 @@ func loadLibp2pOpts(conf *p2p.Config, ctx *cli.Context) error {
for _, v := range strings.Split(ctx.GlobalString(flags.HostMux.Name), ",") {
v = strings.ToLower(strings.TrimSpace(v))
var mc lconf.MsMuxC
var err error
switch v {
case "yamux":
mc, err = p2p.YamuxC()
conf.HostMux = append(conf.HostMux, p2p.YamuxC())
case "mplex":
mc, err = p2p.MplexC()
conf.HostMux = append(conf.HostMux, p2p.MplexC())
default:
return fmt.Errorf("could not recognize mux %s", v)
}
if err != nil {
return fmt.Errorf("failed to make %s constructor: %w", v, err)
}
conf.HostMux = append(conf.HostMux, mc)
}
secArr := strings.Split(ctx.GlobalString(flags.HostSecurity.Name), ",")
for _, v := range secArr {
v = strings.ToLower(strings.TrimSpace(v))
var sc lconf.MsSecC
var err error
switch v {
case "none": // no security, for debugging etc.
if len(conf.HostSecurity) > 0 || len(secArr) > 1 {
......@@ -199,16 +190,12 @@ func loadLibp2pOpts(conf *p2p.Config, ctx *cli.Context) error {
}
conf.NoTransportSecurity = true
case "noise":
sc, err = p2p.NoiseC()
conf.HostSecurity = append(conf.HostSecurity, p2p.NoiseC())
case "tls":
sc, err = p2p.TlsC()
conf.HostSecurity = append(conf.HostSecurity, p2p.TlsC())
default:
return fmt.Errorf("could not recognize security %s", v)
}
if err != nil {
return fmt.Errorf("failed to make %s constructor: %w", v, err)
}
conf.HostSecurity = append(conf.HostSecurity, sc)
}
conf.PeersLo = ctx.GlobalUint(flags.PeersLo.Name)
......
......@@ -8,8 +8,9 @@ import (
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/p2p/discover"
"github.com/ethereum/go-ethereum/p2p/enode"
ds "github.com/ipfs/go-datastore"
lconf "github.com/libp2p/go-libp2p/config"
"github.com/libp2p/go-libp2p"
"github.com/libp2p/go-libp2p/core"
"github.com/libp2p/go-libp2p/core/connmgr"
"github.com/libp2p/go-libp2p/core/crypto"
......@@ -19,8 +20,6 @@ import (
"github.com/libp2p/go-libp2p/p2p/net/conngater"
cmgr "github.com/libp2p/go-libp2p/p2p/net/connmgr"
"github.com/ethereum/go-ethereum/p2p/enode"
"github.com/ethereum-optimism/optimism/op-node/rollup"
)
......@@ -64,8 +63,8 @@ type Config struct {
StaticPeers []core.Multiaddr
HostMux []lconf.MsMuxC
HostSecurity []lconf.MsSecC
HostMux []libp2p.Option
HostSecurity []libp2p.Option
NoTransportSecurity bool
PeersLo uint
......
......@@ -7,13 +7,14 @@ import (
"sync"
"time"
"github.com/libp2p/go-libp2p/core/network"
libp2p "github.com/libp2p/go-libp2p"
lconf "github.com/libp2p/go-libp2p/config"
"github.com/libp2p/go-libp2p/core/connmgr"
"github.com/libp2p/go-libp2p/core/host"
"github.com/libp2p/go-libp2p/core/metrics"
"github.com/libp2p/go-libp2p/core/network"
"github.com/libp2p/go-libp2p/core/peer"
"github.com/libp2p/go-libp2p/core/sec/insecure"
basichost "github.com/libp2p/go-libp2p/p2p/host/basic"
"github.com/libp2p/go-libp2p/p2p/host/peerstore/pstoreds"
"github.com/libp2p/go-libp2p/p2p/muxer/mplex"
......@@ -157,7 +158,7 @@ func (conf *Config) Host(log log.Logger, reporter metrics.Reporter) (host.Host,
if err != nil {
return nil, fmt.Errorf("failed to make listen addr: %w", err)
}
tcpTransport, err := lconf.TransportConstructor(
tcpTransport := libp2p.Transport(
tcp.NewTCPTransport,
tcp.WithConnectionTimeout(time.Minute*60)) // break unused connections
if err != nil {
......@@ -170,50 +171,36 @@ func (conf *Config) Host(log log.Logger, reporter metrics.Reporter) (host.Host,
nat = basichost.NewNATManager
}
p2pConf := &lconf.Config{
opts := []libp2p.Option{
libp2p.Identity(conf.Priv),
// Explicitly set the user-agent, so we can differentiate from other Go libp2p users.
UserAgent: conf.UserAgent,
PeerKey: conf.Priv,
Transports: []lconf.TptC{tcpTransport},
Muxers: conf.HostMux,
SecurityTransports: conf.HostSecurity,
Insecure: conf.NoTransportSecurity,
PSK: nil, // TODO: expose private subnet option to CLI / testing
DialTimeout: conf.TimeoutDial,
libp2p.UserAgent(conf.UserAgent),
tcpTransport,
libp2p.WithDialTimeout(conf.TimeoutDial),
// No relay services, direct connections between peers only.
RelayCustom: false,
Relay: false,
EnableRelayService: false,
RelayServiceOpts: nil,
libp2p.DisableRelay(),
// host will start and listen to network directly after construction from config.
ListenAddrs: []ma.Multiaddr{listenAddr},
AddrsFactory: nil,
ConnectionGater: connGtr,
ConnManager: connMngr,
ResourceManager: nil, // TODO use resource manager interface to manage resources per peer better.
NATManager: nat,
Peerstore: ps,
Reporter: reporter, // may be nil if disabled
MultiaddrResolver: madns.DefaultResolver,
libp2p.ListenAddrs(listenAddr),
libp2p.ConnectionGater(connGtr),
libp2p.ConnectionManager(connMngr),
//libp2p.ResourceManager(nil), // TODO use resource manager interface to manage resources per peer better.
libp2p.NATManager(nat),
libp2p.Peerstore(ps),
libp2p.BandwidthReporter(reporter), // may be nil if disabled
libp2p.MultiaddrResolver(madns.DefaultResolver),
// Ping is a small built-in libp2p protocol that helps us check/debug latency between peers.
DisablePing: false,
Routing: nil,
EnableAutoRelay: false, // don't act as auto relay service
libp2p.Ping(true),
// Help peers with their NAT reachability status, but throttle to avoid too much work.
AutoNATConfig: lconf.AutoNATConfig{
ForceReachability: nil,
EnableService: true,
ThrottleGlobalLimit: 10,
ThrottlePeerLimit: 5,
ThrottleInterval: time.Second * 60,
},
// TODO: hole punching is new, need to review differences with NAT manager options
EnableHolePunching: false,
HolePunchingOptions: nil,
libp2p.EnableNATService(),
libp2p.AutoNATServiceRateLimit(10, 5, time.Second*60),
}
h, err := p2pConf.NewNode()
opts = append(opts, conf.HostMux...)
if conf.NoTransportSecurity {
opts = append(opts, libp2p.Security(insecure.ID, insecure.NewWithIdentity))
} else {
opts = append(opts, conf.HostSecurity...)
}
h, err := libp2p.New(opts...)
if err != nil {
return nil, err
}
......@@ -257,34 +244,18 @@ func addrFromIPAndPort(ip net.IP, port uint16) (ma.Multiaddr, error) {
return ma.NewMultiaddr(fmt.Sprintf("/%s/%s/tcp/%d", ipScheme, ip.String(), port))
}
func YamuxC() (lconf.MsMuxC, error) {
mtpt, err := lconf.MuxerConstructor(yamux.DefaultTransport)
if err != nil {
return lconf.MsMuxC{}, err
}
return lconf.MsMuxC{MuxC: mtpt, ID: "/yamux/1.0.0"}, nil
func YamuxC() libp2p.Option {
return libp2p.Muxer("/yamux/1.0.0", yamux.DefaultTransport)
}
func MplexC() (lconf.MsMuxC, error) {
mtpt, err := lconf.MuxerConstructor(mplex.DefaultTransport)
if err != nil {
return lconf.MsMuxC{}, err
}
return lconf.MsMuxC{MuxC: mtpt, ID: "/mplex/6.7.0"}, nil
func MplexC() libp2p.Option {
return libp2p.Muxer("/mplex/6.7.0", mplex.DefaultTransport)
}
func NoiseC() (lconf.MsSecC, error) {
stpt, err := lconf.SecurityConstructor(noise.New)
if err != nil {
return lconf.MsSecC{}, err
}
return lconf.MsSecC{SecC: stpt, ID: noise.ID}, nil
func NoiseC() libp2p.Option {
return libp2p.Security(noise.ID, noise.New)
}
func TlsC() (lconf.MsSecC, error) {
stpt, err := lconf.SecurityConstructor(tls.New)
if err != nil {
return lconf.MsSecC{}, err
}
return lconf.MsSecC{SecC: stpt, ID: tls.ID}, nil
func TlsC() libp2p.Option {
return libp2p.Security(tls.ID, tls.New)
}
......@@ -11,12 +11,11 @@ import (
"github.com/ethereum/go-ethereum/common"
ds "github.com/ipfs/go-datastore"
"github.com/ipfs/go-datastore/sync"
lconf "github.com/libp2p/go-libp2p/config"
"github.com/libp2p/go-libp2p"
"github.com/libp2p/go-libp2p/core/connmgr"
"github.com/libp2p/go-libp2p/core/crypto"
"github.com/libp2p/go-libp2p/core/network"
"github.com/libp2p/go-libp2p/core/peer"
"github.com/libp2p/go-libp2p/p2p/muxer/yamux"
mocknet "github.com/libp2p/go-libp2p/p2p/net/mock"
tswarm "github.com/libp2p/go-libp2p/p2p/net/swarm/testing"
"github.com/stretchr/testify/require"
......@@ -34,9 +33,6 @@ import (
func TestingConfig(t *testing.T) *Config {
p, _, err := crypto.GenerateSecp256k1Key(rand.Reader)
require.NoError(t, err, "failed to generate new p2p priv key")
mtpt, err := lconf.MuxerConstructor(yamux.DefaultTransport)
require.NoError(t, err)
mux := lconf.MsMuxC{MuxC: mtpt, ID: "/yamux/1.0.0"}
return &Config{
Priv: (p).(*crypto.Secp256k1PrivateKey),
......@@ -45,7 +41,7 @@ func TestingConfig(t *testing.T) *Config {
ListenIP: net.IP{127, 0, 0, 1},
ListenTCPPort: 0, // bind to any available port
StaticPeers: nil,
HostMux: []lconf.MsMuxC{mux},
HostMux: []libp2p.Option{YamuxC()},
NoTransportSecurity: true,
PeersLo: 1,
PeersHi: 10,
......@@ -96,15 +92,6 @@ func TestP2PFull(t *testing.T) {
pB, _, err := crypto.GenerateSecp256k1Key(rand.Reader)
require.NoError(t, err, "failed to generate new p2p priv key")
mplexC, err := MplexC()
require.NoError(t, err)
yamuxC, err := YamuxC()
require.NoError(t, err)
noiseC, err := NoiseC()
require.NoError(t, err)
tlsC, err := TlsC()
require.NoError(t, err)
confA := Config{
Priv: (pA).(*crypto.Secp256k1PrivateKey),
DisableP2P: false,
......@@ -112,8 +99,8 @@ func TestP2PFull(t *testing.T) {
ListenIP: net.IP{127, 0, 0, 1},
ListenTCPPort: 0, // bind to any available port
StaticPeers: nil,
HostMux: []lconf.MsMuxC{yamuxC, mplexC},
HostSecurity: []lconf.MsSecC{noiseC, tlsC},
HostMux: []libp2p.Option{YamuxC(), MplexC()},
HostSecurity: []libp2p.Option{NoiseC(), TlsC()},
NoTransportSecurity: false,
PeersLo: 1,
PeersHi: 10,
......@@ -242,15 +229,6 @@ func TestDiscovery(t *testing.T) {
logB := testlog.Logger(t, log.LvlError).New("host", "B")
logC := testlog.Logger(t, log.LvlError).New("host", "C")
mplexC, err := MplexC()
require.NoError(t, err)
yamuxC, err := YamuxC()
require.NoError(t, err)
noiseC, err := NoiseC()
require.NoError(t, err)
tlsC, err := TlsC()
require.NoError(t, err)
discDBA, err := enode.OpenDB("") // "" = memory db
require.NoError(t, err)
discDBB, err := enode.OpenDB("")
......@@ -269,8 +247,8 @@ func TestDiscovery(t *testing.T) {
ListenIP: net.IP{127, 0, 0, 1},
ListenTCPPort: 0, // bind to any available port
StaticPeers: nil,
HostMux: []lconf.MsMuxC{yamuxC, mplexC},
HostSecurity: []lconf.MsSecC{noiseC, tlsC},
HostMux: []libp2p.Option{YamuxC(), MplexC()},
HostSecurity: []libp2p.Option{NoiseC(), TlsC()},
NoTransportSecurity: false,
PeersLo: 1,
PeersHi: 10,
......
......@@ -11,7 +11,6 @@ import (
"github.com/libp2p/go-libp2p/core/connmgr"
"github.com/libp2p/go-libp2p/core/host"
p2pmetrics "github.com/libp2p/go-libp2p/core/metrics"
"github.com/libp2p/go-libp2p/p2p/protocol/identify"
ma "github.com/multiformats/go-multiaddr"
"github.com/ethereum-optimism/optimism/op-node/metrics"
......@@ -76,8 +75,7 @@ func (n *NodeP2P) init(resourcesCtx context.Context, rollupCfg *rollup.Config, l
}
// notify of any new connections/streams/etc.
n.host.Network().Notify(NewNetworkNotifier(log, metrics))
// unregister identify-push handler. Only identifying on dial is fine, and more robust against spam
n.host.RemoveStreamHandler(identify.IDDelta)
// note: the IDDelta functionality was removed from libP2P, and no longer needs to be explicitly disabled.
n.gs, err = NewGossipSub(resourcesCtx, n.host, rollupCfg, setup, metrics)
if err != nil {
return fmt.Errorf("failed to start gossipsub router: %w", err)
......
......@@ -108,19 +108,19 @@ func dumpPeer(id peer.ID, nw network.Network, pstore peerstore.Peerstore, connMg
info.NodeID = enode.PubkeyToIDV4((*decredSecp.PublicKey)(typedPub).ToECDSA())
}
}
if dat, err := pstore.Get(id, "ProtocolVersion"); err != nil {
if dat, err := pstore.Get(id, "ProtocolVersion"); err == nil {
protocolVersion, ok := dat.(string)
if ok {
info.ProtocolVersion = protocolVersion
}
}
if dat, err := pstore.Get(id, "AgentVersion"); err != nil {
if dat, err := pstore.Get(id, "AgentVersion"); err == nil {
agentVersion, ok := dat.(string)
if ok {
info.UserAgent = agentVersion
}
}
if dat, err := pstore.Get(id, "ENR"); err != nil {
if dat, err := pstore.Get(id, "ENR"); err == nil {
enodeData, ok := dat.(*enode.Node)
if ok {
info.ENR = enodeData.String()
......@@ -134,15 +134,17 @@ func dumpPeer(id peer.ID, nw network.Network, pstore peerstore.Peerstore, connMg
}
}
info.Connectedness = nw.Connectedness(id)
if protocols, err := pstore.GetProtocols(id); err != nil {
info.Protocols = protocols
if protocols, err := pstore.GetProtocols(id); err == nil {
for _, id := range protocols {
info.Protocols = append(info.Protocols, string(id))
}
}
// get the first connection direction, if any (will default to unknown when there are no connections)
for _, c := range nw.ConnsToPeer(id) {
info.Direction = c.Stat().Direction
break
}
if dat, err := pstore.Get(id, "optimismChainID"); err != nil {
if dat, err := pstore.Get(id, "optimismChainID"); err == nil {
chID, ok := dat.(uint64)
if ok {
info.ChainID = chID
......
......@@ -100,12 +100,32 @@ func CheckBatch(cfg *rollup.Config, log log.Logger, l1Blocks []eth.L1BlockRef, l
return BatchDrop
}
// If we ran out of sequencer time drift, then we drop the batch and produce an empty batch instead,
// as the sequencer is not allowed to include anything past this point without moving to the next epoch.
// Check if we ran out of sequencer time drift
if max := batchOrigin.Time + cfg.MaxSequencerDrift; batch.Batch.Timestamp > max {
if len(batch.Batch.Transactions) == 0 {
// If the sequencer is co-operating by producing an empty batch,
// then allow the batch if it was the right thing to do to maintain the L2 time >= L1 time invariant.
// We only check batches that do not advance the epoch, to ensure epoch advancement regardless of time drift is allowed.
if epoch.Number == batchOrigin.Number {
if len(l1Blocks) < 2 {
log.Info("without the next L1 origin we cannot determine yet if this empty batch that exceeds the time drift is still valid")
return BatchUndecided
}
nextOrigin := l1Blocks[1]
if batch.Batch.Timestamp >= nextOrigin.Time { // check if the next L1 origin could have been adopted
log.Info("batch exceeded sequencer time drift without adopting next origin, and next L1 origin would have been valid")
return BatchDrop
} else {
log.Info("continuing with empty batch before late L1 block to preserve L2 time invariant")
}
}
} else {
// If the sequencer is ignoring the time drift rule, then drop the batch and force an empty batch instead,
// as the sequencer is not allowed to include anything past this point without moving to the next epoch.
log.Warn("batch exceeded sequencer time drift, sequencer must adopt new L1 origin to include transactions again", "max_time", max)
return BatchDrop
}
}
// We can do this check earlier, but it's a more intensive one, so we do this last.
for i, txBytes := range batch.Batch.Transactions {
......
......@@ -151,6 +151,22 @@ func TestValidBatch(t *testing.T) {
SequenceNumber: 0,
}
l2A4 := eth.L2BlockRef{
Hash: testutils.RandomHash(rng),
Number: l2A3.Number + 1,
ParentHash: l2A3.Hash,
Time: l2A3.Time + conf.BlockTime, // 4*2 = 8, higher than seq time drift
L1Origin: l1A.ID(),
SequenceNumber: 4,
}
l1BLate := eth.L1BlockRef{
Hash: testutils.RandomHash(rng),
Number: l1A.Number + 1,
ParentHash: l1A.Hash,
Time: l2A4.Time + 1, // too late for l2A4 to adopt yet
}
testCases := []ValidBatchTestCase{
{
Name: "missing L1 info",
......@@ -249,16 +265,16 @@ func TestValidBatch(t *testing.T) {
Expected: BatchDrop,
},
{
Name: "epoch too old", // repeat of now outdated l2A3 data
Name: "epoch too old, but good parent hash and timestamp", // repeat of now outdated l2A3 data
L1Blocks: []eth.L1BlockRef{l1B, l1C, l1D},
L2SafeHead: l2B0, // we already moved on to B
Batch: BatchWithL1InclusionBlock{
L1InclusionBlock: l1C,
Batch: &BatchData{BatchV1{
ParentHash: l2A3.ParentHash,
ParentHash: l2B0.Hash, // build on top of safe head to continue
EpochNum: rollup.Epoch(l2A3.L1Origin.Number), // epoch A is no longer valid
EpochHash: l2A3.L1Origin.Hash,
Timestamp: l2A3.Time,
Timestamp: l2B0.Time + conf.BlockTime, // pass the timestamp check to get too epoch check
Transactions: nil,
}},
},
......@@ -313,23 +329,23 @@ func TestValidBatch(t *testing.T) {
Expected: BatchDrop,
},
{
Name: "sequencer time drift on same epoch",
Name: "sequencer time drift on same epoch with non-empty txs",
L1Blocks: []eth.L1BlockRef{l1A, l1B},
L2SafeHead: l2A3,
Batch: BatchWithL1InclusionBlock{
L1InclusionBlock: l1B,
Batch: &BatchData{BatchV1{ // we build l2A4, which has a timestamp of 2*4 = 8 higher than l2A0
ParentHash: l2A3.Hash,
EpochNum: rollup.Epoch(l2A3.L1Origin.Number),
EpochHash: l2A3.L1Origin.Hash,
Timestamp: l2A3.Time + conf.BlockTime,
Transactions: nil,
ParentHash: l2A4.ParentHash,
EpochNum: rollup.Epoch(l2A4.L1Origin.Number),
EpochHash: l2A4.L1Origin.Hash,
Timestamp: l2A4.Time,
Transactions: []hexutil.Bytes{[]byte("sequencer should not include this tx")},
}},
},
Expected: BatchDrop,
},
{
Name: "sequencer time drift on changing epoch",
Name: "sequencer time drift on changing epoch with non-empty txs",
L1Blocks: []eth.L1BlockRef{l1X, l1Y, l1Z},
L2SafeHead: l2X0,
Batch: BatchWithL1InclusionBlock{
......@@ -339,11 +355,75 @@ func TestValidBatch(t *testing.T) {
EpochNum: rollup.Epoch(l2Y0.L1Origin.Number),
EpochHash: l2Y0.L1Origin.Hash,
Timestamp: l2Y0.Time, // valid, but more than 6 ahead of l1Y.Time
Transactions: nil,
Transactions: []hexutil.Bytes{[]byte("sequencer should not include this tx")},
}},
},
Expected: BatchDrop,
},
{
Name: "sequencer time drift on same epoch with empty txs and late next epoch",
L1Blocks: []eth.L1BlockRef{l1A, l1BLate},
L2SafeHead: l2A3,
Batch: BatchWithL1InclusionBlock{
L1InclusionBlock: l1BLate,
Batch: &BatchData{BatchV1{ // l2A4 time < l1BLate time, so we cannot adopt origin B yet
ParentHash: l2A4.ParentHash,
EpochNum: rollup.Epoch(l2A4.L1Origin.Number),
EpochHash: l2A4.L1Origin.Hash,
Timestamp: l2A4.Time,
Transactions: nil,
}},
},
Expected: BatchAccept, // accepted because empty & preserving L2 time invariant
},
{
Name: "sequencer time drift on changing epoch with empty txs",
L1Blocks: []eth.L1BlockRef{l1X, l1Y, l1Z},
L2SafeHead: l2X0,
Batch: BatchWithL1InclusionBlock{
L1InclusionBlock: l1Z,
Batch: &BatchData{BatchV1{
ParentHash: l2Y0.ParentHash,
EpochNum: rollup.Epoch(l2Y0.L1Origin.Number),
EpochHash: l2Y0.L1Origin.Hash,
Timestamp: l2Y0.Time, // valid, but more than 6 ahead of l1Y.Time
Transactions: nil,
}},
},
Expected: BatchAccept, // accepted because empty & still advancing epoch
},
{
Name: "sequencer time drift on same epoch with empty txs and no next epoch in sight yet",
L1Blocks: []eth.L1BlockRef{l1A},
L2SafeHead: l2A3,
Batch: BatchWithL1InclusionBlock{
L1InclusionBlock: l1B,
Batch: &BatchData{BatchV1{ // we build l2A4, which has a timestamp of 2*4 = 8 higher than l2A0
ParentHash: l2A4.ParentHash,
EpochNum: rollup.Epoch(l2A4.L1Origin.Number),
EpochHash: l2A4.L1Origin.Hash,
Timestamp: l2A4.Time,
Transactions: nil,
}},
},
Expected: BatchUndecided, // we have to wait till the next epoch is in sight to check the time
},
{
Name: "sequencer time drift on same epoch with empty txs and but in-sight epoch that invalidates it",
L1Blocks: []eth.L1BlockRef{l1A, l1B, l1C},
L2SafeHead: l2A3,
Batch: BatchWithL1InclusionBlock{
L1InclusionBlock: l1C,
Batch: &BatchData{BatchV1{ // we build l2A4, which has a timestamp of 2*4 = 8 higher than l2A0
ParentHash: l2A4.ParentHash,
EpochNum: rollup.Epoch(l2A4.L1Origin.Number),
EpochHash: l2A4.L1Origin.Hash,
Timestamp: l2A4.Time,
Transactions: nil,
}},
},
Expected: BatchDrop, // dropped because it could have advanced the epoch to B
},
{
Name: "empty tx included",
L1Blocks: []eth.L1BlockRef{l1A, l1B},
......
......@@ -2,10 +2,13 @@ FROM golang:1.18.0-alpine3.15 as builder
RUN apk add --no-cache make gcc musl-dev linux-headers
COPY ./op-wheel/docker.go.work /app/go.work
COPY ./op-wheel /app/op-wheel
COPY ./op-node /app/op-node
COPY ./op-chain-ops /app/op-chain-ops
COPY ./op-service /app/op-service
COPY ./op-wheel /app/op-wheel
COPY ./op-bindings /app/op-bindings
COPY ./go.mod /app/go.mod
COPY ./go.sum /app/go.sum
WORKDIR /app/op-wheel
......
go 1.18
use (
./op-node
./op-service
./op-wheel
)
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -20,12 +20,12 @@ contract L1CrossDomainMessenger is CrossDomainMessenger, Semver {
OptimismPortal public immutable PORTAL;
/**
* @custom:semver 1.0.0
* @custom:semver 1.1.0
*
* @param _portal Address of the OptimismPortal contract on this network.
*/
constructor(OptimismPortal _portal)
Semver(1, 0, 0)
Semver(1, 1, 0)
CrossDomainMessenger(Predeploys.L2_CROSS_DOMAIN_MESSENGER)
{
PORTAL = _portal;
......
......@@ -371,6 +371,9 @@ contract OptimismPortal is Initializable, ResourceMetering, Semver {
);
}
// Prevent depositing transactions that have too small of a gas limit.
require(_gasLimit >= 21_000, "OptimismPortal: gas limit must cover instrinsic gas cost");
// Transform the from-address to its alias if the caller is a contract.
address from = msg.sender;
if (msg.sender != tx.origin) {
......
......@@ -17,12 +17,12 @@ import { L2ToL1MessagePasser } from "./L2ToL1MessagePasser.sol";
*/
contract L2CrossDomainMessenger is CrossDomainMessenger, Semver {
/**
* @custom:semver 1.0.0
* @custom:semver 1.1.0
*
* @param _l1CrossDomainMessenger Address of the L1CrossDomainMessenger contract.
*/
constructor(address _l1CrossDomainMessenger)
Semver(1, 0, 0)
Semver(1, 1, 0)
CrossDomainMessenger(_l1CrossDomainMessenger)
{
initialize();
......
......@@ -85,6 +85,8 @@ contract L2StandardBridge is StandardBridge, Semver {
/**
* @custom:legacy
* @notice Initiates a withdrawal from L2 to L1.
* This function only works with OptimismMintableERC20 tokens or ether. Use the
* `bridgeERC20` function to bridge native L2 tokens to L1.
*
* @param _l2Token Address of the L2 token to withdraw.
* @param _amount Amount of the L2 token to withdraw.
......@@ -107,6 +109,8 @@ contract L2StandardBridge is StandardBridge, Semver {
* 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.
* This function only works with OptimismMintableERC20 tokens or ether. Use the
* `bridgeERC20To` function to bridge native L2 tokens to L1.
*
* @param _l2Token Address of the L2 token to withdraw.
* @param _to Recipient account on L1.
......@@ -126,7 +130,8 @@ contract L2StandardBridge is StandardBridge, Semver {
/**
* @custom:legacy
* @notice Finalizes a deposit from L1 to L2.
* @notice Finalizes a deposit from L1 to L2. To finalize a deposit of ether, use address(0)
* and the l1Token and the Legacy ERC20 ether predeploy address as the l2Token.
*
* @param _l1Token Address of the L1 token to deposit.
* @param _l2Token Address of the corresponding L2 token.
......@@ -179,10 +184,10 @@ contract L2StandardBridge is StandardBridge, Semver {
uint32 _minGasLimit,
bytes memory _extraData
) internal {
address l1Token = OptimismMintableERC20(_l2Token).l1Token();
if (_l2Token == Predeploys.LEGACY_ERC20_ETH) {
_initiateBridgeETH(_from, _to, _amount, _minGasLimit, _extraData);
} else {
address l1Token = OptimismMintableERC20(_l2Token).l1Token();
_initiateBridgeERC20(_l2Token, l1Token, _from, _to, _amount, _minGasLimit, _extraData);
}
}
......
......@@ -19,6 +19,9 @@ contract FeeVault_Test is Bridge_Initializer {
super.setUp();
vm.etch(Predeploys.BASE_FEE_VAULT, address(new BaseFeeVault(recipient)).code);
vm.etch(Predeploys.L1_FEE_VAULT, address(new L1FeeVault(recipient)).code);
vm.label(Predeploys.BASE_FEE_VAULT, "BaseFeeVault");
vm.label(Predeploys.L1_FEE_VAULT, "L1FeeVault");
}
function test_constructor_succeeds() external {
......
......@@ -5,6 +5,11 @@
"offset": 0,
"length": 20
},
"spacer_151_0_32": {
"slot": 151,
"offset": 0,
"length": 32
},
"spacer_201_0_32": {
"slot": 201,
"offset": 0,
......@@ -22,6 +27,11 @@
"offset": 0,
"length": 20
},
"spacer_151_0_32": {
"slot": 151,
"offset": 0,
"length": 32
},
"spacer_201_0_32": {
"slot": 201,
"offset": 0,
......
......@@ -6,6 +6,6 @@ rm -rf artifacts forge-artifacts
TEMP=$(mktemp -d)
mv contracts/test $TEMP/test
slither .
slither . --foundry-out-directory artifacts
mv $TEMP/test contracts/test
......@@ -242,7 +242,11 @@ const check = {
signer
)
await assertSemver(L2CrossDomainMessenger, 'L2CrossDomainMessenger')
await assertSemver(
L2CrossDomainMessenger,
'L2CrossDomainMessenger',
'1.1.0'
)
const xDomainMessageSenderSlot = await signer.provider.getStorageAt(
predeploys.L2CrossDomainMessenger,
......
......@@ -1014,6 +1014,7 @@ export class CrossChainMessenger {
* Queries the OptimismPortal contract's `provenWithdrawals` mapping
* for a ProvenWithdrawal that matches the passed withdrawalHash
*
* @bedrock
* Note: This function is bedrock-specific.
*
* @returns A ProvenWithdrawal object
......
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