Skip to content

Commit 5bd2ce9

Browse files
committed
Added transactionsRoot to Block (#5077, #5078).
1 parent 0e53d1b commit 5bd2ce9

File tree

4 files changed

+18
-2
lines changed

4 files changed

+18
-2
lines changed

src.ts/_tests/blockchain-data.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export interface TestBlockchainBlock {
3232
parentBeaconBlockRoot?: string;
3333
stateRoot?: string;
3434
receiptsRoot?: string;
35+
transactionsRoot?: string;
3536
}
3637

3738
export interface TestBlockchainTransaction {
@@ -141,6 +142,7 @@ export const testBlock: Record<TestBlockchainNetwork, Array<TestBlockchainBlock>
141142
extraData: "0x476574682f76312e302e302d66633739643332642f6c696e75782f676f312e34",
142143
stateRoot: '0x76ab0b899e8387436ff2658e2988f83cbf1af1590b9fe9feca3714f8d1824940',
143144
receiptsRoot: '0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421',
145+
transactionsRoot: '0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421',
144146
transactions: [ ]
145147
},
146148
{
@@ -158,6 +160,7 @@ export const testBlock: Record<TestBlockchainNetwork, Array<TestBlockchainBlock>
158160
baseFeePerGas: BigInt("40911884304"),
159161
stateRoot: '0xd08663f630cfcf2d7d8fe4d52f7685ad09798b7e6150cabea5eeceb1d89e11c2',
160162
receiptsRoot: '0x473e83ec3df279f44c4fc6da50fe1d0c5a18f1929b90de8917bdcdb88a132750',
163+
transactionsRoot: '0xa3fceebbe1f63ba17026d95ac10bc8e466049845efc7f26fcea1cab819d9aec3',
161164
transactions: [
162165
"0x1c3a398933db10634631f54b435c40c8805c13f12bbac7c3dab858ca44213fa2",
163166
"0xd98947cbdd892cc7f679c903903e6d18a5c5afb19e94437beba79372ad71c347",
@@ -210,6 +213,7 @@ export const testBlock: Record<TestBlockchainNetwork, Array<TestBlockchainBlock>
210213
excessBlobGas: BigInt("79691776"),
211214
stateRoot: '0xa78ad0e0f5d2b3383fdb13f4ad0523723816863556be3a5414536862f4d217df',
212215
receiptsRoot: '0xa254ed337328248b77011c70c2b85d6575f965f2fe65ed233c27e3750c0b7170',
216+
transactionsRoot: '0x7a680941fd602a5ecfff7cf8294e588d02d6e572c0ef57988df2a55179108372',
213217
transactions: [
214218
"0xe8a096a98cd7b8d783cbb30687c3adc8e59f1e9563c0454623cc8af59f8bcab1",
215219
"0x5aac2d50b15e177e8edaae4819e989650a6cdb335dd8924b5a7a7ed1675d15e7",

src.ts/providers/format.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ const _formatBlock = object({
125125

126126
stateRoot: allowNull(formatHash, null),
127127
receiptsRoot: allowNull(formatHash, null),
128+
transactionsRoot: allowNull(formatHash, null),
128129

129130
blobGasUsed: allowNull(getBigInt, null),
130131
excessBlobGas: allowNull(getBigInt, null),

src.ts/providers/formatting.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,11 @@ export interface BlockParams {
111111
*/
112112
receiptsRoot?: null | string;
113113

114+
/**
115+
* The hash of the transactions.
116+
*/
117+
transactionsRoot?: null | string;
118+
114119
/**
115120
* The list of transactions in the block.
116121
*/

src.ts/providers/provider.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,11 @@ export class Block implements BlockParams, Iterable<string> {
549549
*/
550550
readonly receiptsRoot!: null | string;
551551

552+
/**
553+
* The hash of the transactions.
554+
*/
555+
readonly transactionsRoot!: null | string;
556+
552557
/**
553558
* The total amount of blob gas consumed by the transactions
554559
* within the block. See [[link-eip-4844]].
@@ -630,6 +635,7 @@ export class Block implements BlockParams, Iterable<string> {
630635

631636
stateRoot: block.stateRoot,
632637
receiptsRoot: block.receiptsRoot,
638+
transactionsRoot: block.transactionsRoot,
633639
});
634640
}
635641

@@ -673,7 +679,7 @@ export class Block implements BlockParams, Iterable<string> {
673679
const {
674680
baseFeePerGas, difficulty, extraData, gasLimit, gasUsed, hash,
675681
miner, prevRandao, nonce, number, parentHash, parentBeaconBlockRoot,
676-
stateRoot, receiptsRoot, timestamp, transactions
682+
stateRoot, receiptsRoot, transactionsRoot, timestamp, transactions
677683
} = this;
678684

679685
return {
@@ -686,7 +692,7 @@ export class Block implements BlockParams, Iterable<string> {
686692
blobGasUsed: toJson(this.blobGasUsed),
687693
excessBlobGas: toJson(this.excessBlobGas),
688694
hash, miner, prevRandao, nonce, number, parentHash, timestamp,
689-
parentBeaconBlockRoot, stateRoot, receiptsRoot,
695+
parentBeaconBlockRoot, stateRoot, receiptsRoot, transactionsRoot,
690696
transactions,
691697
};
692698
}

0 commit comments

Comments
 (0)