Skip to content

Commit e12604d

Browse files
committed
debug rebase and spec fixes in tx utils
1 parent 4870acf commit e12604d

File tree

16 files changed

+170
-103
lines changed

16 files changed

+170
-103
lines changed

package-lock.json

Lines changed: 30 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/common/src/hardforks.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ export const hardforksDict: HardforksDict = {
164164
},
165165
/**
166166
* Description: Experimental hardfork to test eip 6493 for 6493 devnets will be removed(incomplete/experimental)
167-
* URL :
167+
* URL :
168168
* Status : Final
169169
*/
170170
eip6493: {

packages/tx/src/1559/constructors.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
import { RLP } from '@ethereumjs/rlp'
2-
import { bytesToBigInt, bytesToHex, equalsBytes, validateNoLeadingZeroes, ssz, bigIntToUnpaddedBytes } from '@ethereumjs/util'
2+
import {
3+
bigIntToUnpaddedBytes,
4+
bytesToBigInt,
5+
bytesToHex,
6+
equalsBytes,
7+
validateNoLeadingZeroes,
8+
} from '@ethereumjs/util'
39

410
import { TransactionType } from '../types.js'
511
import { txTypeBytes, validateNotArray } from '../util.js'
@@ -9,6 +15,7 @@ import { FeeMarket1559Tx } from './tx.js'
915
import type { TxOptions } from '../types.js'
1016
import type { TxData, TxValuesArray } from './tx.js'
1117
import type { ValueOf } from '@chainsafe/ssz'
18+
import type { ssz } from '@ethereumjs/util'
1219
export type Eip1559TransactionType = ValueOf<typeof ssz.Eip1559Transaction>
1320

1421
/**
@@ -101,7 +108,10 @@ export function createFeeMarket1559TxFromRLP(serialized: Uint8Array, opts: TxOpt
101108
return create1559FeeMarketTxFromBytesArray(values as TxValuesArray, opts)
102109
}
103110

104-
export function createFeeMarket1559TxFromSszTx(sszWrappedTx: Eip1559TransactionType, opts: TxOptions = {}) {
111+
export function createFeeMarket1559TxFromSszTx(
112+
sszWrappedTx: Eip1559TransactionType,
113+
opts: TxOptions = {},
114+
) {
105115
const {
106116
payload: {
107117
nonce,
@@ -137,6 +147,6 @@ export function createFeeMarket1559TxFromSszTx(sszWrappedTx: Eip1559TransactionT
137147
bigIntToUnpaddedBytes(r),
138148
bigIntToUnpaddedBytes(s),
139149
],
140-
opts
150+
opts,
141151
)
142-
}
152+
}

packages/tx/src/1559/tx.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@ import {
66
bigIntToHex,
77
bigIntToUnpaddedBytes,
88
bytesToBigInt,
9-
bytesToHex,
10-
equalsBytes,
119
setLengthLeft,
12-
ssz,
1310
toBytes,
1411
} from '@ethereumjs/util'
1512

@@ -24,7 +21,7 @@ import { AccessLists, validateNotArray } from '../util.js'
2421

2522
import { createFeeMarket1559Tx } from './constructors.js'
2623

27-
import type { SSZTransactionType } from './baseTransaction.js'
24+
import type { SSZTransactionType } from '../baseTransaction.js'
2825
import type {
2926
AccessList,
3027
AccessListBytes,

packages/tx/src/2930/constructors.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
import { RLP } from '@ethereumjs/rlp'
2-
import { bytesToBigInt, bytesToHex, equalsBytes, validateNoLeadingZeroes, bigIntToUnpaddedBytes, ssz } from '@ethereumjs/util'
2+
import {
3+
bigIntToUnpaddedBytes,
4+
bytesToBigInt,
5+
bytesToHex,
6+
equalsBytes,
7+
validateNoLeadingZeroes,
8+
} from '@ethereumjs/util'
39

410
import { TransactionType } from '../types.js'
511
import { txTypeBytes, validateNotArray } from '../util.js'
@@ -8,8 +14,8 @@ import { AccessList2930Transaction } from './tx.js'
814

915
import type { AccessList, TxOptions } from '../types.js'
1016
import type { TxData, TxValuesArray } from './tx.js'
11-
1217
import type { ValueOf } from '@chainsafe/ssz'
18+
import type { ssz } from '@ethereumjs/util'
1319
export type Eip2930TransactionType = ValueOf<typeof ssz.Eip2930Transaction>
1420

1521
/**
@@ -90,7 +96,10 @@ export function createAccessList2930TxFromRLP(serialized: Uint8Array, opts: TxOp
9096
return createAccessList2930TxFromBytesArray(values as TxValuesArray, opts)
9197
}
9298

93-
export function createAccessList2930TxFromSszTx(sszWrappedTx: Eip2930TransactionType, opts: TxOptions = {}) {
99+
export function createAccessList2930TxFromSszTx(
100+
sszWrappedTx: Eip2930TransactionType,
101+
opts: TxOptions = {},
102+
) {
94103
const {
95104
payload: {
96105
nonce,
@@ -123,6 +132,6 @@ export function createAccessList2930TxFromSszTx(sszWrappedTx: Eip2930Transaction
123132
bigIntToUnpaddedBytes(r),
124133
bigIntToUnpaddedBytes(s),
125134
] as TxValuesArray,
126-
opts
135+
opts,
127136
)
128137
}

packages/tx/src/2930/tx.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import {
66
bigIntToUnpaddedBytes,
77
bytesToBigInt,
88
setLengthLeft,
9-
ssz,
109
toBytes,
1110
} from '@ethereumjs/util'
1211

@@ -20,7 +19,7 @@ import { AccessLists, validateNotArray } from '../util.js'
2019

2120
import { createAccessList2930Tx } from './constructors.js'
2221

23-
import type { SSZTransactionType } from './baseTransaction.js'
22+
import type { SSZTransactionType } from '../baseTransaction.js'
2423
import type {
2524
AccessList,
2625
AccessListBytes,

packages/tx/src/4844/constructors.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { RLP } from '@ethereumjs/rlp'
22
import {
33
bigIntToHex,
4+
bigIntToUnpaddedBytes,
45
blobsToCommitments,
56
blobsToProofs,
67
bytesToBigInt,
@@ -24,7 +25,10 @@ import type {
2425
TxOptions,
2526
} from '../types.js'
2627
import type { TxData, TxValuesArray } from './tx.js'
27-
import type { Kzg } from '@ethereumjs/util'
28+
import type { ValueOf } from '@chainsafe/ssz'
29+
import type { Kzg, ssz } from '@ethereumjs/util'
30+
31+
export type Eip4844TransactionType = ValueOf<typeof ssz.Eip4844Transaction>
2832

2933
const validateBlobTransactionNetworkWrapper = (
3034
blobVersionedHashes: Uint8Array[],
@@ -330,7 +334,10 @@ export function blobTxNetworkWrapperToJSON(
330334
}
331335
}
332336

333-
export function createBlob4844TxFromSszTx(sszWrappedTx: Eip4844TransactionType, opts: TxOptions = {}) {
337+
export function createBlob4844TxFromSszTx(
338+
sszWrappedTx: Eip4844TransactionType,
339+
opts: TxOptions = {},
340+
) {
334341
const {
335342
payload: {
336343
nonce,
@@ -368,6 +375,6 @@ export function createBlob4844TxFromSszTx(sszWrappedTx: Eip4844TransactionType,
368375
bigIntToUnpaddedBytes(r),
369376
bigIntToUnpaddedBytes(s),
370377
],
371-
opts
378+
opts,
372379
)
373380
}

packages/tx/src/4844/tx.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ import {
77
bigIntToUnpaddedBytes,
88
bytesToBigInt,
99
bytesToHex,
10-
toBytes,
1110
setLengthLeft,
11+
toBytes,
1212
} from '@ethereumjs/util'
1313

14-
import { BaseTransaction, SSZTransactionType } from '../baseTransaction.js'
14+
import { BaseTransaction } from '../baseTransaction.js'
1515
import * as EIP1559 from '../capabilities/eip1559.js'
1616
import * as EIP2718 from '../capabilities/eip2718.js'
1717
import * as EIP2930 from '../capabilities/eip2930.js'
@@ -23,6 +23,7 @@ import { AccessLists, validateNotArray } from '../util.js'
2323

2424
import { createBlob4844Tx } from './constructors.js'
2525

26+
import type { SSZTransactionType } from '../baseTransaction.js'
2627
import type {
2728
AccessList,
2829
AccessListBytes,

packages/tx/src/7702/tx.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
toBytes,
1010
} from '@ethereumjs/util'
1111

12-
import { BaseTransaction, SSZTransactionType } from '../baseTransaction.js'
12+
import { BaseTransaction } from '../baseTransaction.js'
1313
import * as EIP1559 from '../capabilities/eip1559.js'
1414
import * as EIP2718 from '../capabilities/eip2718.js'
1515
import * as EIP7702 from '../capabilities/eip7702.js'
@@ -20,6 +20,7 @@ import { AccessLists, AuthorizationLists, validateNotArray } from '../util.js'
2020

2121
import { createEOACode7702Tx } from './constructors.js'
2222

23+
import type { SSZTransactionType } from '../baseTransaction.js'
2324
import type {
2425
AccessList,
2526
AccessListBytes,
@@ -185,7 +186,7 @@ export class EOACode7702Transaction extends BaseTransaction<TransactionType.EOAC
185186
}
186187

187188
sszRaw(): SSZTransactionType {
188-
throw Error("not implemented")
189+
throw Error('not implemented')
189190
}
190191
/**
191192
* Returns the serialized encoding of the EIP-7702 transaction.

packages/tx/src/legacy/constructors.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import { RLP } from '@ethereumjs/rlp'
2-
import { validateNoLeadingZeroes, bytesToBigInt, ssz, BIGINT_2 } from '@ethereumjs/util'
2+
import { BIGINT_2, bytesToBigInt, validateNoLeadingZeroes } from '@ethereumjs/util'
33

44
import { LegacyTx } from './tx.js'
55

66
import type { TxOptions } from '../types.js'
77
import type { TxData, TxValuesArray } from './tx.js'
88
import type { ValueOf } from '@chainsafe/ssz'
9+
import type { ssz } from '@ethereumjs/util'
910

1011
export type ReplayableTransactionType = ValueOf<typeof ssz.ReplayableTransaction>
1112
export type LegacyTransactionType = ValueOf<typeof ssz.LegacyTransaction>
@@ -74,7 +75,7 @@ export function createLegacyTxFromRLP(serialized: Uint8Array, opts: TxOptions =
7475

7576
export function createLegacyTxFromSszTx(
7677
sszWrappedTx: ReplayableTransactionType | LegacyTransactionType,
77-
opts: TxOptions = {}
78+
opts: TxOptions = {},
7879
) {
7980
const {
8081
payload: {
@@ -97,11 +98,11 @@ export function createLegacyTxFromSszTx(
9798
if (chainId !== null && chainId !== undefined) {
9899
v = yParity + BIGINT_2 * chainId + BigInt(35)
99100
} else {
100-
v = yParity
101+
v = yParity + BigInt(27)
101102
}
102103

103104
return createLegacyTxFromBytesArray(
104105
[nonce, gasPrice, gasLimit, to, value, data, v, r, s] as TxValuesArray,
105-
opts
106+
opts,
106107
)
107-
}
108+
}

0 commit comments

Comments
 (0)