nit: tweak error handling for rlp too big (#834)

I believe ValidateSerializedTxn should be returning (or at least
wrapping) types.RlpTooBig instead of creating a new error when the
transaction exceeds max size, since this is the error the txpool
actually checks for:


61706714c3/txpool/txpool_grpc_server.go (L204)

Before this change the ImportResult for an oversized tx would be
INTERNAL_ERROR; after this change it will be INVALID, which seems more
appropriate.

Co-authored-by: Alex Sharov <AskAlexSharov@gmail.com>
This commit is contained in:
Roberto Bayardo 2023-01-17 23:38:47 -08:00 committed by GitHub
parent fc3dd4fd27
commit 39694bc9d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View File

@ -822,7 +822,7 @@ func (p *TxPool) ValidateSerializedTxn(serializedTxn []byte) error {
txMaxSize = 4 * txSlotSize // 128KB
)
if len(serializedTxn) > txMaxSize {
return fmt.Errorf(RLPTooLong.String())
return types.ErrRlpTooBig
}
return nil
}

View File

@ -240,7 +240,7 @@ func mapDiscardReasonToProto(reason DiscardReason) txpool_proto.ImportResult {
return txpool_proto.ImportResult_ALREADY_EXISTS
case UnderPriced, ReplaceUnderpriced, FeeTooLow:
return txpool_proto.ImportResult_FEE_TOO_LOW
case InvalidSender, NegativeValue, OversizedData, InitCodeTooLarge:
case InvalidSender, NegativeValue, OversizedData, InitCodeTooLarge, RLPTooLong:
return txpool_proto.ImportResult_INVALID
default:
return txpool_proto.ImportResult_INTERNAL_ERROR