Skip to content

Commit

Permalink
Merge pull request #6417 from filecoin-project/fix/broadcast-current-…
Browse files Browse the repository at this point in the history
…message

fix: send the last gpbft message for each new participant
  • Loading branch information
simlecode authored Oct 15, 2024
2 parents 814862a + c3c126b commit 9b27205
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
26 changes: 17 additions & 9 deletions pkg/vf3/f3.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,20 +163,28 @@ func (fff *F3) runSigningLoop(ctx context.Context) {

msgCh := fff.inner.MessagesToSign()

loop:
var mb *gpbft.MessageBuilder
alreadyParticipated := make(map[uint64]struct{})
for ctx.Err() == nil {
select {
case <-ctx.Done():
return
case mb, ok := <-msgCh:
if !ok {
continue loop
case <-fff.leaser.notifyParticipation:
if mb == nil {
continue
}
participants := fff.leaser.getParticipantsByInstance(mb.Payload.Instance)
for _, id := range participants {
if err := participateOnce(ctx, mb, id); err != nil {
log.Errorf("while participating for miner f0%d: %+v", id, err)
}
case mb = <-msgCh: // never closed
clear(alreadyParticipated)
}

participants := fff.leaser.getParticipantsByInstance(mb.Payload.Instance)
for _, id := range participants {
if _, ok := alreadyParticipated[id]; ok {
continue
} else if err := participateOnce(ctx, mb, id); err != nil {
log.Errorf("while participating for miner f0%d: %+v", id, err)
} else {
alreadyParticipated[id] = struct{}{}
}
}
}
Expand Down
7 changes: 7 additions & 0 deletions pkg/vf3/participation_lease.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ type leaser struct {
issuer peer.ID
status f3Status
maxLeasableInstances uint64
// Signals that a lease was created and/or updated.
notifyParticipation chan struct{}
}

func newParticipationLeaser(nodeID peer.ID, status f3Status, maxLeasedInstances uint64) *leaser {
Expand All @@ -30,6 +32,7 @@ func newParticipationLeaser(nodeID peer.ID, status f3Status, maxLeasedInstances
issuer: nodeID,
status: status,
maxLeasableInstances: maxLeasedInstances,
notifyParticipation: make(chan struct{}, 1),
}
}

Expand Down Expand Up @@ -98,6 +101,10 @@ func (l *leaser) participate(ticket types.F3ParticipationTicket) (types.F3Partic
return types.F3ParticipationLease{}, types.ErrF3ParticipationTicketStartBeforeExisting
}
l.leases[newLease.MinerID] = newLease
select {
case l.notifyParticipation <- struct{}{}:
default:
}
return newLease, nil
}

Expand Down

0 comments on commit 9b27205

Please sign in to comment.