Skip to content

stop persisting rejected blocks on P-chain #1696

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

Merged
merged 10 commits into from
Jul 11, 2023

Conversation

dhrubabasu
Copy link
Contributor

@dhrubabasu dhrubabasu commented Jul 5, 2023

Why this should be merged

Works towards resolving #1623

How this works

We only call AddStatelessBlock with accepted blocks, removing future rejected blocks from being persisted to memory or disk.

Note: existing rejected blocks on disk are still there, a future PR will be made to prune them.

How this was tested

CI

@dhrubabasu dhrubabasu changed the base branch from master to dev July 5, 2023 20:13
@dhrubabasu dhrubabasu marked this pull request as ready for review July 5, 2023 21:55
@StephenButtolph StephenButtolph added this to the v1.10.5 milestone Jul 6, 2023
@@ -1486,11 +1488,11 @@ func (s *state) init(genesisBytes []byte) error {
return s.Commit()
}

func (s *state) AddStatelessBlock(block blocks.Block, status choices.Status) {
func (s *state) AddStatelessBlock(block blocks.Block) {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: should we err if the block status is not actually accepted?

Copy link
Contributor

Choose a reason for hiding this comment

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

We don't have that information here.

@StephenButtolph StephenButtolph added the vm This involves virtual machines label Jul 10, 2023
AddStatelessBlock(block blocks.Block, status choices.Status)

// Invariant: [block] is an accepted block.
AddStatelessBlock(block blocks.Block)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: should we rename this AddStatelessAcceptedBlock for clarify? Maybe it's too long of name

Copy link
Contributor

Choose a reason for hiding this comment

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

I feel like this change would be reverted when we remove status from GetStatelessBlock

@abi87
Copy link
Contributor

abi87 commented Jul 11, 2023

@dhrubabasu also nit: we cannot yet remove the status from GetStatelessBlock right? Not until we purge rejected blocks

@StephenButtolph
Copy link
Contributor

StephenButtolph commented Jul 11, 2023

@dhrubabasu also nit: we cannot yet remove the status from GetStatelessBlock right? Not until we purge rejected blocks

We could make it so that GetStatelessBlock returns database.ErrNotFound if the status isn't choices.Accepted if we wanted to remove the status from the signature.

Talked with Dhruba offline - going to leave this as part of the followup.

@StephenButtolph StephenButtolph merged commit 659eb4d into dev Jul 11, 2023
@StephenButtolph StephenButtolph deleted the p-chain-stop-persisting-rejected-blocks branch July 11, 2023 17:20
ramilexe pushed a commit to ConsiderItDone/avalanchego that referenced this pull request Jul 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
vm This involves virtual machines
Projects
No open projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants