Skip to content

Commit a1c82c4

Browse files
committed
Make checkpointing chainstore optional via build constraints
1 parent 31aebd2 commit a1c82c4

9 files changed

+45
-9
lines changed

build/buildconstants/params_2k.go

+4
Original file line numberDiff line numberDiff line change
@@ -200,3 +200,7 @@ var F3Enabled = true
200200
const ManifestServerID = "12D3KooWHcNBkqXEBrsjoveQvj6zDF3vK5S9tAfqyYaQF1LGSJwG"
201201

202202
var F3BootstrapEpoch abi.ChainEpoch = 1000
203+
204+
// F3CheckpointFinalizedTipSet set whether F3 should checkpoint tipsets finalized
205+
// by F3. This flag has no effect if F3 is not enabled.
206+
const F3CheckpointFinalizedTipSet = false

build/buildconstants/params_butterfly.go

+4
Original file line numberDiff line numberDiff line change
@@ -101,3 +101,7 @@ var WhitelistedBlock = cid.Undef
101101
const F3Enabled = true
102102
const ManifestServerID = "12D3KooWJr9jy4ngtJNR7JC1xgLFra3DjEtyxskRYWvBK9TC3Yn6"
103103
const F3BootstrapEpoch abi.ChainEpoch = 1000
104+
105+
// F3CheckpointFinalizedTipSet set whether F3 should checkpoint tipsets finalized
106+
// by F3. This flag has no effect if F3 is not enabled.
107+
const F3CheckpointFinalizedTipSet = true

build/buildconstants/params_calibnet.go

+4
Original file line numberDiff line numberDiff line change
@@ -148,3 +148,7 @@ var WhitelistedBlock = cid.Undef
148148
const F3Enabled = true
149149
const ManifestServerID = "12D3KooWS9vD9uwm8u2uPyJV32QBAhKAmPYwmziAgr3Xzk2FU1Mr"
150150
const F3BootstrapEpoch abi.ChainEpoch = UpgradeWaffleHeight + 100
151+
152+
// F3CheckpointFinalizedTipSet set whether F3 should checkpoint tipsets finalized
153+
// by F3. This flag has no effect if F3 is not enabled.
154+
const F3CheckpointFinalizedTipSet = true

build/buildconstants/params_interop.go

+4
Original file line numberDiff line numberDiff line change
@@ -139,3 +139,7 @@ var WhitelistedBlock = cid.Undef
139139
const F3Enabled = true
140140
const ManifestServerID = "12D3KooWQJ2rdVnG4okDUB6yHQhAjNutGNemcM7XzqC9Eo4z9Jce"
141141
const F3BootstrapEpoch abi.ChainEpoch = 1000
142+
143+
// F3CheckpointFinalizedTipSet set whether F3 should checkpoint tipsets finalized
144+
// by F3. This flag has no effect if F3 is not enabled.
145+
const F3CheckpointFinalizedTipSet = true

build/buildconstants/params_mainnet.go

+4
Original file line numberDiff line numberDiff line change
@@ -173,3 +173,7 @@ var WhitelistedBlock = cid.MustParse("bafy2bzaceapyg2uyzk7vueh3xccxkuwbz3nxewjyg
173173
const F3Enabled = true
174174
const ManifestServerID = "12D3KooWENMwUF9YxvQxar7uBWJtZkA6amvK4xWmKXfSiHUo2Qq7"
175175
const F3BootstrapEpoch abi.ChainEpoch = -1
176+
177+
// F3CheckpointFinalizedTipSet set whether F3 should checkpoint tipsets finalized
178+
// by F3. This flag has no effect if F3 is not enabled.
179+
const F3CheckpointFinalizedTipSet = false

build/buildconstants/params_testground.go

+4
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,10 @@ var (
126126
F3Enabled = false
127127
ManifestServerID = ""
128128
F3BootstrapEpoch abi.ChainEpoch = -1
129+
130+
// F3CheckpointFinalizedTipSet set whether F3 should checkpoint tipsets finalized
131+
// by F3. This flag has no effect if F3 is not enabled.
132+
F3CheckpointFinalizedTipSet = true
129133
)
130134

131135
func init() {

chain/lf3/ec.go

+6
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ type ecWrapper struct {
3030
ChainStore *store.ChainStore
3131
Syncer *chain.Syncer
3232
StateManager *stmgr.StateManager
33+
34+
// Checkpoint sets whether to checkpoint tipsets finalized by F3 in ChainStore.
35+
Checkpoint bool
3336
}
3437

3538
type f3TipSet struct {
@@ -209,6 +212,9 @@ func (ec *ecWrapper) getPowerTableLotusTSK(ctx context.Context, tsk types.TipSet
209212
}
210213

211214
func (ec *ecWrapper) Finalize(ctx context.Context, key gpbft.TipSetKey) error {
215+
if !ec.Checkpoint {
216+
return nil // Nothing to do; checkpointing is not enabled.
217+
}
212218
tsk, err := toLotusTipSetKey(key)
213219
if err != nil {
214220
return err

chain/lf3/f3.go

+13-9
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,21 @@ type F3 struct {
3636
newLeases chan leaseRequest
3737
}
3838

39+
type F3CheckpointEnabled bool
40+
3941
type F3Params struct {
4042
fx.In
4143

42-
NetworkName dtypes.NetworkName
43-
ManifestProvider manifest.ManifestProvider
44-
PubSub *pubsub.PubSub
45-
Host host.Host
46-
ChainStore *store.ChainStore
47-
Syncer *chain.Syncer
48-
StateManager *stmgr.StateManager
49-
Datastore dtypes.MetadataDS
50-
Wallet api.Wallet
44+
NetworkName dtypes.NetworkName
45+
ManifestProvider manifest.ManifestProvider
46+
PubSub *pubsub.PubSub
47+
Host host.Host
48+
ChainStore *store.ChainStore
49+
Syncer *chain.Syncer
50+
StateManager *stmgr.StateManager
51+
Datastore dtypes.MetadataDS
52+
Wallet api.Wallet
53+
F3CheckpointEnabled F3CheckpointEnabled
5154
}
5255

5356
var log = logging.Logger("f3")
@@ -59,6 +62,7 @@ func New(mctx helpers.MetricsCtx, lc fx.Lifecycle, params F3Params) (*F3, error)
5962
ChainStore: params.ChainStore,
6063
StateManager: params.StateManager,
6164
Syncer: params.Syncer,
65+
Checkpoint: bool(params.F3CheckpointEnabled),
6266
}
6367
verif := blssig.VerifierWithKeyOnG1()
6468

node/builder_chain.go

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313

1414
"github.com/filecoin-project/lotus/api"
1515
"github.com/filecoin-project/lotus/build"
16+
"github.com/filecoin-project/lotus/build/buildconstants"
1617
"github.com/filecoin-project/lotus/chain"
1718
"github.com/filecoin-project/lotus/chain/beacon"
1819
"github.com/filecoin-project/lotus/chain/consensus"
@@ -164,6 +165,7 @@ var ChainNode = Options(
164165
),
165166

166167
If(build.IsF3Enabled(),
168+
Override(new(*lf3.F3CheckpointEnabled), buildconstants.F3CheckpointFinalizedTipSet),
167169
Override(new(manifest.ManifestProvider), lf3.NewManifestProvider),
168170
Override(new(*lf3.F3), lf3.New),
169171
),

0 commit comments

Comments
 (0)