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

Merge branch 'develop' into feat/factory-storage

parents b9112209 ee860521
---
'@eth-optimism/core-utils': patch
---
Upgraded npm dependencies to latest
---
'@eth-optimism/chain-mon': patch
---
Upgraded npm dependencies to latest
......@@ -375,6 +375,10 @@ jobs:
- pnpm-packages-v2-{{ checksum "pnpm-lock.yaml" }}
- check-changed:
patterns: contracts-bedrock,op-node
# populate node modules from the cache
- run:
name: Install dependencies
command: pnpm install --frozen-lockfile --prefer-offline
- run:
name: build contracts
command: pnpm build
......
......@@ -6,7 +6,7 @@ updates:
interval: daily
open-pull-requests-limit: 10
labels:
- dependabot
- M-dependabot
- package-ecosystem: github-actions
directory: "/"
......@@ -14,7 +14,7 @@ updates:
interval: daily
open-pull-requests-limit: 10
labels:
- dependabot
- M-dependabot
- package-ecosystem: npm
directory: "/"
......@@ -25,7 +25,7 @@ updates:
open-pull-requests-limit: 10
versioning-strategy: auto
labels:
- dependabot
- M-dependabot
- package-ecosystem: gomod
directory: "/"
......@@ -33,4 +33,4 @@ updates:
interval: daily
open-pull-requests-limit: 10
labels:
- dependabot
- M-dependabot
......@@ -12,6 +12,9 @@ pull_request_rules:
- "label!=do-not-merge"
- "label!=multiple-reviewers"
- "label!=mergify-ignore"
- "label!=M-do-not-merge"
- "label!=M-multiple-reviewers"
- "label!=M-mergify-ignore"
- "base=develop"
actions:
queue:
......@@ -27,14 +30,14 @@ pull_request_rules:
This PR has been added to the merge queue, and will be merged soon.
label:
add:
- on-merge-train
- S-on-merge-train
- name: Remove merge train label
conditions:
- "queue-position = -1"
actions:
label:
remove:
- on-merge-train
- S-on-merge-train
- name: Ask to resolve conflict
conditions:
- conflict
......@@ -43,14 +46,14 @@ pull_request_rules:
message: Hey @{{author}}! This PR has merge conflicts. Please fix them before continuing review.
label:
add:
- conflict
- S-conflict
- name: Remove conflicts label when conflicts gone
conditions:
- -conflict
actions:
label:
remove:
- conflict
- S-conflict
- name: Notify author when added to merge queue
conditions:
- "check-pending=Queue: Embarked in merge train"
......@@ -77,7 +80,7 @@ pull_request_rules:
actions:
label:
add:
- indexer
- A-indexer
request_reviews:
users:
- roninjin10
......@@ -87,7 +90,7 @@ pull_request_rules:
actions:
label:
add:
- sdk
- A-pkg-sdk
request_reviews:
users:
- roninjin10
......@@ -97,7 +100,7 @@ pull_request_rules:
actions:
label:
add:
- common-ts
- A-pkg-common-ts
request_reviews:
users:
- roninjin10
......@@ -2,6 +2,15 @@
## Getting started
### Setup env
The `indexer.toml` stores a set of preset environmental variables that can be used to run the indexer with the exception of the network specific `l1-rpc` and `l2-rpc` variables. The `indexer.toml` file can be ran as a default config, otherwise a custom `.toml` config can provided via the `--config` flag when running the application. Additionally, L1 system contract addresses must provided for the specific OP Stack network actively being indexed. Currently the indexer has no way to infer L1 system config addresses provided a L2 chain ID or network enum.
### Testing
All tests can be ran by running `make test` from the `/indexer` directory. This will run all unit and e2e tests.
**NOTE:** Successfully running the E2E tests requires spinning up a local L1 geth node and pre-populating it with necessary bedrock genesis state. This can be done by calling `make devnet-allocs` from the root of the optimism monorepo before running the indexer tests. More information on this can be found in the [op-e2e README](../op-e2e/README.md).
### Run indexer vs goerli
- install docker
......
......@@ -24,11 +24,11 @@ type Config struct {
// fetch this via onchain config from RPCsConfig and remove from config in future
type L1Contracts struct {
OptimismPortal common.Address
L2OutputOracle common.Address
L1CrossDomainMessenger common.Address
L1StandardBridge common.Address
L1ERC721Bridge common.Address
OptimismPortal common.Address `toml:"optimism-portal"`
L2OutputOracle common.Address `toml:"l2-output-oracle"`
L1CrossDomainMessenger common.Address `toml:"l1-cross-domain-messenger"`
L1StandardBridge common.Address `toml:"l1-standard-bridge"`
L1ERC721Bridge common.Address `toml:"l1-erc721-bridge"`
// Some more contracts -- ProxyAdmin, SystemConfig, etcc
// Ignore the auxiliary contracts?
......@@ -52,9 +52,12 @@ func (c L1Contracts) ToSlice() []common.Address {
// ChainConfig configures of the chain being indexed
type ChainConfig struct {
// Configure known chains with the l2 chain id
Preset int
// Configure custom chains via providing the L1Contract addresses
L1Contracts L1Contracts
// NOTE - This currently performs no lookups to extract known L1 contracts by l2 chain id
Preset int
L1Contracts L1Contracts `toml:"l1-contracts"`
// L1StartingHeight is the block height to start indexing from
// NOTE - This is currently unimplemented
L1StartingHeight int
}
// RPCsConfig configures the RPC urls
......
......@@ -80,7 +80,12 @@ func TestLoadConfig_WithoutPreset(t *testing.T) {
testData := `
[chain]
l1contracts = { OptimismPortal = "0x4205Fc579115071764c7423A4f12eDde41f106Ed", L2OutputOracle = "0x42097868233d1aa22e815a266982f2cf17685a27", L1CrossDomainMessenger = "0x420ce71c97B33Cc4729CF772ae268934F7ab5fA1", L1StandardBridge = "0x4209fc46f92E8a1c0deC1b1747d010903E884bE1", L1ERC721Bridge ="0x420749f83b81B301cAb5f48EB8516B986DAef23D" }
[chain.l1-contracts]
optimism-portal = "0x4205Fc579115071764c7423A4f12eDde41f106Ed"
l2-output-oracle = "0x42097868233d1aa22e815a266982f2cf17685a27"
l1-cross-domain-messenger = "0x420ce71c97B33Cc4729CF772ae268934F7ab5fA1"
l1-standard-bridge = "0x4209fc46f92E8a1c0deC1b1747d010903E884bE1"
l1-erc721-bridge = "0x420749f83b81B301cAb5f48EB8516B986DAef23D"
[rpcs]
l1-rpc = "https://l1.example.com"
......
......@@ -3,6 +3,7 @@
[chain]
# OP Goerli
preset = 420
[rpcs]
l1-rpc = "${INDEXER_RPC_URL_L1}"
l2-rpc = "${INDEXER_RPC_URL_L2}"
......
package fault
import (
"context"
"errors"
"fmt"
"math/big"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
)
var (
ErrMissingBlockNumber = errors.New("game loader missing block number")
)
// MinimalDisputeGameFactoryCaller is a minimal interface around [bindings.DisputeGameFactoryCaller].
// This needs to be updated if the [bindings.DisputeGameFactoryCaller] interface changes.
type MinimalDisputeGameFactoryCaller interface {
GameCount(opts *bind.CallOpts) (*big.Int, error)
GameAtIndex(opts *bind.CallOpts, _index *big.Int) (struct {
Proxy common.Address
Timestamp *big.Int
}, error)
}
type FaultDisputeGame struct {
Proxy common.Address
Timestamp *big.Int
}
// GameLoader is a minimal interface for fetching on chain dispute games.
type GameLoader interface {
FetchAllGamesAtBlock(ctx context.Context) ([]FaultDisputeGame, error)
}
type gameLoader struct {
caller MinimalDisputeGameFactoryCaller
}
// NewGameLoader creates a new services that can be used to fetch on chain dispute games.
func NewGameLoader(caller MinimalDisputeGameFactoryCaller) *gameLoader {
return &gameLoader{
caller: caller,
}
}
// FetchAllGamesAtBlock fetches all dispute games from the factory at a given block number.
func (l *gameLoader) FetchAllGamesAtBlock(ctx context.Context, blockNumber *big.Int) ([]FaultDisputeGame, error) {
if blockNumber == nil {
return nil, ErrMissingBlockNumber
}
callOpts := &bind.CallOpts{
Context: ctx,
BlockNumber: blockNumber,
}
gameCount, err := l.caller.GameCount(callOpts)
if err != nil {
return nil, fmt.Errorf("failed to fetch game count: %w", err)
}
games := make([]FaultDisputeGame, gameCount.Uint64())
for i := uint64(0); i < gameCount.Uint64(); i++ {
game, err := l.caller.GameAtIndex(callOpts, big.NewInt(int64(i)))
if err != nil {
return nil, fmt.Errorf("failed to fetch game at index %d: %w", i, err)
}
games[i] = game
}
return games, nil
}
package fault
import (
"context"
"errors"
"math/big"
"testing"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/stretchr/testify/require"
)
var (
gameCountErr = errors.New("game count error")
gameIndexErr = errors.New("game index error")
)
// TestGameLoader_FetchAllGames tests that the game loader correctly fetches all games.
func TestGameLoader_FetchAllGames(t *testing.T) {
t.Parallel()
tests := []struct {
name string
caller *mockMinimalDisputeGameFactoryCaller
blockNumber *big.Int
expectedErr error
expectedLen int
}{
{
name: "success",
caller: newMockMinimalDisputeGameFactoryCaller(10, false, false),
blockNumber: big.NewInt(1),
expectedErr: nil,
expectedLen: 10,
},
{
name: "game count error",
caller: newMockMinimalDisputeGameFactoryCaller(10, true, false),
blockNumber: big.NewInt(1),
expectedErr: gameCountErr,
expectedLen: 0,
},
{
name: "game index error",
caller: newMockMinimalDisputeGameFactoryCaller(10, false, true),
blockNumber: big.NewInt(1),
expectedErr: gameIndexErr,
expectedLen: 0,
},
{
name: "no games",
caller: newMockMinimalDisputeGameFactoryCaller(0, false, false),
blockNumber: big.NewInt(1),
expectedErr: nil,
expectedLen: 0,
},
{
name: "missing block number",
caller: newMockMinimalDisputeGameFactoryCaller(0, false, false),
expectedErr: ErrMissingBlockNumber,
expectedLen: 0,
},
}
for _, test := range tests {
test := test
t.Run(test.name, func(t *testing.T) {
t.Parallel()
loader := NewGameLoader(test.caller)
games, err := loader.FetchAllGamesAtBlock(context.Background(), test.blockNumber)
require.ErrorIs(t, err, test.expectedErr)
require.Len(t, games, test.expectedLen)
expectedGames := test.caller.games
if test.expectedErr != nil {
expectedGames = make([]FaultDisputeGame, 0)
}
require.ElementsMatch(t, expectedGames, translateGames(games))
})
}
}
func generateMockGames(count uint64) []FaultDisputeGame {
games := make([]FaultDisputeGame, count)
for i := uint64(0); i < count; i++ {
games[i] = FaultDisputeGame{
Proxy: common.BigToAddress(big.NewInt(int64(i))),
Timestamp: big.NewInt(int64(i)),
}
}
return games
}
func translateGames(games []FaultDisputeGame) []FaultDisputeGame {
translated := make([]FaultDisputeGame, len(games))
for i, game := range games {
translated[i] = translateFaultDisputeGame(game)
}
return translated
}
func translateFaultDisputeGame(game FaultDisputeGame) FaultDisputeGame {
return FaultDisputeGame{
Proxy: game.Proxy,
Timestamp: game.Timestamp,
}
}
func generateMockGameErrors(count uint64, injectErrors bool) []bool {
errors := make([]bool, count)
if injectErrors {
for i := uint64(0); i < count; i++ {
errors[i] = true
}
}
return errors
}
type mockMinimalDisputeGameFactoryCaller struct {
gameCountErr bool
indexErrors []bool
gameCount uint64
games []FaultDisputeGame
}
func newMockMinimalDisputeGameFactoryCaller(count uint64, gameCountErr bool, indexErrors bool) *mockMinimalDisputeGameFactoryCaller {
return &mockMinimalDisputeGameFactoryCaller{
indexErrors: generateMockGameErrors(count, indexErrors),
gameCountErr: gameCountErr,
gameCount: count,
games: generateMockGames(count),
}
}
func (m *mockMinimalDisputeGameFactoryCaller) GameCount(opts *bind.CallOpts) (*big.Int, error) {
if m.gameCountErr {
return nil, gameCountErr
}
return big.NewInt(int64(m.gameCount)), nil
}
func (m *mockMinimalDisputeGameFactoryCaller) GameAtIndex(opts *bind.CallOpts, _index *big.Int) (struct {
Proxy common.Address
Timestamp *big.Int
}, error) {
index := _index.Uint64()
if m.indexErrors[index] {
return struct {
Proxy common.Address
Timestamp *big.Int
}{}, gameIndexErr
}
return struct {
Proxy common.Address
Timestamp *big.Int
}{
Proxy: m.games[index].Proxy,
Timestamp: m.games[index].Timestamp,
}, nil
}
......@@ -68,7 +68,7 @@
"markdownlint-cli2": "0.4.0",
"mkdirp": "^1.0.4",
"mocha": "^10.2.0",
"nx": "16.6.0",
"nx": "16.7.1",
"nyc": "^15.1.0",
"patch-package": "^6.4.7",
"prettier": "^2.8.0",
......
# @eth-optimism/drippie-mon
## 0.4.3
### Patch Changes
- [#6796](https://github.com/ethereum-optimism/optimism/pull/6796) [`a196c63ad`](https://github.com/ethereum-optimism/optimism/commit/a196c63ad67de04c4143e0ccd6fe4dc27fb2833b) Thanks [@roninjin10](https://github.com/roninjin10)! - Upgraded npm dependencies to latest
- Updated dependencies [[`dfa309e34`](https://github.com/ethereum-optimism/optimism/commit/dfa309e3430ebc8790b932554dde120aafc4161e)]:
- @eth-optimism/core-utils@0.12.3
- @eth-optimism/common-ts@0.8.4
- @eth-optimism/sdk@3.1.1
## 0.4.2
### Patch Changes
......
{
"private": true,
"name": "@eth-optimism/chain-mon",
"version": "0.4.2",
"version": "0.4.3",
"description": "[Optimism] Chain monitoring services",
"main": "dist/index",
"types": "dist/index",
......
# @eth-optimism/common-ts
## 0.8.4
### Patch Changes
- Updated dependencies [[`dfa309e34`](https://github.com/ethereum-optimism/optimism/commit/dfa309e3430ebc8790b932554dde120aafc4161e)]:
- @eth-optimism/core-utils@0.12.3
## 0.8.3
### Patch Changes
......
{
"name": "@eth-optimism/common-ts",
"version": "0.8.3",
"version": "0.8.4",
"description": "[Optimism] Advanced typescript tooling used by various services",
"main": "dist/index",
"types": "dist/index",
......@@ -34,7 +34,7 @@
"url": "https://github.com/ethereum-optimism/optimism.git"
},
"dependencies": {
"@eth-optimism/core-utils": "0.12.2",
"@eth-optimism/core-utils": "0.12.3",
"@sentry/node": "^6.3.1",
"bcfg": "^0.1.7",
"body-parser": "^1.20.0",
......
# @eth-optimism/core-utils
## 0.12.3
### Patch Changes
- [#6797](https://github.com/ethereum-optimism/optimism/pull/6797) [`dfa309e34`](https://github.com/ethereum-optimism/optimism/commit/dfa309e3430ebc8790b932554dde120aafc4161e) Thanks [@roninjin10](https://github.com/roninjin10)! - Upgraded npm dependencies to latest
## 0.12.2
### Patch Changes
......
{
"name": "@eth-optimism/core-utils",
"version": "0.12.2",
"version": "0.12.3",
"description": "[Optimism] Core typescript utilities",
"main": "dist/index",
"types": "dist/index",
......
# @eth-optimism/sdk
## 3.1.1
### Patch Changes
- Updated dependencies [[`dfa309e34`](https://github.com/ethereum-optimism/optimism/commit/dfa309e3430ebc8790b932554dde120aafc4161e)]:
- @eth-optimism/core-utils@0.12.3
## 3.1.0
### Minor Changes
......
{
"name": "@eth-optimism/sdk",
"version": "3.1.0",
"version": "3.1.1",
"description": "[Optimism] Tools for working with Optimism",
"main": "dist/index",
"types": "dist/index",
......@@ -58,7 +58,7 @@
"dependencies": {
"@eth-optimism/contracts": "0.6.0",
"@eth-optimism/contracts-bedrock": "0.16.0",
"@eth-optimism/core-utils": "0.12.2",
"@eth-optimism/core-utils": "0.12.3",
"@types/chai": "^4.2.18",
"@types/chai-as-promised": "^7.1.4",
"@types/mocha": "^10.0.1",
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment