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