From e5bfe7eb97df229954aa169aac62472f567c0cec Mon Sep 17 00:00:00 2001 From: Yilun Date: Sun, 16 May 2021 19:39:45 -0700 Subject: [PATCH] Adjust sigchain verification parameters Signed-off-by: Yilun --- cmd/nknd/nknd.go | 2 +- config/config.go | 20 +++++++++++++------- pb/sigchain.go | 2 +- por/sigchain.go | 4 ++-- 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/cmd/nknd/nknd.go b/cmd/nknd/nknd.go index 00934c910..a6c6ab632 100644 --- a/cmd/nknd/nknd.go +++ b/cmd/nknd/nknd.go @@ -47,7 +47,7 @@ import ( ) const ( - NetVersionNum = 24 // This is temporary and will be removed soon after mainnet is stabilized + NetVersionNum = 25 // This is temporary and will be removed soon after mainnet is stabilized ) var ( diff --git a/config/config.go b/config/config.go index 78d23d9d9..f8490a456 100644 --- a/config/config.go +++ b/config/config.go @@ -163,8 +163,8 @@ var ( values: []bool{false, true}, } SigChainBitShiftMaxLength = HeightDependentInt32{ - heights: []uint32{2633000, 2543000, 0}, - values: []int32{16, 14, 0}, + heights: []uint32{2651000, 2633000, 2543000, 0}, + values: []int32{18, 16, 14, 0}, } SigChainVerifyFingerTableRange = HeightDependentBool{ heights: []uint32{2570000, 0}, @@ -202,15 +202,21 @@ var ( heights: []uint32{2600000, 2570000, 0}, values: []int32{1, 1, 0}, } - SigChainBitShiftPerElement = 4 + SigChainBitShiftPerElement = HeightDependentInt32{ + heights: []uint32{2651000, 0}, + values: []int32{8, 4}, + } SigChainRecentMinerBlocks = 4096 SigChainRecentMinerBitShift = HeightDependentInt32{ - heights: []uint32{2633000, 0}, - values: []int32{4, 0}, + heights: []uint32{2651000, 2633000, 0}, + values: []int32{10, 4, 0}, } SigChainSkipMinerBlocks = 4096 - SigChainSkipMinerMaxAllowed = 3 - SigChainSkipMinerBitShift = HeightDependentInt32{ + SigChainSkipMinerMaxAllowed = HeightDependentInt32{ + heights: []uint32{2651000, 0}, + values: []int32{2, 3}, + } + SigChainSkipMinerBitShift = HeightDependentInt32{ heights: []uint32{2633000, 0}, values: []int32{10, 0}, } diff --git a/pb/sigchain.go b/pb/sigchain.go index c21dffefb..5fc87bd4c 100644 --- a/pb/sigchain.go +++ b/pb/sigchain.go @@ -311,7 +311,7 @@ func ComputeSignatureHash(lastRelayHash []byte, sigChainLen int, height uint32, if maxSigChainLen > 0 && sigChainLen > maxSigChainLen { sigChainLen = maxSigChainLen } - rightShiftBytes(sigHash, config.SigChainBitShiftPerElement*sigChainLen-leftShiftBit) + rightShiftBytes(sigHash, int(config.SigChainBitShiftPerElement.GetValueAtHeight(height))*sigChainLen-leftShiftBit) return sigHash } diff --git a/por/sigchain.go b/por/sigchain.go index 8882e1bfc..5118ecdbd 100644 --- a/por/sigchain.go +++ b/por/sigchain.go @@ -227,8 +227,8 @@ func SignatureHashWithPenalty(sc *pb.SigChain) ([]byte, error) { count := 0 for i := 1; i < sc.Length()-2; i++ { skipped := skipCount(sc.Elems[i].Id, sc.Elems[i+1].Id, sm) - if skipped > config.SigChainSkipMinerMaxAllowed { - count += skipped - config.SigChainSkipMinerMaxAllowed + if skipped > int(config.SigChainSkipMinerMaxAllowed.GetValueAtHeight(height)) { + count += skipped - int(config.SigChainSkipMinerMaxAllowed.GetValueAtHeight(height)) } }