merge with main

pull/3405/head
Rongjian Lan 4 years ago
commit 00efb58e5f
  1. 2
      cmd/harmony/main.go
  2. 2
      consensus/consensus_v2.go
  3. 1
      consensus/quorum/quorum.go
  4. 14
      consensus/validator.go
  5. 9
      rosetta/services/construction_check.go
  6. 12
      rosetta/services/tx_operation.go

@ -315,7 +315,7 @@ func setupNodeAndRun(hc harmonyConfig) {
WSPort: hc.WS.Port,
DebugEnabled: hc.RPCOpt.DebugEnabled,
}
if nodeConfig.ShardID != shard.BeaconChainShardID && hc.General.NodeType != nodeTypeExplorer {
if nodeConfig.ShardID != shard.BeaconChainShardID {
utils.Logger().Info().
Uint32("shardID", currentNode.Blockchain().ShardID()).
Uint32("shardID", nodeConfig.ShardID).Msg("SupportBeaconSyncing")

@ -599,7 +599,7 @@ func (consensus *Consensus) commitBlock(blk *types.Block, committedMsg *FBFTMess
func (consensus *Consensus) SetupForNewConsensus(blk *types.Block, committedMsg *FBFTMessage) {
atomic.AddUint64(&consensus.blockNum, 1)
consensus.SetViewIDs(committedMsg.ViewID + 1)
consensus.SetCurBlockViewID(committedMsg.ViewID + 1)
consensus.LeaderPubKey = committedMsg.SenderPubkeys[0]
// Update consensus keys at last so the change of leader status doesn't mess up normal flow
if blk.IsLastBlockInEpoch() {

@ -119,7 +119,6 @@ type Decider interface {
DependencyInjectionWriter
SetVoters(subCommittee *shard.Committee, epoch *big.Int) (*TallyResult, error)
Policy() Policy
// Add new vote will add the signature in the memory and increase the cumulative voting power
AddNewVote(
p Phase, pubkeys []*bls_cosi.PublicKeyWrapper,
sig *bls_core.Sign, headerHash common.Hash,

@ -113,6 +113,10 @@ func (consensus *Consensus) onPrepared(msg *msg_pb.Message) {
Msg("Wrong BlockNum Received, ignoring!")
return
}
if recvMsg.BlockNum > consensus.blockNum {
consensus.getLogger().Warn().Msgf("[OnPrepared] low consensus block number. Spin sync")
consensus.spinUpStateSync()
}
// check validity of prepared signature
blockHash := recvMsg.BlockHash
@ -148,12 +152,6 @@ func (consensus *Consensus) onPrepared(msg *msg_pb.Message) {
if !consensus.onPreparedSanityChecks(&blockObj, recvMsg) {
return
}
if recvMsg.BlockNum > consensus.blockNum {
consensus.getLogger().Warn().Msgf("[OnPrepared] low consensus block number. Spin sync")
consensus.spinUpStateSync()
}
consensus.mutex.Lock()
defer consensus.mutex.Unlock()
@ -239,6 +237,10 @@ func (consensus *Consensus) onCommitted(msg *msg_pb.Message) {
Msg("Wrong BlockNum Received, ignoring!")
return
}
if recvMsg.BlockNum > consensus.blockNum {
consensus.getLogger().Info().Msg("[OnCommitted] low consensus block number. Spin up state sync")
consensus.spinUpStateSync()
}
aggSig, mask, err := consensus.ReadSignatureBitmapPayload(recvMsg.Payload, 0)
if err != nil {

@ -240,16 +240,17 @@ func (s *ConstructAPI) ConstructionMetadata(
evmErrorMsg := ""
evmReturn := hexutil.Bytes{}
if !isStakingOperation(options.OperationType) &&
options.OperationType != common.ContractCreationOperation &&
len(data) > 0 {
if len(data) > 0 && (options.OperationType == common.ContractCreationOperation ||
options.OperationType == common.NativeTransferOperation) {
gas := hexutil.Uint64(estGasUsed)
callArgs := rpc.CallArgs{
From: senderAddr,
To: &contractAddress,
Data: &data,
Gas: &gas,
}
if options.OperationType == common.NativeTransferOperation {
callArgs.To = &contractAddress
}
evmExe, err := rpc.DoEVMCall(
ctx, s.hmy, callArgs, ethRpc.LatestBlockNumber, vm.Config{}, rpc.CallTimeout, s.hmy.RPCGasCap,
)

@ -158,20 +158,16 @@ func getAmountFromDelegateMessage(receipt *hmytypes.Receipt, data []byte) (*type
})
}
stkAmount := stkMsg.Amount
deductedAmt := stkMsg.Amount
logs := hmytypes.FindLogsWithTopic(receipt, staking.DelegateTopic)
for _, log := range logs {
if len(log.Data) > ethcommon.AddressLength {
validatorAddress := ethcommon.BytesToAddress(log.Data[:ethcommon.AddressLength])
if log.Address == stkMsg.DelegatorAddress && stkMsg.ValidatorAddress == validatorAddress {
if len(log.Data) > ethcommon.AddressLength && log.Address == stkMsg.DelegatorAddress {
// Remove re-delegation amount as funds were never credited to account's balance.
stkAmount = new(big.Int).Sub(stkAmount, new(big.Int).SetBytes(log.Data[ethcommon.AddressLength:]))
break
}
deductedAmt = new(big.Int).Sub(deductedAmt, new(big.Int).SetBytes(log.Data[ethcommon.AddressLength:]))
}
}
return &types.Amount{
Value: negativeBigValue(stkAmount),
Value: negativeBigValue(deductedAmt),
Currency: &common.NativeCurrency,
}, nil
}

Loading…
Cancel
Save