Skip to content

Commit

Permalink
fix lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
nomaxg committed Nov 29, 2023
1 parent 03ca08a commit eabac34
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion arbnode/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -744,8 +744,8 @@ func createNodeImpl(
}
statelessBlockValidator, err = staker.NewStatelessBlockValidator(
inboxReader,
hotShotReader,
inboxTracker,
hotShotReader,
txStreamer,
exec,
rawdb.NewTable(arbDb, storage.BlockValidatorPrefix),
Expand Down
3 changes: 2 additions & 1 deletion staker/block_validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ type BlockValidatorConfig struct {
Dangerous BlockValidatorDangerousConfig `koanf:"dangerous"`
// Espresso specific flags
Espresso bool `koanf:"espresso"`
HotShotAddress string `koanf:"hotshot-address"`
HotShotAddress string `koanf:"hotshot-address"` //nolint
}

func (c *BlockValidatorConfig) Validate() error {
Expand All @@ -109,6 +109,7 @@ func BlockValidatorConfigAddOptions(prefix string, f *flag.FlagSet) {
f.Uint64(prefix+".prerecorded-blocks", DefaultBlockValidatorConfig.PrerecordedBlocks, "record that many blocks ahead of validation (larger footprint)")
f.String(prefix+".current-module-root", DefaultBlockValidatorConfig.CurrentModuleRoot, "current wasm module root ('current' read from chain, 'latest' from machines/latest dir, or provide hash)")
f.String(prefix+".pending-upgrade-module-root", DefaultBlockValidatorConfig.PendingUpgradeModuleRoot, "pending upgrade wasm module root to additionally validate (hash, 'latest' or empty)")
f.String(prefix+".hotshot-address", DefaultBlockValidatorConfig.HotShotAddress, "hotshot contract address that stores the commitments that must be validated against espresso sequencer batches")
f.Bool(prefix+".failure-is-fatal", DefaultBlockValidatorConfig.FailureIsFatal, "failing a validation is treated as a fatal error")
f.Bool(prefix+".espresso", DefaultBlockValidatorConfig.Espresso, "if true, hotshot header preimages will be added to validation entries to verify that transactions have been sequenced by espresso")
BlockValidatorDangerousConfigAddOptions(prefix+".dangerous", f)
Expand Down
11 changes: 8 additions & 3 deletions staker/stateless_block_validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,15 +229,19 @@ func newValidationEntry(

func NewStatelessBlockValidator(
inboxReader InboxReaderInterface,
hotShotReader HotShotReaderInterface,
inbox InboxTrackerInterface,
hotShotReader HotShotReaderInterface,
streamer TransactionStreamerInterface,
recorder execution.ExecutionRecorder,
arbdb ethdb.Database,
das arbstate.DataAvailabilityReader,
config func() *BlockValidatorConfig,
stack *node.Node,
) (*StatelessBlockValidator, error) {
// Sanity check, also used to surpress the unused koanf field lint error
if config().Espresso && config().HotShotAddress == "" {
return nil, errors.New("cannot create a new stateless block validator in espresso mode without a hotshot reader")
}
valConfFetcher := func() *rpcclient.ClientConfig { return &config().ValidationServer }
valClient := server_api.NewValidationClient(valConfFetcher, stack)
execClient := server_api.NewExecutionClient(valConfFetcher, stack)
Expand Down Expand Up @@ -300,8 +304,9 @@ func (v *StatelessBlockValidator) ValidationEntryRecord(ctx context.Context, e *
}
for i, batch := range e.BatchInfo {
if usingEspresso {
// Only provide commitment for L2 message type
batchNum := e.BatchInfo[i].Number
// TODO: Use the inbox tracker to fetch the correct HotShot index
// https://github.com/EspressoSystems/espresso-sequencer/issues/782
batchNum := batch.Number
hotShotCommitment, err := v.hotShotReader.L1HotShotCommitmentFromHeight(batchNum)
if err != nil {
return fmt.Errorf("error attempting to fetch HotShot commitment for block %d: %w", batchNum, err)
Expand Down
4 changes: 2 additions & 2 deletions system_tests/full_challenge_impl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ func RunChallengeTest(t *testing.T, asserterIsCorrect bool, useStubs bool, chall

confirmLatestBlock(ctx, t, l1Info, l1Backend)

asserterValidator, err := staker.NewStatelessBlockValidator(asserterL2.InboxReader, asserterL2.InboxTracker, asserterL2.TxStreamer, asserterExec.Recorder, asserterL2ArbDb, nil, StaticFetcherFrom(t, &conf.BlockValidator), valStack)
asserterValidator, err := staker.NewStatelessBlockValidator(asserterL2.InboxReader, asserterL2.InboxTracker, nil, asserterL2.TxStreamer, asserterExec.Recorder, asserterL2ArbDb, nil, StaticFetcherFrom(t, &conf.BlockValidator), valStack)
if err != nil {
Fatal(t, err)
}
Expand All @@ -390,7 +390,7 @@ func RunChallengeTest(t *testing.T, asserterIsCorrect bool, useStubs bool, chall
if err != nil {
Fatal(t, err)
}
challengerValidator, err := staker.NewStatelessBlockValidator(challengerL2.InboxReader, challengerL2.InboxTracker, challengerL2.TxStreamer, challengerExec.Recorder, challengerL2ArbDb, nil, StaticFetcherFrom(t, &conf.BlockValidator), valStack)
challengerValidator, err := staker.NewStatelessBlockValidator(challengerL2.InboxReader, challengerL2.InboxTracker, nil, challengerL2.TxStreamer, challengerExec.Recorder, challengerL2ArbDb, nil, StaticFetcherFrom(t, &conf.BlockValidator), valStack)
if err != nil {
Fatal(t, err)
}
Expand Down
2 changes: 2 additions & 0 deletions system_tests/staker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ func stakerTestImpl(t *testing.T, faultyStaker bool, honestStakerInactive bool)
statelessA, err := staker.NewStatelessBlockValidator(
l2nodeA.InboxReader,
l2nodeA.InboxTracker,
nil,
l2nodeA.TxStreamer,
execNodeA,
l2nodeA.ArbDB,
Expand Down Expand Up @@ -194,6 +195,7 @@ func stakerTestImpl(t *testing.T, faultyStaker bool, honestStakerInactive bool)
statelessB, err := staker.NewStatelessBlockValidator(
l2nodeB.InboxReader,
l2nodeB.InboxTracker,
nil,
l2nodeB.TxStreamer,
execNodeB,
l2nodeB.ArbDB,
Expand Down

0 comments on commit eabac34

Please sign in to comment.