Skip to content

Commit

Permalink
feat(f3): update go-f3 to 0.7.0 and adapt for changes to the API
Browse files Browse the repository at this point in the history
  • Loading branch information
Stebalien committed Oct 7, 2024
1 parent d2ea23a commit 39d12d3
Show file tree
Hide file tree
Showing 12 changed files with 32 additions and 40 deletions.
12 changes: 1 addition & 11 deletions api/api_full.go
Original file line number Diff line number Diff line change
Expand Up @@ -965,7 +965,7 @@ type FullNode interface {
// it's enabled, and an error when disabled entirely.
F3IsRunning(ctx context.Context) (bool, error) //perm:read
// F3GetProgress returns the progress of the current F3 instance in terms of instance ID, round and phase.
F3GetProgress(ctx context.Context) (F3Progress, error) //perm:read
F3GetProgress(ctx context.Context) (gpbft.Instant, error) //perm:read
}

// F3ParticipationTicket represents a ticket that authorizes a miner to
Expand All @@ -987,16 +987,6 @@ type F3ParticipationLease struct {
ValidityTerm uint64
}

// F3Progress encapsulates the current progress of the F3 instance, specifying
// the instance ID, round, and the current phase of the consensus process.
//
// See FullNode.F3GetProgress.
type F3Progress struct {
Instance uint64
Round uint64
Phase gpbft.Phase
}

// 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 api/mocks/mock_full.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions api/proxy_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions build/openrpc/full.json
Original file line number Diff line number Diff line change
Expand Up @@ -7769,25 +7769,25 @@
},
{
"name": "Filecoin.F3GetProgress",
"description": "```go\nfunc (s *FullNodeStruct) F3GetProgress(p0 context.Context) (F3Progress, error) {\n\tif s.Internal.F3GetProgress == nil {\n\t\treturn *new(F3Progress), ErrNotSupported\n\t}\n\treturn s.Internal.F3GetProgress(p0)\n}\n```",
"description": "```go\nfunc (s *FullNodeStruct) F3GetProgress(p0 context.Context) (gpbft.Instant, error) {\n\tif s.Internal.F3GetProgress == nil {\n\t\treturn *new(gpbft.Instant), ErrNotSupported\n\t}\n\treturn s.Internal.F3GetProgress(p0)\n}\n```",
"summary": "F3GetProgress returns the progress of the current F3 instance in terms of instance ID, round and phase.\n",
"paramStructure": "by-position",
"params": [],
"result": {
"name": "F3Progress",
"description": "F3Progress",
"name": "gpbft.Instant",
"description": "gpbft.Instant",
"summary": "",
"schema": {
"examples": [
{
"Instance": 42,
"ID": 42,
"Round": 42,
"Phase": 0
}
],
"additionalProperties": false,
"properties": {
"Instance": {
"ID": {
"title": "number",
"type": "number"
},
Expand Down
2 changes: 1 addition & 1 deletion chain/lf3/f3.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,6 @@ func (fff *F3) IsRunning() bool {
return fff.inner.IsRunning()
}

func (fff *F3) Progress() (instance, round uint64, phase gpbft.Phase) {
func (fff *F3) Progress() gpbft.Instant {
return fff.inner.Progress()
}
4 changes: 2 additions & 2 deletions chain/lf3/participation_lease.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func (l *leaser) getOrRenewParticipationTicket(participant uint64, previous api.
return nil, api.ErrF3ParticipationTooManyInstances
}

currentInstance, _, _ := l.progress()
currentInstance := l.progress().ID
if len(previous) != 0 {
// A previous ticket is present. To avoid overlapping lease across multiple
// instances for the same participant check its validity and only proceed to
Expand Down Expand Up @@ -76,7 +76,7 @@ func (l *leaser) getOrRenewParticipationTicket(participant uint64, previous api.
}

func (l *leaser) participate(ticket api.F3ParticipationTicket) (api.F3ParticipationLease, error) {
currentInstance, _, _ := l.progress()
currentInstance := l.progress().ID
newLease, err := l.validate(currentInstance, ticket)
if err != nil {
return api.F3ParticipationLease{}, err
Expand Down
8 changes: 6 additions & 2 deletions chain/lf3/participation_lease_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,10 @@ func TestLeaser(t *testing.T) {

type mockProgress struct{ currentInstance uint64 }

func (m *mockProgress) Progress() (uint64, uint64, gpbft.Phase) {
return m.currentInstance, 0, gpbft.INITIAL_PHASE
func (m *mockProgress) Progress() gpbft.Instant {
return gpbft.Instant{
ID: m.currentInstance,
Round: 0,
Phase: gpbft.INITIAL_PHASE,
}
}
2 changes: 1 addition & 1 deletion documentation/en/api-v1-unstable-methods.md
Original file line number Diff line number Diff line change
Expand Up @@ -2614,7 +2614,7 @@ Inputs: `null`
Response:
```json
{
"Instance": 42,
"ID": 42,
"Round": 42,
"Phase": 0
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ require (
github.com/filecoin-project/go-cbor-util v0.0.1
github.com/filecoin-project/go-commp-utils/v2 v2.1.0
github.com/filecoin-project/go-crypto v0.1.0
github.com/filecoin-project/go-f3 v0.5.0
github.com/filecoin-project/go-f3 v0.7.0
github.com/filecoin-project/go-fil-commcid v0.2.0
github.com/filecoin-project/go-hamt-ipld/v3 v3.4.0
github.com/filecoin-project/go-jsonrpc v0.6.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,8 @@ github.com/filecoin-project/go-commp-utils/v2 v2.1.0/go.mod h1:NbxJYlhxtWaNhlVCj
github.com/filecoin-project/go-crypto v0.0.0-20191218222705-effae4ea9f03/go.mod h1:+viYnvGtUTgJRdy6oaeF4MTFKAfatX071MPDPBL11EQ=
github.com/filecoin-project/go-crypto v0.1.0 h1:Pob2MphoipMbe/ksxZOMcQvmBHAd3sI/WEqcbpIsGI0=
github.com/filecoin-project/go-crypto v0.1.0/go.mod h1:K9UFXvvoyAVvB+0Le7oGlKiT9mgA5FHOJdYQXEE8IhI=
github.com/filecoin-project/go-f3 v0.5.0 h1:pRw8A9moEXSxK8v4nmR/Hs09TO2Wrz9h/Al76yt+8jI=
github.com/filecoin-project/go-f3 v0.5.0/go.mod h1:QoxuoK4aktNZD1R/unlhNbhV6TnlNTAbA/QODCnAjak=
github.com/filecoin-project/go-f3 v0.7.0 h1:JNo39SAELT5hEn+rmQZbSJQBJfmGJtp70RfyWJrIayY=
github.com/filecoin-project/go-f3 v0.7.0/go.mod h1:QoxuoK4aktNZD1R/unlhNbhV6TnlNTAbA/QODCnAjak=
github.com/filecoin-project/go-fil-commcid v0.2.0 h1:B+5UX8XGgdg/XsdUpST4pEBviKkFOw+Fvl2bLhSKGpI=
github.com/filecoin-project/go-fil-commcid v0.2.0/go.mod h1:8yigf3JDIil+/WpqR5zoKyP0jBPCOGtEqq/K1CcMy9Q=
github.com/filecoin-project/go-fil-commp-hashhash v0.2.0 h1:HYIUugzjq78YvV3vC6rL95+SfC/aSTVSnZSZiDV5pCk=
Expand Down
8 changes: 3 additions & 5 deletions node/impl/full/f3.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,9 @@ func (f3api *F3API) F3GetF3PowerTable(ctx context.Context, tsk types.TipSetKey)
return f3api.F3.GetF3PowerTable(ctx, tsk)
}

func (f3api *F3API) F3GetProgress(context.Context) (api.F3Progress, error) {
func (f3api *F3API) F3GetProgress(context.Context) (gpbft.Instant, error) {
if f3api.F3 == nil {
return api.F3Progress{}, api.ErrF3Disabled
return gpbft.Instant{}, api.ErrF3Disabled
}
var progress api.F3Progress
progress.Instance, progress.Round, progress.Phase = f3api.F3.Progress()
return progress, nil
return f3api.F3.Progress(), nil
}
6 changes: 3 additions & 3 deletions node/modules/storageminer.go
Original file line number Diff line number Diff line change
Expand Up @@ -467,11 +467,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.Instance+2 >= lease.ValidityTerm:
log.Infof("F3 progressed (%d) to within two instances of lease expiry (%d). Restarting participation.", progress.Instance, lease.ValidityTerm)
case progress.ID+2 >= lease.ValidityTerm:
log.Infof("F3 progressed (%d) to within two instances of lease expiry (%d). Restarting participation.", progress.ID, lease.ValidityTerm)
return nil
default:
remainingInstanceLease := lease.ValidityTerm - progress.Instance
remainingInstanceLease := lease.ValidityTerm - progress.ID
log.Debugf("F3 participation lease is valid for further %d instances. Recking after %s.", remainingInstanceLease, p.checkProgressInterval)
p.backOffFor(ctx, p.checkProgressInterval)
}
Expand Down

0 comments on commit 39d12d3

Please sign in to comment.