[epos] Remove debug code, address lint

pull/1827/head
Edgar Aroutiounian 5 years ago
parent 095be41b56
commit 8d76bf13ee
  1. 2
      internal/configs/sharding/localnet.go
  2. 2
      internal/params/config.go
  3. 5
      shard/committee/assignment.go
  4. 8
      staking/effective/calculate.go

@ -17,7 +17,7 @@ const (
localnetV1Epoch = 1
localnetV2Epoch = 2
localnetEpochBlock1 = 5
localnetEpochBlock1 = 10
twoOne = 5
localnetVdfDifficulty = 5000 // This takes about 10s to finish the vdf

@ -37,7 +37,7 @@ var (
CrossTxEpoch: big.NewInt(0),
CrossLinkEpoch: big.NewInt(0),
// MinEpoch needed is at least 1, crashes on 0
StakingEpoch: big.NewInt(1),
StakingEpoch: EpochTBD,
EIP155Epoch: big.NewInt(0),
S3Epoch: big.NewInt(0),
}

@ -181,6 +181,10 @@ func eposStakedCommittee(
shardBig := big.NewInt(int64(shardCount))
if len(staked) <= stakedSlotsCount {
// WARN unlikely to happen in production but will happen as we are developing
}
for i := 0; i < stakedSlotsCount; i++ {
bucket := int(new(big.Int).Mod(staked[i].Address.Big(), shardBig).Int64())
slot := staked[i]
@ -309,6 +313,5 @@ func (def partialStakingEnabled) Compute(
stakedSlots :=
(instance.NumNodesPerShard() - instance.NumHarmonyOperatedNodesPerShard()) *
int(instance.NumShards())
fmt.Println("Staking epoch happened", config.String())
return eposStakedCommittee(instance, stakerReader, stakedSlots)
}

@ -55,13 +55,14 @@ func median(stakes []SlotPurchase) numeric.Dec {
// Apply ..
func Apply(shortHand map[common.Address]SlotOrder) Slots {
eposedSlots := Slots{}
if len(shortHand) == 0 {
return eposedSlots
}
// Expand
for staker := range shortHand {
slotsCount := int64(len(shortHand[staker].SpreadAmong))
var i int64 = 0
spread := numeric.NewDecFromBigInt(shortHand[staker].Stake).QuoInt64(slotsCount)
var i int64
for ; i < slotsCount; i++ {
eposedSlots = append(eposedSlots, SlotPurchase{staker, spread})
}
@ -69,7 +70,6 @@ func Apply(shortHand map[common.Address]SlotOrder) Slots {
if len(eposedSlots) < len(shortHand) {
// WARN Should never happen
}
median := median(eposedSlots)
for i := range eposedSlots {

Loading…
Cancel
Save