Skip to content

Commit dd67d4a

Browse files
committed
fixes after review
1 parent 09f8049 commit dd67d4a

3 files changed

Lines changed: 15 additions & 15 deletions

File tree

consensus/spos/bls/v2/subroundEndRound.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -988,11 +988,6 @@ func (sr *subroundEndRound) remainingTime() time.Duration {
988988
// If the signature is valid, then the jobDone map corresponding to the node which sent it,
989989
// is set on true for the subround Signature
990990
func (sr *subroundEndRound) receivedSignature(_ context.Context, cnsDta *consensus.Message) bool {
991-
remainingTime := sr.remainingTime()
992-
if remainingTime <= 0 {
993-
return false
994-
}
995-
996991
node := string(cnsDta.PubKey)
997992
pkForLogs := core.GetTrimmedPk(hex.EncodeToString(cnsDta.PubKey))
998993

@@ -1021,6 +1016,11 @@ func (sr *subroundEndRound) receivedSignature(_ context.Context, cnsDta *consens
10211016
return false
10221017
}
10231018

1019+
remainingTime := sr.remainingTime()
1020+
if remainingTime <= 0 {
1021+
return false
1022+
}
1023+
10241024
index, err := sr.ConsensusGroupIndex(node)
10251025
if err != nil {
10261026
log.Debug("receivedSignature.ConsensusGroupIndex",

consensus/spos/bls/v2/subroundSignature.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -267,9 +267,9 @@ func (sr *subroundSignature) doSignatureJobForManagedKeys(ctx context.Context) b
267267
sigCtx, cancel := context.WithTimeout(ctx, timeLeft)
268268
defer cancel()
269269

270-
isTimeLeft := sr.waitForSignatures(timeLeft)
271-
if !isTimeLeft {
272-
log.Debug("doSignatureJobForManagedKeys: timeout while sending signatures")
270+
signaturesReady := sr.waitForSignatures(timeLeft)
271+
if !signaturesReady {
272+
log.Debug("doSignatureJobForManagedKeys: timeout while waiting for signatures to be created")
273273
return false
274274
}
275275

@@ -384,7 +384,7 @@ func (sr *subroundSignature) doSignatureJobForSingleKey(ctx context.Context) boo
384384
}
385385

386386
if !sr.isTimeLeft() {
387-
log.Debug("doSignatureJobForSingleKey: timeout while handling single key singature")
387+
log.Debug("doSignatureJobForSingleKey: timeout while handling single key signature")
388388
return false
389389
}
390390

consensus/spos/bls/v2/subroundSignatureCompetingBlock_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ func TestWaitIfCompetingBlock_RecordSignedNonceCalledBeforeBroadcast(t *testing.
370370
assert.True(t, recordCalled, "RecordSignedNonce should be called before broadcast")
371371
}
372372

373-
func TestWaitIfCompetingBlockForNode_NoCompetingBlockForAnyKey(t *testing.T) {
373+
func TestWaitIfCompetingBlock_NoCompetingBlockForAnyKey(t *testing.T) {
374374
t.Parallel()
375375

376376
sr := createSubroundSignatureForCompetingBlockTests(
@@ -387,7 +387,7 @@ func TestWaitIfCompetingBlockForNode_NoCompetingBlockForAnyKey(t *testing.T) {
387387
assert.False(t, result, "should return false when no key has a competing block")
388388
}
389389

390-
func TestWaitIfCompetingBlockForNode_SameHashForAllKeys(t *testing.T) {
390+
func TestWaitIfCompetingBlock_SameHashForAllKeys(t *testing.T) {
391391
t.Parallel()
392392

393393
currentHash := []byte("current_hash")
@@ -405,7 +405,7 @@ func TestWaitIfCompetingBlockForNode_SameHashForAllKeys(t *testing.T) {
405405
assert.False(t, result, "should return false when all keys signed the same hash")
406406
}
407407

408-
func TestWaitIfCompetingBlockForNode_SelfKeyHasCompetingBlock(t *testing.T) {
408+
func TestWaitIfCompetingBlock_SelfKeyHasCompetingBlock(t *testing.T) {
409409
container := consensusMocks.InitConsensusCore()
410410
container.SetRoundHandler(&testscommon.RoundHandlerMock{
411411
TimeDurationCalled: func() time.Duration {
@@ -465,7 +465,7 @@ func TestWaitIfCompetingBlockForNode_SelfKeyHasCompetingBlock(t *testing.T) {
465465
assert.GreaterOrEqual(t, elapsed, 40*time.Millisecond, "should have waited for competing block delay")
466466
}
467467

468-
func TestWaitIfCompetingBlockForNode_ManagedKeyHasCompetingBlock(t *testing.T) {
468+
func TestWaitIfCompetingBlock_ManagedKeyHasCompetingBlock(t *testing.T) {
469469
container := consensusMocks.InitConsensusCore()
470470
container.SetRoundHandler(&testscommon.RoundHandlerMock{
471471
TimeDurationCalled: func() time.Duration {
@@ -538,10 +538,10 @@ func TestWaitIfCompetingBlockForNode_ManagedKeyHasCompetingBlock(t *testing.T) {
538538
assert.GreaterOrEqual(t, elapsed, 40*time.Millisecond, "should have waited for competing block delay")
539539
}
540540

541-
func TestWaitIfCompetingBlockForNode_WaitsOnceNotPerKey(t *testing.T) {
541+
func TestWaitIfCompetingBlock_WaitsOnceNotPerKey(t *testing.T) {
542542
t.Parallel()
543543

544-
// This test verifies that waitIfCompetingBlockForNode returns after a single wait
544+
// This test verifies that waitIfCompetingBlock returns after a single wait
545545
// even when multiple keys have competing blocks - it should not wait per-key.
546546
container := consensusMocks.InitConsensusCore()
547547
container.SetRoundHandler(&testscommon.RoundHandlerMock{

0 commit comments

Comments
 (0)