Skip to content

Commit

Permalink
throw when gasPrice passed to 1559 tx
Browse files Browse the repository at this point in the history
  • Loading branch information
acolytec3 committed Nov 11, 2024
1 parent 03b7caf commit 6a9b15e
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
4 changes: 4 additions & 0 deletions packages/tx/src/1559/tx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,10 @@ export class FeeMarket1559Tx implements TransactionInterface<TransactionType.Fee
throw new Error(msg)
}

if (txData.gasPrice !== undefined && txData.gasPrice !== null) {
const msg = Legacy.errorMsg(this, 'gasPrice cannot be defined on 1559 tx')
throw new Error(msg)

Check failure on line 137 in packages/tx/src/1559/tx.ts

View workflow job for this annotation

GitHub Actions / browser / test-all-browser

test/fromRpc.spec.ts > [fromJSONRPCProvider] > should work

Error: gasPrice cannot be defined on 1559 tx (tx type=2 hash=0xed1960aa7d0d7b567c946d94331dddb37a1c67f51f30bf51f256ea40db88cfb0 nonce=2 value=16941678280294901 signed=true hf=london maxFeePerGas=16141066326 maxPriorityFeePerGas=1000000000) ❯ new FeeMarket1559Tx src/1559/tx.ts:137:12 ❯ createFeeMarket1559Tx src/1559/constructors.ts:23:9 ❯ createTx src/transactionFactory.ts:43:13 ❯ createTxFromRPC src/transactionFactory.ts:117:9 ❯ createTxFromJSONRPCProvider src/transactionFactory.ts:140:9 ❯ test/fromRpc.spec.ts:60:15

Check failure on line 137 in packages/tx/src/1559/tx.ts

View workflow job for this annotation

GitHub Actions / browser / test-all-browser

test/fromRpc.spec.ts > [normalizeTxParams] > should work

Error: gasPrice cannot be defined on 1559 tx (tx type=2 hash=0xed1960aa7d0d7b567c946d94331dddb37a1c67f51f30bf51f256ea40db88cfb0 nonce=2 value=16941678280294901 signed=true hf=cancun maxFeePerGas=16141066326 maxPriorityFeePerGas=1000000000) ❯ new FeeMarket1559Tx src/1559/tx.ts:137:12 ❯ createFeeMarket1559Tx src/1559/constructors.ts:23:9 ❯ createTx src/transactionFactory.ts:43:13 ❯ test/fromRpc.spec.ts:80:15

Check failure on line 137 in packages/tx/src/1559/tx.ts

View workflow job for this annotation

GitHub Actions / browser / test-all-browser

test/fromRpc.spec.ts > fromRPC: interpret v/r/s values of 0x0 as undefined for Optimism system txs > should work

Error: gasPrice cannot be defined on 1559 tx (tx type=2 hash=not available (unsigned) nonce=316626 value=0 signed=false hf=cancun maxFeePerGas=0 maxPriorityFeePerGas=0) ❯ new FeeMarket1559Tx src/1559/tx.ts:137:12 ❯ createFeeMarket1559Tx src/1559/constructors.ts:23:9 ❯ createTx src/transactionFactory.ts:43:13 ❯ createTxFromRPC src/transactionFactory.ts:117:9 ❯ test/fromRpc.spec.ts:93:23

Check failure on line 137 in packages/tx/src/1559/tx.ts

View workflow job for this annotation

GitHub Actions / browser / test-all-browser

test/fromRpc.spec.ts > fromRPC: ensure `v="0x0"` is correctly decoded for signed txs > should work

Error: gasPrice cannot be defined on 1559 tx (tx type=2 hash=0xd2cdf63bb15eb4bbc655e4cca198c92305f2c6d057ac993ef6f7bacf1c518b2f nonce=697749 value=0 signed=true hf=cancun maxFeePerGas=1000018792 maxPriorityFeePerGas=1000018784) ❯ new FeeMarket1559Tx src/1559/tx.ts:137:12 ❯ createFeeMarket1559Tx src/1559/constructors.ts:23:9 ❯ createTx src/transactionFactory.ts:43:13 ❯ createTxFromRPC src/transactionFactory.ts:117:9 ❯ test/fromRpc.spec.ts:112:23

Check failure on line 137 in packages/tx/src/1559/tx.ts

View workflow job for this annotation

GitHub Actions / tx / test-tx

test/fromRpc.spec.ts > [fromJSONRPCProvider] > should work

Error: gasPrice cannot be defined on 1559 tx (tx type=2 hash=0xed1960aa7d0d7b567c946d94331dddb37a1c67f51f30bf51f256ea40db88cfb0 nonce=2 value=16941678280294901 signed=true hf=london maxFeePerGas=16141066326 maxPriorityFeePerGas=1000000000) ❯ new FeeMarket1559Tx src/1559/tx.ts:137:13 ❯ Module.createFeeMarket1559Tx src/1559/constructors.ts:23:10 ❯ createTx src/transactionFactory.ts:43:14 ❯ createTxFromRPC src/transactionFactory.ts:117:10 ❯ Module.createTxFromJSONRPCProvider src/transactionFactory.ts:140:10 ❯ test/fromRpc.spec.ts:60:16

Check failure on line 137 in packages/tx/src/1559/tx.ts

View workflow job for this annotation

GitHub Actions / tx / test-tx

test/fromRpc.spec.ts > [normalizeTxParams] > should work

Error: gasPrice cannot be defined on 1559 tx (tx type=2 hash=0xed1960aa7d0d7b567c946d94331dddb37a1c67f51f30bf51f256ea40db88cfb0 nonce=2 value=16941678280294901 signed=true hf=cancun maxFeePerGas=16141066326 maxPriorityFeePerGas=1000000000) ❯ new FeeMarket1559Tx src/1559/tx.ts:137:13 ❯ Module.createFeeMarket1559Tx src/1559/constructors.ts:23:10 ❯ Module.createTx src/transactionFactory.ts:43:14 ❯ test/fromRpc.spec.ts:80:16

Check failure on line 137 in packages/tx/src/1559/tx.ts

View workflow job for this annotation

GitHub Actions / tx / test-tx

test/fromRpc.spec.ts > fromRPC: interpret v/r/s values of 0x0 as undefined for Optimism system txs > should work

Error: gasPrice cannot be defined on 1559 tx (tx type=2 hash=not available (unsigned) nonce=316626 value=0 signed=false hf=cancun maxFeePerGas=0 maxPriorityFeePerGas=0) ❯ new FeeMarket1559Tx src/1559/tx.ts:137:13 ❯ Module.createFeeMarket1559Tx src/1559/constructors.ts:23:10 ❯ createTx src/transactionFactory.ts:43:14 ❯ Module.createTxFromRPC src/transactionFactory.ts:117:10 ❯ test/fromRpc.spec.ts:93:24

Check failure on line 137 in packages/tx/src/1559/tx.ts

View workflow job for this annotation

GitHub Actions / tx / test-tx

test/fromRpc.spec.ts > fromRPC: ensure `v="0x0"` is correctly decoded for signed txs > should work

Error: gasPrice cannot be defined on 1559 tx (tx type=2 hash=0xd2cdf63bb15eb4bbc655e4cca198c92305f2c6d057ac993ef6f7bacf1c518b2f nonce=697749 value=0 signed=true hf=cancun maxFeePerGas=1000018792 maxPriorityFeePerGas=1000018784) ❯ new FeeMarket1559Tx src/1559/tx.ts:137:13 ❯ Module.createFeeMarket1559Tx src/1559/constructors.ts:23:10 ❯ createTx src/transactionFactory.ts:43:14 ❯ Module.createTxFromRPC src/transactionFactory.ts:117:10 ❯ test/fromRpc.spec.ts:112:24
}
EIP2718.validateYParity(this)
Legacy.validateHighS(this)

Expand Down
5 changes: 0 additions & 5 deletions packages/tx/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -375,11 +375,6 @@ export interface AccessList2930TxData extends LegacyTxData {
* {@link FeeMarket1559Tx} data.
*/
export interface FeeMarketEIP1559TxData extends AccessList2930TxData {
/**
* The transaction's gas price, inherited from {@link Transaction}. This property is not used for EIP1559
* transactions and should always be undefined for this specific transaction type.
*/
gasPrice?: never | null
/**
* The maximum inclusion fee per gas (this fee is given to the miner)
*/
Expand Down
1 change: 0 additions & 1 deletion packages/tx/test/base.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,6 @@ describe('[BaseTransaction]', () => {
...txType.txs,
// add unsigned variants
...txType.txs.map((tx) =>
// @ts-ignore Not sure why this is now throwing
txType.create.txData({
...tx,
v: undefined,
Expand Down
3 changes: 3 additions & 0 deletions packages/tx/test/eip1559.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,5 +307,8 @@ describe('[FeeMarket1559Tx]', () => {
undefined,
'total fee must be the larger of the two',
)
assert.throws(() => {
createFeeMarket1559Tx({ gasPrice: 1 }, { common })
}, 'gasPrice cannot be defined on 1559 tx')
})
})

0 comments on commit 6a9b15e

Please sign in to comment.