Skip to content

Commit e41fbd4

Browse files
committed
Increase invites limit for god node (#781)
1 parent 1fb8245 commit e41fbd4

File tree

4 files changed

+11
-5
lines changed

4 files changed

+11
-5
lines changed

blockchain/blockchain.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ func (chain *Blockchain) generateGenesis(network types.Network) (*types.Block, e
322322
if chain.config.GenesisConf.GodAddressInvites > 0 {
323323
chain.appState.State.SetGodAddressInvites(chain.config.GenesisConf.GodAddressInvites)
324324
} else {
325-
chain.appState.State.SetGodAddressInvites(common.GodAddressInvitesCount(0))
325+
chain.appState.State.SetGodAddressInvites(common.GodAddressInvitesCount(0, chain.config.Consensus.IncreaseGodInvitesLimit))
326326
}
327327

328328
log.Info("Next validation time", "time", chain.appState.State.NextValidationTime().String(), "unix", nextValidationTimestamp)
@@ -600,7 +600,7 @@ func (chain *Blockchain) applyNewEpoch(appState *appstate.AppState, block *types
600600
}
601601
appState.State.SetEpochBlock(block.Height())
602602
appState.State.ClearEmptyBlocksByShard()
603-
appState.State.SetGodAddressInvites(common.GodAddressInvitesCount(networkSize))
603+
appState.State.SetGodAddressInvites(common.GodAddressInvitesCount(networkSize, chain.config.Consensus.IncreaseGodInvitesLimit))
604604
}
605605

606606
func calculateNewIdentityStatusFlags(validationResults map[common.ShardId]*types.ValidationResults) map[common.Address]state.ValidationStatusFlag {

blockchain/blockchain_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -730,7 +730,7 @@ func Test_Blockchain_GodAddressInvitesLimit(t *testing.T) {
730730
addr := crypto.PubkeyToAddress(key.PublicKey)
731731
chain, state := NewCustomTestBlockchain(5, 0, key)
732732

733-
count := int(common.GodAddressInvitesCount(0))
733+
count := int(common.GodAddressInvitesCount(0, false))
734734
for i := 0; i < count; i++ {
735735
keyReceiver, _ := crypto.GenerateKey()
736736
receiver := crypto.PubkeyToAddress(keyReceiver.PublicKey)

common/network.go

+6-2
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,12 @@ func NormalizedEpochDuration(validationTime time.Time, networkSize int) time.Dur
8181
return day * time.Duration(math2.MinInt(28, int(math.Round(math.Pow(float64(networkSize), 0.33)/21)*21)))
8282
}
8383

84-
func GodAddressInvitesCount(networkSize int) uint16 {
85-
return uint16(math2.MinInt(500, math2.MaxInt(50, networkSize/3)))
84+
func GodAddressInvitesCount(networkSize int, increaseLimit bool) uint16 {
85+
limit := 500
86+
if increaseLimit {
87+
limit = math2.MaxInt(500, int(float32(networkSize)*0.1))
88+
}
89+
return uint16(math2.MinInt(limit, math2.MaxInt(50, networkSize/3)))
8690
}
8791

8892
func EncodeScore(shortPoints float32, shortFlipsCount uint32) byte {

config/consensus.go

+2
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ type ConsensusConf struct {
5757
BurnInviteeStake bool
5858
ReductionOneDelay time.Duration
5959
EnableValidationSharding bool
60+
IncreaseGodInvitesLimit bool
6061
}
6162

6263
type ConsensusVerson uint16
@@ -162,6 +163,7 @@ func ApplyConsensusVersion(ver ConsensusVerson, cfg *ConsensusConf) {
162163
cfg.EndActivationDate = time.Date(2021, 05, 18, 0, 0, 0, 0, time.UTC).Unix()
163164
case ConsensusV6:
164165
cfg.EnableValidationSharding = true
166+
cfg.IncreaseGodInvitesLimit = true
165167
cfg.Version = ConsensusV6
166168
cfg.MigrationTimeout = 0
167169
cfg.GenerateGenesisAfterUpgrade = true

0 commit comments

Comments
 (0)