mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-18 18:02:24 +00:00
core/txpool: Improve error responses
I noticed that these two responses can make their way back to the transaction submitter when submitting unsupported tx types. Adding the extra context makes it easier for the submitter to understand what went wrong. Particularly in the case of the invalid sender response, which is returned when an unsupported transaction type is encountered.
This commit is contained in:
parent
e9467eec1c
commit
e44cfeeaa2
2 changed files with 2 additions and 2 deletions
|
|
@ -341,7 +341,7 @@ func (p *TxPool) Add(txs []*types.Transaction, local bool, sync bool) []error {
|
||||||
for i, split := range splits {
|
for i, split := range splits {
|
||||||
// If the transaction was rejected by all subpools, mark it unsupported
|
// If the transaction was rejected by all subpools, mark it unsupported
|
||||||
if split == -1 {
|
if split == -1 {
|
||||||
errs[i] = core.ErrTxTypeNotSupported
|
errs[i] = fmt.Errorf("%w (type %d)", core.ErrTxTypeNotSupported, txs[i].Type())
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
// Find which subpool handled it and pull in the corresponding error
|
// Find which subpool handled it and pull in the corresponding error
|
||||||
|
|
|
||||||
|
|
@ -99,7 +99,7 @@ func ValidateTransaction(tx *types.Transaction, head *types.Header, signer types
|
||||||
}
|
}
|
||||||
// Make sure the transaction is signed properly
|
// Make sure the transaction is signed properly
|
||||||
if _, err := types.Sender(signer, tx); err != nil {
|
if _, err := types.Sender(signer, tx); err != nil {
|
||||||
return ErrInvalidSender
|
return fmt.Errorf("%w: %w", ErrInvalidSender, err)
|
||||||
}
|
}
|
||||||
// Ensure the transaction has more gas than the bare minimum needed to cover
|
// Ensure the transaction has more gas than the bare minimum needed to cover
|
||||||
// the transaction metadata
|
// the transaction metadata
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue