forked from hyperledger/besu
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
EIP-6110: Add deposit validation and apis (hyperledger#5295)
Completes the implementation of EIP-6110 * Decode and extract deposit from transaction receipt log * Introduce depositContractAddress field in genesis file * Validate deposits in a block against the transaction receipt logs * Update engine_newPayloadV2 and engine_getPayloadV2 according to the spec. Some of the non-functional components were partially implemented in the previous PR Signed-off-by: naviechan <[email protected]> Signed-off-by: Simon Dudley <[email protected]> Co-authored-by: Simon Dudley <[email protected]>
- Loading branch information
Showing
66 changed files
with
1,473 additions
and
337 deletions.
There are no files selected for viewing
This file contains 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
...a/org/hyperledger/besu/tests/acceptance/jsonrpc/ExecutionEngineEip6110AcceptanceTest.java
This file contains 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 contributors to Hyperledger Besu. | ||
* | ||
* 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 ExecutionEngineEip6110AcceptanceTest extends AbstractJsonRpcTest { | ||
private static final String GENESIS_FILE = "/jsonrpc/engine/eip6110/genesis.json"; | ||
private static final String TEST_CASE_PATH = "/jsonrpc/engine/eip6110/test-cases/"; | ||
|
||
private static JsonRpcTestsContext testsContext; | ||
|
||
public ExecutionEngineEip6110AcceptanceTest(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(); | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
acceptance-tests/tests/src/test/resources/jsonrpc/engine/eip6110/genesis.json
This file contains 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,38 @@ | ||
{ | ||
"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, | ||
"terminalTotalDifficulty":0, | ||
"shanghaiTime":0, | ||
"experimentalEipsTime":20, | ||
"clique": { | ||
"period": 5, | ||
"epoch": 30000 | ||
}, | ||
"depositContractAddress": "0x00000000219ab540356cbb839cbe05303d7705fa" | ||
}, | ||
"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" | ||
} |
46 changes: 46 additions & 0 deletions
46
...sts/src/test/resources/jsonrpc/engine/eip6110/test-cases/01_shanghai_prepare_payload.json
This file contains 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,46 @@ | ||
{ | ||
"request": { | ||
"jsonrpc": "2.0", | ||
"method": "engine_forkchoiceUpdatedV2", | ||
"params": [ | ||
{ | ||
"headBlockHash": "0xfe950635b1bd2a416ff6283b0bbd30176e1b1125ad06fa729da9f3f4c1c61710", | ||
"safeBlockHash": "0xfe950635b1bd2a416ff6283b0bbd30176e1b1125ad06fa729da9f3f4c1c61710", | ||
"finalizedBlockHash": "0x0000000000000000000000000000000000000000000000000000000000000000" | ||
}, | ||
{ | ||
"timestamp": "0x10", | ||
"prevRandao": "0x0000000000000000000000000000000000000000000000000000000000000000", | ||
"suggestedFeeRecipient": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", | ||
"withdrawals": [ | ||
{ | ||
"index": "0x0", | ||
"validatorIndex": "0x0", | ||
"address": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", | ||
"amount": "0x3" | ||
}, | ||
{ | ||
"index": "0x1", | ||
"validatorIndex": "0x1", | ||
"address": "0xfe3b557e8fb62b89f4916b721be55ceb828dbd73", | ||
"amount": "0x4" | ||
} | ||
] | ||
} | ||
], | ||
"id": 67 | ||
}, | ||
"response": { | ||
"jsonrpc": "2.0", | ||
"id": 67, | ||
"result": { | ||
"payloadStatus": { | ||
"status": "VALID", | ||
"latestValidHash": "0xfe950635b1bd2a416ff6283b0bbd30176e1b1125ad06fa729da9f3f4c1c61710", | ||
"validationError": null | ||
}, | ||
"payloadId": "0x0065bd1bbeaff359" | ||
} | ||
}, | ||
"statusCode" : 200 | ||
} |
49 changes: 49 additions & 0 deletions
49
.../tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/02_shanghai_getPayloadV2.json
This file contains 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,49 @@ | ||
{ | ||
"request": { | ||
"jsonrpc": "2.0", | ||
"method": "engine_getPayloadV2", | ||
"params": [ | ||
"0x0065bd1bbeaff359" | ||
], | ||
"id": 67 | ||
}, | ||
"response": { | ||
"jsonrpc": "2.0", | ||
"id": 67, | ||
"result": { | ||
"executionPayload": { | ||
"parentHash": "0xfe950635b1bd2a416ff6283b0bbd30176e1b1125ad06fa729da9f3f4c1c61710", | ||
"feeRecipient": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", | ||
"stateRoot": "0xc8c8e840369eac89a610bfe2ec21fcdee4c9c43bec4876f0129fcd4b5311f6dd", | ||
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", | ||
"prevRandao": "0x0000000000000000000000000000000000000000000000000000000000000000", | ||
"gasLimit": "0x1c9c380", | ||
"gasUsed": "0x0", | ||
"timestamp": "0x10", | ||
"extraData": "0x", | ||
"baseFeePerGas": "0x7", | ||
"transactions": [], | ||
"withdrawals": [ | ||
{ | ||
"index": "0x0", | ||
"validatorIndex": "0x0", | ||
"address": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", | ||
"amount": "0x3" | ||
}, | ||
{ | ||
"index": "0x1", | ||
"validatorIndex": "0x1", | ||
"address": "0xfe3b557e8fb62b89f4916b721be55ceb828dbd73", | ||
"amount": "0x4" | ||
} | ||
], | ||
"deposits": null, | ||
"blockNumber": "0x1", | ||
"blockHash": "0xfdd94e3620a88f08927bffb318981a36b663a26e6fd62ab273eb800b90723c13", | ||
"receiptsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421" | ||
}, | ||
"blockValue": "0x0" | ||
} | ||
}, | ||
"statusCode": 200 | ||
} |
49 changes: 49 additions & 0 deletions
49
.../tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/03_shanghai_newPayloadV2.json
This file contains 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,49 @@ | ||
{ | ||
"request": { | ||
"jsonrpc": "2.0", | ||
"method": "engine_newPayloadV2", | ||
"params": [ | ||
{ | ||
"parentHash": "0xfe950635b1bd2a416ff6283b0bbd30176e1b1125ad06fa729da9f3f4c1c61710", | ||
"feeRecipient": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", | ||
"stateRoot": "0xc8c8e840369eac89a610bfe2ec21fcdee4c9c43bec4876f0129fcd4b5311f6dd", | ||
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", | ||
"prevRandao": "0x0000000000000000000000000000000000000000000000000000000000000000", | ||
"gasLimit": "0x1c9c380", | ||
"gasUsed": "0x0", | ||
"timestamp": "0x10", | ||
"extraData": "0x", | ||
"baseFeePerGas": "0x7", | ||
"transactions": [], | ||
"withdrawals": [ | ||
{ | ||
"index": "0x0", | ||
"validatorIndex": "0x0", | ||
"address": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", | ||
"amount": "0x3" | ||
}, | ||
{ | ||
"index": "0x1", | ||
"validatorIndex": "0x1", | ||
"address": "0xfe3b557e8fb62b89f4916b721be55ceb828dbd73", | ||
"amount": "0x4" | ||
} | ||
], | ||
"blockNumber": "0x1", | ||
"blockHash": "0xfdd94e3620a88f08927bffb318981a36b663a26e6fd62ab273eb800b90723c13", | ||
"receiptsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421" | ||
} | ||
], | ||
"id": 67 | ||
}, | ||
"response": { | ||
"jsonrpc": "2.0", | ||
"id": 67, | ||
"result": { | ||
"status": "VALID", | ||
"latestValidHash": "0xfdd94e3620a88f08927bffb318981a36b663a26e6fd62ab273eb800b90723c13", | ||
"validationError": null | ||
} | ||
}, | ||
"statusCode": 200 | ||
} |
28 changes: 28 additions & 0 deletions
28
...src/test/resources/jsonrpc/engine/eip6110/test-cases/04_shanghai_forkchoiceUpdatedV2.json
This file contains 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_forkchoiceUpdatedV2", | ||
"params": [ | ||
{ | ||
"headBlockHash": "0xfdd94e3620a88f08927bffb318981a36b663a26e6fd62ab273eb800b90723c13", | ||
"safeBlockHash": "0xfdd94e3620a88f08927bffb318981a36b663a26e6fd62ab273eb800b90723c13", | ||
"finalizedBlockHash": "0xfdd94e3620a88f08927bffb318981a36b663a26e6fd62ab273eb800b90723c13" | ||
}, | ||
null | ||
], | ||
"id": 67 | ||
}, | ||
"response": { | ||
"jsonrpc": "2.0", | ||
"id": 67, | ||
"result": { | ||
"payloadStatus": { | ||
"status": "VALID", | ||
"latestValidHash": "0xfdd94e3620a88f08927bffb318981a36b663a26e6fd62ab273eb800b90723c13", | ||
"validationError": null | ||
}, | ||
"payloadId": null | ||
} | ||
}, | ||
"statusCode": 200 | ||
} |
46 changes: 46 additions & 0 deletions
46
...ests/src/test/resources/jsonrpc/engine/eip6110/test-cases/05_eip6110_prepare_payload.json
This file contains 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,46 @@ | ||
{ | ||
"request": { | ||
"jsonrpc": "2.0", | ||
"method": "engine_forkchoiceUpdatedV2", | ||
"params": [ | ||
{ | ||
"headBlockHash": "0xfdd94e3620a88f08927bffb318981a36b663a26e6fd62ab273eb800b90723c13", | ||
"safeBlockHash": "0xfdd94e3620a88f08927bffb318981a36b663a26e6fd62ab273eb800b90723c13", | ||
"finalizedBlockHash": "0x0000000000000000000000000000000000000000000000000000000000000000" | ||
}, | ||
{ | ||
"timestamp": "0x20", | ||
"prevRandao": "0x0000000000000000000000000000000000000000000000000000000000000000", | ||
"suggestedFeeRecipient": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", | ||
"withdrawals": [ | ||
{ | ||
"index": "0x0", | ||
"validatorIndex": "0x0", | ||
"address": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", | ||
"amount": "0x1" | ||
}, | ||
{ | ||
"index": "0x1", | ||
"validatorIndex": "0x0", | ||
"address": "0xfe3b557e8fb62b89f4916b721be55ceb828dbd73", | ||
"amount": "0x2" | ||
} | ||
] | ||
} | ||
], | ||
"id": 67 | ||
}, | ||
"response": { | ||
"jsonrpc": "2.0", | ||
"id": 67, | ||
"result": { | ||
"payloadStatus": { | ||
"status": "VALID", | ||
"latestValidHash": "0xfdd94e3620a88f08927bffb318981a36b663a26e6fd62ab273eb800b90723c13", | ||
"validationError": null | ||
}, | ||
"payloadId": "0x0065bd63871ad606" | ||
} | ||
}, | ||
"statusCode" : 200 | ||
} |
49 changes: 49 additions & 0 deletions
49
...ts/tests/src/test/resources/jsonrpc/engine/eip6110/test-cases/06_eip6110_get_payload.json
This file contains 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,49 @@ | ||
{ | ||
"request": { | ||
"jsonrpc": "2.0", | ||
"method": "engine_getPayloadV2", | ||
"params": [ | ||
"0x0065bd63871ad606" | ||
], | ||
"id": 67 | ||
}, | ||
"response": { | ||
"jsonrpc": "2.0", | ||
"id": 67, | ||
"result": { | ||
"executionPayload": { | ||
"parentHash": "0xfdd94e3620a88f08927bffb318981a36b663a26e6fd62ab273eb800b90723c13", | ||
"feeRecipient": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", | ||
"stateRoot": "0x21395692fae33414143728c9ffc0aed8dcc76eb6731dd0f5a3239977478ca969", | ||
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", | ||
"prevRandao": "0x0000000000000000000000000000000000000000000000000000000000000000", | ||
"gasLimit": "0x1c9c380", | ||
"gasUsed": "0x0", | ||
"timestamp": "0x20", | ||
"extraData": "0x", | ||
"baseFeePerGas": "0x7", | ||
"transactions": [], | ||
"withdrawals": [ | ||
{ | ||
"index": "0x0", | ||
"validatorIndex": "0x0", | ||
"address": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", | ||
"amount": "0x1" | ||
}, | ||
{ | ||
"index": "0x1", | ||
"validatorIndex": "0x0", | ||
"address": "0xfe3b557e8fb62b89f4916b721be55ceb828dbd73", | ||
"amount": "0x2" | ||
} | ||
], | ||
"deposits" : [], | ||
"blockNumber": "0x2", | ||
"blockHash": "0x58ea3e01b03ac17c68ed3e3d724a021408273fac8a86f42cb30a26be8e93fbe9", | ||
"receiptsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421" | ||
}, | ||
"blockValue": "0x0" | ||
} | ||
}, | ||
"statusCode": 200 | ||
} |
Oops, something went wrong.