Skip to content

Commit 293f4cc

Browse files
Merge branch 'master' into evm-error-handling
2 parents b4458d7 + 99cfdd6 commit 293f4cc

Some content is hidden

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

81 files changed

+1554
-912
lines changed

package-lock.json

Lines changed: 5 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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/helpers.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { BIGINT_0, bigIntToHex, bytesToHex, intToHex } from '@ethereumjs/util'
33
import { INTERNAL_ERROR, INVALID_BLOCK, INVALID_PARAMS } from './error-code.js'
44

55
import type { Chain } from '../blockchain/index.js'
6+
import type { RPCMethod } from './types.js'
67
import type { Block } from '@ethereumjs/block'
78
import type { JSONRPCTx, TypedTransaction } from '@ethereumjs/tx'
89

@@ -13,7 +14,7 @@ type RPCError = {
1314
data?: string
1415
}
1516

16-
export function callWithStackTrace(handler: Function, debug: boolean) {
17+
export function callWithStackTrace(handler: Function, debug: boolean): RPCMethod {
1718
return async (...args: any) => {
1819
try {
1920
const res = await handler(...args)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ export class Admin {
3131
this._client = client
3232
this._rpcDebug = rpcDebug
3333

34-
this.nodeInfo = middleware(callWithStackTrace(this.nodeInfo.bind(this), this._rpcDebug), 0, [])
35-
this.peers = middleware(callWithStackTrace(this.peers.bind(this), this._rpcDebug), 0, [])
34+
this.nodeInfo = callWithStackTrace(this.nodeInfo.bind(this), this._rpcDebug)
35+
this.peers = callWithStackTrace(this.peers.bind(this), this._rpcDebug)
3636
this.addPeer = middleware(callWithStackTrace(this.addPeer.bind(this), this._rpcDebug), 1, [
3737
[
3838
validators.object({

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

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,9 @@ export class Debug {
148148
1,
149149
[[validators.hex]],
150150
)
151+
this.setHead = middleware(callWithStackTrace(this.setHead.bind(this), this._rpcDebug), 1, [
152+
[validators.blockOption],
153+
])
151154
this.verbosity = middleware(callWithStackTrace(this.verbosity.bind(this), this._rpcDebug), 1, [
152155
[validators.unsignedInteger],
153156
])
@@ -457,4 +460,30 @@ export class Debug {
457460
this.client.config.logger.configure({ level: logLevels[level] })
458461
return `level: ${this.client.config.logger.level}`
459462
}
463+
464+
/**
465+
* Sets the current head of the local chain by block number. Note, this is a
466+
* destructive action and may severely damage your chain. Use with extreme
467+
* caution.
468+
* @param blockOpt Block number or tag to set as head of chain
469+
*/
470+
async setHead(params: [string]) {
471+
const [blockOpt] = params
472+
if (blockOpt === 'pending') {
473+
throw {
474+
code: INVALID_PARAMS,
475+
message: `"pending" is not supported`,
476+
}
477+
}
478+
479+
const block = await getBlockByOption(blockOpt, this.chain)
480+
try {
481+
await this.service.skeleton?.setHead(block, true)
482+
await this.service.execution.setHead([block])
483+
} catch (e) {
484+
throw {
485+
code: INTERNAL_ERROR,
486+
}
487+
}
488+
}
460489
}

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

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy