Conversation
pkg/state/appender.go
Outdated
There was a problem hiding this comment.
Typo, should be "parent's block", I guess.
pkg/state/appender.go
Outdated
| finalizationVoting *proto.FinalizationVoting) error { | ||
| finalizationVoting *proto.FinalizationVoting, | ||
| currentBlockID proto.BlockID) error { | ||
| // Endorsements target the block two heights below the current one (N-2). |
There was a problem hiding this comment.
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.
pkg/state/state.go
Outdated
| func (s *stateManager) softRollback(blockID proto.BlockID) error { | ||
| var ( | ||
| finalizationHeight proto.Height | ||
| finalizationBlock proto.BlockID |
There was a problem hiding this comment.
finalizationBlock is not used, use it or remove.
pkg/state/state.go
Outdated
| bID, bErr := s.rw.newestBlockIDByHeight(h) | ||
| if bErr != nil { | ||
| return wrapErr(stateerr.RollbackError, bErr) | ||
| } | ||
| finalizationBlock = bID |
There was a problem hiding this comment.
This lines can be removed, we don't use finalized block ID for anything.
pkg/state/state_test.go
Outdated
| const ( | ||
| importHeight = 60 | ||
| rollbackToHeight = 40 | ||
| finalizedHeightSet = 10 |
pkg/state/state_test.go
Outdated
|
|
||
| afterRollback, err := manager.LastFinalizedHeight() | ||
| require.NoError(t, err) | ||
| require.Equal(t, proto.CalculateLastFinalizedHeight(rollbackToHeight), afterRollback) |
There was a problem hiding this comment.
This is strange, why after rollback the height of finalized block is 40? It should be genesis block height (1) I suppose.
There was a problem hiding this comment.
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) | ||
| } | ||
|
|
There was a problem hiding this comment.
The test on error while attempting to rollback the finalized block is required.
There was a problem hiding this comment.
Added. And added another test that the manual rollback doesn't throw an error when trying to roll back further than finalized height
No description provided.