[MINOR] Rename deposit to depositRequest (#7145)

Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
pull/7152/head
Gabriel-Trintinalia 6 months ago committed by GitHub
parent fb25f180b0
commit 2df721619a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 12
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/AbstractEngineNewPayload.java
  2. 2
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV4.java
  3. 28
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/DepositRequestParameter.java
  4. 12
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/EnginePayloadParameter.java
  5. 25
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/EngineGetPayloadResultV4.java
  6. 6
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/AbstractEngineGetPayloadTest.java
  7. 22
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/AbstractEngineNewPayloadTest.java
  8. 4
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadV4Test.java
  9. 4
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV3Test.java
  10. 52
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV4Test.java
  11. 8
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/DepositParameterTestFixture.java
  12. 14
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/DepositRequestRequestParameterTest.java
  13. 40
      ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/AbstractBlockCreatorTest.java
  14. 2
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/BlockBody.java
  15. 7
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/DepositRequest.java
  16. 14
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/DepositRequestDecoder.java
  17. 16
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/DepositRequestEncoder.java
  18. 2
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/RequestDecoder.java
  19. 2
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/RequestEncoder.java
  20. 13
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/DepositRequestProcessor.java
  21. 34
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/DepositRequestValidator.java
  22. 2
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/MainnetRequestsValidator.java
  23. 15
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/RequestUtil.java
  24. 22
      ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/encoding/DepositRequestRequestDecoderTest.java
  25. 14
      ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/encoding/DepositRequestRequestEncoderTest.java
  26. 65
      ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/DepositRequestValidatorTest.java
  27. 8
      ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/MainnetBlockBodyValidatorTest.java
  28. 6
      ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/manager/task/GetBodiesFromPeerTaskTest.java
  29. 4
      ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/T8nExecutor.java
  30. 2
      plugin-api/build.gradle
  31. 2
      plugin-api/src/main/java/org/hyperledger/besu/plugin/data/DepositRequest.java

@ -35,7 +35,7 @@ import org.hyperledger.besu.ethereum.BlockProcessingResult;
import org.hyperledger.besu.ethereum.ProtocolContext; import org.hyperledger.besu.ethereum.ProtocolContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.ExecutionEngineJsonRpcMethod; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.ExecutionEngineJsonRpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.DepositParameter; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.DepositRequestParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.EnginePayloadParameter; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.EnginePayloadParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.WithdrawalParameter; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.WithdrawalParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.WithdrawalRequestParameter; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.WithdrawalRequestParameter;
@ -161,12 +161,12 @@ public abstract class AbstractEngineNewPayload extends ExecutionEngineJsonRpcMet
reqId, new JsonRpcError(INVALID_PARAMS, "Invalid withdrawals")); reqId, new JsonRpcError(INVALID_PARAMS, "Invalid withdrawals"));
} }
final Optional<List<Request>> maybeDeposits = final Optional<List<Request>> maybeDepositRequests =
Optional.ofNullable(blockParam.getDeposits()) Optional.ofNullable(blockParam.getDepositRequests())
.map(ds -> ds.stream().map(DepositParameter::toDeposit).collect(toList())); .map(ds -> ds.stream().map(DepositRequestParameter::toDeposit).collect(toList()));
if (!getDepositRequestValidator( if (!getDepositRequestValidator(
protocolSchedule.get(), blockParam.getTimestamp(), blockParam.getBlockNumber()) protocolSchedule.get(), blockParam.getTimestamp(), blockParam.getBlockNumber())
.validateParameter(maybeDeposits)) { .validateParameter(maybeDepositRequests)) {
return new JsonRpcErrorResponse( return new JsonRpcErrorResponse(
reqId, new JsonRpcError(INVALID_PARAMS, "Invalid deposit request")); reqId, new JsonRpcError(INVALID_PARAMS, "Invalid deposit request"));
} }
@ -186,7 +186,7 @@ public abstract class AbstractEngineNewPayload extends ExecutionEngineJsonRpcMet
} }
Optional<List<Request>> maybeRequests = Optional<List<Request>> maybeRequests =
RequestUtil.combine(maybeDeposits, maybeWithdrawalRequests); RequestUtil.combine(maybeDepositRequests, maybeWithdrawalRequests);
if (mergeContext.get().isSyncing()) { if (mergeContext.get().isSyncing()) {
LOG.debug("We are syncing"); LOG.debug("We are syncing");

@ -63,7 +63,7 @@ public class EngineNewPayloadV4 extends AbstractEngineNewPayload {
} else if (maybeBeaconBlockRootParam.isEmpty()) { } else if (maybeBeaconBlockRootParam.isEmpty()) {
return ValidationResult.invalid( return ValidationResult.invalid(
RpcErrorType.INVALID_PARAMS, "Missing parent beacon block root field"); RpcErrorType.INVALID_PARAMS, "Missing parent beacon block root field");
} else if (payloadParameter.getDeposits() == null) { } else if (payloadParameter.getDepositRequests() == null) {
return ValidationResult.invalid(RpcErrorType.INVALID_PARAMS, "Missing deposit field"); return ValidationResult.invalid(RpcErrorType.INVALID_PARAMS, "Missing deposit field");
} else { } else {
return ValidationResult.valid(); return ValidationResult.valid();

@ -17,7 +17,7 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters;
import org.hyperledger.besu.datatypes.BLSPublicKey; import org.hyperledger.besu.datatypes.BLSPublicKey;
import org.hyperledger.besu.datatypes.BLSSignature; import org.hyperledger.besu.datatypes.BLSSignature;
import org.hyperledger.besu.datatypes.GWei; import org.hyperledger.besu.datatypes.GWei;
import org.hyperledger.besu.ethereum.core.Deposit; import org.hyperledger.besu.ethereum.core.DepositRequest;
import java.util.Objects; import java.util.Objects;
@ -28,7 +28,7 @@ import io.vertx.core.json.JsonObject;
import org.apache.tuweni.bytes.Bytes32; import org.apache.tuweni.bytes.Bytes32;
import org.apache.tuweni.units.bigints.UInt64; import org.apache.tuweni.units.bigints.UInt64;
public class DepositParameter { public class DepositRequestParameter {
private final String pubkey; private final String pubkey;
@ -39,7 +39,7 @@ public class DepositParameter {
private final String index; private final String index;
@JsonCreator @JsonCreator
public DepositParameter( public DepositRequestParameter(
@JsonProperty("pubkey") final String pubkey, @JsonProperty("pubkey") final String pubkey,
@JsonProperty("withdrawalCredentials") final String withdrawalCredentials, @JsonProperty("withdrawalCredentials") final String withdrawalCredentials,
@JsonProperty("amount") final String amount, @JsonProperty("amount") final String amount,
@ -52,17 +52,17 @@ public class DepositParameter {
this.index = index; this.index = index;
} }
public static DepositParameter fromDeposit(final Deposit deposit) { public static DepositRequestParameter fromDeposit(final DepositRequest depositRequest) {
return new DepositParameter( return new DepositRequestParameter(
deposit.getPubkey().toString(), depositRequest.getPubkey().toString(),
deposit.getWithdrawalCredentials().toString(), depositRequest.getWithdrawalCredentials().toString(),
deposit.getAmount().toShortHexString(), depositRequest.getAmount().toShortHexString(),
deposit.getSignature().toString(), depositRequest.getSignature().toString(),
deposit.getIndex().toBytes().toQuantityHexString()); depositRequest.getIndex().toBytes().toQuantityHexString());
} }
public Deposit toDeposit() { public DepositRequest toDeposit() {
return new Deposit( return new DepositRequest(
BLSPublicKey.fromHexString(pubkey), BLSPublicKey.fromHexString(pubkey),
Bytes32.fromHexString(withdrawalCredentials), Bytes32.fromHexString(withdrawalCredentials),
GWei.fromHexString(amount), GWei.fromHexString(amount),
@ -108,7 +108,7 @@ public class DepositParameter {
public boolean equals(final Object o) { public boolean equals(final Object o) {
if (this == o) return true; if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false; if (o == null || getClass() != o.getClass()) return false;
final DepositParameter that = (DepositParameter) o; final DepositRequestParameter that = (DepositRequestParameter) o;
return Objects.equals(pubkey, that.pubkey) return Objects.equals(pubkey, that.pubkey)
&& Objects.equals(withdrawalCredentials, that.withdrawalCredentials) && Objects.equals(withdrawalCredentials, that.withdrawalCredentials)
&& Objects.equals(amount, that.amount) && Objects.equals(amount, that.amount)
@ -123,7 +123,7 @@ public class DepositParameter {
@Override @Override
public String toString() { public String toString() {
return "DepositParameter{" return "DepositRequestParameter{"
+ "pubKey='" + "pubKey='"
+ pubkey + pubkey
+ '\'' + '\''

@ -43,7 +43,7 @@ public class EnginePayloadParameter {
private final List<WithdrawalParameter> withdrawals; private final List<WithdrawalParameter> withdrawals;
private final Long blobGasUsed; private final Long blobGasUsed;
private final String excessBlobGas; private final String excessBlobGas;
private final List<DepositParameter> deposits; private final List<DepositRequestParameter> depositRequests;
private final List<WithdrawalRequestParameter> withdrawalRequests; private final List<WithdrawalRequestParameter> withdrawalRequests;
/** /**
@ -66,7 +66,7 @@ public class EnginePayloadParameter {
* @param withdrawals Array of Withdrawal * @param withdrawals Array of Withdrawal
* @param blobGasUsed QUANTITY, 64 Bits * @param blobGasUsed QUANTITY, 64 Bits
* @param excessBlobGas QUANTITY, 64 Bits * @param excessBlobGas QUANTITY, 64 Bits
* @param deposits List of deposit parameters. * @param depositRequests List of deposit parameters.
* @param withdrawalRequestParameters List of withdrawal requests parameters. * @param withdrawalRequestParameters List of withdrawal requests parameters.
*/ */
@JsonCreator @JsonCreator
@ -88,7 +88,7 @@ public class EnginePayloadParameter {
@JsonProperty("withdrawals") final List<WithdrawalParameter> withdrawals, @JsonProperty("withdrawals") final List<WithdrawalParameter> withdrawals,
@JsonProperty("blobGasUsed") final UnsignedLongParameter blobGasUsed, @JsonProperty("blobGasUsed") final UnsignedLongParameter blobGasUsed,
@JsonProperty("excessBlobGas") final String excessBlobGas, @JsonProperty("excessBlobGas") final String excessBlobGas,
@JsonProperty("depositRequests") final List<DepositParameter> deposits, @JsonProperty("depositRequests") final List<DepositRequestParameter> depositRequests,
@JsonProperty("withdrawalRequests") @JsonProperty("withdrawalRequests")
final List<WithdrawalRequestParameter> withdrawalRequestParameters) { final List<WithdrawalRequestParameter> withdrawalRequestParameters) {
this.blockHash = blockHash; this.blockHash = blockHash;
@ -108,7 +108,7 @@ public class EnginePayloadParameter {
this.withdrawals = withdrawals; this.withdrawals = withdrawals;
this.blobGasUsed = blobGasUsed == null ? null : blobGasUsed.getValue(); this.blobGasUsed = blobGasUsed == null ? null : blobGasUsed.getValue();
this.excessBlobGas = excessBlobGas; this.excessBlobGas = excessBlobGas;
this.deposits = deposits; this.depositRequests = depositRequests;
this.withdrawalRequests = withdrawalRequestParameters; this.withdrawalRequests = withdrawalRequestParameters;
} }
@ -180,8 +180,8 @@ public class EnginePayloadParameter {
return excessBlobGas; return excessBlobGas;
} }
public List<DepositParameter> getDeposits() { public List<DepositRequestParameter> getDepositRequests() {
return deposits; return depositRequests;
} }
public List<WithdrawalRequestParameter> getWithdrawalRequests() { public List<WithdrawalRequestParameter> getWithdrawalRequests() {

@ -14,11 +14,11 @@
*/ */
package org.hyperledger.besu.ethereum.api.jsonrpc.internal.results; package org.hyperledger.besu.ethereum.api.jsonrpc.internal.results;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.DepositParameter; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.DepositRequestParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.WithdrawalParameter; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.WithdrawalParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.WithdrawalRequestParameter; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.WithdrawalRequestParameter;
import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.Deposit; import org.hyperledger.besu.ethereum.core.DepositRequest;
import org.hyperledger.besu.ethereum.core.Withdrawal; import org.hyperledger.besu.ethereum.core.Withdrawal;
import org.hyperledger.besu.ethereum.core.WithdrawalRequest; import org.hyperledger.besu.ethereum.core.WithdrawalRequest;
@ -42,12 +42,12 @@ public class EngineGetPayloadResultV4 {
final BlockHeader header, final BlockHeader header,
final List<String> transactions, final List<String> transactions,
final Optional<List<Withdrawal>> withdrawals, final Optional<List<Withdrawal>> withdrawals,
final Optional<List<Deposit>> deposits, final Optional<List<DepositRequest>> depositRequests,
final Optional<List<WithdrawalRequest>> withdrawalRequests, final Optional<List<WithdrawalRequest>> withdrawalRequests,
final String blockValue, final String blockValue,
final BlobsBundleV1 blobsBundle) { final BlobsBundleV1 blobsBundle) {
this.executionPayload = this.executionPayload =
new PayloadResult(header, transactions, withdrawals, deposits, withdrawalRequests); new PayloadResult(header, transactions, withdrawals, depositRequests, withdrawalRequests);
this.blockValue = blockValue; this.blockValue = blockValue;
this.blobsBundle = blobsBundle; this.blobsBundle = blobsBundle;
this.shouldOverrideBuilder = false; this.shouldOverrideBuilder = false;
@ -94,14 +94,14 @@ public class EngineGetPayloadResultV4 {
protected final List<String> transactions; protected final List<String> transactions;
private final List<WithdrawalParameter> withdrawals; private final List<WithdrawalParameter> withdrawals;
private final List<DepositParameter> deposits; private final List<DepositRequestParameter> depositRequests;
private final List<WithdrawalRequestParameter> withdrawalRequests; private final List<WithdrawalRequestParameter> withdrawalRequests;
public PayloadResult( public PayloadResult(
final BlockHeader header, final BlockHeader header,
final List<String> transactions, final List<String> transactions,
final Optional<List<Withdrawal>> withdrawals, final Optional<List<Withdrawal>> withdrawals,
final Optional<List<Deposit>> deposits, final Optional<List<DepositRequest>> depositRequests,
final Optional<List<WithdrawalRequest>> withdrawalRequests) { final Optional<List<WithdrawalRequest>> withdrawalRequests) {
this.blockNumber = Quantity.create(header.getNumber()); this.blockNumber = Quantity.create(header.getNumber());
this.blockHash = header.getHash().toString(); this.blockHash = header.getHash().toString();
@ -125,10 +125,13 @@ public class EngineGetPayloadResultV4 {
.map(WithdrawalParameter::fromWithdrawal) .map(WithdrawalParameter::fromWithdrawal)
.collect(Collectors.toList())) .collect(Collectors.toList()))
.orElse(null); .orElse(null);
this.deposits = this.depositRequests =
deposits depositRequests
.map( .map(
ds -> ds.stream().map(DepositParameter::fromDeposit).collect(Collectors.toList())) ds ->
ds.stream()
.map(DepositRequestParameter::fromDeposit)
.collect(Collectors.toList()))
.orElse(null); .orElse(null);
this.withdrawalRequests = this.withdrawalRequests =
withdrawalRequests withdrawalRequests
@ -216,8 +219,8 @@ public class EngineGetPayloadResultV4 {
} }
@JsonGetter(value = "depositRequests") @JsonGetter(value = "depositRequests")
public List<DepositParameter> getDeposits() { public List<DepositRequestParameter> getDepositRequests() {
return deposits; return depositRequests;
} }
@JsonGetter(value = "withdrawalRequests") @JsonGetter(value = "withdrawalRequests")

@ -105,7 +105,7 @@ public abstract class AbstractEngineGetPayloadTest extends AbstractScheduledApiT
Collections.emptyList(), Collections.emptyList(),
Optional.of(Collections.emptyList()), Optional.of(Collections.emptyList()),
Optional.empty())); Optional.empty()));
private static final Block mockBlockWithDeposits = private static final Block mockBlockWithDepositRequests =
new Block( new Block(
mockHeader, mockHeader,
new BlockBody( new BlockBody(
@ -116,8 +116,8 @@ public abstract class AbstractEngineGetPayloadTest extends AbstractScheduledApiT
protected static final BlockWithReceipts mockBlockWithReceiptsAndWithdrawals = protected static final BlockWithReceipts mockBlockWithReceiptsAndWithdrawals =
new BlockWithReceipts(mockBlockWithWithdrawals, Collections.emptyList()); new BlockWithReceipts(mockBlockWithWithdrawals, Collections.emptyList());
protected static final BlockWithReceipts mockBlockWithReceiptsAndDeposits = protected static final BlockWithReceipts mockBlockWithReceiptsAndDepositRequests =
new BlockWithReceipts(mockBlockWithDeposits, Collections.emptyList()); new BlockWithReceipts(mockBlockWithDepositRequests, Collections.emptyList());
@Mock protected ProtocolContext protocolContext; @Mock protected ProtocolContext protocolContext;

@ -38,7 +38,7 @@ import org.hyperledger.besu.ethereum.ProtocolContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequest; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequest;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.ExecutionEngineJsonRpcMethod; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.ExecutionEngineJsonRpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.DepositParameter; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.DepositRequestParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.EnginePayloadParameter; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.EnginePayloadParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.UnsignedLongParameter; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.UnsignedLongParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.WithdrawalParameter; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.WithdrawalParameter;
@ -54,7 +54,7 @@ import org.hyperledger.besu.ethereum.core.Block;
import org.hyperledger.besu.ethereum.core.BlockBody; import org.hyperledger.besu.ethereum.core.BlockBody;
import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture; import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture;
import org.hyperledger.besu.ethereum.core.Deposit; import org.hyperledger.besu.ethereum.core.DepositRequest;
import org.hyperledger.besu.ethereum.core.Request; import org.hyperledger.besu.ethereum.core.Request;
import org.hyperledger.besu.ethereum.core.Withdrawal; import org.hyperledger.besu.ethereum.core.Withdrawal;
import org.hyperledger.besu.ethereum.core.WithdrawalRequest; import org.hyperledger.besu.ethereum.core.WithdrawalRequest;
@ -410,7 +410,7 @@ public abstract class AbstractEngineNewPayloadTest extends AbstractScheduledApiT
final BlockHeader header, final BlockHeader header,
final List<String> txs, final List<String> txs,
final List<WithdrawalParameter> withdrawals, final List<WithdrawalParameter> withdrawals,
final List<DepositParameter> deposits, final List<DepositRequestParameter> depositRequests,
final List<WithdrawalRequestParameter> withdrawalRequests) { final List<WithdrawalRequestParameter> withdrawalRequests) {
return new EnginePayloadParameter( return new EnginePayloadParameter(
header.getHash(), header.getHash(),
@ -430,18 +430,18 @@ public abstract class AbstractEngineNewPayloadTest extends AbstractScheduledApiT
withdrawals, withdrawals,
header.getBlobGasUsed().map(UnsignedLongParameter::new).orElse(null), header.getBlobGasUsed().map(UnsignedLongParameter::new).orElse(null),
header.getExcessBlobGas().map(BlobGas::toHexString).orElse(null), header.getExcessBlobGas().map(BlobGas::toHexString).orElse(null),
deposits, depositRequests,
withdrawalRequests); withdrawalRequests);
} }
protected BlockHeader setupValidPayload( protected BlockHeader setupValidPayload(
final BlockProcessingResult value, final BlockProcessingResult value,
final Optional<List<Withdrawal>> maybeWithdrawals, final Optional<List<Withdrawal>> maybeWithdrawals,
final Optional<List<Deposit>> maybeDeposits, final Optional<List<DepositRequest>> maybeDepositRequests,
final Optional<List<WithdrawalRequest>> maybeWithdrawalRequests) { final Optional<List<WithdrawalRequest>> maybeWithdrawalRequests) {
BlockHeader mockHeader = BlockHeader mockHeader =
createBlockHeader(maybeWithdrawals, maybeDeposits, maybeWithdrawalRequests); createBlockHeader(maybeWithdrawals, maybeDepositRequests, maybeWithdrawalRequests);
when(blockchain.getBlockByHash(mockHeader.getHash())).thenReturn(Optional.empty()); when(blockchain.getBlockByHash(mockHeader.getHash())).thenReturn(Optional.empty());
// when(blockchain.getBlockHeader(mockHeader.getParentHash())) // when(blockchain.getBlockHeader(mockHeader.getParentHash()))
// .thenReturn(Optional.of(mock(BlockHeader.class))); // .thenReturn(Optional.of(mock(BlockHeader.class)));
@ -474,21 +474,21 @@ public abstract class AbstractEngineNewPayloadTest extends AbstractScheduledApiT
protected BlockHeader createBlockHeader( protected BlockHeader createBlockHeader(
final Optional<List<Withdrawal>> maybeWithdrawals, final Optional<List<Withdrawal>> maybeWithdrawals,
final Optional<List<Deposit>> maybeDeposits, final Optional<List<DepositRequest>> maybeDepositRequests,
final Optional<List<WithdrawalRequest>> maybeWithdrawalRequests) { final Optional<List<WithdrawalRequest>> maybeWithdrawalRequests) {
return createBlockHeaderFixture(maybeWithdrawals, maybeDeposits, maybeWithdrawalRequests) return createBlockHeaderFixture(maybeWithdrawals, maybeDepositRequests, maybeWithdrawalRequests)
.buildHeader(); .buildHeader();
} }
protected BlockHeaderTestFixture createBlockHeaderFixture( protected BlockHeaderTestFixture createBlockHeaderFixture(
final Optional<List<Withdrawal>> maybeWithdrawals, final Optional<List<Withdrawal>> maybeWithdrawals,
final Optional<List<Deposit>> maybeDeposits, final Optional<List<DepositRequest>> maybeDepositRequests,
final Optional<List<WithdrawalRequest>> maybeWithdrawalRequests) { final Optional<List<WithdrawalRequest>> maybeWithdrawalRequests) {
Optional<List<Request>> maybeRequests; Optional<List<Request>> maybeRequests;
if (maybeDeposits.isPresent() || maybeWithdrawalRequests.isPresent()) { if (maybeDepositRequests.isPresent() || maybeWithdrawalRequests.isPresent()) {
List<Request> requests = new ArrayList<>(); List<Request> requests = new ArrayList<>();
maybeDeposits.ifPresent(requests::addAll); maybeDepositRequests.ifPresent(requests::addAll);
maybeWithdrawalRequests.ifPresent(requests::addAll); maybeWithdrawalRequests.ifPresent(requests::addAll);
maybeRequests = Optional.of(requests); maybeRequests = Optional.of(requests);
} else { } else {

@ -71,7 +71,7 @@ public class EngineGetPayloadV4Test extends AbstractEngineGetPayloadTest {
super.before(); super.before();
lenient() lenient()
.when(mergeContext.retrieveBlockById(mockPid)) .when(mergeContext.retrieveBlockById(mockPid))
.thenReturn(Optional.of(mockBlockWithReceiptsAndDeposits)); .thenReturn(Optional.of(mockBlockWithReceiptsAndDepositRequests));
when(protocolContext.safeConsensusContext(Mockito.any())).thenReturn(Optional.of(mergeContext)); when(protocolContext.safeConsensusContext(Mockito.any())).thenReturn(Optional.of(mergeContext));
this.method = this.method =
new EngineGetPayloadV4( new EngineGetPayloadV4(
@ -146,7 +146,7 @@ public class EngineGetPayloadV4Test extends AbstractEngineGetPayloadTest {
assertThat(r.getResult()).isInstanceOf(EngineGetPayloadResultV4.class); assertThat(r.getResult()).isInstanceOf(EngineGetPayloadResultV4.class);
final EngineGetPayloadResultV4 res = (EngineGetPayloadResultV4) r.getResult(); final EngineGetPayloadResultV4 res = (EngineGetPayloadResultV4) r.getResult();
assertThat(res.getExecutionPayload().getWithdrawals()).isNotNull(); assertThat(res.getExecutionPayload().getWithdrawals()).isNotNull();
assertThat(res.getExecutionPayload().getDeposits()).isNotNull(); assertThat(res.getExecutionPayload().getDepositRequests()).isNotNull();
assertThat(res.getExecutionPayload().getWithdrawalRequests()).isNotNull(); assertThat(res.getExecutionPayload().getWithdrawalRequests()).isNotNull();
assertThat(res.getExecutionPayload().getHash()) assertThat(res.getExecutionPayload().getHash())
.isEqualTo(header.getHash().toString()); .isEqualTo(header.getHash().toString());

@ -44,7 +44,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.EnginePayloadS
import org.hyperledger.besu.ethereum.core.BlobTestFixture; import org.hyperledger.besu.ethereum.core.BlobTestFixture;
import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture; import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture;
import org.hyperledger.besu.ethereum.core.Deposit; import org.hyperledger.besu.ethereum.core.DepositRequest;
import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.core.TransactionTestFixture; import org.hyperledger.besu.ethereum.core.TransactionTestFixture;
import org.hyperledger.besu.ethereum.core.Withdrawal; import org.hyperledger.besu.ethereum.core.Withdrawal;
@ -150,7 +150,7 @@ public class EngineNewPayloadV3Test extends EngineNewPayloadV2Test {
@Override @Override
protected BlockHeader createBlockHeader( protected BlockHeader createBlockHeader(
final Optional<List<Withdrawal>> maybeWithdrawals, final Optional<List<Withdrawal>> maybeWithdrawals,
final Optional<List<Deposit>> maybeDeposits, final Optional<List<DepositRequest>> maybeDepositRequests,
final Optional<List<WithdrawalRequest>> maybeWithdrawalRequests) { final Optional<List<WithdrawalRequest>> maybeWithdrawalRequests) {
BlockHeader parentBlockHeader = BlockHeader parentBlockHeader =
new BlockHeaderTestFixture() new BlockHeaderTestFixture()

@ -33,19 +33,19 @@ import org.hyperledger.besu.ethereum.BlockProcessingOutputs;
import org.hyperledger.besu.ethereum.BlockProcessingResult; import org.hyperledger.besu.ethereum.BlockProcessingResult;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequest; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequest;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.DepositParameter; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.DepositRequestParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.EnginePayloadParameter; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.EnginePayloadParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.WithdrawalRequestParameter; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.WithdrawalRequestParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcError;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture; import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture;
import org.hyperledger.besu.ethereum.core.Deposit; import org.hyperledger.besu.ethereum.core.DepositRequest;
import org.hyperledger.besu.ethereum.core.Request; import org.hyperledger.besu.ethereum.core.Request;
import org.hyperledger.besu.ethereum.core.Withdrawal; import org.hyperledger.besu.ethereum.core.Withdrawal;
import org.hyperledger.besu.ethereum.core.WithdrawalRequest; import org.hyperledger.besu.ethereum.core.WithdrawalRequest;
import org.hyperledger.besu.ethereum.mainnet.BodyValidation; import org.hyperledger.besu.ethereum.mainnet.BodyValidation;
import org.hyperledger.besu.ethereum.mainnet.requests.DepositsValidator; import org.hyperledger.besu.ethereum.mainnet.requests.DepositRequestValidator;
import org.hyperledger.besu.ethereum.mainnet.requests.RequestsValidatorCoordinator; import org.hyperledger.besu.ethereum.mainnet.requests.RequestsValidatorCoordinator;
import org.hyperledger.besu.ethereum.mainnet.requests.WithdrawalRequestValidator; import org.hyperledger.besu.ethereum.mainnet.requests.WithdrawalRequestValidator;
import org.hyperledger.besu.evm.gascalculator.PragueGasCalculator; import org.hyperledger.besu.evm.gascalculator.PragueGasCalculator;
@ -92,8 +92,8 @@ public class EngineNewPayloadV4Test extends EngineNewPayloadV3Test {
} }
@Test @Test
public void shouldReturnValidIfDepositsIsNull_WhenDepositsProhibited() { public void shouldReturnValidIfDepositRequestsIsNull_WhenDepositRequestsProhibited() {
final List<DepositParameter> deposits = null; final List<DepositRequestParameter> depositRequests = null;
mockProhibitedRequestsValidator(); mockProhibitedRequestsValidator();
BlockHeader mockHeader = BlockHeader mockHeader =
@ -108,22 +108,23 @@ public class EngineNewPayloadV4Test extends EngineNewPayloadV3Test {
when(mergeCoordinator.getLatestValidAncestor(mockHeader)) when(mergeCoordinator.getLatestValidAncestor(mockHeader))
.thenReturn(Optional.of(mockHeader.getHash())); .thenReturn(Optional.of(mockHeader.getHash()));
var resp = resp(mockEnginePayload(mockHeader, Collections.emptyList(), null, deposits, null)); var resp =
resp(mockEnginePayload(mockHeader, Collections.emptyList(), null, depositRequests, null));
assertValidResponse(mockHeader, resp); assertValidResponse(mockHeader, resp);
} }
@Test @Test
public void shouldReturnInvalidIfDepositsIsNull_WhenDepositsAllowed() { public void shouldReturnInvalidIfDepositRequestsIsNull_WhenDepositRequestsAllowed() {
final List<DepositParameter> deposits = null; final List<DepositRequestParameter> depositRequests = null;
mockAllowedDepositsRequestValidator(); mockAllowedDepositRequestsRequestValidator();
var resp = var resp =
resp( resp(
mockEnginePayload( mockEnginePayload(
createBlockHeader(Optional.empty(), Optional.empty(), Optional.empty()), createBlockHeader(Optional.empty(), Optional.empty(), Optional.empty()),
Collections.emptyList(), Collections.emptyList(),
null, null,
deposits, depositRequests,
null)); null));
assertThat(fromErrorResp(resp).getCode()).isEqualTo(INVALID_PARAMS.getCode()); assertThat(fromErrorResp(resp).getCode()).isEqualTo(INVALID_PARAMS.getCode());
@ -131,15 +132,16 @@ public class EngineNewPayloadV4Test extends EngineNewPayloadV3Test {
} }
@Test @Test
public void shouldReturnValidIfDepositsIsNotNull_WhenDepositsAllowed() { public void shouldReturnValidIfDepositRequestsIsNotNull_WhenDepositRequestsAllowed() {
final List<DepositParameter> depositsParam = List.of(DEPOSIT_PARAM_1); final List<DepositRequestParameter> depositRequestsParam = List.of(DEPOSIT_PARAM_1);
final List<Request> deposits = List.of(DEPOSIT_PARAM_1.toDeposit()); final List<Request> depositRequests = List.of(DEPOSIT_PARAM_1.toDeposit());
mockAllowedDepositsRequestValidator(); mockAllowedDepositRequestsRequestValidator();
BlockHeader mockHeader = BlockHeader mockHeader =
setupValidPayload( setupValidPayload(
new BlockProcessingResult( new BlockProcessingResult(
Optional.of(new BlockProcessingOutputs(null, List.of(), Optional.of(deposits)))), Optional.of(
new BlockProcessingOutputs(null, List.of(), Optional.of(depositRequests)))),
Optional.empty(), Optional.empty(),
Optional.of(List.of(DEPOSIT_PARAM_1.toDeposit())), Optional.of(List.of(DEPOSIT_PARAM_1.toDeposit())),
Optional.empty()); Optional.empty());
@ -148,14 +150,16 @@ public class EngineNewPayloadV4Test extends EngineNewPayloadV3Test {
when(mergeCoordinator.getLatestValidAncestor(mockHeader)) when(mergeCoordinator.getLatestValidAncestor(mockHeader))
.thenReturn(Optional.of(mockHeader.getHash())); .thenReturn(Optional.of(mockHeader.getHash()));
var resp = var resp =
resp(mockEnginePayload(mockHeader, Collections.emptyList(), null, depositsParam, null)); resp(
mockEnginePayload(
mockHeader, Collections.emptyList(), null, depositRequestsParam, null));
assertValidResponse(mockHeader, resp); assertValidResponse(mockHeader, resp);
} }
@Test @Test
public void shouldReturnInvalidIfDepositsIsNotNull_WhenDepositsProhibited() { public void shouldReturnInvalidIfDepositRequestsIsNotNull_WhenDepositRequestsProhibited() {
final List<DepositParameter> deposits = List.of(); final List<DepositRequestParameter> depositRequests = List.of();
lenient() lenient()
.when(protocolSpec.getRequestsValidatorCoordinator()) .when(protocolSpec.getRequestsValidatorCoordinator())
.thenReturn(RequestsValidatorCoordinator.empty()); .thenReturn(RequestsValidatorCoordinator.empty());
@ -167,7 +171,7 @@ public class EngineNewPayloadV4Test extends EngineNewPayloadV3Test {
Optional.empty(), Optional.of(Collections.emptyList()), Optional.empty()), Optional.empty(), Optional.of(Collections.emptyList()), Optional.empty()),
Collections.emptyList(), Collections.emptyList(),
null, null,
deposits, depositRequests,
null)); null));
final JsonRpcError jsonRpcError = fromErrorResp(resp); final JsonRpcError jsonRpcError = fromErrorResp(resp);
@ -264,7 +268,7 @@ public class EngineNewPayloadV4Test extends EngineNewPayloadV3Test {
@Override @Override
protected BlockHeader createBlockHeader( protected BlockHeader createBlockHeader(
final Optional<List<Withdrawal>> maybeWithdrawals, final Optional<List<Withdrawal>> maybeWithdrawals,
final Optional<List<Deposit>> maybeDeposits, final Optional<List<DepositRequest>> maybeDepositRequests,
final Optional<List<WithdrawalRequest>> maybeWithdrawalRequests) { final Optional<List<WithdrawalRequest>> maybeWithdrawalRequests) {
BlockHeader parentBlockHeader = BlockHeader parentBlockHeader =
new BlockHeaderTestFixture() new BlockHeaderTestFixture()
@ -275,9 +279,9 @@ public class EngineNewPayloadV4Test extends EngineNewPayloadV3Test {
.buildHeader(); .buildHeader();
Optional<List<Request>> maybeRequests; Optional<List<Request>> maybeRequests;
if (maybeDeposits.isPresent() || maybeWithdrawalRequests.isPresent()) { if (maybeDepositRequests.isPresent() || maybeWithdrawalRequests.isPresent()) {
List<Request> requests = new ArrayList<>(); List<Request> requests = new ArrayList<>();
maybeDeposits.ifPresent(requests::addAll); maybeDepositRequests.ifPresent(requests::addAll);
maybeWithdrawalRequests.ifPresent(requests::addAll); maybeWithdrawalRequests.ifPresent(requests::addAll);
maybeRequests = Optional.of(requests); maybeRequests = Optional.of(requests);
} else { } else {
@ -315,10 +319,10 @@ public class EngineNewPayloadV4Test extends EngineNewPayloadV3Test {
when(protocolSpec.getRequestsValidatorCoordinator()).thenReturn(validator); when(protocolSpec.getRequestsValidatorCoordinator()).thenReturn(validator);
} }
private void mockAllowedDepositsRequestValidator() { private void mockAllowedDepositRequestsRequestValidator() {
var validator = var validator =
new RequestsValidatorCoordinator.Builder() new RequestsValidatorCoordinator.Builder()
.addValidator(RequestType.DEPOSIT, new DepositsValidator(depositContractAddress)) .addValidator(RequestType.DEPOSIT, new DepositRequestValidator(depositContractAddress))
.build(); .build();
when(protocolSpec.getRequestsValidatorCoordinator()).thenReturn(validator); when(protocolSpec.getRequestsValidatorCoordinator()).thenReturn(validator);
} }

@ -16,14 +16,14 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters;
public class DepositParameterTestFixture { public class DepositParameterTestFixture {
public static final DepositParameter DEPOSIT_PARAM_1 = public static final DepositRequestParameter DEPOSIT_PARAM_1 =
createDeposit( createDeposit(
"0xb10a4a15bf67b328c9b101d09e5c6ee6672978fdad9ef0d9e2ceffaee99223555d8601f0cb3bcc4ce1af9864779a416e", "0xb10a4a15bf67b328c9b101d09e5c6ee6672978fdad9ef0d9e2ceffaee99223555d8601f0cb3bcc4ce1af9864779a416e",
"0x0017a7fcf06faf493d30bbe2632ea7c2383cd86825e12797165de7aa35589483", "0x0017a7fcf06faf493d30bbe2632ea7c2383cd86825e12797165de7aa35589483",
"0x773594000", "0x773594000",
"0xa889db8300194050a2636c92a95bc7160515867614b7971a9500cdb62f9c0890217d2901c3241f86fac029428fc106930606154bd9e406d7588934a5f15b837180b17194d6e44bd6de23e43b163dfe12e369dcc75a3852cd997963f158217eb5", "0xa889db8300194050a2636c92a95bc7160515867614b7971a9500cdb62f9c0890217d2901c3241f86fac029428fc106930606154bd9e406d7588934a5f15b837180b17194d6e44bd6de23e43b163dfe12e369dcc75a3852cd997963f158217eb5",
"0x1"); "0x1");
static final DepositParameter DEPOSIT_PARAM_2 = static final DepositRequestParameter DEPOSIT_PARAM_2 =
createDeposit( createDeposit(
"0x8706d19a62f28a6a6549f96c5adaebac9124a61d44868ec94f6d2d707c6a2f82c9162071231dfeb40e24bfde4ffdf243", "0x8706d19a62f28a6a6549f96c5adaebac9124a61d44868ec94f6d2d707c6a2f82c9162071231dfeb40e24bfde4ffdf243",
"0x006a8dc800c6d8dd6977ef53264e2d030350f0145a91bcd167b4f1c3ea21b271", "0x006a8dc800c6d8dd6977ef53264e2d030350f0145a91bcd167b4f1c3ea21b271",
@ -31,12 +31,12 @@ public class DepositParameterTestFixture {
"0x801b08ca107b623eca32ee9f9111b4e50eb9cfe19e38204b72de7dc04c5a5e00f61bab96f10842576f66020ce851083f1583dd9a6b73301bea6c245cf51f27cf96aeb018852c5f70bf485d16b957cfe49ca008913346b431e7653ae3ddb23b07", "0x801b08ca107b623eca32ee9f9111b4e50eb9cfe19e38204b72de7dc04c5a5e00f61bab96f10842576f66020ce851083f1583dd9a6b73301bea6c245cf51f27cf96aeb018852c5f70bf485d16b957cfe49ca008913346b431e7653ae3ddb23b07",
"0x3"); "0x3");
private static DepositParameter createDeposit( private static DepositRequestParameter createDeposit(
final String pubKey, final String pubKey,
final String withdrawalCredentials, final String withdrawalCredentials,
final String amount, final String amount,
final String signature, final String signature,
final String index) { final String index) {
return new DepositParameter(pubKey, withdrawalCredentials, amount, signature, index); return new DepositRequestParameter(pubKey, withdrawalCredentials, amount, signature, index);
} }
} }

@ -20,18 +20,18 @@ import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.Depo
import org.hyperledger.besu.datatypes.BLSPublicKey; import org.hyperledger.besu.datatypes.BLSPublicKey;
import org.hyperledger.besu.datatypes.BLSSignature; import org.hyperledger.besu.datatypes.BLSSignature;
import org.hyperledger.besu.datatypes.GWei; import org.hyperledger.besu.datatypes.GWei;
import org.hyperledger.besu.ethereum.core.Deposit; import org.hyperledger.besu.ethereum.core.DepositRequest;
import org.apache.tuweni.bytes.Bytes32; import org.apache.tuweni.bytes.Bytes32;
import org.apache.tuweni.units.bigints.UInt64; import org.apache.tuweni.units.bigints.UInt64;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
public class DepositParameterTest { public class DepositRequestRequestParameterTest {
@Test @Test
public void toDeposit() { public void toDeposit() {
Deposit expected = DepositRequest expected =
new Deposit( new DepositRequest(
BLSPublicKey.fromHexString( BLSPublicKey.fromHexString(
"0xb10a4a15bf67b328c9b101d09e5c6ee6672978fdad9ef0d9e2ceffaee99223555d8601f0cb3bcc4ce1af9864779a416e"), "0xb10a4a15bf67b328c9b101d09e5c6ee6672978fdad9ef0d9e2ceffaee99223555d8601f0cb3bcc4ce1af9864779a416e"),
Bytes32.fromHexString( Bytes32.fromHexString(
@ -45,8 +45,8 @@ public class DepositParameterTest {
@Test @Test
public void fromDeposit() { public void fromDeposit() {
Deposit deposit = DepositRequest depositRequest =
new Deposit( new DepositRequest(
BLSPublicKey.fromHexString( BLSPublicKey.fromHexString(
"0xb10a4a15bf67b328c9b101d09e5c6ee6672978fdad9ef0d9e2ceffaee99223555d8601f0cb3bcc4ce1af9864779a416e"), "0xb10a4a15bf67b328c9b101d09e5c6ee6672978fdad9ef0d9e2ceffaee99223555d8601f0cb3bcc4ce1af9864779a416e"),
Bytes32.fromHexString( Bytes32.fromHexString(
@ -56,6 +56,6 @@ public class DepositParameterTest {
"0xa889db8300194050a2636c92a95bc7160515867614b7971a9500cdb62f9c0890217d2901c3241f86fac029428fc106930606154bd9e406d7588934a5f15b837180b17194d6e44bd6de23e43b163dfe12e369dcc75a3852cd997963f158217eb5"), "0xa889db8300194050a2636c92a95bc7160515867614b7971a9500cdb62f9c0890217d2901c3241f86fac029428fc106930606154bd9e406d7588934a5f15b837180b17194d6e44bd6de23e43b163dfe12e369dcc75a3852cd997963f158217eb5"),
UInt64.ONE); UInt64.ONE);
assertThat(DepositParameter.fromDeposit(deposit)).isEqualTo(DEPOSIT_PARAM_1); assertThat(DepositRequestParameter.fromDeposit(depositRequest)).isEqualTo(DEPOSIT_PARAM_1);
} }
} }

@ -47,7 +47,7 @@ import org.hyperledger.besu.ethereum.core.BlobTestFixture;
import org.hyperledger.besu.ethereum.core.BlockDataGenerator; import org.hyperledger.besu.ethereum.core.BlockDataGenerator;
import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.BlockHeaderBuilder; import org.hyperledger.besu.ethereum.core.BlockHeaderBuilder;
import org.hyperledger.besu.ethereum.core.Deposit; import org.hyperledger.besu.ethereum.core.DepositRequest;
import org.hyperledger.besu.ethereum.core.Difficulty; import org.hyperledger.besu.ethereum.core.Difficulty;
import org.hyperledger.besu.ethereum.core.ExecutionContextTestFixture; import org.hyperledger.besu.ethereum.core.ExecutionContextTestFixture;
import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters; import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters;
@ -76,7 +76,7 @@ import org.hyperledger.besu.ethereum.mainnet.ProtocolSpecAdapters;
import org.hyperledger.besu.ethereum.mainnet.WithdrawalsProcessor; import org.hyperledger.besu.ethereum.mainnet.WithdrawalsProcessor;
import org.hyperledger.besu.ethereum.mainnet.feemarket.CancunFeeMarket; import org.hyperledger.besu.ethereum.mainnet.feemarket.CancunFeeMarket;
import org.hyperledger.besu.ethereum.mainnet.requests.DepositRequestProcessor; import org.hyperledger.besu.ethereum.mainnet.requests.DepositRequestProcessor;
import org.hyperledger.besu.ethereum.mainnet.requests.DepositsValidator; import org.hyperledger.besu.ethereum.mainnet.requests.DepositRequestValidator;
import org.hyperledger.besu.ethereum.mainnet.requests.RequestProcessorCoordinator; import org.hyperledger.besu.ethereum.mainnet.requests.RequestProcessorCoordinator;
import org.hyperledger.besu.ethereum.mainnet.requests.RequestsValidatorCoordinator; import org.hyperledger.besu.ethereum.mainnet.requests.RequestsValidatorCoordinator;
import org.hyperledger.besu.evm.internal.EvmConfiguration; import org.hyperledger.besu.evm.internal.EvmConfiguration;
@ -106,7 +106,7 @@ abstract class AbstractBlockCreatorTest {
protected EthScheduler ethScheduler = new DeterministicEthScheduler(); protected EthScheduler ethScheduler = new DeterministicEthScheduler();
@Test @Test
void findDepositsFromReceipts() { void findDepositRequestsFromReceipts() {
BlockDataGenerator blockDataGenerator = new BlockDataGenerator(); BlockDataGenerator blockDataGenerator = new BlockDataGenerator();
TransactionReceipt receiptWithoutDeposit1 = blockDataGenerator.receipt(); TransactionReceipt receiptWithoutDeposit1 = blockDataGenerator.receipt();
TransactionReceipt receiptWithoutDeposit2 = blockDataGenerator.receipt(); TransactionReceipt receiptWithoutDeposit2 = blockDataGenerator.receipt();
@ -122,8 +122,8 @@ abstract class AbstractBlockCreatorTest {
List<TransactionReceipt> receipts = List<TransactionReceipt> receipts =
List.of(receiptWithoutDeposit1, receiptWithDeposit, receiptWithoutDeposit2); List.of(receiptWithoutDeposit1, receiptWithDeposit, receiptWithoutDeposit2);
Deposit expectedDeposit = DepositRequest expectedDepositRequest =
new Deposit( new DepositRequest(
BLSPublicKey.fromHexString( BLSPublicKey.fromHexString(
"0xb10a4a15bf67b328c9b101d09e5c6ee6672978fdad9ef0d9e2ceffaee99223555d8601f0cb3bcc4ce1af9864779a416e"), "0xb10a4a15bf67b328c9b101d09e5c6ee6672978fdad9ef0d9e2ceffaee99223555d8601f0cb3bcc4ce1af9864779a416e"),
Bytes32.fromHexString( Bytes32.fromHexString(
@ -132,17 +132,17 @@ abstract class AbstractBlockCreatorTest {
BLSSignature.fromHexString( BLSSignature.fromHexString(
"0xa889db8300194050a2636c92a95bc7160515867614b7971a9500cdb62f9c0890217d2901c3241f86fac029428fc106930606154bd9e406d7588934a5f15b837180b17194d6e44bd6de23e43b163dfe12e369dcc75a3852cd997963f158217eb5"), "0xa889db8300194050a2636c92a95bc7160515867614b7971a9500cdb62f9c0890217d2901c3241f86fac029428fc106930606154bd9e406d7588934a5f15b837180b17194d6e44bd6de23e43b163dfe12e369dcc75a3852cd997963f158217eb5"),
UInt64.valueOf(539967)); UInt64.valueOf(539967));
final List<Deposit> expectedDeposits = List.of(expectedDeposit); final List<DepositRequest> expectedDepositRequests = List.of(expectedDepositRequest);
var depositsFromReceipts = var depositRequestsFromReceipts =
new DepositRequestProcessor(DEFAULT_DEPOSIT_CONTRACT_ADDRESS).process(null, receipts); new DepositRequestProcessor(DEFAULT_DEPOSIT_CONTRACT_ADDRESS).process(null, receipts);
assertThat(depositsFromReceipts.get()).isEqualTo(expectedDeposits); assertThat(depositRequestsFromReceipts.get()).isEqualTo(expectedDepositRequests);
} }
@Test @Test
void withAllowedDepositsAndContractAddress_DepositsAreParsed() { void withAllowedDepositRequestsAndContractAddress_DepositRequestsAreParsed() {
final AbstractBlockCreator blockCreator = final AbstractBlockCreator blockCreator =
blockCreatorWithAllowedDeposits(DEFAULT_DEPOSIT_CONTRACT_ADDRESS); blockCreatorWithAllowedDepositRequests(DEFAULT_DEPOSIT_CONTRACT_ADDRESS);
final BlockCreationResult blockCreationResult = final BlockCreationResult blockCreationResult =
blockCreator.createBlock( blockCreator.createBlock(
@ -154,15 +154,15 @@ abstract class AbstractBlockCreatorTest {
1L, 1L,
false); false);
List<Request> deposits = emptyList(); List<Request> depositRequests = emptyList();
final Hash requestsRoot = BodyValidation.requestsRoot(deposits); final Hash requestsRoot = BodyValidation.requestsRoot(depositRequests);
assertThat(blockCreationResult.getBlock().getHeader().getRequestsRoot()).hasValue(requestsRoot); assertThat(blockCreationResult.getBlock().getHeader().getRequestsRoot()).hasValue(requestsRoot);
assertThat(blockCreationResult.getBlock().getBody().getRequests()).hasValue(deposits); assertThat(blockCreationResult.getBlock().getBody().getRequests()).hasValue(depositRequests);
} }
@Test @Test
void withAllowedDepositsAndNoContractAddress_DepositsAreNotParsed() { void withAllowedDepositRequestsAndNoContractAddress_DepositRequestsAreNotParsed() {
final AbstractBlockCreator blockCreator = blockCreatorWithAllowedDeposits(null); final AbstractBlockCreator blockCreator = blockCreatorWithAllowedDepositRequests(null);
final BlockCreationResult blockCreationResult = final BlockCreationResult blockCreationResult =
blockCreator.createBlock( blockCreator.createBlock(
@ -179,8 +179,8 @@ abstract class AbstractBlockCreatorTest {
} }
@Test @Test
void withProhibitedDeposits_DepositsAreNotParsed() { void withProhibitedDepositRequests_DepositRequestsAreNotParsed() {
final AbstractBlockCreator blockCreator = blockCreatorWithProhibitedDeposits(); final AbstractBlockCreator blockCreator = blockCreatorWithProhibitedDepositRequests();
final BlockCreationResult blockCreationResult = final BlockCreationResult blockCreationResult =
blockCreator.createBlock( blockCreator.createBlock(
@ -196,7 +196,7 @@ abstract class AbstractBlockCreatorTest {
assertThat(blockCreationResult.getBlock().getBody().getRequests()).isEmpty(); assertThat(blockCreationResult.getBlock().getBody().getRequests()).isEmpty();
} }
private AbstractBlockCreator blockCreatorWithAllowedDeposits( private AbstractBlockCreator blockCreatorWithAllowedDepositRequests(
final Address depositContractAddress) { final Address depositContractAddress) {
final ProtocolSpecAdapters protocolSpecAdapters = final ProtocolSpecAdapters protocolSpecAdapters =
ProtocolSpecAdapters.create( ProtocolSpecAdapters.create(
@ -207,7 +207,7 @@ abstract class AbstractBlockCreatorTest {
new RequestsValidatorCoordinator.Builder() new RequestsValidatorCoordinator.Builder()
.addValidator( .addValidator(
RequestType.DEPOSIT, RequestType.DEPOSIT,
new DepositsValidator((depositContractAddress))) new DepositRequestValidator((depositContractAddress)))
.build()) .build())
.requestProcessorCoordinator( .requestProcessorCoordinator(
new RequestProcessorCoordinator.Builder() new RequestProcessorCoordinator.Builder()
@ -218,7 +218,7 @@ abstract class AbstractBlockCreatorTest {
return createBlockCreator(protocolSpecAdapters); return createBlockCreator(protocolSpecAdapters);
} }
private AbstractBlockCreator blockCreatorWithProhibitedDeposits() { private AbstractBlockCreator blockCreatorWithProhibitedDepositRequests() {
final ProtocolSpecAdapters protocolSpecAdapters = final ProtocolSpecAdapters protocolSpecAdapters =
ProtocolSpecAdapters.create(0, specBuilder -> specBuilder); ProtocolSpecAdapters.create(0, specBuilder -> specBuilder);
return createBlockCreator(protocolSpecAdapters); return createBlockCreator(protocolSpecAdapters);

@ -147,7 +147,7 @@ public class BlockBody implements org.hyperledger.besu.plugin.data.BlockBody {
/** /**
* Read all fields from the block body expecting no list wrapping them. An example of a valid body * Read all fields from the block body expecting no list wrapping them. An example of a valid body
* would be: [txs],[ommers],[withdrawals],[deposits] this method is called directly when importing * would be: [txs],[ommers],[withdrawals],[requests] this method is called directly when importing
* a single block * a single block
* *
* @param input The RLP-encoded input * @param input The RLP-encoded input

@ -25,7 +25,8 @@ import java.util.Objects;
import org.apache.tuweni.bytes.Bytes32; import org.apache.tuweni.bytes.Bytes32;
import org.apache.tuweni.units.bigints.UInt64; import org.apache.tuweni.units.bigints.UInt64;
public class Deposit extends Request implements org.hyperledger.besu.plugin.data.Deposit { public class DepositRequest extends Request
implements org.hyperledger.besu.plugin.data.DepositRequest {
private final BLSPublicKey pubkey; private final BLSPublicKey pubkey;
private final Bytes32 depositWithdrawalCredentials; private final Bytes32 depositWithdrawalCredentials;
@ -33,7 +34,7 @@ public class Deposit extends Request implements org.hyperledger.besu.plugin.data
private final BLSSignature signature; private final BLSSignature signature;
private final UInt64 index; private final UInt64 index;
public Deposit( public DepositRequest(
final BLSPublicKey pubkey, final BLSPublicKey pubkey,
final Bytes32 depositWithdrawalCredentials, final Bytes32 depositWithdrawalCredentials,
final GWei amount, final GWei amount,
@ -96,7 +97,7 @@ public class Deposit extends Request implements org.hyperledger.besu.plugin.data
public boolean equals(final Object o) { public boolean equals(final Object o) {
if (this == o) return true; if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false; if (o == null || getClass() != o.getClass()) return false;
final Deposit that = (Deposit) o; final DepositRequest that = (DepositRequest) o;
return Objects.equals(pubkey, that.pubkey) return Objects.equals(pubkey, that.pubkey)
&& Objects.equals(depositWithdrawalCredentials, that.depositWithdrawalCredentials) && Objects.equals(depositWithdrawalCredentials, that.depositWithdrawalCredentials)
&& Objects.equals(amount, that.amount) && Objects.equals(amount, that.amount)

@ -17,8 +17,8 @@ package org.hyperledger.besu.ethereum.core.encoding;
import org.hyperledger.besu.datatypes.BLSPublicKey; import org.hyperledger.besu.datatypes.BLSPublicKey;
import org.hyperledger.besu.datatypes.BLSSignature; import org.hyperledger.besu.datatypes.BLSSignature;
import org.hyperledger.besu.datatypes.GWei; import org.hyperledger.besu.datatypes.GWei;
import org.hyperledger.besu.ethereum.core.Deposit;
import org.hyperledger.besu.ethereum.core.DepositContract; import org.hyperledger.besu.ethereum.core.DepositContract;
import org.hyperledger.besu.ethereum.core.DepositRequest;
import org.hyperledger.besu.ethereum.rlp.RLP; import org.hyperledger.besu.ethereum.rlp.RLP;
import org.hyperledger.besu.ethereum.rlp.RLPInput; import org.hyperledger.besu.ethereum.rlp.RLPInput;
import org.hyperledger.besu.evm.log.Log; import org.hyperledger.besu.evm.log.Log;
@ -30,9 +30,9 @@ import org.apache.tuweni.bytes.Bytes32;
import org.apache.tuweni.units.bigints.UInt64; import org.apache.tuweni.units.bigints.UInt64;
import org.web3j.tx.Contract; import org.web3j.tx.Contract;
public class DepositDecoder { public class DepositRequestDecoder {
public static Deposit decode(final RLPInput rlpInput) { public static DepositRequest decode(final RLPInput rlpInput) {
rlpInput.enterList(); rlpInput.enterList();
final BLSPublicKey publicKey = BLSPublicKey.readFrom(rlpInput); final BLSPublicKey publicKey = BLSPublicKey.readFrom(rlpInput);
final Bytes32 depositWithdrawalCredential = Bytes32.wrap(rlpInput.readBytes()); final Bytes32 depositWithdrawalCredential = Bytes32.wrap(rlpInput.readBytes());
@ -41,10 +41,10 @@ public class DepositDecoder {
final UInt64 index = UInt64.valueOf(rlpInput.readBigIntegerScalar()); final UInt64 index = UInt64.valueOf(rlpInput.readBigIntegerScalar());
rlpInput.leaveList(); rlpInput.leaveList();
return new Deposit(publicKey, depositWithdrawalCredential, amount, signature, index); return new DepositRequest(publicKey, depositWithdrawalCredential, amount, signature, index);
} }
public static Deposit decodeFromLog(final Log log) { public static DepositRequest decodeFromLog(final Log log) {
Contract.EventValuesWithLog eventValues = DepositContract.staticExtractDepositEventWithLog(log); Contract.EventValuesWithLog eventValues = DepositContract.staticExtractDepositEventWithLog(log);
final byte[] rawPublicKey = (byte[]) eventValues.getNonIndexedValues().get(0).getValue(); final byte[] rawPublicKey = (byte[]) eventValues.getNonIndexedValues().get(0).getValue();
final byte[] rawWithdrawalCredential = final byte[] rawWithdrawalCredential =
@ -53,7 +53,7 @@ public class DepositDecoder {
final byte[] rawSignature = (byte[]) eventValues.getNonIndexedValues().get(3).getValue(); final byte[] rawSignature = (byte[]) eventValues.getNonIndexedValues().get(3).getValue();
final byte[] rawIndex = (byte[]) eventValues.getNonIndexedValues().get(4).getValue(); final byte[] rawIndex = (byte[]) eventValues.getNonIndexedValues().get(4).getValue();
return new Deposit( return new DepositRequest(
BLSPublicKey.wrap(Bytes.wrap(rawPublicKey)), BLSPublicKey.wrap(Bytes.wrap(rawPublicKey)),
Bytes32.wrap(Bytes.wrap(rawWithdrawalCredential)), Bytes32.wrap(Bytes.wrap(rawWithdrawalCredential)),
GWei.of( GWei.of(
@ -64,7 +64,7 @@ public class DepositDecoder {
UInt64.valueOf(Bytes.wrap(rawIndex).reverse().toLong())); UInt64.valueOf(Bytes.wrap(rawIndex).reverse().toLong()));
} }
public static Deposit decodeOpaqueBytes(final Bytes input) { public static DepositRequest decodeOpaqueBytes(final Bytes input) {
return decode(RLP.input(input)); return decode(RLP.input(input));
} }
} }

@ -14,25 +14,25 @@
*/ */
package org.hyperledger.besu.ethereum.core.encoding; package org.hyperledger.besu.ethereum.core.encoding;
import org.hyperledger.besu.ethereum.core.Deposit; import org.hyperledger.besu.ethereum.core.DepositRequest;
import org.hyperledger.besu.ethereum.core.Request; import org.hyperledger.besu.ethereum.core.Request;
import org.hyperledger.besu.ethereum.rlp.RLP; import org.hyperledger.besu.ethereum.rlp.RLP;
import org.hyperledger.besu.ethereum.rlp.RLPOutput; import org.hyperledger.besu.ethereum.rlp.RLPOutput;
import org.apache.tuweni.bytes.Bytes; import org.apache.tuweni.bytes.Bytes;
public class DepositEncoder { public class DepositRequestEncoder {
public static void encode(final Request request, final RLPOutput rlpOutput) { public static void encode(final Request request, final RLPOutput rlpOutput) {
if (!(request instanceof Deposit deposit)) { if (!(request instanceof DepositRequest depositRequest)) {
throw new IllegalArgumentException("The provided request is not of type deposit."); throw new IllegalArgumentException("The provided request is not of type deposit.");
} }
rlpOutput.startList(); rlpOutput.startList();
rlpOutput.writeBytes(deposit.getPubkey()); rlpOutput.writeBytes(depositRequest.getPubkey());
rlpOutput.writeBytes(deposit.getWithdrawalCredentials()); rlpOutput.writeBytes(depositRequest.getWithdrawalCredentials());
rlpOutput.writeUInt64Scalar(deposit.getAmount()); rlpOutput.writeUInt64Scalar(depositRequest.getAmount());
rlpOutput.writeBytes(deposit.getSignature()); rlpOutput.writeBytes(depositRequest.getSignature());
rlpOutput.writeUInt64Scalar(deposit.getIndex()); rlpOutput.writeUInt64Scalar(depositRequest.getIndex());
rlpOutput.endList(); rlpOutput.endList();
} }

@ -41,7 +41,7 @@ public class RequestDecoder {
RequestType.WITHDRAWAL, RequestType.WITHDRAWAL,
WithdrawalRequestDecoder::decode, WithdrawalRequestDecoder::decode,
RequestType.DEPOSIT, RequestType.DEPOSIT,
DepositDecoder::decode); DepositRequestDecoder::decode);
/** /**
* Decodes a request from its RLP encoded bytes. * Decodes a request from its RLP encoded bytes.

@ -38,7 +38,7 @@ public class RequestEncoder {
RequestType.WITHDRAWAL, RequestType.WITHDRAWAL,
WithdrawalRequestEncoder::encode, WithdrawalRequestEncoder::encode,
RequestType.DEPOSIT, RequestType.DEPOSIT,
DepositEncoder::encode); DepositRequestEncoder::encode);
/** /**
* Encodes a Request into the provided RLPOutput. * Encodes a Request into the provided RLPOutput.

@ -15,11 +15,11 @@
package org.hyperledger.besu.ethereum.mainnet.requests; package org.hyperledger.besu.ethereum.mainnet.requests;
import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.ethereum.core.Deposit; import org.hyperledger.besu.ethereum.core.DepositRequest;
import org.hyperledger.besu.ethereum.core.MutableWorldState; import org.hyperledger.besu.ethereum.core.MutableWorldState;
import org.hyperledger.besu.ethereum.core.Request; import org.hyperledger.besu.ethereum.core.Request;
import org.hyperledger.besu.ethereum.core.TransactionReceipt; import org.hyperledger.besu.ethereum.core.TransactionReceipt;
import org.hyperledger.besu.ethereum.core.encoding.DepositDecoder; import org.hyperledger.besu.ethereum.core.encoding.DepositRequestDecoder;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
@ -44,19 +44,20 @@ public class DepositRequestProcessor implements RequestProcessor {
if (depositContractAddress.isEmpty()) { if (depositContractAddress.isEmpty()) {
return Optional.empty(); return Optional.empty();
} }
List<Deposit> deposits = findDepositsFromReceipts(transactionReceipts); List<DepositRequest> depositRequests = findDepositRequestsFromReceipts(transactionReceipts);
return Optional.of(deposits); return Optional.of(depositRequests);
} }
@VisibleForTesting @VisibleForTesting
List<Deposit> findDepositsFromReceipts(final List<TransactionReceipt> transactionReceipts) { List<DepositRequest> findDepositRequestsFromReceipts(
final List<TransactionReceipt> transactionReceipts) {
return depositContractAddress return depositContractAddress
.map( .map(
address -> address ->
transactionReceipts.stream() transactionReceipts.stream()
.flatMap(receipt -> receipt.getLogsList().stream()) .flatMap(receipt -> receipt.getLogsList().stream())
.filter(log -> address.equals(log.getLogger())) .filter(log -> address.equals(log.getLogger()))
.map(DepositDecoder::decodeFromLog) .map(DepositRequestDecoder::decodeFromLog)
.toList()) .toList())
.orElse(Collections.emptyList()); .orElse(Collections.emptyList());
} }

@ -18,10 +18,10 @@ import static org.hyperledger.besu.ethereum.mainnet.requests.RequestUtil.getDepo
import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.ethereum.core.Block; import org.hyperledger.besu.ethereum.core.Block;
import org.hyperledger.besu.ethereum.core.Deposit; import org.hyperledger.besu.ethereum.core.DepositRequest;
import org.hyperledger.besu.ethereum.core.Request; import org.hyperledger.besu.ethereum.core.Request;
import org.hyperledger.besu.ethereum.core.TransactionReceipt; import org.hyperledger.besu.ethereum.core.TransactionReceipt;
import org.hyperledger.besu.ethereum.core.encoding.DepositDecoder; import org.hyperledger.besu.ethereum.core.encoding.DepositRequestDecoder;
import org.hyperledger.besu.evm.log.Log; import org.hyperledger.besu.evm.log.Log;
import java.util.ArrayList; import java.util.ArrayList;
@ -32,44 +32,46 @@ import java.util.Optional;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
public class DepositsValidator implements RequestValidator { public class DepositRequestValidator implements RequestValidator {
private static final Logger LOG = LoggerFactory.getLogger(DepositsValidator.class); private static final Logger LOG = LoggerFactory.getLogger(DepositRequestValidator.class);
private final Address depositContractAddress; private final Address depositContractAddress;
public DepositsValidator(final Address depositContractAddress) { public DepositRequestValidator(final Address depositContractAddress) {
this.depositContractAddress = depositContractAddress; this.depositContractAddress = depositContractAddress;
} }
@Override @Override
public boolean validateParameter(final Optional<List<Request>> deposits) { public boolean validateParameter(final Optional<List<Request>> depositRequests) {
return deposits.isPresent(); return depositRequests.isPresent();
} }
public boolean validateDeposits( public boolean validateDepositRequests(
final Block block, final Block block,
final List<Deposit> actualDeposits, final List<DepositRequest> actualDepositRequests,
final List<TransactionReceipt> receipts) { final List<TransactionReceipt> receipts) {
List<Deposit> expectedDeposits = new ArrayList<>(); List<DepositRequest> expectedDepositRequests = new ArrayList<>();
for (TransactionReceipt receipt : receipts) { for (TransactionReceipt receipt : receipts) {
for (Log log : receipt.getLogsList()) { for (Log log : receipt.getLogsList()) {
if (depositContractAddress.equals(log.getLogger())) { if (depositContractAddress.equals(log.getLogger())) {
Deposit deposit = DepositDecoder.decodeFromLog(log); DepositRequest depositRequest = DepositRequestDecoder.decodeFromLog(log);
expectedDeposits.add(deposit); expectedDepositRequests.add(depositRequest);
} }
} }
} }
boolean isValid = actualDeposits.equals(expectedDeposits); boolean isValid = actualDepositRequests.equals(expectedDepositRequests);
if (!isValid) { if (!isValid) {
LOG.warn( LOG.warn(
"Deposits validation failed. Deposits from block body do not match deposits from logs. Block hash: {}", "Deposits validation failed. Deposits from block body do not match deposits from logs. Block hash: {}",
block.getHash()); block.getHash());
LOG.debug( LOG.debug(
"Deposits from logs: {}, deposits from block body: {}", expectedDeposits, actualDeposits); "Deposits from logs: {}, deposits from block body: {}",
expectedDepositRequests,
actualDepositRequests);
} }
return isValid; return isValid;
@ -78,7 +80,7 @@ public class DepositsValidator implements RequestValidator {
@Override @Override
public boolean validate( public boolean validate(
final Block block, final List<Request> requests, final List<TransactionReceipt> receipts) { final Block block, final List<Request> requests, final List<TransactionReceipt> receipts) {
var deposits = getDepositRequests(Optional.of(requests)).orElse(Collections.emptyList()); var depositRequests = getDepositRequests(Optional.of(requests)).orElse(Collections.emptyList());
return validateDeposits(block, deposits, receipts); return validateDepositRequests(block, depositRequests, receipts);
} }
} }

@ -22,7 +22,7 @@ public class MainnetRequestsValidator {
final Address depositContractAddress) { final Address depositContractAddress) {
return new RequestsValidatorCoordinator.Builder() return new RequestsValidatorCoordinator.Builder()
.addValidator(RequestType.WITHDRAWAL, new WithdrawalRequestValidator()) .addValidator(RequestType.WITHDRAWAL, new WithdrawalRequestValidator())
.addValidator(RequestType.DEPOSIT, new DepositsValidator(depositContractAddress)) .addValidator(RequestType.DEPOSIT, new DepositRequestValidator(depositContractAddress))
.build(); .build();
} }

@ -14,7 +14,7 @@
*/ */
package org.hyperledger.besu.ethereum.mainnet.requests; package org.hyperledger.besu.ethereum.mainnet.requests;
import org.hyperledger.besu.ethereum.core.Deposit; import org.hyperledger.besu.ethereum.core.DepositRequest;
import org.hyperledger.besu.ethereum.core.Request; import org.hyperledger.besu.ethereum.core.Request;
import org.hyperledger.besu.ethereum.core.WithdrawalRequest; import org.hyperledger.besu.ethereum.core.WithdrawalRequest;
@ -42,8 +42,9 @@ public class RequestUtil {
return requests.stream().filter(requestType::isInstance).map(requestType::cast).toList(); return requests.stream().filter(requestType::isInstance).map(requestType::cast).toList();
} }
public static Optional<List<Deposit>> getDepositRequests(final Optional<List<Request>> requests) { public static Optional<List<DepositRequest>> getDepositRequests(
return requests.map(r -> filterRequestsOfType(r, Deposit.class)); final Optional<List<Request>> requests) {
return requests.map(r -> filterRequestsOfType(r, DepositRequest.class));
} }
public static Optional<List<WithdrawalRequest>> getWithdrawalRequests( public static Optional<List<WithdrawalRequest>> getWithdrawalRequests(
@ -54,19 +55,19 @@ public class RequestUtil {
/** /**
* Combines two optional lists of requests into a single optional list. * Combines two optional lists of requests into a single optional list.
* *
* @param maybeDeposits Optional list of deposit requests. * @param maybeDepositRequests Optional list of deposit requests.
* @param maybeWithdrawalRequest Optional list of withdrawal requests. * @param maybeWithdrawalRequest Optional list of withdrawal requests.
* @return An Optional containing the combined list of requests, or an empty Optional if both * @return An Optional containing the combined list of requests, or an empty Optional if both
* inputs are empty. * inputs are empty.
*/ */
public static Optional<List<Request>> combine( public static Optional<List<Request>> combine(
final Optional<List<Request>> maybeDeposits, final Optional<List<Request>> maybeDepositRequests,
final Optional<List<Request>> maybeWithdrawalRequest) { final Optional<List<Request>> maybeWithdrawalRequest) {
if (maybeDeposits.isEmpty() && maybeWithdrawalRequest.isEmpty()) { if (maybeDepositRequests.isEmpty() && maybeWithdrawalRequest.isEmpty()) {
return Optional.empty(); return Optional.empty();
} }
List<Request> requests = new ArrayList<>(); List<Request> requests = new ArrayList<>();
maybeDeposits.ifPresent(requests::addAll); maybeDepositRequests.ifPresent(requests::addAll);
maybeWithdrawalRequest.ifPresent(requests::addAll); maybeWithdrawalRequest.ifPresent(requests::addAll);
return Optional.of(requests); return Optional.of(requests);
} }

@ -20,7 +20,7 @@ import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.BLSPublicKey; import org.hyperledger.besu.datatypes.BLSPublicKey;
import org.hyperledger.besu.datatypes.BLSSignature; import org.hyperledger.besu.datatypes.BLSSignature;
import org.hyperledger.besu.datatypes.GWei; import org.hyperledger.besu.datatypes.GWei;
import org.hyperledger.besu.ethereum.core.Deposit; import org.hyperledger.besu.ethereum.core.DepositRequest;
import org.hyperledger.besu.evm.log.Log; import org.hyperledger.besu.evm.log.Log;
import org.hyperledger.besu.evm.log.LogTopic; import org.hyperledger.besu.evm.log.LogTopic;
@ -31,11 +31,11 @@ import org.apache.tuweni.bytes.Bytes32;
import org.apache.tuweni.units.bigints.UInt64; import org.apache.tuweni.units.bigints.UInt64;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
class DepositDecoderTest { class DepositRequestRequestDecoderTest {
@Test @Test
void shouldDecodeDeposit() { void shouldDecodeDeposit() {
final Deposit expectedDeposit = final DepositRequest expectedDepositRequest =
new Deposit( new DepositRequest(
BLSPublicKey.fromHexString( BLSPublicKey.fromHexString(
"0xb10a4a15bf67b328c9b101d09e5c6ee6672978fdad9ef0d9e2ceffaee99223555d8601f0cb3bcc4ce1af9864779a416e"), "0xb10a4a15bf67b328c9b101d09e5c6ee6672978fdad9ef0d9e2ceffaee99223555d8601f0cb3bcc4ce1af9864779a416e"),
Bytes32.fromHexString( Bytes32.fromHexString(
@ -45,12 +45,12 @@ class DepositDecoderTest {
"0xa889db8300194050a2636c92a95bc7160515867614b7971a9500cdb62f9c0890217d2901c3241f86fac029428fc106930606154bd9e406d7588934a5f15b837180b17194d6e44bd6de23e43b163dfe12e369dcc75a3852cd997963f158217eb5"), "0xa889db8300194050a2636c92a95bc7160515867614b7971a9500cdb62f9c0890217d2901c3241f86fac029428fc106930606154bd9e406d7588934a5f15b837180b17194d6e44bd6de23e43b163dfe12e369dcc75a3852cd997963f158217eb5"),
UInt64.ONE); UInt64.ONE);
final Deposit deposit = final DepositRequest depositRequest =
DepositDecoder.decodeOpaqueBytes( DepositRequestDecoder.decodeOpaqueBytes(
Bytes.fromHexString( Bytes.fromHexString(
"0xf8bbb0b10a4a15bf67b328c9b101d09e5c6ee6672978fdad9ef0d9e2ceffaee99223555d8601f0cb3bcc4ce1af9864779a416ea00017a7fcf06faf493d30bbe2632ea7c2383cd86825e12797165de7aa35589483850773594000b860a889db8300194050a2636c92a95bc7160515867614b7971a9500cdb62f9c0890217d2901c3241f86fac029428fc106930606154bd9e406d7588934a5f15b837180b17194d6e44bd6de23e43b163dfe12e369dcc75a3852cd997963f158217eb501")); "0xf8bbb0b10a4a15bf67b328c9b101d09e5c6ee6672978fdad9ef0d9e2ceffaee99223555d8601f0cb3bcc4ce1af9864779a416ea00017a7fcf06faf493d30bbe2632ea7c2383cd86825e12797165de7aa35589483850773594000b860a889db8300194050a2636c92a95bc7160515867614b7971a9500cdb62f9c0890217d2901c3241f86fac029428fc106930606154bd9e406d7588934a5f15b837180b17194d6e44bd6de23e43b163dfe12e369dcc75a3852cd997963f158217eb501"));
assertThat(deposit).isEqualTo(expectedDeposit); assertThat(depositRequest).isEqualTo(expectedDepositRequest);
} }
@Test @Test
@ -65,10 +65,10 @@ class DepositDecoderTest {
"0x00000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000030b10a4a15bf67b328c9b101d09e5c6ee6672978fdad9ef0d9e2ceffaee99223555d8601f0cb3bcc4ce1af9864779a416e0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200017a7fcf06faf493d30bbe2632ea7c2383cd86825e12797165de7aa35589483000000000000000000000000000000000000000000000000000000000000000800405973070000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060a889db8300194050a2636c92a95bc7160515867614b7971a9500cdb62f9c0890217d2901c3241f86fac029428fc106930606154bd9e406d7588934a5f15b837180b17194d6e44bd6de23e43b163dfe12e369dcc75a3852cd997963f158217eb500000000000000000000000000000000000000000000000000000000000000083f3d080000000000000000000000000000000000000000000000000000000000"); "0x00000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000030b10a4a15bf67b328c9b101d09e5c6ee6672978fdad9ef0d9e2ceffaee99223555d8601f0cb3bcc4ce1af9864779a416e0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200017a7fcf06faf493d30bbe2632ea7c2383cd86825e12797165de7aa35589483000000000000000000000000000000000000000000000000000000000000000800405973070000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060a889db8300194050a2636c92a95bc7160515867614b7971a9500cdb62f9c0890217d2901c3241f86fac029428fc106930606154bd9e406d7588934a5f15b837180b17194d6e44bd6de23e43b163dfe12e369dcc75a3852cd997963f158217eb500000000000000000000000000000000000000000000000000000000000000083f3d080000000000000000000000000000000000000000000000000000000000");
final Log log = new Log(address, data, topics); final Log log = new Log(address, data, topics);
final Deposit deposit = DepositDecoder.decodeFromLog(log); final DepositRequest depositRequest = DepositRequestDecoder.decodeFromLog(log);
final Deposit expectedDeposit = final DepositRequest expectedDepositRequest =
new Deposit( new DepositRequest(
BLSPublicKey.fromHexString( BLSPublicKey.fromHexString(
"0xb10a4a15bf67b328c9b101d09e5c6ee6672978fdad9ef0d9e2ceffaee99223555d8601f0cb3bcc4ce1af9864779a416e"), "0xb10a4a15bf67b328c9b101d09e5c6ee6672978fdad9ef0d9e2ceffaee99223555d8601f0cb3bcc4ce1af9864779a416e"),
Bytes32.fromHexString( Bytes32.fromHexString(
@ -78,6 +78,6 @@ class DepositDecoderTest {
"0xa889db8300194050a2636c92a95bc7160515867614b7971a9500cdb62f9c0890217d2901c3241f86fac029428fc106930606154bd9e406d7588934a5f15b837180b17194d6e44bd6de23e43b163dfe12e369dcc75a3852cd997963f158217eb5"), "0xa889db8300194050a2636c92a95bc7160515867614b7971a9500cdb62f9c0890217d2901c3241f86fac029428fc106930606154bd9e406d7588934a5f15b837180b17194d6e44bd6de23e43b163dfe12e369dcc75a3852cd997963f158217eb5"),
UInt64.valueOf(539967)); UInt64.valueOf(539967));
assertThat(deposit).isEqualTo(expectedDeposit); assertThat(depositRequest).isEqualTo(expectedDepositRequest);
} }
} }

@ -19,19 +19,19 @@ import static org.assertj.core.api.Assertions.assertThat;
import org.hyperledger.besu.datatypes.BLSPublicKey; import org.hyperledger.besu.datatypes.BLSPublicKey;
import org.hyperledger.besu.datatypes.BLSSignature; import org.hyperledger.besu.datatypes.BLSSignature;
import org.hyperledger.besu.datatypes.GWei; import org.hyperledger.besu.datatypes.GWei;
import org.hyperledger.besu.ethereum.core.Deposit; import org.hyperledger.besu.ethereum.core.DepositRequest;
import org.apache.tuweni.bytes.Bytes; import org.apache.tuweni.bytes.Bytes;
import org.apache.tuweni.bytes.Bytes32; import org.apache.tuweni.bytes.Bytes32;
import org.apache.tuweni.units.bigints.UInt64; import org.apache.tuweni.units.bigints.UInt64;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
class DepositEncoderTest { class DepositRequestRequestEncoderTest {
private final String expectedDepositEncodedBytes = private final String expectedDepositEncodedBytes =
"f8bbb0b10a4a15bf67b328c9b101d09e5c6ee6672978fdad9ef0d9e2ceffaee99223555d8601f0cb3bcc4ce1af9864779a416ea00017a7fcf06faf493d30bbe2632ea7c2383cd86825e12797165de7aa35589483850773594000b860a889db8300194050a2636c92a95bc7160515867614b7971a9500cdb62f9c0890217d2901c3241f86fac029428fc106930606154bd9e406d7588934a5f15b837180b17194d6e44bd6de23e43b163dfe12e369dcc75a3852cd997963f158217eb501"; "f8bbb0b10a4a15bf67b328c9b101d09e5c6ee6672978fdad9ef0d9e2ceffaee99223555d8601f0cb3bcc4ce1af9864779a416ea00017a7fcf06faf493d30bbe2632ea7c2383cd86825e12797165de7aa35589483850773594000b860a889db8300194050a2636c92a95bc7160515867614b7971a9500cdb62f9c0890217d2901c3241f86fac029428fc106930606154bd9e406d7588934a5f15b837180b17194d6e44bd6de23e43b163dfe12e369dcc75a3852cd997963f158217eb501";
final Deposit deposit = final DepositRequest depositRequest =
new Deposit( new DepositRequest(
BLSPublicKey.fromHexString( BLSPublicKey.fromHexString(
"0xb10a4a15bf67b328c9b101d09e5c6ee6672978fdad9ef0d9e2ceffaee99223555d8601f0cb3bcc4ce1af9864779a416e"), "0xb10a4a15bf67b328c9b101d09e5c6ee6672978fdad9ef0d9e2ceffaee99223555d8601f0cb3bcc4ce1af9864779a416e"),
Bytes32.fromHexString( Bytes32.fromHexString(
@ -43,19 +43,19 @@ class DepositEncoderTest {
@Test @Test
void shouldEncodeDeposit() { void shouldEncodeDeposit() {
final Bytes encoded = DepositEncoder.encodeOpaqueBytes(deposit); final Bytes encoded = DepositRequestEncoder.encodeOpaqueBytes(depositRequest);
assertThat(encoded).isEqualTo(Bytes.fromHexString(expectedDepositEncodedBytes)); assertThat(encoded).isEqualTo(Bytes.fromHexString(expectedDepositEncodedBytes));
} }
@Test @Test
void shouldEncodeDepositRequest() { void shouldEncodeDepositRequest() {
final Bytes encoded = RequestEncoder.encodeOpaqueBytes(deposit); final Bytes encoded = RequestEncoder.encodeOpaqueBytes(depositRequest);
// Request encoding is Request = RequestType ++ RequestData // Request encoding is Request = RequestType ++ RequestData
assertThat(encoded) assertThat(encoded)
.isEqualTo( .isEqualTo(
Bytes.fromHexString( Bytes.fromHexString(
String.format( String.format(
"0x%02X%s", "0x%02X%s",
deposit.getType().getSerializedType(), expectedDepositEncodedBytes))); depositRequest.getType().getSerializedType(), expectedDepositEncodedBytes)));
} }
} }

@ -23,10 +23,10 @@ import org.hyperledger.besu.datatypes.GWei;
import org.hyperledger.besu.datatypes.RequestType; import org.hyperledger.besu.datatypes.RequestType;
import org.hyperledger.besu.ethereum.core.Block; import org.hyperledger.besu.ethereum.core.Block;
import org.hyperledger.besu.ethereum.core.BlockDataGenerator; import org.hyperledger.besu.ethereum.core.BlockDataGenerator;
import org.hyperledger.besu.ethereum.core.Deposit; import org.hyperledger.besu.ethereum.core.DepositRequest;
import org.hyperledger.besu.ethereum.core.Request; import org.hyperledger.besu.ethereum.core.Request;
import org.hyperledger.besu.ethereum.core.TransactionReceipt; import org.hyperledger.besu.ethereum.core.TransactionReceipt;
import org.hyperledger.besu.ethereum.mainnet.requests.DepositsValidator; import org.hyperledger.besu.ethereum.mainnet.requests.DepositRequestValidator;
import org.hyperledger.besu.ethereum.mainnet.requests.RequestsValidatorCoordinator; import org.hyperledger.besu.ethereum.mainnet.requests.RequestsValidatorCoordinator;
import org.hyperledger.besu.ethereum.mainnet.requests.WithdrawalRequestValidator; import org.hyperledger.besu.ethereum.mainnet.requests.WithdrawalRequestValidator;
import org.hyperledger.besu.evm.log.Log; import org.hyperledger.besu.evm.log.Log;
@ -41,20 +41,20 @@ import org.apache.tuweni.units.bigints.UInt64;
import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
public class DepositsValidatorTest { public class DepositRequestValidatorTest {
private final BlockDataGenerator blockDataGenerator = new BlockDataGenerator(); private final BlockDataGenerator blockDataGenerator = new BlockDataGenerator();
private static Deposit DEPOSIT_1; private static DepositRequest depositRequest1;
private static Deposit DEPOSIT_2; private static DepositRequest depositRequest2;
private static Log LOG_1; private static Log LOG_1;
private static Log LOG_2; private static Log LOG_2;
private static Address DEPOSIT_CONTRACT_ADDRESS; private static Address DEPOSIT_CONTRACT_ADDRESS;
private static RequestsValidatorCoordinator requestsValidatorCoordinator; private static RequestsValidatorCoordinator requestsValidatorCoordinator;
private static DepositsValidator depositsValidator; private static DepositRequestValidator depositRequestValidator;
@BeforeAll @BeforeAll
public static void setup() { public static void setup() {
DEPOSIT_1 = depositRequest1 =
new Deposit( new DepositRequest(
BLSPublicKey.fromHexString( BLSPublicKey.fromHexString(
"0xb10a4a15bf67b328c9b101d09e5c6ee6672978fdad9ef0d9e2ceffaee99223555d8601f0cb3bcc4ce1af9864779a416e"), "0xb10a4a15bf67b328c9b101d09e5c6ee6672978fdad9ef0d9e2ceffaee99223555d8601f0cb3bcc4ce1af9864779a416e"),
Bytes32.fromHexString( Bytes32.fromHexString(
@ -64,8 +64,8 @@ public class DepositsValidatorTest {
"0xa889db8300194050a2636c92a95bc7160515867614b7971a9500cdb62f9c0890217d2901c3241f86fac029428fc106930606154bd9e406d7588934a5f15b837180b17194d6e44bd6de23e43b163dfe12e369dcc75a3852cd997963f158217eb5"), "0xa889db8300194050a2636c92a95bc7160515867614b7971a9500cdb62f9c0890217d2901c3241f86fac029428fc106930606154bd9e406d7588934a5f15b837180b17194d6e44bd6de23e43b163dfe12e369dcc75a3852cd997963f158217eb5"),
UInt64.valueOf(539967)); UInt64.valueOf(539967));
DEPOSIT_2 = depositRequest2 =
new Deposit( new DepositRequest(
BLSPublicKey.fromHexString( BLSPublicKey.fromHexString(
"0x8706d19a62f28a6a6549f96c5adaebac9124a61d44868ec94f6d2d707c6a2f82c9162071231dfeb40e24bfde4ffdf243"), "0x8706d19a62f28a6a6549f96c5adaebac9124a61d44868ec94f6d2d707c6a2f82c9162071231dfeb40e24bfde4ffdf243"),
Bytes32.fromHexString( Bytes32.fromHexString(
@ -97,8 +97,8 @@ public class DepositsValidatorTest {
} }
@Test @Test
public void validateAllowedDeposits() { public void validateAllowedDepositRequests() {
final List<Request> request = List.of(DEPOSIT_1, DEPOSIT_2); final List<Request> request = List.of(depositRequest1, depositRequest2);
final BlockDataGenerator.BlockOptions blockOptions = final BlockDataGenerator.BlockOptions blockOptions =
BlockDataGenerator.BlockOptions.create() BlockDataGenerator.BlockOptions.create()
.setRequests(Optional.of(request)) .setRequests(Optional.of(request))
@ -113,9 +113,9 @@ public class DepositsValidatorTest {
} }
@Test @Test
public void validateAllowedDepositsSeparateReceipts() { public void validateAllowedDepositRequestsSeparateReceipts() {
final List<Request> requests = List.of(DEPOSIT_1, DEPOSIT_2); final List<Request> requests = List.of(depositRequest1, depositRequest2);
final BlockDataGenerator.BlockOptions blockOptions = final BlockDataGenerator.BlockOptions blockOptions =
BlockDataGenerator.BlockOptions.create() BlockDataGenerator.BlockOptions.create()
@ -135,9 +135,9 @@ public class DepositsValidatorTest {
} }
@Test @Test
public void invalidateAllowedDeposits() { public void invalidateAllowedDepositRequests() {
final BlockDataGenerator.BlockOptions blockOptions = final BlockDataGenerator.BlockOptions blockOptions =
BlockDataGenerator.BlockOptions.create().setRequests(Optional.of(List.of(DEPOSIT_1))); BlockDataGenerator.BlockOptions.create().setRequests(Optional.of(List.of(depositRequest1)));
final Block block = blockDataGenerator.block(blockOptions); final Block block = blockDataGenerator.block(blockOptions);
final TransactionReceipt receipt1 = final TransactionReceipt receipt1 =
@ -149,10 +149,10 @@ public class DepositsValidatorTest {
} }
@Test @Test
public void invalidateAllowedDepositsMissingLogInReceipt() { public void invalidateAllowedDepositRequestsMissingLogInReceipt() {
final BlockDataGenerator.BlockOptions blockOptions = final BlockDataGenerator.BlockOptions blockOptions =
BlockDataGenerator.BlockOptions.create() BlockDataGenerator.BlockOptions.create()
.setRequests(Optional.of(List.of(DEPOSIT_1, DEPOSIT_2))); .setRequests(Optional.of(List.of(depositRequest1, depositRequest2)));
final Block block = blockDataGenerator.block(blockOptions); final Block block = blockDataGenerator.block(blockOptions);
final TransactionReceipt receipt1 = final TransactionReceipt receipt1 =
@ -164,9 +164,9 @@ public class DepositsValidatorTest {
} }
@Test @Test
public void invalidateAllowedDepositsExtraLogInReceipt() { public void invalidateAllowedDepositRequestsExtraLogInReceipt() {
final BlockDataGenerator.BlockOptions blockOptions = final BlockDataGenerator.BlockOptions blockOptions =
BlockDataGenerator.BlockOptions.create().setRequests(Optional.of(List.of(DEPOSIT_1))); BlockDataGenerator.BlockOptions.create().setRequests(Optional.of(List.of(depositRequest1)));
final Block block = blockDataGenerator.block(blockOptions); final Block block = blockDataGenerator.block(blockOptions);
final TransactionReceipt receipt1 = final TransactionReceipt receipt1 =
@ -178,10 +178,10 @@ public class DepositsValidatorTest {
} }
@Test @Test
public void invalidateAllowedDepositsWrongOrder() { public void invalidateAllowedDepositRequestsWrongOrder() {
final BlockDataGenerator.BlockOptions blockOptions = final BlockDataGenerator.BlockOptions blockOptions =
BlockDataGenerator.BlockOptions.create() BlockDataGenerator.BlockOptions.create()
.setRequests(Optional.of(List.of(DEPOSIT_1, DEPOSIT_2))); .setRequests(Optional.of(List.of(depositRequest1, depositRequest2)));
final Block block = blockDataGenerator.block(blockOptions); final Block block = blockDataGenerator.block(blockOptions);
final TransactionReceipt receipt1 = final TransactionReceipt receipt1 =
@ -193,11 +193,11 @@ public class DepositsValidatorTest {
} }
@Test @Test
public void invalidateAllowedDepositsMismatchContractAddress() { public void invalidateAllowedDepositRequestsMismatchContractAddress() {
final BlockDataGenerator.BlockOptions blockOptions = final BlockDataGenerator.BlockOptions blockOptions =
BlockDataGenerator.BlockOptions.create() BlockDataGenerator.BlockOptions.create()
.setRequests(Optional.of(List.of(DEPOSIT_1, DEPOSIT_2))); .setRequests(Optional.of(List.of(depositRequest1, depositRequest2)));
final Block block = blockDataGenerator.block(blockOptions); final Block block = blockDataGenerator.block(blockOptions);
final TransactionReceipt receipt1 = final TransactionReceipt receipt1 =
@ -210,24 +210,25 @@ public class DepositsValidatorTest {
@Test @Test
public void validateAllowedDepositParams() { public void validateAllowedDepositParams() {
final Optional<List<Request>> deposits = Optional.of(List.of(DEPOSIT_1, DEPOSIT_2)); final Optional<List<Request>> depositRequests =
assertThat(depositsValidator.validateParameter(deposits)).isTrue(); Optional.of(List.of(depositRequest1, depositRequest2));
assertThat(depositRequestValidator.validateParameter(depositRequests)).isTrue();
final Optional<List<Request>> emptyDeposits = Optional.of(List.of()); final Optional<List<Request>> emptyDepositRequests = Optional.of(List.of());
assertThat(depositsValidator.validateParameter(emptyDeposits)).isTrue(); assertThat(depositRequestValidator.validateParameter(emptyDepositRequests)).isTrue();
} }
@Test @Test
public void invalidateAllowedDepositParams() { public void invalidateAllowedDepositParams() {
final Optional<List<Request>> deposits = Optional.empty(); final Optional<List<Request>> depositRequests = Optional.empty();
assertThat(depositsValidator.validateParameter(deposits)).isFalse(); assertThat(depositRequestValidator.validateParameter(depositRequests)).isFalse();
} }
static RequestsValidatorCoordinator createAllowDepositValidator() { static RequestsValidatorCoordinator createAllowDepositValidator() {
depositsValidator = new DepositsValidator(DEPOSIT_CONTRACT_ADDRESS); depositRequestValidator = new DepositRequestValidator(DEPOSIT_CONTRACT_ADDRESS);
return new RequestsValidatorCoordinator.Builder() return new RequestsValidatorCoordinator.Builder()
.addValidator(RequestType.WITHDRAWAL, new WithdrawalRequestValidator()) .addValidator(RequestType.WITHDRAWAL, new WithdrawalRequestValidator())
.addValidator(RequestType.DEPOSIT, depositsValidator) .addValidator(RequestType.DEPOSIT, depositRequestValidator)
.build(); .build();
} }
} }

@ -28,7 +28,7 @@ import org.hyperledger.besu.ethereum.core.BlockDataGenerator;
import org.hyperledger.besu.ethereum.core.BlockDataGenerator.BlockOptions; import org.hyperledger.besu.ethereum.core.BlockDataGenerator.BlockOptions;
import org.hyperledger.besu.ethereum.core.BlockchainSetupUtil; import org.hyperledger.besu.ethereum.core.BlockchainSetupUtil;
import org.hyperledger.besu.ethereum.core.Withdrawal; import org.hyperledger.besu.ethereum.core.Withdrawal;
import org.hyperledger.besu.ethereum.mainnet.requests.DepositsValidator; import org.hyperledger.besu.ethereum.mainnet.requests.DepositRequestValidator;
import org.hyperledger.besu.ethereum.mainnet.requests.RequestsValidatorCoordinator; import org.hyperledger.besu.ethereum.mainnet.requests.RequestsValidatorCoordinator;
import org.hyperledger.besu.evm.log.LogsBloomFilter; import org.hyperledger.besu.evm.log.LogsBloomFilter;
@ -53,7 +53,7 @@ class MainnetBlockBodyValidatorTest {
@Mock private ProtocolSchedule protocolSchedule; @Mock private ProtocolSchedule protocolSchedule;
@Mock private ProtocolSpec protocolSpec; @Mock private ProtocolSpec protocolSpec;
@Mock private WithdrawalsValidator withdrawalsValidator; @Mock private WithdrawalsValidator withdrawalsValidator;
@Mock private DepositsValidator depositsValidator; @Mock private DepositRequestValidator depositRequestValidator;
@Mock private RequestsValidatorCoordinator requestValidator; @Mock private RequestsValidatorCoordinator requestValidator;
@BeforeEach @BeforeEach
@ -64,7 +64,9 @@ class MainnetBlockBodyValidatorTest {
lenient().when(withdrawalsValidator.validateWithdrawals(any())).thenReturn(true); lenient().when(withdrawalsValidator.validateWithdrawals(any())).thenReturn(true);
lenient().when(withdrawalsValidator.validateWithdrawalsRoot(any())).thenReturn(true); lenient().when(withdrawalsValidator.validateWithdrawalsRoot(any())).thenReturn(true);
lenient().when(depositsValidator.validateDeposits(any(), any(), any())).thenReturn(true); lenient()
.when(depositRequestValidator.validateDepositRequests(any(), any(), any()))
.thenReturn(true);
lenient().when(protocolSpec.getRequestsValidatorCoordinator()).thenReturn(requestValidator); lenient().when(protocolSpec.getRequestsValidatorCoordinator()).thenReturn(requestValidator);
lenient().when(requestValidator.validate(any(), any(), any())).thenReturn(true); lenient().when(requestValidator.validate(any(), any(), any())).thenReturn(true);

@ -24,7 +24,7 @@ import org.hyperledger.besu.datatypes.GWei;
import org.hyperledger.besu.ethereum.core.Block; import org.hyperledger.besu.ethereum.core.Block;
import org.hyperledger.besu.ethereum.core.BlockBody; import org.hyperledger.besu.ethereum.core.BlockBody;
import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.Deposit; import org.hyperledger.besu.ethereum.core.DepositRequest;
import org.hyperledger.besu.ethereum.core.Request; import org.hyperledger.besu.ethereum.core.Request;
import org.hyperledger.besu.ethereum.core.Withdrawal; import org.hyperledger.besu.ethereum.core.Withdrawal;
import org.hyperledger.besu.ethereum.core.WithdrawalRequest; import org.hyperledger.besu.ethereum.core.WithdrawalRequest;
@ -89,9 +89,9 @@ public class GetBodiesFromPeerTaskTest extends PeerMessageTaskTest<List<Block>>
} }
@Test @Test
public void assertBodyIdentifierUsesDepositsToGenerateBodyIdentifiers() { public void assertBodyIdentifierUsesDepositRequestsToGenerateBodyIdentifiers() {
final Request deposit = final Request deposit =
new Deposit( new DepositRequest(
BLSPublicKey.fromHexString( BLSPublicKey.fromHexString(
"0xb10a4a15bf67b328c9b101d09e5c6ee6672978fdad9ef0d9e2ceffaee99223555d8601f0cb3bcc4ce1af9864779a416e"), "0xb10a4a15bf67b328c9b101d09e5c6ee6672978fdad9ef0d9e2ceffaee99223555d8601f0cb3bcc4ce1af9864779a416e"),
Bytes32.fromHexString( Bytes32.fromHexString(

@ -32,7 +32,7 @@ import org.hyperledger.besu.datatypes.VersionedHash;
import org.hyperledger.besu.datatypes.Wei; import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.chain.Blockchain; import org.hyperledger.besu.ethereum.chain.Blockchain;
import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.Deposit; import org.hyperledger.besu.ethereum.core.DepositRequest;
import org.hyperledger.besu.ethereum.core.Request; import org.hyperledger.besu.ethereum.core.Request;
import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.core.TransactionReceipt; import org.hyperledger.besu.ethereum.core.TransactionReceipt;
@ -466,7 +466,7 @@ public class T8nExecutor {
resultObject.put("requestsRoot", requestRoot.toHexString()); resultObject.put("requestsRoot", requestRoot.toHexString());
var deposits = resultObject.putArray("depositRequests"); var deposits = resultObject.putArray("depositRequests");
RequestUtil.filterRequestsOfType(maybeRequests.orElse(List.of()), Deposit.class) RequestUtil.filterRequestsOfType(maybeRequests.orElse(List.of()), DepositRequest.class)
.forEach( .forEach(
deposit -> { deposit -> {
var obj = deposits.addObject(); var obj = deposits.addObject();

@ -70,7 +70,7 @@ Calculated : ${currentHash}
tasks.register('checkAPIChanges', FileStateChecker) { tasks.register('checkAPIChanges', FileStateChecker) {
description = "Checks that the API for the Plugin-API project does not change without deliberate thought" description = "Checks that the API for the Plugin-API project does not change without deliberate thought"
files = sourceSets.main.allJava.files files = sourceSets.main.allJava.files
knownHash = 'zgPAgf+ZxefbnCE9aYEQ5QoeBVsHySi3u+BlhHNHqn8=' knownHash = 'p8jZoKgvi9o8JpVLXTlwh9HoIot4A62hKFHwSOaTF+k='
} }
check.dependsOn('checkAPIChanges') check.dependsOn('checkAPIChanges')

@ -27,7 +27,7 @@ import org.apache.tuweni.units.bigints.UInt64;
* to beacon chain. * to beacon chain.
*/ */
@Unstable @Unstable
public interface Deposit { public interface DepositRequest {
/** /**
* Public key of the address that sends the deposit * Public key of the address that sends the deposit
Loading…
Cancel
Save