-
Notifications
You must be signed in to change notification settings - Fork 935
Add new RPC endpoints debug_setHead & debug_replayBlock #4580
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
3f8c4af
add debug_setHead endpoint
daniellehrner 174fabb
added debug_replayBlock endpoint, added acceptance tests
daniellehrner df1a7f0
updated CHANGELOG.md
daniellehrner 74ade8c
refactored because of changes in return value of validateAndProcessBlock
daniellehrner 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
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
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
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
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
51 changes: 51 additions & 0 deletions
51
...st/java/org/hyperledger/besu/tests/acceptance/jsonrpc/DebugReplayBlockAcceptanceTest.java
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,51 @@ | ||
/* | ||
* Copyright Hyperledger Besu Contributors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations under the License. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
package org.hyperledger.besu.tests.acceptance.jsonrpc; | ||
|
||
import java.io.IOException; | ||
import java.net.URI; | ||
import java.net.URISyntaxException; | ||
|
||
import org.junit.AfterClass; | ||
import org.junit.BeforeClass; | ||
import org.junit.runner.RunWith; | ||
import org.junit.runners.Parameterized; | ||
|
||
@RunWith(Parameterized.class) | ||
public class DebugReplayBlockAcceptanceTest extends AbstractJsonRpcTest { | ||
private static final String GENESIS_FILE = "/jsonrpc/debug/replayBlock/genesis.json"; | ||
private static final String TEST_CASE_PATH = "/jsonrpc/debug/replayBlock/test-cases/"; | ||
|
||
private static AbstractJsonRpcTest.JsonRpcTestsContext testsContext; | ||
|
||
public DebugReplayBlockAcceptanceTest(final String ignored, final URI testCaseFileURI) { | ||
super(ignored, testsContext, testCaseFileURI); | ||
} | ||
|
||
@BeforeClass | ||
public static void init() throws IOException { | ||
testsContext = new JsonRpcTestsContext(GENESIS_FILE); | ||
} | ||
|
||
@Parameterized.Parameters(name = "{0}") | ||
public static Iterable<Object[]> testCases() throws URISyntaxException { | ||
return testCases(TEST_CASE_PATH); | ||
} | ||
|
||
@AfterClass | ||
public static void tearDown() { | ||
testsContext.cluster.close(); | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
...c/test/java/org/hyperledger/besu/tests/acceptance/jsonrpc/DebugSetHeadAcceptanceTest.java
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,51 @@ | ||
/* | ||
* Copyright Hyperledger Besu Contributors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations under the License. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
package org.hyperledger.besu.tests.acceptance.jsonrpc; | ||
|
||
import java.io.IOException; | ||
import java.net.URI; | ||
import java.net.URISyntaxException; | ||
|
||
import org.junit.AfterClass; | ||
import org.junit.BeforeClass; | ||
import org.junit.runner.RunWith; | ||
import org.junit.runners.Parameterized; | ||
|
||
@RunWith(Parameterized.class) | ||
public class DebugSetHeadAcceptanceTest extends AbstractJsonRpcTest { | ||
private static final String GENESIS_FILE = "/jsonrpc/debug/setHead/genesis.json"; | ||
private static final String TEST_CASE_PATH = "/jsonrpc/debug/setHead/test-cases/"; | ||
|
||
private static JsonRpcTestsContext testsContext; | ||
|
||
public DebugSetHeadAcceptanceTest(final String ignored, final URI testCaseFileURI) { | ||
super(ignored, testsContext, testCaseFileURI); | ||
} | ||
|
||
@BeforeClass | ||
public static void init() throws IOException { | ||
testsContext = new JsonRpcTestsContext(GENESIS_FILE); | ||
} | ||
|
||
@Parameterized.Parameters(name = "{0}") | ||
public static Iterable<Object[]> testCases() throws URISyntaxException { | ||
return testCases(TEST_CASE_PATH); | ||
} | ||
|
||
@AfterClass | ||
public static void tearDown() { | ||
testsContext.cluster.close(); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
acceptance-tests/tests/src/test/resources/jsonrpc/debug/replayBlock/genesis.json
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,35 @@ | ||
{ | ||
"config": { | ||
"chainId":1, | ||
"homesteadBlock":0, | ||
"eip150Block":0, | ||
"eip155Block":0, | ||
"eip158Block":0, | ||
"byzantiumBlock":0, | ||
"constantinopleBlock":0, | ||
"petersburgBlock":0, | ||
"istanbulBlock":0, | ||
"muirGlacierBlock":0, | ||
"berlinBlock":0, | ||
"londonBlock":0, | ||
"clique": { | ||
"period": 5, | ||
"epoch": 30000 | ||
}, | ||
"terminalTotalDifficulty":0 | ||
}, | ||
"nonce":"0x42", | ||
"timestamp":"0x0", | ||
"extraData":"0x0000000000000000000000000000000000000000000000000000000000000000a94f5374fce5edbc8e2a8697c15331677e6ebf0b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", | ||
"gasLimit":"0x1C9C380", | ||
"difficulty":"0x400000000", | ||
"mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000", | ||
"coinbase":"0x0000000000000000000000000000000000000000", | ||
"alloc":{ | ||
"0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b":{"balance":"0x6d6172697573766477000000"} | ||
}, | ||
"number":"0x0", | ||
"gasUsed":"0x0", | ||
"parentHash":"0x0000000000000000000000000000000000000000000000000000000000000000", | ||
"baseFeePerGas":"0x7" | ||
} |
32 changes: 32 additions & 0 deletions
32
...sts/tests/src/test/resources/jsonrpc/debug/replayBlock/test-cases/01_prepare_payload.json
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,32 @@ | ||
{ | ||
"request": { | ||
"jsonrpc": "2.0", | ||
"method": "engine_forkchoiceUpdatedV1", | ||
"params": [ | ||
{ | ||
"headBlockHash": "0x3b8fb240d288781d4aac94d3fd16809ee413bc99294a085798a589dae51ddd4a", | ||
"safeBlockHash": "0x3b8fb240d288781d4aac94d3fd16809ee413bc99294a085798a589dae51ddd4a", | ||
"finalizedBlockHash": "0x0000000000000000000000000000000000000000000000000000000000000000" | ||
}, | ||
{ | ||
"timestamp": "0x5", | ||
"prevRandao": "0x0000000000000000000000000000000000000000000000000000000000000000", | ||
"suggestedFeeRecipient": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b" | ||
} | ||
], | ||
"id": 67 | ||
}, | ||
"response": { | ||
"jsonrpc": "2.0", | ||
"id": 67, | ||
"result": { | ||
"payloadStatus": { | ||
"status": "VALID", | ||
"latestValidHash": "0x3b8fb240d288781d4aac94d3fd16809ee413bc99294a085798a589dae51ddd4a", | ||
"validationError": null | ||
}, | ||
"payloadId": "0x0065bd195a9b3bfb" | ||
} | ||
}, | ||
"statusCode" : 200 | ||
} |
35 changes: 35 additions & 0 deletions
35
...s/tests/src/test/resources/jsonrpc/debug/replayBlock/test-cases/02_execute_payload_1.json
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,35 @@ | ||
{ | ||
"request": { | ||
"jsonrpc": "2.0", | ||
"method": "engine_newPayloadV1", | ||
"params": [ | ||
{ | ||
"parentHash": "0x3b8fb240d288781d4aac94d3fd16809ee413bc99294a085798a589dae51ddd4a", | ||
"feeRecipient": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", | ||
"stateRoot": "0xca3149fa9e37db08d1cd49c9061db1002ef1cd58db2210f2115c8c989b2bdf45", | ||
"receiptsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", | ||
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", | ||
"prevRandao": "0x0000000000000000000000000000000000000000000000000000000000000000", | ||
"blockNumber": "0x1", | ||
"gasLimit": "0x1c9c380", | ||
"gasUsed": "0x0", | ||
"timestamp": "0x5", | ||
"extraData": "0x", | ||
"baseFeePerGas": "0x7", | ||
"blockHash": "0x3559e851470f6e7bbed1db474980683e8c315bfce99b2a6ef47c057c04de7858", | ||
"transactions": [] | ||
} | ||
], | ||
"id": 67 | ||
}, | ||
"response": { | ||
"jsonrpc": "2.0", | ||
"id": 67, | ||
"result": { | ||
"status": "VALID", | ||
"latestValidHash": "0x3559e851470f6e7bbed1db474980683e8c315bfce99b2a6ef47c057c04de7858", | ||
"validationError": null | ||
} | ||
}, | ||
"statusCode": 200 | ||
} |
35 changes: 35 additions & 0 deletions
35
...s/tests/src/test/resources/jsonrpc/debug/replayBlock/test-cases/03_execute_payload_2.json
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,35 @@ | ||
{ | ||
"request": { | ||
"jsonrpc": "2.0", | ||
"method": "engine_newPayloadV1", | ||
"params": [ | ||
{ | ||
"parentHash": "0x3559e851470f6e7bbed1db474980683e8c315bfce99b2a6ef47c057c04de7858", | ||
"feeRecipient": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", | ||
"stateRoot": "0xca3149fa9e37db08d1cd49c9061db1002ef1cd58db2210f2115c8c989b2bdf45", | ||
"receiptsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", | ||
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", | ||
"prevRandao": "0x0000000000000000000000000000000000000000000000000000000000000000", | ||
"blockNumber": "0x2", | ||
"gasLimit": "0x1c9c380", | ||
"gasUsed": "0x0", | ||
"timestamp": "0x6", | ||
"extraData": "0x", | ||
"baseFeePerGas": "0x7", | ||
"blockHash": "0x80732341439dd124df94271386141735f13ef8a85e12e9fba15c06bc1ad9fd73", | ||
"transactions": [] | ||
} | ||
], | ||
"id": 67 | ||
}, | ||
"response": { | ||
"jsonrpc": "2.0", | ||
"id": 67, | ||
"result": { | ||
"status": "VALID", | ||
"latestValidHash": "0x80732341439dd124df94271386141735f13ef8a85e12e9fba15c06bc1ad9fd73", | ||
"validationError": null | ||
} | ||
}, | ||
"statusCode": 200 | ||
} |
28 changes: 28 additions & 0 deletions
28
...s/tests/src/test/resources/jsonrpc/debug/replayBlock/test-cases/04_update_forkchoice.json
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,28 @@ | ||
{ | ||
"request": { | ||
"jsonrpc": "2.0", | ||
"method": "engine_forkchoiceUpdatedV1", | ||
"params": [ | ||
{ | ||
"headBlockHash": "0x80732341439dd124df94271386141735f13ef8a85e12e9fba15c06bc1ad9fd73", | ||
"safeBlockHash": "0x80732341439dd124df94271386141735f13ef8a85e12e9fba15c06bc1ad9fd73", | ||
"finalizedBlockHash": "0x3b8fb240d288781d4aac94d3fd16809ee413bc99294a085798a589dae51ddd4a" | ||
}, | ||
null | ||
], | ||
"id": 67 | ||
}, | ||
"response": { | ||
"jsonrpc": "2.0", | ||
"id": 67, | ||
"result": { | ||
"payloadStatus": { | ||
"status": "VALID", | ||
"latestValidHash": "0x80732341439dd124df94271386141735f13ef8a85e12e9fba15c06bc1ad9fd73", | ||
"validationError": null | ||
}, | ||
"payloadId": null | ||
} | ||
}, | ||
"statusCode": 200 | ||
} |
33 changes: 33 additions & 0 deletions
33
...ts/tests/src/test/resources/jsonrpc/debug/replayBlock/test-cases/05_get_latest_block.json
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,33 @@ | ||
{ | ||
"request": { | ||
"jsonrpc":"2.0","method":"eth_getBlockByNumber","params":["latest", false],"id":1 | ||
}, | ||
"response": { | ||
"jsonrpc": "2.0", | ||
"id": 1, | ||
"result": { | ||
"number": "0x2", | ||
"hash": "0x80732341439dd124df94271386141735f13ef8a85e12e9fba15c06bc1ad9fd73", | ||
"mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", | ||
"parentHash": "0x3559e851470f6e7bbed1db474980683e8c315bfce99b2a6ef47c057c04de7858", | ||
"nonce": "0x0000000000000000", | ||
"sha3Uncles": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", | ||
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", | ||
"transactionsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", | ||
"stateRoot": "0xca3149fa9e37db08d1cd49c9061db1002ef1cd58db2210f2115c8c989b2bdf45", | ||
"receiptsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", | ||
"miner": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", | ||
"difficulty": "0x0", | ||
"totalDifficulty": "0x400000000", | ||
"extraData": "0x", | ||
"baseFeePerGas": "0x7", | ||
"size": "0x1fa", | ||
"gasLimit": "0x1c9c380", | ||
"gasUsed": "0x0", | ||
"timestamp": "0x6", | ||
"uncles": [], | ||
"transactions": [] | ||
} | ||
}, | ||
"statusCode": 200 | ||
} |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.