Skip to content

Commit a369f21

Browse files
sumitvekariyarvagg
andauthored
feat(paych): add EnablePaymentChannelManager config option (#13139)
* feat(paych): add EnablePaymentChannelManager option & disable paych by default This change introduces a new configuration option EnablePaymentChannelManager to control whether the payment channel manager is started on node startup. - Added EnablePaymentChannelManager boolean field to FullNode config struct - Set default value to false (disabled by default) since payment channels get minimal use on mainnet - Added conditional wiring in node/builder_chain.go to only start payment channel manager when config option is enabled - Updated config documentation with clear description of the option This saves resources for light nodes and most full nodes that don't use payment channel functionality, while still allowing users to enable it when needed by setting EnablePaymentChannelManager: true in their config. docs: add documentation for EnablePaymentChannelManager config option - Updated default-lotus-config.toml with proper documentation for the new EnablePaymentChannelManager option docs: update CHANGELOG.md with PR number #13139 Updated the CHANGELOG.md entry for EnablePaymentChannelManager feature with the actual PR number from the created pull request. fix: address reviewer feedback on CHANGELOG.md - Fix PR number reference from PR_NUMBER to 13139 - Remove unintended formatting changes as requested by reviewer feat(paych): fix gen-check docs: update config documentation after reordering EnablePaymentChannelManager field * feat(paych): make disabled paych work & tests pass fix(paych): add DisabledPaychAPI stub to return errors when external paych API is called fix(cfg): introduce PaymentChannels top-level config option fix(test): make integration tests work with paych disabled * feat(paych): rename duplicate PaychAPI to avoid confusion --------- Co-authored-by: Rod Vagg <[email protected]>
1 parent 61737b7 commit a369f21

File tree

11 files changed

+258
-49
lines changed

11 files changed

+258
-49
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
- default to PreCommit batching
3131
- default to ProveCommit aggregation
3232
- remove config options: AggregateCommits, AggregateAboveBaseFee, BatchPreCommitAboveBaseFee
33+
- feat(paych): add EnablePaymentChannelManager config option and disable payment channel manager by default ([filecoin-project/lotus#13139](https://github.com/filecoin-project/lotus/pull/13139))
3334

3435
# Node v1.33.0 / 2025-05-08
3536
The Lotus v1.33.0 release introduces experimental v2 APIs with F3 awareness, featuring a new TipSet selection mechanism that significantly enhances how applications interact with the Filecoin blockchain. This release candidate also adds F3-aware Ethereum APIs via the /v2 endpoint. All of the /v2 APIs implement intelligent fallback mechanisms between F3 and Expected Consensus and are exposed through the Lotus Gateway.

documentation/en/default-lotus-config.toml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,3 +395,14 @@
395395
# env var: LOTUS_FAULTREPORTER_CONSENSUSFAULTREPORTERADDRESS
396396
#ConsensusFaultReporterAddress = ""
397397

398+
399+
[PaymentChannels]
400+
# EnablePaymentChannelManager controls whether the payment channel manager is started.
401+
# Default: false (disabled) - payment channels currently have minimal use on mainnet, although
402+
# they remain a Filecoin protocol feature.
403+
# Set to true to enable payment channel functionality if needed.
404+
#
405+
# type: bool
406+
# env var: LOTUS_PAYMENTCHANNELS_ENABLEPAYMENTCHANNELMANAGER
407+
#EnablePaymentChannelManager = false
408+

itests/paych_api_test.go

Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
cbor "github.com/ipfs/go-ipld-cbor"
1010
"github.com/stretchr/testify/require"
1111

12+
"github.com/filecoin-project/go-address"
1213
"github.com/filecoin-project/go-state-types/abi"
1314
"github.com/filecoin-project/go-state-types/big"
1415
paychtypes "github.com/filecoin-project/go-state-types/builtin/v8/paych"
@@ -23,6 +24,7 @@ import (
2324
"github.com/filecoin-project/lotus/chain/events/state"
2425
"github.com/filecoin-project/lotus/chain/types"
2526
"github.com/filecoin-project/lotus/itests/kit"
27+
"github.com/filecoin-project/lotus/node/config"
2628
)
2729

2830
func TestPaymentChannelsAPI(t *testing.T) {
@@ -38,9 +40,15 @@ func TestPaymentChannelsAPI(t *testing.T) {
3840
miner kit.TestMiner
3941
)
4042

43+
enablePaychOpt := kit.WithCfgOpt(func(cfg *config.FullNode) error {
44+
cfg.PaymentChannels = config.PaymentChannelsConfig{
45+
EnablePaymentChannelManager: true,
46+
}
47+
return nil
48+
})
4149
ens := kit.NewEnsemble(t, kit.MockProofs()).
42-
FullNode(&paymentCreator).
43-
FullNode(&paymentReceiver).
50+
FullNode(&paymentCreator, enablePaychOpt).
51+
FullNode(&paymentReceiver, enablePaychOpt).
4452
Miner(&miner, &paymentCreator, kit.WithAllSubsystems()).
4553
Start().
4654
InterconnectAll()
@@ -233,3 +241,45 @@ func waitForMessage(ctx context.Context, t *testing.T, paymentCreator kit.TestFu
233241
t.Log("Confirmed", desc)
234242
return res
235243
}
244+
245+
func TestPaymentChannelsAPIDisabled(t *testing.T) {
246+
ctx := context.Background()
247+
kit.QuietMiningLogs()
248+
full, _, _ := kit.EnsembleMinimal(t, kit.MockProofs())
249+
250+
// Call APIs to confirm they are not available
251+
_, err := full.PaychGet(ctx, address.TestAddress, address.TestAddress2, abi.NewTokenAmount(0), api.PaychGetOpts{})
252+
require.ErrorContains(t, err, "payment channel manager is disabled")
253+
_, err = full.PaychFund(ctx, address.TestAddress, address.TestAddress2, abi.NewTokenAmount(0))
254+
require.ErrorContains(t, err, "payment channel manager is disabled")
255+
_, err = full.PaychAvailableFunds(ctx, address.TestAddress)
256+
require.ErrorContains(t, err, "payment channel manager is disabled")
257+
_, err = full.PaychAvailableFundsByFromTo(ctx, address.TestAddress, address.TestAddress2)
258+
require.ErrorContains(t, err, "payment channel manager is disabled")
259+
_, err = full.PaychGetWaitReady(ctx, cid.Undef)
260+
require.ErrorContains(t, err, "payment channel manager is disabled")
261+
_, err = full.PaychAllocateLane(ctx, address.TestAddress)
262+
require.ErrorContains(t, err, "payment channel manager is disabled")
263+
_, err = full.PaychNewPayment(ctx, address.TestAddress, address.TestAddress2, nil)
264+
require.ErrorContains(t, err, "payment channel manager is disabled")
265+
_, err = full.PaychList(ctx)
266+
require.ErrorContains(t, err, "payment channel manager is disabled")
267+
_, err = full.PaychStatus(ctx, address.TestAddress)
268+
require.ErrorContains(t, err, "payment channel manager is disabled")
269+
_, err = full.PaychSettle(ctx, address.TestAddress)
270+
require.ErrorContains(t, err, "payment channel manager is disabled")
271+
_, err = full.PaychCollect(ctx, address.TestAddress)
272+
require.ErrorContains(t, err, "payment channel manager is disabled")
273+
err = full.PaychVoucherCheckValid(ctx, address.TestAddress, &paychtypes.SignedVoucher{})
274+
require.ErrorContains(t, err, "payment channel manager is disabled")
275+
_, err = full.PaychVoucherCheckSpendable(ctx, address.TestAddress, &paychtypes.SignedVoucher{}, nil, nil)
276+
require.ErrorContains(t, err, "payment channel manager is disabled")
277+
_, err = full.PaychVoucherAdd(ctx, address.TestAddress, &paychtypes.SignedVoucher{}, nil, abi.NewTokenAmount(0))
278+
require.ErrorContains(t, err, "payment channel manager is disabled")
279+
_, err = full.PaychVoucherCreate(ctx, address.TestAddress, abi.NewTokenAmount(0), 0)
280+
require.ErrorContains(t, err, "payment channel manager is disabled")
281+
_, err = full.PaychVoucherList(ctx, address.TestAddress)
282+
require.ErrorContains(t, err, "payment channel manager is disabled")
283+
_, err = full.PaychVoucherSubmit(ctx, address.TestAddress, &paychtypes.SignedVoucher{}, nil, nil)
284+
require.ErrorContains(t, err, "payment channel manager is disabled")
285+
}

itests/paych_cli_test.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626
"github.com/filecoin-project/lotus/chain/types"
2727
"github.com/filecoin-project/lotus/cli/clicommands"
2828
"github.com/filecoin-project/lotus/itests/kit"
29+
"github.com/filecoin-project/lotus/node/config"
2930
)
3031

3132
// TestPaymentChannelsBasic does a basic test to exercise the payment channel CLI
@@ -430,10 +431,15 @@ func getPaychState(ctx context.Context, t *testing.T, node kit.TestFullNode, chA
430431

431432
func startPaychCreatorReceiverMiner(ctx context.Context, t *testing.T, paymentCreator *kit.TestFullNode, paymentReceiver *kit.TestFullNode, blocktime time.Duration) (address.Address, address.Address) {
432433
var miner kit.TestMiner
433-
opts := kit.ThroughRPC()
434+
enablePaychOpt := kit.WithCfgOpt(func(cfg *config.FullNode) error {
435+
cfg.PaymentChannels = config.PaymentChannelsConfig{
436+
EnablePaymentChannelManager: true,
437+
}
438+
return nil
439+
})
434440
kit.NewEnsemble(t, kit.MockProofs()).
435-
FullNode(paymentCreator, opts).
436-
FullNode(paymentReceiver, opts).
441+
FullNode(paymentCreator, kit.ThroughRPC(), enablePaychOpt).
442+
FullNode(paymentReceiver, kit.ThroughRPC(), enablePaychOpt).
437443
Miner(&miner, paymentCreator, kit.WithAllSubsystems()).
438444
Start().
439445
InterconnectAll().

node/builder_chain.go

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import (
4343
"github.com/filecoin-project/lotus/node/impl/full"
4444
"github.com/filecoin-project/lotus/node/impl/gasutils"
4545
"github.com/filecoin-project/lotus/node/impl/net"
46+
"github.com/filecoin-project/lotus/node/impl/paych"
4647
"github.com/filecoin-project/lotus/node/modules"
4748
"github.com/filecoin-project/lotus/node/modules/dtypes"
4849
"github.com/filecoin-project/lotus/node/modules/lp2p"
@@ -118,13 +119,6 @@ var ChainNode = Options(
118119
Override(new(wallet.Default), From(new(*wallet.LocalWallet))),
119120
Override(new(api.Wallet), From(new(wallet.MultiWallet))),
120121

121-
// Service: Payment channels
122-
Override(new(paychmgr.PaychAPI), From(new(modules.PaychAPI))),
123-
Override(new(*paychmgr.Store), modules.NewPaychStore),
124-
Override(new(*paychmgr.Manager), modules.NewManager),
125-
Override(HandlePaymentChannelManagerKey, modules.HandlePaychManager),
126-
Override(SettlePaymentChannelsKey, settler.SettlePaymentChannels),
127-
128122
// Markets (storage)
129123
Override(new(*market.FundManager), market.NewFundManager),
130124

@@ -361,6 +355,18 @@ func ConfigFullNode(c interface{}) Option {
361355
Override(InitChainIndexerKey, modules.InitChainIndexer(cfg.ChainIndexer)),
362356
),
363357
),
358+
359+
If(cfg.PaymentChannels.EnablePaymentChannelManager,
360+
Override(new(paychmgr.ManagerNodeAPI), From(new(modules.PaychManagerNodeAPI))),
361+
Override(new(*paychmgr.Store), modules.NewPaychStore),
362+
Override(new(*paychmgr.Manager), modules.NewManager),
363+
Override(HandlePaymentChannelManagerKey, modules.HandlePaychManager),
364+
Override(SettlePaymentChannelsKey, settler.SettlePaymentChannels),
365+
Override(new(paych.PaychAPI), From(new(paych.PaychImpl))),
366+
),
367+
If(!cfg.PaymentChannels.EnablePaymentChannelManager,
368+
Override(new(paych.PaychAPI), new(paych.DisabledPaych)),
369+
),
364370
)
365371
}
366372

node/config/def.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@ func DefaultFullNode() *FullNode {
100100
ReconcileEmptyIndex: false,
101101
MaxReconcileTipsets: 3 * builtin.EpochsInDay,
102102
},
103+
PaymentChannels: PaymentChannelsConfig{
104+
EnablePaymentChannelManager: false,
105+
},
103106
}
104107
}
105108

node/config/doc_gen.go

Lines changed: 17 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node/config/types.go

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,16 @@ type Common struct {
1818
// FullNode is a full node config
1919
type FullNode struct {
2020
Common
21-
Libp2p Libp2p
22-
Pubsub Pubsub
23-
Wallet Wallet
24-
Fees FeeConfig
25-
Chainstore Chainstore
26-
Fevm FevmConfig
27-
Events EventsConfig
28-
ChainIndexer ChainIndexerConfig
29-
FaultReporter FaultReporterConfig
21+
Libp2p Libp2p
22+
Pubsub Pubsub
23+
Wallet Wallet
24+
Fees FeeConfig
25+
Chainstore Chainstore
26+
Fevm FevmConfig
27+
Events EventsConfig
28+
ChainIndexer ChainIndexerConfig
29+
FaultReporter FaultReporterConfig
30+
PaymentChannels PaymentChannelsConfig
3031
}
3132

3233
// // Common
@@ -671,3 +672,11 @@ type FaultReporterConfig struct {
671672
// rewards. This address should have adequate funds to cover gas fees.
672673
ConsensusFaultReporterAddress string
673674
}
675+
676+
type PaymentChannelsConfig struct {
677+
// EnablePaymentChannelManager controls whether the payment channel manager is started.
678+
// Default: false (disabled) - payment channels currently have minimal use on mainnet, although
679+
// they remain a Filecoin protocol feature.
680+
// Set to true to enable payment channel functionality if needed.
681+
EnablePaymentChannelManager bool
682+
}

0 commit comments

Comments
 (0)