From cc8662cb533cb25787051f52301c3fdce9a5cb72 Mon Sep 17 00:00:00 2001 From: Edgar Aroutiounian Date: Thu, 21 Nov 2019 16:02:25 -0800 Subject: [PATCH] [PR] Address PR comments #3 --- consensus/quorum/one-node-staked-vote.go | 4 ++-- internal/chain/reward.go | 2 +- internal/params/config.go | 2 +- node/node_handler.go | 6 +++--- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/consensus/quorum/one-node-staked-vote.go b/consensus/quorum/one-node-staked-vote.go index 4b97626b5..074f25e89 100644 --- a/consensus/quorum/one-node-staked-vote.go +++ b/consensus/quorum/one-node-staked-vote.go @@ -57,7 +57,7 @@ func (v *stakedVoteWeight) IsQuorumAchieved(p Phase) bool { // QuorumThreshold .. func (v *stakedVoteWeight) QuorumThreshold() *big.Int { - return v.total.Mul(twoThirds).RoundInt() + return v.total.Mul(twoThirds).Ceil().RoundInt() } // RewardThreshold .. @@ -73,7 +73,6 @@ func (v *stakedVoteWeight) Award( payout := big.NewInt(0) last := big.NewInt(0) count := big.NewInt(int64(len(earners))) - // TODO Finish implementing this logic proportional := map[common.Address]numeric.Dec{} for _, details := range v.validatorStakes { @@ -83,6 +82,7 @@ func (v *stakedVoteWeight) Award( ) } } + // TODO Finish implementing this logic w/Chao for i := range earners { cur := big.NewInt(0) diff --git a/internal/chain/reward.go b/internal/chain/reward.go index f462d1d4d..34a5738cc 100644 --- a/internal/chain/reward.go +++ b/internal/chain/reward.go @@ -104,7 +104,7 @@ func AccumulateRewards( for i := range missing { w.Add(1) go func(member int) { - defer w.Add(-1) + defer w.Done() // Slash if missing block was long enough if slasher.ShouldSlash(missing[member].BlsPublicKey) { // TODO Logic diff --git a/internal/params/config.go b/internal/params/config.go index 5892b2258..21af1fda3 100644 --- a/internal/params/config.go +++ b/internal/params/config.go @@ -36,7 +36,7 @@ var ( ChainID: TestnetChainID, CrossTxEpoch: big.NewInt(0), CrossLinkEpoch: big.NewInt(0), - StakingEpoch: big.NewInt(3), + StakingEpoch: EpochTBD, EIP155Epoch: big.NewInt(0), S3Epoch: big.NewInt(0), } diff --git a/node/node_handler.go b/node/node_handler.go index 3f46661bc..cf60f0d34 100644 --- a/node/node_handler.go +++ b/node/node_handler.go @@ -378,10 +378,9 @@ func (node *Node) PostConsensusProcessing(newBlock *types.Block, commitSigAndBit } } } - next := new(big.Int).Add(newBlock.Epoch(), common.Big1) // Update consensus keys at last so the change of leader status doesn't mess up normal flow if shard.Schedule.IsLastBlock(newBlock.Number().Uint64()) { - + next := new(big.Int).Add(newBlock.Epoch(), common.Big1) if node.chainConfig.StakingEpoch.Cmp(next) == 0 && node.Consensus.Decider.Policy() != quorum.SuperMajorityStake { node.Consensus.Decider = quorum.NewDecider(quorum.SuperMajorityStake) @@ -395,7 +394,8 @@ func (node *Node) PostConsensusProcessing(newBlock *types.Block, commitSigAndBit s.FindCommitteeByID(node.Consensus.ShardID).Slots, ) } - + // TODO Need to refactor UpdateConsensusInformation so can fold the following logic + // into UCI - todo because UCI mutates state & called in overloaded contexts node.Consensus.UpdateConsensusInformation() if shard.Schedule.IsLastBlock(newBlock.Number().Uint64()) {