chore: disable F3 participation via gateway (#13123)

Disable F3 module when lotus is run with `--lite` commend since in that
mode the daemon is simply a reverse proxy of a full node.

Stop using F3Backend directly in Eth modules (#13127)
This commit is contained in:
Masih H. Derkani
2025-05-13 15:48:56 +01:00
committed by GitHub
parent c3b48f5e0a
commit 42626fdc4f
6 changed files with 38 additions and 18 deletions

View File

@ -22,6 +22,7 @@
- feat(f3): remove dynnamic manifest functionality and use static manifest ([filecoin-project/lotus#13074](https://github.com/filecoin-project/lotus/pull/13074))
- chore(deps): bump filecoin-ffi for fvm@v4.7 which adds Logs and IpldOps to debug FVM execution traces ([filecoin-project/lotus#13029](https://github.com/filecoin-project/lotus/pull/13029))
- chore: return `method not supported` via Gateway when /v2 isn't supported by the backend ([filecoin-project/lotus#13121](https://github.com/filecoin-project/lotus/pull/13121)
- chore: disable F3 participation via gateway ([filecoin-project/lotus#13123](https://github.com/filecoin-project/lotus/pull/13123)
See https://github.com/filecoin-project/lotus/blob/release/v1.33.0/CHANGELOG.md

View File

@ -19,6 +19,7 @@ import (
"github.com/filecoin-project/lotus/chain/wallet/key"
"github.com/filecoin-project/lotus/node"
"github.com/filecoin-project/lotus/node/config"
"github.com/filecoin-project/lotus/node/impl/full"
"github.com/filecoin-project/lotus/node/modules"
"github.com/filecoin-project/lotus/node/modules/dtypes"
"github.com/filecoin-project/lotus/node/repo"
@ -267,6 +268,7 @@ func F3Disabled() NodeOpt {
node.Unset(new(*lf3.Config)),
node.Unset(new(manifest.ManifestProvider)),
node.Unset(new(lf3.F3Backend)),
node.Unset(new(full.F3CertificateProvider)),
)
}

View File

@ -154,6 +154,7 @@ var ChainNode = Options(
Override(new(full.EthTraceAPIV2), From(new(v2api.Gateway))),
Override(new(full.EthGasAPIV1), From(new(api.Gateway))),
Override(new(full.EthGasAPIV2), From(new(v2api.Gateway))),
If(build.IsF3Enabled(), Override(new(full.F3CertificateProvider), From(new(api.Gateway)))),
// EthSendAPI is a special case, we block the Untrusted method via GatewayEthSend even though it
// shouldn't be exposed on the Gateway API.
Override(new(eth.EthSendAPI), new(modules.GatewayEthSend)),
@ -185,8 +186,9 @@ var ChainNode = Options(
Override(HandleIncomingMessagesKey, modules.HandleIncomingMessages),
Override(HandleIncomingBlocksKey, modules.HandleIncomingBlocks),
),
If(build.IsF3Enabled(),
ApplyIf(func(s *Settings) bool {
return build.IsF3Enabled() && !isLiteNode(s)
},
Override(new(*lf3.Config), lf3.NewConfig),
Override(new(manifest.ManifestProvider), lf3.NewManifestProvider),
Override(new(lf3.F3Backend), lf3.New),

View File

@ -13,20 +13,23 @@ 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 tipSetResolver struct {
cs ChainStore
f3 lf3.F3Backend // can be nil if disabled
useF3ForFinality bool // if true, attempt to use F3 to determine "finalized" tipset
type F3CertificateProvider interface {
F3GetLatestCertificate(ctx context.Context) (*certs.FinalityCertificate, error)
}
func NewTipSetResolver(cs ChainStore, f3 lf3.F3Backend, useF3ForFinality bool) TipSetResolver {
type tipSetResolver struct {
cs ChainStore
f3 F3CertificateProvider // can be nil if disabled
useF3ForFinality bool // if true, attempt to use F3 to determine "finalized" tipset
}
func NewTipSetResolver(cs ChainStore, f3 F3CertificateProvider, useF3ForFinality bool) TipSetResolver {
return &tipSetResolver{cs: cs, f3: f3, useF3ForFinality: useF3ForFinality}
}
@ -34,7 +37,7 @@ func (tsr *tipSetResolver) getLatestF3Cert(ctx context.Context) (*certs.Finality
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.

View File

@ -16,10 +16,16 @@ import (
"github.com/filecoin-project/lotus/chain/types"
)
type F3CertificateProvider interface {
F3GetCertificate(ctx context.Context, instance uint64) (*certs.FinalityCertificate, error)
F3GetLatestCertificate(ctx context.Context) (*certs.FinalityCertificate, error)
}
type F3API struct {
fx.In
F3 lf3.F3Backend `optional:"true"`
F3 lf3.F3Backend `optional:"true"`
F3Certs F3CertificateProvider `optional:"true"`
}
func (f3api *F3API) F3GetOrRenewParticipationTicket(ctx context.Context, miner address.Address, previous api.F3ParticipationTicket, instances uint64) (api.F3ParticipationTicket, error) {
@ -44,17 +50,24 @@ func (f3api *F3API) F3Participate(ctx context.Context, ticket api.F3Participatio
}
func (f3api *F3API) F3GetCertificate(ctx context.Context, instance uint64) (*certs.FinalityCertificate, error) {
if f3api.F3 == nil {
return nil, api.ErrF3Disabled
if f3api.F3 != nil {
return f3api.F3.GetCert(ctx, instance)
}
return f3api.F3.GetCert(ctx, instance)
if f3api.F3Certs != nil {
return f3api.F3Certs.F3GetCertificate(ctx, instance)
}
return nil, api.ErrF3Disabled
}
func (f3api *F3API) F3GetLatestCertificate(ctx context.Context) (*certs.FinalityCertificate, error) {
if f3api.F3 == nil {
return nil, api.ErrF3Disabled
if f3api.F3 != nil {
return f3api.F3.GetLatestCert(ctx)
}
return f3api.F3.GetLatestCert(ctx)
if f3api.F3Certs != nil {
return f3api.F3Certs.F3GetLatestCertificate(ctx)
}
return nil, api.ErrF3Disabled
}
func (f3api *F3API) F3GetManifest(ctx context.Context) (*manifest.Manifest, error) {

View File

@ -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"
@ -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 {