Skip to content
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

EIP-6110: Add deposit validation and apis #5295

Merged
merged 47 commits into from
Jun 21, 2023
Merged
Show file tree
Hide file tree
Changes from 33 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
dcd958b
Initial commit
ensi321 Apr 3, 2023
ee3e2ae
Spotless Apply
ensi321 Apr 3, 2023
e62b6f5
Update test
ensi321 Apr 3, 2023
d25ad53
Added rpc tests. Update block creator rule for deposits
ensi321 Apr 3, 2023
ca121d3
Update test
ensi321 Apr 3, 2023
faf5a83
Update test
ensi321 Apr 4, 2023
53b2ac3
Spotless Apply
ensi321 Apr 4, 2023
941f602
Get deposit validator by block header
ensi321 Apr 4, 2023
0c26667
Fix up unit tests
ensi321 Apr 4, 2023
c15fa47
Recover deleted files
ensi321 Apr 5, 2023
2c80293
Fix test
ensi321 Apr 5, 2023
bb805c1
Rename according to feedback
ensi321 Apr 11, 2023
e6adf32
Introduce depositContractAddress to genesis file
ensi321 Apr 11, 2023
da4e180
Merge remote-tracking branch 'remote/main' into eip-6110
ensi321 Apr 11, 2023
d3d18a8
Update test to accommodate changes
ensi321 Apr 11, 2023
162f60c
Fix test
ensi321 Apr 11, 2023
6d567cc
Address comments
ensi321 Apr 30, 2023
1dbad08
Address pr comments
ensi321 May 2, 2023
00a9edd
Merge remote-tracking branch 'remote/main' into eip-6110
ensi321 May 2, 2023
695e6a0
Updated DepositsValidatorProvider
ensi321 May 2, 2023
fd8739b
Spotless Apply
ensi321 May 2, 2023
0bf4be1
Extract correct logs from receipts
ensi321 May 2, 2023
7f55dd9
Merge branch 'main' into eip-6110
ensi321 May 3, 2023
17d264b
Add changelog
ensi321 May 3, 2023
f79d203
Address PR comments
ensi321 May 8, 2023
807940f
Address PR comments
ensi321 May 8, 2023
d5ec15f
Address PR comments
ensi321 May 8, 2023
d712c0d
Merge branch 'main' into eip-6110
ensi321 May 8, 2023
f962e62
Spotless Apply
ensi321 May 8, 2023
1caf791
Detail log on failing deposit validation
ensi321 May 10, 2023
c3cbf98
Pass depositContractAddress to block creator and coordinator
ensi321 May 11, 2023
dd44ed4
Merge remote-tracking branch 'remote/main' into eip-6110
ensi321 May 12, 2023
201c44e
Update javadoc
ensi321 May 14, 2023
52e422b
Address comments
ensi321 May 16, 2023
713cc5d
Address comments
ensi321 May 16, 2023
eced987
Fix spotless
siladu May 26, 2023
74cda7f
Merge branch 'main' into eip-6110
siladu May 26, 2023
a9f80de
Merge remote-tracking branch 'remote/main' into eip-6110
ensi321 Jun 4, 2023
0b849ca
Merge branch 'hyperledger:main' into eip-6110
ensi321 Jun 11, 2023
e4efdff
Fix acceptance tests
ensi321 Jun 13, 2023
c99fe13
Merge branch 'main' into eip-6110
ensi321 Jun 13, 2023
fa69181
Fix unit tests by setting genesis file in the setup code
siladu Jun 16, 2023
346415c
Merge remote-tracking branch 'upstream/main' into eip-6110
siladu Jun 16, 2023
2380e32
Fix mock in another test, unintended consequence of last commit
siladu Jun 16, 2023
8804b98
Add units for AbstractBlockCreator
siladu Jun 16, 2023
b790ff1
Inline variables and tidy up
siladu Jun 16, 2023
8b270bb
Merge branch 'main' into eip-6110
siladu Jun 21, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
- "Big-EOF" (the EOF version initially slotted for Shanghai) has been moved from Cancun to FutureEIPs [#5429](https://github.com/hyperledger/besu/pull/5429)
- EIP-4844: Zero blob transactions are invalid [#5425](https://github.com/hyperledger/besu/pull/5425)
- Transaction pool flag to disable specific behaviors for locally submitted transactions [#5418](https://github.com/hyperledger/besu/pull/5418)
- Added In-Protocol Deposit prototype (EIP-6110) in the experimental eip. [#5005](https://github.com/hyperledger/besu/pull/5055) [#5295](https://github.com/hyperledger/besu/pull/5295)
- New optional feature to save the txpool content to file on shutdown and reloading it on startup [#5434](https://github.com/hyperledger/besu/pull/5434)
- New option to send SNI header in TLS ClientHello message [#5439](https://github.com/hyperledger/besu/pull/5439)
- Early access - layered transaction pool implementation [#5290](https://github.com/hyperledger/besu/pull/5290)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"berlinBlock":0,
"londonBlock":0,
"shanghaiTime":10,
"experimentalEipsTime":20,
"clique": {
"period": 5,
"epoch": 30000
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"amount": "0x4"
}
],
"deposits": null,
ensi321 marked this conversation as resolved.
Show resolved Hide resolved
"blockNumber": "0x2",
"blockHash": "0x4a7b0e390d320a07150daa9c3b9dddfc6b7f6ca7d7a2971ef2f53ac1f29f24dc",
"receiptsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"request": {
"jsonrpc": "2.0",
"method": "engine_forkchoiceUpdatedV2",
"params": [
{
"headBlockHash": "0x4f88d512a0045bc6d447ba74a18eac0ed2ebb8d9faca325f5f55b2ca84be0705",
"safeBlockHash": "0x4f88d512a0045bc6d447ba74a18eac0ed2ebb8d9faca325f5f55b2ca84be0705",
"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": "0x4f88d512a0045bc6d447ba74a18eac0ed2ebb8d9faca325f5f55b2ca84be0705",
"validationError": null
},
"payloadId": "0x0065bd4610115c06"
}
},
"statusCode" : 200
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"request": {
"jsonrpc": "2.0",
"method": "engine_getPayloadV2",
"params": [
"0x0065bd4610115c06"
],
"id": 67
},
"response": {
"jsonrpc": "2.0",
"id": 67,
"result": {
"executionPayload": {
"parentHash": "0x4f88d512a0045bc6d447ba74a18eac0ed2ebb8d9faca325f5f55b2ca84be0705",
"feeRecipient": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b",
"stateRoot": "0x0212f870b77bf90e46d6d7f3cab2d0b7b8c8599d452736d572048789fffda8de",
"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" : [],
jframe marked this conversation as resolved.
Show resolved Hide resolved
"blockNumber": "0x3",
"blockHash": "0xf6c1bee3c5831a9fc068abd3ed3619fd82900622c6e8bb1dc39dee099b246b88",
"receiptsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421"
},
"blockValue": "0x0"
}
},
"statusCode": 200
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"request": {
"jsonrpc": "2.0",
"method": "engine_newPayloadV2",
"params": [
{
"parentHash": "0x4f88d512a0045bc6d447ba74a18eac0ed2ebb8d9faca325f5f55b2ca84be0705",
"feeRecipient": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b",
"stateRoot": "0x1a10dba514dc4faff7ec13edd9b5ef653c1cd14eb26608bfc2b37717730a55a4",
"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": null,
"blockNumber": "0x3",
"blockHash": "0x1475ca311179652e44b10b7e2d7b72f3708f3201f8d729880a83f3eb397910e8",
"receiptsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421"
}
],
"id": 67
},
"response": {
"jsonrpc": "2.0",
"id": 67,
"error": {
"code": -32602,
"message": "Invalid params"
}
},
"statusCode": 200
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"request": {
"jsonrpc": "2.0",
"method": "engine_newPayloadV2",
"params": [
{
"parentHash": "0x4f88d512a0045bc6d447ba74a18eac0ed2ebb8d9faca325f5f55b2ca84be0705",
"feeRecipient": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b",
"stateRoot": "0x0212f870b77bf90e46d6d7f3cab2d0b7b8c8599d452736d572048789fffda8de",
"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": "0x3",
"blockHash": "0x9a083733e09cb4983933e7a7053ca470c3f583bb54e38d32c9ab396c8ededd6f",
"receiptsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421"
}
],
"id": 67
},
"response": {
"jsonrpc": "2.0",
"id": 67,
"result": {
"status": "VALID",
"latestValidHash": "0x9a083733e09cb4983933e7a7053ca470c3f583bb54e38d32c9ab396c8ededd6f",
"validationError": null
}
},
"statusCode": 200
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.hyperledger.besu.consensus.merge.PostMergeContext;
import org.hyperledger.besu.consensus.merge.TransitionBestPeerComparator;
import org.hyperledger.besu.consensus.merge.blockcreation.MergeCoordinator;
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.ethereum.ProtocolContext;
import org.hyperledger.besu.ethereum.blockcreation.MiningCoordinator;
Expand Down Expand Up @@ -162,6 +163,10 @@ protected MiningCoordinator createTransitionMiningCoordinator(
final ExecutorService blockBuilderExecutor =
MonitoredExecutors.newSingleThreadExecutor("PoS-Block-Builder", metricsSystem);

final GenesisConfigOptions genesisConfigOptions = configOptionsSupplier.get();
final Optional<Address> depositContractAddress =
genesisConfigOptions.getDepositContractAddress();

return new MergeCoordinator(
protocolContext,
protocolSchedule,
Expand All @@ -171,7 +176,8 @@ protected MiningCoordinator createTransitionMiningCoordinator(
},
transactionPool.getPendingTransactions(),
miningParameters,
backwardSyncContext);
backwardSyncContext,
depositContractAddress);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
*/
package org.hyperledger.besu.config;

import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.datatypes.Wei;

Expand Down Expand Up @@ -494,4 +495,12 @@ default boolean isConsensusMigration() {
* @return true, if you want the next block to use zero for the base fee.
*/
boolean isZeroBaseFee();

/**
* The deposit contract address that should be in the logger field in Receipt of Deposit
* transaction
*
* @return the deposit address
*/
Optional<Address> getDepositContractAddress();
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import static java.util.Collections.emptyMap;
import static java.util.Objects.isNull;

import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.datatypes.Wei;

Expand Down Expand Up @@ -47,6 +48,7 @@ public class JsonGenesisConfigOptions implements GenesisConfigOptions {
private static final String DISCOVERY_CONFIG_KEY = "discovery";
private static final String CHECKPOINT_CONFIG_KEY = "checkpoint";
private static final String ZERO_BASE_FEE_KEY = "zerobasefee";
private static final String DEPOSIT_CONTRACT_ADDRESS_KEY = "depositcontractaddress";

private final ObjectNode configRoot;
private final Map<String, String> configOverrides = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
Expand Down Expand Up @@ -418,6 +420,12 @@ public boolean isZeroBaseFee() {
return getOptionalBoolean(ZERO_BASE_FEE_KEY).orElse(false);
}

@Override
public Optional<Address> getDepositContractAddress() {
ensi321 marked this conversation as resolved.
Show resolved Hide resolved
Optional<String> inputAddress = JsonUtil.getString(configRoot, DEPOSIT_CONTRACT_ADDRESS_KEY);
return inputAddress.map(Address::fromHexString);
}

@Override
public Map<String, Object> asMap() {
final ImmutableMap.Builder<String, Object> builder = ImmutableMap.builder();
Expand Down Expand Up @@ -462,6 +470,8 @@ public Map<String, Object> asMap() {
getEvmStackSize().ifPresent(l -> builder.put("evmstacksize", l));
getEcip1017EraRounds().ifPresent(l -> builder.put("ecip1017EraRounds", l));

getDepositContractAddress().ifPresent(l -> builder.put("depositContractAddress", l));

if (isClique()) {
builder.put("clique", getCliqueConfigOptions().asMap());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
*/
package org.hyperledger.besu.config;

import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.datatypes.Wei;

Expand Down Expand Up @@ -371,6 +372,7 @@ public Map<String, Object> asMap() {

getContractSizeLimit().ifPresent(l -> builder.put("contractSizeLimit", l));
getEvmStackSize().ifPresent(l -> builder.put("evmStackSize", l));
getDepositContractAddress().ifPresent(l -> builder.put("depositContractAddress", l));
if (isClique()) {
builder.put("clique", getCliqueConfigOptions().asMap());
}
Expand Down Expand Up @@ -423,6 +425,11 @@ public List<Long> getForkBlockTimestamps() {
return Collections.emptyList();
}

@Override
public Optional<Address> getDepositContractAddress() {
return Optional.empty();
}

/**
* Homestead block stub genesis config options.
*
Expand Down
3 changes: 2 additions & 1 deletion config/src/main/resources/experimental.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"number": 0,
"totalDifficulty": "0x0"
}
},
"depositContractAddress": "0x00000000219ab540356cbb839cbe05303d7705fa"
},
"nonce": "0x42",
"timestamp": "0x0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;

import org.hyperledger.besu.datatypes.Address;

import java.math.BigInteger;
import java.util.HashMap;
import java.util.Map;
Expand Down Expand Up @@ -291,6 +293,30 @@ public void asMapIncludesZeroBaseFee() {
assertThat(config.asMap()).containsOnlyKeys("zeroBaseFee").containsValue(true);
}

@Test
public void shouldGetDepositContractAddress() {
final GenesisConfigOptions config =
fromConfigOptions(
singletonMap("depositContractAddress", "0x00000000219ab540356cbb839cbe05303d7705fa"));
assertThat(config.getDepositContractAddress())
.hasValue(Address.fromHexString("0x00000000219ab540356cbb839cbe05303d7705fa"));
}

@Test
public void shouldNotHaveDepositContractAddressWhenEmpty() {
final GenesisConfigOptions config = fromConfigOptions(emptyMap());
assertThat(config.getDepositContractAddress()).isEmpty();
}

@Test
public void asMapIncludesDepositContractAddress() {
final GenesisConfigOptions config = fromConfigOptions(Map.of("depositContractAddress", "0x0"));

assertThat(config.asMap())
.containsOnlyKeys("depositContractAddress")
.containsValue(Address.ZERO);
}

private GenesisConfigOptions fromConfigOptions(final Map<String, Object> configOptions) {
final ObjectNode rootNode = JsonUtil.createEmptyObjectNode();
final ObjectNode options = JsonUtil.objectNodeFromMap(configOptions);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"byzantiumBlock": 1035301,
"londonBlock": 2222222,
"zeroBaseFee": true,
"depositContractAddress": "0x00000000219ab540356cbb839cbe05303d7705fa",
"ibft2": {
"blockperiodseconds": 2,
"epochlength": 30000,
Expand Down
Loading