-
Notifications
You must be signed in to change notification settings - Fork 514
Add testing_commitBlockV1 RPC Method #787
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
marcindsobczak
wants to merge
1
commit into
ethereum:main
Choose a base branch
from
marcindsobczak:testing-commit-block-v1
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+109
−0
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,109 @@ | ||
| - name: testing_commitBlockV1 | ||
| summary: Builds a block on top of a given parentHash using the provided parameters and commits it to the canonical chain. This is a testing-only method for generating and applying test blocks. | ||
| description: | | ||
| This method is a debugging and testing tool that simplifies the full block production and application flow into a single call. | ||
| It takes the same inputs as `testing_buildBlockV1`, but instead of only returning the built execution payload, it also | ||
| inserts the resulting block into the client's block tree and advances the canonical head to it. | ||
|
|
||
| **Specification:** | ||
| - The client MUST build a new execution payload using the block specified by `parentBlockHash` as its parent, following the exact same rules as `testing_buildBlockV1`. | ||
| - The client MUST use the provided `payloadAttributes` to define the context of the new block. | ||
| - If the `transactions` parameter is an empty array `[]`, the client MUST build an empty block (no transactions). | ||
| - If the `transactions` parameter is JSON `null`, the client MAY build a block from its local transaction pool (mempool). | ||
| - If the `transactions` parameter is a non-empty array, the client MUST include all transactions from the array on the block's transaction list, in the order they were provided, and MUST NOT include any transactions from its local transaction pool. | ||
| - If `extraData` is provided, the client MUST set the `extraData` field of the resulting payload to this value. | ||
| - After the block has been successfully built, the client MUST validate it, insert it into its block tree, and set it as the new canonical head (as if it had been received via `engine_newPayload` followed by `engine_forkchoiceUpdated` pointing at the new block). | ||
| - On success, the client MUST return a Response object whose `blockHash` field is the hash of the block that was committed to the canonical chain. | ||
| - On failure (e.g. block building failed, block validation failed, or the block could not be committed to the chain), the client MUST return a Response object whose `blockHash` field is `null`, and MUST report the reason via a standard JSON-RPC error response (see the `errors` section). | ||
| - Unlike `testing_buildBlockV1`, this method DOES modify the client's canonical chain and head block. | ||
|
|
||
| **Security Considerations:** | ||
| - This method is intended for testing environments ONLY and MUST NOT be exposed on public-facing RPC APIs. | ||
| - Because this method mutates the canonical chain, it is strongly recommended that it be disabled by default and only enabled in explicit test configurations. | ||
| params: | ||
| - name: Parent block hash | ||
| required: true | ||
| schema: | ||
| $ref: '#/components/schemas/hash32' | ||
| - name: Payload attributes | ||
| required: true | ||
| schema: | ||
| title: PayloadAttributesV3 | ||
| type: object | ||
| properties: | ||
| timestamp: | ||
| $ref: '#/components/schemas/uint' | ||
| prevRandao: | ||
| $ref: '#/components/schemas/hash32' | ||
| suggestedFeeRecipient: | ||
| $ref: '#/components/schemas/address' | ||
| withdrawals: | ||
| title: Withdrawals | ||
| type: array | ||
| items: | ||
| $ref: '#/components/schemas/Withdrawal' | ||
| parentBeaconBlockRoot: | ||
| $ref: '#/components/schemas/hash32' | ||
| - name: Transactions | ||
| required: true | ||
| description: | | ||
| An array of raw, signed transactions (hex-encoded) to include in the generated block, or null. | ||
| - If an empty array `[]`: The client MUST build an empty block (no transactions). | ||
| - If `null`: The client MAY build a block from its local transaction pool (mempool). | ||
| - If a non-empty array: The client MUST include ALL transactions from this array in the resulting block, in the order provided, and MUST NOT include any transactions from its local mempool. | ||
| schema: | ||
| title: Transactions | ||
| oneOf: | ||
| - type: array | ||
| items: | ||
| $ref: '#/components/schemas/bytes' | ||
| - type: 'null' | ||
| - name: Extra data | ||
| required: false | ||
| description: | | ||
| Data to be set as the extraData field of the built block. If provided, the client MUST use this exact value. | ||
| schema: | ||
| oneOf: | ||
| - $ref: '#/components/schemas/bytes' | ||
| - type: 'null' | ||
| result: | ||
| name: Response object | ||
| schema: | ||
| title: Response object | ||
| type: object | ||
| required: | ||
| - blockHash | ||
| properties: | ||
| blockHash: | ||
| title: Committed block hash | ||
| description: | | ||
| Hash of the block that was built and committed to the canonical chain. | ||
| `null` if the block could not be built, validated, or committed; in that case the reason is returned via a JSON-RPC error response. | ||
| oneOf: | ||
| - $ref: '#/components/schemas/hash32' | ||
| - type: 'null' | ||
| errors: | ||
| - code: -32602 | ||
| message: Invalid parameters | ||
| - code: -32603 | ||
| message: Internal error | ||
| examples: | ||
| - name: testing_commitBlockV1 example | ||
| params: | ||
| - name: Parent block hash | ||
| value: '0xe27a3e81bd7cfe2aec2cc9e832c73a17c93e7efcf659cf4b39883b96c48708c2' | ||
| - name: Payload attributes | ||
| value: | ||
| timestamp: '0x1ce' | ||
| prevRandao: '0x0000000000000000000000000000000000000000000000000000000000000000' | ||
| suggestedFeeRecipient: '0x0000000000000000000000000000000000000000' | ||
| withdrawals: [] | ||
| parentBeaconBlockRoot: '0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884365149a42212e8822' | ||
| - name: Transactions | ||
| value: [] | ||
| - name: Extra data | ||
| value: null | ||
| result: | ||
| name: Response object | ||
| value: | ||
| blockHash: '0x1234567890123456789012345678901234567890123456789012345678901234' | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks off to me. The response should be just the hash. We don't need to specify null here for the error case because in JSON-RPC if we return an error then there is no response returned.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Already addressed in #801