Skip to content

Commit

Permalink
chore: add frame for no proof state after force flushing nodebufferlist
Browse files Browse the repository at this point in the history
  • Loading branch information
joeylichang authored and VM committed Jun 12, 2024
1 parent 7dd5ec3 commit 50534f8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
3 changes: 3 additions & 0 deletions trie/triedb/pathdb/disklayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,9 @@ func (dl *diskLayer) commit(bottom *diffLayer, force bool) (*diskLayer, error) {
// To remove outdated history objects from the end, we set the 'tail' parameter
// to 'oldest-1' due to the offset between the freezer index and the history ID.
if overflow {
if nl, ok := dl.buffer.(*nodebufferlist); ok {
oldest = nl.persistID - dl.db.config.StateHistory + 1
}
pruned, err := truncateFromTail(ndl.db.diskdb, ndl.db.freezer, oldest-1)
if err != nil {
return nil, err
Expand Down
16 changes: 16 additions & 0 deletions trie/triedb/pathdb/nodebufferlist.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,13 +270,19 @@ func (nf *nodebufferlist) flush(db ethdb.KeyValueStore, clean *fastcache.Cache,
}

commitFunc := func(buffer *multiDifflayer) bool {
if nf.count <= nf.rsevMdNum {
return false
}
if err := nf.base.commit(buffer.root, buffer.id, buffer.block, buffer.layers, buffer.nodes); err != nil {
log.Crit("failed to commit nodes to base node buffer", "error", err)
}
_ = nf.popBack()
return true
}
nf.traverseReverse(commitFunc)
// delete after testing
//prePersistID := nf.persistID
//preBaseLayes := nf.base.layers
persistID := nf.persistID + nf.base.layers
err := nf.base.flush(nf.db, nf.clean, persistID)
if err != nil {
Expand All @@ -285,6 +291,16 @@ func (nf *nodebufferlist) flush(db ethdb.KeyValueStore, clean *fastcache.Cache,
nf.isFlushing.Store(false)
nf.base.reset()
nf.persistID = persistID
// add metrics, delete after testing
// 1. nf.count nf.layers => Guard type
// 2. nf.persistID prePersistID => Guard type
// 2. nf.base.layers preBaseLayes => Guard type

// test:
// 1. setup private seq
// 2. 10 accounts, 1qps, native transfer
// 3. add metrics(above)
// 4. wait more 9w
return nil
}

Expand Down

0 comments on commit 50534f8

Please sign in to comment.