[log] Data epoch & blocknum to subset of ds logs (#2547)

pull/2556/head
Edgar Aroutiounian 5 years ago committed by GitHub
parent 4758d50df2
commit 2b578c0a58
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      internal/chain/engine.go
  2. 10
      internal/chain/reward.go
  3. 6
      node/node_newblock.go

@ -309,8 +309,10 @@ func (e *engineImpl) Finalize(
func payoutUndelegations(
chain engine.ChainReader, header *block.Header, state *state.DB,
) error {
utils.AnalysisStart("payoutUndelegations")
defer utils.AnalysisEnd("payoutUndelegations")
currentHeader := chain.CurrentHeader()
nowEpoch, blockNow := currentHeader.Epoch(), currentHeader.Number()
utils.AnalysisStart("payoutUndelegations", nowEpoch, blockNow)
defer utils.AnalysisEnd("payoutUndelegations", nowEpoch, blockNow)
validators, err := chain.ReadValidatorList()
countTrack := map[common.Address]int{}

@ -84,6 +84,8 @@ func AccumulateRewards(
header *block.Header, beaconChain engine.ChainReader,
) (reward.Reader, error) {
blockNum := header.Number().Uint64()
currentHeader := beaconChain.CurrentHeader()
nowEpoch, blockNow := currentHeader.Epoch(), currentHeader.Number()
if blockNum == 0 {
// genesis block has no parent to reward.
@ -98,7 +100,7 @@ func AccumulateRewards(
// After staking
if bc.Config().IsStaking(header.Epoch()) &&
bc.CurrentHeader().ShardID() == shard.BeaconChainShardID {
utils.AnalysisStart("accumulateRewardBeaconchainSelfPayout")
utils.AnalysisStart("accumulateRewardBeaconchainSelfPayout", nowEpoch, blockNow)
defaultReward := network.BaseStakedReward
beaconCurrentEpoch := beaconChain.CurrentHeader().Epoch()
// TODO Use cached result in off-chain db instead of full computation
@ -166,9 +168,9 @@ func AccumulateRewards(
}
}
}
utils.AnalysisEnd("accumulateRewardBeaconchainSelfPayout")
utils.AnalysisEnd("accumulateRewardBeaconchainSelfPayout", nowEpoch, blockNow)
utils.AnalysisStart("accumulateRewardShardchainPayout")
utils.AnalysisStart("accumulateRewardShardchainPayout", nowEpoch, blockNow)
// Handle rewards for shardchain
if cxLinks := header.CrossLinks(); len(cxLinks) > 0 {
crossLinks := types.CrossLinks{}
@ -291,7 +293,7 @@ func AccumulateRewards(
}
}
}
utils.AnalysisEnd("accumulateRewardShardchainPayout")
utils.AnalysisEnd("accumulateRewardShardchainPayout", nowEpoch, blockNow)
return network.NewStakingEraRewardForRound(newRewards, missing), nil
}
return network.EmptyPayout, nil

@ -84,8 +84,10 @@ func (node *Node) WaitForConsensusReadyV2(readySignal chan struct{}, stopChan ch
}
func (node *Node) proposeNewBlock() (*types.Block, error) {
utils.AnalysisStart("proposeNewBlock")
defer utils.AnalysisEnd("proposeNewBlock")
currentHeader := node.Blockchain().CurrentHeader()
nowEpoch, blockNow := currentHeader.Epoch(), currentHeader.Number()
utils.AnalysisStart("proposeNewBlock", nowEpoch, blockNow)
defer utils.AnalysisEnd("proposeNewBlock", nowEpoch, blockNow)
node.Worker.UpdateCurrent()

Loading…
Cancel
Save