@@ -2,9 +2,10 @@ import { RLP } from '@ethereumjs/rlp'
2
2
import { Trie } from '@ethereumjs/trie'
3
3
import {
4
4
type TxOptions ,
5
+ createTx ,
5
6
createTxFromBlockBodyData ,
6
- createTxFromSerializedData ,
7
- createTxFromTxData ,
7
+ createTxFromExecutionPayloadTx ,
8
+ createTxFromRLP ,
8
9
normalizeTxParams ,
9
10
} from '@ethereumjs/tx'
10
11
import {
@@ -25,7 +26,13 @@ import {
25
26
} from '@ethereumjs/util'
26
27
27
28
import { generateCliqueBlockExtraData } from '../consensus/clique.js'
28
- import { genRequestsTrieRoot , genTransactionsSszRoot , genTransactionsTrieRoot , genWithdrawalsSszRoot , genWithdrawalsTrieRoot } from '../helpers.js'
29
+ import {
30
+ genRequestsTrieRoot ,
31
+ genTransactionsSszRoot ,
32
+ genTransactionsTrieRoot ,
33
+ genWithdrawalsSszRoot ,
34
+ genWithdrawalsTrieRoot ,
35
+ } from '../helpers.js'
29
36
import {
30
37
Block ,
31
38
createBlockHeader ,
@@ -46,6 +53,7 @@ import type {
46
53
RequestsBytes ,
47
54
WithdrawalsBytes ,
48
55
} from '../types.js'
56
+ import type { Common } from '@ethereumjs/common'
49
57
import type { TypedTransaction } from '@ethereumjs/tx'
50
58
import type {
51
59
CLRequest ,
@@ -55,7 +63,6 @@ import type {
55
63
RequestBytes ,
56
64
WithdrawalBytes ,
57
65
} from '@ethereumjs/util'
58
- import type { Common } from '@ethereumjs/common'
59
66
60
67
/**
61
68
* Static constructor to create a block from a block data dictionary
@@ -78,7 +85,7 @@ export function createBlock(blockData: BlockData = {}, opts?: BlockOptions) {
78
85
// parse transactions
79
86
const transactions = [ ]
80
87
for ( const txData of txsData ?? [ ] ) {
81
- const tx = createTxFromTxData ( txData , {
88
+ const tx = createTx ( txData , {
82
89
...opts ,
83
90
// Use header common in case of setHardfork being activated
84
91
common : header . common ,
@@ -289,7 +296,7 @@ export function createBlockFromRPC(
289
296
const opts = { common : header . common }
290
297
for ( const _txParams of blockParams . transactions ?? [ ] ) {
291
298
const txParams = normalizeTxParams ( _txParams )
292
- const tx = createTxFromTxData ( txParams , opts )
299
+ const tx = createTx ( txParams , opts )
293
300
transactions . push ( tx )
294
301
}
295
302
@@ -374,7 +381,7 @@ export const createBlockFromJSONRPCProvider = async (
374
381
*/
375
382
export async function createBlockFromExecutionPayload (
376
383
payload : ExecutionPayload ,
377
- opts : BlockOptions & { common : Common } ,
384
+ opts : BlockOptions & { common : Common } ,
378
385
) : Promise < Block > {
379
386
const {
380
387
blockNumber : number ,
@@ -392,19 +399,19 @@ export async function createBlockFromExecutionPayload(
392
399
const txs = [ ]
393
400
for ( const [ index , serializedTxOrPayload ] of transactions . entries ( ) ) {
394
401
try {
395
- let tx ;
402
+ let tx
396
403
if ( opts . common . isActivatedEIP ( 6493 ) ) {
397
404
if ( typeof serializedTxOrPayload === 'string' ) {
398
405
throw Error ( 'EIP 6493 activated for transaction bytes' )
399
406
}
400
- tx = createTxFromExecutionPayloadTx ( hexToBytes ( serializedTxOrPayload ) , {
407
+ tx = createTxFromExecutionPayloadTx ( serializedTxOrPayload , {
401
408
common : opts ?. common ,
402
409
} )
403
- } else {
410
+ } else {
404
411
if ( typeof serializedTxOrPayload !== 'string' ) {
405
412
throw Error ( 'EIP 6493 not activated for transaction payload' )
406
413
}
407
- tx = createTxFromSerializedData ( hexToBytes ( serializedTxOrPayload as PrefixedHexString ) , {
414
+ tx = createTxFromRLP ( hexToBytes ( serializedTxOrPayload as PrefixedHexString ) , {
408
415
common : opts ?. common ,
409
416
} )
410
417
}
@@ -415,10 +422,14 @@ export async function createBlockFromExecutionPayload(
415
422
}
416
423
}
417
424
418
- const transactionsTrie = opts . common . isActivatedEIP ( 6493 ) ? await genTransactionsSszRoot ( txs ) : await genTransactionsTrieRoot ( txs , new Trie ( { common : opts ?. common } ) )
425
+ const transactionsTrie = opts . common . isActivatedEIP ( 6493 )
426
+ ? await genTransactionsSszRoot ( txs )
427
+ : await genTransactionsTrieRoot ( txs , new Trie ( { common : opts ?. common } ) )
419
428
const withdrawals = withdrawalsData ?. map ( ( wData ) => createWithdrawal ( wData ) )
420
429
const withdrawalsRoot = withdrawals
421
- ? opts . common . isActivatedEIP ( 6493 ) ? genWithdrawalsSszRoot ( withdrawals ) : await genWithdrawalsTrieRoot ( withdrawals , new Trie ( { common : opts ?. common } ) )
430
+ ? opts . common . isActivatedEIP ( 6493 )
431
+ ? genWithdrawalsSszRoot ( withdrawals )
432
+ : await genWithdrawalsTrieRoot ( withdrawals , new Trie ( { common : opts ?. common } ) )
422
433
: undefined
423
434
424
435
const hasDepositRequests = depositRequests !== undefined && depositRequests !== null
0 commit comments