|
|
|
@ -8,7 +8,6 @@ import ( |
|
|
|
|
"sync/atomic" |
|
|
|
|
"time" |
|
|
|
|
|
|
|
|
|
"github.com/ethereum/go-ethereum/common" |
|
|
|
|
"github.com/ethereum/go-ethereum/crypto" |
|
|
|
|
"github.com/ethereum/go-ethereum/rlp" |
|
|
|
|
"github.com/harmony-one/bls/ffi/go/bls" |
|
|
|
@ -18,7 +17,6 @@ import ( |
|
|
|
|
proto_discovery "github.com/harmony-one/harmony/api/proto/discovery" |
|
|
|
|
proto_node "github.com/harmony-one/harmony/api/proto/node" |
|
|
|
|
"github.com/harmony-one/harmony/block" |
|
|
|
|
"github.com/harmony-one/harmony/consensus/quorum" |
|
|
|
|
"github.com/harmony-one/harmony/core/types" |
|
|
|
|
nodeconfig "github.com/harmony-one/harmony/internal/configs/node" |
|
|
|
|
"github.com/harmony-one/harmony/internal/ctxerror" |
|
|
|
@ -27,7 +25,6 @@ import ( |
|
|
|
|
"github.com/harmony-one/harmony/p2p" |
|
|
|
|
"github.com/harmony-one/harmony/p2p/host" |
|
|
|
|
"github.com/harmony-one/harmony/shard" |
|
|
|
|
"github.com/harmony-one/harmony/shard/committee" |
|
|
|
|
staking "github.com/harmony-one/harmony/staking/types" |
|
|
|
|
) |
|
|
|
|
|
|
|
|
@ -335,8 +332,6 @@ func (node *Node) PostConsensusProcessing(newBlock *types.Block, commitSigAndBit |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// fmt.Println("Finished consensus->", node.NodeConfig.Port)
|
|
|
|
|
|
|
|
|
|
// Update last consensus time for metrics
|
|
|
|
|
// TODO: randomly selected a few validators to broadcast messages instead of only leader broadcast
|
|
|
|
|
// TODO: refactor the asynchronous calls to separate go routine.
|
|
|
|
@ -363,35 +358,10 @@ func (node *Node) PostConsensusProcessing(newBlock *types.Block, commitSigAndBit |
|
|
|
|
|
|
|
|
|
// Broadcast client requested missing cross shard receipts if there is any
|
|
|
|
|
node.BroadcastMissingCXReceipts() |
|
|
|
|
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()) { |
|
|
|
|
if node.chainConfig.StakingEpoch.Cmp(next) == 0 && |
|
|
|
|
node.Consensus.Decider.Policy() != quorum.SuperMajorityStake { |
|
|
|
|
node.Consensus.Decider = quorum.NewDecider(quorum.SuperMajorityStake) |
|
|
|
|
node.Consensus.Decider.SetShardIDProvider(func() (uint32, error) { |
|
|
|
|
return node.Consensus.ShardID, nil |
|
|
|
|
}) |
|
|
|
|
s, _ := committee.WithStakingEnabled.Compute( |
|
|
|
|
next, node.chainConfig, node.Consensus.ChainReader, |
|
|
|
|
) |
|
|
|
|
node.Consensus.Decider.UpdateVotingPower( |
|
|
|
|
s.FindCommitteeByID(node.Consensus.ShardID).Slots, |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
node.Consensus.UpdateConsensusInformation() |
|
|
|
|
|
|
|
|
|
if shard.Schedule.IsLastBlock(newBlock.Number().Uint64()) { |
|
|
|
|
if node.chainConfig.StakingEpoch.Cmp(next) == 0 { |
|
|
|
|
// Hit this case again, need after UpdateConsensus
|
|
|
|
|
curPubKeys := committee.WithStakingEnabled.ComputePublicKeys( |
|
|
|
|
next, node.Consensus.ChainReader, |
|
|
|
|
)[int(node.Consensus.ShardID)] |
|
|
|
|
node.Consensus.Decider.UpdateParticipants(curPubKeys) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// TODO chao: uncomment this after beacon syncing is stable
|
|
|
|
|