Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(f3): log the correct number of instances remaining #12578

Merged
merged 1 commit into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading