mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-26 14:46:42 +00:00
triedb/pathdb: polish logs
This commit is contained in:
parent
3bef2944a0
commit
7536daa957
3 changed files with 12 additions and 10 deletions
|
|
@ -20,6 +20,7 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"sync"
|
"sync"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/VictoriaMetrics/fastcache"
|
"github.com/VictoriaMetrics/fastcache"
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
|
|
@ -365,7 +366,7 @@ func (dl *diskLayer) commit(bottom *diffLayer, force bool) (*diskLayer, error) {
|
||||||
if dl.generator != nil {
|
if dl.generator != nil {
|
||||||
dl.generator.stop()
|
dl.generator.stop()
|
||||||
progress = dl.generator.progressMarker()
|
progress = dl.generator.progressMarker()
|
||||||
log.Info("Terminated state snapshot generation")
|
log.Info("Terminated snapshot generation")
|
||||||
|
|
||||||
// If the snapshot has been fully generated, unset the generator
|
// If the snapshot has been fully generated, unset the generator
|
||||||
if progress == nil {
|
if progress == nil {
|
||||||
|
|
@ -380,7 +381,6 @@ func (dl *diskLayer) commit(bottom *diffLayer, force bool) (*diskLayer, error) {
|
||||||
// Resume the background generation if it's not completed yet
|
// Resume the background generation if it's not completed yet
|
||||||
if progress != nil {
|
if progress != nil {
|
||||||
dl.generator.run(bottom.root)
|
dl.generator.run(bottom.root)
|
||||||
log.Info("Resumed state snapshot generation", "root", bottom.root)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Link the generator if snapshot is not yet completed
|
// Link the generator if snapshot is not yet completed
|
||||||
|
|
@ -402,6 +402,7 @@ func (dl *diskLayer) commit(bottom *diffLayer, force bool) (*diskLayer, error) {
|
||||||
|
|
||||||
// revert applies the given state history and return a reverted disk layer.
|
// revert applies the given state history and return a reverted disk layer.
|
||||||
func (dl *diskLayer) revert(h *history) (*diskLayer, error) {
|
func (dl *diskLayer) revert(h *history) (*diskLayer, error) {
|
||||||
|
start := time.Now()
|
||||||
if h.meta.root != dl.rootHash() {
|
if h.meta.root != dl.rootHash() {
|
||||||
return nil, errUnexpectedHistory
|
return nil, errUnexpectedHistory
|
||||||
}
|
}
|
||||||
|
|
@ -441,6 +442,7 @@ func (dl *diskLayer) revert(h *history) (*diskLayer, error) {
|
||||||
if dl.generator != nil {
|
if dl.generator != nil {
|
||||||
ndl.setGenerator(dl.generator)
|
ndl.setGenerator(dl.generator)
|
||||||
}
|
}
|
||||||
|
log.Debug("Reverted data in write buffer", "oldroot", h.meta.root, "newroot", h.meta.parent, "elapsed", common.PrettyDuration(time.Since(start)))
|
||||||
return ndl, nil
|
return ndl, nil
|
||||||
}
|
}
|
||||||
// Terminate the generation before writing any data into database
|
// Terminate the generation before writing any data into database
|
||||||
|
|
@ -465,8 +467,8 @@ func (dl *diskLayer) revert(h *history) (*diskLayer, error) {
|
||||||
if dl.generator != nil && !dl.generator.completed() {
|
if dl.generator != nil && !dl.generator.completed() {
|
||||||
ndl.generator = dl.generator
|
ndl.generator = dl.generator
|
||||||
ndl.generator.run(h.meta.parent)
|
ndl.generator.run(h.meta.parent)
|
||||||
log.Info("Resumed state snapshot generation", "root", h.meta.parent)
|
|
||||||
}
|
}
|
||||||
|
log.Debug("Reverted data in persistent state", "oldroot", h.meta.root, "newroot", h.meta.parent, "elapsed", common.PrettyDuration(time.Since(start)))
|
||||||
return ndl, nil
|
return ndl, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -47,5 +47,5 @@ var (
|
||||||
|
|
||||||
// errNotConstructed is returned if the callers want to iterate the snapshot
|
// errNotConstructed is returned if the callers want to iterate the snapshot
|
||||||
// while the generation is not finished yet.
|
// while the generation is not finished yet.
|
||||||
errNotConstructed = errors.New("state snapshot is not constructed")
|
errNotConstructed = errors.New("snapshot is not constructed")
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -361,7 +361,7 @@ func (g *generator) proveRange(ctx *generatorContext, trieId *trie.ID, prefix []
|
||||||
// Snap state is chunked, generate edge proofs for verification.
|
// Snap state is chunked, generate edge proofs for verification.
|
||||||
tr, err := trie.New(trieId, &diskStore{db: g.db})
|
tr, err := trie.New(trieId, &diskStore{db: g.db})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Info("Trie missing, state snapshotting paused", "state", ctx.root, "kind", kind, "root", trieId.Root)
|
log.Info("Trie missing, snapshotting paused", "state", ctx.root, "kind", kind, "root", trieId.Root)
|
||||||
return nil, errMissingTrie
|
return nil, errMissingTrie
|
||||||
}
|
}
|
||||||
// Generate the Merkle proofs for the first and last element
|
// Generate the Merkle proofs for the first and last element
|
||||||
|
|
@ -483,7 +483,7 @@ func (g *generator) generateRange(ctx *generatorContext, trieId *trie.ID, prefix
|
||||||
if tr == nil {
|
if tr == nil {
|
||||||
tr, err = trie.New(trieId, &diskStore{db: g.db})
|
tr, err = trie.New(trieId, &diskStore{db: g.db})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Info("Trie missing, state snapshotting paused", "state", ctx.root, "kind", kind, "root", trieId.Root)
|
log.Info("Trie missing, snapshotting paused", "state", ctx.root, "kind", kind, "root", trieId.Root)
|
||||||
return false, nil, errMissingTrie
|
return false, nil, errMissingTrie
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -609,7 +609,7 @@ func (g *generator) checkAndFlush(ctx *generatorContext, current []byte) error {
|
||||||
|
|
||||||
// Abort the generation if it's required
|
// Abort the generation if it's required
|
||||||
if abort != nil {
|
if abort != nil {
|
||||||
g.stats.log("Aborting state snapshot generation", ctx.root, g.progress)
|
g.stats.log("Aborting snapshot generation", ctx.root, g.progress)
|
||||||
return newAbortErr(abort) // bubble up an error for interruption
|
return newAbortErr(abort) // bubble up an error for interruption
|
||||||
}
|
}
|
||||||
// Don't hold the iterators too long, release them to let compactor works
|
// Don't hold the iterators too long, release them to let compactor works
|
||||||
|
|
@ -617,7 +617,7 @@ func (g *generator) checkAndFlush(ctx *generatorContext, current []byte) error {
|
||||||
ctx.reopenIterator(snapStorage)
|
ctx.reopenIterator(snapStorage)
|
||||||
}
|
}
|
||||||
if time.Since(ctx.logged) > 8*time.Second {
|
if time.Since(ctx.logged) > 8*time.Second {
|
||||||
g.stats.log("Generating state snapshot", ctx.root, g.progress)
|
g.stats.log("Generating snapshot", ctx.root, g.progress)
|
||||||
ctx.logged = time.Now()
|
ctx.logged = time.Now()
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|
@ -766,7 +766,7 @@ func (g *generator) generateAccounts(ctx *generatorContext, accMarker []byte) er
|
||||||
// gathering and logging, since the method surfs the blocks as they arrive, often
|
// gathering and logging, since the method surfs the blocks as they arrive, often
|
||||||
// being restarted.
|
// being restarted.
|
||||||
func (g *generator) generate(ctx *generatorContext) {
|
func (g *generator) generate(ctx *generatorContext) {
|
||||||
g.stats.log("Resuming state snapshot generation", ctx.root, g.progress)
|
g.stats.log("Resuming snapshot generation", ctx.root, g.progress)
|
||||||
defer ctx.close()
|
defer ctx.close()
|
||||||
|
|
||||||
// Persist the initial marker and state snapshot root if progress is none
|
// Persist the initial marker and state snapshot root if progress is none
|
||||||
|
|
@ -815,7 +815,7 @@ func (g *generator) generate(ctx *generatorContext) {
|
||||||
}
|
}
|
||||||
ctx.batch.Reset()
|
ctx.batch.Reset()
|
||||||
|
|
||||||
log.Info("Generated state snapshot", "accounts", g.stats.accounts, "slots", g.stats.slots,
|
log.Info("Generated snapshot", "accounts", g.stats.accounts, "slots", g.stats.slots,
|
||||||
"storage", g.stats.storage, "dangling", g.stats.dangling, "elapsed", common.PrettyDuration(time.Since(g.stats.start)))
|
"storage", g.stats.storage, "dangling", g.stats.dangling, "elapsed", common.PrettyDuration(time.Since(g.stats.start)))
|
||||||
|
|
||||||
// Update the generation progress marker
|
// Update the generation progress marker
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue