Commit d567b7f4 authored by Matthew Slipper's avatar Matthew Slipper Committed by GitHub

Merge pull request #2240 from ethereum-optimism/develop

Develop -> Master
parents bce23b77 36efcdec
---
'@eth-optimism/replica-healthcheck': patch
---
Fix bug in replica healthcheck dockerfile
---
'@eth-optimism/integration-tests': patch
---
Replaces l1Provider and l2Provider with env.l1Provider and env.l2Provider respectively.
---
'@eth-optimism/l2geth': patch
---
Remove dead code in l2geth
---
'@eth-optimism/data-transport-layer': patch
---
Include patch contexts for bss hf1
---
'@eth-optimism/data-transport-layer': patch
---
Hardcodes BSS HF1 block into the DTL
---
'@eth-optimism/proxyd': patch
---
Update to go-ethereum v1.10.16
---
'@eth-optimism/gas-oracle': patch
---
Update to go-ethereum v1.10.16
---
'@eth-optimism/batch-submitter-service': patch
---
Update to go-ethereum v1.10.16
---
'@eth-optimism/batch-submitter-service': patch
---
Refactors the bss-core service to use a metrics interface to allow
driver-specific metric extensions
---
'@eth-optimism/l2geth': patch
---
Don't block read rpc requests when syncing
---
'@eth-optimism/l2geth': patch
---
Fix queue index comparison
---
'@eth-optimism/sdk': patch
---
1. Fix a bug in `L2Provider.getL1GasPrice()`
2. Make it easier to get correct estimates from `L2Provider.estimateL1Gas()` and `L2.estimateL2GasCost`.
......@@ -45,7 +45,7 @@ type Driver struct {
rawSccContract *bind.BoundContract
ctcContract *ctc.CanonicalTransactionChain
walletAddr common.Address
metrics *metrics.Metrics
metrics *metrics.Base
}
func NewDriver(cfg Config) (*Driver, error) {
......@@ -82,7 +82,7 @@ func NewDriver(cfg Config) (*Driver, error) {
rawSccContract: rawSccContract,
ctcContract: ctcContract,
walletAddr: walletAddr,
metrics: metrics.NewMetrics(cfg.Name),
metrics: metrics.NewBase("batch_submitter", cfg.Name),
}, nil
}
......@@ -97,7 +97,7 @@ func (d *Driver) WalletAddr() common.Address {
}
// Metrics returns the subservice telemetry object.
func (d *Driver) Metrics() *metrics.Metrics {
func (d *Driver) Metrics() metrics.Metrics {
return d.metrics
}
......@@ -184,7 +184,7 @@ func (d *Driver) CraftBatchTx(
stateRoots = append(stateRoots, block.Root())
}
d.metrics.NumElementsPerBatch.Observe(float64(len(stateRoots)))
d.metrics.NumElementsPerBatch().Observe(float64(len(stateRoots)))
log.Info(name+" batch constructed", "num_state_roots", len(stateRoots))
......
......@@ -44,7 +44,7 @@ type Driver struct {
rawCtcContract *bind.BoundContract
walletAddr common.Address
ctcABI *abi.ABI
metrics *metrics.Metrics
metrics *Metrics
}
func NewDriver(cfg Config) (*Driver, error) {
......@@ -80,7 +80,7 @@ func NewDriver(cfg Config) (*Driver, error) {
rawCtcContract: rawCtcContract,
walletAddr: walletAddr,
ctcABI: ctcABI,
metrics: metrics.NewMetrics(cfg.Name),
metrics: NewMetrics(cfg.Name),
}, nil
}
......@@ -95,7 +95,7 @@ func (d *Driver) WalletAddr() common.Address {
}
// Metrics returns the subservice telemetry object.
func (d *Driver) Metrics() *metrics.Metrics {
func (d *Driver) Metrics() metrics.Metrics {
return d.metrics
}
......@@ -219,7 +219,7 @@ func (d *Driver) CraftBatchTx(
continue
}
d.metrics.NumElementsPerBatch.Observe(float64(len(batchElements)))
d.metrics.NumElementsPerBatch().Observe(float64(len(batchElements)))
d.metrics.BatchPruneCount.Set(float64(pruneCount))
log.Info(name+" batch constructed", "num_txs", len(batchElements), "length", len(batchCallData))
......
package sequencer
import (
"github.com/ethereum-optimism/optimism/go/bss-core/metrics"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
)
// Metrics extends the BSS core metrics with additional metrics tracked by the
// sequencer driver.
type Metrics struct {
*metrics.Base
// BatchPruneCount tracks the number of times a batch of sequencer
// transactions is pruned in order to meet the desired size requirements.
BatchPruneCount prometheus.Gauge
}
// NewMetrics initializes a new, extended metrics object.
func NewMetrics(subsystem string) *Metrics {
base := metrics.NewBase("batch_submitter", subsystem)
return &Metrics{
Base: base,
BatchPruneCount: promauto.NewGauge(prometheus.GaugeOpts{
Name: "batch_prune_count",
Help: "Number of times a batch is pruned",
Subsystem: base.SubsystemName(),
}),
}
}
......@@ -3,14 +3,12 @@ module github.com/ethereum-optimism/optimism/go/batch-submitter
go 1.16
require (
github.com/decred/dcrd/hdkeychain/v3 v3.0.0
github.com/ethereum-optimism/optimism/go/bss-core v0.0.0
github.com/ethereum-optimism/optimism/l2geth v1.0.0
github.com/ethereum/go-ethereum v1.10.12
github.com/ethereum/go-ethereum v1.10.16
github.com/getsentry/sentry-go v0.11.0
github.com/prometheus/client_golang v1.11.0
github.com/stretchr/testify v1.7.0
github.com/tyler-smith/go-bip39 v1.0.1-0.20181017060643-dbb3b84ba2ef
github.com/urfave/cli v1.22.5
)
......
......@@ -121,8 +121,9 @@ github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/deckarep/golang-set v0.0.0-20180603214616-504e848d77ea h1:j4317fAZh7X6GqbFowYdYdI0L9bwxL07jyPZIdepyZ0=
github.com/deckarep/golang-set v0.0.0-20180603214616-504e848d77ea/go.mod h1:93vsz/8Wt4joVM7c2AVqh+YRMiUSc14yDtF28KmMOgQ=
github.com/deckarep/golang-set v1.8.0 h1:sk9/l/KqpunDwP7pSjUg0keiOOLEnOBHzykLrsPppp4=
github.com/deckarep/golang-set v1.8.0/go.mod h1:5nI87KwE7wgsBU1F4GKAw2Qod7p5kyS383rP6+o6qqo=
github.com/decred/base58 v1.0.3 h1:KGZuh8d1WEMIrK0leQRM47W85KqCAdl2N+uagbctdDI=
github.com/decred/base58 v1.0.3/go.mod h1:pXP9cXCfM2sFLb2viz2FNIdeMWmZDBKG3ZBYbiSM78E=
github.com/decred/dcrd/chaincfg/chainhash v1.0.2 h1:rt5Vlq/jM3ZawwiacWjPa+smINyLRN07EO0cNBV6DGU=
......@@ -168,8 +169,9 @@ github.com/elastic/gosigar v0.8.1-0.20180330100440-37f05ff46ffa/go.mod h1:cdorVV
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/etcd-io/bbolt v1.3.3/go.mod h1:ZF2nL25h33cCyBtcyWeZ2/I3HQOfTP+0PIEvHjkjCrw=
github.com/ethereum/go-ethereum v1.10.12 h1:el/KddB3gLEsnNgGQ3SQuZuiZjwnFTYHe5TwUet5Om4=
github.com/ethereum/go-ethereum v1.10.12/go.mod h1:W3yfrFyL9C1pHcwY5hmRHVDaorTiQxhYBkKyu5mEDHw=
github.com/ethereum/go-ethereum v1.10.16 h1:3oPrumn0bCW/idjcxMn5YYVCdK7VzJYIvwGZUGLEaoc=
github.com/ethereum/go-ethereum v1.10.16/go.mod h1:Anj6cxczl+AHy63o4X9O8yWNHuN5wMpfb8MAnHkWn7Y=
github.com/fasthttp-contrib/websocket v0.0.0-20160511215533-1f3b11f56072/go.mod h1:duJ4Jxv5lDcvg4QuQr0oowTf7dz4/CR8NtyCooz9HL8=
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M=
......@@ -275,6 +277,7 @@ github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/ad
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/graph-gophers/graphql-go v0.0.0-20201113091052-beb923fada29/go.mod h1:9CQHMSxwO4MprSdzoIEobiHpoLtHm77vfxsvsIN5Vuc=
github.com/graph-gophers/graphql-go v1.3.0/go.mod h1:9CQHMSxwO4MprSdzoIEobiHpoLtHm77vfxsvsIN5Vuc=
github.com/hashicorp/go-bexpr v0.1.10 h1:9kuI5PFotCboP3dkDYFr/wi0gg0QVbSNz5oFRpxn4uE=
github.com/hashicorp/go-bexpr v0.1.10/go.mod h1:oxlubA2vC/gFVfX1A6JGp7ls7uCDlfJn732ehYYg+g0=
github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
......@@ -310,8 +313,9 @@ github.com/iris-contrib/go.uuid v2.0.0+incompatible/go.mod h1:iz2lgM/1UnEf1kP0L/
github.com/iris-contrib/jade v1.1.3/go.mod h1:H/geBymxJhShH5kecoiOCSssPX7QWYH7UaeZTSWddIk=
github.com/iris-contrib/pongo2 v0.0.1/go.mod h1:Ssh+00+3GAZqSQb30AvBRNxBx7rf0GqwkjqxNd0u65g=
github.com/iris-contrib/schema v0.0.1/go.mod h1:urYA3uvUNG1TIIjOSCzHr9/LmbQo8LrOcOqfqxa4hXw=
github.com/jackpal/go-nat-pmp v1.0.2-0.20160603034137-1fa385a6f458 h1:6OvNmYgJyexcZ3pYbTI9jWx5tHo1Dee/tWbLMfPe2TA=
github.com/jackpal/go-nat-pmp v1.0.2-0.20160603034137-1fa385a6f458/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc=
github.com/jackpal/go-nat-pmp v1.0.2 h1:KzKSgb7qkJvOUTqYl9/Hg/me3pWgBmERKrTGD7BdWus=
github.com/jackpal/go-nat-pmp v1.0.2/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc=
github.com/jarcoal/httpmock v1.0.8/go.mod h1:ATjnClrvW/3tijVmpL/va5Z3aAyGvqU3gCT8nX0Txik=
github.com/jedisct1/go-minisign v0.0.0-20190909160543-45766022959e/go.mod h1:G1CVv03EnqU1wYL2dFwXxW2An0az9JTl/ZsqXQeBlkU=
github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
......@@ -334,6 +338,7 @@ github.com/jung-kurt/gofpdf v1.0.3-0.20190309125859-24315acbbda5/go.mod h1:7Id9E
github.com/jwilder/encoding v0.0.0-20170811194829-b4e1701a28ef/go.mod h1:Ct9fl0F6iIOGgxJ5npU/IUOhOhqlVrGjyIZc8/MagT0=
github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88/go.mod h1:3w7q1U84EfirKl04SVQ/s7nPm1ZPhiXd34z40TNz36k=
github.com/karalabe/usb v0.0.0-20211005121534-4c5740d64559/go.mod h1:Od972xHfMJowv7NGVDiWVxk2zxnWgjLlJzE+F4F7AGU=
github.com/karalabe/usb v0.0.2/go.mod h1:Od972xHfMJowv7NGVDiWVxk2zxnWgjLlJzE+F4F7AGU=
github.com/kataras/golog v0.0.10/go.mod h1:yJ8YKCmyL+nWjERB90Qwn+bdyBZsaQwU3bTVFgkFIp8=
github.com/kataras/iris/v12 v12.1.8/go.mod h1:LMYy4VlP67TQ3Zgriz8RE2h2kMZV2SgMYbq3UhfoFmE=
github.com/kataras/neffos v0.0.14/go.mod h1:8lqADm8PnbeFfL7CLXh1WHw53dG27MC3pgi2R1rmoTE=
......
package metrics
import "github.com/prometheus/client_golang/prometheus"
type Metrics interface {
// SubsystemName returns the subsystem name for the metrics group.
SubsystemName() string
// BalanceETH tracks the amount of ETH in the submitter's account.
BalanceETH() prometheus.Gauge
// BatchSizeBytes tracks the size of batch submission transactions.
BatchSizeBytes() prometheus.Summary
// NumElementsPerBatch tracks the number of L2 transactions in each batch
// submission.
NumElementsPerBatch() prometheus.Summary
// SubmissionTimestamp tracks the time at which each batch was confirmed.
SubmissionTimestamp() prometheus.Gauge
// SubmissionGasUsedWei tracks the amount of gas used to submit each batch.
SubmissionGasUsedWei() prometheus.Gauge
// BatchsSubmitted tracks the total number of successful batch submissions.
BatchesSubmitted() prometheus.Counter
// FailedSubmissions tracks the total number of failed batch submissions.
FailedSubmissions() prometheus.Counter
// BatchTxBuildTimeMs tracks the duration it takes to construct a batch
// transaction.
BatchTxBuildTimeMs() prometheus.Gauge
// BatchConfirmationTimeMs tracks the duration it takes to confirm a batch
// transaction.
BatchConfirmationTimeMs() prometheus.Gauge
}
package metrics
import (
"fmt"
"strings"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
)
type Metrics struct {
// ETHBalance tracks the amount of ETH in the submitter's account.
ETHBalance prometheus.Gauge
type Base struct {
// subsystemName stores the name that will prefix all metrics. This can be
// used by drivers to futher extend the core metrics and ensure they use the
// same prefix.
subsystemName string
// BatchSizeInBytes tracks the size of batch submission transactions.
BatchSizeInBytes prometheus.Summary
// balanceETH tracks the amount of ETH in the submitter's account.
balanceETH prometheus.Gauge
// NumElementsPerBatch tracks the number of L2 transactions in each batch
// batchSizeBytes tracks the size of batch submission transactions.
batchSizeBytes prometheus.Summary
// numElementsPerBatch tracks the number of L2 transactions in each batch
// submission.
NumElementsPerBatch prometheus.Summary
numElementsPerBatch prometheus.Summary
// SubmissionTimestamp tracks the time at which each batch was confirmed.
SubmissionTimestamp prometheus.Gauge
// submissionTimestamp tracks the time at which each batch was confirmed.
submissionTimestamp prometheus.Gauge
// SubmissionGasUsed tracks the amount of gas used to submit each batch.
SubmissionGasUsed prometheus.Gauge
// submissionGasUsedWei tracks the amount of gas used to submit each batch.
submissionGasUsedWei prometheus.Gauge
// BatchsSubmitted tracks the total number of successful batch submissions.
BatchesSubmitted prometheus.Counter
// batchsSubmitted tracks the total number of successful batch submissions.
batchesSubmitted prometheus.Counter
// FailedSubmissions tracks the total number of failed batch submissions.
FailedSubmissions prometheus.Counter
// failedSubmissions tracks the total number of failed batch submissions.
failedSubmissions prometheus.Counter
// BatchTxBuildTime tracks the duration it takes to construct a batch
// batchTxBuildTimeMs tracks the duration it takes to construct a batch
// transaction.
BatchTxBuildTime prometheus.Gauge
batchTxBuildTimeMs prometheus.Gauge
// BatchConfirmationTime tracks the duration it takes to confirm a batch
// batchConfirmationTimeMs tracks the duration it takes to confirm a batch
// transaction.
BatchConfirmationTime prometheus.Gauge
// BatchPruneCount tracks the number of times a batch of sequencer
// transactions is pruned in order to meet the desired size requirements.
//
// NOTE: This is currently only active in the sequencer driver.
BatchPruneCount prometheus.Gauge
batchConfirmationTimeMs prometheus.Gauge
}
func NewMetrics(subsystem string) *Metrics {
subsystem = "batch_submitter_" + strings.ToLower(subsystem)
return &Metrics{
ETHBalance: promauto.NewGauge(prometheus.GaugeOpts{
func NewBase(serviceName, subServiceName string) *Base {
subsystem := MakeSubsystemName(serviceName, subServiceName)
return &Base{
subsystemName: subsystem,
balanceETH: promauto.NewGauge(prometheus.GaugeOpts{
Name: "balance_eth",
Help: "ETH balance of the batch submitter",
Subsystem: subsystem,
}),
BatchSizeInBytes: promauto.NewSummary(prometheus.SummaryOpts{
batchSizeBytes: promauto.NewSummary(prometheus.SummaryOpts{
Name: "batch_size_bytes",
Help: "Size of batches in bytes",
Subsystem: subsystem,
Objectives: map[float64]float64{0.5: 0.05, 0.9: 0.01, 0.99: 0.001},
}),
NumElementsPerBatch: promauto.NewSummary(prometheus.SummaryOpts{
numElementsPerBatch: promauto.NewSummary(prometheus.SummaryOpts{
Name: "num_elements_per_batch",
Help: "Number of elements in each batch",
Objectives: map[float64]float64{0.5: 0.05, 0.9: 0.01, 0.99: 0.001},
Subsystem: subsystem,
}),
SubmissionTimestamp: promauto.NewGauge(prometheus.GaugeOpts{
submissionTimestamp: promauto.NewGauge(prometheus.GaugeOpts{
Name: "submission_timestamp_ms",
Help: "Timestamp of last batch submitter submission",
Subsystem: subsystem,
}),
SubmissionGasUsed: promauto.NewGauge(prometheus.GaugeOpts{
submissionGasUsedWei: promauto.NewGauge(prometheus.GaugeOpts{
Name: "submission_gas_used_wei",
Help: "Gas used to submit each batch",
Subsystem: subsystem,
}),
BatchesSubmitted: promauto.NewCounter(prometheus.CounterOpts{
batchesSubmitted: promauto.NewCounter(prometheus.CounterOpts{
Name: "batches_submitted",
Help: "Count of batches submitted",
Subsystem: subsystem,
}),
FailedSubmissions: promauto.NewCounter(prometheus.CounterOpts{
failedSubmissions: promauto.NewCounter(prometheus.CounterOpts{
Name: "failed_submissions",
Help: "Count of failed batch submissions",
Subsystem: subsystem,
}),
BatchTxBuildTime: promauto.NewGauge(prometheus.GaugeOpts{
batchTxBuildTimeMs: promauto.NewGauge(prometheus.GaugeOpts{
Name: "batch_tx_build_time_ms",
Help: "Time to construct batch transactions",
Subsystem: subsystem,
}),
BatchConfirmationTime: promauto.NewGauge(prometheus.GaugeOpts{
batchConfirmationTimeMs: promauto.NewGauge(prometheus.GaugeOpts{
Name: "batch_confirmation_time_ms",
Help: "Time to confirm batch transactions",
Subsystem: subsystem,
}),
BatchPruneCount: promauto.NewGauge(prometheus.GaugeOpts{
Name: "batch_prune_count",
Help: "Number of times a batch is pruned",
Subsystem: subsystem,
}),
}
}
// SubsystemName returns the subsystem name for the metrics group.
func (b *Base) SubsystemName() string {
return b.subsystemName
}
// BalanceETH tracks the amount of ETH in the submitter's account.
func (b *Base) BalanceETH() prometheus.Gauge {
return b.balanceETH
}
// BatchSizeBytes tracks the size of batch submission transactions.
func (b *Base) BatchSizeBytes() prometheus.Summary {
return b.batchSizeBytes
}
// NumElementsPerBatch tracks the number of L2 transactions in each batch
// submission.
func (b *Base) NumElementsPerBatch() prometheus.Summary {
return b.numElementsPerBatch
}
// SubmissionTimestamp tracks the time at which each batch was confirmed.
func (b *Base) SubmissionTimestamp() prometheus.Gauge {
return b.submissionTimestamp
}
// SubmissionGasUsedWei tracks the amount of gas used to submit each batch.
func (b *Base) SubmissionGasUsedWei() prometheus.Gauge {
return b.submissionGasUsedWei
}
// BatchsSubmitted tracks the total number of successful batch submissions.
func (b *Base) BatchesSubmitted() prometheus.Counter {
return b.batchesSubmitted
}
// FailedSubmissions tracks the total number of failed batch submissions.
func (b *Base) FailedSubmissions() prometheus.Counter {
return b.failedSubmissions
}
// BatchTxBuildTimeMs tracks the duration it takes to construct a batch
// transaction.
func (b *Base) BatchTxBuildTimeMs() prometheus.Gauge {
return b.batchTxBuildTimeMs
}
// BatchConfirmationTimeMs tracks the duration it takes to confirm a batch
// transaction.
func (b *Base) BatchConfirmationTimeMs() prometheus.Gauge {
return b.batchConfirmationTimeMs
}
// MakeSubsystemName builds the subsystem name for a group of metrics, which
// prometheus will use to prefix all metrics in the group. If two non-empty
// strings are provided, they are joined with an underscore. If only one
// non-empty string is provided, that name will be used alone. Otherwise an
// empty string is returned after converting the characters to lower case.
//
// NOTE: This method panics if spaces are included in either string.
func MakeSubsystemName(serviceName string, subServiceName string) string {
var subsystem string
switch {
case serviceName != "" && subServiceName != "":
subsystem = fmt.Sprintf("%s_%s", serviceName, subServiceName)
case serviceName != "":
subsystem = serviceName
default:
subsystem = subServiceName
}
if strings.ContainsAny(subsystem, " ") {
panic(fmt.Sprintf("metrics name \"%s\"cannot have spaces", subsystem))
}
return strings.ToLower(subsystem)
}
......@@ -31,7 +31,7 @@ type Driver interface {
WalletAddr() common.Address
// Metrics returns the subservice telemetry object.
Metrics() *metrics.Metrics
Metrics() metrics.Metrics
// ClearPendingTx a publishes a transaction at the next available nonce in
// order to clear any transactions in the mempool left over from a prior
......@@ -83,7 +83,7 @@ type Service struct {
cancel func()
txMgr txmgr.TxManager
metrics *metrics.Metrics
metrics metrics.Metrics
wg sync.WaitGroup
}
......@@ -147,7 +147,7 @@ func (s *Service) eventLoop() {
log.Error(name+" unable to get current balance", "err", err)
continue
}
s.metrics.ETHBalance.Set(weiToEth64(balance))
s.metrics.BalanceETH().Set(weiToEth64(balance))
// Determine the range of L2 blocks that the batch submitter has not
// processed, and needs to take action on.
......@@ -186,7 +186,7 @@ func (s *Service) eventLoop() {
continue
}
batchTxBuildTime := time.Since(batchTxBuildStart) / time.Millisecond
s.metrics.BatchTxBuildTime.Set(float64(batchTxBuildTime))
s.metrics.BatchTxBuildTimeMs().Set(float64(batchTxBuildTime))
// Record the size of the batch transaction.
var txBuf bytes.Buffer
......@@ -194,7 +194,7 @@ func (s *Service) eventLoop() {
log.Error(name+" unable to encode batch tx", "err", err)
continue
}
s.metrics.BatchSizeInBytes.Observe(float64(len(txBuf.Bytes())))
s.metrics.BatchSizeBytes().Observe(float64(len(txBuf.Bytes())))
// Construct the transaction submission clousure that will attempt
// to send the next transaction at the given nonce and gas price.
......@@ -214,7 +214,7 @@ func (s *Service) eventLoop() {
if err != nil {
log.Error(name+" unable to publish batch tx",
"err", err)
s.metrics.FailedSubmissions.Inc()
s.metrics.FailedSubmissions().Inc()
continue
}
......@@ -223,10 +223,10 @@ func (s *Service) eventLoop() {
"tx_hash", receipt.TxHash)
batchConfirmationTime := time.Since(batchConfirmationStart) /
time.Millisecond
s.metrics.BatchConfirmationTime.Set(float64(batchConfirmationTime))
s.metrics.BatchesSubmitted.Inc()
s.metrics.SubmissionGasUsed.Set(float64(receipt.GasUsed))
s.metrics.SubmissionTimestamp.Set(float64(time.Now().UnixNano() / 1e6))
s.metrics.BatchConfirmationTimeMs().Set(float64(batchConfirmationTime))
s.metrics.BatchesSubmitted().Inc()
s.metrics.SubmissionGasUsedWei().Set(float64(receipt.GasUsed))
s.metrics.SubmissionTimestamp().Set(float64(time.Now().UnixNano() / 1e6))
case err := <-s.ctx.Done():
log.Error(name+" service shutting down", "err", err)
......
......@@ -3,6 +3,6 @@ module github.com/ethereum-optimism/optimism/go/gas-oracle
go 1.16
require (
github.com/ethereum/go-ethereum v1.10.10
github.com/ethereum/go-ethereum v1.10.16
github.com/urfave/cli v1.20.0
)
......@@ -92,8 +92,8 @@ github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/deckarep/golang-set v0.0.0-20180603214616-504e848d77ea h1:j4317fAZh7X6GqbFowYdYdI0L9bwxL07jyPZIdepyZ0=
github.com/deckarep/golang-set v0.0.0-20180603214616-504e848d77ea/go.mod h1:93vsz/8Wt4joVM7c2AVqh+YRMiUSc14yDtF28KmMOgQ=
github.com/deckarep/golang-set v1.8.0 h1:sk9/l/KqpunDwP7pSjUg0keiOOLEnOBHzykLrsPppp4=
github.com/deckarep/golang-set v1.8.0/go.mod h1:5nI87KwE7wgsBU1F4GKAw2Qod7p5kyS383rP6+o6qqo=
github.com/deepmap/oapi-codegen v1.6.0/go.mod h1:ryDa9AgbELGeB+YEXE1dR53yAjHwFvE9iAUlWl9Al3M=
github.com/deepmap/oapi-codegen v1.8.2 h1:SegyeYGcdi0jLLrpbCMoJxnUUn8GBXHsvr4rbzjuhfU=
github.com/deepmap/oapi-codegen v1.8.2/go.mod h1:YLgSKSDv/bZQB7N4ws6luhozi3cEdRktEqrX88CvjIw=
......@@ -109,8 +109,8 @@ github.com/edsrzf/mmap-go v1.0.0 h1:CEBF7HpRnUCSJgGUb5h1Gm7e3VkmVDrR8lvWVLtrOFw=
github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M=
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/ethereum/go-ethereum v1.10.10 h1:Ft2GcLQrr2M89l49g9NoqgNtJZ9AahzMb7N6VXKZy5U=
github.com/ethereum/go-ethereum v1.10.10/go.mod h1:W3yfrFyL9C1pHcwY5hmRHVDaorTiQxhYBkKyu5mEDHw=
github.com/ethereum/go-ethereum v1.10.16 h1:3oPrumn0bCW/idjcxMn5YYVCdK7VzJYIvwGZUGLEaoc=
github.com/ethereum/go-ethereum v1.10.16/go.mod h1:Anj6cxczl+AHy63o4X9O8yWNHuN5wMpfb8MAnHkWn7Y=
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5 h1:FtmdgXiUlNeRsoNMFlKLDt+S+6hbjVMEW6RGQ7aUf7c=
github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5/go.mod h1:VvhXpOYNQvB+uIk2RvXzuaQtkQJzzIx6lSBe1xv7hi0=
......@@ -191,7 +191,7 @@ github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORR
github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/graph-gophers/graphql-go v0.0.0-20201113091052-beb923fada29/go.mod h1:9CQHMSxwO4MprSdzoIEobiHpoLtHm77vfxsvsIN5Vuc=
github.com/graph-gophers/graphql-go v1.3.0/go.mod h1:9CQHMSxwO4MprSdzoIEobiHpoLtHm77vfxsvsIN5Vuc=
github.com/hashicorp/go-bexpr v0.1.10 h1:9kuI5PFotCboP3dkDYFr/wi0gg0QVbSNz5oFRpxn4uE=
github.com/hashicorp/go-bexpr v0.1.10/go.mod h1:oxlubA2vC/gFVfX1A6JGp7ls7uCDlfJn732ehYYg+g0=
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
......@@ -222,8 +222,8 @@ github.com/influxdata/promql/v2 v2.12.0/go.mod h1:fxOPu+DY0bqCTCECchSRtWfc+0X19y
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=
github.com/influxdata/usage-client v0.0.0-20160829180054-6d3895376368/go.mod h1:Wbbw6tYNvwa5dlB6304Sd+82Z3f7PmVZHVKU637d4po=
github.com/jackpal/go-nat-pmp v1.0.2-0.20160603034137-1fa385a6f458 h1:6OvNmYgJyexcZ3pYbTI9jWx5tHo1Dee/tWbLMfPe2TA=
github.com/jackpal/go-nat-pmp v1.0.2-0.20160603034137-1fa385a6f458/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc=
github.com/jackpal/go-nat-pmp v1.0.2 h1:KzKSgb7qkJvOUTqYl9/Hg/me3pWgBmERKrTGD7BdWus=
github.com/jackpal/go-nat-pmp v1.0.2/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc=
github.com/jedisct1/go-minisign v0.0.0-20190909160543-45766022959e/go.mod h1:G1CVv03EnqU1wYL2dFwXxW2An0az9JTl/ZsqXQeBlkU=
github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo=
......@@ -237,7 +237,7 @@ github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfV
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
github.com/jung-kurt/gofpdf v1.0.3-0.20190309125859-24315acbbda5/go.mod h1:7Id9E/uU8ce6rXgefFLlgrJj/GYY22cpxn+r32jIOes=
github.com/jwilder/encoding v0.0.0-20170811194829-b4e1701a28ef/go.mod h1:Ct9fl0F6iIOGgxJ5npU/IUOhOhqlVrGjyIZc8/MagT0=
github.com/karalabe/usb v0.0.0-20211005121534-4c5740d64559/go.mod h1:Od972xHfMJowv7NGVDiWVxk2zxnWgjLlJzE+F4F7AGU=
github.com/karalabe/usb v0.0.2/go.mod h1:Od972xHfMJowv7NGVDiWVxk2zxnWgjLlJzE+F4F7AGU=
github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4=
......
......@@ -6,7 +6,7 @@ require (
github.com/BurntSushi/toml v0.4.1
github.com/alicebob/gopher-json v0.0.0-20200520072559-a9ecdc9d1d3a // indirect
github.com/alicebob/miniredis v2.5.0+incompatible
github.com/ethereum/go-ethereum v1.10.11
github.com/ethereum/go-ethereum v1.10.16
github.com/go-redis/redis/v8 v8.11.4
github.com/golang/snappy v0.0.4
github.com/gomodule/redigo v1.8.8 // indirect
......
......@@ -102,8 +102,8 @@ github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/deckarep/golang-set v0.0.0-20180603214616-504e848d77ea h1:j4317fAZh7X6GqbFowYdYdI0L9bwxL07jyPZIdepyZ0=
github.com/deckarep/golang-set v0.0.0-20180603214616-504e848d77ea/go.mod h1:93vsz/8Wt4joVM7c2AVqh+YRMiUSc14yDtF28KmMOgQ=
github.com/deckarep/golang-set v1.8.0 h1:sk9/l/KqpunDwP7pSjUg0keiOOLEnOBHzykLrsPppp4=
github.com/deckarep/golang-set v1.8.0/go.mod h1:5nI87KwE7wgsBU1F4GKAw2Qod7p5kyS383rP6+o6qqo=
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/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
......@@ -120,8 +120,8 @@ github.com/edsrzf/mmap-go v1.0.0 h1:CEBF7HpRnUCSJgGUb5h1Gm7e3VkmVDrR8lvWVLtrOFw=
github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M=
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/ethereum/go-ethereum v1.10.11 h1:KKIcwpmur9iTaVbR2dxlHu+peHVhU+/KX//NWvT1n9U=
github.com/ethereum/go-ethereum v1.10.11/go.mod h1:W3yfrFyL9C1pHcwY5hmRHVDaorTiQxhYBkKyu5mEDHw=
github.com/ethereum/go-ethereum v1.10.16 h1:3oPrumn0bCW/idjcxMn5YYVCdK7VzJYIvwGZUGLEaoc=
github.com/ethereum/go-ethereum v1.10.16/go.mod h1:Anj6cxczl+AHy63o4X9O8yWNHuN5wMpfb8MAnHkWn7Y=
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5 h1:FtmdgXiUlNeRsoNMFlKLDt+S+6hbjVMEW6RGQ7aUf7c=
github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5/go.mod h1:VvhXpOYNQvB+uIk2RvXzuaQtkQJzzIx6lSBe1xv7hi0=
......@@ -219,7 +219,7 @@ github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI=
github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/graph-gophers/graphql-go v0.0.0-20201113091052-beb923fada29/go.mod h1:9CQHMSxwO4MprSdzoIEobiHpoLtHm77vfxsvsIN5Vuc=
github.com/graph-gophers/graphql-go v1.3.0/go.mod h1:9CQHMSxwO4MprSdzoIEobiHpoLtHm77vfxsvsIN5Vuc=
github.com/hashicorp/go-bexpr v0.1.10 h1:9kuI5PFotCboP3dkDYFr/wi0gg0QVbSNz5oFRpxn4uE=
github.com/hashicorp/go-bexpr v0.1.10/go.mod h1:oxlubA2vC/gFVfX1A6JGp7ls7uCDlfJn732ehYYg+g0=
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
......@@ -247,8 +247,8 @@ github.com/influxdata/promql/v2 v2.12.0/go.mod h1:fxOPu+DY0bqCTCECchSRtWfc+0X19y
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=
github.com/influxdata/usage-client v0.0.0-20160829180054-6d3895376368/go.mod h1:Wbbw6tYNvwa5dlB6304Sd+82Z3f7PmVZHVKU637d4po=
github.com/jackpal/go-nat-pmp v1.0.2-0.20160603034137-1fa385a6f458 h1:6OvNmYgJyexcZ3pYbTI9jWx5tHo1Dee/tWbLMfPe2TA=
github.com/jackpal/go-nat-pmp v1.0.2-0.20160603034137-1fa385a6f458/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc=
github.com/jackpal/go-nat-pmp v1.0.2 h1:KzKSgb7qkJvOUTqYl9/Hg/me3pWgBmERKrTGD7BdWus=
github.com/jackpal/go-nat-pmp v1.0.2/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc=
github.com/jedisct1/go-minisign v0.0.0-20190909160543-45766022959e/go.mod h1:G1CVv03EnqU1wYL2dFwXxW2An0az9JTl/ZsqXQeBlkU=
github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo=
......@@ -267,7 +267,7 @@ github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7V
github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM=
github.com/jung-kurt/gofpdf v1.0.3-0.20190309125859-24315acbbda5/go.mod h1:7Id9E/uU8ce6rXgefFLlgrJj/GYY22cpxn+r32jIOes=
github.com/jwilder/encoding v0.0.0-20170811194829-b4e1701a28ef/go.mod h1:Ct9fl0F6iIOGgxJ5npU/IUOhOhqlVrGjyIZc8/MagT0=
github.com/karalabe/usb v0.0.0-20211005121534-4c5740d64559/go.mod h1:Od972xHfMJowv7NGVDiWVxk2zxnWgjLlJzE+F4F7AGU=
github.com/karalabe/usb v0.0.2/go.mod h1:Od972xHfMJowv7NGVDiWVxk2zxnWgjLlJzE+F4F7AGU=
github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4=
......
......@@ -2,17 +2,11 @@
import { ethers } from 'hardhat'
import { expectApprox } from '@eth-optimism/core-utils'
import { predeploys } from '@eth-optimism/contracts'
import { asL2Provider } from '@eth-optimism/sdk'
import { Contract, BigNumber } from 'ethers'
/* Imports: Internal */
import { expect } from './shared/setup'
import {
l2Provider,
l1Provider,
envConfig,
DEFAULT_TEST_GAS_L1,
} from './shared/utils'
import { envConfig, DEFAULT_TEST_GAS_L1 } from './shared/utils'
import { OptimismEnv } from './shared/env'
/**
......@@ -21,7 +15,6 @@ import { OptimismEnv } from './shared/env'
* must be equal to the blocknumber/timestamp of the L1 transaction.
*/
describe('OVM Context: Layer 2 EVM Context', () => {
const L2Provider = asL2Provider(l2Provider)
let env: OptimismEnv
before(async () => {
env = await OptimismEnv.new()
......@@ -66,8 +59,10 @@ describe('OVM Context: Layer 2 EVM Context', () => {
// Get the L1 block that the enqueue transaction was in so that
// the timestamp can be compared against the layer two contract
const l1Block = await l1Provider.getBlock(pair.receipt.blockNumber)
const l2Block = await l2Provider.getBlock(pair.remoteReceipt.blockNumber)
const l1Block = await env.l1Provider.getBlock(pair.receipt.blockNumber)
const l2Block = await env.l2Provider.getBlock(
pair.remoteReceipt.blockNumber
)
// block.number should return the value of the L2 block number.
const l2BlockNumber = await OVMContextStorage.blockNumbers(i)
......@@ -103,7 +98,7 @@ describe('OVM Context: Layer 2 EVM Context', () => {
})
await dummyTx.wait()
const block = await L2Provider.getBlockWithTransactions('latest')
const block = await env.l2Provider.getBlockWithTransactions('latest')
const [, returnData] = await Multicall.callStatic.aggregate(
[
[
......
/* Imports: External */
import { expectApprox, sleep } from '@eth-optimism/core-utils'
import { asL2Provider } from '@eth-optimism/sdk'
import { Wallet, BigNumber, Contract, ContractFactory, constants } from 'ethers'
import { serialize } from '@ethersproject/transactions'
import { ethers } from 'hardhat'
......@@ -11,7 +10,6 @@ import {
/* Imports: Internal */
import {
l2Provider,
defaultTransactionFactory,
fundUser,
L2_CHAINID,
......@@ -27,8 +25,6 @@ describe('Basic RPC tests', () => {
let env: OptimismEnv
let wallet: Wallet
const provider = asL2Provider(l2Provider)
let Reverter: Contract
let ValueContext: Contract
let revertMessage: string
......@@ -86,7 +82,7 @@ describe('Basic RPC tests', () => {
}
await expect(
provider.sendTransaction(await wallet.signTransaction(tx))
env.l2Provider.sendTransaction(await wallet.signTransaction(tx))
).to.be.rejectedWith('invalid transaction: invalid sender')
})
......@@ -98,7 +94,7 @@ describe('Basic RPC tests', () => {
chainId: null, // Disables EIP155 transaction signing.
}
const signed = await wallet.signTransaction(tx)
const response = await provider.sendTransaction(signed)
const response = await env.l2Provider.sendTransaction(signed)
expect(response.chainId).to.equal(0)
const v = response.v
......@@ -114,12 +110,14 @@ describe('Basic RPC tests', () => {
value: ethers.utils.parseEther('0.1'),
}
const balanceBefore = await provider.getBalance(env.l2Wallet.address)
const balanceBefore = await env.l2Provider.getBalance(
env.l2Wallet.address
)
const result = await env.l2Wallet.sendTransaction(tx)
const receipt = await result.wait()
expect(receipt.status).to.deep.equal(1)
const balAfter = await provider.getBalance(env.l2Wallet.address)
const balAfter = await env.l2Provider.getBalance(env.l2Wallet.address)
expect(balAfter.lte(balanceBefore.sub(ethers.utils.parseEther('0.1')))).to
.be.true
})
......@@ -187,7 +185,7 @@ describe('Basic RPC tests', () => {
describe('eth_call', () => {
it('should correctly identify call out-of-gas', async () => {
await expect(
provider.call({
env.l2Provider.call({
...revertingTx,
gasLimit: 1,
})
......@@ -195,7 +193,9 @@ describe('Basic RPC tests', () => {
})
it('should correctly return solidity revert data from a call', async () => {
await expect(provider.call(revertingTx)).to.be.revertedWith(revertMessage)
await expect(env.l2Provider.call(revertingTx)).to.be.revertedWith(
revertMessage
)
})
it('should produce error when called from ethers', async () => {
......@@ -203,14 +203,14 @@ describe('Basic RPC tests', () => {
})
it('should correctly return revert data from contract creation', async () => {
await expect(provider.call(revertingDeployTx)).to.be.revertedWith(
await expect(env.l2Provider.call(revertingDeployTx)).to.be.revertedWith(
revertMessage
)
})
it('should correctly identify contract creation out of gas', async () => {
await expect(
provider.call({
env.l2Provider.call({
...revertingDeployTx,
gasLimit: 1,
})
......@@ -225,7 +225,7 @@ describe('Basic RPC tests', () => {
// Do the call and check msg.value
const data = ValueContext.interface.encodeFunctionData('getCallValue')
const res = await provider.call({
const res = await env.l2Provider.call({
to: ValueContext.address,
from,
data,
......@@ -239,7 +239,7 @@ describe('Basic RPC tests', () => {
it('should use address(0) as the default "from" value', async () => {
// Do the call and check msg.sender
const data = ValueContext.interface.encodeFunctionData('getCaller')
const res = await provider.call({
const res = await env.l2Provider.call({
to: ValueContext.address,
data,
})
......@@ -257,7 +257,7 @@ describe('Basic RPC tests', () => {
// Do the call and check msg.sender
const data = ValueContext.interface.encodeFunctionData('getCaller')
const res = await provider.call({
const res = await env.l2Provider.call({
to: ValueContext.address,
from,
data,
......@@ -297,9 +297,8 @@ describe('Basic RPC tests', () => {
}
expect(errored).to.be.true
const receipt: TransactionReceipt = await provider.getTransactionReceipt(
tx.hash
)
const receipt: TransactionReceipt =
await env.l2Provider.getTransactionReceipt(tx.hash)
expect(receipt.status).to.eq(0)
})
......@@ -320,9 +319,8 @@ describe('Basic RPC tests', () => {
}
expect(errored).to.be.true
const receipt: TransactionReceipt = await provider.getTransactionReceipt(
tx.hash
)
const receipt: TransactionReceipt =
await env.l2Provider.getTransactionReceipt(tx.hash)
expect(receipt.status).to.eq(0)
})
......@@ -354,7 +352,9 @@ describe('Basic RPC tests', () => {
const res = await env.l2Wallet.sendTransaction(tx)
await res.wait()
const json = await provider.send('eth_getTransactionReceipt', [res.hash])
const json = await env.l2Provider.send('eth_getTransactionReceipt', [
res.hash,
])
expect(l1GasUsed).to.deep.equal(BigNumber.from(json.l1GasUsed))
expect(l1GasPrice).to.deep.equal(BigNumber.from(json.l1GasPrice))
......@@ -370,7 +370,9 @@ describe('Basic RPC tests', () => {
const result = await wallet.sendTransaction(tx)
await result.wait()
const transaction = (await provider.getTransaction(result.hash)) as any
const transaction = (await env.l2Provider.getTransaction(
result.hash
)) as any
expect(transaction.queueOrigin).to.equal('sequencer')
expect(transaction.transactionIndex).to.be.eq(0)
expect(transaction.gasLimit).to.be.deep.eq(BigNumber.from(tx.gasLimit))
......@@ -385,7 +387,7 @@ describe('Basic RPC tests', () => {
const result = await wallet.sendTransaction(tx)
const receipt = await result.wait()
const block = (await provider.getBlockWithTransactions(
const block = (await env.l2Provider.getBlockWithTransactions(
receipt.blockHash
)) as any
......@@ -411,13 +413,13 @@ describe('Basic RPC tests', () => {
'should return the same result when new transactions are not applied',
async () => {
// Get latest block once to start.
const prev = await provider.getBlockWithTransactions('latest')
const prev = await env.l2Provider.getBlockWithTransactions('latest')
// set wait to null to allow a deep object comparison
prev.transactions[0].wait = null
// Over ten seconds, repeatedly check the latest block to make sure nothing has changed.
for (let i = 0; i < 5; i++) {
const latest = await provider.getBlockWithTransactions('latest')
const latest = await env.l2Provider.getBlockWithTransactions('latest')
latest.transactions[0].wait = null
// Check each key of the transaction individually
// for easy debugging if one field changes
......@@ -436,7 +438,7 @@ describe('Basic RPC tests', () => {
describe('eth_getBalance', () => {
it('should get the OVM_ETH balance', async () => {
const rpcBalance = await provider.getBalance(env.l2Wallet.address)
const rpcBalance = await env.l2Provider.getBalance(env.l2Wallet.address)
const contractBalance = await env.ovmEth.balanceOf(env.l2Wallet.address)
expect(rpcBalance).to.be.deep.eq(contractBalance)
})
......@@ -444,7 +446,7 @@ describe('Basic RPC tests', () => {
describe('eth_chainId', () => {
it('should get the correct chainid', async () => {
const { chainId } = await provider.getNetwork()
const { chainId } = await env.l2Provider.getNetwork()
expect(chainId).to.be.eq(L2_CHAINID)
})
})
......@@ -453,7 +455,7 @@ describe('Basic RPC tests', () => {
it('simple send gas estimation is deterministic', async () => {
let lastEstimate: BigNumber
for (let i = 0; i < 10; i++) {
const estimate = await l2Provider.estimateGas({
const estimate = await env.l2Provider.estimateGas({
to: defaultTransactionFactory().to,
value: 0,
})
......@@ -476,7 +478,7 @@ describe('Basic RPC tests', () => {
})
it('should return a gas estimate for txs with empty data', async () => {
const estimate = await l2Provider.estimateGas({
const estimate = await env.l2Provider.estimateGas({
to: defaultTransactionFactory().to,
value: 0,
})
......@@ -485,13 +487,13 @@ describe('Basic RPC tests', () => {
})
it('should fail for a reverting call transaction', async () => {
await expect(provider.send('eth_estimateGas', [revertingTx])).to.be
await expect(env.l2Provider.send('eth_estimateGas', [revertingTx])).to.be
.reverted
})
it('should fail for a reverting deploy transaction', async () => {
await expect(provider.send('eth_estimateGas', [revertingDeployTx])).to.be
.reverted
await expect(env.l2Provider.send('eth_estimateGas', [revertingDeployTx]))
.to.be.reverted
})
})
......@@ -510,10 +512,10 @@ describe('Basic RPC tests', () => {
const tx = (await storage.deploy()).deployTransaction
const receipt = await tx.wait()
const txTrace = await provider.send('debug_traceTransaction', [
const txTrace = await env.l2Provider.send('debug_traceTransaction', [
receipt.transactionHash,
])
const blockTrace = await provider.send('debug_traceBlockByHash', [
const blockTrace = await env.l2Provider.send('debug_traceBlockByHash', [
receipt.blockHash,
])
expect(txTrace).to.deep.equal(blockTrace[0].result)
......@@ -522,7 +524,7 @@ describe('Basic RPC tests', () => {
describe('rollup_gasPrices', () => {
it('should return the L1 and L2 gas prices', async () => {
const result = await provider.send('rollup_gasPrices', [])
const result = await env.l2Provider.send('rollup_gasPrices', [])
const l1GasPrice = await env.gasPriceOracle.l1BaseFee()
const l2GasPrice = await env.gasPriceOracle.gasPrice()
......
......@@ -6,7 +6,6 @@ import { predeploys } from '@eth-optimism/contracts'
/* Imports: Internal */
import { expect } from './shared/setup'
import { OptimismEnv } from './shared/env'
import { l2Provider } from './shared/utils'
describe('Whitelist', async () => {
const initialAmount = 1000
......@@ -24,7 +23,7 @@ describe('Whitelist', async () => {
describe('when the whitelist is disabled', () => {
it('should be able to deploy a contract', async () => {
await expect(
l2Provider.send('eth_call', [
env.l2Provider.send('eth_call', [
Factory__ERC20.getDeployTransaction(
initialAmount,
tokenName,
......@@ -50,7 +49,7 @@ describe('Whitelist', async () => {
it('should fail if the user is not whitelisted', async () => {
await expect(
l2Provider.send('eth_call', [
env.l2Provider.send('eth_call', [
{
...Factory__ERC20.getDeployTransaction(
initialAmount,
......@@ -77,7 +76,7 @@ describe('Whitelist', async () => {
it('should succeed if the user is whitelisted', async () => {
await expect(
l2Provider.send('eth_call', [
env.l2Provider.send('eth_call', [
{
...Factory__ERC20.getDeployTransaction(
initialAmount,
......
......@@ -186,16 +186,8 @@ func (st *StateTransition) buyGas() error {
}
}
if st.state.GetBalance(st.msg.From()).Cmp(mgval) < 0 {
if rcfg.UsingOVM {
// Hack to prevent race conditions with the `gas-oracle`
// where policy level balance checks pass and then fail
// during consensus. The user gets some free gas
// in this case.
mgval = st.state.GetBalance(st.msg.From())
} else {
return errInsufficientBalanceForGas
}
}
if err := st.gp.SubGas(st.msg.Gas()); err != nil {
return err
}
......
......@@ -52,6 +52,7 @@ import (
var (
errNoSequencerURL = errors.New("sequencer transaction forwarding not configured")
errStillSyncing = errors.New("sequencer still syncing, cannot accept transactions")
)
const (
......@@ -1611,6 +1612,12 @@ func (args *SendTxArgs) toTransaction() *types.Transaction {
// SubmitTransaction is a helper function that submits tx to txPool and logs a message.
func SubmitTransaction(ctx context.Context, b Backend, tx *types.Transaction) (common.Hash, error) {
// Do not accept transactions if running as the sequencer and
// the node is still syncing.
if !b.IsVerifier() && b.IsSyncing() {
return common.Hash{}, errStillSyncing
}
if err := b.SendTx(ctx, tx); err != nil {
return common.Hash{}, err
}
......
......@@ -245,17 +245,16 @@ func (s *SyncService) Start() error {
if s.verifier {
go s.VerifierLoop()
} else {
// The sequencer must sync the transactions to the tip and the
// pending queue transactions on start before setting sync status
// to false and opening up the RPC to accept transactions.
go func() {
if err := s.syncTransactionsToTip(); err != nil {
return fmt.Errorf("Sequencer cannot sync transactions to tip: %w", err)
log.Crit("Sequencer cannot sync transactions to tip: %w", err)
}
if err := s.syncQueueToTip(); err != nil {
return fmt.Errorf("Sequencer cannot sync queue to tip: %w", err)
log.Crit("Sequencer cannot sync queue to tip: %w", err)
}
s.setSyncStatus(false)
go s.SequencerLoop()
}()
}
return nil
}
......@@ -348,10 +347,10 @@ func (s *SyncService) initializeLatestL1(ctcDeployHeight *big.Int) error {
qi := tx.GetMeta().QueueIndex
// When the queue index is set
if qi != nil {
if qi == queueIndex {
log.Info("Found correct staring queue index", "queue-index", qi)
if *qi == *queueIndex {
log.Info("Found correct staring queue index", "queue-index", *qi)
} else {
log.Info("Found incorrect staring queue index, fixing", "old", queueIndex, "new", qi)
log.Info("Found incorrect staring queue index, fixing", "old", *queueIndex, "new", *qi)
queueIndex = qi
}
break
......
......@@ -12,6 +12,8 @@ COPY --from=builder /optimism/yarn.lock .
COPY --from=builder /optimism/node_modules ./node_modules
# copy deps (would have been nice if docker followed the symlinks required)
COPY --from=builder /optimism/packages/sdk/package.json ./packages/sdk/package.json
COPY --from=builder /optimism/packages/sdk/dist ./packages/sdk/dist
COPY --from=builder /optimism/packages/core-utils/package.json ./packages/core-utils/package.json
COPY --from=builder /optimism/packages/core-utils/dist ./packages/core-utils/dist
COPY --from=builder /optimism/packages/common-ts/package.json ./packages/common-ts/package.json
......
......@@ -9,7 +9,6 @@ DATA_TRANSPORT_LAYER__LOGS_PER_POLLING_INTERVAL=2000
DATA_TRANSPORT_LAYER__DANGEROUSLY_CATCH_ALL_ERRORS=true
DATA_TRANSPORT_LAYER__SERVER_HOSTNAME=0.0.0.0
DATA_TRANSPORT_LAYER__L1_START_HEIGHT=1
DATA_TRANSPORT_LAYER__BSS_HARDFORK_1_INDEX=0
DATA_TRANSPORT_LAYER__ADDRESS_MANAGER=
DATA_TRANSPORT_LAYER__L1_RPC_ENDPOINT=
......
......@@ -74,7 +74,10 @@ const deployFn: DeployFunction = async (hre) => {
// Check if if we're on the hardhat chain ID. This will only happen in CI. If this is the case, we
// can skip directly to transferring ownership over to the ChugSplashDictator contract.
if (await isHardhatNode(hre)) {
if (
(await isHardhatNode(hre)) ||
process.env.AUTOMATICALLY_TRANSFER_OWNERSHIP === 'true'
) {
const owner = await hre.ethers.getSigner(currentOwner)
await Lib_AddressManager.connect(owner).transferOwnership(
AddressDictator.address
......
......@@ -86,7 +86,10 @@ const deployFn: DeployFunction = async (hre) => {
// Check if if we're on the hardhat chain ID. This will only happen in CI. If this is the case, we
// can skip directly to transferring ownership over to the ChugSplashDictator contract.
if (await isHardhatNode(hre)) {
if (
(await isHardhatNode(hre)) ||
process.env.AUTOMATICALLY_TRANSFER_OWNERSHIP === 'true'
) {
const owner = await hre.ethers.getSigner(currentOwner)
await Proxy__OVM_L1StandardBridge.connect(owner).setOwner(
ChugSplashDictator.address
......
export const BSS_HF1_INDEX = {
10: 2824317,
}
export * from './chain-constants'
export * from './patch-contexts'
export const PATCH_CONTEXTS = {
10: {
2817218: 1643139411,
2817287: 1643139718,
2817898: 1643140952,
2818512: 1643141859,
2818984: 1643142762,
2819864: 1643144275,
2820902: 1643146079,
2821157: 1643146389,
2821170: 1643146389,
2821339: 1643146689,
2821772: 1643147604,
2821814: 1643147909,
2821952: 1643147909,
2822262: 1643148824,
2822342: 1643149130,
2822425: 1643149130,
2822602: 1643149430,
2822742: 1643149733,
2822987: 1643150660,
2822999: 1643150660,
2823039: 1643150964,
2823046: 1643150964,
2823055: 1643150964,
2823096: 1643151269,
2823205: 1643151572,
2823260: 1643151572,
2823306: 1643151572,
2823322: 1643151572,
2823413: 1643151872,
2823419: 1643151872,
2823460: 1643151872,
2823561: 1643152174,
2823592: 1643152174,
2824036: 1643152774,
2824050: 1643153075,
2824107: 1643153075,
2824247: 1643153376,
2832642: 1643173416,
2835330: 1643181396,
2838173: 1643188371,
2838174: 1643188371,
2838175: 1643188371,
2840388: 1643192601,
2844171: 1643202366,
2845370: 1643204181,
2845931: 1643205096,
2846484: 1643205696,
2894118: 1643281866,
2894119: 1643281866,
2959506: 1643399826,
2967959: 1643419611,
2971530: 1643432181,
2974571: 1643443881,
2981176: 1643465226,
2984205: 1643470986,
2995760: 1643498166,
2996847: 1643501211,
2997086: 1643501811,
2997087: 1643501811,
2997569: 1643503026,
2998970: 1643506101,
3000041: 1643510376,
3000042: 1643510376,
3000973: 1643514306,
3001008: 1643514606,
3001009: 1643514606,
3002529: 1643520081,
3008446: 1643541501,
3009141: 1643543016,
3012287: 1643551521,
3012348: 1643551821,
3022052: 1643574336,
3042815: 1643624616,
3043000: 1643625516,
3060328: 1643656446,
3060471: 1643656746,
3064982: 1643667996,
3070655: 1643683461,
},
}
......@@ -4,6 +4,7 @@ import { BigNumber } from 'ethers'
/* Imports: Internal */
import { SimpleDB } from './simple-db'
import { PATCH_CONTEXTS, BSS_HF1_INDEX } from '../config'
import {
EnqueueEntry,
StateRootBatchEntry,
......@@ -32,7 +33,7 @@ interface Indexed {
}
interface ExtraTransportDBOptions {
bssHardfork1Index?: number
l2ChainId?: number
}
export class TransportDB {
......@@ -300,13 +301,19 @@ export class TransportDB {
}
let timestamp = enqueue.timestamp
if (
typeof this.opts.bssHardfork1Index === 'number' &&
transaction.index >= this.opts.bssHardfork1Index
) {
// BSS HF1 activates at block 0 if not specified.
const bssHf1Index = BSS_HF1_INDEX[this.opts.l2ChainId] || 0
if (transaction.index >= bssHf1Index) {
timestamp = transaction.timestamp
}
// Override with patch contexts if necessary
const contexts = PATCH_CONTEXTS[this.opts.l2ChainId]
if (contexts && contexts[transaction.index + 1]) {
timestamp = contexts[transaction.index + 1]
}
return {
...transaction,
...{
......
......@@ -108,7 +108,7 @@ export class L1IngestionService extends BaseService<L1IngestionServiceOptions> {
protected async _init(): Promise<void> {
this.state.db = new TransportDB(this.options.db, {
bssHardfork1Index: this.options.bssHardfork1Index,
l2ChainId: this.options.l2ChainId,
})
this.l1IngestionMetrics = registerMetrics(this.metrics)
......
......@@ -86,7 +86,7 @@ export class L2IngestionService extends BaseService<L2IngestionServiceOptions> {
this.l2IngestionMetrics = registerMetrics(this.metrics)
this.state.db = new TransportDB(this.options.db, {
bssHardfork1Index: this.options.bssHardfork1Index,
l2ChainId: this.options.l2ChainId,
})
this.state.l2RpcProvider =
......
......@@ -9,6 +9,7 @@ import { L1IngestionService } from '../l1-ingestion/service'
import { L1TransportServer } from '../server/service'
import { validators } from '../../utils'
import { L2IngestionService } from '../l2-ingestion/service'
import { BSS_HF1_INDEX } from '../../config'
export interface L1DataTransportServiceOptions {
nodeEnv: string
......@@ -36,7 +37,6 @@ export interface L1DataTransportServiceOptions {
defaultBackend: string
l1GasPriceBackend: string
l1StartHeight?: number
bssHardfork1Index?: number
}
const optionSettings = {
......@@ -68,15 +68,14 @@ export class L1DataTransportService extends BaseService<L1DataTransportServiceOp
protected async _init(): Promise<void> {
this.logger.info('Initializing L1 Data Transport Service...')
if (this.options.bssHardfork1Index !== null && this.options.bssHardfork1Index !== undefined) {
this.logger.info(`BSS HF1 is active at block: ${this.options.bssHardfork1Index}`)
} else {
this.logger.info(`BSS HF1 is not active`)
}
this.state.db = level(this.options.dbPath)
await this.state.db.open()
// BSS HF1 activates at block 0 if not specified.
const bssHf1Index = BSS_HF1_INDEX[this.options.l2ChainId] || 0
this.logger.info(`L2 chain ID is: ${this.options.l2ChainId}`)
this.logger.info(`BSS HF1 will activate at: ${bssHf1Index}`)
this.state.metrics = new Metrics({
labels: {
environment: this.options.nodeEnv,
......
......@@ -51,7 +51,6 @@ type ethNetwork = 'mainnet' | 'kovan' | 'goerli'
useSentry: config.bool('use-sentry', false),
sentryDsn: config.str('sentry-dsn'),
sentryTraceRate: config.ufloat('sentry-trace-rate', 0.05),
bssHardfork1Index: config.uint('bss-hardfork-1-index', null),
})
const stop = async (signal) => {
......
......@@ -88,7 +88,7 @@ export class L1TransportServer extends BaseService<L1TransportServerOptions> {
}
this.state.db = new TransportDB(this.options.db, {
bssHardfork1Index: this.options.bssHardfork1Index,
l2ChainId: this.options.l2ChainId,
})
this.state.l1RpcProvider =
......
......@@ -31,7 +31,7 @@ export const getL1GasPrice = async (
l2Provider: ProviderLike
): Promise<BigNumber> => {
const gpo = connectGasPriceOracle(l2Provider)
return gpo.gasPrice()
return gpo.l1BaseFee()
}
/**
......@@ -48,7 +48,11 @@ export const estimateL1Gas = async (
const gpo = connectGasPriceOracle(l2Provider)
return gpo.getL1GasUsed(
serialize({
...tx,
data: tx.data,
to: tx.to,
gasPrice: tx.gasPrice,
type: tx.type,
gasLimit: tx.gasLimit,
nonce: toNumber(tx.nonce as NumberLike),
})
)
......@@ -68,7 +72,11 @@ export const estimateL1GasCost = async (
const gpo = connectGasPriceOracle(l2Provider)
return gpo.getL1Fee(
serialize({
...tx,
data: tx.data,
to: tx.to,
gasPrice: tx.gasPrice,
type: tx.type,
gasLimit: tx.gasLimit,
nonce: toNumber(tx.nonce as NumberLike),
})
)
......
......@@ -7860,9 +7860,9 @@ fmix@^0.1.0:
imul "^1.0.0"
follow-redirects@^1.12.1, follow-redirects@^1.14.0:
version "1.14.7"
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.14.7.tgz#2004c02eb9436eee9a21446a6477debf17e81685"
integrity sha512-+hbxoLbFMbRKDwohX8GkTataGqO6Jb7jGwpAlwgy2bIz25XtRm7KEzJM76R1WiNT5SwZkX4Y75SwBolkpmE7iQ==
version "1.14.8"
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.14.8.tgz#016996fb9a11a100566398b1c6839337d7bfa8fc"
integrity sha512-1x0S9UVJHsQprFcEC/qnNzBLcIxsjAV905f/UkQxbclCsoTWlacCNOpQa/anodLl2uaEKFhfWOvM2Qg77+15zA==
for-each@^0.3.3, for-each@~0.3.3:
version "0.3.3"
......
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