print_stages: bor snaps info (#9008)

This commit is contained in:
Alex Sharov 2023-12-21 08:08:55 +07:00 committed by GitHub
parent 379a5f8ea1
commit 4eecd8c86c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 11 deletions

View File

@ -42,7 +42,7 @@ var cmdResetState = &cobra.Command{
defer borSn.Close()
defer agg.Close()
if err := db.View(ctx, func(tx kv.Tx) error { return printStages(tx, sn, agg) }); err != nil {
if err := db.View(ctx, func(tx kv.Tx) error { return printStages(tx, sn, borSn, agg) }); err != nil {
if !errors.Is(err, context.Canceled) {
logger.Error(err.Error())
}
@ -58,7 +58,7 @@ var cmdResetState = &cobra.Command{
// set genesis after reset all buckets
fmt.Printf("After reset: \n")
if err := db.View(ctx, func(tx kv.Tx) error { return printStages(tx, sn, agg) }); err != nil {
if err := db.View(ctx, func(tx kv.Tx) error { return printStages(tx, sn, borSn, agg) }); err != nil {
if !errors.Is(err, context.Canceled) {
logger.Error(err.Error())
}
@ -97,7 +97,7 @@ func init() {
rootCmd.AddCommand(cmdClearBadBlocks)
}
func printStages(tx kv.Tx, snapshots *freezeblocks.RoSnapshots, agg *state.AggregatorV3) error {
func printStages(tx kv.Tx, snapshots *freezeblocks.RoSnapshots, borSn *freezeblocks.BorRoSnapshots, agg *state.AggregatorV3) error {
var err error
var progress uint64
w := new(tabwriter.Writer)
@ -121,18 +121,16 @@ func printStages(tx kv.Tx, snapshots *freezeblocks.RoSnapshots, agg *state.Aggre
}
fmt.Fprintf(w, "--\n")
fmt.Fprintf(w, "prune distance: %s\n\n", pm.String())
fmt.Fprintf(w, "blocks.v2: %t, blocks=%d, segments=%d, indices=%d\n\n", snapshots.Cfg().Enabled, snapshots.BlocksAvailable(), snapshots.SegmentsMax(), snapshots.IndicesMax())
fmt.Fprintf(w, "blocks.v2: %t, blocks=%d, segments=%d, indices=%d\n", snapshots.Cfg().Enabled, snapshots.BlocksAvailable(), snapshots.SegmentsMax(), snapshots.IndicesMax())
fmt.Fprintf(w, "blocks.bor.v2: segments=%d, indices=%d\n\n", borSn.SegmentsMax(), borSn.IndicesMax())
h3, err := kvcfg.HistoryV3.Enabled(tx)
if err != nil {
return err
}
lastK, lastV, err := rawdbv3.Last(tx, kv.MaxTxNum)
if err != nil {
return err
}
_, lastBlockInHistSnap, _ := rawdbv3.TxNums.FindBlockNum(tx, agg.EndTxNumMinimax())
fmt.Fprintf(w, "history.v3: %t, idx steps: %.02f, lastMaxTxNum=%d->%d, lastBlockInSnap=%d\n\n", h3, rawdbhelpers.IdxStepsCountV3(tx), u64or0(lastK), u64or0(lastV), lastBlockInHistSnap)
_lb, _lt, _ := rawdbv3.TxNums.Last(tx)
fmt.Fprintf(w, "history.v3: %t, idx steps: %.02f, lastBlockInSnap=%d, TxNums_Index(%d,%d)\n\n", h3, rawdbhelpers.IdxStepsCountV3(tx), lastBlockInHistSnap, _lb, _lt)
s1, err := tx.ReadSequence(kv.EthTx)
if err != nil {
return err

View File

@ -1271,7 +1271,7 @@ func stageHistory(db kv.RwDB, ctx context.Context, logger log.Logger) error {
if err != nil {
return err
}
_ = printStages(tx, sn, agg)
_ = printStages(tx, sn, borSn, agg)
} else {
if err := stagedsync.SpawnAccountHistoryIndex(stageAcc, tx, cfg, ctx, logger); err != nil {
return err
@ -1342,7 +1342,7 @@ func printAllStages(db kv.RoDB, ctx context.Context, logger log.Logger) error {
defer sn.Close()
defer borSn.Close()
defer agg.Close()
return db.View(ctx, func(tx kv.Tx) error { return printStages(tx, sn, agg) })
return db.View(ctx, func(tx kv.Tx) error { return printStages(tx, sn, borSn, agg) })
}
func printAppliedMigrations(db kv.RwDB, ctx context.Context, logger log.Logger) error {