Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit aa09462

Browse files
schaablefvictorio
andauthored
Prague support (NomicFoundation#6223)
* feat: replace forked ethereumjs packages with originals * feat: replace forked ethereumjs packages with originals in hardhat-ledger * feat: add prague to supported hardforks * feat: add prague to chains map * feat: add prague to edr mappings * feat: add authorization list and sign type 4 tx * Convert Prague hardfork to EDR's SpecId * feat: update EDR * feat: fix TODOs in convertToEdr * feat: signing with micro-eth-signer * docs: add changeset * fix: remove log message * fix: remove log messages * refactor: improve clarity and add tests --------- Co-authored-by: Franco Victorio <[email protected]>
1 parent dfcba6f commit aa09462

File tree

42 files changed

+443
-1006
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+443
-1006
lines changed

.changeset/fuzzy-paws-explain.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@nomicfoundation/hardhat-ledger": minor
3+
"hardhat": minor
4+
---
5+
6+
Add support for the Prague hardfork

docs/src/content/hardhat-network/docs/reference/index.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
- merge
1515
- shanghai
1616
- cancun
17+
- prague
1718

1819
## Config
1920

@@ -66,7 +67,7 @@ The block gas limit to use in Hardhat Network's blockchain. Default value: `30_0
6667

6768
#### `hardfork`
6869

69-
This setting changes how Hardhat Network works, to mimic Ethereum's mainnet at a given hardfork. It must be one of `"byzantium"`, `"constantinople"`, `"petersburg"`, `"istanbul"`, `"muirGlacier"`, `"berlin"`, `"london"`, `"arrowGlacier"`, `"grayGlacier"`, `"merge"`, `"shanghai"` and `"cancun"`. Default value: `"cancun"`
70+
This setting changes how Hardhat Network works, to mimic Ethereum's mainnet at a given hardfork. It must be one of `"byzantium"`, `"constantinople"`, `"petersburg"`, `"istanbul"`, `"muirGlacier"`, `"berlin"`, `"london"`, `"arrowGlacier"`, `"grayGlacier"`, `"merge"`, `"shanghai"`, `"cancun"` and `"prague"`. Default value: `"cancun"`
7071

7172
#### `throwOnTransactionFailures`
7273

packages/hardhat-core/package.json

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@
5959
"devDependencies": {
6060
"@nomicfoundation/eslint-plugin-hardhat-internal-rules": "workspace:^",
6161
"@nomicfoundation/eslint-plugin-slow-imports": "workspace:^",
62-
"@nomicfoundation/ethereumjs-block": "5.0.4",
6362
"@types/async-eventemitter": "^0.2.1",
6463
"@types/bn.js": "^5.1.0",
6564
"@types/chai": "^4.2.0",
@@ -98,12 +97,9 @@
9897
"typescript": "~5.0.0"
9998
},
10099
"dependencies": {
100+
"@ethereumjs/util": "^9.1.0",
101101
"@ethersproject/abi": "^5.1.2",
102-
"@metamask/eth-sig-util": "^4.0.0",
103102
"@nomicfoundation/edr": "^0.10.0",
104-
"@nomicfoundation/ethereumjs-common": "4.0.4",
105-
"@nomicfoundation/ethereumjs-tx": "5.0.4",
106-
"@nomicfoundation/ethereumjs-util": "9.0.4",
107103
"@nomicfoundation/solidity-analyzer": "^0.1.0",
108104
"@sentry/node": "^5.18.1",
109105
"@types/bn.js": "^5.1.0",
@@ -118,7 +114,6 @@
118114
"enquirer": "^2.3.0",
119115
"env-paths": "^2.2.0",
120116
"ethereum-cryptography": "^1.0.3",
121-
"ethereumjs-abi": "^0.6.8",
122117
"find-up": "^5.0.0",
123118
"fp-ts": "1.19.3",
124119
"fs-extra": "^7.0.1",
@@ -127,6 +122,7 @@
127122
"json-stream-stringify": "^3.1.4",
128123
"keccak": "^3.0.2",
129124
"lodash": "^4.17.11",
125+
"micro-eth-signer": "^0.14.0",
130126
"mnemonist": "^0.38.0",
131127
"mocha": "^10.0.0",
132128
"p-map": "^4.0.0",

packages/hardhat-core/src/builtin-tasks/node.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type EthereumjsUtilT from "@nomicfoundation/ethereumjs-util";
1+
import type EthereumjsUtilT from "@ethereumjs/util";
22

33
import picocolors from "picocolors";
44
import debug from "debug";
@@ -56,7 +56,7 @@ function logHardhatNetworkAccounts(networkConfig: HardhatNetworkConfig) {
5656
privateToAddress,
5757
toBytes,
5858
toChecksumAddress,
59-
} = require("@nomicfoundation/ethereumjs-util") as typeof EthereumjsUtilT;
59+
} = require("@ethereumjs/util") as typeof EthereumjsUtilT;
6060

6161
console.log("Accounts");
6262
console.log("========");

packages/hardhat-core/src/internal/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export const HARDHAT_NETWORK_SUPPORTED_HARDFORKS = [
2323
"merge",
2424
"shanghai",
2525
"cancun",
26+
"prague",
2627
];
2728

2829
export const HARDHAT_MEMPOOL_SUPPORTED_ORDERS = ["fifo", "priority"] as const;

packages/hardhat-core/src/internal/core/config/default-config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ export const defaultHardhatNetworkParams: Omit<
7777
[HardforkName.MERGE, 15_537_394],
7878
[HardforkName.SHANGHAI, 17_034_870],
7979
[HardforkName.CANCUN, 19_426_589],
80+
[HardforkName.PRAGUE, 30_000_000], // TODO: replace with actual block number
8081
]),
8182
},
8283
],
@@ -138,6 +139,7 @@ export const defaultHardhatNetworkParams: Omit<
138139
[HardforkName.MERGE, 1_450_409],
139140
[HardforkName.SHANGHAI, 2_990_908],
140141
[HardforkName.CANCUN, 5_187_023],
142+
[HardforkName.PRAGUE, 30_000_000], // TODO: replace with actual block number
141143
]),
142144
},
143145
],

packages/hardhat-core/src/internal/core/errors-list.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,24 @@ Please check that you are sending an \`address\` parameter.`,
486486
Please check that you are sending a non-empty string for network or forking \`URL\` parameter.`,
487487
shouldBeReported: false,
488488
},
489+
INCOMPATIBLE_EIP7702_FIELDS: {
490+
number: 118,
491+
message: "An incompatible transaction with gasPrice and EIP-7702 fields.",
492+
title: "Incompatible EIP-7702 parameters",
493+
description: `You are trying to send a transaction with a locally managed
494+
account, and its parameters are incompatible. You sent both gasPrice and authorizationList.
495+
496+
Please double check your transactions' parameters.`,
497+
shouldBeReported: false,
498+
},
499+
DATA_FIELD_CANNOT_BE_NULL_WITH_NULL_ADDRESS: {
500+
number: 119,
501+
message: `The "to" field is undefined, and the "data" field is also undefined; however, a transaction to the null address cannot have an undefined "data" field.`,
502+
title: "Transaction to null address cannot have undefined data",
503+
description:
504+
"The transaction to the null address cannot have undefined data",
505+
shouldBeReported: false,
506+
},
489507
},
490508
TASK_DEFINITIONS: {
491509
PARAM_AFTER_VARIADIC: {
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import * as t from "io-ts";
2+
3+
import { rpcAddress, rpcQuantity, rpcHash, rpcParity } from "./base-types";
4+
5+
const rpcAuthorizationListTuple = t.type({
6+
chainId: rpcQuantity,
7+
address: rpcAddress,
8+
nonce: rpcQuantity,
9+
yParity: rpcParity,
10+
r: rpcHash,
11+
s: rpcHash,
12+
});
13+
14+
export const rpcAuthorizationList = t.array(rpcAuthorizationListTuple);
15+
16+
export type RpcAuthorizationListTuple = t.TypeOf<
17+
typeof rpcAuthorizationListTuple
18+
>;
19+
20+
export type RpcAuthorizationList = t.TypeOf<typeof rpcAuthorizationList>;

packages/hardhat-core/src/internal/core/jsonrpc/types/base-types.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {
22
bytesToHex as bufferToHex,
33
isValidAddress,
44
toBytes,
5-
} from "@nomicfoundation/ethereumjs-util";
5+
} from "@ethereumjs/util";
66
import * as t from "io-ts";
77

88
import * as BigIntUtils from "../../../util/bigint";
@@ -27,6 +27,14 @@ export const rpcData = new t.Type<Buffer>(
2727
t.identity
2828
);
2929

30+
export const rpcParity = new t.Type<Buffer>(
31+
"PARITY",
32+
Buffer.isBuffer,
33+
(u, c) =>
34+
isRpcParityString(u) ? t.success(Buffer.from(toBytes(u))) : t.failure(u, c),
35+
t.identity
36+
);
37+
3038
export const rpcHash = new t.Type<Buffer>(
3139
"HASH",
3240
(v): v is Buffer => Buffer.isBuffer(v) && v.length === HASH_LENGTH_BYTES,
@@ -216,6 +224,10 @@ function isRpcDataString(u: unknown): u is string {
216224
return typeof u === "string" && u.match(/^0x(?:[0-9a-fA-F]{2})*$/) !== null;
217225
}
218226

227+
function isRpcParityString(u: unknown): u is string {
228+
return typeof u === "string" && u.match(/^0x[0-9a-fA-F]{1,2}$/) !== null;
229+
}
230+
219231
function isRpcHashString(u: unknown): u is string {
220232
return typeof u === "string" && u.length === 66 && isRpcDataString(u);
221233
}

packages/hardhat-core/src/internal/core/jsonrpc/types/input/transactionRequest.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import * as t from "io-ts";
33
import { optionalOrNullable } from "../../../../util/io-ts";
44
import { rpcAccessList } from "../access-list";
55
import { rpcAddress, rpcData, rpcHash, rpcQuantity } from "../base-types";
6+
import { rpcAuthorizationList } from "../authorization-list";
67

78
// Type used by eth_sendTransaction
89
export const rpcTransactionRequest = t.type(
@@ -20,6 +21,7 @@ export const rpcTransactionRequest = t.type(
2021
maxPriorityFeePerGas: optionalOrNullable(rpcQuantity),
2122
blobs: optionalOrNullable(t.array(rpcData)),
2223
blobVersionedHashes: optionalOrNullable(t.array(rpcHash)),
24+
authorizationList: optionalOrNullable(rpcAuthorizationList),
2325
},
2426
"RpcTransactionRequest"
2527
);
@@ -42,6 +44,14 @@ export interface RpcTransactionRequestInput {
4244
maxPriorityFeePerGas?: string;
4345
blobs?: string[];
4446
blobVersionedHashes?: string[];
47+
authorizationList?: Array<{
48+
chainId: string;
49+
address: string;
50+
nonce: string;
51+
yParity: string;
52+
r: string;
53+
s: string;
54+
}>;
4555
}
4656

4757
export type RpcTransactionRequest = t.TypeOf<typeof rpcTransactionRequest>;

0 commit comments

Comments
 (0)