Skip to content

Commit

Permalink
Expose access to progress on f3 runner
Browse files Browse the repository at this point in the history
The root F3 instance holds reference to the `gpbftRunner`, not
`gpbftHost`. To allow access to current progress from Lotus, move the
`Progress` implementation to runner and expose at root `F3` type.

Part of #599
  • Loading branch information
masih committed Sep 30, 2024
1 parent 475919a commit 7ad42da
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
9 changes: 9 additions & 0 deletions f3.go
Original file line number Diff line number Diff line change
Expand Up @@ -451,3 +451,12 @@ func (m *F3) GetPowerTable(ctx context.Context, ts gpbft.TipSetKey) (gpbft.Power

return nil, fmt.Errorf("no known network manifest")
}

func (m *F3) Progress() (instance, round uint64, phase gpbft.Phase) {
m.mu.Lock()
defer m.mu.Unlock()
if m.runner != nil {
instance, round, phase = m.runner.Progress()

Check warning on line 459 in f3.go

View check run for this annotation

Codecov / codecov/patch

f3.go#L455-L459

Added lines #L455 - L459 were not covered by tests
}
return

Check warning on line 461 in f3.go

View check run for this annotation

Codecov / codecov/patch

f3.go#L461

Added line #L461 was not covered by tests
}
18 changes: 9 additions & 9 deletions host.go
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ func (h *gpbftRunner) startPubsub() (<-chan gpbft.ValidatedMessage, error) {

var (
_ gpbft.Host = (*gpbftHost)(nil)
_ gpbft.Progress = (*gpbftHost)(nil).Progress
_ gpbft.Progress = (*gpbftRunner)(nil).Progress
)

// gpbftHost is a newtype of gpbftRunner exposing APIs required by the gpbft.Participant
Expand Down Expand Up @@ -493,6 +493,14 @@ func (h *gpbftRunner) Stop(context.Context) error {
)
}

// Progress returns the latest progress of GPBFT consensus in terms of instance
// ID, round and phase.
//
// This API is safe for concurrent use.
func (h *gpbftRunner) Progress() (instance, round uint64, phase gpbft.Phase) {
return h.participant.Progress()

Check warning on line 501 in host.go

View check run for this annotation

Codecov / codecov/patch

host.go#L500-L501

Added lines #L500 - L501 were not covered by tests
}

// Returns inputs to the next GPBFT instance.
// These are:
// - the supplemental data.
Expand Down Expand Up @@ -777,11 +785,3 @@ func (h *gpbftHost) Verify(pubKey gpbft.PubKey, msg []byte, sig []byte) error {
func (h *gpbftHost) Aggregate(pubKeys []gpbft.PubKey) (gpbft.Aggregate, error) {
return h.verifier.Aggregate(pubKeys)
}

// Progress returns the latest progress of GPBFT concensus in terms of instance
// ID, round and phase.
//
// This API is safe for concurrent use.
func (h *gpbftHost) Progress() (instance, round uint64, phase gpbft.Phase) {
return h.participant.Progress()
}

0 comments on commit 7ad42da

Please sign in to comment.