diff --git a/cmd/rpcdaemon/commands/send_transaction.go b/cmd/rpcdaemon/commands/send_transaction.go index 9452e88b3d5..7dae0081dae 100644 --- a/cmd/rpcdaemon/commands/send_transaction.go +++ b/cmd/rpcdaemon/commands/send_transaction.go @@ -10,9 +10,7 @@ import ( "github.com/ledgerwatch/erigon-lib/common/hexutility" txPoolProto "github.com/ledgerwatch/erigon-lib/gointerfaces/txpool" - "github.com/ledgerwatch/erigon/core/rawdb" "github.com/ledgerwatch/erigon/core/types" - "github.com/ledgerwatch/erigon/crypto" "github.com/ledgerwatch/erigon/eth/ethconfig" "github.com/ledgerwatch/erigon/params" ) @@ -32,27 +30,16 @@ func (api *APIImpl) SendRawTransaction(ctx context.Context, encodedTx hexutility if !txn.Protected() { return common.Hash{}, errors.New("only replay-protected (EIP-155) transactions allowed over RPC") } - hash := txn.Hash() - res, err := api.txPool.Add(ctx, &txPoolProto.AddRequest{RlpTxs: [][]byte{encodedTx}}) - if err != nil { - return common.Hash{}, err - } - - if res.Imported[0] != txPoolProto.ImportResult_SUCCESS { - return hash, fmt.Errorf("%s: %s", txPoolProto.ImportResult_name[int32(res.Imported[0])], res.Errors[0]) - } + // this has been moved to prior to adding of transactions to capture the + // pre state of the db - which is used for logging in the messages below tx, err := api.db.BeginRo(ctx) if err != nil { return common.Hash{}, err } + defer tx.Rollback() - // Print a log with full txn details for manual investigations and interventions - blockNum := rawdb.ReadCurrentBlockNumber(tx) - if blockNum == nil { - return common.Hash{}, err - } cc, err := api.chainConfig(tx) if err != nil { return common.Hash{}, err @@ -65,17 +52,14 @@ func (api *APIImpl) SendRawTransaction(ctx context.Context, encodedTx hexutility return common.Hash{}, fmt.Errorf("invalid chain id, expected: %d got: %d", chainId, *txnChainId) } - signer := types.MakeSigner(cc, *blockNum) - from, err := txn.Sender(*signer) + hash := txn.Hash() + res, err := api.txPool.Add(ctx, &txPoolProto.AddRequest{RlpTxs: [][]byte{encodedTx}}) if err != nil { return common.Hash{}, err } - if txn.GetTo() == nil { - addr := crypto.CreateAddress(from, txn.GetNonce()) - api.logger.Info("Submitted contract creation", "hash", txn.Hash().Hex(), "from", from, "nonce", txn.GetNonce(), "contract", addr.Hex(), "value", txn.GetValue()) - } else { - api.logger.Info("Submitted transaction", "hash", txn.Hash().Hex(), "from", from, "nonce", txn.GetNonce(), "recipient", txn.GetTo(), "value", txn.GetValue()) + if res.Imported[0] != txPoolProto.ImportResult_SUCCESS { + return hash, fmt.Errorf("%s: %s", txPoolProto.ImportResult_name[int32(res.Imported[0])], res.Errors[0]) } return txn.Hash(), nil