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

fix: save and load transition state for block processing #324

Merged
merged 12 commits into from
Dec 8, 2023

Conversation

gballet
Copy link
Owner

@gballet gballet commented Dec 7, 2023

This is a problem that only appears with multiple block producers: when loading the chain, the current conversion state wasn't loaded before calling Process. As a result, it would fail when trying to create a block on top of that synced block, and that would cause the block production to fail.

This would in turn trigger the issue that you can not join the network after it's verged, as it would try to reorg to build on top of the block that the node that produced the verge block produced on top of this one (being the only machine left on the network at this point). This will be fixed in another PR.

Another issue came from the fact that the saved address pointer would still be used afterwards, thus updating it when the block was being re-executed multiple times. This would cause any following client to find a different root, because the stride of the iterator would be the original one, while it would be the last produced payload in the block producer.

core/state/database.go Outdated Show resolved Hide resolved
core/state/database.go Outdated Show resolved Hide resolved
core/state/database.go Outdated Show resolved Hide resolved
consensus/beacon/consensus.go Outdated Show resolved Hide resolved
core/blockchain.go Outdated Show resolved Hide resolved
core/state/database.go Outdated Show resolved Hide resolved
core/state/database.go Outdated Show resolved Hide resolved
core/state/database.go Outdated Show resolved Hide resolved
core/state/database.go Outdated Show resolved Hide resolved
core/state/database.go Outdated Show resolved Hide resolved
core/state/database.go Outdated Show resolved Hide resolved
core/state/database.go Outdated Show resolved Hide resolved
core/state/database.go Outdated Show resolved Hide resolved
core/state/statedb.go Outdated Show resolved Hide resolved
@gballet gballet merged commit 1e2d2ad into transition-post-genesis Dec 8, 2023
gballet added a commit that referenced this pull request Feb 8, 2024
* fix: save and load transition state for block processing

* log whether the tree is verkle in LoadTransitionState

* fix: ensure the transition is marked as started in insertChain

* dump saved address

* fix nil pointer panic

* remove stacktrace that is no longer useful

* fix a panic

* fix build

* check: copy current account address BEFORE it's saved

* mandatory panic fix

* Remove debug fmt.Println

* more cleanup + comments
gballet added a commit that referenced this pull request Feb 28, 2024
* fix: save and load transition state for block processing

* log whether the tree is verkle in LoadTransitionState

* fix: ensure the transition is marked as started in insertChain

* dump saved address

* fix nil pointer panic

* remove stacktrace that is no longer useful

* fix a panic

* fix build

* check: copy current account address BEFORE it's saved

* mandatory panic fix

* Remove debug fmt.Println

* more cleanup + comments
gballet added a commit that referenced this pull request Mar 26, 2024
* fix: save and load transition state for block processing

* log whether the tree is verkle in LoadTransitionState

* fix: ensure the transition is marked as started in insertChain

* dump saved address

* fix nil pointer panic

* remove stacktrace that is no longer useful

* fix a panic

* fix build

* check: copy current account address BEFORE it's saved

* mandatory panic fix

* Remove debug fmt.Println

* more cleanup + comments
gballet added a commit that referenced this pull request Apr 15, 2024
* fix: save and load transition state for block processing

* log whether the tree is verkle in LoadTransitionState

* fix: ensure the transition is marked as started in insertChain

* dump saved address

* fix nil pointer panic

* remove stacktrace that is no longer useful

* fix a panic

* fix build

* check: copy current account address BEFORE it's saved

* mandatory panic fix

* Remove debug fmt.Println

* more cleanup + comments
gballet added a commit that referenced this pull request Apr 29, 2024
quell linter issue

support Transition post tree in conversion

Refactor transition post genesis (#311)

* rewrite per-block conversion pointer management

* remove unused method

* fix: a branch that can verge at genesis or post genesis (#314)

* fix: import cycle in conversion refactor (#315)

* fix shadowfork panic in OpenStorageTrie

fix OpenStorageTrie: return an error instead of panicking if the account tree not a verkle tree (#321)

add a switch to force proof in blocks (#322)

* add a switch to force proof in blocks

* activate switch

* fix switch type

add switch to override the stride of the overlay conversion (#323)

* add switch to override the stride of the overlay conversion

* set a default stride of 10k

add a few traces for relaunch

add missing step in the chain of setting the override for overlay stride

fix: save and load transition state for block processing (#324)

* fix: save and load transition state for block processing

* log whether the tree is verkle in LoadTransitionState

* fix: ensure the transition is marked as started in insertChain

* dump saved address

* fix nil pointer panic

* remove stacktrace that is no longer useful

* fix a panic

* fix build

* check: copy current account address BEFORE it's saved

* mandatory panic fix

* Remove debug fmt.Println

* more cleanup + comments

fix: ensure StorageProcessed is properly recovered

add traces for gas pool overflow

cmd/{geth, utils}: add a command to clear verkle costs (#326)

* cmd/{geth, utils}: add a command to clear verkle costs

fix:  boolean issue

fix: load finalization state in FinalizeAndAssemble (#340)

* Conversion and TransitionTrie fixes (#346)

* fixes

Signed-off-by: Ignacio Hagopian <[email protected]>

* remove old comment

Signed-off-by: Ignacio Hagopian <[email protected]>

---------

Signed-off-by: Ignacio Hagopian <[email protected]>

* trace cleanup

---------

Signed-off-by: Ignacio Hagopian <[email protected]>
Co-authored-by: Ignacio Hagopian <[email protected]>

fix: check for nil override in NewBlockChain (#357)

fix rebase issue

fix a few rebase issues

add debug traces

fix: assume that having to create a new transaction state mean it hasn't happened.

This is a workaround, because it will always be false when restarting a node
that has started the transition but not necessarily completed it.

add logs to debug shadowfork

persist conversion state to db and use an LRU cache for active transition states (#375)

* persist conversion state to db

* fix: don't recreate LRU when writing state

* opt: only write state to db if not already present in LRU

* fix: rlp can't encode TransitionState

* fix: use gob because binary.Write does not support structs 🤦‍♂️

* fix: nil pointer panic

* add logs to debug shadowfork

* no such thing as not enough traces

* ditto

* fix stupid bug

* add a comment for readability

* add more traces

* Lock the state transition during conversion (#384)

* heavy handed approach: lock the state transition during conversion

* also lock transition state loading/unloading

* reduce logs verbosity

* add conversion test to workflow (#386)

* add conversion test to workflow

* mandatory -f switch fix in rm

* forgot & at the end of the geth command

* remove incorrect kill

* add debug traces

* add an overlay stride

* fix typo

* Apply suggestions from code review

eth: add debug_conversionStatus RPC call (#392)

* eth: add debug_conversionStatus RPC call

* add debug trace4s

* Apply suggestions from code review

* export started/ended fields

fix post-verge sync (#404)

* fix post-verge sync

* review: fix truncated comment
gballet added a commit that referenced this pull request Apr 29, 2024
quell linter issue

support Transition post tree in conversion

Refactor transition post genesis (#311)

* rewrite per-block conversion pointer management

* remove unused method

* fix: a branch that can verge at genesis or post genesis (#314)

* fix: import cycle in conversion refactor (#315)

* fix shadowfork panic in OpenStorageTrie

fix OpenStorageTrie: return an error instead of panicking if the account tree not a verkle tree (#321)

add a switch to force proof in blocks (#322)

* add a switch to force proof in blocks

* activate switch

* fix switch type

add switch to override the stride of the overlay conversion (#323)

* add switch to override the stride of the overlay conversion

* set a default stride of 10k

add a few traces for relaunch

add missing step in the chain of setting the override for overlay stride

fix: save and load transition state for block processing (#324)

* fix: save and load transition state for block processing

* log whether the tree is verkle in LoadTransitionState

* fix: ensure the transition is marked as started in insertChain

* dump saved address

* fix nil pointer panic

* remove stacktrace that is no longer useful

* fix a panic

* fix build

* check: copy current account address BEFORE it's saved

* mandatory panic fix

* Remove debug fmt.Println

* more cleanup + comments

fix: ensure StorageProcessed is properly recovered

add traces for gas pool overflow

cmd/{geth, utils}: add a command to clear verkle costs (#326)

* cmd/{geth, utils}: add a command to clear verkle costs

fix:  boolean issue

fix: load finalization state in FinalizeAndAssemble (#340)

* Conversion and TransitionTrie fixes (#346)

* fixes

Signed-off-by: Ignacio Hagopian <[email protected]>

* remove old comment

Signed-off-by: Ignacio Hagopian <[email protected]>

---------

Signed-off-by: Ignacio Hagopian <[email protected]>

* trace cleanup

---------

Signed-off-by: Ignacio Hagopian <[email protected]>
Co-authored-by: Ignacio Hagopian <[email protected]>

fix: check for nil override in NewBlockChain (#357)

fix rebase issue

fix a few rebase issues

add debug traces

fix: assume that having to create a new transaction state mean it hasn't happened.

This is a workaround, because it will always be false when restarting a node
that has started the transition but not necessarily completed it.

add logs to debug shadowfork

persist conversion state to db and use an LRU cache for active transition states (#375)

* persist conversion state to db

* fix: don't recreate LRU when writing state

* opt: only write state to db if not already present in LRU

* fix: rlp can't encode TransitionState

* fix: use gob because binary.Write does not support structs 🤦‍♂️

* fix: nil pointer panic

* add logs to debug shadowfork

* no such thing as not enough traces

* ditto

* fix stupid bug

* add a comment for readability

* add more traces

* Lock the state transition during conversion (#384)

* heavy handed approach: lock the state transition during conversion

* also lock transition state loading/unloading

* reduce logs verbosity

* add conversion test to workflow (#386)

* add conversion test to workflow

* mandatory -f switch fix in rm

* forgot & at the end of the geth command

* remove incorrect kill

* add debug traces

* add an overlay stride

* fix typo

* Apply suggestions from code review

eth: add debug_conversionStatus RPC call (#392)

* eth: add debug_conversionStatus RPC call

* add debug trace4s

* Apply suggestions from code review

* export started/ended fields

fix post-verge sync (#404)

* fix post-verge sync

* review: fix truncated comment
@gballet gballet mentioned this pull request Apr 29, 2024
gballet added a commit that referenced this pull request May 2, 2024
quell linter issue

support Transition post tree in conversion

Refactor transition post genesis (#311)

* rewrite per-block conversion pointer management

* remove unused method

* fix: a branch that can verge at genesis or post genesis (#314)

* fix: import cycle in conversion refactor (#315)

* fix shadowfork panic in OpenStorageTrie

fix OpenStorageTrie: return an error instead of panicking if the account tree not a verkle tree (#321)

add a switch to force proof in blocks (#322)

* add a switch to force proof in blocks

* activate switch

* fix switch type

add switch to override the stride of the overlay conversion (#323)

* add switch to override the stride of the overlay conversion

* set a default stride of 10k

add a few traces for relaunch

add missing step in the chain of setting the override for overlay stride

fix: save and load transition state for block processing (#324)

* fix: save and load transition state for block processing

* log whether the tree is verkle in LoadTransitionState

* fix: ensure the transition is marked as started in insertChain

* dump saved address

* fix nil pointer panic

* remove stacktrace that is no longer useful

* fix a panic

* fix build

* check: copy current account address BEFORE it's saved

* mandatory panic fix

* Remove debug fmt.Println

* more cleanup + comments

fix: ensure StorageProcessed is properly recovered

add traces for gas pool overflow

cmd/{geth, utils}: add a command to clear verkle costs (#326)

* cmd/{geth, utils}: add a command to clear verkle costs

fix:  boolean issue

fix: load finalization state in FinalizeAndAssemble (#340)

* Conversion and TransitionTrie fixes (#346)

* fixes

Signed-off-by: Ignacio Hagopian <[email protected]>

* remove old comment

Signed-off-by: Ignacio Hagopian <[email protected]>

---------

Signed-off-by: Ignacio Hagopian <[email protected]>

* trace cleanup

---------

Signed-off-by: Ignacio Hagopian <[email protected]>
Co-authored-by: Ignacio Hagopian <[email protected]>

fix: check for nil override in NewBlockChain (#357)

fix rebase issue

fix a few rebase issues

add debug traces

fix: assume that having to create a new transaction state mean it hasn't happened.

This is a workaround, because it will always be false when restarting a node
that has started the transition but not necessarily completed it.

add logs to debug shadowfork

persist conversion state to db and use an LRU cache for active transition states (#375)

* persist conversion state to db

* fix: don't recreate LRU when writing state

* opt: only write state to db if not already present in LRU

* fix: rlp can't encode TransitionState

* fix: use gob because binary.Write does not support structs 🤦‍♂️

* fix: nil pointer panic

* add logs to debug shadowfork

* no such thing as not enough traces

* ditto

* fix stupid bug

* add a comment for readability

* add more traces

* Lock the state transition during conversion (#384)

* heavy handed approach: lock the state transition during conversion

* also lock transition state loading/unloading

* reduce logs verbosity

* add conversion test to workflow (#386)

* add conversion test to workflow

* mandatory -f switch fix in rm

* forgot & at the end of the geth command

* remove incorrect kill

* add debug traces

* add an overlay stride

* fix typo

* Apply suggestions from code review

eth: add debug_conversionStatus RPC call (#392)

* eth: add debug_conversionStatus RPC call

* add debug trace4s

* Apply suggestions from code review

* export started/ended fields

fix post-verge sync (#404)

* fix post-verge sync

* review: fix truncated comment
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.

1 participant