Skip to content

Commit

Permalink
sync malfeasance proof during genesis (#4785)
Browse files Browse the repository at this point in the history
## Motivation
malfeasance proof isn't synced during genesis period.
  • Loading branch information
countvonzero committed Aug 7, 2023
1 parent 7c3ef42 commit 55282ea
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 4 additions & 6 deletions syncer/syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -450,13 +450,11 @@ func (s *Syncer) syncAtx(ctx context.Context) error {
s.logger.WithContext(ctx).With().Info("atxs synced to epoch", s.lastAtxEpoch())

// FIXME https://github.com/spacemeshos/go-spacemesh/issues/3987
if s.ticker.CurrentLayer() > types.GetEffectiveGenesis() {
s.logger.WithContext(ctx).With().Info("syncing malicious proofs")
if err := s.syncMalfeasance(ctx); err != nil {
return err
}
s.logger.WithContext(ctx).With().Info("malicious IDs synced")
s.logger.WithContext(ctx).With().Info("syncing malicious proofs")
if err := s.syncMalfeasance(ctx); err != nil {
return err
}
s.logger.WithContext(ctx).With().Info("malicious IDs synced")
s.setATXSynced()
return nil
}
Expand Down
4 changes: 3 additions & 1 deletion syncer/syncer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ func startWithSyncedState(t *testing.T, ts *testSyncer) types.LayerID {

gLayer := types.GetEffectiveGenesis()
ts.mTicker.advanceToLayer(gLayer)
ts.mDataFetcher.EXPECT().PollMaliciousProofs(gomock.Any())
ts.mDataFetcher.EXPECT().GetEpochATXs(gomock.Any(), gLayer.GetEpoch())
require.True(t, ts.syncer.synchronize(context.Background()))
require.True(t, ts.syncer.ListenToATXGossip())
Expand Down Expand Up @@ -348,6 +349,7 @@ func TestSyncAtxs_Genesis(t *testing.T) {
for epoch := types.EpochID(1); epoch <= tc.lastSynced; epoch++ {
ts.mDataFetcher.EXPECT().GetEpochATXs(gomock.Any(), epoch)
}
ts.mDataFetcher.EXPECT().PollMaliciousProofs(gomock.Any())
}
require.True(t, ts.syncer.synchronize(context.Background()))
require.True(t, ts.syncer.ListenToATXGossip())
Expand Down Expand Up @@ -388,7 +390,6 @@ func TestSyncAtxs(t *testing.T) {
for lid := lyr; lid < tc.current; lid++ {
ts.mDataFetcher.EXPECT().PollLayerData(gomock.Any(), lid)
}

require.True(t, ts.syncer.synchronize(context.Background()))
require.Equal(t, tc.lastSyncEpoch, ts.syncer.lastAtxEpoch())
})
Expand Down Expand Up @@ -648,6 +649,7 @@ func TestSynchronize_RecoverFromCheckpoint(t *testing.T) {
withForkFinder(ts.mForkFinder))
// should not sync any atxs before current epoch
ts.mDataFetcher.EXPECT().GetEpochATXs(gomock.Any(), current.GetEpoch())
ts.mDataFetcher.EXPECT().PollMaliciousProofs(gomock.Any())
require.True(t, ts.syncer.synchronize(context.Background()))
require.Equal(t, current.GetEpoch(), ts.syncer.lastAtxEpoch())
types.SetEffectiveGenesis(types.FirstEffectiveGenesis().Uint32())
Expand Down

0 comments on commit 55282ea

Please sign in to comment.