@ethereumjs/common
Advanced tools
Comparing version 4.3.0 to 4.4.0
@@ -23,2 +23,3 @@ "use strict"; | ||
}, | ||
depositContractAddress: '0x00000000219ab540356cBB839Cbe05303d7705Fa', | ||
hardforks: [ | ||
@@ -120,2 +121,6 @@ { | ||
}, | ||
{ | ||
name: 'prague', | ||
block: null, | ||
}, | ||
], | ||
@@ -571,7 +576,7 @@ bootstrapNodes: [ | ||
}, | ||
kaustinen: { | ||
name: 'kaustinen', | ||
kaustinen6: { | ||
name: 'kaustinen6', | ||
chainId: 69420, | ||
networkId: 69420, | ||
defaultHardfork: 'prague', | ||
defaultHardfork: 'osaka', | ||
consensus: { | ||
@@ -581,3 +586,3 @@ type: 'pos', | ||
}, | ||
comment: 'Verkle kaustinen testnet 2 (likely temporary, do not hard-wire into production code)', | ||
comment: 'Verkle kaustinen testnet 6 (likely temporary, do not hard-wire into production code)', | ||
url: 'https://github.com/eth-clients/kaustinen/', | ||
@@ -589,3 +594,3 @@ genesis: { | ||
nonce: '0x0000000000001234', | ||
timestamp: '0x65608a64', | ||
timestamp: '0x66190fbc', | ||
}, | ||
@@ -648,5 +653,5 @@ hardforks: [ | ||
{ | ||
name: 'prague', | ||
name: 'osaka', | ||
block: null, | ||
timestamp: '1700825700', | ||
timestamp: '1712848500', | ||
}, | ||
@@ -653,0 +658,0 @@ ], |
@@ -119,5 +119,3 @@ "use strict"; | ||
networkId: 69, | ||
}, | ||
// Optimism has not implemented the London hardfork yet (targeting Q1.22) | ||
{ hardfork: enums_js_1.Hardfork.Berlin, ...opts }); | ||
}, opts); | ||
} | ||
@@ -736,3 +734,3 @@ if (chainParamsOrName === enums_js_1.CustomChain.OptimisticEthereum) { | ||
name !== enums_js_1.Hardfork.Paris) { | ||
const hfBlockBytes = (0, util_1.hexToBytes)('0x' + blockOrTime.toString(16).padStart(16, '0')); | ||
const hfBlockBytes = (0, util_1.hexToBytes)(`0x${blockOrTime.toString(16).padStart(16, '0')}`); | ||
hfBytes = (0, util_1.concatBytes)(hfBytes, hfBlockBytes); | ||
@@ -739,0 +737,0 @@ prevBlockOrTime = blockOrTime; |
@@ -51,23 +51,2 @@ "use strict"; | ||
}, | ||
2315: { | ||
comment: 'Simple subroutines for the EVM', | ||
url: 'https://eips.ethereum.org/EIPS/eip-2315', | ||
status: Status.Draft, | ||
minimumHardfork: enums_js_1.Hardfork.Istanbul, | ||
requiredEIPs: [], | ||
gasPrices: { | ||
beginsub: { | ||
v: 2, | ||
d: 'Base fee of the BEGINSUB opcode', | ||
}, | ||
returnsub: { | ||
v: 5, | ||
d: 'Base fee of the RETURNSUB opcode', | ||
}, | ||
jumpsub: { | ||
v: 10, | ||
d: 'Base fee of the JUMPSUB opcode', | ||
}, | ||
}, | ||
}, | ||
2565: { | ||
@@ -86,2 +65,46 @@ comment: 'ModExp gas cost', | ||
}, | ||
2537: { | ||
comment: 'BLS12-381 precompiles', | ||
url: 'https://eips.ethereum.org/EIPS/eip-2537', | ||
status: 'Draft', | ||
minimumHardfork: enums_js_1.Hardfork.Chainstart, | ||
requiredEIPs: [], | ||
gasConfig: {}, | ||
gasPrices: { | ||
Bls12381G1AddGas: { | ||
v: 500, | ||
d: 'Gas cost of a single BLS12-381 G1 addition precompile-call', | ||
}, | ||
Bls12381G1MulGas: { | ||
v: 12000, | ||
d: 'Gas cost of a single BLS12-381 G1 multiplication precompile-call', | ||
}, | ||
Bls12381G2AddGas: { | ||
v: 800, | ||
d: 'Gas cost of a single BLS12-381 G2 addition precompile-call', | ||
}, | ||
Bls12381G2MulGas: { | ||
v: 45000, | ||
d: 'Gas cost of a single BLS12-381 G2 multiplication precompile-call', | ||
}, | ||
Bls12381PairingBaseGas: { | ||
v: 65000, | ||
d: 'Base gas cost of BLS12-381 pairing check', | ||
}, | ||
Bls12381PairingPerPairGas: { | ||
v: 43000, | ||
d: 'Per-pair gas cost of BLS12-381 pairing check', | ||
}, | ||
Bls12381MapG1Gas: { | ||
v: 5500, | ||
d: 'Gas cost of BLS12-381 map field element to G1', | ||
}, | ||
Bls12381MapG2Gas: { | ||
v: 75000, | ||
d: 'Gas cost of BLS12-381 map field element to G2', | ||
}, | ||
}, | ||
vm: {}, | ||
pow: {}, | ||
}, | ||
2718: { | ||
@@ -200,7 +223,7 @@ comment: 'Typed Transaction Envelope', | ||
historyStorageAddress: { | ||
v: BigInt('0xfffffffffffffffffffffffffffffffffffffffe'), | ||
v: BigInt('0x0aae40965e6800cd9b1f4b05ff21581047e3f91e'), | ||
d: 'The address where the historical blockhashes are stored', | ||
}, | ||
historyServeWindow: { | ||
v: BigInt(256), | ||
v: BigInt(8192), | ||
d: 'The amount of blocks to be served by the historical blockhash contract', | ||
@@ -212,3 +235,3 @@ }, | ||
comment: 'AUTH and AUTHCALL opcodes', | ||
url: 'https://eips.ethereum.org/EIPS/eip-3074', | ||
url: 'https://github.com/ethereum/EIPs/commit/eca4416ff3c025fcb6ec8cd4eac481e74e108481', | ||
status: Status.Review, | ||
@@ -485,2 +508,9 @@ minimumHardfork: enums_js_1.Hardfork.London, | ||
}, | ||
6110: { | ||
comment: 'Supply validator deposits on chain', | ||
url: 'https://eips.ethereum.org/EIPS/eip-6110', | ||
status: Status.Draft, | ||
minimumHardfork: enums_js_1.Hardfork.Cancun, | ||
requiredEIPs: [7685], | ||
}, | ||
6780: { | ||
@@ -499,3 +529,99 @@ comment: 'SELFDESTRUCT only in same transaction', | ||
requiredEIPs: [], | ||
gasPrices: { | ||
create: { | ||
v: 1000, | ||
d: 'Base fee of the CREATE opcode', | ||
}, | ||
coldsload: { | ||
v: 0, | ||
d: 'Gas cost of the first read of storage from a given location (per transaction)', | ||
}, | ||
}, | ||
vm: { | ||
// kaustinen 6 current uses this address, however this will be updated to correct address | ||
// in next iteration | ||
historyStorageAddress: { | ||
v: BigInt('0xfffffffffffffffffffffffffffffffffffffffe'), | ||
d: 'The address where the historical blockhashes are stored', | ||
}, | ||
}, | ||
}, | ||
7002: { | ||
comment: 'Execution layer triggerable withdrawals (experimental)', | ||
url: 'https://github.com/ethereum/EIPs/blob/3b5fcad6b35782f8aaeba7d4ac26004e8fbd720f/EIPS/eip-7002.md', | ||
status: Status.Draft, | ||
minimumHardfork: enums_js_1.Hardfork.Paris, | ||
requiredEIPs: [7685], | ||
vm: { | ||
withdrawalRequestType: { | ||
v: BigInt(0x01), | ||
d: 'The withdrawal request type for EIP-7685', | ||
}, | ||
excessWithdrawalsRequestStorageSlot: { | ||
v: BigInt(0), | ||
d: 'The storage slot of the excess withdrawals', | ||
}, | ||
withdrawalsRequestCountStorage: { | ||
v: BigInt(1), | ||
d: 'The storage slot of the withdrawal request count', | ||
}, | ||
withdrawalsRequestQueueHeadStorageSlot: { | ||
v: BigInt(2), | ||
d: 'The storage slot of the withdrawal request head of the queue', | ||
}, | ||
withdrawalsRequestTailHeadStorageSlot: { | ||
v: BigInt(3), | ||
d: 'The storage slot of the withdrawal request tail of the queue', | ||
}, | ||
withdrawalsRequestQueueStorageOffset: { | ||
v: BigInt(4), | ||
d: 'The storage slot of the withdrawal request queue offset', | ||
}, | ||
maxWithdrawalRequestsPerBlock: { | ||
v: BigInt(16), | ||
d: 'The max withdrawal requests per block', | ||
}, | ||
targetWithdrawalRequestsPerBlock: { | ||
v: BigInt(2), | ||
d: 'The target withdrawal requests per block', | ||
}, | ||
minWithdrawalRequestFee: { | ||
v: BigInt(1), | ||
d: 'The minimum withdrawal request fee (in wei)', | ||
}, | ||
withdrawalRequestFeeUpdateFraction: { | ||
v: BigInt(17), | ||
d: 'The withdrawal request fee update fraction (used in the fake exponential)', | ||
}, | ||
systemAddress: { | ||
v: BigInt('0xfffffffffffffffffffffffffffffffffffffffe'), | ||
d: 'The system address to perform operations on the withdrawal requests predeploy address', | ||
}, | ||
withdrawalRequestPredeployAddress: { | ||
v: BigInt('0x00A3ca265EBcb825B45F985A16CEFB49958cE017'), | ||
d: 'Address of the validator excess address', | ||
}, | ||
}, | ||
}, | ||
7251: { | ||
comment: 'Execution layer triggered consolidations (experimental)', | ||
url: 'https://eips.ethereum.org/EIPS/eip-7251', | ||
status: Status.Draft, | ||
minimumHardfork: enums_js_1.Hardfork.Paris, | ||
requiredEIPs: [7685], | ||
vm: { | ||
consolidationRequestType: { | ||
v: BigInt(0x02), | ||
d: 'The withdrawal request type for EIP-7685', | ||
}, | ||
systemAddress: { | ||
v: BigInt('0xfffffffffffffffffffffffffffffffffffffffe'), | ||
d: 'The system address to perform operations on the consolidation requests predeploy address', | ||
}, | ||
consolidationRequestPredeployAddress: { | ||
v: BigInt('0x00b42dbF2194e931E80326D950320f7d9Dbeac02'), | ||
d: 'Address of the consolidations contract', | ||
}, | ||
}, | ||
}, | ||
7516: { | ||
@@ -514,3 +640,33 @@ comment: 'BLOBBASEFEE opcode', | ||
}, | ||
7685: { | ||
comment: 'General purpose execution layer requests', | ||
url: 'https://eips.ethereum.org/EIPS/eip-7685', | ||
status: Status.Draft, | ||
// TODO: Set correct minimum hardfork | ||
minimumHardfork: enums_js_1.Hardfork.Cancun, | ||
requiredEIPs: [3675], | ||
gasPrices: {}, | ||
}, | ||
7702: { | ||
comment: 'Set EOA account code for one transaction', | ||
url: 'https://github.com/ethereum/EIPs/blob/62419ca3f45375db00b04a368ea37c0bfb05386a/EIPS/eip-7702.md', | ||
status: Status.Review, | ||
// TODO: Set correct minimum hardfork | ||
minimumHardfork: enums_js_1.Hardfork.Cancun, | ||
requiredEIPs: [2718, 2929, 2930], | ||
gasPrices: { | ||
perAuthBaseCost: { | ||
v: 2500, | ||
d: 'Gas cost of each authority item', | ||
}, | ||
}, | ||
}, | ||
7709: { | ||
comment: 'Use historical block hashes saved in state for BLOCKHASH', | ||
url: 'https://eips.ethereum.org/EIPS/eip-7709', | ||
status: Status.Draft, | ||
minimumHardfork: enums_js_1.Hardfork.Chainstart, | ||
requiredEIPs: [2935], | ||
}, | ||
}; | ||
//# sourceMappingURL=eips.js.map |
@@ -6,3 +6,3 @@ export declare enum Chain { | ||
Holesky = 17000, | ||
Kaustinen = 69420 | ||
Kaustinen6 = 69420 | ||
} | ||
@@ -40,3 +40,4 @@ /** | ||
Cancun = "cancun", | ||
Prague = "prague" | ||
Prague = "prague", | ||
Osaka = "osaka" | ||
} | ||
@@ -43,0 +44,0 @@ export declare enum ConsensusType { |
@@ -11,3 +11,3 @@ "use strict"; | ||
Chain[Chain["Holesky"] = 17000] = "Holesky"; | ||
Chain[Chain["Kaustinen"] = 69420] = "Kaustinen"; | ||
Chain[Chain["Kaustinen6"] = 69420] = "Kaustinen6"; | ||
})(Chain = exports.Chain || (exports.Chain = {})); | ||
@@ -39,6 +39,6 @@ // Having this info as record will force typescript to make sure no chain is missed | ||
}, | ||
[Chain.Kaustinen]: { | ||
name: 'kaustinen', | ||
[Chain.Kaustinen6]: { | ||
name: 'kaustinen6', | ||
blockNumber: util_1.BIGINT_0, | ||
stateRoot: (0, util_1.hexToBytes)('0x5e8519756841faf0b2c28951c451b61a4b407b70a5ce5b57992f4bec973173ff'), | ||
stateRoot: (0, util_1.hexToBytes)('0x1fbf85345a3cbba9a6d44f991b721e55620a22397c2a93ee8d5011136ac300ee'), | ||
}, | ||
@@ -67,2 +67,3 @@ }; | ||
Hardfork["Prague"] = "prague"; | ||
Hardfork["Osaka"] = "osaka"; | ||
})(Hardfork = exports.Hardfork || (exports.Hardfork = {})); | ||
@@ -69,0 +70,0 @@ var ConsensusType; |
@@ -837,8 +837,15 @@ "use strict"; | ||
name: 'prague', | ||
comment: 'Next feature hardfork after cancun, internally used for verkle testing/implementation (incomplete/experimental)', | ||
comment: 'Next feature hardfork after cancun, internally used for pectra testing/implementation (incomplete/experimental)', | ||
url: 'https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/prague.md', | ||
status: Status.Draft, | ||
eips: [6800], | ||
eips: [2537, 2935, 3074, 6110, 7002, 7251, 7685], | ||
}, | ||
osaka: { | ||
name: 'osaka', | ||
comment: 'Next feature hardfork after prague, internally used for verkle testing/implementation (incomplete/experimental)', | ||
url: 'https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/osaka.md', | ||
status: Status.Draft, | ||
eips: [2935, 6800], | ||
}, | ||
}; | ||
//# sourceMappingURL=hardforks.js.map |
@@ -52,2 +52,63 @@ /** | ||
export declare type AccessList = AccessListItem[]; | ||
/** | ||
* Authorization list types | ||
*/ | ||
export declare type AuthorizationListItem = { | ||
chainId: PrefixedHexString; | ||
address: PrefixedHexString; | ||
nonce: PrefixedHexString[]; | ||
yParity: PrefixedHexString; | ||
r: PrefixedHexString; | ||
s: PrefixedHexString; | ||
}; | ||
export declare type AuthorizationListBytesItem = [ | ||
Uint8Array, | ||
Uint8Array, | ||
Uint8Array[], | ||
Uint8Array, | ||
Uint8Array, | ||
Uint8Array | ||
]; | ||
export declare type AuthorizationListBytes = AuthorizationListBytesItem[]; | ||
export declare type AuthorizationList = AuthorizationListItem[]; | ||
/** | ||
* Verkle related | ||
* | ||
* Experimental (do not implement) | ||
*/ | ||
export declare type AccessEventFlags = { | ||
stemRead: boolean; | ||
stemWrite: boolean; | ||
chunkRead: boolean; | ||
chunkWrite: boolean; | ||
chunkFill: boolean; | ||
}; | ||
/** | ||
* Verkle related | ||
* | ||
* Experimental (do not implement) | ||
*/ | ||
export interface AccessWitnessInterface { | ||
touchAndChargeProofOfAbsence(address: Address): bigint; | ||
touchAndChargeMessageCall(address: Address): bigint; | ||
touchAndChargeValueTransfer(caller: Address, target: Address): bigint; | ||
touchAndChargeContractCreateInit(address: Address): bigint; | ||
touchAndChargeContractCreateCompleted(address: Address): bigint; | ||
touchTxOriginAndComputeGas(origin: Address): bigint; | ||
touchTxTargetAndComputeGas(target: Address, { sendsValue }: { | ||
sendsValue?: boolean; | ||
}): bigint; | ||
touchCodeChunksRangeOnReadAndChargeGas(contact: Address, startPc: number, endPc: number): bigint; | ||
touchCodeChunksRangeOnWriteAndChargeGas(contact: Address, startPc: number, endPc: number): bigint; | ||
touchAddressOnWriteAndComputeGas(address: Address, treeIndex: number | bigint, subIndex: number | Uint8Array): bigint; | ||
touchAddressOnReadAndComputeGas(address: Address, treeIndex: number | bigint, subIndex: number | Uint8Array): bigint; | ||
touchAddressAndChargeGas(address: Address, treeIndex: number | bigint, subIndex: number | Uint8Array, { isWrite }: { | ||
isWrite?: boolean; | ||
}): bigint; | ||
touchAddress(address: Address, treeIndex: number | bigint, subIndex: number | Uint8Array, { isWrite }: { | ||
isWrite?: boolean; | ||
}): AccessEventFlags; | ||
shallowCopy(): AccessWitnessInterface; | ||
merge(accessWitness: AccessWitnessInterface): void; | ||
} | ||
export interface StateManagerInterface { | ||
@@ -60,2 +121,3 @@ getAccount(address: Address): Promise<Account | undefined>; | ||
getContractCode(address: Address): Promise<Uint8Array>; | ||
getContractCodeSize?(address: Address): Promise<number>; | ||
getContractStorage(address: Address, key: Uint8Array): Promise<Uint8Array>; | ||
@@ -73,2 +135,3 @@ putContractStorage(address: Address, key: Uint8Array, value: Uint8Array): Promise<void>; | ||
getAppliedKey?(address: Uint8Array): Uint8Array; | ||
checkChunkWitnessPresent?(contract: Address, programCounter: number): Promise<boolean>; | ||
} | ||
@@ -75,0 +138,0 @@ export interface EVMStateManagerInterface extends StateManagerInterface { |
import type { Chain, ConsensusAlgorithm, ConsensusType, Hardfork } from './enums.js'; | ||
import type { BigIntLike, ECDSASignature, Kzg } from '@ethereumjs/util'; | ||
import type { BigIntLike, ECDSASignature, Kzg, PrefixedHexString } from '@ethereumjs/util'; | ||
export interface ChainName { | ||
@@ -35,11 +35,12 @@ [chainId: string]: string; | ||
consensus: ConsensusConfig; | ||
depositContractAddress?: PrefixedHexString; | ||
} | ||
export interface GenesisBlockConfig { | ||
timestamp?: string; | ||
gasLimit: number | string; | ||
difficulty: number | string; | ||
nonce: string; | ||
extraData: string; | ||
baseFeePerGas?: string; | ||
excessBlobGas?: string; | ||
timestamp?: PrefixedHexString | string; | ||
gasLimit: number | PrefixedHexString | string; | ||
difficulty: number | PrefixedHexString | string; | ||
nonce: PrefixedHexString | string; | ||
extraData: PrefixedHexString | string; | ||
baseFeePerGas?: PrefixedHexString | string; | ||
excessBlobGas?: PrefixedHexString | string; | ||
} | ||
@@ -51,3 +52,3 @@ export interface HardforkTransitionConfig { | ||
timestamp?: number | string; | ||
forkHash?: string | null; | ||
forkHash?: PrefixedHexString | null; | ||
} | ||
@@ -87,3 +88,7 @@ export interface BootstrapNodeConfig { | ||
* Selected EIPs which can be activated, please use an array for instantiation | ||
* (e.g. `eips: [ 1559, 3860 ]`) | ||
* (e.g. `eips: [ 2537, ]`) | ||
* | ||
* Currently supported: | ||
* | ||
* - [EIP-2537](https://eips.ethereum.org/EIPS/eip-2537) - BLS12-381 precompiles | ||
*/ | ||
@@ -142,5 +147,5 @@ eips?: number[]; | ||
export interface HardforkByOpts { | ||
blockNumber?: BigIntLike; | ||
timestamp?: BigIntLike; | ||
td?: BigIntLike; | ||
blockNumber?: BigIntLike | string; | ||
timestamp?: BigIntLike | string; | ||
td?: BigIntLike | string; | ||
} | ||
@@ -147,0 +152,0 @@ declare type ParamDict = { |
@@ -20,12 +20,13 @@ declare type ConfigHardfork = { | ||
networkId: number; | ||
depositContractAddress: `0x${string}`; | ||
genesis: { | ||
timestamp: string; | ||
gasLimit: string; | ||
difficulty: string; | ||
nonce: string; | ||
extraData: string; | ||
mixHash: string; | ||
coinbase: string; | ||
baseFeePerGas: string; | ||
excessBlobGas: string; | ||
timestamp: `0x${string}`; | ||
gasLimit: `0x${string}`; | ||
difficulty: `0x${string}`; | ||
nonce: `0x${string}`; | ||
extraData: `0x${string}`; | ||
mixHash: `0x${string}`; | ||
coinbase: `0x${string}`; | ||
baseFeePerGas: `0x${string}`; | ||
excessBlobGas: `0x${string}`; | ||
}; | ||
@@ -32,0 +33,0 @@ hardfork: string | undefined; |
@@ -15,6 +15,6 @@ "use strict"; | ||
} | ||
if ((0, util_1.isHexPrefixed)(nonce)) { | ||
return '0x' + (0, util_1.stripHexPrefix)(nonce).padStart(16, '0'); | ||
if ((0, util_1.isHexString)(nonce)) { | ||
return `0x${(0, util_1.stripHexPrefix)(nonce).padStart(16, '0')}`; | ||
} | ||
return '0x' + nonce.padStart(16, '0'); | ||
return `0x${nonce.padStart(16, '0')}`; | ||
} | ||
@@ -30,18 +30,13 @@ /** | ||
function parseGethParams(json, mergeForkIdPostMerge = true) { | ||
const { name, config, difficulty, mixHash, gasLimit, coinbase, baseFeePerGas, excessBlobGas, } = json; | ||
let { extraData, timestamp, nonce } = json; | ||
const genesisTimestamp = Number(timestamp); | ||
const { chainId } = config; | ||
const { name, config, difficulty, mixHash, gasLimit, coinbase, baseFeePerGas, excessBlobGas, extraData: unparsedExtraData, nonce: unparsedNonce, timestamp: unparsedTimestamp, } = json; | ||
const genesisTimestamp = Number(unparsedTimestamp); | ||
const { chainId, depositContractAddress, } = config; | ||
// geth is not strictly putting empty fields with a 0x prefix | ||
if (extraData === '') { | ||
extraData = '0x'; | ||
} | ||
const extraData = unparsedExtraData === '' ? '0x' : unparsedExtraData; | ||
// geth may use number for timestamp | ||
if (!(0, util_1.isHexPrefixed)(timestamp)) { | ||
timestamp = (0, util_1.intToHex)(parseInt(timestamp)); | ||
} | ||
// geth may not give us a nonce strictly formatted to an 8 byte hex string | ||
if (nonce.length !== 18) { | ||
nonce = formatNonce(nonce); | ||
} | ||
const timestamp = (0, util_1.isHexString)(unparsedTimestamp) | ||
? unparsedTimestamp | ||
: (0, util_1.intToHex)(parseInt(unparsedTimestamp)); | ||
// geth may not give us a nonce strictly formatted to an 8 byte 0x-prefixed hex string | ||
const nonce = unparsedNonce.length !== 18 ? formatNonce(unparsedNonce) : unparsedNonce; | ||
// EIP155 and EIP158 are both part of Spurious Dragon hardfork and must occur at the same time | ||
@@ -56,2 +51,3 @@ // but have different configuration parameters in geth genesis parameters | ||
networkId: chainId, | ||
depositContractAddress, | ||
genesis: { | ||
@@ -105,2 +101,3 @@ timestamp, | ||
[enums_js_1.Hardfork.Prague]: { name: 'pragueTime', postMerge: true, isTimestamp: true }, | ||
[enums_js_1.Hardfork.Osaka]: { name: 'osakaTime', postMerge: true, isTimestamp: true }, | ||
}; | ||
@@ -176,6 +173,8 @@ // forkMapRev is the map from config field name to Hardfork | ||
} | ||
// We copy the JSON object here because it's frozen in browser and properties can't be modified | ||
const finalJson = { ...json }; | ||
if (name !== undefined) { | ||
json.name = name; | ||
finalJson.name = name; | ||
} | ||
return parseGethParams(json, mergeForkIdPostMerge); | ||
return parseGethParams(finalJson, mergeForkIdPostMerge); | ||
} | ||
@@ -182,0 +181,0 @@ catch (e) { |
@@ -20,2 +20,3 @@ export const chains = { | ||
}, | ||
depositContractAddress: '0x00000000219ab540356cBB839Cbe05303d7705Fa', | ||
hardforks: [ | ||
@@ -117,2 +118,6 @@ { | ||
}, | ||
{ | ||
name: 'prague', | ||
block: null, | ||
}, | ||
], | ||
@@ -568,7 +573,7 @@ bootstrapNodes: [ | ||
}, | ||
kaustinen: { | ||
name: 'kaustinen', | ||
kaustinen6: { | ||
name: 'kaustinen6', | ||
chainId: 69420, | ||
networkId: 69420, | ||
defaultHardfork: 'prague', | ||
defaultHardfork: 'osaka', | ||
consensus: { | ||
@@ -578,3 +583,3 @@ type: 'pos', | ||
}, | ||
comment: 'Verkle kaustinen testnet 2 (likely temporary, do not hard-wire into production code)', | ||
comment: 'Verkle kaustinen testnet 6 (likely temporary, do not hard-wire into production code)', | ||
url: 'https://github.com/eth-clients/kaustinen/', | ||
@@ -586,3 +591,3 @@ genesis: { | ||
nonce: '0x0000000000001234', | ||
timestamp: '0x65608a64', | ||
timestamp: '0x66190fbc', | ||
}, | ||
@@ -645,5 +650,5 @@ hardforks: [ | ||
{ | ||
name: 'prague', | ||
name: 'osaka', | ||
block: null, | ||
timestamp: '1700825700', | ||
timestamp: '1712848500', | ||
}, | ||
@@ -650,0 +655,0 @@ ], |
@@ -116,5 +116,3 @@ import { BIGINT_0, TypeOutput, bytesToHex, concatBytes, hexToBytes, intToBytes, toType, } from '@ethereumjs/util'; | ||
networkId: 69, | ||
}, | ||
// Optimism has not implemented the London hardfork yet (targeting Q1.22) | ||
{ hardfork: Hardfork.Berlin, ...opts }); | ||
}, opts); | ||
} | ||
@@ -733,3 +731,3 @@ if (chainParamsOrName === CustomChain.OptimisticEthereum) { | ||
name !== Hardfork.Paris) { | ||
const hfBlockBytes = hexToBytes('0x' + blockOrTime.toString(16).padStart(16, '0')); | ||
const hfBlockBytes = hexToBytes(`0x${blockOrTime.toString(16).padStart(16, '0')}`); | ||
hfBytes = concatBytes(hfBytes, hfBlockBytes); | ||
@@ -736,0 +734,0 @@ prevBlockOrTime = blockOrTime; |
@@ -48,23 +48,2 @@ import { Hardfork } from './enums.js'; | ||
}, | ||
2315: { | ||
comment: 'Simple subroutines for the EVM', | ||
url: 'https://eips.ethereum.org/EIPS/eip-2315', | ||
status: Status.Draft, | ||
minimumHardfork: Hardfork.Istanbul, | ||
requiredEIPs: [], | ||
gasPrices: { | ||
beginsub: { | ||
v: 2, | ||
d: 'Base fee of the BEGINSUB opcode', | ||
}, | ||
returnsub: { | ||
v: 5, | ||
d: 'Base fee of the RETURNSUB opcode', | ||
}, | ||
jumpsub: { | ||
v: 10, | ||
d: 'Base fee of the JUMPSUB opcode', | ||
}, | ||
}, | ||
}, | ||
2565: { | ||
@@ -83,2 +62,46 @@ comment: 'ModExp gas cost', | ||
}, | ||
2537: { | ||
comment: 'BLS12-381 precompiles', | ||
url: 'https://eips.ethereum.org/EIPS/eip-2537', | ||
status: 'Draft', | ||
minimumHardfork: Hardfork.Chainstart, | ||
requiredEIPs: [], | ||
gasConfig: {}, | ||
gasPrices: { | ||
Bls12381G1AddGas: { | ||
v: 500, | ||
d: 'Gas cost of a single BLS12-381 G1 addition precompile-call', | ||
}, | ||
Bls12381G1MulGas: { | ||
v: 12000, | ||
d: 'Gas cost of a single BLS12-381 G1 multiplication precompile-call', | ||
}, | ||
Bls12381G2AddGas: { | ||
v: 800, | ||
d: 'Gas cost of a single BLS12-381 G2 addition precompile-call', | ||
}, | ||
Bls12381G2MulGas: { | ||
v: 45000, | ||
d: 'Gas cost of a single BLS12-381 G2 multiplication precompile-call', | ||
}, | ||
Bls12381PairingBaseGas: { | ||
v: 65000, | ||
d: 'Base gas cost of BLS12-381 pairing check', | ||
}, | ||
Bls12381PairingPerPairGas: { | ||
v: 43000, | ||
d: 'Per-pair gas cost of BLS12-381 pairing check', | ||
}, | ||
Bls12381MapG1Gas: { | ||
v: 5500, | ||
d: 'Gas cost of BLS12-381 map field element to G1', | ||
}, | ||
Bls12381MapG2Gas: { | ||
v: 75000, | ||
d: 'Gas cost of BLS12-381 map field element to G2', | ||
}, | ||
}, | ||
vm: {}, | ||
pow: {}, | ||
}, | ||
2718: { | ||
@@ -197,7 +220,7 @@ comment: 'Typed Transaction Envelope', | ||
historyStorageAddress: { | ||
v: BigInt('0xfffffffffffffffffffffffffffffffffffffffe'), | ||
v: BigInt('0x0aae40965e6800cd9b1f4b05ff21581047e3f91e'), | ||
d: 'The address where the historical blockhashes are stored', | ||
}, | ||
historyServeWindow: { | ||
v: BigInt(256), | ||
v: BigInt(8192), | ||
d: 'The amount of blocks to be served by the historical blockhash contract', | ||
@@ -209,3 +232,3 @@ }, | ||
comment: 'AUTH and AUTHCALL opcodes', | ||
url: 'https://eips.ethereum.org/EIPS/eip-3074', | ||
url: 'https://github.com/ethereum/EIPs/commit/eca4416ff3c025fcb6ec8cd4eac481e74e108481', | ||
status: Status.Review, | ||
@@ -482,2 +505,9 @@ minimumHardfork: Hardfork.London, | ||
}, | ||
6110: { | ||
comment: 'Supply validator deposits on chain', | ||
url: 'https://eips.ethereum.org/EIPS/eip-6110', | ||
status: Status.Draft, | ||
minimumHardfork: Hardfork.Cancun, | ||
requiredEIPs: [7685], | ||
}, | ||
6780: { | ||
@@ -496,3 +526,99 @@ comment: 'SELFDESTRUCT only in same transaction', | ||
requiredEIPs: [], | ||
gasPrices: { | ||
create: { | ||
v: 1000, | ||
d: 'Base fee of the CREATE opcode', | ||
}, | ||
coldsload: { | ||
v: 0, | ||
d: 'Gas cost of the first read of storage from a given location (per transaction)', | ||
}, | ||
}, | ||
vm: { | ||
// kaustinen 6 current uses this address, however this will be updated to correct address | ||
// in next iteration | ||
historyStorageAddress: { | ||
v: BigInt('0xfffffffffffffffffffffffffffffffffffffffe'), | ||
d: 'The address where the historical blockhashes are stored', | ||
}, | ||
}, | ||
}, | ||
7002: { | ||
comment: 'Execution layer triggerable withdrawals (experimental)', | ||
url: 'https://github.com/ethereum/EIPs/blob/3b5fcad6b35782f8aaeba7d4ac26004e8fbd720f/EIPS/eip-7002.md', | ||
status: Status.Draft, | ||
minimumHardfork: Hardfork.Paris, | ||
requiredEIPs: [7685], | ||
vm: { | ||
withdrawalRequestType: { | ||
v: BigInt(0x01), | ||
d: 'The withdrawal request type for EIP-7685', | ||
}, | ||
excessWithdrawalsRequestStorageSlot: { | ||
v: BigInt(0), | ||
d: 'The storage slot of the excess withdrawals', | ||
}, | ||
withdrawalsRequestCountStorage: { | ||
v: BigInt(1), | ||
d: 'The storage slot of the withdrawal request count', | ||
}, | ||
withdrawalsRequestQueueHeadStorageSlot: { | ||
v: BigInt(2), | ||
d: 'The storage slot of the withdrawal request head of the queue', | ||
}, | ||
withdrawalsRequestTailHeadStorageSlot: { | ||
v: BigInt(3), | ||
d: 'The storage slot of the withdrawal request tail of the queue', | ||
}, | ||
withdrawalsRequestQueueStorageOffset: { | ||
v: BigInt(4), | ||
d: 'The storage slot of the withdrawal request queue offset', | ||
}, | ||
maxWithdrawalRequestsPerBlock: { | ||
v: BigInt(16), | ||
d: 'The max withdrawal requests per block', | ||
}, | ||
targetWithdrawalRequestsPerBlock: { | ||
v: BigInt(2), | ||
d: 'The target withdrawal requests per block', | ||
}, | ||
minWithdrawalRequestFee: { | ||
v: BigInt(1), | ||
d: 'The minimum withdrawal request fee (in wei)', | ||
}, | ||
withdrawalRequestFeeUpdateFraction: { | ||
v: BigInt(17), | ||
d: 'The withdrawal request fee update fraction (used in the fake exponential)', | ||
}, | ||
systemAddress: { | ||
v: BigInt('0xfffffffffffffffffffffffffffffffffffffffe'), | ||
d: 'The system address to perform operations on the withdrawal requests predeploy address', | ||
}, | ||
withdrawalRequestPredeployAddress: { | ||
v: BigInt('0x00A3ca265EBcb825B45F985A16CEFB49958cE017'), | ||
d: 'Address of the validator excess address', | ||
}, | ||
}, | ||
}, | ||
7251: { | ||
comment: 'Execution layer triggered consolidations (experimental)', | ||
url: 'https://eips.ethereum.org/EIPS/eip-7251', | ||
status: Status.Draft, | ||
minimumHardfork: Hardfork.Paris, | ||
requiredEIPs: [7685], | ||
vm: { | ||
consolidationRequestType: { | ||
v: BigInt(0x02), | ||
d: 'The withdrawal request type for EIP-7685', | ||
}, | ||
systemAddress: { | ||
v: BigInt('0xfffffffffffffffffffffffffffffffffffffffe'), | ||
d: 'The system address to perform operations on the consolidation requests predeploy address', | ||
}, | ||
consolidationRequestPredeployAddress: { | ||
v: BigInt('0x00b42dbF2194e931E80326D950320f7d9Dbeac02'), | ||
d: 'Address of the consolidations contract', | ||
}, | ||
}, | ||
}, | ||
7516: { | ||
@@ -511,3 +637,33 @@ comment: 'BLOBBASEFEE opcode', | ||
}, | ||
7685: { | ||
comment: 'General purpose execution layer requests', | ||
url: 'https://eips.ethereum.org/EIPS/eip-7685', | ||
status: Status.Draft, | ||
// TODO: Set correct minimum hardfork | ||
minimumHardfork: Hardfork.Cancun, | ||
requiredEIPs: [3675], | ||
gasPrices: {}, | ||
}, | ||
7702: { | ||
comment: 'Set EOA account code for one transaction', | ||
url: 'https://github.com/ethereum/EIPs/blob/62419ca3f45375db00b04a368ea37c0bfb05386a/EIPS/eip-7702.md', | ||
status: Status.Review, | ||
// TODO: Set correct minimum hardfork | ||
minimumHardfork: Hardfork.Cancun, | ||
requiredEIPs: [2718, 2929, 2930], | ||
gasPrices: { | ||
perAuthBaseCost: { | ||
v: 2500, | ||
d: 'Gas cost of each authority item', | ||
}, | ||
}, | ||
}, | ||
7709: { | ||
comment: 'Use historical block hashes saved in state for BLOCKHASH', | ||
url: 'https://eips.ethereum.org/EIPS/eip-7709', | ||
status: Status.Draft, | ||
minimumHardfork: Hardfork.Chainstart, | ||
requiredEIPs: [2935], | ||
}, | ||
}; | ||
//# sourceMappingURL=eips.js.map |
@@ -6,3 +6,3 @@ export declare enum Chain { | ||
Holesky = 17000, | ||
Kaustinen = 69420 | ||
Kaustinen6 = 69420 | ||
} | ||
@@ -40,3 +40,4 @@ /** | ||
Cancun = "cancun", | ||
Prague = "prague" | ||
Prague = "prague", | ||
Osaka = "osaka" | ||
} | ||
@@ -43,0 +44,0 @@ export declare enum ConsensusType { |
@@ -8,3 +8,3 @@ import { BIGINT_0, hexToBytes } from '@ethereumjs/util'; | ||
Chain[Chain["Holesky"] = 17000] = "Holesky"; | ||
Chain[Chain["Kaustinen"] = 69420] = "Kaustinen"; | ||
Chain[Chain["Kaustinen6"] = 69420] = "Kaustinen6"; | ||
})(Chain || (Chain = {})); | ||
@@ -36,6 +36,6 @@ // Having this info as record will force typescript to make sure no chain is missed | ||
}, | ||
[Chain.Kaustinen]: { | ||
name: 'kaustinen', | ||
[Chain.Kaustinen6]: { | ||
name: 'kaustinen6', | ||
blockNumber: BIGINT_0, | ||
stateRoot: hexToBytes('0x5e8519756841faf0b2c28951c451b61a4b407b70a5ce5b57992f4bec973173ff'), | ||
stateRoot: hexToBytes('0x1fbf85345a3cbba9a6d44f991b721e55620a22397c2a93ee8d5011136ac300ee'), | ||
}, | ||
@@ -64,2 +64,3 @@ }; | ||
Hardfork["Prague"] = "prague"; | ||
Hardfork["Osaka"] = "osaka"; | ||
})(Hardfork || (Hardfork = {})); | ||
@@ -66,0 +67,0 @@ export var ConsensusType; |
@@ -834,8 +834,15 @@ export var Status; | ||
name: 'prague', | ||
comment: 'Next feature hardfork after cancun, internally used for verkle testing/implementation (incomplete/experimental)', | ||
comment: 'Next feature hardfork after cancun, internally used for pectra testing/implementation (incomplete/experimental)', | ||
url: 'https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/prague.md', | ||
status: Status.Draft, | ||
eips: [6800], | ||
eips: [2537, 2935, 3074, 6110, 7002, 7251, 7685], | ||
}, | ||
osaka: { | ||
name: 'osaka', | ||
comment: 'Next feature hardfork after prague, internally used for verkle testing/implementation (incomplete/experimental)', | ||
url: 'https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/osaka.md', | ||
status: Status.Draft, | ||
eips: [2935, 6800], | ||
}, | ||
}; | ||
//# sourceMappingURL=hardforks.js.map |
@@ -52,2 +52,63 @@ /** | ||
export declare type AccessList = AccessListItem[]; | ||
/** | ||
* Authorization list types | ||
*/ | ||
export declare type AuthorizationListItem = { | ||
chainId: PrefixedHexString; | ||
address: PrefixedHexString; | ||
nonce: PrefixedHexString[]; | ||
yParity: PrefixedHexString; | ||
r: PrefixedHexString; | ||
s: PrefixedHexString; | ||
}; | ||
export declare type AuthorizationListBytesItem = [ | ||
Uint8Array, | ||
Uint8Array, | ||
Uint8Array[], | ||
Uint8Array, | ||
Uint8Array, | ||
Uint8Array | ||
]; | ||
export declare type AuthorizationListBytes = AuthorizationListBytesItem[]; | ||
export declare type AuthorizationList = AuthorizationListItem[]; | ||
/** | ||
* Verkle related | ||
* | ||
* Experimental (do not implement) | ||
*/ | ||
export declare type AccessEventFlags = { | ||
stemRead: boolean; | ||
stemWrite: boolean; | ||
chunkRead: boolean; | ||
chunkWrite: boolean; | ||
chunkFill: boolean; | ||
}; | ||
/** | ||
* Verkle related | ||
* | ||
* Experimental (do not implement) | ||
*/ | ||
export interface AccessWitnessInterface { | ||
touchAndChargeProofOfAbsence(address: Address): bigint; | ||
touchAndChargeMessageCall(address: Address): bigint; | ||
touchAndChargeValueTransfer(caller: Address, target: Address): bigint; | ||
touchAndChargeContractCreateInit(address: Address): bigint; | ||
touchAndChargeContractCreateCompleted(address: Address): bigint; | ||
touchTxOriginAndComputeGas(origin: Address): bigint; | ||
touchTxTargetAndComputeGas(target: Address, { sendsValue }: { | ||
sendsValue?: boolean; | ||
}): bigint; | ||
touchCodeChunksRangeOnReadAndChargeGas(contact: Address, startPc: number, endPc: number): bigint; | ||
touchCodeChunksRangeOnWriteAndChargeGas(contact: Address, startPc: number, endPc: number): bigint; | ||
touchAddressOnWriteAndComputeGas(address: Address, treeIndex: number | bigint, subIndex: number | Uint8Array): bigint; | ||
touchAddressOnReadAndComputeGas(address: Address, treeIndex: number | bigint, subIndex: number | Uint8Array): bigint; | ||
touchAddressAndChargeGas(address: Address, treeIndex: number | bigint, subIndex: number | Uint8Array, { isWrite }: { | ||
isWrite?: boolean; | ||
}): bigint; | ||
touchAddress(address: Address, treeIndex: number | bigint, subIndex: number | Uint8Array, { isWrite }: { | ||
isWrite?: boolean; | ||
}): AccessEventFlags; | ||
shallowCopy(): AccessWitnessInterface; | ||
merge(accessWitness: AccessWitnessInterface): void; | ||
} | ||
export interface StateManagerInterface { | ||
@@ -60,2 +121,3 @@ getAccount(address: Address): Promise<Account | undefined>; | ||
getContractCode(address: Address): Promise<Uint8Array>; | ||
getContractCodeSize?(address: Address): Promise<number>; | ||
getContractStorage(address: Address, key: Uint8Array): Promise<Uint8Array>; | ||
@@ -73,2 +135,3 @@ putContractStorage(address: Address, key: Uint8Array, value: Uint8Array): Promise<void>; | ||
getAppliedKey?(address: Uint8Array): Uint8Array; | ||
checkChunkWitnessPresent?(contract: Address, programCounter: number): Promise<boolean>; | ||
} | ||
@@ -75,0 +138,0 @@ export interface EVMStateManagerInterface extends StateManagerInterface { |
import type { Chain, ConsensusAlgorithm, ConsensusType, Hardfork } from './enums.js'; | ||
import type { BigIntLike, ECDSASignature, Kzg } from '@ethereumjs/util'; | ||
import type { BigIntLike, ECDSASignature, Kzg, PrefixedHexString } from '@ethereumjs/util'; | ||
export interface ChainName { | ||
@@ -35,11 +35,12 @@ [chainId: string]: string; | ||
consensus: ConsensusConfig; | ||
depositContractAddress?: PrefixedHexString; | ||
} | ||
export interface GenesisBlockConfig { | ||
timestamp?: string; | ||
gasLimit: number | string; | ||
difficulty: number | string; | ||
nonce: string; | ||
extraData: string; | ||
baseFeePerGas?: string; | ||
excessBlobGas?: string; | ||
timestamp?: PrefixedHexString | string; | ||
gasLimit: number | PrefixedHexString | string; | ||
difficulty: number | PrefixedHexString | string; | ||
nonce: PrefixedHexString | string; | ||
extraData: PrefixedHexString | string; | ||
baseFeePerGas?: PrefixedHexString | string; | ||
excessBlobGas?: PrefixedHexString | string; | ||
} | ||
@@ -51,3 +52,3 @@ export interface HardforkTransitionConfig { | ||
timestamp?: number | string; | ||
forkHash?: string | null; | ||
forkHash?: PrefixedHexString | null; | ||
} | ||
@@ -87,3 +88,7 @@ export interface BootstrapNodeConfig { | ||
* Selected EIPs which can be activated, please use an array for instantiation | ||
* (e.g. `eips: [ 1559, 3860 ]`) | ||
* (e.g. `eips: [ 2537, ]`) | ||
* | ||
* Currently supported: | ||
* | ||
* - [EIP-2537](https://eips.ethereum.org/EIPS/eip-2537) - BLS12-381 precompiles | ||
*/ | ||
@@ -142,5 +147,5 @@ eips?: number[]; | ||
export interface HardforkByOpts { | ||
blockNumber?: BigIntLike; | ||
timestamp?: BigIntLike; | ||
td?: BigIntLike; | ||
blockNumber?: BigIntLike | string; | ||
timestamp?: BigIntLike | string; | ||
td?: BigIntLike | string; | ||
} | ||
@@ -147,0 +152,0 @@ declare type ParamDict = { |
@@ -20,12 +20,13 @@ declare type ConfigHardfork = { | ||
networkId: number; | ||
depositContractAddress: `0x${string}`; | ||
genesis: { | ||
timestamp: string; | ||
gasLimit: string; | ||
difficulty: string; | ||
nonce: string; | ||
extraData: string; | ||
mixHash: string; | ||
coinbase: string; | ||
baseFeePerGas: string; | ||
excessBlobGas: string; | ||
timestamp: `0x${string}`; | ||
gasLimit: `0x${string}`; | ||
difficulty: `0x${string}`; | ||
nonce: `0x${string}`; | ||
extraData: `0x${string}`; | ||
mixHash: `0x${string}`; | ||
coinbase: `0x${string}`; | ||
baseFeePerGas: `0x${string}`; | ||
excessBlobGas: `0x${string}`; | ||
}; | ||
@@ -32,0 +33,0 @@ hardfork: string | undefined; |
@@ -1,2 +0,2 @@ | ||
import { intToHex, isHexPrefixed, stripHexPrefix } from '@ethereumjs/util'; | ||
import { intToHex, isHexString, stripHexPrefix } from '@ethereumjs/util'; | ||
import { Hardfork } from './enums.js'; | ||
@@ -12,6 +12,6 @@ /** | ||
} | ||
if (isHexPrefixed(nonce)) { | ||
return '0x' + stripHexPrefix(nonce).padStart(16, '0'); | ||
if (isHexString(nonce)) { | ||
return `0x${stripHexPrefix(nonce).padStart(16, '0')}`; | ||
} | ||
return '0x' + nonce.padStart(16, '0'); | ||
return `0x${nonce.padStart(16, '0')}`; | ||
} | ||
@@ -27,18 +27,13 @@ /** | ||
function parseGethParams(json, mergeForkIdPostMerge = true) { | ||
const { name, config, difficulty, mixHash, gasLimit, coinbase, baseFeePerGas, excessBlobGas, } = json; | ||
let { extraData, timestamp, nonce } = json; | ||
const genesisTimestamp = Number(timestamp); | ||
const { chainId } = config; | ||
const { name, config, difficulty, mixHash, gasLimit, coinbase, baseFeePerGas, excessBlobGas, extraData: unparsedExtraData, nonce: unparsedNonce, timestamp: unparsedTimestamp, } = json; | ||
const genesisTimestamp = Number(unparsedTimestamp); | ||
const { chainId, depositContractAddress, } = config; | ||
// geth is not strictly putting empty fields with a 0x prefix | ||
if (extraData === '') { | ||
extraData = '0x'; | ||
} | ||
const extraData = unparsedExtraData === '' ? '0x' : unparsedExtraData; | ||
// geth may use number for timestamp | ||
if (!isHexPrefixed(timestamp)) { | ||
timestamp = intToHex(parseInt(timestamp)); | ||
} | ||
// geth may not give us a nonce strictly formatted to an 8 byte hex string | ||
if (nonce.length !== 18) { | ||
nonce = formatNonce(nonce); | ||
} | ||
const timestamp = isHexString(unparsedTimestamp) | ||
? unparsedTimestamp | ||
: intToHex(parseInt(unparsedTimestamp)); | ||
// geth may not give us a nonce strictly formatted to an 8 byte 0x-prefixed hex string | ||
const nonce = unparsedNonce.length !== 18 ? formatNonce(unparsedNonce) : unparsedNonce; | ||
// EIP155 and EIP158 are both part of Spurious Dragon hardfork and must occur at the same time | ||
@@ -53,2 +48,3 @@ // but have different configuration parameters in geth genesis parameters | ||
networkId: chainId, | ||
depositContractAddress, | ||
genesis: { | ||
@@ -102,2 +98,3 @@ timestamp, | ||
[Hardfork.Prague]: { name: 'pragueTime', postMerge: true, isTimestamp: true }, | ||
[Hardfork.Osaka]: { name: 'osakaTime', postMerge: true, isTimestamp: true }, | ||
}; | ||
@@ -173,6 +170,8 @@ // forkMapRev is the map from config field name to Hardfork | ||
} | ||
// We copy the JSON object here because it's frozen in browser and properties can't be modified | ||
const finalJson = { ...json }; | ||
if (name !== undefined) { | ||
json.name = name; | ||
finalJson.name = name; | ||
} | ||
return parseGethParams(json, mergeForkIdPostMerge); | ||
return parseGethParams(finalJson, mergeForkIdPostMerge); | ||
} | ||
@@ -179,0 +178,0 @@ catch (e) { |
{ | ||
"name": "@ethereumjs/common", | ||
"version": "4.3.0", | ||
"version": "4.4.0", | ||
"description": "Resources common to all Ethereum implementations", | ||
@@ -53,4 +53,4 @@ "keywords": [ | ||
"prepublishOnly": "../../config/cli/prepublish.sh", | ||
"test": "npm run test:node && npm run test:browser", | ||
"test:browser": "npx vitest run --browser.name=chrome --browser.headless", | ||
"test": "npm run test:node", | ||
"test:browser": "npx vitest run --config=../../config/vitest.config.browser.mts", | ||
"test:node": "npx vitest run", | ||
@@ -60,3 +60,3 @@ "tsc": "../../config/cli/ts-compile.sh" | ||
"dependencies": { | ||
"@ethereumjs/util": "^9.0.3" | ||
"@ethereumjs/util": "^9.1.0" | ||
}, | ||
@@ -63,0 +63,0 @@ "devDependencies": { |
@@ -408,7 +408,6 @@ # @ethereumjs/common | ||
- [EIP-1559](https://eips.ethereum.org/EIPS/eip-1559) - Fee market change for ETH 1.0 chain | ||
- [EIP-2315](https://eips.ethereum.org/EIPS/eip-2315) - Simple subroutines for the EVM (`outdated`) | ||
- [EIP-2537](https://eips.ethereum.org/EIPS/eip-2537) - BLS precompiles (removed in v4.0.0, see latest v3 release) | ||
- [EIP-2565](https://eips.ethereum.org/EIPS/eip-2565) - ModExp gas cost | ||
- [EIP-2718](https://eips.ethereum.org/EIPS/eip-2718) - Transaction Types | ||
- [EIP-2935](https://eips.ethereum.org/EIPS/eip-2935) - Save historical block hashes in state (`experimental`) | ||
- [EIP-2935](https://eips.ethereum.org/EIPS/eip-2935) - Serve historical block hashes from state (Prague) | ||
- [EIP-2929](https://eips.ethereum.org/EIPS/eip-2929) - gas cost increases for state access opcodes | ||
@@ -435,4 +434,10 @@ - [EIP-2930](https://eips.ethereum.org/EIPS/eip-2930) - Optional access list tx type | ||
- [EIP-5656](https://eips.ethereum.org/EIPS/eip-5656) - MCOPY - Memory copying instruction (Cancun) | ||
- [EIP-6110](https://eips.ethereum.org/EIPS/eip-6110) - Supply validator deposits on chain (Prague) | ||
- [EIP-6780](https://eips.ethereum.org/EIPS/eip-6780) - SELFDESTRUCT only in same transaction (Cancun) | ||
- [EIP-7002](https://eips.ethereum.org/EIPS/eip-7002) - Execution layer triggerable withdrawals (Prague) | ||
- [EIP-7251](https://eips.ethereum.org/EIPS/eip-7251) - Execution layer triggerable validator consolidations (Prague) | ||
- [EIP-7702](https://eips.ethereum.org/EIPS/eip-7702) - EOA code transactions (Prague) (`outdated`) | ||
- [EIP-7709](https://eips.ethereum.org/EIPS/eip-7709) - Read BLOCKHASH from storage and update cost (Osaka) | ||
- [EIP-7516](https://eips.ethereum.org/EIPS/eip-7516) - BLOBBASEFEE opcode (Cancun) | ||
- [EIP-7685](https://eips.ethereum.org/EIPS/eip-7685) - General purpose execution layer requests (Prague) | ||
@@ -439,0 +444,0 @@ ### Bootstrap Nodes |
@@ -26,2 +26,3 @@ import type { ChainConfig } from './types.js' | ||
}, | ||
depositContractAddress: '0x00000000219ab540356cBB839Cbe05303d7705Fa', | ||
hardforks: [ | ||
@@ -123,2 +124,6 @@ { | ||
}, | ||
{ | ||
name: 'prague', | ||
block: null, | ||
}, | ||
], | ||
@@ -575,7 +580,7 @@ bootstrapNodes: [ | ||
}, | ||
kaustinen: { | ||
name: 'kaustinen', | ||
kaustinen6: { | ||
name: 'kaustinen6', | ||
chainId: 69420, | ||
networkId: 69420, | ||
defaultHardfork: 'prague', | ||
defaultHardfork: 'osaka', | ||
consensus: { | ||
@@ -585,3 +590,3 @@ type: 'pos', | ||
}, | ||
comment: 'Verkle kaustinen testnet 2 (likely temporary, do not hard-wire into production code)', | ||
comment: 'Verkle kaustinen testnet 6 (likely temporary, do not hard-wire into production code)', | ||
url: 'https://github.com/eth-clients/kaustinen/', | ||
@@ -593,3 +598,3 @@ genesis: { | ||
nonce: '0x0000000000001234', | ||
timestamp: '0x65608a64', | ||
timestamp: '0x66190fbc', | ||
}, | ||
@@ -652,5 +657,5 @@ hardforks: [ | ||
{ | ||
name: 'prague', | ||
name: 'osaka', | ||
block: null, | ||
timestamp: '1700825700', | ||
timestamp: '1712848500', | ||
}, | ||
@@ -657,0 +662,0 @@ ], |
@@ -160,4 +160,3 @@ import { | ||
}, | ||
// Optimism has not implemented the London hardfork yet (targeting Q1.22) | ||
{ hardfork: Hardfork.Berlin, ...opts } | ||
opts | ||
) | ||
@@ -886,3 +885,3 @@ } | ||
) { | ||
const hfBlockBytes = hexToBytes('0x' + blockOrTime.toString(16).padStart(16, '0')) | ||
const hfBlockBytes = hexToBytes(`0x${blockOrTime.toString(16).padStart(16, '0')}`) | ||
hfBytes = concatBytes(hfBytes, hfBlockBytes) | ||
@@ -889,0 +888,0 @@ prevBlockOrTime = blockOrTime |
204
src/eips.ts
@@ -55,23 +55,2 @@ import { Hardfork } from './enums.js' | ||
}, | ||
2315: { | ||
comment: 'Simple subroutines for the EVM', | ||
url: 'https://eips.ethereum.org/EIPS/eip-2315', | ||
status: Status.Draft, | ||
minimumHardfork: Hardfork.Istanbul, | ||
requiredEIPs: [], | ||
gasPrices: { | ||
beginsub: { | ||
v: 2, | ||
d: 'Base fee of the BEGINSUB opcode', | ||
}, | ||
returnsub: { | ||
v: 5, | ||
d: 'Base fee of the RETURNSUB opcode', | ||
}, | ||
jumpsub: { | ||
v: 10, | ||
d: 'Base fee of the JUMPSUB opcode', | ||
}, | ||
}, | ||
}, | ||
2565: { | ||
@@ -90,2 +69,46 @@ comment: 'ModExp gas cost', | ||
}, | ||
2537: { | ||
comment: 'BLS12-381 precompiles', | ||
url: 'https://eips.ethereum.org/EIPS/eip-2537', | ||
status: 'Draft', | ||
minimumHardfork: Hardfork.Chainstart, | ||
requiredEIPs: [], | ||
gasConfig: {}, | ||
gasPrices: { | ||
Bls12381G1AddGas: { | ||
v: 500, | ||
d: 'Gas cost of a single BLS12-381 G1 addition precompile-call', | ||
}, | ||
Bls12381G1MulGas: { | ||
v: 12000, | ||
d: 'Gas cost of a single BLS12-381 G1 multiplication precompile-call', | ||
}, | ||
Bls12381G2AddGas: { | ||
v: 800, | ||
d: 'Gas cost of a single BLS12-381 G2 addition precompile-call', | ||
}, | ||
Bls12381G2MulGas: { | ||
v: 45000, | ||
d: 'Gas cost of a single BLS12-381 G2 multiplication precompile-call', | ||
}, | ||
Bls12381PairingBaseGas: { | ||
v: 65000, | ||
d: 'Base gas cost of BLS12-381 pairing check', | ||
}, | ||
Bls12381PairingPerPairGas: { | ||
v: 43000, | ||
d: 'Per-pair gas cost of BLS12-381 pairing check', | ||
}, | ||
Bls12381MapG1Gas: { | ||
v: 5500, | ||
d: 'Gas cost of BLS12-381 map field element to G1', | ||
}, | ||
Bls12381MapG2Gas: { | ||
v: 75000, | ||
d: 'Gas cost of BLS12-381 map field element to G2', | ||
}, | ||
}, | ||
vm: {}, | ||
pow: {}, | ||
}, | ||
2718: { | ||
@@ -204,7 +227,7 @@ comment: 'Typed Transaction Envelope', | ||
historyStorageAddress: { | ||
v: BigInt('0xfffffffffffffffffffffffffffffffffffffffe'), | ||
v: BigInt('0x0aae40965e6800cd9b1f4b05ff21581047e3f91e'), | ||
d: 'The address where the historical blockhashes are stored', | ||
}, | ||
historyServeWindow: { | ||
v: BigInt(256), | ||
v: BigInt(8192), | ||
d: 'The amount of blocks to be served by the historical blockhash contract', | ||
@@ -216,3 +239,3 @@ }, | ||
comment: 'AUTH and AUTHCALL opcodes', | ||
url: 'https://eips.ethereum.org/EIPS/eip-3074', | ||
url: 'https://github.com/ethereum/EIPs/commit/eca4416ff3c025fcb6ec8cd4eac481e74e108481', | ||
status: Status.Review, | ||
@@ -489,2 +512,9 @@ minimumHardfork: Hardfork.London, | ||
}, | ||
6110: { | ||
comment: 'Supply validator deposits on chain', | ||
url: 'https://eips.ethereum.org/EIPS/eip-6110', | ||
status: Status.Draft, | ||
minimumHardfork: Hardfork.Cancun, | ||
requiredEIPs: [7685], | ||
}, | ||
6780: { | ||
@@ -503,3 +533,99 @@ comment: 'SELFDESTRUCT only in same transaction', | ||
requiredEIPs: [], | ||
gasPrices: { | ||
create: { | ||
v: 1000, | ||
d: 'Base fee of the CREATE opcode', | ||
}, | ||
coldsload: { | ||
v: 0, | ||
d: 'Gas cost of the first read of storage from a given location (per transaction)', | ||
}, | ||
}, | ||
vm: { | ||
// kaustinen 6 current uses this address, however this will be updated to correct address | ||
// in next iteration | ||
historyStorageAddress: { | ||
v: BigInt('0xfffffffffffffffffffffffffffffffffffffffe'), | ||
d: 'The address where the historical blockhashes are stored', | ||
}, | ||
}, | ||
}, | ||
7002: { | ||
comment: 'Execution layer triggerable withdrawals (experimental)', | ||
url: 'https://github.com/ethereum/EIPs/blob/3b5fcad6b35782f8aaeba7d4ac26004e8fbd720f/EIPS/eip-7002.md', | ||
status: Status.Draft, | ||
minimumHardfork: Hardfork.Paris, | ||
requiredEIPs: [7685], | ||
vm: { | ||
withdrawalRequestType: { | ||
v: BigInt(0x01), | ||
d: 'The withdrawal request type for EIP-7685', | ||
}, | ||
excessWithdrawalsRequestStorageSlot: { | ||
v: BigInt(0), | ||
d: 'The storage slot of the excess withdrawals', | ||
}, | ||
withdrawalsRequestCountStorage: { | ||
v: BigInt(1), | ||
d: 'The storage slot of the withdrawal request count', | ||
}, | ||
withdrawalsRequestQueueHeadStorageSlot: { | ||
v: BigInt(2), | ||
d: 'The storage slot of the withdrawal request head of the queue', | ||
}, | ||
withdrawalsRequestTailHeadStorageSlot: { | ||
v: BigInt(3), | ||
d: 'The storage slot of the withdrawal request tail of the queue', | ||
}, | ||
withdrawalsRequestQueueStorageOffset: { | ||
v: BigInt(4), | ||
d: 'The storage slot of the withdrawal request queue offset', | ||
}, | ||
maxWithdrawalRequestsPerBlock: { | ||
v: BigInt(16), | ||
d: 'The max withdrawal requests per block', | ||
}, | ||
targetWithdrawalRequestsPerBlock: { | ||
v: BigInt(2), | ||
d: 'The target withdrawal requests per block', | ||
}, | ||
minWithdrawalRequestFee: { | ||
v: BigInt(1), | ||
d: 'The minimum withdrawal request fee (in wei)', | ||
}, | ||
withdrawalRequestFeeUpdateFraction: { | ||
v: BigInt(17), | ||
d: 'The withdrawal request fee update fraction (used in the fake exponential)', | ||
}, | ||
systemAddress: { | ||
v: BigInt('0xfffffffffffffffffffffffffffffffffffffffe'), | ||
d: 'The system address to perform operations on the withdrawal requests predeploy address', | ||
}, | ||
withdrawalRequestPredeployAddress: { | ||
v: BigInt('0x00A3ca265EBcb825B45F985A16CEFB49958cE017'), | ||
d: 'Address of the validator excess address', | ||
}, | ||
}, | ||
}, | ||
7251: { | ||
comment: 'Execution layer triggered consolidations (experimental)', | ||
url: 'https://eips.ethereum.org/EIPS/eip-7251', | ||
status: Status.Draft, | ||
minimumHardfork: Hardfork.Paris, | ||
requiredEIPs: [7685], | ||
vm: { | ||
consolidationRequestType: { | ||
v: BigInt(0x02), | ||
d: 'The withdrawal request type for EIP-7685', | ||
}, | ||
systemAddress: { | ||
v: BigInt('0xfffffffffffffffffffffffffffffffffffffffe'), | ||
d: 'The system address to perform operations on the consolidation requests predeploy address', | ||
}, | ||
consolidationRequestPredeployAddress: { | ||
v: BigInt('0x00b42dbF2194e931E80326D950320f7d9Dbeac02'), | ||
d: 'Address of the consolidations contract', | ||
}, | ||
}, | ||
}, | ||
7516: { | ||
@@ -518,2 +644,32 @@ comment: 'BLOBBASEFEE opcode', | ||
}, | ||
7685: { | ||
comment: 'General purpose execution layer requests', | ||
url: 'https://eips.ethereum.org/EIPS/eip-7685', | ||
status: Status.Draft, | ||
// TODO: Set correct minimum hardfork | ||
minimumHardfork: Hardfork.Cancun, | ||
requiredEIPs: [3675], | ||
gasPrices: {}, | ||
}, | ||
7702: { | ||
comment: 'Set EOA account code for one transaction', | ||
url: 'https://github.com/ethereum/EIPs/blob/62419ca3f45375db00b04a368ea37c0bfb05386a/EIPS/eip-7702.md', | ||
status: Status.Review, | ||
// TODO: Set correct minimum hardfork | ||
minimumHardfork: Hardfork.Cancun, | ||
requiredEIPs: [2718, 2929, 2930], | ||
gasPrices: { | ||
perAuthBaseCost: { | ||
v: 2500, | ||
d: 'Gas cost of each authority item', | ||
}, | ||
}, | ||
}, | ||
7709: { | ||
comment: 'Use historical block hashes saved in state for BLOCKHASH', | ||
url: 'https://eips.ethereum.org/EIPS/eip-7709', | ||
status: Status.Draft, | ||
minimumHardfork: Hardfork.Chainstart, | ||
requiredEIPs: [2935], | ||
}, | ||
} |
@@ -8,3 +8,3 @@ import { BIGINT_0, hexToBytes } from '@ethereumjs/util' | ||
Holesky = 17000, | ||
Kaustinen = 69420, | ||
Kaustinen6 = 69420, | ||
} | ||
@@ -48,6 +48,6 @@ | ||
}, | ||
[Chain.Kaustinen]: { | ||
name: 'kaustinen', | ||
[Chain.Kaustinen6]: { | ||
name: 'kaustinen6', | ||
blockNumber: BIGINT_0, | ||
stateRoot: hexToBytes('0x5e8519756841faf0b2c28951c451b61a4b407b70a5ce5b57992f4bec973173ff'), | ||
stateRoot: hexToBytes('0x1fbf85345a3cbba9a6d44f991b721e55620a22397c2a93ee8d5011136ac300ee'), | ||
}, | ||
@@ -76,2 +76,3 @@ } | ||
Prague = 'prague', | ||
Osaka = 'osaka', | ||
} | ||
@@ -78,0 +79,0 @@ |
@@ -841,7 +841,15 @@ import type { HardforksDict } from './types.js' | ||
comment: | ||
'Next feature hardfork after cancun, internally used for verkle testing/implementation (incomplete/experimental)', | ||
'Next feature hardfork after cancun, internally used for pectra testing/implementation (incomplete/experimental)', | ||
url: 'https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/prague.md', | ||
status: Status.Draft, | ||
eips: [6800], | ||
eips: [2537, 2935, 3074, 6110, 7002, 7251, 7685], | ||
}, | ||
osaka: { | ||
name: 'osaka', | ||
comment: | ||
'Next feature hardfork after prague, internally used for verkle testing/implementation (incomplete/experimental)', | ||
url: 'https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/osaka.md', | ||
status: Status.Draft, | ||
eips: [2935, 6800], | ||
}, | ||
} |
@@ -68,2 +68,84 @@ /** | ||
/** | ||
* Authorization list types | ||
*/ | ||
export type AuthorizationListItem = { | ||
chainId: PrefixedHexString | ||
address: PrefixedHexString | ||
nonce: PrefixedHexString[] | ||
yParity: PrefixedHexString | ||
r: PrefixedHexString | ||
s: PrefixedHexString | ||
} | ||
// Tuple of [chain_id, address, [nonce], y_parity, r, s] | ||
export type AuthorizationListBytesItem = [ | ||
Uint8Array, | ||
Uint8Array, | ||
Uint8Array[], | ||
Uint8Array, | ||
Uint8Array, | ||
Uint8Array | ||
] | ||
export type AuthorizationListBytes = AuthorizationListBytesItem[] | ||
export type AuthorizationList = AuthorizationListItem[] | ||
/** | ||
* Verkle related | ||
* | ||
* Experimental (do not implement) | ||
*/ | ||
export type AccessEventFlags = { | ||
stemRead: boolean | ||
stemWrite: boolean | ||
chunkRead: boolean | ||
chunkWrite: boolean | ||
chunkFill: boolean | ||
} | ||
/** | ||
* Verkle related | ||
* | ||
* Experimental (do not implement) | ||
*/ | ||
export interface AccessWitnessInterface { | ||
touchAndChargeProofOfAbsence(address: Address): bigint | ||
touchAndChargeMessageCall(address: Address): bigint | ||
touchAndChargeValueTransfer(caller: Address, target: Address): bigint | ||
touchAndChargeContractCreateInit(address: Address): bigint | ||
touchAndChargeContractCreateCompleted(address: Address): bigint | ||
touchTxOriginAndComputeGas(origin: Address): bigint | ||
touchTxTargetAndComputeGas(target: Address, { sendsValue }: { sendsValue?: boolean }): bigint | ||
touchCodeChunksRangeOnReadAndChargeGas(contact: Address, startPc: number, endPc: number): bigint | ||
touchCodeChunksRangeOnWriteAndChargeGas(contact: Address, startPc: number, endPc: number): bigint | ||
touchAddressOnWriteAndComputeGas( | ||
address: Address, | ||
treeIndex: number | bigint, | ||
subIndex: number | Uint8Array | ||
): bigint | ||
touchAddressOnReadAndComputeGas( | ||
address: Address, | ||
treeIndex: number | bigint, | ||
subIndex: number | Uint8Array | ||
): bigint | ||
touchAddressAndChargeGas( | ||
address: Address, | ||
treeIndex: number | bigint, | ||
subIndex: number | Uint8Array, | ||
{ isWrite }: { isWrite?: boolean } | ||
): bigint | ||
touchAddress( | ||
address: Address, | ||
treeIndex: number | bigint, | ||
subIndex: number | Uint8Array, | ||
{ isWrite }: { isWrite?: boolean } | ||
): AccessEventFlags | ||
shallowCopy(): AccessWitnessInterface | ||
merge(accessWitness: AccessWitnessInterface): void | ||
} | ||
/* | ||
* Generic StateManager interface corresponding with the @ethereumjs/statemanager package | ||
* | ||
*/ | ||
export interface StateManagerInterface { | ||
@@ -76,2 +158,3 @@ getAccount(address: Address): Promise<Account | undefined> | ||
getContractCode(address: Address): Promise<Uint8Array> | ||
getContractCodeSize?(address: Address): Promise<number> | ||
getContractStorage(address: Address, key: Uint8Array): Promise<Uint8Array> | ||
@@ -89,2 +172,9 @@ putContractStorage(address: Address, key: Uint8Array, value: Uint8Array): Promise<void> | ||
getAppliedKey?(address: Uint8Array): Uint8Array | ||
/* | ||
* The following optional methods are Verkle related | ||
* | ||
* Experimental (do not implement) | ||
*/ | ||
checkChunkWitnessPresent?(contract: Address, programCounter: number): Promise<boolean> | ||
} | ||
@@ -91,0 +181,0 @@ |
import type { Chain, ConsensusAlgorithm, ConsensusType, Hardfork } from './enums.js' | ||
import type { BigIntLike, ECDSASignature, Kzg } from '@ethereumjs/util' | ||
import type { BigIntLike, ECDSASignature, Kzg, PrefixedHexString } from '@ethereumjs/util' | ||
@@ -41,12 +41,14 @@ export interface ChainName { | ||
consensus: ConsensusConfig | ||
depositContractAddress?: PrefixedHexString | ||
} | ||
// TODO: Remove the string type and only keep PrefixedHexString | ||
export interface GenesisBlockConfig { | ||
timestamp?: string | ||
gasLimit: number | string | ||
difficulty: number | string | ||
nonce: string | ||
extraData: string | ||
baseFeePerGas?: string | ||
excessBlobGas?: string | ||
timestamp?: PrefixedHexString | string | ||
gasLimit: number | PrefixedHexString | string | ||
difficulty: number | PrefixedHexString | string | ||
nonce: PrefixedHexString | string | ||
extraData: PrefixedHexString | string | ||
baseFeePerGas?: PrefixedHexString | string | ||
excessBlobGas?: PrefixedHexString | string | ||
} | ||
@@ -59,3 +61,3 @@ | ||
timestamp?: number | string | ||
forkHash?: string | null | ||
forkHash?: PrefixedHexString | null | ||
} | ||
@@ -101,3 +103,7 @@ | ||
* Selected EIPs which can be activated, please use an array for instantiation | ||
* (e.g. `eips: [ 1559, 3860 ]`) | ||
* (e.g. `eips: [ 2537, ]`) | ||
* | ||
* Currently supported: | ||
* | ||
* - [EIP-2537](https://eips.ethereum.org/EIPS/eip-2537) - BLS12-381 precompiles | ||
*/ | ||
@@ -159,6 +165,7 @@ eips?: number[] | ||
// TODO: Deprecate the string type and only keep BigIntLike | ||
export interface HardforkByOpts { | ||
blockNumber?: BigIntLike | ||
timestamp?: BigIntLike | ||
td?: BigIntLike | ||
blockNumber?: BigIntLike | string | ||
timestamp?: BigIntLike | string | ||
td?: BigIntLike | string | ||
} | ||
@@ -165,0 +172,0 @@ |
@@ -1,5 +0,7 @@ | ||
import { intToHex, isHexPrefixed, stripHexPrefix } from '@ethereumjs/util' | ||
import { intToHex, isHexString, stripHexPrefix } from '@ethereumjs/util' | ||
import { Hardfork } from './enums.js' | ||
import type { PrefixedHexString } from '@ethereumjs/util' | ||
type ConfigHardfork = | ||
@@ -13,10 +15,10 @@ | { name: string; block: null; timestamp: number } | ||
*/ | ||
function formatNonce(nonce: string): string { | ||
function formatNonce(nonce: string): PrefixedHexString { | ||
if (!nonce || nonce === '0x0') { | ||
return '0x0000000000000000' | ||
} | ||
if (isHexPrefixed(nonce)) { | ||
return '0x' + stripHexPrefix(nonce).padStart(16, '0') | ||
if (isHexString(nonce)) { | ||
return `0x${stripHexPrefix(nonce).padStart(16, '0')}` | ||
} | ||
return '0x' + nonce.padStart(16, '0') | ||
return `0x${nonce.padStart(16, '0')}` | ||
} | ||
@@ -42,30 +44,37 @@ | ||
excessBlobGas, | ||
extraData: unparsedExtraData, | ||
nonce: unparsedNonce, | ||
timestamp: unparsedTimestamp, | ||
}: { | ||
name: string | ||
config: any | ||
difficulty: string | ||
mixHash: string | ||
gasLimit: string | ||
coinbase: string | ||
baseFeePerGas: string | ||
excessBlobGas: string | ||
difficulty: PrefixedHexString | ||
mixHash: PrefixedHexString | ||
gasLimit: PrefixedHexString | ||
coinbase: PrefixedHexString | ||
baseFeePerGas: PrefixedHexString | ||
excessBlobGas: PrefixedHexString | ||
extraData: string | ||
nonce: string | ||
timestamp: string | ||
} = json | ||
let { extraData, timestamp, nonce }: { extraData: string; timestamp: string; nonce: string } = | ||
json | ||
const genesisTimestamp = Number(timestamp) | ||
const { chainId }: { chainId: number } = config | ||
const genesisTimestamp = Number(unparsedTimestamp) | ||
const { | ||
chainId, | ||
depositContractAddress, | ||
}: { chainId: number; depositContractAddress: PrefixedHexString } = config | ||
// geth is not strictly putting empty fields with a 0x prefix | ||
if (extraData === '') { | ||
extraData = '0x' | ||
} | ||
const extraData: PrefixedHexString = | ||
unparsedExtraData === '' ? '0x' : (unparsedExtraData as PrefixedHexString) | ||
// geth may use number for timestamp | ||
if (!isHexPrefixed(timestamp)) { | ||
timestamp = intToHex(parseInt(timestamp)) | ||
} | ||
// geth may not give us a nonce strictly formatted to an 8 byte hex string | ||
if (nonce.length !== 18) { | ||
nonce = formatNonce(nonce) | ||
} | ||
const timestamp: PrefixedHexString = isHexString(unparsedTimestamp) | ||
? unparsedTimestamp | ||
: intToHex(parseInt(unparsedTimestamp)) | ||
// geth may not give us a nonce strictly formatted to an 8 byte 0x-prefixed hex string | ||
const nonce: PrefixedHexString = | ||
unparsedNonce.length !== 18 ? formatNonce(unparsedNonce) : (unparsedNonce as PrefixedHexString) | ||
// EIP155 and EIP158 are both part of Spurious Dragon hardfork and must occur at the same time | ||
@@ -83,2 +92,3 @@ // but have different configuration parameters in geth genesis parameters | ||
networkId: chainId, | ||
depositContractAddress, | ||
genesis: { | ||
@@ -134,2 +144,3 @@ timestamp, | ||
[Hardfork.Prague]: { name: 'pragueTime', postMerge: true, isTimestamp: true }, | ||
[Hardfork.Osaka]: { name: 'osakaTime', postMerge: true, isTimestamp: true }, | ||
} | ||
@@ -220,6 +231,10 @@ | ||
} | ||
// We copy the JSON object here because it's frozen in browser and properties can't be modified | ||
const finalJson = { ...json } | ||
if (name !== undefined) { | ||
json.name = name | ||
finalJson.name = name | ||
} | ||
return parseGethParams(json, mergeForkIdPostMerge) | ||
return parseGethParams(finalJson, mergeForkIdPostMerge) | ||
} catch (e: any) { | ||
@@ -226,0 +241,0 @@ throw new Error(`Error parsing parameters file: ${e.message}`) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
713356
12595
464
Updated@ethereumjs/util@^9.1.0