Compare commits

...

3 Commits

Author SHA1 Message Date
“GheisMohammadi” 4ea4ba5b54
add logs for discarding transactions in addPendingTransactions 10 months ago
“GheisMohammadi” 9b6261f4a1
add more logs for transaction and pool 10 months ago
“GheisMohammadi” 6a4f25fc89
add logs for received transactions 10 months ago
  1. 35
      node/node.go
  2. 14
      node/node_handler.go
  3. 3
      node/node_newblock.go

@ -221,12 +221,12 @@ func (node *Node) tryBroadcast(tx *types.Transaction) {
msg := proto_node.ConstructTransactionListMessageAccount(types.Transactions{tx})
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++ {
err := node.host.SendMessageToGroups([]nodeconfig.GroupID{shardGroupID}, p2p.ConstructMessage(msg))
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 {
break
}
@ -239,12 +239,12 @@ func (node *Node) tryBroadcastStaking(stakingTx *staking.StakingTransaction) {
shardGroupID := nodeconfig.NewGroupIDByShardID(
nodeconfig.ShardID(shard.BeaconChainShardID),
) // 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++ {
if err := node.host.SendMessageToGroups([]nodeconfig.GroupID{shardGroupID},
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 {
break
}
@ -267,25 +267,40 @@ func addPendingTransactions(registry *registry.Registry, newTxs types.Transactio
if tx.ShardID() != tx.ToShardID() {
if !acceptCx {
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
}
if isBeforeHIP30 {
if tx.ToShardID() >= nxtShards {
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
}
}
}
if tx.IsEthCompatible() && !bc.Config().IsEthCompatible(bc.CurrentBlock().Epoch()) {
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
}
if isBeforeHIP30 {
if bc.ShardID() >= nxtShards {
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
}
}
utils.Logger().Debug().
Str("tx_hash", tx.Hash().Hex()).
Msg("[addPendingTransactions] tx is added to the txs pool array")
poolTxs = append(poolTxs, tx)
}
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()) {
poolTxs := types.PoolTransactions{}
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)
}
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()
utils.Logger().Info().
Int("length of newStakingTxs", len(poolTxs)).
@ -360,7 +385,7 @@ func (node *Node) AddPendingTransaction(newTx *types.Transaction) error {
var err error
for i := range errs {
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]
break
}

@ -115,6 +115,13 @@ func (node *Node) transactionMessageHandler(msgPayload []byte) {
Msg("Failed to deserialize transaction list")
return
}
// log the transactions
for _, tx := range txs {
utils.Logger().Info().
Str("tx_hash", tx.Hash().Hex()).
Msg("Received a new transaction, adding to pending transactions")
}
// add txs to pending list
addPendingTransactions(node.registry, txs)
}
}
@ -132,6 +139,13 @@ func (node *Node) stakingMessageHandler(msgPayload []byte) {
Msg("Failed to deserialize staking transaction list")
return
}
// log the transactions
for _, tx := range txs {
utils.Logger().Info().
Str("tx_hash", tx.Hash().Hex()).
Msg("Received a new staking transaction, adding to pending staking transactions")
}
// add txs to pending list
node.addPendingStakingTransactions(txs)
}
}

@ -175,14 +175,17 @@ func (node *Node) ProposeNewBlock(commitSigs chan []byte) (*types.Block, error)
plainTxsPerAcc := types.Transactions{}
for _, tx := range poolTxs {
if plainTx, ok := tx.(*types.Transaction); ok {
utils.Logger().Info().Str("tx_hash", tx.Hash().Hex()).Msg("add transaction to proposing block")
plainTxsPerAcc = append(plainTxsPerAcc, plainTx)
} else if stakingTx, ok := tx.(*staking.StakingTransaction); ok {
// Only process staking transactions after pre-staking epoch happened.
if node.Blockchain().Config().IsPreStaking(node.Worker.GetCurrentHeader().Epoch()) {
utils.Logger().Info().Str("tx_hash", tx.Hash().Hex()).Msg("add staking transaction to proposing block")
pendingStakingTxs = append(pendingStakingTxs, stakingTx)
}
} else {
utils.Logger().Err(types.ErrUnknownPoolTxType).
Str("tx_hash", tx.Hash().Hex()).
Msg("Failed to parse pending transactions")
return nil, types.ErrUnknownPoolTxType
}

Loading…
Cancel
Save