|
|
@ -221,12 +221,12 @@ func (node *Node) tryBroadcast(tx *types.Transaction) { |
|
|
|
msg := proto_node.ConstructTransactionListMessageAccount(types.Transactions{tx}) |
|
|
|
msg := proto_node.ConstructTransactionListMessageAccount(types.Transactions{tx}) |
|
|
|
|
|
|
|
|
|
|
|
shardGroupID := nodeconfig.NewGroupIDByShardID(nodeconfig.ShardID(tx.ShardID())) |
|
|
|
shardGroupID := nodeconfig.NewGroupIDByShardID(nodeconfig.ShardID(tx.ShardID())) |
|
|
|
utils.Logger().Info().Str("shardGroupID", string(shardGroupID)).Msg("tryBroadcast") |
|
|
|
utils.Logger().Info().Str("tx_hash", tx.Hash().Hex()).Str("shardGroupID", string(shardGroupID)).Msg("tryBroadcast") |
|
|
|
|
|
|
|
|
|
|
|
for attempt := 0; attempt < NumTryBroadCast; attempt++ { |
|
|
|
for attempt := 0; attempt < NumTryBroadCast; attempt++ { |
|
|
|
err := node.host.SendMessageToGroups([]nodeconfig.GroupID{shardGroupID}, p2p.ConstructMessage(msg)) |
|
|
|
err := node.host.SendMessageToGroups([]nodeconfig.GroupID{shardGroupID}, p2p.ConstructMessage(msg)) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
utils.Logger().Error().Int("attempt", attempt).Msg("Error when trying to broadcast tx") |
|
|
|
utils.Logger().Error().Str("tx_hash", tx.Hash().Hex()).Int("attempt", attempt).Msg("Error when trying to broadcast tx") |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
break |
|
|
|
break |
|
|
|
} |
|
|
|
} |
|
|
@ -239,12 +239,12 @@ func (node *Node) tryBroadcastStaking(stakingTx *staking.StakingTransaction) { |
|
|
|
shardGroupID := nodeconfig.NewGroupIDByShardID( |
|
|
|
shardGroupID := nodeconfig.NewGroupIDByShardID( |
|
|
|
nodeconfig.ShardID(shard.BeaconChainShardID), |
|
|
|
nodeconfig.ShardID(shard.BeaconChainShardID), |
|
|
|
) // broadcast to beacon chain
|
|
|
|
) // broadcast to beacon chain
|
|
|
|
utils.Logger().Info().Str("shardGroupID", string(shardGroupID)).Msg("tryBroadcastStaking") |
|
|
|
utils.Logger().Info().Str("tx_hash", stakingTx.Hash().Hex()).Str("shardGroupID", string(shardGroupID)).Msg("tryBroadcastStaking") |
|
|
|
|
|
|
|
|
|
|
|
for attempt := 0; attempt < NumTryBroadCast; attempt++ { |
|
|
|
for attempt := 0; attempt < NumTryBroadCast; attempt++ { |
|
|
|
if err := node.host.SendMessageToGroups([]nodeconfig.GroupID{shardGroupID}, |
|
|
|
if err := node.host.SendMessageToGroups([]nodeconfig.GroupID{shardGroupID}, |
|
|
|
p2p.ConstructMessage(msg)); err != nil { |
|
|
|
p2p.ConstructMessage(msg)); err != nil { |
|
|
|
utils.Logger().Error().Int("attempt", attempt).Msg("Error when trying to broadcast staking tx") |
|
|
|
utils.Logger().Error().Str("tx_hash", stakingTx.Hash().Hex()).Int("attempt", attempt).Msg("Error when trying to broadcast staking tx") |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
break |
|
|
|
break |
|
|
|
} |
|
|
|
} |
|
|
@ -267,25 +267,40 @@ func addPendingTransactions(registry *registry.Registry, newTxs types.Transactio |
|
|
|
if tx.ShardID() != tx.ToShardID() { |
|
|
|
if tx.ShardID() != tx.ToShardID() { |
|
|
|
if !acceptCx { |
|
|
|
if !acceptCx { |
|
|
|
errs = append(errs, errors.WithMessage(errInvalidEpoch, "cross-shard tx not accepted yet")) |
|
|
|
errs = append(errs, errors.WithMessage(errInvalidEpoch, "cross-shard tx not accepted yet")) |
|
|
|
|
|
|
|
utils.Logger().Debug().Err(errors.WithMessage(errInvalidEpoch, "cross-shard tx not accepted yet")). |
|
|
|
|
|
|
|
Str("tx_hash", tx.Hash().Hex()). |
|
|
|
|
|
|
|
Msg("[addPendingTransactions] tx is not added to pending pool") |
|
|
|
continue |
|
|
|
continue |
|
|
|
} |
|
|
|
} |
|
|
|
if isBeforeHIP30 { |
|
|
|
if isBeforeHIP30 { |
|
|
|
if tx.ToShardID() >= nxtShards { |
|
|
|
if tx.ToShardID() >= nxtShards { |
|
|
|
errs = append(errs, errors.New("shards 2 and 3 are shutting down in the next epoch")) |
|
|
|
errs = append(errs, errors.New("shards 2 and 3 are shutting down in the next epoch")) |
|
|
|
|
|
|
|
utils.Logger().Debug().Err(errors.WithMessage(errInvalidEpoch, "shards 2 and 3 are shutting down in the next epoch")). |
|
|
|
|
|
|
|
Str("tx_hash", tx.Hash().Hex()). |
|
|
|
|
|
|
|
Msg("[addPendingTransactions] tx is not added to pending pool") |
|
|
|
continue |
|
|
|
continue |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if tx.IsEthCompatible() && !bc.Config().IsEthCompatible(bc.CurrentBlock().Epoch()) { |
|
|
|
if tx.IsEthCompatible() && !bc.Config().IsEthCompatible(bc.CurrentBlock().Epoch()) { |
|
|
|
errs = append(errs, errors.WithMessage(errInvalidEpoch, "ethereum tx not accepted yet")) |
|
|
|
errs = append(errs, errors.WithMessage(errInvalidEpoch, "ethereum tx not accepted yet")) |
|
|
|
|
|
|
|
utils.Logger().Debug().Err(errors.WithMessage(errInvalidEpoch, "ethereum tx not accepted yet")). |
|
|
|
|
|
|
|
Str("tx_hash", tx.Hash().Hex()). |
|
|
|
|
|
|
|
Msg("[addPendingTransactions] tx is not added to pending pool") |
|
|
|
continue |
|
|
|
continue |
|
|
|
} |
|
|
|
} |
|
|
|
if isBeforeHIP30 { |
|
|
|
if isBeforeHIP30 { |
|
|
|
if bc.ShardID() >= nxtShards { |
|
|
|
if bc.ShardID() >= nxtShards { |
|
|
|
errs = append(errs, errors.New("shards 2 and 3 are shutting down in the next epoch")) |
|
|
|
errs = append(errs, errors.New("shards 2 and 3 are shutting down in the next epoch")) |
|
|
|
|
|
|
|
utils.Logger().Debug().Err(errors.WithMessage(errInvalidEpoch, "shards 2 and 3 are shutting down in the next epoch")). |
|
|
|
|
|
|
|
Str("tx_hash", tx.Hash().Hex()). |
|
|
|
|
|
|
|
Msg("[addPendingTransactions] tx is not added to pending pool") |
|
|
|
continue |
|
|
|
continue |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
utils.Logger().Debug(). |
|
|
|
|
|
|
|
Str("tx_hash", tx.Hash().Hex()). |
|
|
|
|
|
|
|
Msg("[addPendingTransactions] tx is added to the txs pool array") |
|
|
|
poolTxs = append(poolTxs, tx) |
|
|
|
poolTxs = append(poolTxs, tx) |
|
|
|
} |
|
|
|
} |
|
|
|
errs = append(errs, registry.GetTxPool().AddRemotes(poolTxs)...) |
|
|
|
errs = append(errs, registry.GetTxPool().AddRemotes(poolTxs)...) |
|
|
@ -305,9 +320,19 @@ func (node *Node) addPendingStakingTransactions(newStakingTxs staking.StakingTra |
|
|
|
if node.Blockchain().Config().IsPreStaking(node.Blockchain().CurrentHeader().Epoch()) { |
|
|
|
if node.Blockchain().Config().IsPreStaking(node.Blockchain().CurrentHeader().Epoch()) { |
|
|
|
poolTxs := types.PoolTransactions{} |
|
|
|
poolTxs := types.PoolTransactions{} |
|
|
|
for _, tx := range newStakingTxs { |
|
|
|
for _, tx := range newStakingTxs { |
|
|
|
|
|
|
|
utils.Logger().Debug(). |
|
|
|
|
|
|
|
Str("tx_hash", tx.Hash().Hex()). |
|
|
|
|
|
|
|
Msg("[addPendingStakingTransactions] tx is added to the txs pool array") |
|
|
|
poolTxs = append(poolTxs, tx) |
|
|
|
poolTxs = append(poolTxs, tx) |
|
|
|
} |
|
|
|
} |
|
|
|
errs := node.TxPool.AddRemotes(poolTxs) |
|
|
|
errs := node.TxPool.AddRemotes(poolTxs) |
|
|
|
|
|
|
|
if len(errs) > 0 { |
|
|
|
|
|
|
|
for _, err := range errs { |
|
|
|
|
|
|
|
utils.Logger().Debug(). |
|
|
|
|
|
|
|
Err(err). |
|
|
|
|
|
|
|
Msg("[addPendingStakingTransactions] AddRemotes failed") |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
pendingCount, queueCount := node.TxPool.Stats() |
|
|
|
pendingCount, queueCount := node.TxPool.Stats() |
|
|
|
utils.Logger().Info(). |
|
|
|
utils.Logger().Info(). |
|
|
|
Int("length of newStakingTxs", len(poolTxs)). |
|
|
|
Int("length of newStakingTxs", len(poolTxs)). |
|
|
@ -360,7 +385,7 @@ func (node *Node) AddPendingTransaction(newTx *types.Transaction) error { |
|
|
|
var err error |
|
|
|
var err error |
|
|
|
for i := range errs { |
|
|
|
for i := range errs { |
|
|
|
if errs[i] != nil { |
|
|
|
if errs[i] != nil { |
|
|
|
utils.Logger().Info().Err(errs[i]).Msg("[AddPendingTransaction] Failed adding new transaction") |
|
|
|
// utils.Logger().Info().Err(errs[i]).Msg("[AddPendingTransaction] Failed adding new transaction")
|
|
|
|
err = errs[i] |
|
|
|
err = errs[i] |
|
|
|
break |
|
|
|
break |
|
|
|
} |
|
|
|
} |
|
|
|