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

Trie recovery #5861

Merged
merged 71 commits into from
Jul 28, 2023
Merged

Trie recovery #5861

merged 71 commits into from
Jul 28, 2023

Conversation

LukaszRozmej
Copy link
Member

@LukaszRozmej LukaszRozmej commented Jun 23, 2023

Changes

If node will be missing in the trie this PR will attempt to recover it for the network.

If there are peers<=eth66 the HealingTrieStore will catch TrieNodeException and use GetNodeDataTrieNodeRecovery to connect to <=eth66 peers and recover rlp by hash with GetNodeData, then store it back in db.

If this fails, HealingStateTree and HealingStorageTree will catch MissingTrieNodeException thrown in PatriciaTree durign traversing and will try to use SnapTrieNodeRecovery to recover with GetTrieNodes.

All this happens only when BlockchainProcessor.IsMainProcessingThread is true.

Limitations:

  1. Can recover only when data is available on the network. For GetNodeData it might be longer, but for GetTrieNodes there is hard limit of 128 blocks. Past that time-window recovery is not possible.
  2. Recovery with snap-sync GetTrieNodes doesn't currently verify received rlp not sure if it can be added easily.

Example logs (ignore will throw message it was for testing):
image

Types of changes

What types of changes does your code introduce?

  • Bugfix (a non-breaking change that fixes an issue)
  • New feature (a non-breaking change that adds functionality)
  • Breaking change (a change that causes existing functionality not to work as expected)
  • Optimization
  • Refactoring
  • Documentation update
  • Build-related changes
  • Other: Description

Testing

Requires testing

  • Yes
  • No

If yes, did you write tests?

  • Yes
  • No

Documentation

Requires documentation update

  • Yes
  • No

Requires explanation in Release Notes

  • Yes
  • No

Copy link
Contributor

@marcindsobczak marcindsobczak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! The only thing I would change is to not keep snap protocol enabled after syncing - IMO we should try to avoid introducing solution which will make nethermind work a bit worse in normal mode to support the feature which is great, but will be used rarely. Worth to try with P2P AddCapability, enable snap protocol only when node is corrupted and request all peers to add satellite protocol

@LukaszRozmej
Copy link
Member Author

Looks good! The only thing I would change is to not keep snap protocol enabled after syncing - IMO we should try to avoid introducing solution which will make nethermind work a bit worse in normal mode to support the feature which is great, but will be used rarely. Worth to try with P2P AddCapability, enable snap protocol only when node is corrupted and request all peers to add satellite protocol

This won't work as AddCapability is not in rlpx spec :(

@LukaszRozmej LukaszRozmej merged commit a099f0f into master Jul 28, 2023
61 checks passed
@LukaszRozmej LukaszRozmej deleted the feature/trie-recovery-snap-sync branch July 28, 2023 13:19
flcl42 added a commit that referenced this pull request Aug 14, 2023
flcl42 added a commit that referenced this pull request Aug 16, 2023
MarekM25 added a commit that referenced this pull request Aug 18, 2023
* - Added Eip4788 to ReleaseSpecs
- Added Eip4788 wiring to ChainSpecs

* - Added passing state to Precompiles
- Added Eip4788 stateful precompile

* - Adds consensus logic of Eip4788

* - Tests update

* - Minor fixes, Missing migration code

* - Test improvements

* - Test progress, Cleanup

* - More tests fixes

* - Whitespace fixes

* - Attempt fix failing JsonRpc.Tests

* - Fix whistespace check failure

* - move setup precompile 4788 to instance method
- make Instance field in Precompile static generic to match class type

* - fix some build issue

* - fixed failing tests

* - Apply changes

* - Fix failing tests

* - ws fixes

* - Introduce IBeaconBlockRootHandler

* - Removed unnecessary "null" default value

* - Fixed some naming inconsistensies

* - Fix ws problems

* - Fix default behavior of beaconBlockRootHandler argument in BlockProcessor.ctor

* - fix

* - Fix ws

* small improvements

* Add EngineApiVersions

* - refactor PayloadAttributes.Validate

* - ws fix

* Init beacon root precompile state for genesis (#5982)

* - Applied suggested changes

* Fix merge

* Fix name, whitespaces

* Fix expected code

* Remove balance set

* genesis.json beacon root.

* jsonrpc: fix parentBeaconBlockRoot naming, add isEip4788.

* Catch args issue

* - ignore 0x0b from precompile checks

* Ignore for genesis

* Don't count RLP wrapper, when calc tx size for pooled txs msg

* Revert "Trie recovery (#5861)"

This reverts commit a099f0f.

* Use main EIP to detect fork

* Adding some workarounds

* Add system acc

* Another workaround

* What if zero bloc

* Another idea

* Another idea

* +

* +

* Another attempt

* 1) What

* No genesis

* 2) H

* Revert "Revert "Trie recovery (#5861)""

This reverts commit 1425d3c.

* Adhere a formal rule of encoding

* Decline payloads with v3 fields

* 2) The

* Fix 2) The

* clarification comment

* fix typo in file name

* Add RLP testing scenarios

* FIx tracer type

* - 4788 cleanup

* - Make Eip4788 settabe from chainspec

* Fix merge

* - other tests fixes

* Working on review comments

* fix build

* remove BeaconBlock from precompile list

* - moved ParentBeaconBlockRoot type from byte[] to Keccak
- removed commented precompile line from VirtualMachine

* - fixed some tests
- removed deprectated tests

* - more cleanup

* - adjusted expected size in blob tx size tests

* - ws fix

* Default addr

* more cosmetic stuff

* Remove worldState parameter

* Revert "more cosmetic stuff"

This reverts commit 872bce8.

---------

Co-authored-by: Demuirgos <ayman.bouchareb@outlook.fr>
Co-authored-by: lukasz.rozmej <lukasz.rozmej@gmail.com>
Co-authored-by: Alexey <me@flcl.me>
Co-authored-by: spencer-tb <spencer@spencertaylorbrown.uk>
Co-authored-by: smartprogrammer <smartprogrammer@windowslive.com>
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.

None yet

5 participants