Skip to content

Commit

Permalink
feat:ec:f3: add env var to disable F3 (#12176)
Browse files Browse the repository at this point in the history
* F3-388: add env var to disable F3

Signed-off-by: Jakub Sztandera <[email protected]>

* F3-388: check env variable in pubsub also

Signed-off-by: Jakub Sztandera <[email protected]>

* F3-388: use DISABLE_F3=1 instead of _yes_ like in drand

Signed-off-by: Jakub Sztandera <[email protected]>

* Use IsF3Enabled() and remove the runtime stopping

Signed-off-by: Jakub Sztandera <[email protected]>

---------

Signed-off-by: Jakub Sztandera <[email protected]>
Co-authored-by: Jakub Sztandera <[email protected]>
  • Loading branch information
adlrocha and Kubuxu authored Jul 4, 2024
1 parent f8c5b73 commit 7e37ee1
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion build/params_2k.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,5 +189,5 @@ const Eip155ChainId = 31415926

var WhitelistedBlock = cid.Undef

const F3Enabled = true
const f3Enabled = true
const F3BootstrapEpoch abi.ChainEpoch = 100
2 changes: 1 addition & 1 deletion build/params_butterfly.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,5 +106,5 @@ const Eip155ChainId = 3141592

var WhitelistedBlock = cid.Undef

const F3Enabled = true
const f3Enabled = true
const F3BootstrapEpoch abi.ChainEpoch = 200
2 changes: 1 addition & 1 deletion build/params_calibnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,5 +152,5 @@ const Eip155ChainId = 314159

var WhitelistedBlock = cid.Undef

const F3Enabled = true
const f3Enabled = true
const F3BootstrapEpoch abi.ChainEpoch = UpgradeWaffleHeight + 100
2 changes: 1 addition & 1 deletion build/params_interop.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,5 +145,5 @@ const Eip155ChainId = 3141592

var WhitelistedBlock = cid.Undef

const F3Enabled = true
const f3Enabled = true
const F3BootstrapEpoch abi.ChainEpoch = 1000
2 changes: 1 addition & 1 deletion build/params_mainnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,5 +169,5 @@ const Eip155ChainId = 314
// WhitelistedBlock skips checks on message validity in this block to sidestep the zero-bls signature
var WhitelistedBlock = MustParseCid("bafy2bzaceapyg2uyzk7vueh3xccxkuwbz3nxewjyguoxvhx77malc2lzn2ybi")

const F3Enabled = false
const f3Enabled = false
const F3BootstrapEpoch abi.ChainEpoch = -1
7 changes: 7 additions & 0 deletions build/params_shared_funcs.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package build

import (
"os"

"github.com/ipfs/go-cid"
"github.com/libp2p/go-libp2p/core/protocol"

Expand Down Expand Up @@ -49,3 +51,8 @@ func MustParseCid(c string) cid.Cid {

return ret
}

func IsF3Enabled() bool {
const F3DisableEnvKey = "LOTUS_DISABLE_F3"
return f3Enabled && len(os.Getenv(F3DisableEnvKey)) == 0
}
2 changes: 1 addition & 1 deletion node/builder_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ var ChainNode = Options(
Override(HandleIncomingBlocksKey, modules.HandleIncomingBlocks),
),

If(build.F3Enabled, Override(new(*lf3.F3), lf3.New)),
If(build.IsF3Enabled(), Override(new(*lf3.F3), lf3.New)),
)

func ConfigFullNode(c interface{}) Option {
Expand Down
2 changes: 1 addition & 1 deletion node/builder_miner.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ func ConfigStorageMiner(c interface{}) Option {
Override(new(config.HarmonyDB), cfg.HarmonyDB),
Override(new(harmonydb.ITestID), harmonydb.ITestID("")),
Override(new(*ctladdr.AddressSelector), modules.AddressSelector(&cfg.Addresses)),
If(build.F3Enabled, Override(F3Participation, modules.F3Participation)),
If(build.IsF3Enabled(), Override(F3Participation, modules.F3Participation)),
)
}

Expand Down
2 changes: 1 addition & 1 deletion node/modules/lp2p/pubsub.go
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ func GossipSub(in GossipIn) (service *pubsub.PubSub, err error) {
build.IndexerIngestTopic(in.Nn),
}

if build.F3Enabled {
if build.IsF3Enabled() {
allowTopics = append(allowTopics, gpbft.NetworkName(in.Nn).PubSubTopic())
}

Expand Down

0 comments on commit 7e37ee1

Please sign in to comment.