Skip to content

Commit ab28366

Browse files
committed
condense flags into NUM_BLOCKS
1 parent c95b330 commit ab28366

File tree

5 files changed

+30
-43
lines changed

5 files changed

+30
-43
lines changed

validator/cmd/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,6 @@ func Main() cliapp.LifecycleAction {
5959
beaconClient := service.NewBlobSidecarClient(cfg.BeaconConfig.BeaconURL)
6060
blobClient := service.NewBlobSidecarClient(cfg.BlobConfig.BeaconURL)
6161

62-
return service.NewValidator(l, headerClient, beaconClient, blobClient, closeApp, cfg.BlocksPerMinuteConfig*cfg.HoursOfBlobDataConfig*60), nil
62+
return service.NewValidator(l, headerClient, beaconClient, blobClient, closeApp, cfg.NumBlocks), nil
6363
}
6464
}

validator/flags/config.go

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,10 @@ import (
1010
)
1111

1212
type ValidatorConfig struct {
13-
LogConfig oplog.CLIConfig
14-
BeaconConfig common.BeaconConfig
15-
BlobConfig common.BeaconConfig
16-
BlocksPerMinuteConfig int
17-
HoursOfBlobDataConfig int
13+
LogConfig oplog.CLIConfig
14+
BeaconConfig common.BeaconConfig
15+
BlobConfig common.BeaconConfig
16+
NumBlocks int
1817
}
1918

2019
func (c ValidatorConfig) Check() error {
@@ -26,12 +25,8 @@ func (c ValidatorConfig) Check() error {
2625
return fmt.Errorf("blob config check failed: %w", err)
2726
}
2827

29-
if c.BlocksPerMinuteConfig <= 0 {
30-
return fmt.Errorf("blocks per minute must be greater than 0")
31-
}
32-
33-
if c.HoursOfBlobDataConfig <= 0 {
34-
return fmt.Errorf("hours of blob data must be greater than 0")
28+
if c.NumBlocks <= 0 {
29+
return fmt.Errorf("number of blocks must be greater than 0")
3530
}
3631

3732
return nil
@@ -50,7 +45,6 @@ func ReadConfig(cliCtx *cli.Context) ValidatorConfig {
5045
BeaconURL: cliCtx.String(BlobApiClientUrlFlag.Name),
5146
BeaconClientTimeout: timeout,
5247
},
53-
BlocksPerMinuteConfig: cliCtx.Int(BeaconClientTimeoutFlag.Name),
54-
HoursOfBlobDataConfig: cliCtx.Int(HoursOfBlobDataClientFlag.Name),
48+
NumBlocks: cliCtx.Int(NumBlocksClientFlag.Name),
5549
}
5650
}

validator/flags/flags.go

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,12 @@ var (
2727
Required: true,
2828
EnvVars: opservice.PrefixEnvVar(EnvVarPrefix, "BLOB_API_HTTP"),
2929
}
30-
BlocksPerMinuteClientFlag = &cli.IntFlag{
31-
Name: "blocks-per-minute",
32-
Usage: "The number of blocks per minute",
33-
Value: 5,
30+
NumBlocksClientFlag = &cli.IntFlag{
31+
Name: "num-blocks",
32+
Usage: "The number of blocks to read blob data for",
33+
Value: 600,
3434
Required: true,
35-
EnvVars: opservice.PrefixEnvVar(EnvVarPrefix, "BLOCKS_PER_MINUTE"),
36-
}
37-
HoursOfBlobDataClientFlag = &cli.IntFlag{
38-
Name: "hours-of-blob-data",
39-
Usage: "The number of hours of blob data to fetch",
40-
Value: 2,
41-
Required: true,
42-
EnvVars: opservice.PrefixEnvVar(EnvVarPrefix, "HOURS_OF_BLOB_DATA"),
35+
EnvVars: opservice.PrefixEnvVar(EnvVarPrefix, "NUM_BLOCKS"),
4336
}
4437
)
4538

validator/service/service.go

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,25 +29,25 @@ const (
2929
retryAttempts = 10
3030
)
3131

32-
func NewValidator(l log.Logger, headerClient client.BeaconBlockHeadersProvider, beaconAPI BlobSidecarClient, blobAPI BlobSidecarClient, app context.CancelCauseFunc, hoursOfBlocks int) *ValidatorService {
32+
func NewValidator(l log.Logger, headerClient client.BeaconBlockHeadersProvider, beaconAPI BlobSidecarClient, blobAPI BlobSidecarClient, app context.CancelCauseFunc, numBlocks int) *ValidatorService {
3333
return &ValidatorService{
34-
log: l,
35-
headerClient: headerClient,
36-
beaconAPI: beaconAPI,
37-
blobAPI: blobAPI,
38-
closeApp: app,
39-
hoursOfBlocks: hoursOfBlocks,
34+
log: l,
35+
headerClient: headerClient,
36+
beaconAPI: beaconAPI,
37+
blobAPI: blobAPI,
38+
closeApp: app,
39+
numBlocks: numBlocks,
4040
}
4141
}
4242

4343
type ValidatorService struct {
44-
stopped atomic.Bool
45-
log log.Logger
46-
headerClient client.BeaconBlockHeadersProvider
47-
beaconAPI BlobSidecarClient
48-
blobAPI BlobSidecarClient
49-
closeApp context.CancelCauseFunc
50-
hoursOfBlocks int
44+
stopped atomic.Bool
45+
log log.Logger
46+
headerClient client.BeaconBlockHeadersProvider
47+
beaconAPI BlobSidecarClient
48+
blobAPI BlobSidecarClient
49+
closeApp context.CancelCauseFunc
50+
numBlocks int
5151
}
5252

5353
// Start starts the validator service. This will fetch the current range of blocks to validate and start the validation
@@ -64,7 +64,7 @@ func (a *ValidatorService) Start(ctx context.Context) error {
6464
}
6565

6666
end := header.Data.Header.Message.Slot - finalizedL1Offset
67-
start := end - phase0.Slot(a.hoursOfBlocks)
67+
start := end - phase0.Slot(a.numBlocks)
6868

6969
go a.checkBlobs(ctx, start, end)
7070

validator/service/service_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,9 @@ func setup(t *testing.T) (*ValidatorService, *beacontest.StubBeaconClient, *stub
7171
data: make(map[string]response),
7272
}
7373

74-
HoursOfBlobData := 5 * 2 * 60 // 2 hours of blob data at 5 blocks per minute
74+
numBlocks := 600
7575

76-
return NewValidator(l, headerClient, beacon, blob, cancel, HoursOfBlobData), headerClient, beacon, blob
76+
return NewValidator(l, headerClient, beacon, blob, cancel, numBlocks), headerClient, beacon, blob
7777
}
7878

7979
func TestValidatorService_OnFetchError(t *testing.T) {

0 commit comments

Comments
 (0)