Skip to content

Commit

Permalink
Adjust sigchain verification parameters
Browse files Browse the repository at this point in the history
Signed-off-by: Yilun <[email protected]>
  • Loading branch information
yilunzhang committed May 17, 2021
1 parent fcd8a4d commit e5bfe7e
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 11 deletions.
2 changes: 1 addition & 1 deletion cmd/nknd/nknd.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
20 changes: 13 additions & 7 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -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},
}
Expand Down
2 changes: 1 addition & 1 deletion pb/sigchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
4 changes: 2 additions & 2 deletions por/sigchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
}

Expand Down

0 comments on commit e5bfe7e

Please sign in to comment.