diff --git a/op-challenger/config/config.go b/op-challenger/config/config.go index d53eec9048d37..874acdcd145f2 100644 --- a/op-challenger/config/config.go +++ b/op-challenger/config/config.go @@ -65,17 +65,16 @@ const ( // This also contains config options for auxiliary services. // It is used to initialize the challenger. type Config struct { - L1EthRpc string // L1 RPC Url - L1Beacon string // L1 Beacon API Url - L1BeaconSkipBlobVerification bool // Skip verification of the KZG proof for each blob. Not recommended unless the provided beacon endpoints are trusted. - GameFactoryAddress common.Address // Address of the dispute game factory - GameAllowlist []common.Address // Allowlist of fault game addresses - GameWindow time.Duration // Maximum time duration to look for games to progress - Datadir string // Data Directory - MaxConcurrency uint // Maximum number of threads to use when progressing games - PollInterval time.Duration // Polling interval for latest-block subscription when using an HTTP RPC provider - AllowInvalidPrestate bool // Whether to allow responding to games where the prestate does not match - MinUpdateInterval time.Duration // Minimum duration the L1 head block time must advance before scheduling a new update cycle + L1EthRpc string // L1 RPC Url + L1Beacon string // L1 Beacon API Url + GameFactoryAddress common.Address // Address of the dispute game factory + GameAllowlist []common.Address // Allowlist of fault game addresses + GameWindow time.Duration // Maximum time duration to look for games to progress + Datadir string // Data Directory + MaxConcurrency uint // Maximum number of threads to use when progressing games + PollInterval time.Duration // Polling interval for latest-block subscription when using an HTTP RPC provider + AllowInvalidPrestate bool // Whether to allow responding to games where the prestate does not match + MinUpdateInterval time.Duration // Minimum duration the L1 head block time must advance before scheduling a new update cycle AdditionalBondClaimants []common.Address // List of addresses to claim bonds for in addition to the tx manager sender @@ -152,46 +151,42 @@ func NewInteropConfig( Datadir: datadir, Cannon: vm.Config{ - VmType: types.TraceTypeCannon, - L1: l1EthRpc, - L1Beacon: l1BeaconApi, - L1BeaconSkipBlobVerification: false, - L2s: l2Rpcs, - SnapshotFreq: DefaultCannonSnapshotFreq, - InfoFreq: DefaultCannonInfoFreq, - DebugInfo: true, - BinarySnapshots: true, + VmType: types.TraceTypeCannon, + L1: l1EthRpc, + L1Beacon: l1BeaconApi, + L2s: l2Rpcs, + SnapshotFreq: DefaultCannonSnapshotFreq, + InfoFreq: DefaultCannonInfoFreq, + DebugInfo: true, + BinarySnapshots: true, }, CannonKona: vm.Config{ - VmType: types.TraceTypeCannonKona, - L1: l1EthRpc, - L1Beacon: l1BeaconApi, - L1BeaconSkipBlobVerification: false, - L2s: l2Rpcs, - SnapshotFreq: DefaultCannonSnapshotFreq, - InfoFreq: DefaultCannonInfoFreq, - DebugInfo: true, - BinarySnapshots: true, + VmType: types.TraceTypeCannonKona, + L1: l1EthRpc, + L1Beacon: l1BeaconApi, + L2s: l2Rpcs, + SnapshotFreq: DefaultCannonSnapshotFreq, + InfoFreq: DefaultCannonInfoFreq, + DebugInfo: true, + BinarySnapshots: true, }, Asterisc: vm.Config{ - VmType: types.TraceTypeAsterisc, - L1: l1EthRpc, - L1Beacon: l1BeaconApi, - L1BeaconSkipBlobVerification: false, - L2s: l2Rpcs, - SnapshotFreq: DefaultAsteriscSnapshotFreq, - InfoFreq: DefaultAsteriscInfoFreq, - BinarySnapshots: true, + VmType: types.TraceTypeAsterisc, + L1: l1EthRpc, + L1Beacon: l1BeaconApi, + L2s: l2Rpcs, + SnapshotFreq: DefaultAsteriscSnapshotFreq, + InfoFreq: DefaultAsteriscInfoFreq, + BinarySnapshots: true, }, AsteriscKona: vm.Config{ - VmType: types.TraceTypeAsteriscKona, - L1: l1EthRpc, - L1Beacon: l1BeaconApi, - L1BeaconSkipBlobVerification: false, - L2s: l2Rpcs, - SnapshotFreq: DefaultAsteriscSnapshotFreq, - InfoFreq: DefaultAsteriscInfoFreq, - BinarySnapshots: true, + VmType: types.TraceTypeAsteriscKona, + L1: l1EthRpc, + L1Beacon: l1BeaconApi, + L2s: l2Rpcs, + SnapshotFreq: DefaultAsteriscSnapshotFreq, + InfoFreq: DefaultAsteriscInfoFreq, + BinarySnapshots: true, }, GameWindow: DefaultGameWindow, } @@ -226,46 +221,42 @@ func NewConfig( Datadir: datadir, Cannon: vm.Config{ - VmType: types.TraceTypeCannon, - L1: l1EthRpc, - L1Beacon: l1BeaconApi, - L1BeaconSkipBlobVerification: false, - L2s: []string{l2EthRpc}, - SnapshotFreq: DefaultCannonSnapshotFreq, - InfoFreq: DefaultCannonInfoFreq, - DebugInfo: true, - BinarySnapshots: true, + VmType: types.TraceTypeCannon, + L1: l1EthRpc, + L1Beacon: l1BeaconApi, + L2s: []string{l2EthRpc}, + SnapshotFreq: DefaultCannonSnapshotFreq, + InfoFreq: DefaultCannonInfoFreq, + DebugInfo: true, + BinarySnapshots: true, }, CannonKona: vm.Config{ - VmType: types.TraceTypeCannonKona, - L1: l1EthRpc, - L1Beacon: l1BeaconApi, - L1BeaconSkipBlobVerification: false, - L2s: []string{l2EthRpc}, - SnapshotFreq: DefaultCannonSnapshotFreq, - InfoFreq: DefaultCannonInfoFreq, - DebugInfo: true, - BinarySnapshots: true, + VmType: types.TraceTypeCannonKona, + L1: l1EthRpc, + L1Beacon: l1BeaconApi, + L2s: []string{l2EthRpc}, + SnapshotFreq: DefaultCannonSnapshotFreq, + InfoFreq: DefaultCannonInfoFreq, + DebugInfo: true, + BinarySnapshots: true, }, Asterisc: vm.Config{ - VmType: types.TraceTypeAsterisc, - L1: l1EthRpc, - L1Beacon: l1BeaconApi, - L1BeaconSkipBlobVerification: false, - L2s: []string{l2EthRpc}, - SnapshotFreq: DefaultAsteriscSnapshotFreq, - InfoFreq: DefaultAsteriscInfoFreq, - BinarySnapshots: true, + VmType: types.TraceTypeAsterisc, + L1: l1EthRpc, + L1Beacon: l1BeaconApi, + L2s: []string{l2EthRpc}, + SnapshotFreq: DefaultAsteriscSnapshotFreq, + InfoFreq: DefaultAsteriscInfoFreq, + BinarySnapshots: true, }, AsteriscKona: vm.Config{ - VmType: types.TraceTypeAsteriscKona, - L1: l1EthRpc, - L1Beacon: l1BeaconApi, - L1BeaconSkipBlobVerification: false, - L2s: []string{l2EthRpc}, - SnapshotFreq: DefaultAsteriscSnapshotFreq, - InfoFreq: DefaultAsteriscInfoFreq, - BinarySnapshots: true, + VmType: types.TraceTypeAsteriscKona, + L1: l1EthRpc, + L1Beacon: l1BeaconApi, + L2s: []string{l2EthRpc}, + SnapshotFreq: DefaultAsteriscSnapshotFreq, + InfoFreq: DefaultAsteriscInfoFreq, + BinarySnapshots: true, }, GameWindow: DefaultGameWindow, } diff --git a/op-challenger/flags/flags.go b/op-challenger/flags/flags.go index 4f4a16ac08c77..a911eaaf1bfc7 100644 --- a/op-challenger/flags/flags.go +++ b/op-challenger/flags/flags.go @@ -283,13 +283,6 @@ var ( EnvVars: prefixEnvVars("RESPONSE_DELAY_AFTER"), Value: config.DefaultResponseDelayAfter, } - L1BeaconSkipBlobVerificationFlag = &cli.BoolFlag{ - Name: "l1-beacon-skip-blob-verification", - Usage: "Skip verification of the KZG proof for each blob returned by the Beacon node. Not recommended unless the provided beacon endpoints are trusted.", - EnvVars: prefixEnvVars("L1_BEACON_SKIP_BLOB_VERIFICATION"), - Value: false, - Hidden: true, - } ) // requiredFlags are checked by [CheckRequired] @@ -337,7 +330,6 @@ var optionalFlags = []cli.Flag{ ResponseDelayFlag, ResponseDelayAfterFlag, L1GenesisFlag, - L1BeaconSkipBlobVerificationFlag, } func init() { @@ -703,109 +695,103 @@ func NewConfigFromCLI(ctx *cli.Context, logger log.Logger) (*config.Config, erro networks := ctx.StringSlice(flags.NetworkFlagName) l1EthRpc := ctx.String(L1EthRpcFlag.Name) l1Beacon := ctx.String(L1BeaconFlag.Name) - l1BeaconSkipBlobVerification := ctx.Bool(L1BeaconSkipBlobVerificationFlag.Name) l2Rpcs := ctx.StringSlice(L2EthRpcFlag.Name) l2Experimental := ctx.String(L2ExperimentalEthRpcFlag.Name) return &config.Config{ // Required Flags - L1EthRpc: l1EthRpc, - L1Beacon: l1Beacon, - L1BeaconSkipBlobVerification: l1BeaconSkipBlobVerification, - TraceTypes: traceTypes, - GameFactoryAddress: gameFactoryAddress, - GameAllowlist: allowedGames, - GameWindow: ctx.Duration(GameWindowFlag.Name), - MaxConcurrency: maxConcurrency, - L2Rpcs: l2Rpcs, - MaxPendingTx: ctx.Uint64(MaxPendingTransactionsFlag.Name), - PollInterval: ctx.Duration(HTTPPollInterval.Name), - MinUpdateInterval: ctx.Duration(MinUpdateInterval.Name), - AdditionalBondClaimants: claimants, - RollupRpc: ctx.String(RollupRpcFlag.Name), - SupervisorRPC: ctx.String(SupervisorRpcFlag.Name), + L1EthRpc: l1EthRpc, + L1Beacon: l1Beacon, + TraceTypes: traceTypes, + GameFactoryAddress: gameFactoryAddress, + GameAllowlist: allowedGames, + GameWindow: ctx.Duration(GameWindowFlag.Name), + MaxConcurrency: maxConcurrency, + L2Rpcs: l2Rpcs, + MaxPendingTx: ctx.Uint64(MaxPendingTransactionsFlag.Name), + PollInterval: ctx.Duration(HTTPPollInterval.Name), + MinUpdateInterval: ctx.Duration(MinUpdateInterval.Name), + AdditionalBondClaimants: claimants, + RollupRpc: ctx.String(RollupRpcFlag.Name), + SupervisorRPC: ctx.String(SupervisorRpcFlag.Name), Cannon: vm.Config{ - L1GenesisPath: ctx.String(L1GenesisFlag.Name), - VmType: types.TraceTypeCannon, - L1: l1EthRpc, - L1Beacon: l1Beacon, - L1BeaconSkipBlobVerification: l1BeaconSkipBlobVerification, - L2s: l2Rpcs, - L2Experimental: l2Experimental, - VmBin: ctx.String(CannonBinFlag.Name), - Server: ctx.String(CannonServerFlag.Name), - Networks: networks, - L2Custom: ctx.Bool(CannonL2CustomFlag.Name), - RollupConfigPaths: RollupConfigFlag.StringSlice(ctx, types.TraceTypeCannon), - L2GenesisPaths: L2GenesisFlag.StringSlice(ctx, types.TraceTypeCannon), - DepsetConfigPath: DepsetConfigFlag.String(ctx, types.TraceTypeCannon), - SnapshotFreq: ctx.Uint(CannonSnapshotFreqFlag.Name), - InfoFreq: ctx.Uint(CannonInfoFreqFlag.Name), - DebugInfo: true, - BinarySnapshots: true, + L1GenesisPath: ctx.String(L1GenesisFlag.Name), + VmType: types.TraceTypeCannon, + L1: l1EthRpc, + L1Beacon: l1Beacon, + L2s: l2Rpcs, + L2Experimental: l2Experimental, + VmBin: ctx.String(CannonBinFlag.Name), + Server: ctx.String(CannonServerFlag.Name), + Networks: networks, + L2Custom: ctx.Bool(CannonL2CustomFlag.Name), + RollupConfigPaths: RollupConfigFlag.StringSlice(ctx, types.TraceTypeCannon), + L2GenesisPaths: L2GenesisFlag.StringSlice(ctx, types.TraceTypeCannon), + DepsetConfigPath: DepsetConfigFlag.String(ctx, types.TraceTypeCannon), + SnapshotFreq: ctx.Uint(CannonSnapshotFreqFlag.Name), + InfoFreq: ctx.Uint(CannonInfoFreqFlag.Name), + DebugInfo: true, + BinarySnapshots: true, }, CannonAbsolutePreState: ctx.String(CannonPreStateFlag.Name), CannonAbsolutePreStateBaseURL: cannonPreStatesURL, CannonKona: vm.Config{ - L1GenesisPath: ctx.String(L1GenesisFlag.Name), - VmType: types.TraceTypeCannonKona, - L1: l1EthRpc, - L1Beacon: l1Beacon, - L1BeaconSkipBlobVerification: l1BeaconSkipBlobVerification, - L2s: l2Rpcs, - L2Experimental: l2Experimental, - VmBin: ctx.String(CannonBinFlag.Name), - Server: ctx.String(CannonKonaServerFlag.Name), - Networks: networks, - L2Custom: ctx.Bool(CannonKonaL2CustomFlag.Name), - RollupConfigPaths: RollupConfigFlag.StringSlice(ctx, types.TraceTypeCannonKona), - L2GenesisPaths: L2GenesisFlag.StringSlice(ctx, types.TraceTypeCannonKona), - DepsetConfigPath: DepsetConfigFlag.String(ctx, types.TraceTypeCannonKona), - SnapshotFreq: ctx.Uint(CannonSnapshotFreqFlag.Name), - InfoFreq: ctx.Uint(CannonInfoFreqFlag.Name), - DebugInfo: true, - BinarySnapshots: true, + L1GenesisPath: ctx.String(L1GenesisFlag.Name), + VmType: types.TraceTypeCannonKona, + L1: l1EthRpc, + L1Beacon: l1Beacon, + L2s: l2Rpcs, + L2Experimental: l2Experimental, + VmBin: ctx.String(CannonBinFlag.Name), + Server: ctx.String(CannonKonaServerFlag.Name), + Networks: networks, + L2Custom: ctx.Bool(CannonKonaL2CustomFlag.Name), + RollupConfigPaths: RollupConfigFlag.StringSlice(ctx, types.TraceTypeCannonKona), + L2GenesisPaths: L2GenesisFlag.StringSlice(ctx, types.TraceTypeCannonKona), + DepsetConfigPath: DepsetConfigFlag.String(ctx, types.TraceTypeCannonKona), + SnapshotFreq: ctx.Uint(CannonSnapshotFreqFlag.Name), + InfoFreq: ctx.Uint(CannonInfoFreqFlag.Name), + DebugInfo: true, + BinarySnapshots: true, }, CannonKonaAbsolutePreState: ctx.String(CannonKonaPreStateFlag.Name), CannonKonaAbsolutePreStateBaseURL: cannonKonaPreStatesURL, Datadir: ctx.String(DatadirFlag.Name), Asterisc: vm.Config{ - L1GenesisPath: ctx.String(L1GenesisFlag.Name), - VmType: types.TraceTypeAsterisc, - L1: l1EthRpc, - L1Beacon: l1Beacon, - L1BeaconSkipBlobVerification: l1BeaconSkipBlobVerification, - L2s: l2Rpcs, - L2Experimental: l2Experimental, - VmBin: ctx.String(AsteriscBinFlag.Name), - Server: ctx.String(AsteriscServerFlag.Name), - Networks: networks, - RollupConfigPaths: RollupConfigFlag.StringSlice(ctx, types.TraceTypeAsterisc), - L2GenesisPaths: L2GenesisFlag.StringSlice(ctx, types.TraceTypeAsterisc), - DepsetConfigPath: DepsetConfigFlag.String(ctx, types.TraceTypeAsterisc), - SnapshotFreq: ctx.Uint(AsteriscSnapshotFreqFlag.Name), - InfoFreq: ctx.Uint(AsteriscInfoFreqFlag.Name), - BinarySnapshots: true, + L1GenesisPath: ctx.String(L1GenesisFlag.Name), + VmType: types.TraceTypeAsterisc, + L1: l1EthRpc, + L1Beacon: l1Beacon, + L2s: l2Rpcs, + L2Experimental: l2Experimental, + VmBin: ctx.String(AsteriscBinFlag.Name), + Server: ctx.String(AsteriscServerFlag.Name), + Networks: networks, + RollupConfigPaths: RollupConfigFlag.StringSlice(ctx, types.TraceTypeAsterisc), + L2GenesisPaths: L2GenesisFlag.StringSlice(ctx, types.TraceTypeAsterisc), + DepsetConfigPath: DepsetConfigFlag.String(ctx, types.TraceTypeAsterisc), + SnapshotFreq: ctx.Uint(AsteriscSnapshotFreqFlag.Name), + InfoFreq: ctx.Uint(AsteriscInfoFreqFlag.Name), + BinarySnapshots: true, }, AsteriscAbsolutePreState: ctx.String(AsteriscPreStateFlag.Name), AsteriscAbsolutePreStateBaseURL: asteriscPreStatesURL, AsteriscKona: vm.Config{ - L1GenesisPath: ctx.String(L1GenesisFlag.Name), - VmType: types.TraceTypeAsteriscKona, - L1: l1EthRpc, - L1Beacon: l1Beacon, - L1BeaconSkipBlobVerification: l1BeaconSkipBlobVerification, - L2s: l2Rpcs, - L2Experimental: l2Experimental, - VmBin: ctx.String(AsteriscBinFlag.Name), - Server: ctx.String(AsteriscKonaServerFlag.Name), - Networks: networks, - L2Custom: ctx.Bool(AsteriscKonaL2CustomFlag.Name), - RollupConfigPaths: RollupConfigFlag.StringSlice(ctx, types.TraceTypeAsteriscKona), - L2GenesisPaths: L2GenesisFlag.StringSlice(ctx, types.TraceTypeAsteriscKona), - DepsetConfigPath: DepsetConfigFlag.String(ctx, types.TraceTypeAsteriscKona), - SnapshotFreq: ctx.Uint(AsteriscSnapshotFreqFlag.Name), - InfoFreq: ctx.Uint(AsteriscInfoFreqFlag.Name), - BinarySnapshots: true, + L1GenesisPath: ctx.String(L1GenesisFlag.Name), + VmType: types.TraceTypeAsteriscKona, + L1: l1EthRpc, + L1Beacon: l1Beacon, + L2s: l2Rpcs, + L2Experimental: l2Experimental, + VmBin: ctx.String(AsteriscBinFlag.Name), + Server: ctx.String(AsteriscKonaServerFlag.Name), + Networks: networks, + L2Custom: ctx.Bool(AsteriscKonaL2CustomFlag.Name), + RollupConfigPaths: RollupConfigFlag.StringSlice(ctx, types.TraceTypeAsteriscKona), + L2GenesisPaths: L2GenesisFlag.StringSlice(ctx, types.TraceTypeAsteriscKona), + DepsetConfigPath: DepsetConfigFlag.String(ctx, types.TraceTypeAsteriscKona), + SnapshotFreq: ctx.Uint(AsteriscSnapshotFreqFlag.Name), + InfoFreq: ctx.Uint(AsteriscInfoFreqFlag.Name), + BinarySnapshots: true, }, AsteriscKonaAbsolutePreState: ctx.String(AsteriscKonaPreStateFlag.Name), AsteriscKonaAbsolutePreStateBaseURL: asteriscKonaPreStatesURL, diff --git a/op-challenger/game/fault/trace/vm/executor.go b/op-challenger/game/fault/trace/vm/executor.go index 4aa2d7673e153..38fe3791c84dd 100644 --- a/op-challenger/game/fault/trace/vm/executor.go +++ b/op-challenger/game/fault/trace/vm/executor.go @@ -49,18 +49,17 @@ type Config struct { BinarySnapshots bool // Whether to use binary snapshots instead of JSON // Host Configuration - L1 string - L1Beacon string - L1BeaconSkipBlobVerification bool // Skip verification of the KZG proof for each blob. Not recommended unless the provided beacon endpoints are trusted. - L2s []string - L2Experimental string - Server string // Path to the executable that provides the pre-image oracle server - Networks []string - L2Custom bool - RollupConfigPaths []string - L1GenesisPath string - L2GenesisPaths []string - DepsetConfigPath string + L1 string + L1Beacon string + L2s []string + L2Experimental string + Server string // Path to the executable that provides the pre-image oracle server + Networks []string + L2Custom bool + RollupConfigPaths []string + L1GenesisPath string + L2GenesisPaths []string + DepsetConfigPath string } func (c *Config) Check() error { diff --git a/op-challenger/game/fault/trace/vm/kona_server_executor.go b/op-challenger/game/fault/trace/vm/kona_server_executor.go index 8d5337f9abeae..76da826975487 100644 --- a/op-challenger/game/fault/trace/vm/kona_server_executor.go +++ b/op-challenger/game/fault/trace/vm/kona_server_executor.go @@ -61,9 +61,5 @@ func (s *KonaExecutor) OracleCommand(cfg Config, dataDir string, inputs utils.Lo args = append(args, "--l1-config-path", cfg.L1GenesisPath) } - if cfg.L1BeaconSkipBlobVerification { - args = append(args, "--l1-beacon-skip-blob-verification") - } - return args, nil } diff --git a/op-challenger/game/fault/trace/vm/kona_server_executor_test.go b/op-challenger/game/fault/trace/vm/kona_server_executor_test.go index e55fd59cb51e2..8894bfab8b2fb 100644 --- a/op-challenger/game/fault/trace/vm/kona_server_executor_test.go +++ b/op-challenger/game/fault/trace/vm/kona_server_executor_test.go @@ -46,76 +46,3 @@ func TestKonaFillHostCommand(t *testing.T) { require.True(t, slices.Contains(args, "--claimed-l2-block-number")) require.True(t, slices.Contains(args, "--l1-config-path")) } - -func TestKonaL1BeaconSkipBlobVerification(t *testing.T) { - dir := "mockdir" - baseCfg := Config{ - L1: "http://localhost:8888", - L1Beacon: "http://localhost:9000", - L2s: []string{"http://localhost:9999"}, - Server: "./bin/mockserver", - Networks: []string{"op-mainnet"}, - L1GenesisPath: "mockdir/l1-genesis-1.json", - } - inputs := utils.LocalGameInputs{ - L1Head: common.Hash{0x11}, - L2Head: common.Hash{0x22}, - L2OutputRoot: common.Hash{0x33}, - L2Claim: common.Hash{0x44}, - L2SequenceNumber: big.NewInt(3333), - } - - t.Run("NotIncludedByDefault", func(t *testing.T) { - cfg := baseCfg - cfg.L1BeaconSkipBlobVerification = false - vmConfig := NewKonaExecutor() - args, err := vmConfig.OracleCommand(cfg, dir, inputs) - require.NoError(t, err) - require.False(t, slices.Contains(args, "--l1-beacon-skip-blob-verification")) - }) - - t.Run("IncludedWhenTrue", func(t *testing.T) { - cfg := baseCfg - cfg.L1BeaconSkipBlobVerification = true - vmConfig := NewKonaExecutor() - args, err := vmConfig.OracleCommand(cfg, dir, inputs) - require.NoError(t, err) - require.True(t, slices.Contains(args, "--l1-beacon-skip-blob-verification")) - }) -} - -func TestKonaSuperL1BeaconSkipBlobVerification(t *testing.T) { - dir := "mockdir" - baseCfg := Config{ - L1: "http://localhost:8888", - L1Beacon: "http://localhost:9000", - L2s: []string{"http://localhost:9999", "http://localhost:9998"}, - Server: "./bin/mockserver", - RollupConfigPaths: []string{"rollup1.json", "rollup2.json"}, - L1GenesisPath: "mockdir/l1-genesis-1.json", - } - inputs := utils.LocalGameInputs{ - L1Head: common.Hash{0x11}, - AgreedPreState: []byte{1, 2, 3, 4}, - L2Claim: common.Hash{0x44}, - L2SequenceNumber: big.NewInt(3333), - } - - t.Run("NotIncludedByDefault", func(t *testing.T) { - cfg := baseCfg - cfg.L1BeaconSkipBlobVerification = false - vmConfig := NewKonaSuperExecutor() - args, err := vmConfig.OracleCommand(cfg, dir, inputs) - require.NoError(t, err) - require.False(t, slices.Contains(args, "--l1-beacon-skip-blob-verification")) - }) - - t.Run("IncludedWhenTrue", func(t *testing.T) { - cfg := baseCfg - cfg.L1BeaconSkipBlobVerification = true - vmConfig := NewKonaSuperExecutor() - args, err := vmConfig.OracleCommand(cfg, dir, inputs) - require.NoError(t, err) - require.True(t, slices.Contains(args, "--l1-beacon-skip-blob-verification")) - }) -} diff --git a/op-challenger/game/fault/trace/vm/kona_super_server_executor.go b/op-challenger/game/fault/trace/vm/kona_super_server_executor.go index 8843abf33dec1..5aa347f70e5f7 100644 --- a/op-challenger/game/fault/trace/vm/kona_super_server_executor.go +++ b/op-challenger/game/fault/trace/vm/kona_super_server_executor.go @@ -54,9 +54,5 @@ func (s *KonaSuperExecutor) OracleCommand(cfg Config, dataDir string, inputs uti args = append(args, "--l1-config-path", cfg.L1GenesisPath) } - if cfg.L1BeaconSkipBlobVerification { - args = append(args, "--l1-beacon-skip-blob-verification") - } - return args, nil } diff --git a/op-challenger/game/fault/trace/vm/op_program_server_executor.go b/op-challenger/game/fault/trace/vm/op_program_server_executor.go index a89b33894344f..c56d3aa4b79d0 100644 --- a/op-challenger/game/fault/trace/vm/op_program_server_executor.go +++ b/op-challenger/game/fault/trace/vm/op_program_server_executor.go @@ -75,8 +75,5 @@ func (s *OpProgramServerExecutor) OracleCommand(cfg Config, dataDir string, inpu if cfg.L1GenesisPath != "" { args = append(args, "--l1.config", cfg.L1GenesisPath) } - if cfg.L1BeaconSkipBlobVerification { - args = append(args, "--l1.beacon.skip-blob-verification") - } return args, nil } diff --git a/op-challenger/game/fault/trace/vm/op_program_server_executor_test.go b/op-challenger/game/fault/trace/vm/op_program_server_executor_test.go index 72f7b20a7be9c..37fa6a2600733 100644 --- a/op-challenger/game/fault/trace/vm/op_program_server_executor_test.go +++ b/op-challenger/game/fault/trace/vm/op_program_server_executor_test.go @@ -20,8 +20,8 @@ func TestOpProgramFillHostCommand(t *testing.T) { toPairs := func(args []string) map[string]string { pairs := make(map[string]string, len(args)/2) for i := 0; i < len(args); i += 2 { - // Boolean flags can't accept a value after a space - if args[i] == "--l2.custom" || args[i] == "--l1.beacon.skip-blob-verification" { + // l2.custom is a boolean flag so can't accept a value after a space + if args[i] == "--l2.custom" { pairs[args[i]] = "true" i-- continue @@ -217,18 +217,4 @@ func TestOpProgramFillHostCommand(t *testing.T) { require.Equal(t, pairs["--log.level"], logTest.arg) }) } - - t.Run("WithoutL1BeaconSkipBlobVerification", func(t *testing.T) { - pairs := oracleCommand(t, log.LvlInfo, func(c *Config, _ *utils.LocalGameInputs) { - c.L1BeaconSkipBlobVerification = false - }) - require.NotContains(t, pairs, "--l1.beacon.skip-blob-verification") - }) - - t.Run("WithL1BeaconSkipBlobVerification", func(t *testing.T) { - pairs := oracleCommand(t, log.LvlInfo, func(c *Config, _ *utils.LocalGameInputs) { - c.L1BeaconSkipBlobVerification = true - }) - require.Equal(t, "true", pairs["--l1.beacon.skip-blob-verification"]) - }) } diff --git a/op-node/config/beacon.go b/op-node/config/beacon.go index 679deba22d1d9..2de46e217aaf0 100644 --- a/op-node/config/beacon.go +++ b/op-node/config/beacon.go @@ -19,17 +19,15 @@ type L1BeaconEndpointSetup interface { // ShouldIgnoreBeaconCheck returns true if the Beacon-node version check should not halt startup. ShouldIgnoreBeaconCheck() bool ShouldFetchAllSidecars() bool - ShouldSkipBlobVerification() bool Check() error } type L1BeaconEndpointConfig struct { - BeaconAddr string // Address of L1 User Beacon-API endpoint to use (beacon namespace required) - BeaconHeader string // Optional HTTP header for all requests to L1 Beacon - BeaconFallbackAddrs []string // Addresses of L1 Beacon-API fallback endpoints (only for blob sidecars retrieval) - BeaconCheckIgnore bool // When false, halt startup if the beacon version endpoint fails - BeaconFetchAllSidecars bool // Whether to fetch all blob sidecars and filter locally - BeaconSkipBlobVerification bool // Whether to skip the verification of the kzg_proof for each blob returned by the Beacon node + BeaconAddr string // Address of L1 User Beacon-API endpoint to use (beacon namespace required) + BeaconHeader string // Optional HTTP header for all requests to L1 Beacon + BeaconFallbackAddrs []string // Addresses of L1 Beacon-API fallback endpoints (only for blob sidecars retrieval) + BeaconCheckIgnore bool // When false, halt startup if the beacon version endpoint fails + BeaconFetchAllSidecars bool // Whether to fetch all blob sidecars and filter locally } var _ L1BeaconEndpointSetup = (*L1BeaconEndpointConfig)(nil) @@ -68,10 +66,6 @@ func (cfg *L1BeaconEndpointConfig) ShouldFetchAllSidecars() bool { return cfg.BeaconFetchAllSidecars } -func (cfg *L1BeaconEndpointConfig) ShouldSkipBlobVerification() bool { - return cfg.BeaconSkipBlobVerification -} - func parseHTTPHeader(headerStr string) (http.Header, error) { h := make(http.Header, 1) s := strings.SplitN(headerStr, ": ", 2) diff --git a/op-node/flags/flags.go b/op-node/flags/flags.go index d7ff28eb46816..d98e959a2953e 100644 --- a/op-node/flags/flags.go +++ b/op-node/flags/flags.go @@ -107,14 +107,6 @@ var ( EnvVars: prefixEnvVars("L1_BEACON_FETCH_ALL_SIDECARS"), Category: L1RPCCategory, } - BeaconSkipBlobVerification = &cli.BoolFlag{ - Name: "l1.beacon.skip-blob-verification", - Usage: "If true, skips the verification of the kzg_proof for each blob returned by the Beacon node. Not recommended unless the provided beacon endpoints are trusted.", - Required: false, - Value: false, - EnvVars: prefixEnvVars("L1_BEACON_SKIP_BLOB_VERIFICATION"), - Category: L1RPCCategory, - } SyncModeFlag = &cli.GenericFlag{ Name: "syncmode", Usage: fmt.Sprintf("Blockchain sync mode (options: %s)", openum.EnumString(sync.ModeStrings)), @@ -442,7 +434,6 @@ var optionalFlags = []cli.Flag{ BeaconFallbackAddrs, BeaconCheckIgnore, BeaconFetchAllSidecars, - BeaconSkipBlobVerification, SyncModeFlag, FetchWithdrawalRootFromState, L1TrustRPC, diff --git a/op-node/node/node.go b/op-node/node/node.go index 960e822434ebf..2cf93f6800e99 100644 --- a/op-node/node/node.go +++ b/op-node/node/node.go @@ -362,8 +362,7 @@ func (n *OpNode) initL1BeaconAPI(ctx context.Context, cfg *config.Config) error return fmt.Errorf("failed to setup L1 Beacon API client: %w", err) } beaconCfg := sources.L1BeaconClientConfig{ - FetchAllSidecars: cfg.Beacon.ShouldFetchAllSidecars(), - SkipBlobVerification: cfg.Beacon.ShouldSkipBlobVerification(), + FetchAllSidecars: cfg.Beacon.ShouldFetchAllSidecars(), } n.beacon = sources.NewL1BeaconClient(beaconClient, beaconCfg, fallbacks...) diff --git a/op-node/service.go b/op-node/service.go index 875b366bee8f0..af72a6c4b78cb 100644 --- a/op-node/service.go +++ b/op-node/service.go @@ -158,12 +158,11 @@ func NewSupervisorEndpointConfig(ctx *cli.Context) *interop.Config { func NewBeaconEndpointConfig(ctx *cli.Context) config.L1BeaconEndpointSetup { return &config.L1BeaconEndpointConfig{ - BeaconAddr: ctx.String(flags.BeaconAddr.Name), - BeaconHeader: ctx.String(flags.BeaconHeader.Name), - BeaconFallbackAddrs: ctx.StringSlice(flags.BeaconFallbackAddrs.Name), - BeaconCheckIgnore: ctx.Bool(flags.BeaconCheckIgnore.Name), - BeaconFetchAllSidecars: ctx.Bool(flags.BeaconFetchAllSidecars.Name), - BeaconSkipBlobVerification: ctx.Bool(flags.BeaconSkipBlobVerification.Name), + BeaconAddr: ctx.String(flags.BeaconAddr.Name), + BeaconHeader: ctx.String(flags.BeaconHeader.Name), + BeaconFallbackAddrs: ctx.StringSlice(flags.BeaconFallbackAddrs.Name), + BeaconCheckIgnore: ctx.Bool(flags.BeaconCheckIgnore.Name), + BeaconFetchAllSidecars: ctx.Bool(flags.BeaconFetchAllSidecars.Name), } } diff --git a/op-program/host/config/config.go b/op-program/host/config/config.go index 5dde48f8695cd..3aa5190bdcdc6 100644 --- a/op-program/host/config/config.go +++ b/op-program/host/config/config.go @@ -60,12 +60,11 @@ type Config struct { DataFormat types.DataFormat // L1Head is the block hash of the L1 chain head block - L1Head common.Hash - L1URL string - L1BeaconURL string - L1BeaconSkipBlobVerification bool // Skip verification of the KZG proof for each blob. Not recommended unless the provided beacon endpoints are trusted. - L1TrustRPC bool - L1RPCKind sources.RPCProviderKind + L1Head common.Hash + L1URL string + L1BeaconURL string + L1TrustRPC bool + L1RPCKind sources.RPCProviderKind // L2Head is the l2 block hash contained in the L2 Output referenced by the L2OutputRoot for pre-interop mode L2Head common.Hash @@ -397,29 +396,28 @@ func NewConfigFromCLI(log log.Logger, ctx *cli.Context) (*Config, error) { } return &Config{ - L2ChainID: l2ChainID, - Rollups: rollupCfgs, - L1ChainConfig: l1ChainConfig, - DataDir: ctx.String(flags.DataDir.Name), - DataFormat: dbFormat, - L2URLs: ctx.StringSlice(flags.L2NodeAddr.Name), - L2ExperimentalURLs: ctx.StringSlice(flags.L2NodeExperimentalAddr.Name), - L2ChainConfigs: l2ChainConfigs, - L2Head: l2Head, - L2OutputRoot: l2OutputRoot, - AgreedPrestate: agreedPrestate, - DependencySet: dependencySet, - L2Claim: l2Claim, - L2ClaimBlockNumber: l2ClaimBlockNum, - L1Head: l1Head, - L1URL: ctx.String(flags.L1NodeAddr.Name), - L1BeaconURL: ctx.String(flags.L1BeaconAddr.Name), - L1BeaconSkipBlobVerification: ctx.Bool(flags.L1BeaconSkipBlobVerification.Name), - L1TrustRPC: ctx.Bool(flags.L1TrustRPC.Name), - L1RPCKind: sources.RPCProviderKind(ctx.String(flags.L1RPCProviderKind.Name)), - ExecCmd: ctx.String(flags.Exec.Name), - ServerMode: ctx.Bool(flags.Server.Name), - InteropEnabled: interopEnabled, + L2ChainID: l2ChainID, + Rollups: rollupCfgs, + L1ChainConfig: l1ChainConfig, + DataDir: ctx.String(flags.DataDir.Name), + DataFormat: dbFormat, + L2URLs: ctx.StringSlice(flags.L2NodeAddr.Name), + L2ExperimentalURLs: ctx.StringSlice(flags.L2NodeExperimentalAddr.Name), + L2ChainConfigs: l2ChainConfigs, + L2Head: l2Head, + L2OutputRoot: l2OutputRoot, + AgreedPrestate: agreedPrestate, + DependencySet: dependencySet, + L2Claim: l2Claim, + L2ClaimBlockNumber: l2ClaimBlockNum, + L1Head: l1Head, + L1URL: ctx.String(flags.L1NodeAddr.Name), + L1BeaconURL: ctx.String(flags.L1BeaconAddr.Name), + L1TrustRPC: ctx.Bool(flags.L1TrustRPC.Name), + L1RPCKind: sources.RPCProviderKind(ctx.String(flags.L1RPCProviderKind.Name)), + ExecCmd: ctx.String(flags.Exec.Name), + ServerMode: ctx.Bool(flags.Server.Name), + InteropEnabled: interopEnabled, }, nil } diff --git a/op-program/host/config/config_test.go b/op-program/host/config/config_test.go index b66b4eb2787ec..0dc868adb6c77 100644 --- a/op-program/host/config/config_test.go +++ b/op-program/host/config/config_test.go @@ -310,24 +310,3 @@ func validInteropConfig() *Config { cfg.L2OutputRoot = crypto.Keccak256Hash(cfg.AgreedPrestate) return cfg } - -func TestL1BeaconSkipBlobVerification(t *testing.T) { - t.Run("DefaultIsFalse", func(t *testing.T) { - cfg := validConfig() - require.False(t, cfg.L1BeaconSkipBlobVerification, "L1BeaconSkipBlobVerification should default to false") - }) - - t.Run("CanBeSetToTrue", func(t *testing.T) { - cfg := validConfig() - cfg.L1BeaconSkipBlobVerification = true - require.True(t, cfg.L1BeaconSkipBlobVerification) - require.NoError(t, cfg.Check()) - }) - - t.Run("WorksWithInterop", func(t *testing.T) { - cfg := validInteropConfig() - cfg.L1BeaconSkipBlobVerification = true - require.True(t, cfg.L1BeaconSkipBlobVerification) - require.NoError(t, cfg.Check()) - }) -} diff --git a/op-program/host/flags/flags.go b/op-program/host/flags/flags.go index cd666b97b2cf7..01aab1990718c 100644 --- a/op-program/host/flags/flags.go +++ b/op-program/host/flags/flags.go @@ -112,12 +112,6 @@ var ( Usage: "Address of L1 Beacon API endpoint to use", EnvVars: prefixEnvVars("L1_BEACON_API"), } - L1BeaconSkipBlobVerification = &cli.BoolFlag{ - Name: "l1.beacon.skip-blob-verification", - Usage: "Skip verification of the kzg_proof for each blob returned by the Beacon node. Not recommended unless the provided beacon endpoints are trusted.", - Value: false, - EnvVars: prefixEnvVars("L1_BEACON_SKIP_BLOB_VERIFICATION"), - } L1TrustRPC = &cli.BoolFlag{ Name: "l1.trustrpc", Usage: "Trust the L1 RPC, sync faster at risk of malicious/buggy RPC providing bad or inconsistent L1 data", @@ -175,7 +169,6 @@ var programFlags = []cli.Flag{ L2GenesisPath, L1NodeAddr, L1BeaconAddr, - L1BeaconSkipBlobVerification, L1TrustRPC, L1RPCProviderKind, DepsetConfig, diff --git a/op-program/host/host.go b/op-program/host/host.go index 5f3a3f5479784..be9063f316960 100644 --- a/op-program/host/host.go +++ b/op-program/host/host.go @@ -95,10 +95,7 @@ func makeDefaultPrefetcher(ctx context.Context, logger log.Logger, kv kvstore.KV logger.Info("Connecting to L1 beacon", "l1", cfg.L1BeaconURL) l1Beacon := sources.NewBeaconHTTPClient(client.NewBasicHTTPClient(cfg.L1BeaconURL, logger)) - l1BlobFetcher := sources.NewL1BeaconClient(l1Beacon, sources.L1BeaconClientConfig{ - FetchAllSidecars: false, - SkipBlobVerification: cfg.L1BeaconSkipBlobVerification, - }) + l1BlobFetcher := sources.NewL1BeaconClient(l1Beacon, sources.L1BeaconClientConfig{FetchAllSidecars: false}) logger.Info("Initializing L2 clients") sources, err := prefetcher.NewRetryingL2SourcesFromURLs(ctx, logger, cfg.Rollups, cfg.L2URLs, cfg.L2ExperimentalURLs) diff --git a/op-service/sources/l1_beacon_client.go b/op-service/sources/l1_beacon_client.go index f6586de8d40d4..7400c7e948286 100644 --- a/op-service/sources/l1_beacon_client.go +++ b/op-service/sources/l1_beacon_client.go @@ -13,7 +13,7 @@ import ( "sync" "github.com/ethereum/go-ethereum" - "github.com/ethereum/go-ethereum/crypto/kzg4844" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum-optimism/optimism/op-service/apis" "github.com/ethereum-optimism/optimism/op-service/client" @@ -28,8 +28,7 @@ const ( ) type L1BeaconClientConfig struct { - FetchAllSidecars bool - SkipBlobVerification bool + FetchAllSidecars bool } // L1BeaconClient is a high level golang client for the Beacon API. @@ -272,42 +271,45 @@ func (cl *L1BeaconClient) GetBlobs(ctx context.Context, ref eth.L1BlockRef, hash if err != nil { return nil, fmt.Errorf("failed to get blob sidecars for L1BlockRef %s: %w", ref, err) } - blobs, err := blobsFromSidecars(blobSidecars, hashes, cl.cfg.SkipBlobVerification) + blobs, err := blobsFromSidecars(blobSidecars, hashes) if err != nil { return nil, fmt.Errorf("failed to get blobs from sidecars for L1BlockRef %s: %w", ref, err) } return blobs, nil } -func blobsFromSidecars(blobSidecars []*eth.BlobSidecar, hashes []eth.IndexedBlobHash, skipBlobVerification bool) ([]*eth.Blob, error) { +func blobsFromSidecars(blobSidecars []*eth.BlobSidecar, hashes []eth.IndexedBlobHash) ([]*eth.Blob, error) { if len(blobSidecars) != len(hashes) { return nil, fmt.Errorf("number of hashes and blobSidecars mismatch, %d != %d", len(hashes), len(blobSidecars)) } - out := make([]*eth.Blob, len(hashes)) for i, ih := range hashes { sidecar := blobSidecars[i] if sidx := uint64(sidecar.Index); sidx != ih.Index { return nil, fmt.Errorf("expected sidecars to be ordered by hashes, but got %d != %d", sidx, ih.Index) } - - // make sure the blob's kzg commitment hashes to the expected value - hash := eth.KZGToVersionedHash(kzg4844.Commitment(sidecar.KZGCommitment)) - if hash != ih.Hash { - return nil, fmt.Errorf("expected hash %s for blob at index %d but got %s", ih.Hash, ih.Index, hash) - } - - if !skipBlobVerification { - // confirm blob data is valid by verifying its proof against the commitment - if err := eth.VerifyBlobProof(&sidecar.Blob, kzg4844.Commitment(sidecar.KZGCommitment), kzg4844.Proof(sidecar.KZGProof)); err != nil { - return nil, fmt.Errorf("blob at index %d failed verification: %w", i, err) - } + if err := verifyBlob(&sidecar.Blob, ih.Hash); err != nil { + return nil, fmt.Errorf("blob %d failed verification: %w", i, err) } out[i] = &sidecar.Blob } return out, nil } +// verifyBlob verifies that the blob data corresponds to the provided commitment. +// It recomputes the commitment from the blob data and checks it matches the expected commitment hash. +func verifyBlob(blob *eth.Blob, expectedCommitmentHash common.Hash) error { + recomputedCommitment, err := blob.ComputeKZGCommitment() + if err != nil { + return fmt.Errorf("cannot compute KZG commitment for blob: %w", err) + } + recomputedCommitmentHash := eth.KZGToVersionedHash(recomputedCommitment) + if recomputedCommitmentHash != expectedCommitmentHash { + return fmt.Errorf("recomputed commitment %s does not match expected commitment %s", recomputedCommitmentHash, expectedCommitmentHash) + } + return nil +} + // GetVersion fetches the version of the Beacon-node. func (cl *L1BeaconClient) GetVersion(ctx context.Context) (string, error) { return cl.cl.NodeVersion(ctx) diff --git a/op-service/sources/l1_beacon_client_test.go b/op-service/sources/l1_beacon_client_test.go index 2a6cfafba0a03..0e39d192891be 100644 --- a/op-service/sources/l1_beacon_client_test.go +++ b/op-service/sources/l1_beacon_client_test.go @@ -16,6 +16,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/crypto/kzg4844" @@ -63,17 +64,17 @@ func TestBlobsFromSidecars(t *testing.T) { // put the sidecars in scrambled order to confirm error sidecars := []*eth.BlobSidecar{sidecar2, sidecar0, sidecar1} - _, err := blobsFromSidecars(sidecars, hashes, false) + _, err := blobsFromSidecars(sidecars, hashes) require.Error(t, err) // too few sidecars should error sidecars = []*eth.BlobSidecar{sidecar0, sidecar1} - _, err = blobsFromSidecars(sidecars, hashes, false) + _, err = blobsFromSidecars(sidecars, hashes) require.Error(t, err) // correct order should work sidecars = []*eth.BlobSidecar{sidecar0, sidecar1, sidecar2} - blobs, err := blobsFromSidecars(sidecars, hashes, false) + blobs, err := blobsFromSidecars(sidecars, hashes) require.NoError(t, err) // confirm order by checking first blob byte against expected index for i := range blobs { @@ -84,20 +85,20 @@ func TestBlobsFromSidecars(t *testing.T) { badProof := *sidecar0 badProof.KZGProof[11]++ sidecars[1] = &badProof - _, err = blobsFromSidecars(sidecars, hashes, false) + _, err = blobsFromSidecars(sidecars, hashes) require.Error(t, err) // mangle a commitment to make sure it's detected badCommitment := *sidecar0 badCommitment.KZGCommitment[13]++ sidecars[1] = &badCommitment - _, err = blobsFromSidecars(sidecars, hashes, false) + _, err = blobsFromSidecars(sidecars, hashes) require.Error(t, err) // mangle a hash to make sure it's detected sidecars[1] = sidecar0 hashes[2].Hash[17]++ - _, err = blobsFromSidecars(sidecars, hashes, false) + _, err = blobsFromSidecars(sidecars, hashes) require.Error(t, err) } @@ -117,7 +118,7 @@ func KZGProofFromHex(s string) (kzg4844.Proof, error) { var badProof, _ = KZGProofFromHex("0xc00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000") -func TestBlobsFromSidecars_SkipBlobVerification(t *testing.T) { +func TestBlobsFromSidecars_BadProof(t *testing.T) { indices := []uint64{5, 7, 2} index0, sidecar0 := makeTestBlobSidecar(indices[0]) index1, sidecar1 := makeTestBlobSidecar(indices[1]) @@ -129,20 +130,16 @@ func TestBlobsFromSidecars_SkipBlobVerification(t *testing.T) { // Set proof to a bad / stubbed value sidecars[1].KZGProof = eth.Bytes48(badProof) - // Check that verification succeeds when skipBlobVerification is true - _, err := blobsFromSidecars(sidecars, hashes, true) + // Check that verification succeeds, the proof is not required + _, err := blobsFromSidecars(sidecars, hashes) require.NoError(t, err) - // Check that verification fails when skipBlobVerification is false - _, err = blobsFromSidecars(sidecars, hashes, false) - require.Error(t, err) - } func TestBlobsFromSidecars_EmptySidecarList(t *testing.T) { hashes := []eth.IndexedBlobHash{} sidecars := []*eth.BlobSidecar{} - blobs, err := blobsFromSidecars(sidecars, hashes, false) + blobs, err := blobsFromSidecars(sidecars, hashes) require.NoError(t, err) require.Empty(t, blobs, "blobs should be empty when no sidecars are provided") } @@ -228,7 +225,7 @@ func TestBeaconClientFallback(t *testing.T) { require.NoError(t, err) } -func TestBeaconClientSkipBlobVerification(t *testing.T) { +func TestBeaconClientBadProof(t *testing.T) { indices := []uint64{5, 7, 2} index0, sidecar0 := makeTestBlobSidecar(indices[0]) index1, sidecar1 := makeTestBlobSidecar(indices[1]) @@ -246,17 +243,10 @@ func TestBeaconClientSkipBlobVerification(t *testing.T) { p.EXPECT().BeaconGenesis(ctx).Return(eth.APIGenesisResponse{Data: eth.ReducedGenesisData{GenesisTime: 10}}, nil) p.EXPECT().ConfigSpec(ctx).Return(eth.APIConfigResponse{Data: eth.ReducedConfigData{SecondsPerSlot: 2}}, nil) - clientWithValidation := NewL1BeaconClient(p, L1BeaconClientConfig{SkipBlobVerification: false}) + clientWithValidation := NewL1BeaconClient(p, L1BeaconClientConfig{}) p.EXPECT().BeaconBlobSideCars(ctx, false, uint64(1), hashes).Return(eth.APIGetBlobSidecarsResponse{Data: apiSidecars}, nil) _, err := clientWithValidation.GetBlobs(ctx, eth.L1BlockRef{Time: 12}, hashes) - assert.Error(t, err) - - p.EXPECT().BeaconGenesis(ctx).Return(eth.APIGenesisResponse{Data: eth.ReducedGenesisData{GenesisTime: 10}}, nil) - p.EXPECT().ConfigSpec(ctx).Return(eth.APIConfigResponse{Data: eth.ReducedConfigData{SecondsPerSlot: 2}}, nil) - clientWithoutValidation := NewL1BeaconClient(p, L1BeaconClientConfig{SkipBlobVerification: true}) - p.EXPECT().BeaconBlobSideCars(ctx, false, uint64(1), hashes).Return(eth.APIGetBlobSidecarsResponse{Data: apiSidecars}, nil) - _, err = clientWithoutValidation.GetBlobs(ctx, eth.L1BlockRef{Time: 12}, hashes) - assert.NoError(t, err) + assert.NoError(t, err) // The verification flow does not require a valid proof } func TestBeaconHTTPClient(t *testing.T) { @@ -304,3 +294,14 @@ func TestClientPoolSeveral(t *testing.T) { p.MoveToNext() } } + +func TestVerifyBlob(t *testing.T) { + blob := eth.Blob{} + blob[0] = byte(7) + versionedHash := common.HexToHash("0x0164e32184169f11528f72aeb318f94d958aa28fba0731a52aead6df0104a98e") + require.NoError(t, verifyBlob(&blob, versionedHash)) + + differentBlob := eth.Blob{} + differentBlob[0] = byte(8) + require.Error(t, verifyBlob(&differentBlob, versionedHash)) +}