Skip to content

Commit

Permalink
Merge pull request onflow#6402 from onflow/leo/log-block-id-height-in…
Browse files Browse the repository at this point in the history
…-approvals

[Verification] Adding block id and height in verified approvals
  • Loading branch information
zhangchiqing authored Sep 3, 2024
2 parents b47fa60 + e76b08f commit 9f7e8b1
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions engine/verification/verifier/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,27 +163,28 @@ func (e *Engine) process(originID flow.Identifier, event interface{}) error {
func (e *Engine) verify(ctx context.Context, originID flow.Identifier,
vc *verification.VerifiableChunkData) error {
// log it first
log := e.log.With().Timestamp().
Hex("origin", logging.ID(originID)).
log := e.log.With().
Uint64("chunk_index", vc.Chunk.Index).
Hex("result_id", logging.Entity(vc.Result)).
Uint64("block_height", vc.Header.Height).
Hex("block_id", vc.Chunk.ChunkBody.BlockID[:]).
Logger()

log.Info().Msg("verifiable chunk received by verifier engine")

// only accept internal calls
if originID != e.me.NodeID() {
return fmt.Errorf("invalid remote origin for verify")
return fmt.Errorf("invalid remote origin for verify: %v", originID)
}

var err error

// extracts chunk ID
ch, ok := vc.Result.Chunks.ByIndex(vc.Chunk.Index)
if !ok {
return engine.NewInvalidInputErrorf("chunk out of range requested: %v", vc.Chunk.Index)
}
log.With().Hex("chunk_id", logging.Entity(ch)).Logger()
log = log.With().
Hex("chunk_id", logging.Entity(ch)).
Logger()

// execute the assigned chunk
span, _ := e.tracer.StartSpanFromContext(ctx, trace.VERVerChunkVerify)
Expand All @@ -200,58 +201,58 @@ func (e *Engine) verify(ctx context.Context, originID flow.Identifier,
// if any fault found with the chunk
switch chFault := err.(type) {
case *chmodels.CFMissingRegisterTouch:
e.log.Warn().
log.Warn().
Str("chunk_fault_type", "missing_register_touch").
Str("chunk_fault", chFault.Error()).
Msg("chunk fault found, could not verify chunk")
// still create approvals for this case
case *chmodels.CFNonMatchingFinalState:
// TODO raise challenge
e.log.Warn().
log.Warn().
Str("chunk_fault_type", "final_state_mismatch").
Str("chunk_fault", chFault.Error()).
Msg("chunk fault found, could not verify chunk")
return nil
case *chmodels.CFInvalidVerifiableChunk:
// TODO raise challenge
e.log.Error().
log.Error().
Str("chunk_fault_type", "invalid_verifiable_chunk").
Str("chunk_fault", chFault.Error()).
Msg("chunk fault found, could not verify chunk")
return nil
case *chmodels.CFInvalidEventsCollection:
// TODO raise challenge
e.log.Error().
log.Error().
Str("chunk_fault_type", "invalid_event_collection").
Str("chunk_fault", chFault.Error()).
Msg("chunk fault found, could not verify chunk")
return nil
case *chmodels.CFSystemChunkIncludedCollection:
e.log.Error().
log.Error().
Str("chunk_fault_type", "system_chunk_includes_collection").
Str("chunk_fault", chFault.Error()).
Msg("chunk fault found, could not verify chunk")
return nil
case *chmodels.CFExecutionDataBlockIDMismatch:
e.log.Error().
log.Error().
Str("chunk_fault_type", "execution_data_block_id_mismatch").
Str("chunk_fault", chFault.Error()).
Msg("chunk fault found, could not verify chunk")
return nil
case *chmodels.CFExecutionDataChunksLengthMismatch:
e.log.Error().
log.Error().
Str("chunk_fault_type", "execution_data_chunks_count_mismatch").
Str("chunk_fault", chFault.Error()).
Msg("chunk fault found, could not verify chunk")
return nil
case *chmodels.CFExecutionDataInvalidChunkCID:
e.log.Error().
log.Error().
Str("chunk_fault_type", "execution_data_chunk_cid_mismatch").
Str("chunk_fault", chFault.Error()).
Msg("chunk fault found, could not verify chunk")
return nil
case *chmodels.CFInvalidExecutionDataID:
e.log.Error().
log.Error().
Str("chunk_fault_type", "execution_data_root_cid_mismatch").
Str("chunk_fault", chFault.Error()).
Msg("chunk fault found, could not verify chunk")
Expand Down

0 comments on commit 9f7e8b1

Please sign in to comment.