refactor(state): common interface and adapters for trie and state#3017
refactor(state): common interface and adapters for trie and state#3017
Conversation
Codecov Report❌ Patch coverage is ❌ Your patch status has failed because the patch coverage (19.38%) is below the target coverage (60.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #3017 +/- ##
==========================================
- Coverage 76.47% 76.17% -0.31%
==========================================
Files 323 326 +3
Lines 32169 32326 +157
==========================================
+ Hits 24602 24623 +21
- Misses 5803 5929 +126
- Partials 1764 1774 +10 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
rodrodros
left a comment
There was a problem hiding this comment.
It looks good overall!
I think some other changes might be required, perhaps in a different PR, but I think all the current code should be prefixed with Deprecated. For example, Trie should be now DeprecatedTrie and State should be DeprecatedState.
Their package names should be updated as well. It will be clear for all of us programming in the node that we are using deprecated structures
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> Signed-off-by: MaksymMalicki <81577596+MaksymMalicki@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> Signed-off-by: MaksymMalicki <81577596+MaksymMalicki@users.noreply.github.com>
Signed-off-by: MaksymMalicki <81577596+MaksymMalicki@users.noreply.github.com>
Signed-off-by: MaksymMalicki <81577596+MaksymMalicki@users.noreply.github.com>
This PR introduces common state and trie interfaces. Shared methods previously used outside the
trie/trie2packages, the newstatepackage and the old state related.gofiles have been abstracted into thecommontrieandcommonstatepackages. Adapters have been implemented for the respective structs. The commonstate package includes a StateFactory struct, which is responsible for generating the appropriate version of the state. The new interfaces are calledcommonstate.State,commonstate.StateReader(used only for read purposes) andcommontrie.Trie.This PR also adds a new testing utility that reads an
USE_NEW_STATEenvironment variable (set from the Makefile) to determine whether unit tests should run with the old or new state. The utility is located in thestate_test_utilspackage. It will be used in the following PR, where thecommonstateandcommontriepackages are integrated into the project.Lastly, this PR introduces an experimental boolean CLI flag
--new-state, which specifies whether the node should run using the old or new state/trie packages.All the new packages have been put in the
statepackage, so that they are easy to spot and remove in the future, once the integration is finished.Breaking changes:
Next PR to review: #3277