diff --git a/arbnode/node.go b/arbnode/node.go index fab41a3f5b..54a34bf2a6 100644 --- a/arbnode/node.go +++ b/arbnode/node.go @@ -744,8 +744,8 @@ func createNodeImpl( } statelessBlockValidator, err = staker.NewStatelessBlockValidator( inboxReader, - hotShotReader, inboxTracker, + hotShotReader, txStreamer, exec, rawdb.NewTable(arbDb, storage.BlockValidatorPrefix), diff --git a/staker/block_validator.go b/staker/block_validator.go index ba8b188c9a..0126f4e6d1 100644 --- a/staker/block_validator.go +++ b/staker/block_validator.go @@ -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 { @@ -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) diff --git a/staker/stateless_block_validator.go b/staker/stateless_block_validator.go index 06f54af704..f6cf9a50ef 100644 --- a/staker/stateless_block_validator.go +++ b/staker/stateless_block_validator.go @@ -229,8 +229,8 @@ func newValidationEntry( func NewStatelessBlockValidator( inboxReader InboxReaderInterface, - hotShotReader HotShotReaderInterface, inbox InboxTrackerInterface, + hotShotReader HotShotReaderInterface, streamer TransactionStreamerInterface, recorder execution.ExecutionRecorder, arbdb ethdb.Database, @@ -238,6 +238,10 @@ func NewStatelessBlockValidator( 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) @@ -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) diff --git a/system_tests/full_challenge_impl_test.go b/system_tests/full_challenge_impl_test.go index 99064d1913..f157f5fc96 100644 --- a/system_tests/full_challenge_impl_test.go +++ b/system_tests/full_challenge_impl_test.go @@ -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) } @@ -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) } diff --git a/system_tests/staker_test.go b/system_tests/staker_test.go index 6267abe0c5..fdce7dd3cf 100644 --- a/system_tests/staker_test.go +++ b/system_tests/staker_test.go @@ -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, @@ -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,