This repository was archived by the owner on Nov 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Check if approval voting db is empty on startup #6219
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -378,6 +378,25 @@ impl ApprovalVotingSubsystem { | |
| } | ||
| } | ||
|
|
||
| // Checks and logs approval vote db state. It is perfectly normal to start with an | ||
| // empty approval vote DB if we changed DB type or the node will sync from scratch. | ||
| fn db_sanity_check(db: Arc<dyn Database>, config: DatabaseConfig) -> SubsystemResult<()> { | ||
| let backend = DbBackend::new(db, config); | ||
| let all_blocks = backend.load_all_blocks()?; | ||
|
|
||
| if all_blocks.is_empty() { | ||
| gum::info!(target: LOG_TARGET, "Starting with an empty approval vote DB.",); | ||
| } else { | ||
| gum::debug!( | ||
| target: LOG_TARGET, | ||
| "Starting with {} blocks in approval vote DB.", | ||
| all_blocks.len() | ||
| ); | ||
| } | ||
|
|
||
| Ok(()) | ||
| } | ||
|
|
||
| #[overseer::subsystem(ApprovalVoting, error = SubsystemError, prefix = self::overseer)] | ||
| impl<Context: Send> ApprovalVotingSubsystem { | ||
| fn start(self, ctx: Context) -> SpawnedSubsystem { | ||
|
|
@@ -732,6 +751,10 @@ async fn run<B, Context>( | |
| where | ||
| B: Backend, | ||
| { | ||
| if let Err(err) = db_sanity_check(subsystem.db, subsystem.db_config) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we bail in case we can't read from the db?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, we could so that, it also happens later if not here. |
||
| gum::warn!(target: LOG_TARGET, ?err, "Could not run approval vote DB sanity check"); | ||
| } | ||
|
|
||
| let mut state = State { | ||
| session_window: None, | ||
| keystore: subsystem.keystore, | ||
|
|
||
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.
Uh oh!
There was an error while loading. Please reload this page.