Skip to content

Commit

Permalink
chore: move IsNearUpgrade helper to buildconstants
Browse files Browse the repository at this point in the history
  • Loading branch information
ribasushi committed Jul 16, 2024
1 parent 8dd52c2 commit 1f743ef
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 16 deletions.
10 changes: 10 additions & 0 deletions build/buildconstants/shared_funcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import (
logging "github.com/ipfs/go-log/v2"

"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"

"github.com/filecoin-project/lotus/chain/actors/policy"
)

// moved from now-defunct build/paramfetch.go
Expand All @@ -21,3 +24,10 @@ func MustParseAddress(addr string) address.Address {

return ret
}

func IsNearUpgrade(epoch, upgradeEpoch abi.ChainEpoch) bool {
if upgradeEpoch < 0 {
return false
}
return epoch > upgradeEpoch-policy.ChainFinality && epoch < upgradeEpoch+policy.ChainFinality
}
12 changes: 0 additions & 12 deletions build/isnearupgrade.go

This file was deleted.

2 changes: 2 additions & 0 deletions build/parameters.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ var GenesisFile = buildconstants.GenesisFile // Deprecated: Use buildconstants.G
var NetworkBundle = buildconstants.NetworkBundle // Deprecated: Use buildconstants.NetworkBundle instead
var ActorDebugging = buildconstants.ActorDebugging // Deprecated: Use buildconstants.ActorDebugging instead

var IsNearUpgrade = buildconstants.IsNearUpgrade // Deprecated: Use buildconstants.IsNearUpgrade instead

var GenesisNetworkVersion = buildconstants.GenesisNetworkVersion // Deprecated: Use buildconstants.GenesisNetworkVersion instead

var UpgradeBreezeHeight abi.ChainEpoch = buildconstants.UpgradeBreezeHeight // Deprecated: Use buildconstants.UpgradeBreezeHeight instead
Expand Down
5 changes: 3 additions & 2 deletions chain/vm/fvm.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (

"github.com/filecoin-project/lotus/blockstore"
"github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/lotus/build/buildconstants"
"github.com/filecoin-project/lotus/chain/actors"
"github.com/filecoin-project/lotus/chain/actors/adt"
"github.com/filecoin-project/lotus/chain/actors/aerrors"
Expand Down Expand Up @@ -94,10 +95,10 @@ func (x *FvmExtern) VerifyConsensusFault(ctx context.Context, a, b, extra []byte
}

// workaround chain halt
if build.IsNearUpgrade(blockA.Height, build.UpgradeWatermelonFixHeight) {
if buildconstants.IsNearUpgrade(blockA.Height, build.UpgradeWatermelonFixHeight) {
return ret, totalGas
}
if build.IsNearUpgrade(blockB.Height, build.UpgradeWatermelonFixHeight) {
if buildconstants.IsNearUpgrade(blockB.Height, build.UpgradeWatermelonFixHeight) {
return ret, totalGas
}

Expand Down
5 changes: 3 additions & 2 deletions chain/vm/syscalls.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
proof7 "github.com/filecoin-project/specs-actors/v7/actors/runtime/proof"

"github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/lotus/build/buildconstants"
"github.com/filecoin-project/lotus/chain/actors/adt"
"github.com/filecoin-project/lotus/chain/actors/builtin/miner"
"github.com/filecoin-project/lotus/chain/actors/policy"
Expand Down Expand Up @@ -115,10 +116,10 @@ func (ss *syscallShim) VerifyConsensusFault(a, b, extra []byte) (*runtime7.Conse
}

// workaround chain halt
if build.IsNearUpgrade(blockA.Height, build.UpgradeOrangeHeight) {
if buildconstants.IsNearUpgrade(blockA.Height, build.UpgradeOrangeHeight) {
return nil, xerrors.Errorf("consensus reporting disabled around Upgrade Orange")
}
if build.IsNearUpgrade(blockB.Height, build.UpgradeOrangeHeight) {
if buildconstants.IsNearUpgrade(blockB.Height, build.UpgradeOrangeHeight) {
return nil, xerrors.Errorf("consensus reporting disabled around Upgrade Orange")
}

Expand Down

0 comments on commit 1f743ef

Please sign in to comment.