From 22884f18f11faab09b0f8279db3fbb835b429007 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Sat, 19 Dec 2020 20:44:16 +0100 Subject: [PATCH 1/8] define v9 upgrade --- build/params_mainnet.go | 2 ++ chain/stmgr/forks.go | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/build/params_mainnet.go b/build/params_mainnet.go index db7166eec..195f0dd01 100644 --- a/build/params_mainnet.go +++ b/build/params_mainnet.go @@ -41,6 +41,8 @@ const UpgradeKumquatHeight = 170000 const UpgradeCalicoHeight = 265200 const UpgradePersianHeight = UpgradeCalicoHeight + (builtin2.EpochsInHour * 60) +const UpgradeOrangeHeight = 336458 + // 2020-12-22T02:00:00Z const UpgradeClausHeight = 343200 diff --git a/chain/stmgr/forks.go b/chain/stmgr/forks.go index 3bdf23f59..7fe12d2a8 100644 --- a/chain/stmgr/forks.go +++ b/chain/stmgr/forks.go @@ -96,6 +96,10 @@ func DefaultUpgradeSchedule() UpgradeSchedule { Height: build.UpgradePersianHeight, Network: network.Version8, Migration: nil, + }, { + Height: build.UpgradeOrangeHeight, + Network: network.Version9, + Migration: nil, }} if build.UpgradeActorsV2Height == math.MaxInt64 { // disable actors upgrade From 24dd6e01d7ececfbd6664138499b47df37dff9d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Sat, 19 Dec 2020 20:53:08 +0100 Subject: [PATCH 2/8] disable SF for finality epochs --- chain/gen/slashfilter/slashfilter.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/chain/gen/slashfilter/slashfilter.go b/chain/gen/slashfilter/slashfilter.go index ee0435156..a73f3e2f6 100644 --- a/chain/gen/slashfilter/slashfilter.go +++ b/chain/gen/slashfilter/slashfilter.go @@ -2,6 +2,7 @@ package slashfilter import ( "fmt" + "github.com/filecoin-project/lotus/build" "golang.org/x/xerrors" @@ -26,6 +27,10 @@ func New(dstore ds.Batching) *SlashFilter { } func (f *SlashFilter) MinedBlock(bh *types.BlockHeader, parentEpoch abi.ChainEpoch) error { + if bh.Height < build.UpgradeOrangeHeight+build.Finality { + return nil + } + epochKey := ds.NewKey(fmt.Sprintf("/%s/%d", bh.Miner, bh.Height)) { // double-fork mining (2 blocks at one epoch) From a3b325db5db1af0764a2dc67666dad3d1e51a099 Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Sat, 19 Dec 2020 21:00:12 +0100 Subject: [PATCH 3/8] Disable consensus faults during upgrade orange Signed-off-by: Jakub Sztandera --- chain/gen/slashfilter/slashfilter.go | 5 ++++- chain/vm/syscalls.go | 12 +++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/chain/gen/slashfilter/slashfilter.go b/chain/gen/slashfilter/slashfilter.go index a73f3e2f6..cb12ddb08 100644 --- a/chain/gen/slashfilter/slashfilter.go +++ b/chain/gen/slashfilter/slashfilter.go @@ -2,6 +2,7 @@ package slashfilter import ( "fmt" + "github.com/filecoin-project/lotus/build" "golang.org/x/xerrors" @@ -27,7 +28,9 @@ func New(dstore ds.Batching) *SlashFilter { } func (f *SlashFilter) MinedBlock(bh *types.BlockHeader, parentEpoch abi.ChainEpoch) error { - if bh.Height < build.UpgradeOrangeHeight+build.Finality { + if bh.Height > build.UpgradeOrangeHeight-build.Finality && + bh.Height < build.UpgradeOrangeHeight+build.Finality { + // consenssus faults disabled during Upgrade Orange return nil } diff --git a/chain/vm/syscalls.go b/chain/vm/syscalls.go index ba6ee2f1d..b063e5f25 100644 --- a/chain/vm/syscalls.go +++ b/chain/vm/syscalls.go @@ -17,6 +17,7 @@ import ( "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/crypto" "github.com/filecoin-project/go-state-types/network" + "github.com/filecoin-project/lotus/build" "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" @@ -107,11 +108,20 @@ func (ss *syscallShim) VerifyConsensusFault(a, b, extra []byte) (*runtime2.Conse return nil, xerrors.Errorf("cannot decode second block header: %f", decodeErr) } + // workaround chain halt + if blockA.Height > build.UpgradeOrangeHeight-build.Finality && + blockA.Height < build.UpgradeOrangeHeight+build.Finality { + return nil, xerrors.Errorf("consensus reporting disabled around Upgrade Orange") + } + if blockB.Height > build.UpgradeOrangeHeight-build.Finality && + blockB.Height < build.UpgradeOrangeHeight+build.Finality { + return nil, xerrors.Errorf("consensus reporting disabled around Upgrade Orange") + } + // are blocks the same? if blockA.Cid().Equals(blockB.Cid()) { return nil, fmt.Errorf("no consensus fault: submitted blocks are the same") } - // (1) check conditions necessary to any consensus fault // were blocks mined by same miner? From c1aafb7b71ffeb4470bf838b8f44b0867ffe1142 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Sat, 19 Dec 2020 21:29:12 +0100 Subject: [PATCH 4/8] Add missing v9 to chain/actors/version --- chain/actors/version.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chain/actors/version.go b/chain/actors/version.go index 1cafa45c9..1d9f1f8a2 100644 --- a/chain/actors/version.go +++ b/chain/actors/version.go @@ -18,7 +18,7 @@ func VersionForNetwork(version network.Version) Version { switch version { case network.Version0, network.Version1, network.Version2, network.Version3: return Version0 - case network.Version4, network.Version5, network.Version6, network.Version7, network.Version8: + case network.Version4, network.Version5, network.Version6, network.Version7, network.Version8, network.Version9: return Version2 default: panic(fmt.Sprintf("unsupported network version %d", version)) From 594737ff6c5cd346cdca968e898e829e2b336d5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Sat, 19 Dec 2020 21:34:57 +0100 Subject: [PATCH 5/8] Upgrade specs-actors --- go.mod | 2 +- go.sum | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index e6bc14a1b..f99e44de4 100644 --- a/go.mod +++ b/go.mod @@ -43,7 +43,7 @@ require ( github.com/filecoin-project/go-statestore v0.1.0 github.com/filecoin-project/go-storedcounter v0.0.0-20200421200003-1c99c62e8a5b github.com/filecoin-project/specs-actors v0.9.13 - github.com/filecoin-project/specs-actors/v2 v2.3.2 + github.com/filecoin-project/specs-actors/v2 v2.3.3 github.com/filecoin-project/specs-storage v0.1.1-0.20201105051918-5188d9774506 github.com/filecoin-project/test-vectors/schema v0.0.5 github.com/gbrlsnchs/jwt/v3 v3.0.0-beta.1 diff --git a/go.sum b/go.sum index 644904013..847f66933 100644 --- a/go.sum +++ b/go.sum @@ -296,6 +296,8 @@ github.com/filecoin-project/specs-actors v0.9.13/go.mod h1:TS1AW/7LbG+615j4NsjMK github.com/filecoin-project/specs-actors/v2 v2.0.1/go.mod h1:v2NZVYinNIKA9acEMBm5wWXxqv5+frFEbekBFemYghY= github.com/filecoin-project/specs-actors/v2 v2.3.2 h1:2Vcf4CGa29kRh4JJ02m+FbvD/p3YNnLGsaHfw7Uj49g= github.com/filecoin-project/specs-actors/v2 v2.3.2/go.mod h1:UuJQLoTx/HPvvWeqlIFmC/ywlOLHNe8SNQ3OunFbu2Y= +github.com/filecoin-project/specs-actors/v2 v2.3.3 h1:5Pd6pjU7VjUye+Hz4gYBCPAFdBxtEbHsgGYvWmfc83w= +github.com/filecoin-project/specs-actors/v2 v2.3.3/go.mod h1:UuJQLoTx/HPvvWeqlIFmC/ywlOLHNe8SNQ3OunFbu2Y= github.com/filecoin-project/specs-storage v0.1.1-0.20201105051918-5188d9774506 h1:Ur/l2+6qN+lQiqjozWWc5p9UDaAMDZKTlDS98oRnlIw= github.com/filecoin-project/specs-storage v0.1.1-0.20201105051918-5188d9774506/go.mod h1:nJRRM7Aa9XVvygr3W9k6xGF46RWzr2zxF/iGoAIfA/g= github.com/filecoin-project/test-vectors/schema v0.0.5 h1:w3zHQhzM4pYxJDl21avXjOKBLF8egrvwUwjpT8TquDg= From 420888aeaeb035d708c9dc2ca57182aff81c3362 Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Sat, 19 Dec 2020 21:35:14 +0100 Subject: [PATCH 6/8] Add UpgradeOrange to params_2k and params_testground Signed-off-by: Jakub Sztandera --- build/params_2k.go | 1 + build/params_testground.go | 1 + 2 files changed, 2 insertions(+) diff --git a/build/params_2k.go b/build/params_2k.go index 1155488b4..bcce509d7 100644 --- a/build/params_2k.go +++ b/build/params_2k.go @@ -24,6 +24,7 @@ var UpgradeLiftoffHeight = abi.ChainEpoch(-5) const UpgradeKumquatHeight = 15 const UpgradeCalicoHeight = 20 const UpgradePersianHeight = 25 +const UpgradeOrangeHeight = 27 const UpgradeClausHeight = 30 var DrandSchedule = map[abi.ChainEpoch]DrandEnum{ diff --git a/build/params_testground.go b/build/params_testground.go index dbfdf223c..d0e54e3f2 100644 --- a/build/params_testground.go +++ b/build/params_testground.go @@ -91,6 +91,7 @@ var ( UpgradeCalicoHeight abi.ChainEpoch = -7 UpgradePersianHeight abi.ChainEpoch = -8 UpgradeClausHeight abi.ChainEpoch = -9 + UpgradeOrangeHeight abi.ChainEpoch = -10 DrandSchedule = map[abi.ChainEpoch]DrandEnum{ 0: DrandMainnet, From c7e3e9fa7f893da22a08678970a8a0058a7fb8c5 Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Sat, 19 Dec 2020 21:51:07 +0100 Subject: [PATCH 7/8] Add IsNearUpgrade Signed-off-by: Jakub Sztandera --- chain/gen/slashfilter/slashfilter.go | 4 +--- chain/vm/syscalls.go | 6 ++---- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/chain/gen/slashfilter/slashfilter.go b/chain/gen/slashfilter/slashfilter.go index cb12ddb08..5edcd5439 100644 --- a/chain/gen/slashfilter/slashfilter.go +++ b/chain/gen/slashfilter/slashfilter.go @@ -28,9 +28,7 @@ func New(dstore ds.Batching) *SlashFilter { } func (f *SlashFilter) MinedBlock(bh *types.BlockHeader, parentEpoch abi.ChainEpoch) error { - if bh.Height > build.UpgradeOrangeHeight-build.Finality && - bh.Height < build.UpgradeOrangeHeight+build.Finality { - // consenssus faults disabled during Upgrade Orange + if build.IsNearUpgrade(bh.Height, build.UpgradeOrangeHeight) { return nil } diff --git a/chain/vm/syscalls.go b/chain/vm/syscalls.go index b063e5f25..0bcfe10a7 100644 --- a/chain/vm/syscalls.go +++ b/chain/vm/syscalls.go @@ -109,12 +109,10 @@ func (ss *syscallShim) VerifyConsensusFault(a, b, extra []byte) (*runtime2.Conse } // workaround chain halt - if blockA.Height > build.UpgradeOrangeHeight-build.Finality && - blockA.Height < build.UpgradeOrangeHeight+build.Finality { + if build.IsNearUpgrade(blockA.Height, build.UpgradeOrangeHeight) { return nil, xerrors.Errorf("consensus reporting disabled around Upgrade Orange") } - if blockB.Height > build.UpgradeOrangeHeight-build.Finality && - blockB.Height < build.UpgradeOrangeHeight+build.Finality { + if build.IsNearUpgrade(blockB.Height, build.UpgradeOrangeHeight) { return nil, xerrors.Errorf("consensus reporting disabled around Upgrade Orange") } From e777b879a1e368bf71b83a05759cb27afcfa28f8 Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Sat, 19 Dec 2020 22:10:45 +0100 Subject: [PATCH 8/8] Add the missing file Signed-off-by: Jakub Sztandera --- build/isnearupgrade.go | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 build/isnearupgrade.go diff --git a/build/isnearupgrade.go b/build/isnearupgrade.go new file mode 100644 index 000000000..4273f0e9e --- /dev/null +++ b/build/isnearupgrade.go @@ -0,0 +1,9 @@ +package build + +import ( + "github.com/filecoin-project/go-state-types/abi" +) + +func IsNearUpgrade(epoch, upgradeEpoch abi.ChainEpoch) bool { + return epoch > upgradeEpoch-Finality && epoch < upgradeEpoch+Finality +}