Skip to content

Commit

Permalink
Expose access to progress on f3 runner (#673)
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 authored Oct 1, 2024
1 parent 70ae074 commit 9556aff
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
7 changes: 7 additions & 0 deletions f3.go
Original file line number Diff line number Diff line change
Expand Up @@ -414,3 +414,10 @@ 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) {
if st := m.state.Load(); st != nil && st.runner != nil {
instance, round, phase = st.runner.Progress()
}
return
}
18 changes: 9 additions & 9 deletions host.go
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,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 @@ -491,6 +491,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()
}

// Returns inputs to the next GPBFT instance.
// These are:
// - the supplemental data.
Expand Down Expand Up @@ -775,11 +783,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 9556aff

Please sign in to comment.