Skip to content

Commit 99cfdd6

Browse files
jochem-brouwerg11techlucassaldanha
authored
Implement pectra devnet-5 spec (#3807)
* evm: add devnet-5 EIP-7702 changes * vm: add devnet-5 EIP-7685 changes * monorepo: make cspell happy * vm/client: fix tests * evm: remove redundant test * remove accidental console.log * remove 7742 and add 7691 independently * fix t8ntool empty requests reporting * client: fix engine reporting empty requests * t8n: fix requests reporting * Implement EIP 7623: calldata cost increase (#3813) * common/evm/vm: implement EIP7623 calldata cost increase * move the floorcost update and add debug log * fix t8ntool empty requests reporting * common: add 7623 * tx: add 7623 validator * t8n: throw on invalid txs * make cspell happy --------- Co-authored-by: harkamal <[email protected]> * client: fix requests contract address (devnet-5) (#3818) * update chainid to uint256 * evm: update bls gas (eips PR 9097) * evm: bls update msm gas (eips PR 9116) * evm: bls update pairing gas (eips PR 9098) * evm: rename bls files and remove g1mul, g2mul (eips PR 8945) * evm: update 2537 addresses in test * tx: add eip-7691 param * tx: add required params to common * vm/tests: update 7002 test: correctly deploy withdrawal contract * client: update genesis contracts * evm: update bls test files * vm: 2935 update history serve window * evm: EXTCODE* do not follow 7702 delegations for gas calculations * vm: t8n fix: exit early on non-existent 2935 code * vm: move floor check after applying refund * evm: update bls cases * evm/common: cleanup pr * monorepo: casing maxblob -> maxBlob * tx: tx tests support prague * tx: add missing forks * client: switch cl request types --------- Co-authored-by: harkamal <[email protected]> Co-authored-by: Lucas Saldanha <[email protected]>
1 parent 15994b9 commit 99cfdd6

Some content is hidden

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

51 files changed

+797
-490
lines changed

packages/block/src/block/block.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ export class Block {
249249
}
250250
}
251251
if (this.common.isActivatedEIP(4844)) {
252-
const blobGasLimit = this.common.param('maxblobGasPerBlock')
252+
const blobGasLimit = this.common.param('maxBlobGasPerBlock')
253253
const blobGasPerBlob = this.common.param('blobGasPerBlob')
254254
if (tx instanceof Blob4844Tx) {
255255
blobGasUsed += BigInt(tx.numBlobs()) * blobGasPerBlob
@@ -354,7 +354,7 @@ export class Block {
354354
*/
355355
validateBlobTransactions(parentHeader: BlockHeader) {
356356
if (this.common.isActivatedEIP(4844)) {
357-
const blobGasLimit = this.common.param('maxblobGasPerBlock')
357+
const blobGasLimit = this.common.param('maxBlobGasPerBlock')
358358
const blobGasPerBlob = this.common.param('blobGasPerBlob')
359359
let blobGasUsed = BIGINT_0
360360

packages/block/src/helpers.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,10 @@ export function genRequestsRoot(
172172

173173
let flatRequests = new Uint8Array()
174174
for (const req of requests) {
175-
flatRequests = concatBytes(flatRequests, sha256Function(req.bytes))
175+
if (req.bytes.length > 1) {
176+
// Only append requests if they have content
177+
flatRequests = concatBytes(flatRequests, sha256Function(req.bytes))
178+
}
176179
}
177180

178181
return sha256Function(flatRequests)

packages/block/src/params.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export const paramsBlock: ParamsDict = {
1010
gasLimitBoundDivisor: 1024, // The bound divisor of the gas limit, used in update calculations
1111
targetBlobGasPerBlock: 0, // Base value needed here since called pre-4844 in BlockHeader.calcNextExcessBlobGas()
1212
blobGasPerBlob: 0,
13-
maxblobGasPerBlock: 0,
13+
maxBlobGasPerBlock: 0,
1414
// format
1515
maxExtraDataSize: 32, // Maximum size extra data may be after Genesis
1616
// pow
@@ -72,7 +72,7 @@ export const paramsBlock: ParamsDict = {
7272
// gasConfig
7373
targetBlobGasPerBlock: 393216, // The target blob gas consumed per block
7474
blobGasPerBlob: 131072, // The base fee for blob gas per blob
75-
maxblobGasPerBlock: 786432, // The max blob gas allowable per block
75+
maxBlobGasPerBlock: 786432, // The max blob gas allowable per block
7676
blobGasPriceUpdateFraction: 3338477, // The denominator used in the exponential when calculating a blob gas price
7777
// gasPrices
7878
simplePerBlobGas: 12000, // The basic gas fee for each blob
@@ -85,4 +85,13 @@ export const paramsBlock: ParamsDict = {
8585
// pow
8686
difficultyBombDelay: 11400000, // the amount of blocks to delay the difficulty bomb with
8787
},
88+
/**
89+
. * Blob throughput increase
90+
. */
91+
7691: {
92+
// gasConfig
93+
targetBlobGasPerBlock: 786432, // The target blob gas consumed per block
94+
maxBlobGasPerBlock: 1179648, // The max blob gas allowable per block
95+
blobGasPriceUpdateFraction: 5007716, // The denominator used in the exponential when calculating a blob gas price
96+
},
8897
}

packages/client/src/miner/pendingBlock.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ export class PendingBlock {
192192
// Get if and how many blobs are allowed in the tx
193193
let allowedBlobs
194194
if (vm.common.isActivatedEIP(4844)) {
195-
const blobGasLimit = vm.common.param('maxblobGasPerBlock')
195+
const blobGasLimit = vm.common.param('maxBlobGasPerBlock')
196196
const blobGasPerBlob = vm.common.param('blobGasPerBlob')
197197
allowedBlobs = Number(blobGasLimit / blobGasPerBlob)
198198
} else {
@@ -270,7 +270,7 @@ export class PendingBlock {
270270
let allowedBlobs
271271
if (vm.common.isActivatedEIP(4844)) {
272272
const bundle = this.blobsBundles.get(payloadId) ?? { blobs: [], commitments: [], proofs: [] }
273-
const blobGasLimit = vm.common.param('maxblobGasPerBlock')
273+
const blobGasLimit = vm.common.param('maxBlobGasPerBlock')
274274
const blobGasPerBlob = vm.common.param('blobGasPerBlob')
275275
allowedBlobs = Number(blobGasLimit / blobGasPerBlob) - bundle.blobs.length
276276
} else {

packages/client/src/rpc/modules/engine/util/getPayload.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,20 @@ export const blockToExecutionPayload = (
2525
// ethereumjs does not provide any transaction censoring detection (yet) to suggest
2626
// overriding builder/mev-boost blocks
2727
const shouldOverrideBuilder = false
28+
29+
let executionRequests = undefined
30+
if (requests !== undefined) {
31+
executionRequests = []
32+
for (const request of requests) {
33+
if (request.bytes.length > 1) {
34+
executionRequests.push(bytesToHex(request.bytes))
35+
}
36+
}
37+
}
38+
2839
return {
2940
executionPayload,
30-
executionRequests: requests?.map((req) => bytesToHex(req.data)),
41+
executionRequests,
3142
blockValue: bigIntToHex(value),
3243
blobsBundle,
3344
shouldOverrideBuilder,

packages/client/src/rpc/modules/engine/util/newPayload.ts

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -57,30 +57,35 @@ export const validateAndGen7685RequestsHash = (
5757
common: Common,
5858
executionRequests: PrefixedHexString[],
5959
): PrefixedHexString => {
60-
let validationError: string | null = null
61-
6260
const requests: CLRequest<CLRequestType>[] = []
63-
let requestIndex = 0
64-
if (common.isActivatedEIP(6110)) {
65-
requests.push(new CLRequest(CLRequestType.Deposit, hexToBytes(executionRequests[requestIndex])))
66-
requestIndex++
67-
}
68-
if (common.isActivatedEIP(7002)) {
69-
requests.push(
70-
new CLRequest(CLRequestType.Withdrawal, hexToBytes(executionRequests[requestIndex])),
71-
)
72-
requestIndex++
73-
}
74-
if (common.isActivatedEIP(7251)) {
75-
requests.push(
76-
new CLRequest(CLRequestType.Consolidation, hexToBytes(executionRequests[requestIndex])),
77-
)
78-
requestIndex++
79-
}
8061

81-
if (requestIndex !== executionRequests.length) {
82-
validationError = `Invalid executionRequests=${executionRequests.length} expected=${requestIndex}`
83-
throw validationError
62+
for (const request of executionRequests) {
63+
const bytes = hexToBytes(request)
64+
if (bytes.length === 0) {
65+
throw new Error('Got a request without a request-identifier')
66+
}
67+
switch (bytes[0]) {
68+
case CLRequestType.Deposit:
69+
if (!common.isActivatedEIP(6110)) {
70+
throw new Error(`Deposit requests are not active`)
71+
}
72+
requests.push(new CLRequest(CLRequestType.Deposit, bytes.slice(1)))
73+
break
74+
case CLRequestType.Withdrawal:
75+
if (!common.isActivatedEIP(7002)) {
76+
throw new Error(`Withdrawal requests are not active`)
77+
}
78+
requests.push(new CLRequest(CLRequestType.Withdrawal, bytes.slice(1)))
79+
break
80+
case CLRequestType.Consolidation:
81+
if (!common.isActivatedEIP(7251)) {
82+
throw new Error(`Consolidation requests are not active`)
83+
}
84+
requests.push(new CLRequest(CLRequestType.Consolidation, bytes.slice(1)))
85+
break
86+
default:
87+
throw new Error(`Unknown request identifier: got ${bytes[0]}`)
88+
}
8489
}
8590

8691
const sha256Function = common.customCrypto.sha256 ?? sha256

packages/client/src/rpc/modules/eth.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1160,7 +1160,7 @@ export class Eth {
11601160
// Blob Transactions sent over RPC are expected to be in Network Wrapper format
11611161
tx = createBlob4844TxFromSerializedNetworkWrapper(txBuf, { common })
11621162

1163-
const blobGasLimit = tx.common.param('maxblobGasPerBlock')
1163+
const blobGasLimit = tx.common.param('maxBlobGasPerBlock')
11641164
const blobGasPerBlob = tx.common.param('blobGasPerBlob')
11651165

11661166
if (BigInt((tx.blobs ?? []).length) * blobGasPerBlob > blobGasLimit) {
@@ -1402,7 +1402,7 @@ export class Eth {
14021402
let blobGasUsedRatio = 0
14031403
if (b.header.excessBlobGas !== undefined) {
14041404
baseFeePerBlobGas = b.header.getBlobGasPrice()
1405-
const max = b.common.param('maxblobGasPerBlock')
1405+
const max = b.common.param('maxBlobGasPerBlock')
14061406
blobGasUsedRatio = Number(blobGasUsed) / Number(max)
14071407
}
14081408

packages/client/src/service/txpool.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ export class TxPool {
399399
}
400400

401401
pruneBlobsAndProofsCache() {
402-
const blobGasLimit = this.config.chainCommon.param('maxblobGasPerBlock')
402+
const blobGasLimit = this.config.chainCommon.param('maxBlobGasPerBlock')
403403
const blobGasPerBlob = this.config.chainCommon.param('blobGasPerBlob')
404404
const allowedBlobsPerBlock = Number(blobGasLimit / blobGasPerBlob)
405405

packages/client/test/miner/pendingBlock.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ describe('[PendingBlock]', async () => {
366366
const fillProofs = blobsToProofs(kzg, fillBlobs, fillCommitments)
367367
const fillBlobAndProof = { blob: fillBlobs[0], proof: fillProofs[0] }
368368

369-
const blobGasLimit = txPool['config'].chainCommon.param('maxblobGasPerBlock')
369+
const blobGasLimit = txPool['config'].chainCommon.param('maxBlobGasPerBlock')
370370
const blobGasPerBlob = txPool['config'].chainCommon.param('blobGasPerBlob')
371371
const allowedBlobsPerBlock = Number(blobGasLimit / blobGasPerBlob)
372372
const allowedLength = allowedBlobsPerBlock * txPool['config'].blobsAndProofsCacheBlocks

packages/client/test/rpc/engine/newPayloadV4.spec.ts

Lines changed: 32 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ const [blockData] = beaconData
1212

1313
const parentBeaconBlockRoot = '0x42942949c4ed512cd85c2cb54ca88591338cbb0564d3a2bea7961a639ef29d64'
1414
const validForkChoiceState = {
15-
headBlockHash: '0x6abe4c2777a6a1e994d83920cfb95229b071174b95c89343f54b926f733789f2',
16-
safeBlockHash: '0x6abe4c2777a6a1e994d83920cfb95229b071174b95c89343f54b926f733789f2',
17-
finalizedBlockHash: '0x6abe4c2777a6a1e994d83920cfb95229b071174b95c89343f54b926f733789f2',
15+
headBlockHash: '0x5bc7efe14c04eed7572809bb9c11d48d872139384097b95e04f8ab1b01ae8ecc',
16+
safeBlockHash: '0x5bc7efe14c04eed7572809bb9c11d48d872139384097b95e04f8ab1b01ae8ecc',
17+
finalizedBlockHash: '0x5bc7efe14c04eed7572809bb9c11d48d872139384097b95e04f8ab1b01ae8ecc',
1818
}
1919
const validPayloadAttributes = {
2020
timestamp: '0x64ba84fd',
@@ -35,26 +35,24 @@ const electraGenesisContracts = {
3535
// sender corresponding to the priv key 0x9c9996335451aab4fc4eac58e31a8c300e095cdbcee532d53d09280e83360355
3636
'0x610adc49ecd66cbf176a8247ebd59096c031bd9f': { balance: '0x6d6172697573766477000000' },
3737
// eip 2925 contract
38-
'0x0aae40965e6800cd9b1f4b05ff21581047e3f91e': {
38+
'0x0f792be4b0c0cb4dae440ef133e90c0ecd48cccc': {
3939
balance: '0',
4040
nonce: '1',
41-
code: '0x3373fffffffffffffffffffffffffffffffffffffffe1460575767ffffffffffffffff5f3511605357600143035f3511604b575f35612000014311604b57611fff5f3516545f5260205ff35b5f5f5260205ff35b5f5ffd5b5f35611fff60014303165500',
41+
code: '0x3373fffffffffffffffffffffffffffffffffffffffe14604657602036036042575f35600143038111604257611fff81430311604257611fff9006545f5260205ff35b5f5ffd5b5f35611fff60014303065500',
4242
},
4343
// consolidation requests contract
44-
'0x00706203067988Ab3E2A2ab626EdCD6f28bDBbbb': {
45-
balance: '0',
46-
nonce: '1',
47-
code: '0x3373fffffffffffffffffffffffffffffffffffffffe1460cf573615156028575f545f5260205ff35b366060141561019a5760115f54807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1461019a57600182026001905f5b5f821115608057810190830284830290049160010191906065565b90939004341061019a57600154600101600155600354806004026004013381556001015f358155600101602035815560010160403590553360601b5f5260605f60143760745fa0600101600355005b6003546002548082038060011160e3575060015b5f5b8181146101295780607402838201600402600401805490600101805490600101805490600101549260601b84529083601401528260340152906054015260010160e5565b910180921461013b5790600255610146565b90505f6002555f6003555b5f54807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff141561017357505f5b6001546001828201116101885750505f61018e565b01600190035b5f555f6001556074025ff35b5f5ffd',
44+
'0x00431f263ce400f4455c2dcf564e53007ca4bbbb': {
45+
nonce: '0x01',
46+
balance: '0x00',
47+
code: '0x3373fffffffffffffffffffffffffffffffffffffffe1460d35760115f54807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1461019a57600182026001905f5b5f82111560685781019083028483029004916001019190604d565b9093900492505050366060146088573661019a573461019a575f5260205ff35b341061019a57600154600101600155600354806004026004013381556001015f358155600101602035815560010160403590553360601b5f5260605f60143760745fa0600101600355005b6003546002548082038060021160e7575060025b5f5b8181146101295782810160040260040181607402815460601b815260140181600101548152602001816002015481526020019060030154905260010160e9565b910180921461013b5790600255610146565b90505f6002555f6003555b5f54807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff141561017357505f5b6001546001828201116101885750505f61018e565b01600190035b5f555f6001556074025ff35b5f5ffd',
48+
storage: {},
4849
},
4950
// withdrawals request contract
50-
'0x05F27129610CB42103b665629CB5c8C00296AaAa': {
51-
balance: '0',
52-
nonce: '1',
53-
code: '0x3373fffffffffffffffffffffffffffffffffffffffe1460c7573615156028575f545f5260205ff35b36603814156101f05760115f54807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff146101f057600182026001905f5b5f821115608057810190830284830290049160010191906065565b9093900434106101f057600154600101600155600354806003026004013381556001015f35815560010160203590553360601b5f5260385f601437604c5fa0600101600355005b6003546002548082038060101160db575060105b5f5b81811461017f5780604c02838201600302600401805490600101805490600101549160601b83528260140152807fffffffffffffffffffffffffffffffff0000000000000000000000000000000016826034015260401c906044018160381c81600701538160301c81600601538160281c81600501538160201c81600401538160181c81600301538160101c81600201538160081c81600101535360010160dd565b9101809214610191579060025561019c565b90505f6002555f6003555b5f54807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff14156101c957505f5b6001546002828201116101de5750505f6101e4565b01600290035b5f555f600155604c025ff35b5f5ffd',
54-
storage: {
55-
'0x0000000000000000000000000000000000000000000000000000000000000000':
56-
'0x000000000000000000000000000000000000000000000000000000000000049d',
57-
},
51+
'0x0c15f14308530b7cdb8460094bbb9cc28b9aaaaa': {
52+
nonce: '0x01',
53+
balance: '0x00',
54+
code: '0x3373fffffffffffffffffffffffffffffffffffffffe1460cb5760115f54807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff146101f457600182026001905f5b5f82111560685781019083028483029004916001019190604d565b909390049250505036603814608857366101f457346101f4575f5260205ff35b34106101f457600154600101600155600354806003026004013381556001015f35815560010160203590553360601b5f5260385f601437604c5fa0600101600355005b6003546002548082038060101160df575060105b5f5b8181146101835782810160030260040181604c02815460601b8152601401816001015481526020019060020154807fffffffffffffffffffffffffffffffff00000000000000000000000000000000168252906010019060401c908160381c81600701538160301c81600601538160281c81600501538160201c81600401538160181c81600301538160101c81600201538160081c81600101535360010160e1565b910180921461019557906002556101a0565b90505f6002555f6003555b5f54807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff14156101cd57505f5b6001546002828201116101e25750505f6101e8565b01600290035b5f555f600155604c025ff35b5f5ffd',
55+
storage: {},
5856
},
5957
// beacon deposit contract for deposit receipts
6058
'0x00000000219ab540356cBB839Cbe05303d7705Fa': {
@@ -160,9 +158,9 @@ describe(`${method}: call with executionPayloadV4`, () => {
160158
withdrawals: [],
161159
blobGasUsed: '0x0',
162160
excessBlobGas: '0x0',
163-
parentHash: '0x6abe4c2777a6a1e994d83920cfb95229b071174b95c89343f54b926f733789f2',
164-
stateRoot: '0x7aa6e46df1f78988a3141b5e7da8abee78d1daca175f43fe8866b2d1bf8d8ef8',
165-
blockHash: '0x9a5903d803e6e7c3631cd76cb7279f93d7facc995c53eaffadf4e225504b18eb',
161+
parentHash: '0x5bc7efe14c04eed7572809bb9c11d48d872139384097b95e04f8ab1b01ae8ecc',
162+
stateRoot: '0xebe157ea5c3dc6fb5970f67b76266903282aee9772030f06c112348f32037fd9',
163+
blockHash: '0x725c21032b68ae7d2f143581d0196cfbfd14dbc45c14eaeab15443831de489b7',
166164
}
167165

168166
const oldMethods = ['engine_newPayloadV1', 'engine_newPayloadV2', 'engine_newPayloadV3']
@@ -180,7 +178,7 @@ describe(`${method}: call with executionPayloadV4`, () => {
180178
assert.ok(res.error.message.includes(expectedError))
181179
}
182180

183-
res = await rpc.request(method, [validBlock, [], parentBeaconBlockRoot, ['0x', '0x', '0x']])
181+
res = await rpc.request(method, [validBlock, [], parentBeaconBlockRoot, []])
184182
assert.equal(res.result.status, 'VALID')
185183

186184
res = await rpc.request('engine_forkchoiceUpdatedV3', validPayload)
@@ -201,9 +199,20 @@ describe(`${method}: call with executionPayloadV4`, () => {
201199

202200
res = await rpc.request('engine_getPayloadV4', [payloadId])
203201
const { executionPayload, executionRequests } = res.result
202+
203+
assert.ok(
204+
executionRequests?.length === 1,
205+
'executionRequests should have the deposit request, and should exclude the other requests (these are empty)',
206+
)
207+
208+
const depositRequestBytes = hexToBytes(executionRequests[0])
209+
assert.ok(
210+
depositRequestBytes[0] === 0x00,
211+
'deposit request byte 0 is the deposit request identifier byte (0x00)',
212+
)
204213
assert.ok(
205-
executionRequests?.length === 3,
206-
'executionRequests should have 3 entries for each request type',
214+
depositRequestBytes.length > 1,
215+
'deposit request includes data (and is thus not empty)',
207216
)
208217

209218
res = await rpc.request(method, [

0 commit comments

Comments
 (0)