Skip to content

Commit

Permalink
Merge branch 'develop' into cp-903/offchain-mtcannon/refactor-mipsevm…
Browse files Browse the repository at this point in the history
…-pkgs
  • Loading branch information
mbaxter committed Jul 16, 2024
2 parents c68abec + db10779 commit 77ead49
Show file tree
Hide file tree
Showing 134 changed files with 6,805 additions and 7,176 deletions.
1 change: 0 additions & 1 deletion .coderabbit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ reviews:
collapse_walkthrough: true
path_filters:
- "!**/*.json"
- "!op-bindings/bindings/**"
path_instructions:
- path: "**.sol"
instructions: "Focus on the following areas:
Expand Down
7 changes: 0 additions & 7 deletions .github/mergify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,6 @@ pull_request_rules:
label:
add:
- A-op-batcher
- name: Add A-op-bindings label
conditions:
- 'files~=^op-bindings/'
actions:
label:
add:
- A-op-bindings
- name: Add A-op-bootnode label
conditions:
- 'files~=^op-bootnode/'
Expand Down
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ packages/contracts-bedrock/deployments/anvil

coverage.out

# Ignore bedrock go bindings local output files
op-bindings/bin

__pycache__

Expand Down
1 change: 0 additions & 1 deletion .semgrepignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ tests/
# Semgrep-action log folder
.semgrep_logs/

op-bindings/bindings/

packages/*/node_modules
packages/*/test
7 changes: 4 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ lint-go:
golangci-lint run -E goimports,sqlclosecheck,bodyclose,asciicheck,misspell,errorlint --timeout 5m -e "errors.As" -e "errors.Is" ./...
.PHONY: lint-go

lint-go-fix:
golangci-lint run -E goimports,sqlclosecheck,bodyclose,asciicheck,misspell,errorlint --timeout 5m -e "errors.As" -e "errors.Is" ./... --fix
.PHONY: lint-go-fix

build-ts: submodules
if [ -f "$$NVM_DIR/nvm.sh" ]; then \
. $$NVM_DIR/nvm.sh && nvm use; \
Expand Down Expand Up @@ -101,9 +105,6 @@ submodules:
git submodule update --init --recursive
.PHONY: submodules

op-bindings:
make -C ./op-bindings
.PHONY: op-bindings

op-node:
make -C ./op-node op-node
Expand Down
1 change: 0 additions & 1 deletion codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ comment:

ignore:
- "op-e2e"
- "op-bindings/bindings/*.go"
- "**/*.t.sol"
- "packages/contracts-bedrock/test/**/*.sol"
- "packages/contracts-bedrock/scripts/**/*.sol"
Expand Down
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ require (
github.com/hashicorp/golang-lru/v2 v2.0.7
github.com/hashicorp/raft v1.7.0
github.com/hashicorp/raft-boltdb v0.0.0-20231211162105-6c830fa4535e
github.com/holiman/uint256 v1.2.4
github.com/holiman/uint256 v1.3.0
github.com/ipfs/go-datastore v0.6.0
github.com/ipfs/go-ds-leveldb v0.5.0
github.com/klauspost/compress v1.17.9
Expand All @@ -39,6 +39,7 @@ require (
github.com/pkg/errors v0.9.1
github.com/pkg/profile v1.7.0
github.com/prometheus/client_golang v1.19.1
github.com/protolambda/ctxlock v0.1.0
github.com/stretchr/testify v1.9.0
github.com/urfave/cli/v2 v2.27.1
golang.org/x/crypto v0.25.0
Expand Down
6 changes: 4 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -339,8 +339,8 @@ github.com/holiman/billy v0.0.0-20240216141850-2abb0c79d3c4 h1:X4egAf/gcS1zATw6w
github.com/holiman/billy v0.0.0-20240216141850-2abb0c79d3c4/go.mod h1:5GuXa7vkL8u9FkFuWdVvfR5ix8hRB7DbOAaYULamFpc=
github.com/holiman/bloomfilter/v2 v2.0.3 h1:73e0e/V0tCydx14a0SCYS/EWCxgwLZ18CZcZKVu0fao=
github.com/holiman/bloomfilter/v2 v2.0.3/go.mod h1:zpoh+gs7qcpqrHr3dB55AMiJwo0iURXE7ZOP9L9hSkA=
github.com/holiman/uint256 v1.2.4 h1:jUc4Nk8fm9jZabQuqr2JzednajVmBpC+oiTiXZJEApU=
github.com/holiman/uint256 v1.2.4/go.mod h1:EOMSn4q6Nyt9P6efbI3bueV4e1b3dGlUCXeiRV4ng7E=
github.com/holiman/uint256 v1.3.0 h1:4wdcm/tnd0xXdu7iS3ruNvxkWwrb4aeBQv19ayYn8F4=
github.com/holiman/uint256 v1.3.0/go.mod h1:EOMSn4q6Nyt9P6efbI3bueV4e1b3dGlUCXeiRV4ng7E=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/huin/goupnp v1.3.0 h1:UvLUlWDNpoUdYzb2TCn+MuTWtcjXKSza2n6CBdQ0xXc=
github.com/huin/goupnp v1.3.0/go.mod h1:gnGPsThkYa7bFi/KWmEysQRf48l2dvR5bxr2OFckNX8=
Expand Down Expand Up @@ -652,6 +652,8 @@ github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsT
github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A=
github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo=
github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo=
github.com/protolambda/ctxlock v0.1.0 h1:rCUY3+vRdcdZXqT07iXgyr744J2DU2LCBIXowYAjBCE=
github.com/protolambda/ctxlock v0.1.0/go.mod h1:vefhX6rIZH8rsg5ZpOJfEDYQOppZi19SfPiGOFrNnwM=
github.com/prysmaticlabs/gohashtree v0.0.1-alpha.0.20220714111606-acbb2962fb48 h1:cSo6/vk8YpvkLbk9v3FO97cakNmUoxwi2KMP8hd5WIw=
github.com/prysmaticlabs/gohashtree v0.0.1-alpha.0.20220714111606-acbb2962fb48/go.mod h1:4pWaT30XoEx1j8KNJf3TV+E3mQkaufn7mf+jRNb/Fuk=
github.com/quic-go/qpack v0.4.0 h1:Cr9BXA1sQS2SmDUWjSofMPNKmvF6IiIfDRmgU0w1ZCo=
Expand Down
60 changes: 30 additions & 30 deletions op-challenger/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,23 @@ import (
)

var (
validL1EthRpc = "http://localhost:8545"
validL1BeaconUrl = "http://localhost:9000"
validGameFactoryAddress = common.Address{0x23}
validCannonBin = "./bin/cannon"
validCannonOpProgramBin = "./bin/op-program"
validCannonNetwork = "mainnet"
validCannonAbsolutPreState = "pre.json"
validCannonAbsolutPreStateBaseURL, _ = url.Parse("http://localhost/foo/")
validDatadir = "/tmp/data"
validL2Rpc = "http://localhost:9545"
validRollupRpc = "http://localhost:8555"

validAsteriscBin = "./bin/asterisc"
validAsteriscOpProgramBin = "./bin/op-program"
validAsteriscNetwork = "mainnet"
validAsteriscAbsolutPreState = "pre.json"
validAsteriscAbsolutPreStateBaseURL, _ = url.Parse("http://localhost/bar/")
validL1EthRpc = "http://localhost:8545"
validL1BeaconUrl = "http://localhost:9000"
validGameFactoryAddress = common.Address{0x23}
validCannonBin = "./bin/cannon"
validCannonOpProgramBin = "./bin/op-program"
validCannonNetwork = "mainnet"
validCannonAbsolutePreState = "pre.json"
validCannonAbsolutePreStateBaseURL, _ = url.Parse("http://localhost/foo/")
validDatadir = "/tmp/data"
validL2Rpc = "http://localhost:9545"
validRollupRpc = "http://localhost:8555"

validAsteriscBin = "./bin/asterisc"
validAsteriscOpProgramBin = "./bin/op-program"
validAsteriscNetwork = "mainnet"
validAsteriscAbsolutePreState = "pre.json"
validAsteriscAbsolutePreStateBaseURL, _ = url.Parse("http://localhost/bar/")
)

var cannonTraceTypes = []types.TraceType{types.TraceTypeCannon, types.TraceTypePermissioned}
Expand All @@ -39,14 +39,14 @@ var asteriscTraceTypes = []types.TraceType{types.TraceTypeAsterisc}
func applyValidConfigForCannon(cfg *Config) {
cfg.Cannon.VmBin = validCannonBin
cfg.Cannon.Server = validCannonOpProgramBin
cfg.CannonAbsolutePreStateBaseURL = validCannonAbsolutPreStateBaseURL
cfg.CannonAbsolutePreStateBaseURL = validCannonAbsolutePreStateBaseURL
cfg.Cannon.Network = validCannonNetwork
}

func applyValidConfigForAsterisc(cfg *Config) {
cfg.Asterisc.VmBin = validAsteriscBin
cfg.Asterisc.Server = validAsteriscOpProgramBin
cfg.AsteriscAbsolutePreStateBaseURL = validAsteriscAbsolutPreStateBaseURL
cfg.AsteriscAbsolutePreStateBaseURL = validAsteriscAbsolutePreStateBaseURL
cfg.Asterisc.Network = validAsteriscNetwork
}

Expand Down Expand Up @@ -135,22 +135,22 @@ func TestCannonRequiredArgs(t *testing.T) {

t.Run(fmt.Sprintf("TestCannonAbsolutePreState-%v", traceType), func(t *testing.T) {
config := validConfig(traceType)
config.CannonAbsolutePreState = validCannonAbsolutPreState
config.CannonAbsolutePreState = validCannonAbsolutePreState
config.CannonAbsolutePreStateBaseURL = nil
require.NoError(t, config.Check())
})

t.Run(fmt.Sprintf("TestCannonAbsolutePreStateBaseURL-%v", traceType), func(t *testing.T) {
config := validConfig(traceType)
config.CannonAbsolutePreState = ""
config.CannonAbsolutePreStateBaseURL = validCannonAbsolutPreStateBaseURL
config.CannonAbsolutePreStateBaseURL = validCannonAbsolutePreStateBaseURL
require.NoError(t, config.Check())
})

t.Run(fmt.Sprintf("TestMustNotSupplyBothCannonAbsolutePreStateAndBaseURL-%v", traceType), func(t *testing.T) {
config := validConfig(traceType)
config.CannonAbsolutePreState = validCannonAbsolutPreState
config.CannonAbsolutePreStateBaseURL = validCannonAbsolutPreStateBaseURL
config.CannonAbsolutePreState = validCannonAbsolutePreState
config.CannonAbsolutePreStateBaseURL = validCannonAbsolutePreStateBaseURL
require.ErrorIs(t, config.Check(), ErrCannonAbsolutePreStateAndBaseURL)
})

Expand Down Expand Up @@ -241,22 +241,22 @@ func TestAsteriscRequiredArgs(t *testing.T) {

t.Run(fmt.Sprintf("TestAsteriscAbsolutePreState-%v", traceType), func(t *testing.T) {
config := validConfig(traceType)
config.AsteriscAbsolutePreState = validAsteriscAbsolutPreState
config.AsteriscAbsolutePreState = validAsteriscAbsolutePreState
config.AsteriscAbsolutePreStateBaseURL = nil
require.NoError(t, config.Check())
})

t.Run(fmt.Sprintf("TestAsteriscAbsolutePreStateBaseURL-%v", traceType), func(t *testing.T) {
config := validConfig(traceType)
config.AsteriscAbsolutePreState = ""
config.AsteriscAbsolutePreStateBaseURL = validAsteriscAbsolutPreStateBaseURL
config.AsteriscAbsolutePreStateBaseURL = validAsteriscAbsolutePreStateBaseURL
require.NoError(t, config.Check())
})

t.Run(fmt.Sprintf("TestMustNotSupplyBothAsteriscAbsolutePreStateAndBaseURL-%v", traceType), func(t *testing.T) {
config := validConfig(traceType)
config.AsteriscAbsolutePreState = validAsteriscAbsolutPreState
config.AsteriscAbsolutePreStateBaseURL = validAsteriscAbsolutPreStateBaseURL
config.AsteriscAbsolutePreState = validAsteriscAbsolutePreState
config.AsteriscAbsolutePreStateBaseURL = validAsteriscAbsolutePreStateBaseURL
require.ErrorIs(t, config.Check(), ErrAsteriscAbsolutePreStateAndBaseURL)
})

Expand Down Expand Up @@ -370,7 +370,7 @@ func TestRequireConfigForMultipleTraceTypesForCannon(t *testing.T) {
cfg.CannonAbsolutePreState = ""
cfg.CannonAbsolutePreStateBaseURL = nil
require.ErrorIs(t, cfg.Check(), ErrMissingCannonAbsolutePreState)
cfg.CannonAbsolutePreState = validCannonAbsolutPreState
cfg.CannonAbsolutePreState = validCannonAbsolutePreState

// Require output cannon specific args
cfg.RollupRpc = ""
Expand All @@ -388,7 +388,7 @@ func TestRequireConfigForMultipleTraceTypesForAsterisc(t *testing.T) {
cfg.AsteriscAbsolutePreState = ""
cfg.AsteriscAbsolutePreStateBaseURL = nil
require.ErrorIs(t, cfg.Check(), ErrMissingAsteriscAbsolutePreState)
cfg.AsteriscAbsolutePreState = validAsteriscAbsolutPreState
cfg.AsteriscAbsolutePreState = validAsteriscAbsolutePreState

// Require output asterisc specific args
cfg.RollupRpc = ""
Expand All @@ -413,7 +413,7 @@ func TestRequireConfigForMultipleTraceTypesForCannonAndAsterisc(t *testing.T) {
cfg.AsteriscAbsolutePreState = ""
cfg.AsteriscAbsolutePreStateBaseURL = nil
require.ErrorIs(t, cfg.Check(), ErrMissingAsteriscAbsolutePreState)
cfg.AsteriscAbsolutePreState = validAsteriscAbsolutPreState
cfg.AsteriscAbsolutePreState = validAsteriscAbsolutePreState

// Require cannon specific args
cfg.Asterisc.Server = ""
Expand Down
8 changes: 8 additions & 0 deletions op-challenger/game/keccak/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,13 @@ type OracleSource interface {
Oracles() []keccakTypes.LargePreimageOracle
}

type Metrics interface {
RecordLargePreimageCount(count int)
}

type LargePreimageScheduler struct {
log log.Logger
m Metrics
cl faultTypes.ClockReader
ch chan common.Hash
oracles OracleSource
Expand All @@ -33,11 +38,13 @@ type LargePreimageScheduler struct {

func NewLargePreimageScheduler(
logger log.Logger,
m Metrics,
cl faultTypes.ClockReader,
oracleSource OracleSource,
challenger Challenger) *LargePreimageScheduler {
return &LargePreimageScheduler{
log: logger,
m: m,
cl: cl,
ch: make(chan common.Hash, 1),
oracles: oracleSource,
Expand Down Expand Up @@ -94,6 +101,7 @@ func (s *LargePreimageScheduler) verifyOraclePreimages(ctx context.Context, orac
if err != nil {
return err
}
s.m.RecordLargePreimageCount(len(preimages))
period, err := oracle.ChallengePeriod(ctx)
if err != nil {
return fmt.Errorf("failed to load challenge period: %w", err)
Expand Down
3 changes: 2 additions & 1 deletion op-challenger/game/keccak/scheduler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"time"

keccakTypes "github.com/ethereum-optimism/optimism/op-challenger/game/keccak/types"
"github.com/ethereum-optimism/optimism/op-challenger/metrics"
"github.com/ethereum-optimism/optimism/op-service/clock"
"github.com/ethereum-optimism/optimism/op-service/sources/batching/rpcblock"
"github.com/ethereum-optimism/optimism/op-service/testlog"
Expand Down Expand Up @@ -50,7 +51,7 @@ func TestScheduleNextCheck(t *testing.T) {
}
cl := clock.NewDeterministicClock(time.Unix(int64(currentTimestamp), 0))
challenger := &stubChallenger{}
scheduler := NewLargePreimageScheduler(logger, cl, OracleSourceArray{oracle}, challenger)
scheduler := NewLargePreimageScheduler(logger, metrics.NoopMetrics, cl, OracleSourceArray{oracle}, challenger)
scheduler.Start(ctx)
defer scheduler.Close()
err := scheduler.Schedule(common.Hash{0xaa}, 3)
Expand Down
2 changes: 1 addition & 1 deletion op-challenger/game/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ func (s *Service) initLargePreimages() error {
fetcher := fetcher.NewPreimageFetcher(s.logger, s.l1Client)
verifier := keccak.NewPreimageVerifier(s.logger, fetcher)
challenger := keccak.NewPreimageChallenger(s.logger, s.metrics, verifier, s.txSender)
s.preimages = keccak.NewLargePreimageScheduler(s.logger, s.l1Clock, s.oracles, challenger)
s.preimages = keccak.NewLargePreimageScheduler(s.logger, s.metrics, s.l1Clock, s.oracles, challenger)
return nil
}

Expand Down
12 changes: 12 additions & 0 deletions op-challenger/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ type Metricer interface {
RecordGameUpdateScheduled()
RecordGameUpdateCompleted()

RecordLargePreimageCount(count int)

IncActiveExecutors()
DecActiveExecutors()
IncIdleExecutors()
Expand Down Expand Up @@ -81,6 +83,7 @@ type Metrics struct {

preimageChallenged prometheus.Counter
preimageChallengeFailed prometheus.Counter
preimageCount prometheus.Gauge

highestActedL1Block prometheus.Gauge

Expand Down Expand Up @@ -193,6 +196,11 @@ func NewMetrics() *Metrics {
Name: "preimage_challenge_failed",
Help: "Number of preimage challenges that failed",
}),
preimageCount: factory.NewGauge(prometheus.GaugeOpts{
Namespace: Namespace,
Name: "preimage_count",
Help: "Number of large preimage proposals being tracked by the challenger",
}),
trackedGames: *factory.NewGaugeVec(prometheus.GaugeOpts{
Namespace: Namespace,
Name: "tracked_games",
Expand Down Expand Up @@ -261,6 +269,10 @@ func (m *Metrics) RecordPreimageChallengeFailed() {
m.preimageChallengeFailed.Add(1)
}

func (m *Metrics) RecordLargePreimageCount(count int) {
m.preimageCount.Set(float64(count))
}

func (m *Metrics) RecordBondClaimFailed() {
m.bondClaimFailures.Add(1)
}
Expand Down
1 change: 1 addition & 0 deletions op-challenger/metrics/noop.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ func (*NoopMetricsImpl) RecordActedL1Block(_ uint64) {}

func (*NoopMetricsImpl) RecordPreimageChallenged() {}
func (*NoopMetricsImpl) RecordPreimageChallengeFailed() {}
func (*NoopMetricsImpl) RecordLargePreimageCount(_ int) {}

func (*NoopMetricsImpl) RecordBondClaimFailed() {}
func (*NoopMetricsImpl) RecordBondClaimed(uint64) {}
Expand Down
Loading

0 comments on commit 77ead49

Please sign in to comment.