chore(node): Node no longer uses a singleton to create an rpc.Environment#4639
Merged
chore(node): Node no longer uses a singleton to create an rpc.Environment#4639
Node no longer uses a singleton to create an rpc.Environment#4639Conversation
Because `rpc.Environment` does not store a `GenesisDoc` in memory anymore, (see #1290), we don't need to create it as a singleton. The risk of storing multiple copies of the genesis in memory isn't there anymore, because we now load it from disk.
Node no longer uses a singleton to create an rpc.EnvironmentNode no longer uses a singleton to create an rpc.Environment
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
Because
rpc.Environmentdoes not store aGenesisDocin memory anymore, (see #1290), we don't need to create it as a singleton. The risk of storing multiple copies of the genesis in memory isn't there anymore, because we now load it from disk.This Change
This PR removes the
sync.Onceconstruct that we put in place.Additional Note
The change also ensures that
TestProviderin thelight/provider/httppackage behaves as expected. Inmain, this test passes because it's set up using aMemDB, which is a dummy in-memory store rather than a real database. Thus, databaseGetoperations always succeed.However, in the context of the work to remove cometbft-db, we now use a "real" database, i.e., one that a
Nodecloses when it shuts down. Since theEnvironmentobject was treated as a singleton, each iteration ofTestProvidercreated a newNodeusing the same underlying database. This database would be closed at the end of the first iteration when that iteration'sNodeshut down. Subsequent iterations then attempted to callGeton a closed database, causing a panic.This change fixes that issue.
PR checklist
.changelog(we use unclog to manage our changelog)[ ] Updated relevant documentation (docs/orspec/) and code comments