Commit 43cfef03 authored by mergify[bot]'s avatar mergify[bot] Committed by GitHub

Merge branch 'develop' into indexer.bridge.metrics

parents 38d3505b 6ab378e4
---
'@eth-optimism/endpoint-monitor': patch
'@eth-optimism/indexer-api': patch
'@eth-optimism/op-exporter': patch
'@eth-optimism/chain-mon': patch
'@eth-optimism/common-ts': patch
'@eth-optimism/contracts-bedrock': patch
'@eth-optimism/contracts-ts': patch
'@eth-optimism/core-utils': patch
'@eth-optimism/fee-estimation': patch
'@eth-optimism/sdk': patch
'@eth-optimism/web3.js-plugin': patch
---
Updated dev dependencies related to testing that is causing audit tooling to report failures
# @eth-optimism/endpoint-monitor # @eth-optimism/endpoint-monitor
## 1.0.3
### Patch Changes
- [#7450](https://github.com/ethereum-optimism/optimism/pull/7450) [`ac90e16a7`](https://github.com/ethereum-optimism/optimism/commit/ac90e16a7f85c4f73661ae6023135c3d00421c1e) Thanks [@roninjin10](https://github.com/roninjin10)! - Updated dev dependencies related to testing that is causing audit tooling to report failures
## 1.0.2 ## 1.0.2
### Patch Changes ### Patch Changes
......
{ {
"name": "@eth-optimism/endpoint-monitor", "name": "@eth-optimism/endpoint-monitor",
"version": "1.0.2", "version": "1.0.3",
"private": true, "private": true,
"dependencies": {} "dependencies": {}
} }
# @eth-optimism/indexer-api
## 0.0.4
### Patch Changes
- [#7450](https://github.com/ethereum-optimism/optimism/pull/7450) [`ac90e16a7`](https://github.com/ethereum-optimism/optimism/commit/ac90e16a7f85c4f73661ae6023135c3d00421c1e) Thanks [@roninjin10](https://github.com/roninjin10)! - Updated dev dependencies related to testing that is causing audit tooling to report failures
{ {
"name": "@eth-optimism/indexer-api", "name": "@eth-optimism/indexer-api",
"version": "0.0.3", "version": "0.0.4",
"description": "[Optimism] typescript types for the indexer service", "description": "[Optimism] typescript types for the indexer service",
"main": "indexer.cjs", "main": "indexer.cjs",
"module": "indexer.js", "module": "indexer.js",
......
...@@ -152,10 +152,10 @@ func (a *Agent) tryResolveClaims(ctx context.Context) error { ...@@ -152,10 +152,10 @@ func (a *Agent) tryResolveClaims(ctx context.Context) error {
resolvableClaims = append(resolvableClaims, int64(claim.ContractIndex)) resolvableClaims = append(resolvableClaims, int64(claim.ContractIndex))
} }
} }
a.log.Info("Resolving claims", "numClaims", len(resolvableClaims))
if len(resolvableClaims) == 0 { if len(resolvableClaims) == 0 {
return errNoResolvableClaims return errNoResolvableClaims
} }
a.log.Info("Resolving claims", "numClaims", len(resolvableClaims))
var wg sync.WaitGroup var wg sync.WaitGroup
wg.Add(len(resolvableClaims)) wg.Add(len(resolvableClaims))
......
...@@ -58,22 +58,27 @@ func TestMonitorGames(t *testing.T) { ...@@ -58,22 +58,27 @@ func TestMonitorGames(t *testing.T) {
go func() { go func() {
headerNotSent := true headerNotSent := true
waitErr := wait.For(context.Background(), 100*time.Millisecond, func() (bool, error) { for {
if len(sched.scheduled) >= 1 { if len(sched.scheduled) >= 1 {
return true, nil break
} }
if mockHeadSource.sub == nil { if mockHeadSource.sub == nil {
return false, nil continue
} }
if headerNotSent { if headerNotSent {
mockHeadSource.sub.headers <- &ethtypes.Header{ select {
case mockHeadSource.sub.headers <- &ethtypes.Header{
Number: big.NewInt(1), Number: big.NewInt(1),
}:
headerNotSent = false
case <-ctx.Done():
break
default:
} }
headerNotSent = false
} }
return false, nil // Just to avoid a tight loop
}) time.Sleep(100 * time.Millisecond)
require.NoError(t, waitErr) }
mockHeadSource.err = fmt.Errorf("eth subscribe test error") mockHeadSource.err = fmt.Errorf("eth subscribe test error")
cancel() cancel()
}() }()
...@@ -94,27 +99,29 @@ func TestMonitorGames(t *testing.T) { ...@@ -94,27 +99,29 @@ func TestMonitorGames(t *testing.T) {
defer cancel() defer cancel()
go func() { go func() {
headerNotSent := true
waitErr := wait.For(context.Background(), 100*time.Millisecond, func() (bool, error) { waitErr := wait.For(context.Background(), 100*time.Millisecond, func() (bool, error) {
return mockHeadSource.sub != nil, nil return mockHeadSource.sub != nil, nil
}) })
require.NoError(t, waitErr) require.NoError(t, waitErr)
mockHeadSource.sub.errChan <- fmt.Errorf("test error") mockHeadSource.sub.errChan <- fmt.Errorf("test error")
waitErr = wait.For(context.Background(), 100*time.Millisecond, func() (bool, error) { for {
if len(sched.scheduled) >= 1 { if len(sched.scheduled) >= 1 {
return true, nil break
} }
if mockHeadSource.sub == nil { if mockHeadSource.sub == nil {
return false, nil continue
} }
if headerNotSent { select {
mockHeadSource.sub.headers <- &ethtypes.Header{ case mockHeadSource.sub.headers <- &ethtypes.Header{
Number: big.NewInt(1), Number: big.NewInt(1),
} }:
headerNotSent = false case <-ctx.Done():
break
default:
} }
return false, nil // Just to avoid a tight loop
}) time.Sleep(100 * time.Millisecond)
}
require.NoError(t, waitErr) require.NoError(t, waitErr)
mockHeadSource.err = fmt.Errorf("eth subscribe test error") mockHeadSource.err = fmt.Errorf("eth subscribe test error")
cancel() cancel()
...@@ -122,7 +129,7 @@ func TestMonitorGames(t *testing.T) { ...@@ -122,7 +129,7 @@ func TestMonitorGames(t *testing.T) {
err := monitor.MonitorGames(ctx) err := monitor.MonitorGames(ctx)
require.NoError(t, err) require.NoError(t, err)
require.Len(t, sched.scheduled, 1) require.NotEmpty(t, sched.scheduled) // We might get more than one update scheduled.
require.Equal(t, []common.Address{addr1, addr2}, sched.scheduled[0]) require.Equal(t, []common.Address{addr1, addr2}, sched.scheduled[0])
}) })
} }
......
...@@ -504,7 +504,7 @@ func TestBigL2Txs(gt *testing.T) { ...@@ -504,7 +504,7 @@ func TestBigL2Txs(gt *testing.T) {
if miner.l1GasPool.Gas() < tx.Gas() { // fill the L1 block with batcher txs until we run out of gas if miner.l1GasPool.Gas() < tx.Gas() { // fill the L1 block with batcher txs until we run out of gas
break break
} }
log.Info("including batcher tx", "nonce", tx) log.Info("including batcher tx", "nonce", tx.Nonce())
miner.IncludeTx(t, tx) miner.IncludeTx(t, tx)
txs = txs[1:] txs = txs[1:]
} }
......
package actions package actions
import ( import (
"context"
"errors" "errors"
"time"
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils" "github.com/ethereum-optimism/optimism/op-e2e/e2eutils"
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils/wait"
"github.com/ethereum-optimism/optimism/op-program/client/l2/engineapi" "github.com/ethereum-optimism/optimism/op-program/client/l2/engineapi"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
...@@ -176,12 +179,22 @@ func (e *L2Engine) ActL2IncludeTx(from common.Address) Action { ...@@ -176,12 +179,22 @@ func (e *L2Engine) ActL2IncludeTx(from common.Address) Action {
return return
} }
i := e.engineApi.PendingIndices(from) var i uint64
txs, q := e.eth.TxPool().ContentFrom(from) var txs []*types.Transaction
require.Greaterf(t, uint64(len(txs)), i, var q []*types.Transaction
"no pending txs from %s, and have %d unprocessable queued txs from this account", from, len(q)) // Wait for the tx to be in the pending tx queue
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
defer cancel()
err := wait.For(ctx, time.Second, func() (bool, error) {
i = e.engineApi.PendingIndices(from)
txs, q = e.eth.TxPool().ContentFrom(from)
return uint64(len(txs)) > i, nil
})
require.NoError(t, err,
"no pending txs from %s, and have %d unprocessable queued txs from this account: %w", from, len(q), err)
tx := txs[i] tx := txs[i]
err := e.engineApi.IncludeTx(tx, from) err = e.engineApi.IncludeTx(tx, from)
if errors.Is(err, engineapi.ErrNotBuildingBlock) { if errors.Is(err, engineapi.ErrNotBuildingBlock) {
t.InvalidAction(err.Error()) t.InvalidAction(err.Error())
} else if errors.Is(err, engineapi.ErrUsesTooMuchGas) { } else if errors.Is(err, engineapi.ErrUsesTooMuchGas) {
......
...@@ -16,6 +16,7 @@ import ( ...@@ -16,6 +16,7 @@ import (
"github.com/ethereum-optimism/optimism/op-chain-ops/genesis" "github.com/ethereum-optimism/optimism/op-chain-ops/genesis"
"github.com/ethereum-optimism/optimism/op-e2e/external" "github.com/ethereum-optimism/optimism/op-e2e/external"
oplog "github.com/ethereum-optimism/optimism/op-service/log"
) )
var ( var (
...@@ -65,6 +66,23 @@ func init() { ...@@ -65,6 +66,23 @@ func init() {
testing.Init() // Register test flags before parsing testing.Init() // Register test flags before parsing
flag.Parse() flag.Parse()
// Setup global logger
lvl := log.Lvl(EthNodeVerbosity)
if lvl < log.LvlCrit {
log.Root().SetHandler(log.DiscardHandler())
} else if lvl > log.LvlTrace { // clip to trace level
lvl = log.LvlTrace
}
// We cannot attach a testlog logger,
// because the global logger is shared between different independent parallel tests.
// Tests that write to a testlogger of another finished test fail.
h := oplog.NewLogHandler(os.Stdout, oplog.CLIConfig{
Level: lvl,
Color: false, // some CI logs do not handle colors well
Format: oplog.FormatTerminal,
})
oplog.SetGlobalLogHandler(h)
if err := allExist(l1AllocsPath, l1DeploymentsPath, deployConfigPath); err != nil { if err := allExist(l1AllocsPath, l1DeploymentsPath, deployConfigPath); err != nil {
return return
} }
......
...@@ -197,7 +197,7 @@ func (h *Helper) WaitForGameDataDeletion(ctx context.Context, games ...GameAddr) ...@@ -197,7 +197,7 @@ func (h *Helper) WaitForGameDataDeletion(ctx context.Context, games ...GameAddr)
if err != nil { if err != nil {
return false, fmt.Errorf("failed to check dir %v is deleted: %w", dir, err) return false, fmt.Errorf("failed to check dir %v is deleted: %w", dir, err)
} }
h.t.Errorf("Game data directory %v not yet deleted", dir) h.t.Logf("Game data directory %v not yet deleted", dir)
return false, nil return false, nil
} }
return true, nil return true, nil
......
package wait
import (
"context"
"fmt"
"math/big"
"time"
"github.com/ethereum/go-ethereum/core/types"
)
// BlockCaller is a subset of the [ethclient.Client] interface
// encompassing methods that query for block information.
type BlockCaller interface {
BlockByNumber(ctx context.Context, number *big.Int) (*types.Block, error)
BlockNumber(ctx context.Context) (uint64, error)
}
func ForBlock(ctx context.Context, client BlockCaller, n uint64) error {
for {
if ctx.Done() != nil {
return ctx.Err()
}
height, err := client.BlockNumber(ctx)
if err != nil {
return err
}
if height < n {
time.Sleep(500 * time.Millisecond)
continue
}
break
}
return nil
}
func ForBlockWithTimestamp(ctx context.Context, client BlockCaller, target uint64) error {
_, err := AndGet(ctx, time.Second, func() (uint64, error) {
head, err := client.BlockByNumber(ctx, nil)
if err != nil {
return 0, err
}
return head.Time(), nil
}, func(actual uint64) bool {
return actual >= target
})
return err
}
func ForNextBlock(ctx context.Context, client BlockCaller) error {
current, err := client.BlockNumber(ctx)
// Long timeout so we don't have to care what the block time is. If the test passes this will complete early anyway.
ctx, cancel := context.WithTimeout(ctx, 60*time.Second)
defer cancel()
if err != nil {
return fmt.Errorf("get starting block number: %w", err)
}
return ForBlock(ctx, client, current+1)
}
...@@ -69,59 +69,25 @@ func printDebugTrace(ctx context.Context, client *ethclient.Client, txHash commo ...@@ -69,59 +69,25 @@ func printDebugTrace(ctx context.Context, client *ethclient.Client, txHash commo
fmt.Printf("TxTrace: %v\n", trace) fmt.Printf("TxTrace: %v\n", trace)
} }
func ForBlock(ctx context.Context, client *ethclient.Client, n uint64) error { func For(ctx context.Context, rate time.Duration, cb func() (bool, error)) error {
tick := time.NewTicker(rate)
defer tick.Stop()
for { for {
height, err := client.BlockNumber(ctx) // Perform the first check before any waiting.
done, err := cb()
if err != nil { if err != nil {
return err return err
} }
if height < n { if done {
time.Sleep(500 * time.Millisecond) return nil
continue
}
break
}
return nil
}
func ForBlockWithTimestamp(ctx context.Context, client *ethclient.Client, target uint64) error {
_, err := AndGet(ctx, time.Second, func() (uint64, error) {
head, err := client.BlockByNumber(ctx, nil)
if err != nil {
return 0, err
} }
return head.Time(), nil
}, func(actual uint64) bool {
return actual >= target
})
return err
}
func ForNextBlock(ctx context.Context, client *ethclient.Client) error {
current, err := client.BlockNumber(ctx)
if err != nil {
return fmt.Errorf("get starting block number: %w", err)
}
return ForBlock(ctx, client, current+1)
}
func For(ctx context.Context, rate time.Duration, cb func() (bool, error)) error {
tick := time.NewTicker(rate)
defer tick.Stop()
for {
select { select {
case <-ctx.Done(): case <-ctx.Done():
return ctx.Err() return ctx.Err()
case <-tick.C: case <-tick.C:
done, err := cb() // Allow loop to continue for next retry
if err != nil {
return err
}
if done {
return nil
}
} }
} }
} }
......
...@@ -3,12 +3,6 @@ package op_e2e ...@@ -3,12 +3,6 @@ package op_e2e
import ( import (
"os" "os"
"testing" "testing"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum-optimism/optimism/op-e2e/config"
oplog "github.com/ethereum-optimism/optimism/op-service/log"
"github.com/ethereum-optimism/optimism/op-service/testlog"
) )
var enableParallelTesting bool = os.Getenv("OP_E2E_DISABLE_PARALLEL") != "true" var enableParallelTesting bool = os.Getenv("OP_E2E_DISABLE_PARALLEL") != "true"
...@@ -18,12 +12,4 @@ func InitParallel(t *testing.T) { ...@@ -18,12 +12,4 @@ func InitParallel(t *testing.T) {
if enableParallelTesting { if enableParallelTesting {
t.Parallel() t.Parallel()
} }
lvl := log.Lvl(config.EthNodeVerbosity)
if lvl < log.LvlCrit {
log.Root().SetHandler(log.DiscardHandler())
} else if lvl > log.LvlTrace { // clip to trace level
lvl = log.LvlTrace
}
h := testlog.Handler(t, lvl, log.TerminalFormat(false)) // some CI logs do not handle colors well
oplog.SetGlobalLogHandler(h)
} }
...@@ -5,6 +5,7 @@ import ( ...@@ -5,6 +5,7 @@ import (
"testing" "testing"
"time" "time"
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils/wait"
"github.com/ethereum-optimism/optimism/op-node/client" "github.com/ethereum-optimism/optimism/op-node/client"
"github.com/ethereum-optimism/optimism/op-node/node" "github.com/ethereum-optimism/optimism/op-node/node"
"github.com/ethereum-optimism/optimism/op-node/sources" "github.com/ethereum-optimism/optimism/op-node/sources"
...@@ -34,10 +35,11 @@ func TestStopStartSequencer(t *testing.T) { ...@@ -34,10 +35,11 @@ func TestStopStartSequencer(t *testing.T) {
require.NoError(t, err) require.NoError(t, err)
require.True(t, active, "sequencer should be active") require.True(t, active, "sequencer should be active")
blockBefore := latestBlock(t, l2Seq) require.NoError(
time.Sleep(time.Duration(cfg.DeployConfig.L2BlockTime+1) * time.Second) t,
blockAfter := latestBlock(t, l2Seq) wait.ForNextBlock(ctx, l2Seq),
require.Greaterf(t, blockAfter, blockBefore, "Chain did not advance") "Chain did not advance after starting sequencer",
)
ctx, cancel = context.WithTimeout(context.Background(), 5*time.Second) ctx, cancel = context.WithTimeout(context.Background(), 5*time.Second)
defer cancel() defer cancel()
...@@ -50,9 +52,9 @@ func TestStopStartSequencer(t *testing.T) { ...@@ -50,9 +52,9 @@ func TestStopStartSequencer(t *testing.T) {
require.NoError(t, err) require.NoError(t, err)
require.False(t, active, "sequencer should be inactive") require.False(t, active, "sequencer should be inactive")
blockBefore = latestBlock(t, l2Seq) blockBefore := latestBlock(t, l2Seq)
time.Sleep(time.Duration(cfg.DeployConfig.L2BlockTime+1) * time.Second) time.Sleep(time.Duration(cfg.DeployConfig.L2BlockTime+1) * time.Second)
blockAfter = latestBlock(t, l2Seq) blockAfter := latestBlock(t, l2Seq)
require.Equal(t, blockAfter, blockBefore, "Chain advanced after stopping sequencer") require.Equal(t, blockAfter, blockBefore, "Chain advanced after stopping sequencer")
ctx, cancel = context.WithTimeout(context.Background(), 5*time.Second) ctx, cancel = context.WithTimeout(context.Background(), 5*time.Second)
...@@ -66,10 +68,11 @@ func TestStopStartSequencer(t *testing.T) { ...@@ -66,10 +68,11 @@ func TestStopStartSequencer(t *testing.T) {
require.NoError(t, err) require.NoError(t, err)
require.True(t, active, "sequencer should be active again") require.True(t, active, "sequencer should be active again")
blockBefore = latestBlock(t, l2Seq) require.NoError(
time.Sleep(time.Duration(cfg.DeployConfig.L2BlockTime+1) * time.Second) t,
blockAfter = latestBlock(t, l2Seq) wait.ForNextBlock(ctx, l2Seq),
require.Greater(t, blockAfter, blockBefore, "Chain did not advance after starting sequencer") "Chain did not advance after starting sequencer",
)
} }
func TestPersistSequencerStateWhenChanged(t *testing.T) { func TestPersistSequencerStateWhenChanged(t *testing.T) {
......
# @eth-optimism/op-exporter # @eth-optimism/op-exporter
## 0.5.5
### Patch Changes
- [#7450](https://github.com/ethereum-optimism/optimism/pull/7450) [`ac90e16a7`](https://github.com/ethereum-optimism/optimism/commit/ac90e16a7f85c4f73661ae6023135c3d00421c1e) Thanks [@roninjin10](https://github.com/roninjin10)! - Updated dev dependencies related to testing that is causing audit tooling to report failures
## 0.5.4 ## 0.5.4
### Patch Changes ### Patch Changes
......
{ {
"name": "@eth-optimism/op-exporter", "name": "@eth-optimism/op-exporter",
"version": "0.5.4", "version": "0.5.5",
"private": true, "private": true,
"devDependencies": {} "devDependencies": {}
} }
# @eth-optimism/drippie-mon # @eth-optimism/drippie-mon
## 0.5.1
### Patch Changes
- [#7450](https://github.com/ethereum-optimism/optimism/pull/7450) [`ac90e16a7`](https://github.com/ethereum-optimism/optimism/commit/ac90e16a7f85c4f73661ae6023135c3d00421c1e) Thanks [@roninjin10](https://github.com/roninjin10)! - Updated dev dependencies related to testing that is causing audit tooling to report failures
- Updated dependencies [[`ac90e16a7`](https://github.com/ethereum-optimism/optimism/commit/ac90e16a7f85c4f73661ae6023135c3d00421c1e)]:
- @eth-optimism/common-ts@0.8.7
- @eth-optimism/contracts-bedrock@0.16.2
- @eth-optimism/core-utils@0.13.1
- @eth-optimism/sdk@3.1.4
## 0.5.0 ## 0.5.0
### Minor Changes ### Minor Changes
......
{ {
"private": true, "private": true,
"name": "@eth-optimism/chain-mon", "name": "@eth-optimism/chain-mon",
"version": "0.5.0", "version": "0.5.1",
"description": "[Optimism] Chain monitoring services", "description": "[Optimism] Chain monitoring services",
"main": "dist/index", "main": "dist/index",
"types": "dist/index", "types": "dist/index",
......
# @eth-optimism/common-ts # @eth-optimism/common-ts
## 0.8.7
### Patch Changes
- [#7450](https://github.com/ethereum-optimism/optimism/pull/7450) [`ac90e16a7`](https://github.com/ethereum-optimism/optimism/commit/ac90e16a7f85c4f73661ae6023135c3d00421c1e) Thanks [@roninjin10](https://github.com/roninjin10)! - Updated dev dependencies related to testing that is causing audit tooling to report failures
- Updated dependencies [[`ac90e16a7`](https://github.com/ethereum-optimism/optimism/commit/ac90e16a7f85c4f73661ae6023135c3d00421c1e)]:
- @eth-optimism/core-utils@0.13.1
## 0.8.6 ## 0.8.6
### Patch Changes ### Patch Changes
......
{ {
"name": "@eth-optimism/common-ts", "name": "@eth-optimism/common-ts",
"version": "0.8.6", "version": "0.8.7",
"description": "[Optimism] Advanced typescript tooling used by various services", "description": "[Optimism] Advanced typescript tooling used by various services",
"main": "dist/index", "main": "dist/index",
"types": "dist/index", "types": "dist/index",
......
# @eth-optimism/contracts-bedrock # @eth-optimism/contracts-bedrock
## 0.16.2
### Patch Changes
- [#7450](https://github.com/ethereum-optimism/optimism/pull/7450) [`ac90e16a7`](https://github.com/ethereum-optimism/optimism/commit/ac90e16a7f85c4f73661ae6023135c3d00421c1e) Thanks [@roninjin10](https://github.com/roninjin10)! - Updated dev dependencies related to testing that is causing audit tooling to report failures
## 0.16.1 ## 0.16.1
### Patch Changes ### Patch Changes
......
{ {
"name": "@eth-optimism/contracts-bedrock", "name": "@eth-optimism/contracts-bedrock",
"version": "0.16.1", "version": "0.16.2",
"description": "Contracts for Optimism Specs", "description": "Contracts for Optimism Specs",
"license": "MIT", "license": "MIT",
"files": [ "files": [
......
# @eth-optimism/contracts-ts
## 0.16.2
### Patch Changes
- [#7450](https://github.com/ethereum-optimism/optimism/pull/7450) [`ac90e16a7`](https://github.com/ethereum-optimism/optimism/commit/ac90e16a7f85c4f73661ae6023135c3d00421c1e) Thanks [@roninjin10](https://github.com/roninjin10)! - Updated dev dependencies related to testing that is causing audit tooling to report failures
{ {
"name": "@eth-optimism/contracts-ts", "name": "@eth-optimism/contracts-ts",
"version": "0.15.0", "version": "0.16.2",
"description": "TypeScript interface for Contracts Bedrock", "description": "TypeScript interface for Contracts Bedrock",
"license": "MIT", "license": "MIT",
"repository": { "repository": {
......
# @eth-optimism/core-utils # @eth-optimism/core-utils
## 0.13.1
### Patch Changes
- [#7450](https://github.com/ethereum-optimism/optimism/pull/7450) [`ac90e16a7`](https://github.com/ethereum-optimism/optimism/commit/ac90e16a7f85c4f73661ae6023135c3d00421c1e) Thanks [@roninjin10](https://github.com/roninjin10)! - Updated dev dependencies related to testing that is causing audit tooling to report failures
## 0.13.0 ## 0.13.0
### Minor Changes ### Minor Changes
......
{ {
"name": "@eth-optimism/core-utils", "name": "@eth-optimism/core-utils",
"version": "0.13.0", "version": "0.13.1",
"description": "[Optimism] Core typescript utilities", "description": "[Optimism] Core typescript utilities",
"main": "dist/index", "main": "dist/index",
"types": "dist/index", "types": "dist/index",
......
# @eth-optimism/fee-estimation # @eth-optimism/fee-estimation
## 0.15.3
### Patch Changes
- [#7450](https://github.com/ethereum-optimism/optimism/pull/7450) [`ac90e16a7`](https://github.com/ethereum-optimism/optimism/commit/ac90e16a7f85c4f73661ae6023135c3d00421c1e) Thanks [@roninjin10](https://github.com/roninjin10)! - Updated dev dependencies related to testing that is causing audit tooling to report failures
## 0.15.2 ## 0.15.2
### Patch Changes ### Patch Changes
......
{ {
"name": "@eth-optimism/fee-estimation", "name": "@eth-optimism/fee-estimation",
"version": "0.15.2", "version": "0.15.3",
"description": "Lightweight library for doing OP-Chain gas estimation", "description": "Lightweight library for doing OP-Chain gas estimation",
"license": "MIT", "license": "MIT",
"repository": { "repository": {
......
# @eth-optimism/sdk # @eth-optimism/sdk
## 3.1.4
### Patch Changes
- [#7450](https://github.com/ethereum-optimism/optimism/pull/7450) [`ac90e16a7`](https://github.com/ethereum-optimism/optimism/commit/ac90e16a7f85c4f73661ae6023135c3d00421c1e) Thanks [@roninjin10](https://github.com/roninjin10)! - Updated dev dependencies related to testing that is causing audit tooling to report failures
- Updated dependencies [[`ac90e16a7`](https://github.com/ethereum-optimism/optimism/commit/ac90e16a7f85c4f73661ae6023135c3d00421c1e)]:
- @eth-optimism/contracts-bedrock@0.16.2
- @eth-optimism/core-utils@0.13.1
## 3.1.3 ## 3.1.3
### Patch Changes ### Patch Changes
......
{ {
"name": "@eth-optimism/sdk", "name": "@eth-optimism/sdk",
"version": "3.1.3", "version": "3.1.4",
"description": "[Optimism] Tools for working with Optimism", "description": "[Optimism] Tools for working with Optimism",
"main": "dist/index", "main": "dist/index",
"types": "dist/index", "types": "dist/index",
......
# @eth-optimism/web3.js-plugin # @eth-optimism/web3.js-plugin
## 0.1.3
### Patch Changes
- [#7450](https://github.com/ethereum-optimism/optimism/pull/7450) [`ac90e16a7`](https://github.com/ethereum-optimism/optimism/commit/ac90e16a7f85c4f73661ae6023135c3d00421c1e) Thanks [@roninjin10](https://github.com/roninjin10)! - Updated dev dependencies related to testing that is causing audit tooling to report failures
## 0.1.2 ## 0.1.2
### Patch Changes ### Patch Changes
......
{ {
"name": "@eth-optimism/web3.js-plugin", "name": "@eth-optimism/web3.js-plugin",
"version": "0.1.2", "version": "0.1.3",
"description": "A Web3.js plugin for doing OP-Chain gas estimation", "description": "A Web3.js plugin for doing OP-Chain gas estimation",
"license": "MIT", "license": "MIT",
"repository": { "repository": {
......
This diff is collapsed.
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
"editable": true, "editable": true,
"fiscalYearStartMonth": 0, "fiscalYearStartMonth": 0,
"graphTooltip": 0, "graphTooltip": 0,
"id": 1,
"links": [], "links": [],
"liveNow": false, "liveNow": false,
"panels": [ "panels": [
...@@ -31,88 +32,57 @@ ...@@ -31,88 +32,57 @@
"color": { "color": {
"mode": "thresholds" "mode": "thresholds"
}, },
"custom": {
"axisCenteredZero": true,
"axisColorMode": "series",
"axisGridShow": false,
"axisPlacement": "auto",
"barAlignment": 0,
"drawStyle": "line",
"fillOpacity": 0,
"gradientMode": "none",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"insertNulls": false,
"lineInterpolation": "stepAfter",
"lineWidth": 1,
"pointSize": 5,
"scaleDistribution": {
"type": "linear"
},
"showPoints": "never",
"spanNulls": false,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "off"
}
},
"decimals": 0,
"displayName": "Number of Transactions (positive number = success, negative = failures)",
"mappings": [], "mappings": [],
"thresholds": { "thresholds": {
"mode": "absolute", "mode": "absolute",
"steps": [ "steps": [
{ {
"color": "red", "color": "text",
"value": null "value": null
}, },
{ {
"color": "yellow", "color": "red",
"value": 1 "value": -1
}, },
{
"color": "green",
"value": 4
}
]
}
},
"overrides": []
},
"gridPos": {
"h": 5,
"w": 6,
"x": 0,
"y": 0
},
"id": 1,
"options": {
"orientation": "auto",
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"showThresholdLabels": false,
"showThresholdMarkers": true
},
"pluginVersion": "10.1.2",
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "PBFA97CFB590B2093"
},
"disableTextWrap": false,
"editorMode": "builder",
"expr": "metamask_tx_success",
"fullMetaSearch": false,
"includeNullMetadata": true,
"instant": false,
"legendFormat": "__auto",
"range": true,
"refId": "A",
"useBackend": false
}
],
"title": "Successful Transaction Since Last Failure",
"type": "gauge"
},
{
"datasource": {
"type": "prometheus",
"uid": "PBFA97CFB590B2093"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{ {
"color": "text", "color": "text",
"value": null "value": 0
}, },
{ {
"color": "red", "color": "green",
"value": 1 "value": 1
} }
] ]
...@@ -121,25 +91,29 @@ ...@@ -121,25 +91,29 @@
"overrides": [] "overrides": []
}, },
"gridPos": { "gridPos": {
"h": 5, "h": 8,
"w": 6, "w": 24,
"x": 6, "x": 0,
"y": 0 "y": 0
}, },
"id": 2, "id": 1,
"options": { "options": {
"orientation": "auto", "legend": {
"reduceOptions": {
"calcs": [ "calcs": [
"lastNotNull" "last"
], ],
"fields": "", "displayMode": "list",
"values": false "placement": "bottom",
"showLegend": true
}, },
"showThresholdLabels": false, "timezone": [
"showThresholdMarkers": true "browser"
],
"tooltip": {
"mode": "single",
"sort": "none"
}
}, },
"pluginVersion": "10.1.2",
"targets": [ "targets": [
{ {
"datasource": { "datasource": {
...@@ -148,7 +122,7 @@ ...@@ -148,7 +122,7 @@
}, },
"disableTextWrap": false, "disableTextWrap": false,
"editorMode": "builder", "editorMode": "builder",
"expr": "metamask_tx_failure", "expr": "metamask_self_send",
"fullMetaSearch": false, "fullMetaSearch": false,
"includeNullMetadata": true, "includeNullMetadata": true,
"instant": false, "instant": false,
...@@ -158,8 +132,8 @@ ...@@ -158,8 +132,8 @@
"useBackend": false "useBackend": false
} }
], ],
"title": "Failed Transactions Since Last Success", "title": "Self Transferring on OP Goerli (positive number = success, negative = failures)",
"type": "gauge" "type": "timeseries"
} }
], ],
"refresh": "5s", "refresh": "5s",
...@@ -170,7 +144,7 @@ ...@@ -170,7 +144,7 @@
"list": [] "list": []
}, },
"time": { "time": {
"from": "now-6h", "from": "now-30m",
"to": "now" "to": "now"
}, },
"timepicker": {}, "timepicker": {},
...@@ -179,4 +153,4 @@ ...@@ -179,4 +153,4 @@
"uid": "f66f7076-c724-4f81-8ff9-58d6d99f2716", "uid": "f66f7076-c724-4f81-8ff9-58d6d99f2716",
"version": 1, "version": 1,
"weekStart": "" "weekStart": ""
} }
\ No newline at end of file
...@@ -15,8 +15,6 @@ export default defineConfig({ ...@@ -15,8 +15,6 @@ export default defineConfig({
fullyParallel: true, fullyParallel: true,
/* Fail the build on CI if you accidentally left test.only in the source code. */ /* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: !!process.env.CI, forbidOnly: !!process.env.CI,
/* Retry on CI only */
retries: process.env.CI ? 2 : 0,
/* Opt out of parallel tests on CI. */ /* Opt out of parallel tests on CI. */
workers: process.env.CI ? 1 : undefined, workers: process.env.CI ? 1 : undefined,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */ /* Reporter to use. See https://playwright.dev/docs/test-reporters */
......
...@@ -6,8 +6,7 @@ import { mnemonicToAccount, privateKeyToAccount } from 'viem/accounts' ...@@ -6,8 +6,7 @@ import { mnemonicToAccount, privateKeyToAccount } from 'viem/accounts'
import { testWithSynpress } from './testWithSynpressUtil' import { testWithSynpress } from './testWithSynpressUtil'
import { import {
incrementMetamaskTxCounter, incrementSelfSendTxGauge,
setMetamaskTxCounter,
} from './prometheusUtils' } from './prometheusUtils'
const env = z.object({ const env = z.object({
...@@ -24,18 +23,31 @@ const expectedSender = ...@@ -24,18 +23,31 @@ const expectedSender =
: mnemonicToAccount( : mnemonicToAccount(
env.METAMASK_SECRET_WORDS_OR_PRIVATEKEY as string env.METAMASK_SECRET_WORDS_OR_PRIVATEKEY as string
).address.toLowerCase() ).address.toLowerCase()
const expectedRecipient = '0x8fcfbe8953433fd1f2e8375ee99057833e4e1e9e' const expectedRecipient = expectedSender
let sharedPage: Page let sharedPage: Page
let wasSuccessful: boolean
let handledFailure: boolean
test.describe.configure({ mode: 'serial' }) test.describe.configure({ mode: 'serial' })
test.beforeAll(() => {
wasSuccessful = false
handledFailure = false
})
test.afterAll(async () => { test.afterAll(async () => {
// This is handling failure scenarios such as Playwright timeouts
// where are not able to catch and respond to an error.
if (!wasSuccessful && !handledFailure) {
await incrementSelfSendTxGauge(false)
}
await sharedPage.close() await sharedPage.close()
}) })
testWithSynpress('Setup wallet and dApp', async ({ page }) => { testWithSynpress('Setup wallet and dApp', async ({ page }) => {
console.log('Seting up wallet and dApp...') console.log('Setting up wallet and dApp...')
sharedPage = page sharedPage = page
await sharedPage.goto('http://localhost:9011') await sharedPage.goto('http://localhost:9011')
console.log('Setup wallet and dApp') console.log('Setup wallet and dApp')
...@@ -66,8 +78,8 @@ testWithSynpress('Add OP Goerli network', async () => { ...@@ -66,8 +78,8 @@ testWithSynpress('Add OP Goerli network', async () => {
try { try {
await expect(sharedPage.locator('#chainId')).toHaveText(expectedChainId) await expect(sharedPage.locator('#chainId')).toHaveText(expectedChainId)
} catch (error) { } catch (error) {
await setMetamaskTxCounter(true, 0) await incrementSelfSendTxGauge(false)
await incrementMetamaskTxCounter(false) handledFailure = true
throw error throw error
} }
console.log('Added OP Goerli network') console.log('Added OP Goerli network')
...@@ -81,15 +93,15 @@ test(`Connect wallet with ${expectedSender}`, async () => { ...@@ -81,15 +93,15 @@ test(`Connect wallet with ${expectedSender}`, async () => {
try { try {
await expect(sharedPage.locator('#accounts')).toHaveText(expectedSender) await expect(sharedPage.locator('#accounts')).toHaveText(expectedSender)
} catch (error) { } catch (error) {
await setMetamaskTxCounter(true, 0) await incrementSelfSendTxGauge(false)
await incrementMetamaskTxCounter(false) handledFailure = true
throw error throw error
} }
console.log(`Connected wallet with ${expectedSender}`) console.log(`Connected wallet with ${expectedSender}`)
}) })
test('Send an EIP-1559 transaciton and verfiy success', async () => { test('Send an EIP-1559 transaction and verify success', async () => {
console.log('Sending an EIP-1559 transaciton and verfiy success...') console.log('Sending an EIP-1559 transaction and verify success...')
const expectedTransferAmount = '0x1' const expectedTransferAmount = '0x1'
const expectedTxType = '0x2' const expectedTxType = '0x2'
...@@ -120,7 +132,7 @@ test('Send an EIP-1559 transaciton and verfiy success', async () => { ...@@ -120,7 +132,7 @@ test('Send an EIP-1559 transaciton and verfiy success', async () => {
// Waiting for RPC response to be populated on the page // Waiting for RPC response to be populated on the page
await sharedPage.waitForTimeout(2_000) await sharedPage.waitForTimeout(2_000)
const transaction = JSON.parse( const transactionReceipt = JSON.parse(
(await sharedPage.locator('body > main').innerText()).replace( (await sharedPage.locator('body > main').innerText()).replace(
'Response: ', 'Response: ',
'' ''
...@@ -128,13 +140,13 @@ test('Send an EIP-1559 transaciton and verfiy success', async () => { ...@@ -128,13 +140,13 @@ test('Send an EIP-1559 transaciton and verfiy success', async () => {
) )
try { try {
expect(transaction.status).toBe('0x1') expect(transactionReceipt.status).toBe('0x1')
await setMetamaskTxCounter(false, 0) wasSuccessful = true
await incrementMetamaskTxCounter(true) await incrementSelfSendTxGauge(true)
} catch (error) { } catch (error) {
await setMetamaskTxCounter(true, 0) await incrementSelfSendTxGauge(false)
await incrementMetamaskTxCounter(false) handledFailure = true
throw error throw error
} }
console.log('Sent an EIP-1559 transaciton and verfied success') console.log('Sent an EIP-1559 transaction and verified success')
}) })
import 'dotenv/config' import 'dotenv/config'
import { z } from 'zod' import { z } from 'zod'
import { Counter, Pushgateway } from 'prom-client' import { Gauge, Pushgateway } from 'prom-client'
const env = z const env = z
.object({ .object({
...@@ -9,21 +9,15 @@ const env = z ...@@ -9,21 +9,15 @@ const env = z
}) })
.parse(process.env) .parse(process.env)
const txSuccessMetricName = 'metamask_tx_success' const selfSendTransactionMetricName = 'metamask_self_send'
const txFailureMetricName = 'metamask_tx_failure'
const txSuccessCounter = new Counter({ const selfSendGauge = new Gauge({
name: txSuccessMetricName, name: selfSendTransactionMetricName,
help: 'A counter signifying the number of successful transactions sent with Metamask since last failure', help: 'A gauge signifying the number of transactions sent with Metamask',
})
const txFailureCounter = new Counter({
name: txFailureMetricName,
help: 'A counter signifying the number of failed transactions sent with Metamask since last successful transaction',
}) })
export const getMetamaskTxCounterValue = async (isSuccess: boolean) => { export const getSelfSendGaugeValue = async () => {
const metricName = isSuccess ? txSuccessMetricName : txFailureMetricName const prometheusMetricQuery = `${env.PROMETHEUS_SERVER_URL}/api/v1/query?query=${selfSendTransactionMetricName}`
const prometheusMetricQuery = `${env.PROMETHEUS_SERVER_URL}/api/v1/query?query=${metricName}`
const response = await fetch(prometheusMetricQuery) const response = await fetch(prometheusMetricQuery)
if (!response.ok) { if (!response.ok) {
...@@ -37,12 +31,12 @@ export const getMetamaskTxCounterValue = async (isSuccess: boolean) => { ...@@ -37,12 +31,12 @@ export const getMetamaskTxCounterValue = async (isSuccess: boolean) => {
// [ // [
// { // {
// metric: { // metric: {
// __name__: 'metamask_tx_success', // __name__: 'metamask_self_send',
// exported_job: 'metamask_tx_count', // exported_job: 'metamask_self_send_tx_count',
// instance: 'pushgateway:9091', // instance: 'pushgateway:9091',
// job: 'pushgateway' // job: 'pushgateway'
// }, // },
// value: [ 1695250414.474, '0' ] // value: [ 1695847795.646, '-1' ]
// } // }
// ] // ]
try { try {
...@@ -66,7 +60,9 @@ export const getMetamaskTxCounterValue = async (isSuccess: boolean) => { ...@@ -66,7 +60,9 @@ export const getMetamaskTxCounterValue = async (isSuccess: boolean) => {
if ( if (
error.message === "Cannot read properties of undefined (reading 'value')" error.message === "Cannot read properties of undefined (reading 'value')"
) { ) {
console.warn(`No data found for metric ${metricName} in Prometheus`) console.warn(
`No data found for metric ${selfSendTransactionMetricName} in Prometheus`
)
return undefined return undefined
} }
...@@ -74,28 +70,26 @@ export const getMetamaskTxCounterValue = async (isSuccess: boolean) => { ...@@ -74,28 +70,26 @@ export const getMetamaskTxCounterValue = async (isSuccess: boolean) => {
} }
} }
export const setMetamaskTxCounter = async ( export const setSelfSendTxGauge = async (valueToSetTo: number) => {
isSuccess: boolean, console.log(`Setting ${selfSendTransactionMetricName} to ${valueToSetTo}`)
valueToSetTo: number selfSendGauge.set(valueToSetTo)
) => {
const metricName = isSuccess ? txSuccessMetricName : txFailureMetricName
const txCounter = isSuccess ? txSuccessCounter : txFailureCounter
txCounter.reset()
console.log(`Setting ${metricName} to ${valueToSetTo}`)
txCounter.inc(valueToSetTo)
const pushGateway = new Pushgateway(env.PROMETHEUS_PUSHGATEWAY_URL) const pushGateway = new Pushgateway(env.PROMETHEUS_PUSHGATEWAY_URL)
await pushGateway.pushAdd({ jobName: 'metamask_tx_count' }) await pushGateway.pushAdd({ jobName: 'metamask_self_send_tx_count' })
} }
export const incrementMetamaskTxCounter = async (isSuccess: boolean) => { export const incrementSelfSendTxGauge = async (isSuccess: boolean) => {
const metricName = isSuccess ? txSuccessMetricName : txFailureMetricName const currentMetricValue = (await getSelfSendGaugeValue()) ?? 0
const currentMetricValue = (await getMetamaskTxCounterValue(true)) ?? 0
let newMetricValue: number
if (isSuccess) {
newMetricValue = currentMetricValue >= 0 ? currentMetricValue + 1 : 1
} else {
newMetricValue = currentMetricValue < 0 ? currentMetricValue - 1 : -1
}
console.log( console.log(
`Current value of ${metricName} is ${currentMetricValue}, incrementing to ${ `Current value of ${selfSendTransactionMetricName} is ${currentMetricValue}, incrementing to ${newMetricValue}`
currentMetricValue + 1
}`
) )
await setMetamaskTxCounter(isSuccess, currentMetricValue + 1) await setSelfSendTxGauge(newMetricValue)
} }
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