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

7288: include WithdrawalRequestPredeployAddress in genesis configuration #7356

1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
- Added EIP-7702 [#7237](https://github.com/hyperledger/besu/pull/7237)
- Implement gnark-crypto for eip-196 [#7262](https://github.com/hyperledger/besu/pull/7262)
- Add trie log pruner metrics [#7352](https://github.com/hyperledger/besu/pull/7352)
- Allow configuration of Withdrawal Request Predeploy Address via genesis configuration [#7356](https://github.com/hyperledger/besu/pull/7356)
- `--Xbonsai-parallel-tx-processing-enabled` option enables executing transactions in parallel during block processing for Bonsai nodes

### Bug fixes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,13 @@ default boolean isConsensusMigration() {
*/
boolean isFixedBaseFee();

/**
* The withdrawal request predeploy address
*
* @return the withdrawal request predeploy address
*/
Optional<Address> getWithdrawalRequestPredeployAddress();

/**
* The deposit contract address that should be in the logger field in Receipt of Deposit
* transaction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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_PREDEPLOY_ADDRESS_KEY =
Matilda-Clerke marked this conversation as resolved.
Show resolved Hide resolved
"withdrawalrequestpredeployaddress";
Matilda-Clerke marked this conversation as resolved.
Show resolved Hide resolved
private static final String DEPOSIT_CONTRACT_ADDRESS_KEY = "depositcontractaddress";

private final ObjectNode configRoot;
Expand Down Expand Up @@ -438,6 +440,13 @@ public boolean isFixedBaseFee() {
return getOptionalBoolean(FIXED_BASE_FEE_KEY).orElse(false);
}

@Override
public Optional<Address> getWithdrawalRequestPredeployAddress() {
Optional<String> inputAddress =
JsonUtil.getString(configRoot, WITHDRAWAL_REQUEST_PREDEPLOY_ADDRESS_KEY);
return inputAddress.map(Address::fromHexString);
}

@Override
public Optional<Address> getDepositContractAddress() {
Optional<String> inputAddress = JsonUtil.getString(configRoot, DEPOSIT_CONTRACT_ADDRESS_KEY);
Expand Down Expand Up @@ -492,6 +501,8 @@ public Map<String, Object> asMap() {
getEvmStackSize().ifPresent(l -> builder.put("evmstacksize", l));
getEcip1017EraRounds().ifPresent(l -> builder.put("ecip1017EraRounds", l));

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

if (isClique()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,11 @@ public List<Long> getForkBlockTimestamps() {
return Collections.emptyList();
}

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

@Override
public Optional<Address> getDepositContractAddress() {
return Optional.empty();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,32 @@ void asMapIncludesFixedBaseFee() {
assertThat(config.asMap()).containsOnlyKeys("fixedBaseFee").containsValue(true);
}

@Test
void shouldGetWithdrawalRequestPredeployAddress() {
final GenesisConfigOptions config =
fromConfigOptions(
singletonMap(
"withdrawalRequestPredeployAddress", "0x00000000219ab540356cbb839cbe05303d7705fa"));
assertThat(config.getWithdrawalRequestPredeployAddress())
.hasValue(Address.fromHexString("0x00000000219ab540356cbb839cbe05303d7705fa"));
}

@Test
void shouldNotHaveWithdrawalRequestPredeployAddressWhenEmpty() {
final GenesisConfigOptions config = fromConfigOptions(emptyMap());
assertThat(config.getWithdrawalRequestPredeployAddress()).isEmpty();
}

@Test
void asMapIncludesWithdrawalRequestPredeployAddress() {
final GenesisConfigOptions config =
fromConfigOptions(Map.of("withdrawalRequestPredeployAddress", "0x0"));

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

@Test
void shouldGetDepositContractAddress() {
final GenesisConfigOptions config =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
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_PREDEPLOY_ADDRESS;

import org.hyperledger.besu.config.GenesisConfigOptions;
import org.hyperledger.besu.config.PowAlgorithm;
Expand Down Expand Up @@ -766,6 +767,10 @@ static ProtocolSpecBuilder pragueDefinition(
final boolean isParallelTxProcessingEnabled,
final MetricsSystem metricsSystem) {

final Address withdrawalRequestPredeployAddress =
genesisConfigOptions
.getWithdrawalRequestPredeployAddress()
.orElse(DEFAULT_WITHDRAWAL_REQUEST_PREDEPLOY_ADDRESS);
final Address depositContractAddress =
genesisConfigOptions.getDepositContractAddress().orElse(DEFAULT_DEPOSIT_CONTRACT_ADDRESS);

Expand All @@ -791,7 +796,8 @@ static ProtocolSpecBuilder pragueDefinition(
// 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(withdrawalRequestPredeployAddress, depositContractAddress))

// change to accept EIP-7702 transactions
.transactionValidatorFactoryBuilder(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@ public static RequestsValidatorCoordinator pragueRequestsValidator(
}

public static RequestProcessorCoordinator pragueRequestsProcessors(
final Address depositContractAddress) {
final Address withdrawalRequestPredeployAddress, final Address depositContractAddress) {
return new RequestProcessorCoordinator.Builder()
.addProcessor(RequestType.WITHDRAWAL, new WithdrawalRequestProcessor())
.addProcessor(
RequestType.WITHDRAWAL,
new WithdrawalRequestProcessor(withdrawalRequestPredeployAddress))
.addProcessor(RequestType.CONSOLIDATION, new ConsolidationRequestProcessor())
.addProcessor(RequestType.DEPOSIT, new DepositRequestProcessor(depositContractAddress))
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
public class WithdrawalRequestProcessor
extends AbstractSystemCallRequestProcessor<WithdrawalRequest> {

public static final Address WITHDRAWAL_REQUEST_PREDEPLOY_ADDRESS =
public static final Address DEFAULT_WITHDRAWAL_REQUEST_PREDEPLOY_ADDRESS =
Address.fromHexString("0x00A3ca265EBcb825B45F985A16CEFB49958cE017");

private static final int ADDRESS_BYTES = 20;
Expand All @@ -35,14 +35,20 @@ public class WithdrawalRequestProcessor
private static final int WITHDRAWAL_REQUEST_BYTES_SIZE =
ADDRESS_BYTES + PUBLIC_KEY_BYTES + AMOUNT_BYTES;

private final Address withdrawakRequestPredeployAddress;
Matilda-Clerke marked this conversation as resolved.
Show resolved Hide resolved

public WithdrawalRequestProcessor(final Address withdrawalRequestPredeployAddress) {
this.withdrawakRequestPredeployAddress = withdrawalRequestPredeployAddress;
}

/**
* Gets the call address for withdrawal requests.
*
* @return The call address.
*/
@Override
protected Address getCallAddress() {
return WITHDRAWAL_REQUEST_PREDEPLOY_ADDRESS;
return withdrawakRequestPredeployAddress;
}

/**
Expand Down
Loading