Skip to content
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
13 changes: 8 additions & 5 deletions node/impl/eth/tipsetresolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,31 @@ import (
"github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/build/buildconstants"
"github.com/filecoin-project/lotus/chain/actors/policy"
"github.com/filecoin-project/lotus/chain/lf3"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/chain/types/ethtypes"
)

var _ TipSetResolver = (*tipSetResolver)(nil)

type F3CertificateProvider interface {
F3GetLatestCertificate(ctx context.Context) (*certs.FinalityCertificate, error)
}

type tipSetResolver struct {
cs ChainStore
f3 lf3.F3Backend // can be nil if disabled
useF3ForFinality bool // if true, attempt to use F3 to determine "finalized" tipset
f3 F3CertificateProvider // can be nil if disabled
useF3ForFinality bool // if true, attempt to use F3 to determine "finalized" tipset
}

func NewTipSetResolver(cs ChainStore, f3 lf3.F3Backend, useF3ForFinality bool) TipSetResolver {
func NewTipSetResolver(cs ChainStore, f3 F3CertificateProvider, useF3ForFinality bool) TipSetResolver {
return &tipSetResolver{cs: cs, f3: f3, useF3ForFinality: useF3ForFinality}
}

func (tsr *tipSetResolver) getLatestF3Cert(ctx context.Context) (*certs.FinalityCertificate, error) {
if tsr.f3 == nil {
return nil, nil
}
cert, err := tsr.f3.GetLatestCert(ctx)
cert, err := tsr.f3.F3GetLatestCertificate(ctx)
if err != nil {
if errors.Is(err, f3.ErrF3NotRunning) || errors.Is(err, api.ErrF3NotReady) {
// Only fall back to EC finality if F3 isn't running or not ready.
Expand Down
3 changes: 1 addition & 2 deletions node/modules/eth.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"github.com/filecoin-project/lotus/chain/events"
"github.com/filecoin-project/lotus/chain/events/filter"
"github.com/filecoin-project/lotus/chain/index"
"github.com/filecoin-project/lotus/chain/lf3"
"github.com/filecoin-project/lotus/chain/messagepool"
"github.com/filecoin-project/lotus/chain/stmgr"
"github.com/filecoin-project/lotus/chain/store"
Expand All @@ -29,7 +28,7 @@ import (
type TipSetResolverParams struct {
fx.In
ChainStore eth.ChainStore
F3 lf3.F3Backend `optional:"true"`
F3 full.F3CertificateProvider `optional:"true"`
}

func MakeV1TipSetResolver(params TipSetResolverParams) full.EthTipSetResolverV2 {
Expand Down
Loading