Skip to content
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 54 additions & 1 deletion cmd/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,15 @@ func CommandServe(cfg *config.Config) *cli.Command {
Value: 4,
},

&cli.Int64Flag{ // --l2-flashtestations-per-block
Category: strings.ToUpper(categoryL2),
Destination: &cfg.L2.FlashtestationsPerBlock,
EnvVars: []string{envPrefix + strings.ToUpper(categoryL2) + "_FLASHTESTATIONS_PER_BLOCK"},
Name: categoryL2 + "-flashtestations-per-block",
Usage: "expected count of flashtestations per block on l2",
Value: 1,
},

&cli.Uint64Flag{
Category: strings.ToUpper(categoryL2),
Destination: &cfg.L2.GenesisTime,
Expand Down Expand Up @@ -122,7 +131,51 @@ func CommandServe(cfg *config.Config) *cli.Command {
EnvVars: []string{envPrefix + strings.ToUpper(categoryL2) + "_MONITOR_BUILDER_POLICY_CONTRACT_FUNCTION_SIGNATURE"},
Name: categoryL2 + "-monitor-builder-policy-contract-function-signature",
Usage: "l2 builder flashtestations policy contract function `signature` to monitor",
Value: "verifyBlockBuilderProof(uint8,bytes32)",
Value: "permitVerifyBlockBuilderProof(uint8,bytes32,uint256,bytes)",
},

&cli.StringFlag{ // --l2-monitor-builder-policy-add-workload-id-signature
Category: strings.ToUpper(categoryL2),
Destination: &cfg.L2.MonitorBuilderPolicyAddWorkloadIdSignature,
EnvVars: []string{envPrefix + strings.ToUpper(categoryL2) + "_MONITOR_BUILDER_POLICY_ADD_WORKLOAD_ID_SIGNATURE"},
Name: categoryL2 + "-monitor-builder-policy-add-workload-id-signature",
Usage: "l2 builder policy function `signature` to add workload id",
Value: "addWorkloadToPolicy(bytes32,string,string[])",
},

&cli.StringFlag{ // --l2-monitor-builder-policy-add-workload-id-event-signature
Category: strings.ToUpper(categoryL2),
Destination: &cfg.L2.MonitorBuilderPolicyAddWorkloadIdEventSignature,
EnvVars: []string{envPrefix + strings.ToUpper(categoryL2) + "_MONITOR_BUILDER_POLICY_ADD_WORKLOAD_ID_EVENT_SIGNATURE"},
Name: categoryL2 + "-monitor-builder-policy-add-workload-id-event-signature",
Usage: "l2 builder policy event `signature` to add workload id",
Value: "WorkloadAddedToPolicy(bytes32)",
},

&cli.StringFlag{ // --l2-monitor-flashtestations-registry-contract
Category: strings.ToUpper(categoryL2),
Destination: &cfg.L2.MonitorFlashtestationRegistryContract,
EnvVars: []string{envPrefix + strings.ToUpper(categoryL2) + "_MONITOR_FLASHTESTATIONS_REGISTRY_CONTRACT"},
Name: categoryL2 + "-monitor-flashtestations-registry-contract",
Usage: "l2 builder flashtestations registry contract `address` to monitor",
},

&cli.StringFlag{ // --l2-monitor-flashtestations-registry-function-signature
Category: strings.ToUpper(categoryL2),
Destination: &cfg.L2.MonitorFlashtestationRegistryFunctionSignature,
EnvVars: []string{envPrefix + strings.ToUpper(categoryL2) + "_MONITOR_FLASHTESTATIONS_REGISTRY_CONTRACT_FUNCTION_SIGNATURE"},
Name: categoryL2 + "-monitor-flashtestations-registry-contract-function-signature",
Usage: "l2 builder flashtestations registry contract function `signature` to monitor",
Value: "permitRegisterTEEService(bytes,bytes,uint256,uint256,bytes)",
},

&cli.StringFlag{ // --l2-monitor-flashtestations-registry-event-signature
Category: strings.ToUpper(categoryL2),
Destination: &cfg.L2.MonitorFlashtestationRegistryEventSignature,
EnvVars: []string{envPrefix + strings.ToUpper(categoryL2) + "_MONITOR_FLASHTESTATIONS_REGISTRY_EVENT_SIGNATURE"},
Name: categoryL2 + "-monitor-flashtestations-registry-event-signature",
Usage: "l2 builder flashtestations registry contract event `signature` to monitor",
Value: "TEEServiceRegistered(address,bytes,bool)",
},

&cli.StringFlag{ // --l2-monitor-flashblock-number-contract
Expand Down
55 changes: 41 additions & 14 deletions config/l2.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,25 @@ import (
type L2 struct {
Dir *Dir `yaml:"-"`

BlockTime time.Duration `yaml:"block_time"`
FlashblocksPerBlock int64 `yaml:"flashblocks_per_block"`
GenesisTime uint64 `yaml:"genesis_time"`
NetworkID uint64 `yaml:"network_id"`
ReorgWindow time.Duration `yaml:"reorg_window"`
Rpc string `yaml:"rpc"`
RpcFallback []string `yaml:"rpc_fallback"`
BlockTime time.Duration `yaml:"block_time"`
FlashblocksPerBlock int64 `yaml:"flashblocks_per_block"`
FlashtestationsPerBlock int64 `yaml:"flashtestations_per_block"`
GenesisTime uint64 `yaml:"genesis_time"`
NetworkID uint64 `yaml:"network_id"`
ReorgWindow time.Duration `yaml:"reorg_window"`
Rpc string `yaml:"rpc"`
RpcFallback []string `yaml:"rpc_fallback"`

MonitorBuilderAddress string `yaml:"monitor_builder_address"`
MonitorBuilderPolicyAddWorkloadIdEventSignature string `yaml:"monitor_builder_policy_add_workload_id_event_signature"`
MonitorBuilderPolicyAddWorkloadIdSignature string `yaml:"monitor_builder_policy_add_workload_id_signature"`
MonitorBuilderPolicyContract string `yaml:"monitor_builder_policy_contract"`
MonitorBuilderPolicyContractFunctionSignature string `yaml:"monitor_builder_policy_contract_function_signature"`
MonitorFlashblockNumberContract string `yaml:"monitor_builder_flashblock_number_contract"`
MonitorFlashblockNumberContractFunctionSignature string `yaml:"monitor_builder_flashblock_number_contract_function_signature"`
MonitorFlashtestationRegistryContract string `yaml:"monitor_flashtestation_registry_contract"`
MonitorFlashtestationRegistryEventSignature string `yaml:"monitor_flashtestation_registry_event_signature"`
MonitorFlashtestationRegistryFunctionSignature string `yaml:"monitor_flashtestation_registry_function_signature"`
MonitorTxReceipts bool `yaml:"monitor_tx_receipts"`
MonitorWalletAddresses map[string]string `yaml:"monitor_wallet_addresses"`

Expand All @@ -37,13 +43,14 @@ const (
)

var (
errL2InvalidBuilderAddress = errors.New("invalid l2 builder address")
errL2InvalidBuilderPolicyContact = errors.New("invalid l2 builder policy contract address")
errL2InvalidFlashblockNumberContact = errors.New("invalid l2 flashblocks number contract address")
errL2InvalidRpc = errors.New("invalid l2 rpc url")
errL2InvalidRpcFallback = errors.New("invalid l2 fallback rpc url")
errL2InvalidWalletAddress = errors.New("invalid l2 wallet address")
errL2ReorgWindowTooLarge = errors.New("l2 reorg window is too large")
errL2InvalidBuilderAddress = errors.New("invalid l2 builder address")
errL2InvalidBuilderPolicyContact = errors.New("invalid l2 builder policy contract address")
errL2InvalidFlashblockNumberContact = errors.New("invalid l2 flashblocks number contract address")
errL2InvalidFlashtestationsRegistryContact = errors.New("invalid l2 flashtestations registry contract address")
errL2InvalidRpc = errors.New("invalid l2 rpc url")
errL2InvalidRpcFallback = errors.New("invalid l2 fallback rpc url")
errL2InvalidWalletAddress = errors.New("invalid l2 wallet address")
errL2ReorgWindowTooLarge = errors.New("l2 reorg window is too large")
)

func (cfg *L2) Validate() error {
Expand Down Expand Up @@ -121,6 +128,26 @@ func (cfg *L2) Validate() error {
}
}

{ // monitor_flashtestations_registry_contract
if cfg.MonitorFlashtestationRegistryContract != "" {
_addr, err := ethcommon.ParseHexOrString(cfg.MonitorFlashtestationRegistryContract)
if err != nil {
errs = append(errs, fmt.Errorf("%w: %s: %w",
errL2InvalidFlashtestationsRegistryContact,
cfg.MonitorFlashtestationRegistryContract,
err,
))
}
if len(_addr) != 20 {
errs = append(errs, fmt.Errorf("%w: %s: invalid length (want 20, got %d)",
errL2InvalidFlashtestationsRegistryContact,
cfg.MonitorFlashtestationRegistryContract,
len(_addr),
))
}
}
}

{ // monitor_builder_flashblock_number_contract
if cfg.MonitorFlashblockNumberContract != "" {
_addr, err := ethcommon.ParseHexOrString(cfg.MonitorFlashblockNumberContract)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ require (
go.opentelemetry.io/otel/sdk v1.37.0
go.opentelemetry.io/otel/sdk/metric v1.37.0
go.uber.org/zap v1.27.0
golang.org/x/crypto v0.40.0
)

replace github.com/ethereum/go-ethereum => github.com/ethereum-optimism/op-geth v1.101511.1
Expand Down Expand Up @@ -71,7 +72,6 @@ require (
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
go.opentelemetry.io/otel/trace v1.37.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/crypto v0.40.0 // indirect
golang.org/x/exp v0.0.0-20250711185948-6ae5c78190dc // indirect
golang.org/x/sync v0.16.0 // indirect
golang.org/x/sys v0.34.0 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0=
github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
Expand Down
10 changes: 10 additions & 0 deletions metrics/exports.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ var (
FlashblocksLandedCount otelapi.Int64Gauge
FlashblocksMissedCount otelapi.Int64Gauge

FlashtestationsLandedCount otelapi.Int64Gauge
FlashtestationsMissedCount otelapi.Int64Gauge
RegisteredFlashtestationsCount otelapi.Int64Gauge
WorkloadAddedToPolicyCount otelapi.Int64Gauge

ReorgsCount otelapi.Int64Counter
ReorgDepth otelapi.Int64Gauge

Expand Down Expand Up @@ -52,6 +57,11 @@ var (
setupFlashblocksLandedCount,
setupFlashblocksMissedCount,

setupFlashtestationsLandedCount,
setupFlashtestationsMissedCount,
setupRegisteredFlashtestationsCount,
setupWorkloadAddedToPolicyCount,

setupReorgsCount,
setupReorgDepth,

Expand Down
44 changes: 44 additions & 0 deletions metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,50 @@ func setupFlashblocksMissedCount(ctx context.Context, _ *config.ProbeTx) error {
return nil
}

func setupFlashtestationsLandedCount(ctx context.Context, _ *config.ProbeTx) error {
m, err := meter.Int64Gauge("flashtestations_landed_count",
otelapi.WithDescription("flashtestations landed by our builder"),
)
if err != nil {
return err
}
FlashtestationsLandedCount = m
return nil
}

func setupFlashtestationsMissedCount(ctx context.Context, _ *config.ProbeTx) error {
m, err := meter.Int64Gauge("flashtestations_missed_count",
otelapi.WithDescription("flashtestations missed by our builder"),
)
if err != nil {
return err
}
FlashtestationsMissedCount = m
return nil
}

func setupRegisteredFlashtestationsCount(ctx context.Context, _ *config.ProbeTx) error {
m, err := meter.Int64Gauge("registered_flashtestations_count",
otelapi.WithDescription("registered flashtestations count"),
)
if err != nil {
return err
}
RegisteredFlashtestationsCount = m
return nil
}

func setupWorkloadAddedToPolicyCount(ctx context.Context, _ *config.ProbeTx) error {
m, err := meter.Int64Gauge("workload_added_to_policy_count",
otelapi.WithDescription("workload added to policy count"),
)
if err != nil {
return err
}
WorkloadAddedToPolicyCount = m
return nil
}

func setupBlocksSeenCount(ctx context.Context, _ *config.ProbeTx) error {
m, err := meter.Int64Gauge("blocks_seen_count",
otelapi.WithDescription("blocks seen by the monitor"),
Expand Down
Loading