-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Transaction:inferType wrong behaviour #4858
Comments
Thanks! Could you provide a short code snippet (like |
Sure! Code snippet
BehaviourIt logs Expected behaviourSince it has not |
I was about to do the PR, but someone already did it 😄 |
@ricmoo I was having the same issue with transaction type inferring (but with different transaction type). When I was creating a blob transaction, the type will always be inferred as dynamic fee transaction. The following code snippet is the definition of blob transaction in geth, it shows that a blob transaction can only use EIP1559 fees. // BlobTx represents an EIP-4844 transaction.
type BlobTx struct {
ChainID *uint256.Int
Nonce uint64
GasTipCap *uint256.Int // a.k.a. maxPriorityFeePerGas
GasFeeCap *uint256.Int // a.k.a. maxFeePerGas
Gas uint64
To common.Address
Value *uint256.Int
Data []byte
AccessList AccessList
BlobFeeCap *uint256.Int // a.k.a. maxFeePerBlobGas
BlobHashes []common.Hash
// A blob transaction can optionally contain blobs. This field must be set when BlobTx
// is used to create a transaction for signing.
Sidecar *BlobTxSidecar `rlp:"-"`
// Signature values
V *uint256.Int `json:"v" gencodec:"required"`
R *uint256.Int `json:"r" gencodec:"required"`
S *uint256.Int `json:"s" gencodec:"required"`
} So which means, in the above transaction inferring code, the if statement for inferring the blob transaction should be at the top: // Explicit type
if (this.type != null) {
types.push(this.type);
} else {
if (hasFee) {
types.push(2);
} else if (hasGasPrice) {
types.push(1);
if (!hasAccessList) { types.push(0); }
} else if (hasAccessList) {
types.push(1);
types.push(2);
} else if (hasBlob && this.to) { // <-- this should be at the top
types.push(3);
} else {
types.push(0);
types.push(1);
types.push(2);
types.push(3);
}
} |
Ethers Version
6.8.0
Search Terms
inferType
Describe the Problem
Rationale
inferTypes()
function adds typeeip2930
incorrectly:https://github.com/ethers-io/ethers.js/blob/main/src.ts/transaction/transaction.ts#L1024
Error description
if the transaction has a
gasPrice
set, it directly adds to a possible transaction type thetype: 1 (eip2930)
.Later on, it checks if it has an
accessList
, so it addstype: 0 (legacy)
.Logic should be the other way around. If it has
gasPrice
, addtype: 0 (legacy)
. And if it also hasaccessList
, then addtype: 1 (eip2930)
.Since the function sorts the types and later on returns the highest one, it will always return
type: 1 (eip2930)
if it hasgasPrice
set.Correct code
Code Snippet
Contract ABI
No response
Errors
No response
Environment
node.js (v12 or newer)
Environment (Other)
No response
The text was updated successfully, but these errors were encountered: