|
|
@ -171,6 +171,7 @@ func eposStakedCommittee( |
|
|
|
if validator.EPOSStatus != effective.Active { |
|
|
|
if validator.EPOSStatus != effective.Active { |
|
|
|
continue |
|
|
|
continue |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// TODO(audit): remove the sanity check here; do the sanity check with maxBLSKey before validator change
|
|
|
|
if err := validator.SanityCheck(maxBLSKey); err != nil { |
|
|
|
if err := validator.SanityCheck(maxBLSKey); err != nil { |
|
|
|
utils.Logger().Info(). |
|
|
|
utils.Logger().Info(). |
|
|
|
Int("staked-candidates", len(candidates)). |
|
|
|
Int("staked-candidates", len(candidates)). |
|
|
@ -178,10 +179,7 @@ func eposStakedCommittee( |
|
|
|
Msg("validator sanity check failed") |
|
|
|
Msg("validator sanity check failed") |
|
|
|
continue |
|
|
|
continue |
|
|
|
} |
|
|
|
} |
|
|
|
validatorStake := big.NewInt(0) |
|
|
|
totalStake := validator.TotalDelegation() |
|
|
|
for _, delegation := range validator.Delegations { |
|
|
|
|
|
|
|
validatorStake.Add(validatorStake, delegation.Amount) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
found := false |
|
|
|
found := false |
|
|
|
dupKey := shard.BlsPublicKey{} |
|
|
|
dupKey := shard.BlsPublicKey{} |
|
|
@ -202,28 +200,23 @@ func eposStakedCommittee( |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
essentials[validator.Address] = effective.SlotOrder{ |
|
|
|
essentials[validator.Address] = effective.SlotOrder{ |
|
|
|
validatorStake, |
|
|
|
totalStake, |
|
|
|
validator.SlotPubKeys, |
|
|
|
validator.SlotPubKeys, |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
staked := effective.Apply(essentials, stakedSlotsCount) |
|
|
|
electedSlots := effective.Apply(essentials, stakedSlotsCount) |
|
|
|
shardBig := big.NewInt(int64(shardCount)) |
|
|
|
shardBig := big.NewInt(int64(shardCount)) |
|
|
|
|
|
|
|
|
|
|
|
if l := len(staked); l < stakedSlotsCount { |
|
|
|
totalEffectiveStake := numeric.ZeroDec() |
|
|
|
// WARN unlikely to happen in production but will happen as we are developing
|
|
|
|
|
|
|
|
stakedSlotsCount = l |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
totalStake := numeric.ZeroDec() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for i := 0; i < stakedSlotsCount; i++ { |
|
|
|
for i := 0; i < len(electedSlots); i++ { |
|
|
|
shardID := int(new(big.Int).Mod(staked[i].BlsPublicKey.Big(), shardBig).Int64()) |
|
|
|
slot := electedSlots[i] |
|
|
|
slot := staked[i] |
|
|
|
shardID := int(new(big.Int).Mod(slot.BlsPublicKey.Big(), shardBig).Int64()) |
|
|
|
totalStake = totalStake.Add(slot.Dec) |
|
|
|
totalEffectiveStake = totalEffectiveStake.Add(slot.Dec) |
|
|
|
shardState.Shards[shardID].Slots = append(shardState.Shards[shardID].Slots, shard.Slot{ |
|
|
|
shardState.Shards[shardID].Slots = append(shardState.Shards[shardID].Slots, shard.Slot{ |
|
|
|
slot.Address, |
|
|
|
slot.Address, |
|
|
|
staked[i].BlsPublicKey, |
|
|
|
slot.BlsPublicKey, |
|
|
|
&slot.Dec, |
|
|
|
&slot.Dec, |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
@ -231,7 +224,7 @@ func eposStakedCommittee( |
|
|
|
if c := len(candidates); c != 0 { |
|
|
|
if c := len(candidates); c != 0 { |
|
|
|
utils.Logger().Info(). |
|
|
|
utils.Logger().Info(). |
|
|
|
Int("staked-candidates", c). |
|
|
|
Int("staked-candidates", c). |
|
|
|
Str("total-staked-by-validators", totalStake.String()). |
|
|
|
Str("sum-all-effective-stake-by-validators", totalEffectiveStake.String()). |
|
|
|
Msg("epos based super-committe") |
|
|
|
Msg("epos based super-committe") |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|