Skip to content

Auto rollback finalization#1996

Open
esuwu wants to merge 7 commits intoadd-network-messagesfrom
auto-rollback-finalization
Open

Auto rollback finalization#1996
esuwu wants to merge 7 commits intoadd-network-messagesfrom
auto-rollback-finalization

Conversation

@esuwu
Copy link
Contributor

@esuwu esuwu commented Feb 11, 2026

No description provided.

@esuwu esuwu requested a review from alexeykiselev February 11, 2026 19:48
Copy link
Collaborator

Choose a reason for hiding this comment

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

Typo, should be "parent's block", I guess.

finalizationVoting *proto.FinalizationVoting) error {
finalizationVoting *proto.FinalizationVoting,
currentBlockID proto.BlockID) error {
// Endorsements target the block two heights below the current one (N-2).
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this is not always true. I think this check should be performed somewhere outside. In this functions we have to get block height by ID and store it. That's all.

func (s *stateManager) softRollback(blockID proto.BlockID) error {
var (
finalizationHeight proto.Height
finalizationBlock proto.BlockID
Copy link
Collaborator

Choose a reason for hiding this comment

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

finalizationBlock is not used, use it or remove.

Comment on lines 2370 to 2374
bID, bErr := s.rw.newestBlockIDByHeight(h)
if bErr != nil {
return wrapErr(stateerr.RollbackError, bErr)
}
finalizationBlock = bID
Copy link
Collaborator

Choose a reason for hiding this comment

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

This lines can be removed, we don't use finalized block ID for anything.

const (
importHeight = 60
rollbackToHeight = 40
finalizedHeightSet = 10
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why "...Set"?


afterRollback, err := manager.LastFinalizedHeight()
require.NoError(t, err)
require.Equal(t, proto.CalculateLastFinalizedHeight(rollbackToHeight), afterRollback)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is strange, why after rollback the height of finalized block is 40? It should be genesis block height (1) I suppose.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's not 40, it's 1, the result of this expression proto.CalculateLastFinalizedHeight(rollbackToHeight) is 1. But I understand why this is confusing, i shoud've just put 1

require.NoError(t, err)
require.Equal(t, proto.CalculateLastFinalizedHeight(rollbackToHeight), afterRollback)
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

The test on error while attempting to rollback the finalized block is required.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added. And added another test that the manual rollback doesn't throw an error when trying to roll back further than finalized height

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants