From 94940d95a9e383b557d3d9eca2ac05ae09d50bf5 Mon Sep 17 00:00:00 2001 From: "Masih H. Derkani" Date: Sun, 11 May 2025 12:04:08 -0400 Subject: [PATCH 1/6] Disable F3 participation via gateway 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. --- cli/lotus/daemon.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/cli/lotus/daemon.go b/cli/lotus/daemon.go index bc0bab33d2d..2ab7b975cc8 100644 --- a/cli/lotus/daemon.go +++ b/cli/lotus/daemon.go @@ -16,6 +16,8 @@ import ( "strings" "github.com/cheggaaa/pb/v3" + "github.com/filecoin-project/go-f3/manifest" + "github.com/filecoin-project/lotus/chain/lf3" metricsprom "github.com/ipfs/go-metrics-prometheus" "github.com/klauspost/compress/zstd" "github.com/mitchellh/go-homedir" @@ -393,7 +395,13 @@ var DaemonCmd = &cli.Command{ } liteModeDeps = node.Options( node.Override(new(lapi.Gateway), gapiv1), - node.Override(new(v2api.Gateway), gapiv2)) + node.Override(new(v2api.Gateway), gapiv2), + + // Disable attempts of F3 participation via gateway. + node.Unset(new(*lf3.Config)), + node.Unset(new(manifest.ManifestProvider)), + node.Unset(new(lf3.F3Backend)), + ) } // some libraries like ipfs/go-ds-measure and ipfs/go-ipfs-blockstore From 07b3608a66b389058858a89db8886c732f111a3b Mon Sep 17 00:00:00 2001 From: "Masih H. Derkani" Date: Sun, 11 May 2025 12:12:36 -0400 Subject: [PATCH 2/6] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8bef4d3b8f4..81a0bbe4673 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 From 4de1364efc4bec9f8275dcab6ca62342acd6be55 Mon Sep 17 00:00:00 2001 From: "Masih H. Derkani" Date: Sun, 11 May 2025 12:15:33 -0400 Subject: [PATCH 3/6] `make gen` --- cli/lotus/daemon.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cli/lotus/daemon.go b/cli/lotus/daemon.go index 2ab7b975cc8..8f12517c353 100644 --- a/cli/lotus/daemon.go +++ b/cli/lotus/daemon.go @@ -16,8 +16,6 @@ import ( "strings" "github.com/cheggaaa/pb/v3" - "github.com/filecoin-project/go-f3/manifest" - "github.com/filecoin-project/lotus/chain/lf3" metricsprom "github.com/ipfs/go-metrics-prometheus" "github.com/klauspost/compress/zstd" "github.com/mitchellh/go-homedir" @@ -29,6 +27,7 @@ import ( "go.opencensus.io/tag" "golang.org/x/xerrors" + "github.com/filecoin-project/go-f3/manifest" "github.com/filecoin-project/go-jsonrpc" "github.com/filecoin-project/go-paramfetch" @@ -41,6 +40,7 @@ import ( "github.com/filecoin-project/lotus/chain/consensus" "github.com/filecoin-project/lotus/chain/consensus/filcns" "github.com/filecoin-project/lotus/chain/index" + "github.com/filecoin-project/lotus/chain/lf3" proofsffi "github.com/filecoin-project/lotus/chain/proofs/ffi" "github.com/filecoin-project/lotus/chain/stmgr" "github.com/filecoin-project/lotus/chain/store" From 874d682cfa0da8922cefbb6f54c6b033db01e293 Mon Sep 17 00:00:00 2001 From: "Masih H. Derkani" Date: Sun, 11 May 2025 16:01:09 -0400 Subject: [PATCH 4/6] Move DI to builder_chain.go --- cli/lotus/daemon.go | 10 +--------- node/builder_chain.go | 5 +++-- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/cli/lotus/daemon.go b/cli/lotus/daemon.go index 8f12517c353..bc0bab33d2d 100644 --- a/cli/lotus/daemon.go +++ b/cli/lotus/daemon.go @@ -27,7 +27,6 @@ import ( "go.opencensus.io/tag" "golang.org/x/xerrors" - "github.com/filecoin-project/go-f3/manifest" "github.com/filecoin-project/go-jsonrpc" "github.com/filecoin-project/go-paramfetch" @@ -40,7 +39,6 @@ import ( "github.com/filecoin-project/lotus/chain/consensus" "github.com/filecoin-project/lotus/chain/consensus/filcns" "github.com/filecoin-project/lotus/chain/index" - "github.com/filecoin-project/lotus/chain/lf3" proofsffi "github.com/filecoin-project/lotus/chain/proofs/ffi" "github.com/filecoin-project/lotus/chain/stmgr" "github.com/filecoin-project/lotus/chain/store" @@ -395,13 +393,7 @@ var DaemonCmd = &cli.Command{ } liteModeDeps = node.Options( node.Override(new(lapi.Gateway), gapiv1), - node.Override(new(v2api.Gateway), gapiv2), - - // Disable attempts of F3 participation via gateway. - node.Unset(new(*lf3.Config)), - node.Unset(new(manifest.ManifestProvider)), - node.Unset(new(lf3.F3Backend)), - ) + node.Override(new(v2api.Gateway), gapiv2)) } // some libraries like ipfs/go-ds-measure and ipfs/go-ipfs-blockstore diff --git a/node/builder_chain.go b/node/builder_chain.go index 8174bf63051..da3c1827c07 100644 --- a/node/builder_chain.go +++ b/node/builder_chain.go @@ -185,8 +185,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), From 5dfd901f08b31408764170ba1eb35f90c980044d Mon Sep 17 00:00:00 2001 From: "Masih H. Derkani" Date: Mon, 12 May 2025 14:53:29 -0400 Subject: [PATCH 5/6] Fix dependency injection of gateway cert APIs --- itests/kit/node_opts.go | 2 ++ node/builder_chain.go | 1 + node/impl/full/f3.go | 27 ++++++++++++++++++++------- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/itests/kit/node_opts.go b/itests/kit/node_opts.go index d2b0d984c79..12c35aaa1c0 100644 --- a/itests/kit/node_opts.go +++ b/itests/kit/node_opts.go @@ -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)), ) } diff --git a/node/builder_chain.go b/node/builder_chain.go index da3c1827c07..29be0edb293 100644 --- a/node/builder_chain.go +++ b/node/builder_chain.go @@ -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)), diff --git a/node/impl/full/f3.go b/node/impl/full/f3.go index 64dc1bef51b..31de3c137b6 100644 --- a/node/impl/full/f3.go +++ b/node/impl/full/f3.go @@ -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) + } + if f3api.F3Certs != nil { + return f3api.F3Certs.F3GetCertificate(ctx, instance) } - return f3api.F3.GetCert(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) + } + if f3api.F3Certs != nil { + return f3api.F3Certs.F3GetLatestCertificate(ctx) } - return f3api.F3.GetLatestCert(ctx) + return nil, api.ErrF3Disabled } func (f3api *F3API) F3GetManifest(ctx context.Context) (*manifest.Manifest, error) { From dbba460aba7d21cd1ecebe3b36d2e63c7c0aad66 Mon Sep 17 00:00:00 2001 From: Rod Vagg Date: Tue, 13 May 2025 10:44:23 -0400 Subject: [PATCH 6/6] chore: stop using F3Backend directly in Eth modules (#13127) --- node/impl/eth/tipsetresolver.go | 13 ++++++++----- node/modules/eth.go | 3 +-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/node/impl/eth/tipsetresolver.go b/node/impl/eth/tipsetresolver.go index 67edfb50b4f..e911a1981cd 100644 --- a/node/impl/eth/tipsetresolver.go +++ b/node/impl/eth/tipsetresolver.go @@ -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 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} } @@ -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. diff --git a/node/modules/eth.go b/node/modules/eth.go index cfd75e9118c..c29e8f88c47 100644 --- a/node/modules/eth.go +++ b/node/modules/eth.go @@ -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 {