Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v2/consortium_test: fix for pbss: do not insert inserted blocks #613

Draft
wants to merge 29 commits into
base: path-base-implementing
Choose a base branch
from

Conversation

Francesco4203
Copy link
Collaborator

@Francesco4203 Francesco4203 commented Oct 25, 2024

This PR is originated from #612

Before this PR, in TestIsPeriodBlock and TestIsTrippEffective, the chain of blocks is inserted while it still includes some previously inserted blocks, causing the below error when running on path scheme.

Potential reason:

[To be updated]...

This PR is to fix it by only inserting newly created blocks.

Run test before this PR

--- FAIL: TestIsTrippEffective (0.19s)
panic: triedb parent [0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421] layer missing [recovered]
        panic: triedb parent [0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421] layer missing

goroutine 4016 [running]:
testing.tRunner.func1.2({0x105c97d20, 0x140002d1770})
        /opt/homebrew/Cellar/go/1.22.3/libexec/src/testing/testing.go:1631 +0x1c4
testing.tRunner.func1()
        /opt/homebrew/Cellar/go/1.22.3/libexec/src/testing/testing.go:1634 +0x33c
panic({0x105c97d20?, 0x140002d1770?})
        /opt/homebrew/Cellar/go/1.22.3/libexec/src/runtime/panic.go:770 +0x124
github.com/ethereum/go-ethereum/consensus/consortium/v2.testIsTrippEffective(0x140000c3a00, {0x10592235d, 0x4})
        /Users/long.nguyen/Documents/GitHub/ronin/consensus/consortium/v2/consortium_test.go:2437 +0xe5c
github.com/ethereum/go-ethereum/consensus/consortium/v2.TestIsTrippEffective(0x140000c3a00)
        /Users/long.nguyen/Documents/GitHub/ronin/consensus/consortium/v2/consortium_test.go:2341 +0x40
testing.tRunner(0x140000c3a00, 0x105df9818)
        /opt/homebrew/Cellar/go/1.22.3/libexec/src/testing/testing.go:1689 +0xec
created by testing.(*T).Run in goroutine 1
        /opt/homebrew/Cellar/go/1.22.3/libexec/src/testing/testing.go:1742 +0x318
exit status 2
FAIL    github.com/ethereum/go-ethereum/consensus/consortium/v2 1.631s

Run test after this PR

PASS
ok      github.com/ethereum/go-ethereum/consensus/consortium/v2 1.530s

huyngopt1994 and others added 29 commits September 17, 2024 11:30
* core,trie,eth,cmd: rework preimage store

* ci: trigger unittest path-base-implementing
…liary tool to capture all deleted node wwhich can't be captured by trie.Committer. The deleted nodes (axieinfinity#552)

can be removed from the disk later. Implement traverse and rework init Trie
* cmd, core/state, light, trie, eth: add trie owner notion

* all: refactor

* tests: fix goimports

* core/state/snapshot: fix ineffasigns

Co-authored-by: rjl493456442 <[email protected]>
Co-authored-by: Martin Holst Swende <[email protected]>
* core, trie: rework trie commiter

changed the commit procedure, introduce new struct called nodeSet for
returning including all dirty nodes of a trie. Multiple nodeset will be
merged to MergedNodeSet struct. then be submitted to in-memory database
from block to block

* trie,core: fix comments
* core: store genesis allocation and recommit them if necessary (#24460)

* core: store genesis allocation and recommit them if necessary

* core: recover predefined genesis allocation if possible

* all: cleanup the APIs for initializing genesis (#25473)

* all: polish tests

* core: apply feedback from Guillaume

* core: fix comment

---------

Co-authored-by: rjl493456442 <[email protected]>
core, eth, les, trie: rework snap sync

Co-authored-by: rjl493456442 <[email protected]>
… ethdb, can be used independently of the chain database, reference by commit 1941c5e (axieinfinity#571)
* all: move genesis initialization to blockchain

* all: fix test
…#574)

* core: add blockchain test for failing create/destroy-case

* core,state: some refactors

* core/rawdb: refactor db inspector for extending multiple ancient store
…ieinfinity#578)

* core,eth,tests,trie: abstract node scheme, and contruct database
interface instead of keyvalue for supporting storing diff reverse data
in ancient

* stacktrie,core,eth: port the changes in stacktries, track the path prefix of nodes when commits,  use ethdb.Database for constructing trie.Database, it's not necessary right now, but it's required for path-based used to open reverse diff freezer

* core,trie: add scheme and resolvepath logic
* trie: track deleted nodes

* core: track deleted nodes
* all: prep for path-based trie storage

* all: use rawdb.HasLegacyNode() to check for node existance instead of check for length
* trie: implement NodeBlob API for trie iterator

This functionality is needed in new path-based storage scheme, but
can be implemented in a seperate PR though.

When an account is deleted, then all the storage slots should be
nuked out from the disk as well. In hash-based storage scheme they
are still left in the disk but in new scheme, they will be iterated
and marked as deleted.

But why the NodeBlob API is needed in this scenario? Because when
the node is marked deleted, the previous value is also required to
be recorded to construct the reverse diff.

* fuzzers/stacktrie: enable test

---------

Co-authored-by: Gary Rong <[email protected]>
* trie: refactor tracer

* fix: add description
* trie: add wrapper for database

* trie: refactor trie node

* all: fix test

* rawdb, trie: fix comment

trie: change name WithPrev => NodeWithPrev
rawdb: add schema_test
* trie: triestate/Set to track changes

* core/state: track state changes

journal.go: in resetObjectChange
- add account in resetObjectChange (ref ethereum/go-ethereum#27339)
- add prevAccount and prevStorage (ref ethereum/go-ethereum#27376)
- add prevAccountOrigin and prevStorageOrigin to track changes
state_object.go: add origin for tracking the original StateAccount before change
statedb.go:
- add accountsOrigin and storagesOrigin, same functions as above
- stateObjectsDestruct now track the previous state before destruct
- add functions for handle destructing old states

* all: apply changes to tests
* core/state: clean up: db already exist in stateObject

* core, trie: statedb also commit the block number
* all: clean up overall structure, preparing for path-based (axieinfinity#594)

* trie/triedb/pathdb: init pathdb components

* core, trie: track state change with address instead of hash

Reference: ethereum/go-ethereum@817553c

* trie: refactor

* rawdb: implement freezer resettable & state freezer  (axieinfinity#596)

* rawdb: implement freezer resettable

* rawdb: implement state freezer

* rawdb: update description

* trie: path based scheme implementing (axieinfinity#598)

* core/state: move account definition to core/types

Reference: ethereum/go-ethereum#27323

* trie: add path base utils

* triedb: implement history and adding some test utils

* trie/triedb/pathdb: implement difflayer and disklayer

* Fix some issues related to history, and add logic checking maxbyte when is zero for retrieving ancient ranges with maxbyte is zero

* trie/triedb/pathdb: implement database.go

* freezer: Add unit test and docs for support freezer reading with no limit size

* trie/triedb/pathdb: add database and difflayer tests

* triedb/pathdb: implement journal and add more comments

---------

Co-authored-by: Huy Ngo <[email protected]>

---------

Co-authored-by: Francesco4203 <[email protected]>
* trie: enable pathdb: add path config and enable tests

* core/rawdb: now also inspect the state freezer in pathdb; rename

* cmd: working on cmd ronin

* core: refactor; add pathbase config; fix tests

- all: fix and enable tests for pathbase
- blockchain: open triedb explicitly in blockchain functions and close right after use, since diskLayer inside pathdb is a skeleton
- blockchain: when writeBlockWithState, pathbase will skip the explicit garbage collector, which is only needed for hashbase
- genesis.go: nit: change check genesis state, ref ethereum/go-ethereum@08bf8a6

* tests: enable path tests

* eth: enable path scheme

- all: fix tests, enable path scheme tests
- state_accessor: split function to retrieve statedb from block to hash scheme and path scheme

* light, miner, les, ethclient: clean up tests

* trie: refactor triereader, return err when state reader won't be created in hash and path

* trie: fix failed test in iterator and sync test tie

* trie,core: improve trie reader and add checking config nil when initing
database

* trie: statedb instance is committed, then it's not usable, a new instance must be created based on new root updated database, reference by commit 6d2aeb4

* cmd,les,eth: fixed unittest and adding flag Parrallel correctly

* core, eth: fix tests

* core: refactor and fix sync_test logic

* tmp: disable pathbase for TestIsPeriodBlock, TestIsTrippEffective

---------

Co-authored-by: Huy Ngo <[email protected]>
…me object when passing parents in cosortium v1 (axieinfinity#608)

* cmd,eth: fix wrong compare logic when data dir is empty and moving checking error correctly

* docker: passing state.scheme when initing the genesis data

* rawdb: add missing freezer in collections

* v1/consortium:  create a copy to keep parents content

In snapshot function, the list parents is popped out gradually for getting its contents, so when calling apply, the parents list is empty. Simply create a copy at the beginning to fix it.
This has been fixed in consortium v2. For a full sync scenario, however, the first blocks are still processed with consortium v1, which causes our node to panic.

---------

Co-authored-by: Francesco4203 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants