7288: include WithdrawalRequestPredeployAddress in genesis configuration (#7356)

* 7288: include WithdrawalRequestPredeployAddress in genesis configuration

Signed-off-by: Matilda Clerke <matilda.clerke@consensys.net>

* 7288: Update changelog

Signed-off-by: Matilda Clerke <matilda.clerke@consensys.net>

* 7288: Fix typo in new variable

Signed-off-by: Matilda Clerke <matilda.clerke@consensys.net>

* 7288: Rename withdrawalRequestPredeployAddress to withdrawalRequestContractAddress

Signed-off-by: Matilda Clerke <matilda.clerke@consensys.net>

* 7288: Update changelog to match recent changes

Signed-off-by: Matilda Clerke <matilda.clerke@consensys.net>

* 5098: Move changelog item to next release

Signed-off-by: Matilda Clerke <matilda.clerke@consensys.net>

---------

Signed-off-by: Matilda Clerke <matilda.clerke@consensys.net>
Signed-off-by: Matilda-Clerke <matilda.clerke@consensys.net>
pull/7392/head
Matilda-Clerke 4 months ago committed by GitHub
parent f8edb7332c
commit 94b497e261
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 1
      CHANGELOG.md
  2. 7
      config/src/main/java/org/hyperledger/besu/config/GenesisConfigOptions.java
  3. 11
      config/src/main/java/org/hyperledger/besu/config/JsonGenesisConfigOptions.java
  4. 5
      config/src/main/java/org/hyperledger/besu/config/StubGenesisConfigOptions.java
  5. 26
      config/src/test/java/org/hyperledger/besu/config/GenesisConfigOptionsTest.java
  6. 8
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetProtocolSpecs.java
  7. 6
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/MainnetRequestsValidator.java
  8. 10
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/WithdrawalRequestProcessor.java

@ -7,6 +7,7 @@
- --Xbonsai-limit-trie-logs-enabled is deprecated, use --bonsai-limit-trie-logs-enabled instead
- --Xbonsai-trie-logs-pruning-window-size is deprecated, use --bonsai-trie-logs-pruning-window-size instead
- `besu storage x-trie-log` subcommand is deprecated, use `besu storage trie-log` instead
- Allow configuration of Withdrawal Request Contract Address via genesis configuration [#7356](https://github.com/hyperledger/besu/pull/7356)
### Breaking Changes

@ -525,6 +525,13 @@ public interface GenesisConfigOptions {
*/
boolean isFixedBaseFee();
/**
* The withdrawal request predeploy address
*
* @return the withdrawal request predeploy address
*/
Optional<Address> getWithdrawalRequestContractAddress();
/**
* The deposit contract address that should be in the logger field in Receipt of Deposit
* transaction

@ -49,6 +49,8 @@ public class JsonGenesisConfigOptions implements GenesisConfigOptions {
private static final String CHECKPOINT_CONFIG_KEY = "checkpoint";
private static final String ZERO_BASE_FEE_KEY = "zerobasefee";
private static final String FIXED_BASE_FEE_KEY = "fixedbasefee";
private static final String WITHDRAWAL_REQUEST_CONTRACT_ADDRESS_KEY =
"withdrawalrequestcontractaddress";
private static final String DEPOSIT_CONTRACT_ADDRESS_KEY = "depositcontractaddress";
private final ObjectNode configRoot;
@ -438,6 +440,13 @@ public class JsonGenesisConfigOptions implements GenesisConfigOptions {
return getOptionalBoolean(FIXED_BASE_FEE_KEY).orElse(false);
}
@Override
public Optional<Address> getWithdrawalRequestContractAddress() {
Optional<String> inputAddress =
JsonUtil.getString(configRoot, WITHDRAWAL_REQUEST_CONTRACT_ADDRESS_KEY);
return inputAddress.map(Address::fromHexString);
}
@Override
public Optional<Address> getDepositContractAddress() {
Optional<String> inputAddress = JsonUtil.getString(configRoot, DEPOSIT_CONTRACT_ADDRESS_KEY);
@ -492,6 +501,8 @@ public class JsonGenesisConfigOptions implements GenesisConfigOptions {
getEvmStackSize().ifPresent(l -> builder.put("evmstacksize", l));
getEcip1017EraRounds().ifPresent(l -> builder.put("ecip1017EraRounds", l));
getWithdrawalRequestContractAddress()
.ifPresent(l -> builder.put("withdrawalRequestContractAddress", l));
getDepositContractAddress().ifPresent(l -> builder.put("depositContractAddress", l));
if (isClique()) {

@ -457,6 +457,11 @@ public class StubGenesisConfigOptions implements GenesisConfigOptions, Cloneable
return Collections.emptyList();
}
@Override
public Optional<Address> getWithdrawalRequestContractAddress() {
return Optional.empty();
}
@Override
public Optional<Address> getDepositContractAddress() {
return Optional.empty();

@ -332,6 +332,32 @@ class GenesisConfigOptionsTest {
assertThat(config.asMap()).containsOnlyKeys("fixedBaseFee").containsValue(true);
}
@Test
void shouldGetWithdrawalRequestContractAddress() {
final GenesisConfigOptions config =
fromConfigOptions(
singletonMap(
"withdrawalRequestContractAddress", "0x00000000219ab540356cbb839cbe05303d7705fa"));
assertThat(config.getWithdrawalRequestContractAddress())
.hasValue(Address.fromHexString("0x00000000219ab540356cbb839cbe05303d7705fa"));
}
@Test
void shouldNotHaveWithdrawalRequestContractAddressWhenEmpty() {
final GenesisConfigOptions config = fromConfigOptions(emptyMap());
assertThat(config.getWithdrawalRequestContractAddress()).isEmpty();
}
@Test
void asMapIncludesWithdrawalRequestContractAddress() {
final GenesisConfigOptions config =
fromConfigOptions(Map.of("withdrawalRequestContractAddress", "0x0"));
assertThat(config.asMap())
.containsOnlyKeys("withdrawalRequestContractAddress")
.containsValue(Address.ZERO);
}
@Test
void shouldGetDepositContractAddress() {
final GenesisConfigOptions config =

@ -17,6 +17,7 @@ package org.hyperledger.besu.ethereum.mainnet;
import static org.hyperledger.besu.ethereum.mainnet.requests.DepositRequestProcessor.DEFAULT_DEPOSIT_CONTRACT_ADDRESS;
import static org.hyperledger.besu.ethereum.mainnet.requests.MainnetRequestsValidator.pragueRequestsProcessors;
import static org.hyperledger.besu.ethereum.mainnet.requests.MainnetRequestsValidator.pragueRequestsValidator;
import static org.hyperledger.besu.ethereum.mainnet.requests.WithdrawalRequestProcessor.DEFAULT_WITHDRAWAL_REQUEST_CONTRACT_ADDRESS;
import org.hyperledger.besu.config.GenesisConfigOptions;
import org.hyperledger.besu.config.PowAlgorithm;
@ -766,6 +767,10 @@ public abstract class MainnetProtocolSpecs {
final boolean isParallelTxProcessingEnabled,
final MetricsSystem metricsSystem) {
final Address withdrawalRequestContractAddress =
genesisConfigOptions
.getWithdrawalRequestContractAddress()
.orElse(DEFAULT_WITHDRAWAL_REQUEST_CONTRACT_ADDRESS);
final Address depositContractAddress =
genesisConfigOptions.getDepositContractAddress().orElse(DEFAULT_DEPOSIT_CONTRACT_ADDRESS);
@ -791,7 +796,8 @@ public abstract class MainnetProtocolSpecs {
// EIP-7002 Withdrawals / EIP-6610 Deposits / EIP-7685 Requests
.requestsValidator(pragueRequestsValidator(depositContractAddress))
// EIP-7002 Withdrawals / EIP-6610 Deposits / EIP-7685 Requests
.requestProcessorCoordinator(pragueRequestsProcessors(depositContractAddress))
.requestProcessorCoordinator(
pragueRequestsProcessors(withdrawalRequestContractAddress, depositContractAddress))
// change to accept EIP-7702 transactions
.transactionValidatorFactoryBuilder(

@ -28,9 +28,11 @@ public class MainnetRequestsValidator {
}
public static RequestProcessorCoordinator pragueRequestsProcessors(
final Address depositContractAddress) {
final Address withdrawalRequestContractAddress, final Address depositContractAddress) {
return new RequestProcessorCoordinator.Builder()
.addProcessor(RequestType.WITHDRAWAL, new WithdrawalRequestProcessor())
.addProcessor(
RequestType.WITHDRAWAL,
new WithdrawalRequestProcessor(withdrawalRequestContractAddress))
.addProcessor(RequestType.CONSOLIDATION, new ConsolidationRequestProcessor())
.addProcessor(RequestType.DEPOSIT, new DepositRequestProcessor(depositContractAddress))
.build();

@ -26,7 +26,7 @@ import org.apache.tuweni.units.bigints.UInt64;
public class WithdrawalRequestProcessor
extends AbstractSystemCallRequestProcessor<WithdrawalRequest> {
public static final Address WITHDRAWAL_REQUEST_PREDEPLOY_ADDRESS =
public static final Address DEFAULT_WITHDRAWAL_REQUEST_CONTRACT_ADDRESS =
Address.fromHexString("0x00A3ca265EBcb825B45F985A16CEFB49958cE017");
private static final int ADDRESS_BYTES = 20;
@ -35,6 +35,12 @@ public class WithdrawalRequestProcessor
private static final int WITHDRAWAL_REQUEST_BYTES_SIZE =
ADDRESS_BYTES + PUBLIC_KEY_BYTES + AMOUNT_BYTES;
private final Address withdrawalRequestContractAddress;
public WithdrawalRequestProcessor(final Address withdrawalRequestContractAddress) {
this.withdrawalRequestContractAddress = withdrawalRequestContractAddress;
}
/**
* Gets the call address for withdrawal requests.
*
@ -42,7 +48,7 @@ public class WithdrawalRequestProcessor
*/
@Override
protected Address getCallAddress() {
return WITHDRAWAL_REQUEST_PREDEPLOY_ADDRESS;
return withdrawalRequestContractAddress;
}
/**

Loading…
Cancel
Save