Skip to content

Commit

Permalink
PR and UT fix
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverbundalo committed May 29, 2024
1 parent 3805340 commit 8dd9db7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 15 deletions.
18 changes: 4 additions & 14 deletions consensus/polybft/state_sync_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,24 +159,14 @@ func (s *stateSyncManager) saveVote(msg *TransportMessage) error {
valSet := s.validatorSet
s.lock.RUnlock()

if valSet == nil || msg.EpochNumber < epoch || msg.EpochNumber > epoch+1{
return nil
}

if msg.EpochNumber == epoch+1 {
if err := s.state.EpochStore.insertEpoch(epoch+1, nil); err != nil {
return fmt.Errorf("error saving msg vote from a future epoch: %d. Error: %w", epoch+1, err)
}
}
if valSet == nil || msg.EpochNumber < epoch || msg.EpochNumber > epoch+1 {
// Epoch metadata is undefined or received a message for the irrelevant epoch
return nil
}

if msg.EpochNumber != epoch && msg.EpochNumber != epoch+1 {
// Epoch metadata is undefined or received a message for the irrelevant epoch
return nil
} else if msg.EpochNumber == epoch+1 {
if msg.EpochNumber == epoch+1 {
if err := s.state.EpochStore.insertEpoch(epoch+1, nil); err != nil {
return fmt.Errorf("error inserting epoch: %w", err)
return fmt.Errorf("error saving msg vote from a future epoch: %d. Error: %w", epoch+1, err)
}
}

Expand Down
3 changes: 2 additions & 1 deletion consensus/polybft/state_sync_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@ func TestStateSyncManager_MessagePool(t *testing.T) {
msg, err := val.sign(vals.GetValidator("0"), signer.DomainStateReceiver)
require.NoError(t, err)

msg.EpochNumber = 1
// invalid epoch +2
msg.EpochNumber = 2

require.NoError(t, s.saveVote(msg))

Expand Down

0 comments on commit 8dd9db7

Please sign in to comment.