Skip to content

Commit 7b4f2c1

Browse files
committed
Added EIP-4844 fields to Provider classes and formatter (#4570).
1 parent f1666f1 commit 7b4f2c1

File tree

5 files changed

+291
-21
lines changed

5 files changed

+291
-21
lines changed

src.ts/_tests/blockchain-data.ts

Lines changed: 177 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export type TestBlockchainNetwork =
2-
"mainnet" | "goerli";
2+
"mainnet" | "goerli" | "sepolia";
33

44
export interface TestBlockchainAddress {
55
test: string;
@@ -13,19 +13,21 @@ export interface TestBlockchainAddress {
1313

1414
export interface TestBlockchainBlock {
1515
test: string;
16-
hash: string,
17-
parentHash: string,
18-
number: number,
19-
timestamp: number,
20-
nonce: string,
21-
difficulty: bigint,
22-
gasLimit: bigint,
23-
gasUsed: bigint,
24-
miner: string,
25-
extraData: string,
26-
transactions: Array<string>,
16+
hash: string;
17+
parentHash: string;
18+
number: number;
19+
timestamp: number;
20+
nonce: string;
21+
difficulty: bigint;
22+
gasLimit: bigint;
23+
gasUsed: bigint;
24+
miner: string;
25+
extraData: string;
26+
transactions: Array<string>;
2727

28-
baseFeePerGas?: bigint
28+
baseFeePerGas?: bigint;
29+
blobGasUsed?: bigint;
30+
excessBlobGas?: bigint;
2931
}
3032

3133
export interface TestBlockchainTransaction {
@@ -46,7 +48,7 @@ export interface TestBlockchainTransaction {
4648
r: string,
4749
s: string,
4850
yParity: 0 | 1,
49-
v: number,
51+
v?: number,
5052
networkV: null | bigint,
5153
},
5254
creates: null | string,
@@ -56,6 +58,8 @@ export interface TestBlockchainTransaction {
5658

5759
maxPriorityFeePerGas?: bigint,
5860
maxFeePerGas?: bigint
61+
maxFeePerBlobGas?: bigint;
62+
blobVersionedHashes?: Array<string>
5963
}
6064

6165
export interface TestBlockchainReceipt {
@@ -84,7 +88,10 @@ export interface TestBlockchainReceipt {
8488
status: null | number,
8589
to: string,
8690
hash: string,
87-
index: number
91+
index: number;
92+
93+
blobGasUsed?: bigint;
94+
blobGasPrice?: bigint;
8895
};
8996

9097
export const testAddress: Record<TestBlockchainNetwork, Array<TestBlockchainAddress>> = {
@@ -109,6 +116,8 @@ export const testAddress: Record<TestBlockchainNetwork, Array<TestBlockchainAddr
109116
},
110117
],
111118
goerli: [
119+
],
120+
sepolia: [
112121
]
113122
};
114123

@@ -174,6 +183,100 @@ export const testBlock: Record<TestBlockchainNetwork, Array<TestBlockchainBlock>
174183
],
175184
goerli: [
176185
],
186+
sepolia: [
187+
{
188+
test: "eip-4844-BLob-block",
189+
hash: "0xa76eb2ed547798d6010f599902788136f0cd289e2c6df5bbf5242e36e356124d",
190+
parentHash: "0x2b579cb7224abdbe7a66c76380d60329bba41d95d225feb80ca1a78cf83a5124",
191+
number: 5198187,
192+
timestamp: 1706801700,
193+
nonce: "0x0000000000000000",
194+
difficulty: BigInt(0),
195+
gasLimit: BigInt("30000000"),
196+
gasUsed: BigInt("5622957"),
197+
baseFeePerGas: BigInt("48793932840"),
198+
miner: "0x008b3b2F992C0E14eDaa6E2c662Bec549CAA8df1",
199+
extraData: "0x",
200+
blobGasUsed: BigInt("524288"),
201+
excessBlobGas: BigInt("79691776"),
202+
transactions: [
203+
"0xe8a096a98cd7b8d783cbb30687c3adc8e59f1e9563c0454623cc8af59f8bcab1",
204+
"0x5aac2d50b15e177e8edaae4819e989650a6cdb335dd8924b5a7a7ed1675d15e7",
205+
"0x21c94c24419f746efd2c1f470c0842df21ab8da14f7db8e30a12c53a4e7d5145",
206+
"0x85b40ce37262a7962487bd37bf36867b344525b425a90a25516ac3c2cb1f6535",
207+
"0x1a674ff3bd6bbe7bc7ada2ae3da893a7b74b4cfaadebc8c3f0fe0c9ad3c1c35b",
208+
"0x48cafe99a7d2284a1664e05c404dd88e4113ffb65bf49846716bd855ffc6835d",
209+
"0x658065003e8952782d121d9b5729845862c2a45ed24e46c634041a77c4577bed",
210+
"0xc5416e0a2383b1a9b3ba030803f88e45faebfb35ad5db022e44a09b15aeae385",
211+
"0x9030f7962f3f638f96bb703f45cdaa8778cf393ead767592aa50bce32230eae3",
212+
"0xce008888308a4c1d51f87a1c2a75b1d0bd15eb096c675ad091dcc9705e4d016d",
213+
"0xcf17c1f09a22c992a469da0023ad3c9bd2c29a8532146bcdf9ce3216609ea50c",
214+
"0x3933e49a215c80b35ec7d48e2741fda50c8cc7b92652e79663e4423c00e8e1e2",
215+
"0x82b2af4ed108880c151ee38cb3ab28e81ba86a2b0e707dd9cee9bf341f895a8a",
216+
"0x51ef5af42d572d6135bec154d5c754928465bad00d1ff7b769a5b65e0054a90e",
217+
"0x87cab3ae3a36d439a539ded7eb57e0ef07c5a1fbe1697c2e5ba8d7c03875fd22",
218+
"0x70371a20dfbff0ee753b52cd9445f431454b929c7375624a96f5dbc25e88afed",
219+
"0x57ee8a4a09875b7720f7d9e75fb93a1cc86d166ad9a1b4c2d7cf2c7c8324fbc0",
220+
"0xf004bd2b0119aca5f364b16421a5b2e7db811568761f5542fdcd74903cd9115d",
221+
"0x5b6635688362651e1cd33c668bd748d964ba93006661e53dc117d1c1e44886a5",
222+
"0xe5893e07bfec18dd206da279a47ee5cc9471930bbb3b85d64ee4945b98137348",
223+
"0x4f0f48032a77a80550f71cbcbe86f7d1b34009910f12dbe153a93cb66965393e",
224+
"0x5420c3f7b5118e0829df31794aa55a1a91e0009600bbff283b553d5ac7a248ff",
225+
"0xece2175e4b06bf6105f5be10a9ed48808a5f96f12f80b3941ee7cb1eeca99e03",
226+
"0x383ea6445cd183e32fbc7b846c00b34c419078fe4055cd078f8692fc02b300c8",
227+
"0x6c4aef4c26410b1fcbf24d0148e3d66a10cb3e9ad4ca10a71782489688cdd45a",
228+
"0xe7e24b8c8182832e7b1113cd07ae68e4ca8618decdc527650f57d25d0b681fde",
229+
"0xef5f520662c133be33209249fbc93afb7c614c06a0b45086d15c33bd7c0ca47a",
230+
"0x4af20dc2e952e381789065f2cd0c88730fea820bcc3db82eaddf63b36e65b3ac",
231+
"0xf99eef2240abc5002c9d71a90ffd463935642aaf81213f37337327c1afcb502c",
232+
"0xf7d1ad53e2435e6d978563e39db89660d1b4de6084a3a3cefe7025d28507017f",
233+
"0xfc21e64a158ac26ea9afc754460e16fefc4316a3fb92ec9a6042b792d7855788",
234+
"0xee60e551bcf518853ef4f5c33551ad07fa95267814940c4203934c79355b1ac0",
235+
"0x2a3c649caf77b942b206b9eb1be4635d950cf9a15fea2b43d3d7cbeddf700739",
236+
"0xbbd7b9c1434eb98d177f2ff8911b0186309534dea942c40a86517d69247cd0ac",
237+
"0xd86daa6d16e2aee4fc6ae831336ada63623685fb998dc5c605284a034604d751",
238+
"0xcfc848dfbbbe76fe0095f04ef35c931799c294eb3623e5cb8c0d81362e8bf125",
239+
"0x71e3ea97c91bd14388d99d69d122314a1cf0d595cbad1e45040277b470c4e67b",
240+
"0xa9b2e44e46d38bb67cbd7a2d47d57e60892dff018f7754b54a221ae3f1b996c4",
241+
"0xd1b8f9d669bd7f5072a095476e94e90510f2a18b434551fb7852b5c38c41471a",
242+
"0xa3858e80680997080fddde083398e857b14cd4e2cfe74629f6a1245df0447efb",
243+
"0x97593f663b07f8a4555202abb691cf7997210284195c24980abee02040c60618",
244+
"0x03387f22b01919486338fbd874dd7059f8df62d5b16052cb0ab855b6a364777e",
245+
"0xf2561f5f487c3d20c42b42e697a49fb5d05e0fb844ca97b2f127b210475f457e",
246+
"0xa67951a1309f1c7ec07ee518ecad831d12c5c78619250681068e7973243f7d9b",
247+
"0x7b007997da62b3ac9e5a7005066941e74f5c14d0bdaf4ac44faa8c3479b3cf45",
248+
"0x74379408aa3518cbbb394886c91f77ba95ccd37f6b10517834f69a8ff5120ca7",
249+
"0xd4843ef02a0d9802d31a89e13e60b6e71870de9124d0b472047012f7a4320f83",
250+
"0xaa50331afeafd8f9e913a9f78e898e299314d0825936724cc31211ebf177a9bf",
251+
"0xf20c83f2e5d199ad84a7b5dc6fda9611772516e07e7fc71b9f7889af4f2a16aa",
252+
"0x89a7c645987dc079ce1af236ed3dd445ad805cc030e5a57766324d4a0a1def9a",
253+
"0xe8e7d1116c2c60afd063b9c1e87624426cf6c9fd8d3fa6befe25666e68459570",
254+
"0x50be079e71cabf80ca27c39a27f9c0759ac272151f4608b9b75ebfac8284a601",
255+
"0xca24f69d47438ebd0b8f304f2f6d7a513d056905f10b164ed6a2cff6da1d4fea",
256+
"0x08d2521e04dfd0decc2f556b11274212e84076ff84a0135e9b4e3434de09d42a",
257+
"0xcc1e01932a627e9aa20d2b72480d13b4826e128efbbe03526504f7cb9facfc1f",
258+
"0x0a3ac907b6d1584cb3d7f9f588ddb4bdd7878db34bc47bd8baf881dd71a98f7d",
259+
"0x487539ee9cc6933e13e75e94935c30faffa826c28460fed6d9c3a07d15e2617f",
260+
"0xad251856762796acc75dc2846def1f6995fe1b5c747bcab51c10f561d22ffd57",
261+
"0x27ca72aa253e009e5e4497dd838986c561e7bea129fec930bc276968525456a8",
262+
"0xe26391de668d3eb6f5a3c2f3e14f911dc683873b7ea60d883116c205610b36ff",
263+
"0x691c3c5583c5f6444dc6c2f26315a127fc72ebd4f3848055cc8abb8a941d065b",
264+
"0x449578293a1dce8d3c147fed564a765515d090e8cd8866209648eb86cd5c1090",
265+
"0xb79c6f59d533663ca4fa3a70e9c8be18a3761edc43923c2ecd0904447f654f90",
266+
"0xc03863ffa85dd15e0d774ea20006dffd01a868dbf3ff2abe04ccdbf4f027d7ec",
267+
"0x28bc1a65696947beb387adbbeabb5328e5f812c435db288688041d9a8c6ab372",
268+
"0x6dca99c2103d3894ba83c75e0fa0d42f722e5e93fe6f7a6a55a80cf2907a1a5e",
269+
"0x75a7c5f00d79f1b30f82855a8b25077182f1abfd5dbccdf18fe1276e6c9e6a1e",
270+
"0x3fc5a320d8c16bcfe2eda847582d34731abc12a3bffbf334a238b47c0bacb90d",
271+
"0x47a61770f0771ba34d8e8ab883a3d588769a8d387eb5531b4befccb7ea23a6d3",
272+
"0xdc8d0b20e8d8b0fbce50d24eaa36bc56467f35459139dda5e42ffebb1060535c",
273+
"0x65bebb9628b5bf5d5e1dbedf00a7e6610fb5615c7ff9d92adaa135bc88f90648",
274+
"0x9d2f5b7858631ee196bc24d14d2ef1ce07af081d8fe27b2be70ab90bd8edf930",
275+
"0xd7724915af54b4d2c896d05c039f5ba508c878d524eb132c09c3abc22f6111ca",
276+
"0xfda6f72dde86c0b8f84ea7c1e157f1d207dd2e974589cc351404bd5a01fe1d9d",
277+
"0x3fae3676e266af80b0cc810b6b491750b64b013da78935a288b93e33215bee32" ]
278+
},
279+
],
177280
};
178281

179282
export const testTransaction: Record<TestBlockchainNetwork, Array<TestBlockchainTransaction>> = {
@@ -231,6 +334,41 @@ export const testTransaction: Record<TestBlockchainNetwork, Array<TestBlockchain
231334
}
232335
],
233336
goerli: [
337+
],
338+
sepolia: [
339+
{
340+
test: "EIP-4844-BLOb-tx",
341+
hash: "0x6c4aef4c26410b1fcbf24d0148e3d66a10cb3e9ad4ca10a71782489688cdd45a",
342+
blockHash: '0xa76eb2ed547798d6010f599902788136f0cd289e2c6df5bbf5242e36e356124d',
343+
blockNumber: 5198187,
344+
// index: 185,
345+
type: 3,
346+
from: '0x1803c760451DC8da8935c7B7E47e1c60910E6986',
347+
to: '0x4f56fFC63c28b72F79b02E91F11a4707bac4043C',
348+
gasLimit: BigInt("21000"),
349+
nonce: 1635,
350+
data: '0x',
351+
value: BigInt("0"),
352+
gasPrice: BigInt("54793932840"),
353+
maxPriorityFeePerGas: BigInt("6000000000"),
354+
maxFeePerGas: BigInt("600000000000"),
355+
maxFeePerBlobGas: BigInt("60000000000"),
356+
chainId: BigInt(11155111),
357+
signature: {
358+
r: "0x56fc10a770e9fa39a30f71a56d13affbdc390a1bfb419ff806e59b54bfc8bab1",
359+
s: "0x35be8b0c774c179520dd43df46925361c4817472441d7dd5162d43efc90679f1",
360+
yParity: 1,
361+
networkV: null
362+
},
363+
creates: null,
364+
accessList: [ ],
365+
blobVersionedHashes: [
366+
"0x010264a7b018f0edbe5caa5cb309ca50d3d7c6c7c990d21bf30a7f18ffd06cd6",
367+
"0x017fe9ef61e3c501acec804ec15849d977433f4cf87050c098272dd1257f9c68",
368+
"0x019975416c9d7c70ba9cc041464a6e1c3e4f176bdab463573504b55c681364c8",
369+
"0x0123ae55ad7d8e8afec2202bdc6dfb931efc8990acf29afbd0c3c0ef61eae92d"
370+
]
371+
}
234372
]
235373
};
236374

@@ -319,11 +457,34 @@ export const testReceipt: Record<TestBlockchainNetwork, Array<TestBlockchainRece
319457
}
320458
],
321459
goerli: [
460+
],
461+
sepolia: [
462+
{
463+
test: "eip-4844-BLOb-receipt",
464+
//byzantium: true,
465+
blockHash: "0xa76eb2ed547798d6010f599902788136f0cd289e2c6df5bbf5242e36e356124d",
466+
blockNumber: 5198187,
467+
type: 3,
468+
contractAddress: null,
469+
cumulativeGasUsed: BigInt("930313"),
470+
from: "0x1803c760451DC8da8935c7B7E47e1c60910E6986",
471+
gasUsed: BigInt("21000"),
472+
gasPrice: BigInt("54793932840"),
473+
logs: [ ],
474+
logsBloom: "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
475+
root: null,
476+
status: 1,
477+
to: "0x4f56fFC63c28b72F79b02E91F11a4707bac4043C",
478+
hash: "0x6c4aef4c26410b1fcbf24d0148e3d66a10cb3e9ad4ca10a71782489688cdd45a",
479+
index: 24,
480+
blobGasUsed: BigInt("524288"),
481+
blobGasPrice: BigInt("23276216517"),
482+
}
322483
]
323484
};
324485

325486
export const networkNames: Array<TestBlockchainNetwork> = [
326-
"mainnet", "goerli"
487+
"mainnet", "goerli", "sepolia"
327488
];
328489
export function networkFeatureAtBlock(feature: string, block: number): boolean {
329490
switch (feature) {

src.ts/_tests/test-providers-data.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,23 @@ describe("Test Provider Address operations", function() {
109109

110110
function assertObj(prefix: string, actual: any, expected: any): void {
111111
assert.ok(actual != null, `${ prefix } is null`);
112+
113+
if (typeof(expected) !== "object") {
114+
assert.equal(actual, expected, prefix);
115+
return;
116+
}
117+
112118
for (const key in expected) {
113119
if (expected[key] === undefined) { continue; }
114-
assert.equal(actual[key], expected[key], `${ prefix }.${ key }`);
120+
if (Array.isArray(expected[key])) {
121+
assert.ok(Array.isArray(actual[key]), `Array.isArray(${ prefix }.${ key })`);
122+
assert.equal(actual[key].length, expected[key].length, `${ prefix }.${ key }.length`);
123+
for (let i = 0; i < expected[key].length; i++) {
124+
assertObj(`${ prefix }[${ i }]`, actual[key][i], expected[key][i]);
125+
}
126+
} else {
127+
assert.equal(actual[key], expected[key], `${ prefix }.${ key }`);
128+
}
115129
}
116130
}
117131

@@ -252,6 +266,7 @@ describe("Test Networks", function() {
252266
if (provider == null || !(provider instanceof JsonRpcProvider)) { continue; }
253267

254268
it(`checks network chainId: ${ providerName }/${ networkName }`, async function() {
269+
this.timeout(10000);
255270
const chainId = await provider.send("eth_chainId", [ ]);
256271
assert.equal(parseInt(chainId), network.chainId, "chainId");
257272
});

src.ts/providers/format.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@ export function allowNull(format: FormatFunc, nullValue?: any): FormatFunc {
2626
});
2727
}
2828

29-
export function arrayOf(format: FormatFunc): FormatFunc {
29+
export function arrayOf(format: FormatFunc, allowNull?: boolean): FormatFunc {
3030
return ((array: any) => {
31+
if (allowNull && array == null) { return null; }
3132
if (!Array.isArray(array)) { throw new Error("not an array"); }
3233
return array.map((i) => format(i));
3334
});
@@ -119,6 +120,9 @@ const _formatBlock = object({
119120
gasLimit: getBigInt,
120121
gasUsed: getBigInt,
121122

123+
blobGasUsed: allowNull(getBigInt, null),
124+
excessBlobGas: allowNull(getBigInt, null),
125+
122126
miner: allowNull(getAddress),
123127
extraData: formatData,
124128

@@ -159,6 +163,7 @@ const _formatTransactionReceipt = object({
159163
index: getNumber,
160164
root: allowNull(hexlify),
161165
gasUsed: getBigInt,
166+
blobGasUsed: allowNull(getBigInt, null),
162167
logsBloom: allowNull(formatData),
163168
blockHash: formatHash,
164169
hash: formatHash,
@@ -167,6 +172,7 @@ const _formatTransactionReceipt = object({
167172
//confirmations: allowNull(getNumber, null),
168173
cumulativeGasUsed: getBigInt,
169174
effectiveGasPrice: allowNull(getBigInt),
175+
blobGasPrice: allowNull(getBigInt, null),
170176
status: allowNull(getNumber),
171177
type: allowNull(getNumber, 0)
172178
}, {
@@ -195,6 +201,7 @@ export function formatTransactionResponse(value: any): TransactionResponseParams
195201
return getNumber(value);
196202
},
197203
accessList: allowNull(accessListify, null),
204+
blobVersionedHashes: allowNull(arrayOf(formatHash, true), null),
198205

199206
blockHash: allowNull(formatHash, null),
200207
blockNumber: allowNull(getNumber, null),
@@ -208,6 +215,7 @@ export function formatTransactionResponse(value: any): TransactionResponseParams
208215
gasPrice: allowNull(getBigInt),
209216
maxPriorityFeePerGas: allowNull(getBigInt),
210217
maxFeePerGas: allowNull(getBigInt),
218+
maxFeePerBlobGas: allowNull(getBigInt, null),
211219

212220
gasLimit: getBigInt,
213221
to: allowNull(getAddress, null),

0 commit comments

Comments
 (0)