Skip to content

Commit

Permalink
Improve network versioning logic
Browse files Browse the repository at this point in the history
  • Loading branch information
arajasek committed Sep 10, 2020
1 parent 1493f7d commit b00cd87
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
8 changes: 8 additions & 0 deletions build/params_shared_funcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,11 @@ func MessagesTopic(netName dtypes.NetworkName) string { return "/fil/msgs/" + st
func DhtProtocolName(netName dtypes.NetworkName) protocol.ID {
return protocol.ID("/fil/kad/" + string(netName))
}

func UseNewestNetwork() bool {
// TODO: Put these in a container we can iterate over
if UpgradeBreezeHeight <= 0 && UpgradeSmokeHeight <= 0 {
return true
}
return false
}
3 changes: 3 additions & 0 deletions build/params_shared_vals.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ package build
import (
"math/big"

"github.com/filecoin-project/go-state-types/network"

"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/specs-actors/actors/builtin"
"github.com/filecoin-project/specs-actors/actors/builtin/miner"
Expand All @@ -20,6 +22,7 @@ const UnixfsLinksPerLevel = 1024
// Consensus / Network

const AllowableClockDriftSecs = uint64(1)
const NewestNetworkVersion = network.Version2

// Epochs
const ForkLengthThreshold = Finality
Expand Down
10 changes: 7 additions & 3 deletions chain/stmgr/stmgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -1125,13 +1125,17 @@ func (sm *StateManager) GetCirculatingSupply(ctx context.Context, height abi.Cha
}

func (sm *StateManager) GetNtwkVersion(ctx context.Context, height abi.ChainEpoch) network.Version {
if build.UpgradeBreezeHeight == 0 {
return network.Version1
if build.UseNewestNetwork() {
return build.NewestNetworkVersion
}

if height <= build.UpgradeBreezeHeight {
return network.Version0
}

return network.Version1
if height <= build.UpgradeSmokeHeight {
return network.Version1
}

return build.NewestNetworkVersion
}

0 comments on commit b00cd87

Please sign in to comment.