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. 14
      rosetta/services/tx_operation.go

@ -315,7 +315,7 @@ func setupNodeAndRun(hc harmonyConfig) {
WSPort: hc.WS.Port, WSPort: hc.WS.Port,
DebugEnabled: hc.RPCOpt.DebugEnabled, DebugEnabled: hc.RPCOpt.DebugEnabled,
} }
if nodeConfig.ShardID != shard.BeaconChainShardID && hc.General.NodeType != nodeTypeExplorer { if nodeConfig.ShardID != shard.BeaconChainShardID {
utils.Logger().Info(). utils.Logger().Info().
Uint32("shardID", currentNode.Blockchain().ShardID()). Uint32("shardID", currentNode.Blockchain().ShardID()).
Uint32("shardID", nodeConfig.ShardID).Msg("SupportBeaconSyncing") 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) { func (consensus *Consensus) SetupForNewConsensus(blk *types.Block, committedMsg *FBFTMessage) {
atomic.AddUint64(&consensus.blockNum, 1) atomic.AddUint64(&consensus.blockNum, 1)
consensus.SetViewIDs(committedMsg.ViewID + 1) consensus.SetCurBlockViewID(committedMsg.ViewID + 1)
consensus.LeaderPubKey = committedMsg.SenderPubkeys[0] consensus.LeaderPubKey = committedMsg.SenderPubkeys[0]
// Update consensus keys at last so the change of leader status doesn't mess up normal flow // Update consensus keys at last so the change of leader status doesn't mess up normal flow
if blk.IsLastBlockInEpoch() { if blk.IsLastBlockInEpoch() {

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

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

@ -240,16 +240,17 @@ func (s *ConstructAPI) ConstructionMetadata(
evmErrorMsg := "" evmErrorMsg := ""
evmReturn := hexutil.Bytes{} evmReturn := hexutil.Bytes{}
if !isStakingOperation(options.OperationType) && if len(data) > 0 && (options.OperationType == common.ContractCreationOperation ||
options.OperationType != common.ContractCreationOperation && options.OperationType == common.NativeTransferOperation) {
len(data) > 0 {
gas := hexutil.Uint64(estGasUsed) gas := hexutil.Uint64(estGasUsed)
callArgs := rpc.CallArgs{ callArgs := rpc.CallArgs{
From: senderAddr, From: senderAddr,
To: &contractAddress,
Data: &data, Data: &data,
Gas: &gas, Gas: &gas,
} }
if options.OperationType == common.NativeTransferOperation {
callArgs.To = &contractAddress
}
evmExe, err := rpc.DoEVMCall( evmExe, err := rpc.DoEVMCall(
ctx, s.hmy, callArgs, ethRpc.LatestBlockNumber, vm.Config{}, rpc.CallTimeout, s.hmy.RPCGasCap, 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) logs := hmytypes.FindLogsWithTopic(receipt, staking.DelegateTopic)
for _, log := range logs { for _, log := range logs {
if len(log.Data) > ethcommon.AddressLength { if len(log.Data) > ethcommon.AddressLength && log.Address == stkMsg.DelegatorAddress {
validatorAddress := ethcommon.BytesToAddress(log.Data[:ethcommon.AddressLength]) // Remove re-delegation amount as funds were never credited to account's balance.
if log.Address == stkMsg.DelegatorAddress && stkMsg.ValidatorAddress == validatorAddress { deductedAmt = new(big.Int).Sub(deductedAmt, new(big.Int).SetBytes(log.Data[ethcommon.AddressLength:]))
// 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
}
} }
} }
return &types.Amount{ return &types.Amount{
Value: negativeBigValue(stkAmount), Value: negativeBigValue(deductedAmt),
Currency: &common.NativeCurrency, Currency: &common.NativeCurrency,
}, nil }, nil
} }

Loading…
Cancel
Save