Skip to content

Commit

Permalink
Merge pull request #6834 from onflow/leo/log-verify-execution-result
Browse files Browse the repository at this point in the history
[Util] Log verification progress
  • Loading branch information
zhangchiqing authored Jan 13, 2025
2 parents bdb7b5e + cd5ae62 commit bbb02eb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
8 changes: 4 additions & 4 deletions cmd/util/cmd/verify_execution_result/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ var (
// # verify the last 100 sealed blocks
// ./util verify_execution_result --chain flow-testnet --datadir /var/flow/data/protocol --chunk_data_pack_dir /var/flow/data/chunk_data_pack --lastk 100
// # verify the blocks from height 2000 to 3000
// ./util verify_execution_result --chain flow-testnet --datadir /var/flow/data/protocol --chunk_data_pack_dir /var/flow/data/chunk_data_pack --from_to 2000-3000
// ./util verify_execution_result --chain flow-testnet --datadir /var/flow/data/protocol --chunk_data_pack_dir /var/flow/data/chunk_data_pack --from_to 2000_3000
var Cmd = &cobra.Command{
Use: "verify-execution-result",
Short: "verify block execution by verifying all chunks in the result",
Expand All @@ -47,7 +47,7 @@ func init() {
"last k sealed blocks to verify")

Cmd.Flags().StringVar(&flagFromTo, "from_to", "",
"the height range to verify blocks (inclusive), i.e, 1-1000, 1000-2000, 2000-3000, etc.")
"the height range to verify blocks (inclusive), i.e, 1_1000, 1000_2000, 2000_3000, etc.")

Cmd.Flags().UintVar(&flagWorkerCount, "worker_count", 1,
"number of workers to use for verification, default is 1")
Expand Down Expand Up @@ -93,9 +93,9 @@ func run(*cobra.Command, []string) {
}

func parseFromTo(fromTo string) (from, to uint64, err error) {
parts := strings.Split(fromTo, "-")
parts := strings.Split(fromTo, "_")
if len(parts) != 2 {
return 0, 0, fmt.Errorf("invalid format: expected 'from-to', got '%s'", fromTo)
return 0, 0, fmt.Errorf("invalid format: expected 'from_to', got '%s'", fromTo)
}

from, err = strconv.ParseUint(strings.TrimSpace(parts[0]), 10, 64)
Expand Down
11 changes: 11 additions & 0 deletions engine/verification/verifier/verifiers.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"github.com/onflow/flow-go/module"
"github.com/onflow/flow-go/module/chunks"
"github.com/onflow/flow-go/module/metrics"
"github.com/onflow/flow-go/module/util"
"github.com/onflow/flow-go/state/protocol"
"github.com/onflow/flow-go/storage"
storagepebble "github.com/onflow/flow-go/storage/pebble"
Expand Down Expand Up @@ -125,6 +126,14 @@ func verifyConcurrently(
var lowestErrHeight uint64 = ^uint64(0) // Initialize to max value of uint64
var mu sync.Mutex // To protect access to lowestErr and lowestErrHeight

lg := util.LogProgress(
log.Logger,
util.DefaultLogProgressConfig(
fmt.Sprintf("verifying heights progress for [%v:%v]", from, to),
int(to+1-from),
),
)

// Worker function
worker := func() {
for {
Expand Down Expand Up @@ -154,6 +163,8 @@ func verifyConcurrently(
} else {
log.Info().Uint64("height", height).Msg("verified height successfully")
}

lg(1) // log progress
}
}
}
Expand Down

0 comments on commit bbb02eb

Please sign in to comment.