|
|
|
@ -84,9 +84,13 @@ func (node *Node) WaitForConsensusReadyV2(readySignal chan struct{}, stopChan ch |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (node *Node) proposeNewBlock() (*types.Block, error) { |
|
|
|
|
utils.AnalysisStart("proposeNewBlock") |
|
|
|
|
defer utils.AnalysisEnd("proposeNewBlock") |
|
|
|
|
|
|
|
|
|
node.Worker.UpdateCurrent() |
|
|
|
|
|
|
|
|
|
// Update worker's current header and state data in preparation to propose/process new transactions
|
|
|
|
|
// Update worker's current header and
|
|
|
|
|
// state data in preparation to propose/process new transactions
|
|
|
|
|
var ( |
|
|
|
|
coinbase = node.Consensus.SelfAddresses[node.Consensus.LeaderPubKey.SerializeToHexStr()] |
|
|
|
|
beneficiary = coinbase |
|
|
|
@ -117,6 +121,8 @@ func (node *Node) proposeNewBlock() (*types.Block, error) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Prepare normal and staking transactions retrieved from transaction pool
|
|
|
|
|
utils.AnalysisStart("proposeNewBlockChooseFromTxnPool") |
|
|
|
|
|
|
|
|
|
pendingPoolTxs, err := node.TxPool.Pending() |
|
|
|
|
if err != nil { |
|
|
|
|
utils.Logger().Err(err).Msg("Failed to fetch pending transactions") |
|
|
|
@ -144,6 +150,7 @@ func (node *Node) proposeNewBlock() (*types.Block, error) { |
|
|
|
|
pendingPlainTxs[addr] = plainTxsPerAcc |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
utils.AnalysisEnd("proposeNewBlockChooseFromTxnPool") |
|
|
|
|
|
|
|
|
|
// Try commit normal and staking transactions based on the current state
|
|
|
|
|
// The successfully committed transactions will be put in the proposed block
|
|
|
|
@ -168,6 +175,7 @@ func (node *Node) proposeNewBlock() (*types.Block, error) { |
|
|
|
|
isBeaconchainInStakingEra := node.NodeConfig.ShardID == shard.BeaconChainShardID && |
|
|
|
|
node.Blockchain().Config().IsStaking(node.Worker.GetCurrentHeader().Epoch()) |
|
|
|
|
|
|
|
|
|
utils.AnalysisStart("proposeNewBlockVerifyCrossLinks") |
|
|
|
|
// Prepare cross links and slashing messages
|
|
|
|
|
var crossLinksToPropose types.CrossLinks |
|
|
|
|
if isBeaconchainInCrossLinkEra { |
|
|
|
@ -202,6 +210,7 @@ func (node *Node) proposeNewBlock() (*types.Block, error) { |
|
|
|
|
} |
|
|
|
|
node.Blockchain().DeleteFromPendingCrossLinks(invalidToDelete) |
|
|
|
|
} |
|
|
|
|
utils.AnalysisEnd("proposeNewBlockVerifyCrossLinks") |
|
|
|
|
|
|
|
|
|
if isBeaconchainInStakingEra { |
|
|
|
|
// this will set a meaningful w.current.slashes
|
|
|
|
|