Skip to content

chore(node): Node no longer uses a singleton to create an rpc.Environment#4639

Merged
alesforz merged 2 commits intomainfrom
alesforz/remove-sync-once
Dec 10, 2024
Merged

chore(node): Node no longer uses a singleton to create an rpc.Environment#4639
alesforz merged 2 commits intomainfrom
alesforz/remove-sync-once

Conversation

@alesforz
Copy link
Collaborator

@alesforz alesforz commented Dec 10, 2024

Context

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.

This Change

This PR removes the sync.Once construct that we put in place.

Additional Note

The change also ensures that TestProvider in the light/provider/http package behaves as expected. In main, this test passes because it's set up using a MemDB, which is a dummy in-memory store rather than a real database. Thus, database Get operations always succeed.

However, in the context of the work to remove cometbft-db, we now use a "real" database, i.e., one that a Node closes when it shuts down. Since the Environment object was treated as a singleton, each iteration of TestProvider created a new Node using the same underlying database. This database would be closed at the end of the first iteration when that iteration's Node shut down. Subsequent iterations then attempted to call Get on a closed database, causing a panic.

This change fixes that issue.


PR checklist

  • Tests written/updated
  • Changelog entry added in .changelog (we use unclog to manage our changelog)
  • [ ] Updated relevant documentation (docs/ or spec/) and code comments

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.
@alesforz alesforz added storage P:tech-debt Priority: Technical debt that needs to be paid off to enable us to move faster, reliably labels Dec 10, 2024
@alesforz alesforz self-assigned this Dec 10, 2024
@alesforz alesforz changed the title Chore(node): Node no longer uses a singleton to create an rpc.Environment chore(node): Node no longer uses a singleton to create an rpc.Environment Dec 10, 2024
@alesforz alesforz marked this pull request as ready for review December 10, 2024 10:41
@alesforz alesforz requested a review from a team as a code owner December 10, 2024 10:41
@alesforz alesforz requested a review from a team December 10, 2024 10:41
Copy link
Collaborator

@melekes melekes left a comment

Choose a reason for hiding this comment

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

👍

@alesforz alesforz added this pull request to the merge queue Dec 10, 2024
Merged via the queue into main with commit be17b70 Dec 10, 2024
@alesforz alesforz deleted the alesforz/remove-sync-once branch December 10, 2024 12:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P:tech-debt Priority: Technical debt that needs to be paid off to enable us to move faster, reliably storage

Projects

No open projects
Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants