Skip to content

Commit

Permalink
fix(f3): log the correct number of instances remaining (#12578)
Browse files Browse the repository at this point in the history
  • Loading branch information
Stebalien authored Oct 10, 2024
1 parent 0d9dcd7 commit 4586794
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
4 changes: 4 additions & 0 deletions api/api_full.go
Original file line number Diff line number Diff line change
Expand Up @@ -989,6 +989,10 @@ type F3ParticipationLease struct {
ValidityTerm uint64
}

func (l *F3ParticipationLease) ToInstance() uint64 {
return l.FromInstance + l.ValidityTerm
}

// EthSubscriber is the reverse interface to the client, called after EthSubscribe
type EthSubscriber interface {
// note: the parameter is ethtypes.EthSubscriptionResponse serialized as json object
Expand Down
4 changes: 2 additions & 2 deletions chain/lf3/participation_lease.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func (l *leaser) getParticipantsByInstance(instance uint64) []uint64 {
defer l.mutex.Unlock()
var participants []uint64
for id, lease := range l.leases {
if instance > lease.FromInstance+lease.ValidityTerm {
if instance > lease.ToInstance() {
// Lazily delete the expired leases.
delete(l.leases, id)
} else {
Expand Down Expand Up @@ -145,7 +145,7 @@ func (l *leaser) validate(currentNetwork gpbft.NetworkName, currentInstance uint
// Combine the errors to remove significance of the order by which they are
// checked outside if this function.
var err error
if currentNetwork != lease.Network || currentInstance > lease.FromInstance+lease.ValidityTerm {
if currentNetwork != lease.Network || currentInstance > lease.ToInstance() {
err = multierr.Append(err, api.ErrF3ParticipationTicketExpired)
}
if l.issuer != lease.Issuer {
Expand Down
8 changes: 4 additions & 4 deletions node/modules/storageminer.go
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ func (p *f3Participator) tryF3Participate(ctx context.Context, ticket api.F3Part
log.Infow("Successfully acquired F3 participation lease.",
"issuer", lease.Issuer,
"not-before", lease.FromInstance,
"not-after", lease.FromInstance+lease.ValidityTerm,
"not-after", lease.ToInstance(),
)
p.previousTicket = ticket
return lease, true, nil
Expand Down Expand Up @@ -505,11 +505,11 @@ func (p *f3Participator) awaitLeaseExpiry(ctx context.Context, lease api.F3Parti
}
log.Errorw("Failed to check F3 progress while awaiting lease expiry. Retrying after backoff.", "attempts", p.backoff.Attempt(), "backoff", p.backoff.Duration(), "err", err)
p.backOff(ctx)
case progress.ID+2 >= lease.FromInstance+lease.ValidityTerm:
log.Infof("F3 progressed (%d) to within two instances of lease expiry (%d+%d). Renewing participation.", progress.ID, lease.FromInstance, lease.ValidityTerm)
case progress.ID+2 >= lease.ToInstance():
log.Infof("F3 progressed (%d) to within two instances of lease expiry (%d). Renewing participation.", progress.ID, lease.ToInstance())
return nil
default:
remainingInstanceLease := lease.ValidityTerm - progress.ID
remainingInstanceLease := lease.ToInstance() - progress.ID
log.Debugf("F3 participation lease is valid for further %d instances. Re-checking after %s.", remainingInstanceLease, p.checkProgressInterval)
p.backOffFor(ctx, p.checkProgressInterval)
}
Expand Down

0 comments on commit 4586794

Please sign in to comment.