Commit e23bb19f authored by Ethen Pociask's avatar Ethen Pociask

Merge branch 'develop' of https://github.com/epociask/optimism into indexer.docs

parents bc133a18 706a972f
---
'@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
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
}
# @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",
......
......@@ -23,7 +23,7 @@ importers:
version: 0.4.8
'@nrwl/nx-cloud':
specifier: latest
version: 16.3.0
version: 16.4.0-beta.1
'@types/chai':
specifier: ^4.2.18
version: 4.2.21
......@@ -192,7 +192,7 @@ importers:
packages/common-ts:
dependencies:
'@eth-optimism/core-utils':
specifier: 0.12.2
specifier: 0.12.3
version: link:../core-utils
'@sentry/node':
specifier: ^6.3.1
......@@ -450,7 +450,7 @@ importers:
specifier: 0.16.0
version: link:../contracts-bedrock
'@eth-optimism/core-utils':
specifier: 0.12.2
specifier: 0.12.3
version: link:../core-utils
'@types/chai':
specifier: ^4.2.18
......@@ -3184,10 +3184,10 @@ packages:
tslib: 2.6.0
dev: true
/@nrwl/nx-cloud@16.3.0:
resolution: {integrity: sha512-nJrGsVufhY74KcP7kM7BqFOGAoO5OEF6+wfiM295DgmEG9c1yW+x5QiQaC42K9SWYn/eKQa1X7466ZA5lynXoQ==}
/@nrwl/nx-cloud@16.4.0-beta.1:
resolution: {integrity: sha512-XQFmpVtGJghvR+JJWgp2so0eeJSG7U1W0/WcyAskTnCSMt8M5FFotJmF4upFfRK1rexlECZ7xbcZzUXuIEqzsw==}
dependencies:
nx-cloud: 16.3.0
nx-cloud: 16.4.0-beta.1
transitivePeerDependencies:
- debug
dev: true
......@@ -4100,6 +4100,12 @@ packages:
'@swc/core-win32-x64-msvc': 1.3.76
dev: true
/@swc/helpers@0.5.1:
resolution: {integrity: sha512-sJ902EfIzn1Fa+qYmjdQqh8tPsoxyBz+8yBKC2HKUxyezKJFwPGOn7pv4WY6QuQW//ySQi5lJjA/ZT9sNWWNTg==}
dependencies:
tslib: 2.6.0
dev: true
/@tanstack/query-core@4.29.25:
resolution: {integrity: sha512-DI4y4VC6Uw4wlTpOocEXDky69xeOScME1ezLKsj+hOk7DguC9fkqXtp6Hn39BVb9y0b5IBrY67q6kIX623Zj4Q==}
......@@ -13628,11 +13634,12 @@ packages:
resolution: {integrity: sha512-ub5E4+FBPKwAZx0UwIQOjYWGHTEq5sPqHQNRN8Z9e4A7u3Tj1weLJsL59yH9vmvqEtBHaOmT6cYQKIZOxp35FQ==}
dev: true
/nx-cloud@16.3.0:
resolution: {integrity: sha512-hmNgpeLO4v4WDSWa8YhwX+q+9ohIyY8iqxlWyIKixWzQH2XfRgYFjOLH4IDLGOlKa3hg7MB6+4+75cK9CfSmKw==}
/nx-cloud@16.4.0-beta.1:
resolution: {integrity: sha512-I62IBQDjbA3h+P8JVFrannVllj8O9/3YYfyg8sPLVYxFKwnqqsgR6kG2zHxB9Q2k0hoSU7JZ02d9oPJsRzL5rg==}
hasBin: true
dependencies:
'@nrwl/nx-cloud': 16.3.0
'@nrwl/nx-cloud': 16.4.0-beta.1
'@swc/helpers': 0.5.1
axios: 1.1.3
chalk: 4.1.2
dotenv: 10.0.0
......
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