From 063776f8ee5999321aeb7c37edc74c9acf843382 Mon Sep 17 00:00:00 2001 From: Jared Wasinger Date: Tue, 13 Feb 2024 21:55:04 -0800 Subject: [PATCH] better comment. log when a block cross-validates successfully --- core/blockchain.go | 2 ++ core/cross_validator.go | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/core/blockchain.go b/core/blockchain.go index 14c457eedb..c60a19c498 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -1382,6 +1382,8 @@ func (bc *BlockChain) writeBlockWithState(block *types.Block, receipts []*types. // TODO: return the error and stop importing the current chain. // I'm leaving it like this so I can watch validation errors as // the client follows the chain. + } else { + log.Info("successfully cross-validated block", "number", witness.Block.NumberU64(), "hash", witness.Block.Hash()) } } // Irrelevant of the canonical status, write the block itself to the database. diff --git a/core/cross_validator.go b/core/cross_validator.go index 36fb78ab88..fb4ad07d5e 100644 --- a/core/cross_validator.go +++ b/core/cross_validator.go @@ -26,9 +26,10 @@ type crossValidator struct { // TODO: differentiate between errors from witness verification (maybe consensus // failure) and anything else. func (c *crossValidator) CrossValidateBlock(chainConfig *params.ChainConfig, witness *state.Witness) error { - // encode the witness to RLP, zeroing-out the block state root before sending - // it for cross validation to make it impossible for a cross-validator to - // produce a correct validation result without computing it. + // encode the witness to RLP, zeroing-out the block state root before encoding. + // this is to make it impossible for a cross-validator to + // produce a correct post-state root without executing the + // witness themselves. enc, _ := witness.EncodeRLP() // TODO: implement retry if endpoint can't be reached @@ -55,7 +56,6 @@ func (c *crossValidator) CrossValidateBlock(chainConfig *params.ChainConfig, wit if bytes.Compare(body, witness.Block.Header().Root[:]) != 0 { if errInner := state.DumpBlockWitnessToFile(chainConfig, witness, c.witnessRecordingPath); errInner != nil { log.Error("failed to dump block to file", "error", errInner) - panic("should not happen") } return err }