From 2df721619a61e0eb2c9bedb8e72bbedc21b50c07 Mon Sep 17 00:00:00 2001 From: Gabriel-Trintinalia Date: Wed, 29 May 2024 13:39:44 +1000 Subject: [PATCH] [MINOR] Rename deposit to depositRequest (#7145) Signed-off-by: Gabriel-Trintinalia --- .../engine/AbstractEngineNewPayload.java | 12 ++-- .../methods/engine/EngineNewPayloadV4.java | 2 +- ...eter.java => DepositRequestParameter.java} | 28 ++++---- .../parameters/EnginePayloadParameter.java | 12 ++-- .../results/EngineGetPayloadResultV4.java | 25 +++---- .../engine/AbstractEngineGetPayloadTest.java | 6 +- .../engine/AbstractEngineNewPayloadTest.java | 22 +++---- .../engine/EngineGetPayloadV4Test.java | 4 +- .../engine/EngineNewPayloadV3Test.java | 4 +- .../engine/EngineNewPayloadV4Test.java | 52 ++++++++------- .../DepositParameterTestFixture.java | 8 +-- ...> DepositRequestRequestParameterTest.java} | 14 ++-- .../AbstractBlockCreatorTest.java | 40 ++++++------ .../besu/ethereum/core/BlockBody.java | 2 +- .../{Deposit.java => DepositRequest.java} | 7 +- ...ecoder.java => DepositRequestDecoder.java} | 14 ++-- ...ncoder.java => DepositRequestEncoder.java} | 16 ++--- .../core/encoding/RequestDecoder.java | 2 +- .../core/encoding/RequestEncoder.java | 2 +- .../requests/DepositRequestProcessor.java | 13 ++-- ...ator.java => DepositRequestValidator.java} | 34 +++++----- .../requests/MainnetRequestsValidator.java | 2 +- .../mainnet/requests/RequestUtil.java | 15 +++-- ... => DepositRequestRequestDecoderTest.java} | 22 +++---- ... => DepositRequestRequestEncoderTest.java} | 14 ++-- ....java => DepositRequestValidatorTest.java} | 65 ++++++++++--------- .../MainnetBlockBodyValidatorTest.java | 8 ++- .../task/GetBodiesFromPeerTaskTest.java | 6 +- .../hyperledger/besu/evmtool/T8nExecutor.java | 4 +- plugin-api/build.gradle | 2 +- .../{Deposit.java => DepositRequest.java} | 2 +- 31 files changed, 237 insertions(+), 222 deletions(-) rename ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/{DepositParameter.java => DepositRequestParameter.java} (83%) rename ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/{DepositParameterTest.java => DepositRequestRequestParameterTest.java} (88%) rename ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/{Deposit.java => DepositRequest.java} (94%) rename ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/{DepositDecoder.java => DepositRequestDecoder.java} (86%) rename ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/{DepositEncoder.java => DepositRequestEncoder.java} (73%) rename ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/{DepositsValidator.java => DepositRequestValidator.java} (68%) rename ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/encoding/{DepositDecoderTest.java => DepositRequestRequestDecoderTest.java} (88%) rename ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/encoding/{DepositEncoderTest.java => DepositRequestRequestEncoderTest.java} (87%) rename ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/{DepositsValidatorTest.java => DepositRequestValidatorTest.java} (83%) rename plugin-api/src/main/java/org/hyperledger/besu/plugin/data/{Deposit.java => DepositRequest.java} (98%) diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/AbstractEngineNewPayload.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/AbstractEngineNewPayload.java index d2faf8e7d86..e8134fdb1a5 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/AbstractEngineNewPayload.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/AbstractEngineNewPayload.java @@ -35,7 +35,7 @@ import org.hyperledger.besu.ethereum.ProtocolContext; 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.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.WithdrawalParameter; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.WithdrawalRequestParameter; @@ -161,12 +161,12 @@ public JsonRpcResponse syncResponse(final JsonRpcRequestContext requestContext) reqId, new JsonRpcError(INVALID_PARAMS, "Invalid withdrawals")); } - final Optional> maybeDeposits = - Optional.ofNullable(blockParam.getDeposits()) - .map(ds -> ds.stream().map(DepositParameter::toDeposit).collect(toList())); + final Optional> maybeDepositRequests = + Optional.ofNullable(blockParam.getDepositRequests()) + .map(ds -> ds.stream().map(DepositRequestParameter::toDeposit).collect(toList())); if (!getDepositRequestValidator( protocolSchedule.get(), blockParam.getTimestamp(), blockParam.getBlockNumber()) - .validateParameter(maybeDeposits)) { + .validateParameter(maybeDepositRequests)) { return new JsonRpcErrorResponse( reqId, new JsonRpcError(INVALID_PARAMS, "Invalid deposit request")); } @@ -186,7 +186,7 @@ public JsonRpcResponse syncResponse(final JsonRpcRequestContext requestContext) } Optional> maybeRequests = - RequestUtil.combine(maybeDeposits, maybeWithdrawalRequests); + RequestUtil.combine(maybeDepositRequests, maybeWithdrawalRequests); if (mergeContext.get().isSyncing()) { LOG.debug("We are syncing"); diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV4.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV4.java index 83d406106fd..93060821f80 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV4.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV4.java @@ -63,7 +63,7 @@ protected ValidationResult validateParameters( } else if (maybeBeaconBlockRootParam.isEmpty()) { return ValidationResult.invalid( 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"); } else { return ValidationResult.valid(); diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/DepositParameter.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/DepositRequestParameter.java similarity index 83% rename from ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/DepositParameter.java rename to ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/DepositRequestParameter.java index e2a3a4d207d..39d6476ca46 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/DepositParameter.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/DepositRequestParameter.java @@ -17,7 +17,7 @@ import org.hyperledger.besu.datatypes.BLSPublicKey; import org.hyperledger.besu.datatypes.BLSSignature; import org.hyperledger.besu.datatypes.GWei; -import org.hyperledger.besu.ethereum.core.Deposit; +import org.hyperledger.besu.ethereum.core.DepositRequest; import java.util.Objects; @@ -28,7 +28,7 @@ import org.apache.tuweni.bytes.Bytes32; import org.apache.tuweni.units.bigints.UInt64; -public class DepositParameter { +public class DepositRequestParameter { private final String pubkey; @@ -39,7 +39,7 @@ public class DepositParameter { private final String index; @JsonCreator - public DepositParameter( + public DepositRequestParameter( @JsonProperty("pubkey") final String pubkey, @JsonProperty("withdrawalCredentials") final String withdrawalCredentials, @JsonProperty("amount") final String amount, @@ -52,17 +52,17 @@ public DepositParameter( this.index = index; } - public static DepositParameter fromDeposit(final Deposit deposit) { - return new DepositParameter( - deposit.getPubkey().toString(), - deposit.getWithdrawalCredentials().toString(), - deposit.getAmount().toShortHexString(), - deposit.getSignature().toString(), - deposit.getIndex().toBytes().toQuantityHexString()); + public static DepositRequestParameter fromDeposit(final DepositRequest depositRequest) { + return new DepositRequestParameter( + depositRequest.getPubkey().toString(), + depositRequest.getWithdrawalCredentials().toString(), + depositRequest.getAmount().toShortHexString(), + depositRequest.getSignature().toString(), + depositRequest.getIndex().toBytes().toQuantityHexString()); } - public Deposit toDeposit() { - return new Deposit( + public DepositRequest toDeposit() { + return new DepositRequest( BLSPublicKey.fromHexString(pubkey), Bytes32.fromHexString(withdrawalCredentials), GWei.fromHexString(amount), @@ -108,7 +108,7 @@ public String getIndex() { public boolean equals(final Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; - final DepositParameter that = (DepositParameter) o; + final DepositRequestParameter that = (DepositRequestParameter) o; return Objects.equals(pubkey, that.pubkey) && Objects.equals(withdrawalCredentials, that.withdrawalCredentials) && Objects.equals(amount, that.amount) @@ -123,7 +123,7 @@ public int hashCode() { @Override public String toString() { - return "DepositParameter{" + return "DepositRequestParameter{" + "pubKey='" + pubkey + '\'' diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/EnginePayloadParameter.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/EnginePayloadParameter.java index a264c60edf3..4fd24e15a6f 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/EnginePayloadParameter.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/EnginePayloadParameter.java @@ -43,7 +43,7 @@ public class EnginePayloadParameter { private final List withdrawals; private final Long blobGasUsed; private final String excessBlobGas; - private final List deposits; + private final List depositRequests; private final List withdrawalRequests; /** @@ -66,7 +66,7 @@ public class EnginePayloadParameter { * @param withdrawals Array of Withdrawal * @param blobGasUsed 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. */ @JsonCreator @@ -88,7 +88,7 @@ public EnginePayloadParameter( @JsonProperty("withdrawals") final List withdrawals, @JsonProperty("blobGasUsed") final UnsignedLongParameter blobGasUsed, @JsonProperty("excessBlobGas") final String excessBlobGas, - @JsonProperty("depositRequests") final List deposits, + @JsonProperty("depositRequests") final List depositRequests, @JsonProperty("withdrawalRequests") final List withdrawalRequestParameters) { this.blockHash = blockHash; @@ -108,7 +108,7 @@ public EnginePayloadParameter( this.withdrawals = withdrawals; this.blobGasUsed = blobGasUsed == null ? null : blobGasUsed.getValue(); this.excessBlobGas = excessBlobGas; - this.deposits = deposits; + this.depositRequests = depositRequests; this.withdrawalRequests = withdrawalRequestParameters; } @@ -180,8 +180,8 @@ public String getExcessBlobGas() { return excessBlobGas; } - public List getDeposits() { - return deposits; + public List getDepositRequests() { + return depositRequests; } public List getWithdrawalRequests() { diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/EngineGetPayloadResultV4.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/EngineGetPayloadResultV4.java index 03a5082dad7..133fbabe609 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/EngineGetPayloadResultV4.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/EngineGetPayloadResultV4.java @@ -14,11 +14,11 @@ */ 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.WithdrawalRequestParameter; 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.WithdrawalRequest; @@ -42,12 +42,12 @@ public EngineGetPayloadResultV4( final BlockHeader header, final List transactions, final Optional> withdrawals, - final Optional> deposits, + final Optional> depositRequests, final Optional> withdrawalRequests, final String blockValue, final BlobsBundleV1 blobsBundle) { this.executionPayload = - new PayloadResult(header, transactions, withdrawals, deposits, withdrawalRequests); + new PayloadResult(header, transactions, withdrawals, depositRequests, withdrawalRequests); this.blockValue = blockValue; this.blobsBundle = blobsBundle; this.shouldOverrideBuilder = false; @@ -94,14 +94,14 @@ public static class PayloadResult { protected final List transactions; private final List withdrawals; - private final List deposits; + private final List depositRequests; private final List withdrawalRequests; public PayloadResult( final BlockHeader header, final List transactions, final Optional> withdrawals, - final Optional> deposits, + final Optional> depositRequests, final Optional> withdrawalRequests) { this.blockNumber = Quantity.create(header.getNumber()); this.blockHash = header.getHash().toString(); @@ -125,10 +125,13 @@ public PayloadResult( .map(WithdrawalParameter::fromWithdrawal) .collect(Collectors.toList())) .orElse(null); - this.deposits = - deposits + this.depositRequests = + depositRequests .map( - ds -> ds.stream().map(DepositParameter::fromDeposit).collect(Collectors.toList())) + ds -> + ds.stream() + .map(DepositRequestParameter::fromDeposit) + .collect(Collectors.toList())) .orElse(null); this.withdrawalRequests = withdrawalRequests @@ -216,8 +219,8 @@ public List getWithdrawals() { } @JsonGetter(value = "depositRequests") - public List getDeposits() { - return deposits; + public List getDepositRequests() { + return depositRequests; } @JsonGetter(value = "withdrawalRequests") diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/AbstractEngineGetPayloadTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/AbstractEngineGetPayloadTest.java index f0479bd7d2e..77952f6dc69 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/AbstractEngineGetPayloadTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/AbstractEngineGetPayloadTest.java @@ -105,7 +105,7 @@ public AbstractEngineGetPayloadTest() { Collections.emptyList(), Optional.of(Collections.emptyList()), Optional.empty())); - private static final Block mockBlockWithDeposits = + private static final Block mockBlockWithDepositRequests = new Block( mockHeader, new BlockBody( @@ -116,8 +116,8 @@ public AbstractEngineGetPayloadTest() { protected static final BlockWithReceipts mockBlockWithReceiptsAndWithdrawals = new BlockWithReceipts(mockBlockWithWithdrawals, Collections.emptyList()); - protected static final BlockWithReceipts mockBlockWithReceiptsAndDeposits = - new BlockWithReceipts(mockBlockWithDeposits, Collections.emptyList()); + protected static final BlockWithReceipts mockBlockWithReceiptsAndDepositRequests = + new BlockWithReceipts(mockBlockWithDepositRequests, Collections.emptyList()); @Mock protected ProtocolContext protocolContext; diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/AbstractEngineNewPayloadTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/AbstractEngineNewPayloadTest.java index dba31f7f0d6..26d0dad955d 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/AbstractEngineNewPayloadTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/AbstractEngineNewPayloadTest.java @@ -38,7 +38,7 @@ 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.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.UnsignedLongParameter; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.WithdrawalParameter; @@ -54,7 +54,7 @@ import org.hyperledger.besu.ethereum.core.BlockBody; import org.hyperledger.besu.ethereum.core.BlockHeader; 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.Withdrawal; import org.hyperledger.besu.ethereum.core.WithdrawalRequest; @@ -410,7 +410,7 @@ protected EnginePayloadParameter mockEnginePayload( final BlockHeader header, final List txs, final List withdrawals, - final List deposits, + final List depositRequests, final List withdrawalRequests) { return new EnginePayloadParameter( header.getHash(), @@ -430,18 +430,18 @@ protected EnginePayloadParameter mockEnginePayload( withdrawals, header.getBlobGasUsed().map(UnsignedLongParameter::new).orElse(null), header.getExcessBlobGas().map(BlobGas::toHexString).orElse(null), - deposits, + depositRequests, withdrawalRequests); } protected BlockHeader setupValidPayload( final BlockProcessingResult value, final Optional> maybeWithdrawals, - final Optional> maybeDeposits, + final Optional> maybeDepositRequests, final Optional> maybeWithdrawalRequests) { BlockHeader mockHeader = - createBlockHeader(maybeWithdrawals, maybeDeposits, maybeWithdrawalRequests); + createBlockHeader(maybeWithdrawals, maybeDepositRequests, maybeWithdrawalRequests); when(blockchain.getBlockByHash(mockHeader.getHash())).thenReturn(Optional.empty()); // when(blockchain.getBlockHeader(mockHeader.getParentHash())) // .thenReturn(Optional.of(mock(BlockHeader.class))); @@ -474,21 +474,21 @@ protected JsonRpcError fromErrorResp(final JsonRpcResponse resp) { protected BlockHeader createBlockHeader( final Optional> maybeWithdrawals, - final Optional> maybeDeposits, + final Optional> maybeDepositRequests, final Optional> maybeWithdrawalRequests) { - return createBlockHeaderFixture(maybeWithdrawals, maybeDeposits, maybeWithdrawalRequests) + return createBlockHeaderFixture(maybeWithdrawals, maybeDepositRequests, maybeWithdrawalRequests) .buildHeader(); } protected BlockHeaderTestFixture createBlockHeaderFixture( final Optional> maybeWithdrawals, - final Optional> maybeDeposits, + final Optional> maybeDepositRequests, final Optional> maybeWithdrawalRequests) { Optional> maybeRequests; - if (maybeDeposits.isPresent() || maybeWithdrawalRequests.isPresent()) { + if (maybeDepositRequests.isPresent() || maybeWithdrawalRequests.isPresent()) { List requests = new ArrayList<>(); - maybeDeposits.ifPresent(requests::addAll); + maybeDepositRequests.ifPresent(requests::addAll); maybeWithdrawalRequests.ifPresent(requests::addAll); maybeRequests = Optional.of(requests); } else { diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadV4Test.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadV4Test.java index 68828619c90..e8e4e821a37 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadV4Test.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineGetPayloadV4Test.java @@ -71,7 +71,7 @@ public void before() { super.before(); lenient() .when(mergeContext.retrieveBlockById(mockPid)) - .thenReturn(Optional.of(mockBlockWithReceiptsAndDeposits)); + .thenReturn(Optional.of(mockBlockWithReceiptsAndDepositRequests)); when(protocolContext.safeConsensusContext(Mockito.any())).thenReturn(Optional.of(mergeContext)); this.method = new EngineGetPayloadV4( @@ -146,7 +146,7 @@ public void shouldReturnBlockForKnownPayloadId() { assertThat(r.getResult()).isInstanceOf(EngineGetPayloadResultV4.class); final EngineGetPayloadResultV4 res = (EngineGetPayloadResultV4) r.getResult(); assertThat(res.getExecutionPayload().getWithdrawals()).isNotNull(); - assertThat(res.getExecutionPayload().getDeposits()).isNotNull(); + assertThat(res.getExecutionPayload().getDepositRequests()).isNotNull(); assertThat(res.getExecutionPayload().getWithdrawalRequests()).isNotNull(); assertThat(res.getExecutionPayload().getHash()) .isEqualTo(header.getHash().toString()); diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV3Test.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV3Test.java index 4604c8487c1..98a71ebf35d 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV3Test.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV3Test.java @@ -44,7 +44,7 @@ import org.hyperledger.besu.ethereum.core.BlobTestFixture; import org.hyperledger.besu.ethereum.core.BlockHeader; 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.TransactionTestFixture; import org.hyperledger.besu.ethereum.core.Withdrawal; @@ -150,7 +150,7 @@ public void shouldValidVersionedHash_whenListIsEmpty() { @Override protected BlockHeader createBlockHeader( final Optional> maybeWithdrawals, - final Optional> maybeDeposits, + final Optional> maybeDepositRequests, final Optional> maybeWithdrawalRequests) { BlockHeader parentBlockHeader = new BlockHeaderTestFixture() diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV4Test.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV4Test.java index 276eaf6b611..86b096cf1e8 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV4Test.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV4Test.java @@ -33,19 +33,19 @@ import org.hyperledger.besu.ethereum.BlockProcessingResult; 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.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.WithdrawalRequestParameter; 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.core.BlockHeader; 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.Withdrawal; import org.hyperledger.besu.ethereum.core.WithdrawalRequest; 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.WithdrawalRequestValidator; import org.hyperledger.besu.evm.gascalculator.PragueGasCalculator; @@ -92,8 +92,8 @@ public void shouldReturnExpectedMethodName() { } @Test - public void shouldReturnValidIfDepositsIsNull_WhenDepositsProhibited() { - final List deposits = null; + public void shouldReturnValidIfDepositRequestsIsNull_WhenDepositRequestsProhibited() { + final List depositRequests = null; mockProhibitedRequestsValidator(); BlockHeader mockHeader = @@ -108,22 +108,23 @@ public void shouldReturnValidIfDepositsIsNull_WhenDepositsProhibited() { when(mergeCoordinator.getLatestValidAncestor(mockHeader)) .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); } @Test - public void shouldReturnInvalidIfDepositsIsNull_WhenDepositsAllowed() { - final List deposits = null; - mockAllowedDepositsRequestValidator(); + public void shouldReturnInvalidIfDepositRequestsIsNull_WhenDepositRequestsAllowed() { + final List depositRequests = null; + mockAllowedDepositRequestsRequestValidator(); var resp = resp( mockEnginePayload( createBlockHeader(Optional.empty(), Optional.empty(), Optional.empty()), Collections.emptyList(), null, - deposits, + depositRequests, null)); assertThat(fromErrorResp(resp).getCode()).isEqualTo(INVALID_PARAMS.getCode()); @@ -131,15 +132,16 @@ public void shouldReturnInvalidIfDepositsIsNull_WhenDepositsAllowed() { } @Test - public void shouldReturnValidIfDepositsIsNotNull_WhenDepositsAllowed() { - final List depositsParam = List.of(DEPOSIT_PARAM_1); - final List deposits = List.of(DEPOSIT_PARAM_1.toDeposit()); + public void shouldReturnValidIfDepositRequestsIsNotNull_WhenDepositRequestsAllowed() { + final List depositRequestsParam = List.of(DEPOSIT_PARAM_1); + final List depositRequests = List.of(DEPOSIT_PARAM_1.toDeposit()); - mockAllowedDepositsRequestValidator(); + mockAllowedDepositRequestsRequestValidator(); BlockHeader mockHeader = setupValidPayload( 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.of(List.of(DEPOSIT_PARAM_1.toDeposit())), Optional.empty()); @@ -148,14 +150,16 @@ public void shouldReturnValidIfDepositsIsNotNull_WhenDepositsAllowed() { when(mergeCoordinator.getLatestValidAncestor(mockHeader)) .thenReturn(Optional.of(mockHeader.getHash())); var resp = - resp(mockEnginePayload(mockHeader, Collections.emptyList(), null, depositsParam, null)); + resp( + mockEnginePayload( + mockHeader, Collections.emptyList(), null, depositRequestsParam, null)); assertValidResponse(mockHeader, resp); } @Test - public void shouldReturnInvalidIfDepositsIsNotNull_WhenDepositsProhibited() { - final List deposits = List.of(); + public void shouldReturnInvalidIfDepositRequestsIsNotNull_WhenDepositRequestsProhibited() { + final List depositRequests = List.of(); lenient() .when(protocolSpec.getRequestsValidatorCoordinator()) .thenReturn(RequestsValidatorCoordinator.empty()); @@ -167,7 +171,7 @@ public void shouldReturnInvalidIfDepositsIsNotNull_WhenDepositsProhibited() { Optional.empty(), Optional.of(Collections.emptyList()), Optional.empty()), Collections.emptyList(), null, - deposits, + depositRequests, null)); final JsonRpcError jsonRpcError = fromErrorResp(resp); @@ -264,7 +268,7 @@ public void shouldReturnValidIfWithdrawalRequestsIsNotNull_WhenWithdrawalRequest @Override protected BlockHeader createBlockHeader( final Optional> maybeWithdrawals, - final Optional> maybeDeposits, + final Optional> maybeDepositRequests, final Optional> maybeWithdrawalRequests) { BlockHeader parentBlockHeader = new BlockHeaderTestFixture() @@ -275,9 +279,9 @@ protected BlockHeader createBlockHeader( .buildHeader(); Optional> maybeRequests; - if (maybeDeposits.isPresent() || maybeWithdrawalRequests.isPresent()) { + if (maybeDepositRequests.isPresent() || maybeWithdrawalRequests.isPresent()) { List requests = new ArrayList<>(); - maybeDeposits.ifPresent(requests::addAll); + maybeDepositRequests.ifPresent(requests::addAll); maybeWithdrawalRequests.ifPresent(requests::addAll); maybeRequests = Optional.of(requests); } else { @@ -315,10 +319,10 @@ private void mockProhibitedRequestsValidator() { when(protocolSpec.getRequestsValidatorCoordinator()).thenReturn(validator); } - private void mockAllowedDepositsRequestValidator() { + private void mockAllowedDepositRequestsRequestValidator() { var validator = new RequestsValidatorCoordinator.Builder() - .addValidator(RequestType.DEPOSIT, new DepositsValidator(depositContractAddress)) + .addValidator(RequestType.DEPOSIT, new DepositRequestValidator(depositContractAddress)) .build(); when(protocolSpec.getRequestsValidatorCoordinator()).thenReturn(validator); } diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/DepositParameterTestFixture.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/DepositParameterTestFixture.java index 575b73c73b3..f3f5f420bbb 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/DepositParameterTestFixture.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/DepositParameterTestFixture.java @@ -16,14 +16,14 @@ public class DepositParameterTestFixture { - public static final DepositParameter DEPOSIT_PARAM_1 = + public static final DepositRequestParameter DEPOSIT_PARAM_1 = createDeposit( "0xb10a4a15bf67b328c9b101d09e5c6ee6672978fdad9ef0d9e2ceffaee99223555d8601f0cb3bcc4ce1af9864779a416e", "0x0017a7fcf06faf493d30bbe2632ea7c2383cd86825e12797165de7aa35589483", "0x773594000", "0xa889db8300194050a2636c92a95bc7160515867614b7971a9500cdb62f9c0890217d2901c3241f86fac029428fc106930606154bd9e406d7588934a5f15b837180b17194d6e44bd6de23e43b163dfe12e369dcc75a3852cd997963f158217eb5", "0x1"); - static final DepositParameter DEPOSIT_PARAM_2 = + static final DepositRequestParameter DEPOSIT_PARAM_2 = createDeposit( "0x8706d19a62f28a6a6549f96c5adaebac9124a61d44868ec94f6d2d707c6a2f82c9162071231dfeb40e24bfde4ffdf243", "0x006a8dc800c6d8dd6977ef53264e2d030350f0145a91bcd167b4f1c3ea21b271", @@ -31,12 +31,12 @@ public class DepositParameterTestFixture { "0x801b08ca107b623eca32ee9f9111b4e50eb9cfe19e38204b72de7dc04c5a5e00f61bab96f10842576f66020ce851083f1583dd9a6b73301bea6c245cf51f27cf96aeb018852c5f70bf485d16b957cfe49ca008913346b431e7653ae3ddb23b07", "0x3"); - private static DepositParameter createDeposit( + private static DepositRequestParameter createDeposit( final String pubKey, final String withdrawalCredentials, final String amount, final String signature, final String index) { - return new DepositParameter(pubKey, withdrawalCredentials, amount, signature, index); + return new DepositRequestParameter(pubKey, withdrawalCredentials, amount, signature, index); } } diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/DepositParameterTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/DepositRequestRequestParameterTest.java similarity index 88% rename from ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/DepositParameterTest.java rename to ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/DepositRequestRequestParameterTest.java index 56dfed3fd4b..ce5780641be 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/DepositParameterTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/DepositRequestRequestParameterTest.java @@ -20,18 +20,18 @@ import org.hyperledger.besu.datatypes.BLSPublicKey; import org.hyperledger.besu.datatypes.BLSSignature; 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.units.bigints.UInt64; import org.junit.jupiter.api.Test; -public class DepositParameterTest { +public class DepositRequestRequestParameterTest { @Test public void toDeposit() { - Deposit expected = - new Deposit( + DepositRequest expected = + new DepositRequest( BLSPublicKey.fromHexString( "0xb10a4a15bf67b328c9b101d09e5c6ee6672978fdad9ef0d9e2ceffaee99223555d8601f0cb3bcc4ce1af9864779a416e"), Bytes32.fromHexString( @@ -45,8 +45,8 @@ public void toDeposit() { @Test public void fromDeposit() { - Deposit deposit = - new Deposit( + DepositRequest depositRequest = + new DepositRequest( BLSPublicKey.fromHexString( "0xb10a4a15bf67b328c9b101d09e5c6ee6672978fdad9ef0d9e2ceffaee99223555d8601f0cb3bcc4ce1af9864779a416e"), Bytes32.fromHexString( @@ -56,6 +56,6 @@ public void fromDeposit() { "0xa889db8300194050a2636c92a95bc7160515867614b7971a9500cdb62f9c0890217d2901c3241f86fac029428fc106930606154bd9e406d7588934a5f15b837180b17194d6e44bd6de23e43b163dfe12e369dcc75a3852cd997963f158217eb5"), UInt64.ONE); - assertThat(DepositParameter.fromDeposit(deposit)).isEqualTo(DEPOSIT_PARAM_1); + assertThat(DepositRequestParameter.fromDeposit(depositRequest)).isEqualTo(DEPOSIT_PARAM_1); } } diff --git a/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/AbstractBlockCreatorTest.java b/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/AbstractBlockCreatorTest.java index 103b8fdb667..856bf874b20 100644 --- a/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/AbstractBlockCreatorTest.java +++ b/ethereum/blockcreation/src/test/java/org/hyperledger/besu/ethereum/blockcreation/AbstractBlockCreatorTest.java @@ -47,7 +47,7 @@ import org.hyperledger.besu.ethereum.core.BlockDataGenerator; import org.hyperledger.besu.ethereum.core.BlockHeader; 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.ExecutionContextTestFixture; import org.hyperledger.besu.ethereum.core.ImmutableMiningParameters; @@ -76,7 +76,7 @@ import org.hyperledger.besu.ethereum.mainnet.WithdrawalsProcessor; import org.hyperledger.besu.ethereum.mainnet.feemarket.CancunFeeMarket; 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.RequestsValidatorCoordinator; import org.hyperledger.besu.evm.internal.EvmConfiguration; @@ -106,7 +106,7 @@ abstract class AbstractBlockCreatorTest { protected EthScheduler ethScheduler = new DeterministicEthScheduler(); @Test - void findDepositsFromReceipts() { + void findDepositRequestsFromReceipts() { BlockDataGenerator blockDataGenerator = new BlockDataGenerator(); TransactionReceipt receiptWithoutDeposit1 = blockDataGenerator.receipt(); TransactionReceipt receiptWithoutDeposit2 = blockDataGenerator.receipt(); @@ -122,8 +122,8 @@ void findDepositsFromReceipts() { List receipts = List.of(receiptWithoutDeposit1, receiptWithDeposit, receiptWithoutDeposit2); - Deposit expectedDeposit = - new Deposit( + DepositRequest expectedDepositRequest = + new DepositRequest( BLSPublicKey.fromHexString( "0xb10a4a15bf67b328c9b101d09e5c6ee6672978fdad9ef0d9e2ceffaee99223555d8601f0cb3bcc4ce1af9864779a416e"), Bytes32.fromHexString( @@ -132,17 +132,17 @@ void findDepositsFromReceipts() { BLSSignature.fromHexString( "0xa889db8300194050a2636c92a95bc7160515867614b7971a9500cdb62f9c0890217d2901c3241f86fac029428fc106930606154bd9e406d7588934a5f15b837180b17194d6e44bd6de23e43b163dfe12e369dcc75a3852cd997963f158217eb5"), UInt64.valueOf(539967)); - final List expectedDeposits = List.of(expectedDeposit); + final List expectedDepositRequests = List.of(expectedDepositRequest); - var depositsFromReceipts = + var depositRequestsFromReceipts = new DepositRequestProcessor(DEFAULT_DEPOSIT_CONTRACT_ADDRESS).process(null, receipts); - assertThat(depositsFromReceipts.get()).isEqualTo(expectedDeposits); + assertThat(depositRequestsFromReceipts.get()).isEqualTo(expectedDepositRequests); } @Test - void withAllowedDepositsAndContractAddress_DepositsAreParsed() { + void withAllowedDepositRequestsAndContractAddress_DepositRequestsAreParsed() { final AbstractBlockCreator blockCreator = - blockCreatorWithAllowedDeposits(DEFAULT_DEPOSIT_CONTRACT_ADDRESS); + blockCreatorWithAllowedDepositRequests(DEFAULT_DEPOSIT_CONTRACT_ADDRESS); final BlockCreationResult blockCreationResult = blockCreator.createBlock( @@ -154,15 +154,15 @@ void withAllowedDepositsAndContractAddress_DepositsAreParsed() { 1L, false); - List deposits = emptyList(); - final Hash requestsRoot = BodyValidation.requestsRoot(deposits); + List depositRequests = emptyList(); + final Hash requestsRoot = BodyValidation.requestsRoot(depositRequests); assertThat(blockCreationResult.getBlock().getHeader().getRequestsRoot()).hasValue(requestsRoot); - assertThat(blockCreationResult.getBlock().getBody().getRequests()).hasValue(deposits); + assertThat(blockCreationResult.getBlock().getBody().getRequests()).hasValue(depositRequests); } @Test - void withAllowedDepositsAndNoContractAddress_DepositsAreNotParsed() { - final AbstractBlockCreator blockCreator = blockCreatorWithAllowedDeposits(null); + void withAllowedDepositRequestsAndNoContractAddress_DepositRequestsAreNotParsed() { + final AbstractBlockCreator blockCreator = blockCreatorWithAllowedDepositRequests(null); final BlockCreationResult blockCreationResult = blockCreator.createBlock( @@ -179,8 +179,8 @@ void withAllowedDepositsAndNoContractAddress_DepositsAreNotParsed() { } @Test - void withProhibitedDeposits_DepositsAreNotParsed() { - final AbstractBlockCreator blockCreator = blockCreatorWithProhibitedDeposits(); + void withProhibitedDepositRequests_DepositRequestsAreNotParsed() { + final AbstractBlockCreator blockCreator = blockCreatorWithProhibitedDepositRequests(); final BlockCreationResult blockCreationResult = blockCreator.createBlock( @@ -196,7 +196,7 @@ void withProhibitedDeposits_DepositsAreNotParsed() { assertThat(blockCreationResult.getBlock().getBody().getRequests()).isEmpty(); } - private AbstractBlockCreator blockCreatorWithAllowedDeposits( + private AbstractBlockCreator blockCreatorWithAllowedDepositRequests( final Address depositContractAddress) { final ProtocolSpecAdapters protocolSpecAdapters = ProtocolSpecAdapters.create( @@ -207,7 +207,7 @@ private AbstractBlockCreator blockCreatorWithAllowedDeposits( new RequestsValidatorCoordinator.Builder() .addValidator( RequestType.DEPOSIT, - new DepositsValidator((depositContractAddress))) + new DepositRequestValidator((depositContractAddress))) .build()) .requestProcessorCoordinator( new RequestProcessorCoordinator.Builder() @@ -218,7 +218,7 @@ private AbstractBlockCreator blockCreatorWithAllowedDeposits( return createBlockCreator(protocolSpecAdapters); } - private AbstractBlockCreator blockCreatorWithProhibitedDeposits() { + private AbstractBlockCreator blockCreatorWithProhibitedDepositRequests() { final ProtocolSpecAdapters protocolSpecAdapters = ProtocolSpecAdapters.create(0, specBuilder -> specBuilder); return createBlockCreator(protocolSpecAdapters); diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/BlockBody.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/BlockBody.java index c14722edc24..4b8ab926137 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/BlockBody.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/BlockBody.java @@ -147,7 +147,7 @@ public static BlockBody readWrappedBodyFrom( /** * 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 * * @param input The RLP-encoded input diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/Deposit.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/DepositRequest.java similarity index 94% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/Deposit.java rename to ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/DepositRequest.java index 6a6476069e3..a005fa831e0 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/Deposit.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/DepositRequest.java @@ -25,7 +25,8 @@ import org.apache.tuweni.bytes.Bytes32; 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 Bytes32 depositWithdrawalCredentials; @@ -33,7 +34,7 @@ public class Deposit extends Request implements org.hyperledger.besu.plugin.data private final BLSSignature signature; private final UInt64 index; - public Deposit( + public DepositRequest( final BLSPublicKey pubkey, final Bytes32 depositWithdrawalCredentials, final GWei amount, @@ -96,7 +97,7 @@ public String toString() { public boolean equals(final Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; - final Deposit that = (Deposit) o; + final DepositRequest that = (DepositRequest) o; return Objects.equals(pubkey, that.pubkey) && Objects.equals(depositWithdrawalCredentials, that.depositWithdrawalCredentials) && Objects.equals(amount, that.amount) diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/DepositDecoder.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/DepositRequestDecoder.java similarity index 86% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/DepositDecoder.java rename to ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/DepositRequestDecoder.java index 05fd5498e96..85b56e1a573 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/DepositDecoder.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/DepositRequestDecoder.java @@ -17,8 +17,8 @@ import org.hyperledger.besu.datatypes.BLSPublicKey; import org.hyperledger.besu.datatypes.BLSSignature; 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.DepositRequest; import org.hyperledger.besu.ethereum.rlp.RLP; import org.hyperledger.besu.ethereum.rlp.RLPInput; import org.hyperledger.besu.evm.log.Log; @@ -30,9 +30,9 @@ import org.apache.tuweni.units.bigints.UInt64; 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(); final BLSPublicKey publicKey = BLSPublicKey.readFrom(rlpInput); final Bytes32 depositWithdrawalCredential = Bytes32.wrap(rlpInput.readBytes()); @@ -41,10 +41,10 @@ public static Deposit decode(final RLPInput rlpInput) { final UInt64 index = UInt64.valueOf(rlpInput.readBigIntegerScalar()); 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); final byte[] rawPublicKey = (byte[]) eventValues.getNonIndexedValues().get(0).getValue(); final byte[] rawWithdrawalCredential = @@ -53,7 +53,7 @@ public static Deposit decodeFromLog(final Log log) { final byte[] rawSignature = (byte[]) eventValues.getNonIndexedValues().get(3).getValue(); final byte[] rawIndex = (byte[]) eventValues.getNonIndexedValues().get(4).getValue(); - return new Deposit( + return new DepositRequest( BLSPublicKey.wrap(Bytes.wrap(rawPublicKey)), Bytes32.wrap(Bytes.wrap(rawWithdrawalCredential)), GWei.of( @@ -64,7 +64,7 @@ public static Deposit decodeFromLog(final Log log) { 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)); } } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/DepositEncoder.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/DepositRequestEncoder.java similarity index 73% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/DepositEncoder.java rename to ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/DepositRequestEncoder.java index f40a28a6320..a99b0b761ce 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/DepositEncoder.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/DepositRequestEncoder.java @@ -14,25 +14,25 @@ */ 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.rlp.RLP; import org.hyperledger.besu.ethereum.rlp.RLPOutput; import org.apache.tuweni.bytes.Bytes; -public class DepositEncoder { +public class DepositRequestEncoder { 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."); } rlpOutput.startList(); - rlpOutput.writeBytes(deposit.getPubkey()); - rlpOutput.writeBytes(deposit.getWithdrawalCredentials()); - rlpOutput.writeUInt64Scalar(deposit.getAmount()); - rlpOutput.writeBytes(deposit.getSignature()); - rlpOutput.writeUInt64Scalar(deposit.getIndex()); + rlpOutput.writeBytes(depositRequest.getPubkey()); + rlpOutput.writeBytes(depositRequest.getWithdrawalCredentials()); + rlpOutput.writeUInt64Scalar(depositRequest.getAmount()); + rlpOutput.writeBytes(depositRequest.getSignature()); + rlpOutput.writeUInt64Scalar(depositRequest.getIndex()); rlpOutput.endList(); } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/RequestDecoder.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/RequestDecoder.java index 1eb85cc4aa8..4953cbb84ff 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/RequestDecoder.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/RequestDecoder.java @@ -41,7 +41,7 @@ interface Decoder { RequestType.WITHDRAWAL, WithdrawalRequestDecoder::decode, RequestType.DEPOSIT, - DepositDecoder::decode); + DepositRequestDecoder::decode); /** * Decodes a request from its RLP encoded bytes. diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/RequestEncoder.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/RequestEncoder.java index d62d924a3cb..4f79da453ca 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/RequestEncoder.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/RequestEncoder.java @@ -38,7 +38,7 @@ interface Encoder { RequestType.WITHDRAWAL, WithdrawalRequestEncoder::encode, RequestType.DEPOSIT, - DepositEncoder::encode); + DepositRequestEncoder::encode); /** * Encodes a Request into the provided RLPOutput. diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/DepositRequestProcessor.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/DepositRequestProcessor.java index 766ce1f94e0..ce3ed6a5f65 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/DepositRequestProcessor.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/DepositRequestProcessor.java @@ -15,11 +15,11 @@ package org.hyperledger.besu.ethereum.mainnet.requests; 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.Request; 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.List; @@ -44,19 +44,20 @@ public Optional> process( if (depositContractAddress.isEmpty()) { return Optional.empty(); } - List deposits = findDepositsFromReceipts(transactionReceipts); - return Optional.of(deposits); + List depositRequests = findDepositRequestsFromReceipts(transactionReceipts); + return Optional.of(depositRequests); } @VisibleForTesting - List findDepositsFromReceipts(final List transactionReceipts) { + List findDepositRequestsFromReceipts( + final List transactionReceipts) { return depositContractAddress .map( address -> transactionReceipts.stream() .flatMap(receipt -> receipt.getLogsList().stream()) .filter(log -> address.equals(log.getLogger())) - .map(DepositDecoder::decodeFromLog) + .map(DepositRequestDecoder::decodeFromLog) .toList()) .orElse(Collections.emptyList()); } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/DepositsValidator.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/DepositRequestValidator.java similarity index 68% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/DepositsValidator.java rename to ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/DepositRequestValidator.java index 6a2d3bdc587..6c9eedf305d 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/DepositsValidator.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/DepositRequestValidator.java @@ -18,10 +18,10 @@ import org.hyperledger.besu.datatypes.Address; 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.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 java.util.ArrayList; @@ -32,44 +32,46 @@ import org.slf4j.Logger; 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; - public DepositsValidator(final Address depositContractAddress) { + public DepositRequestValidator(final Address depositContractAddress) { this.depositContractAddress = depositContractAddress; } @Override - public boolean validateParameter(final Optional> deposits) { - return deposits.isPresent(); + public boolean validateParameter(final Optional> depositRequests) { + return depositRequests.isPresent(); } - public boolean validateDeposits( + public boolean validateDepositRequests( final Block block, - final List actualDeposits, + final List actualDepositRequests, final List receipts) { - List expectedDeposits = new ArrayList<>(); + List expectedDepositRequests = new ArrayList<>(); for (TransactionReceipt receipt : receipts) { for (Log log : receipt.getLogsList()) { if (depositContractAddress.equals(log.getLogger())) { - Deposit deposit = DepositDecoder.decodeFromLog(log); - expectedDeposits.add(deposit); + DepositRequest depositRequest = DepositRequestDecoder.decodeFromLog(log); + expectedDepositRequests.add(depositRequest); } } } - boolean isValid = actualDeposits.equals(expectedDeposits); + boolean isValid = actualDepositRequests.equals(expectedDepositRequests); if (!isValid) { LOG.warn( "Deposits validation failed. Deposits from block body do not match deposits from logs. Block hash: {}", block.getHash()); LOG.debug( - "Deposits from logs: {}, deposits from block body: {}", expectedDeposits, actualDeposits); + "Deposits from logs: {}, deposits from block body: {}", + expectedDepositRequests, + actualDepositRequests); } return isValid; @@ -78,7 +80,7 @@ public boolean validateDeposits( @Override public boolean validate( final Block block, final List requests, final List receipts) { - var deposits = getDepositRequests(Optional.of(requests)).orElse(Collections.emptyList()); - return validateDeposits(block, deposits, receipts); + var depositRequests = getDepositRequests(Optional.of(requests)).orElse(Collections.emptyList()); + return validateDepositRequests(block, depositRequests, receipts); } } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/MainnetRequestsValidator.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/MainnetRequestsValidator.java index 9f9b4539d00..56e47aea50b 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/MainnetRequestsValidator.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/MainnetRequestsValidator.java @@ -22,7 +22,7 @@ public static RequestsValidatorCoordinator pragueRequestsValidator( final Address depositContractAddress) { return new RequestsValidatorCoordinator.Builder() .addValidator(RequestType.WITHDRAWAL, new WithdrawalRequestValidator()) - .addValidator(RequestType.DEPOSIT, new DepositsValidator(depositContractAddress)) + .addValidator(RequestType.DEPOSIT, new DepositRequestValidator(depositContractAddress)) .build(); } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/RequestUtil.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/RequestUtil.java index 3d85fc48f52..459fdbe110a 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/RequestUtil.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/requests/RequestUtil.java @@ -14,7 +14,7 @@ */ 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.WithdrawalRequest; @@ -42,8 +42,9 @@ public static List filterRequestsOfType( return requests.stream().filter(requestType::isInstance).map(requestType::cast).toList(); } - public static Optional> getDepositRequests(final Optional> requests) { - return requests.map(r -> filterRequestsOfType(r, Deposit.class)); + public static Optional> getDepositRequests( + final Optional> requests) { + return requests.map(r -> filterRequestsOfType(r, DepositRequest.class)); } public static Optional> getWithdrawalRequests( @@ -54,19 +55,19 @@ public static Optional> getWithdrawalRequests( /** * 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. * @return An Optional containing the combined list of requests, or an empty Optional if both * inputs are empty. */ public static Optional> combine( - final Optional> maybeDeposits, + final Optional> maybeDepositRequests, final Optional> maybeWithdrawalRequest) { - if (maybeDeposits.isEmpty() && maybeWithdrawalRequest.isEmpty()) { + if (maybeDepositRequests.isEmpty() && maybeWithdrawalRequest.isEmpty()) { return Optional.empty(); } List requests = new ArrayList<>(); - maybeDeposits.ifPresent(requests::addAll); + maybeDepositRequests.ifPresent(requests::addAll); maybeWithdrawalRequest.ifPresent(requests::addAll); return Optional.of(requests); } diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/encoding/DepositDecoderTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/encoding/DepositRequestRequestDecoderTest.java similarity index 88% rename from ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/encoding/DepositDecoderTest.java rename to ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/encoding/DepositRequestRequestDecoderTest.java index 131cd089972..0a6cee956d1 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/encoding/DepositDecoderTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/encoding/DepositRequestRequestDecoderTest.java @@ -20,7 +20,7 @@ import org.hyperledger.besu.datatypes.BLSPublicKey; import org.hyperledger.besu.datatypes.BLSSignature; 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.LogTopic; @@ -31,11 +31,11 @@ import org.apache.tuweni.units.bigints.UInt64; import org.junit.jupiter.api.Test; -class DepositDecoderTest { +class DepositRequestRequestDecoderTest { @Test void shouldDecodeDeposit() { - final Deposit expectedDeposit = - new Deposit( + final DepositRequest expectedDepositRequest = + new DepositRequest( BLSPublicKey.fromHexString( "0xb10a4a15bf67b328c9b101d09e5c6ee6672978fdad9ef0d9e2ceffaee99223555d8601f0cb3bcc4ce1af9864779a416e"), Bytes32.fromHexString( @@ -45,12 +45,12 @@ void shouldDecodeDeposit() { "0xa889db8300194050a2636c92a95bc7160515867614b7971a9500cdb62f9c0890217d2901c3241f86fac029428fc106930606154bd9e406d7588934a5f15b837180b17194d6e44bd6de23e43b163dfe12e369dcc75a3852cd997963f158217eb5"), UInt64.ONE); - final Deposit deposit = - DepositDecoder.decodeOpaqueBytes( + final DepositRequest depositRequest = + DepositRequestDecoder.decodeOpaqueBytes( Bytes.fromHexString( "0xf8bbb0b10a4a15bf67b328c9b101d09e5c6ee6672978fdad9ef0d9e2ceffaee99223555d8601f0cb3bcc4ce1af9864779a416ea00017a7fcf06faf493d30bbe2632ea7c2383cd86825e12797165de7aa35589483850773594000b860a889db8300194050a2636c92a95bc7160515867614b7971a9500cdb62f9c0890217d2901c3241f86fac029428fc106930606154bd9e406d7588934a5f15b837180b17194d6e44bd6de23e43b163dfe12e369dcc75a3852cd997963f158217eb501")); - assertThat(deposit).isEqualTo(expectedDeposit); + assertThat(depositRequest).isEqualTo(expectedDepositRequest); } @Test @@ -65,10 +65,10 @@ void shouldDecodeDepositFromLog() { "0x00000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000030b10a4a15bf67b328c9b101d09e5c6ee6672978fdad9ef0d9e2ceffaee99223555d8601f0cb3bcc4ce1af9864779a416e0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200017a7fcf06faf493d30bbe2632ea7c2383cd86825e12797165de7aa35589483000000000000000000000000000000000000000000000000000000000000000800405973070000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060a889db8300194050a2636c92a95bc7160515867614b7971a9500cdb62f9c0890217d2901c3241f86fac029428fc106930606154bd9e406d7588934a5f15b837180b17194d6e44bd6de23e43b163dfe12e369dcc75a3852cd997963f158217eb500000000000000000000000000000000000000000000000000000000000000083f3d080000000000000000000000000000000000000000000000000000000000"); final Log log = new Log(address, data, topics); - final Deposit deposit = DepositDecoder.decodeFromLog(log); + final DepositRequest depositRequest = DepositRequestDecoder.decodeFromLog(log); - final Deposit expectedDeposit = - new Deposit( + final DepositRequest expectedDepositRequest = + new DepositRequest( BLSPublicKey.fromHexString( "0xb10a4a15bf67b328c9b101d09e5c6ee6672978fdad9ef0d9e2ceffaee99223555d8601f0cb3bcc4ce1af9864779a416e"), Bytes32.fromHexString( @@ -78,6 +78,6 @@ void shouldDecodeDepositFromLog() { "0xa889db8300194050a2636c92a95bc7160515867614b7971a9500cdb62f9c0890217d2901c3241f86fac029428fc106930606154bd9e406d7588934a5f15b837180b17194d6e44bd6de23e43b163dfe12e369dcc75a3852cd997963f158217eb5"), UInt64.valueOf(539967)); - assertThat(deposit).isEqualTo(expectedDeposit); + assertThat(depositRequest).isEqualTo(expectedDepositRequest); } } diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/encoding/DepositEncoderTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/encoding/DepositRequestRequestEncoderTest.java similarity index 87% rename from ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/encoding/DepositEncoderTest.java rename to ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/encoding/DepositRequestRequestEncoderTest.java index 7b4052cffb3..8f0de595f68 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/encoding/DepositEncoderTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/encoding/DepositRequestRequestEncoderTest.java @@ -19,19 +19,19 @@ import org.hyperledger.besu.datatypes.BLSPublicKey; import org.hyperledger.besu.datatypes.BLSSignature; 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.Bytes32; import org.apache.tuweni.units.bigints.UInt64; import org.junit.jupiter.api.Test; -class DepositEncoderTest { +class DepositRequestRequestEncoderTest { private final String expectedDepositEncodedBytes = "f8bbb0b10a4a15bf67b328c9b101d09e5c6ee6672978fdad9ef0d9e2ceffaee99223555d8601f0cb3bcc4ce1af9864779a416ea00017a7fcf06faf493d30bbe2632ea7c2383cd86825e12797165de7aa35589483850773594000b860a889db8300194050a2636c92a95bc7160515867614b7971a9500cdb62f9c0890217d2901c3241f86fac029428fc106930606154bd9e406d7588934a5f15b837180b17194d6e44bd6de23e43b163dfe12e369dcc75a3852cd997963f158217eb501"; - final Deposit deposit = - new Deposit( + final DepositRequest depositRequest = + new DepositRequest( BLSPublicKey.fromHexString( "0xb10a4a15bf67b328c9b101d09e5c6ee6672978fdad9ef0d9e2ceffaee99223555d8601f0cb3bcc4ce1af9864779a416e"), Bytes32.fromHexString( @@ -43,19 +43,19 @@ class DepositEncoderTest { @Test void shouldEncodeDeposit() { - final Bytes encoded = DepositEncoder.encodeOpaqueBytes(deposit); + final Bytes encoded = DepositRequestEncoder.encodeOpaqueBytes(depositRequest); assertThat(encoded).isEqualTo(Bytes.fromHexString(expectedDepositEncodedBytes)); } @Test void shouldEncodeDepositRequest() { - final Bytes encoded = RequestEncoder.encodeOpaqueBytes(deposit); + final Bytes encoded = RequestEncoder.encodeOpaqueBytes(depositRequest); // Request encoding is Request = RequestType ++ RequestData assertThat(encoded) .isEqualTo( Bytes.fromHexString( String.format( "0x%02X%s", - deposit.getType().getSerializedType(), expectedDepositEncodedBytes))); + depositRequest.getType().getSerializedType(), expectedDepositEncodedBytes))); } } diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/DepositsValidatorTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/DepositRequestValidatorTest.java similarity index 83% rename from ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/DepositsValidatorTest.java rename to ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/DepositRequestValidatorTest.java index 99eae1437a6..0360032388b 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/DepositsValidatorTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/DepositRequestValidatorTest.java @@ -23,10 +23,10 @@ import org.hyperledger.besu.datatypes.RequestType; import org.hyperledger.besu.ethereum.core.Block; 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.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.WithdrawalRequestValidator; import org.hyperledger.besu.evm.log.Log; @@ -41,20 +41,20 @@ import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; -public class DepositsValidatorTest { +public class DepositRequestValidatorTest { private final BlockDataGenerator blockDataGenerator = new BlockDataGenerator(); - private static Deposit DEPOSIT_1; - private static Deposit DEPOSIT_2; + private static DepositRequest depositRequest1; + private static DepositRequest depositRequest2; private static Log LOG_1; private static Log LOG_2; private static Address DEPOSIT_CONTRACT_ADDRESS; private static RequestsValidatorCoordinator requestsValidatorCoordinator; - private static DepositsValidator depositsValidator; + private static DepositRequestValidator depositRequestValidator; @BeforeAll public static void setup() { - DEPOSIT_1 = - new Deposit( + depositRequest1 = + new DepositRequest( BLSPublicKey.fromHexString( "0xb10a4a15bf67b328c9b101d09e5c6ee6672978fdad9ef0d9e2ceffaee99223555d8601f0cb3bcc4ce1af9864779a416e"), Bytes32.fromHexString( @@ -64,8 +64,8 @@ public static void setup() { "0xa889db8300194050a2636c92a95bc7160515867614b7971a9500cdb62f9c0890217d2901c3241f86fac029428fc106930606154bd9e406d7588934a5f15b837180b17194d6e44bd6de23e43b163dfe12e369dcc75a3852cd997963f158217eb5"), UInt64.valueOf(539967)); - DEPOSIT_2 = - new Deposit( + depositRequest2 = + new DepositRequest( BLSPublicKey.fromHexString( "0x8706d19a62f28a6a6549f96c5adaebac9124a61d44868ec94f6d2d707c6a2f82c9162071231dfeb40e24bfde4ffdf243"), Bytes32.fromHexString( @@ -97,8 +97,8 @@ public static void setup() { } @Test - public void validateAllowedDeposits() { - final List request = List.of(DEPOSIT_1, DEPOSIT_2); + public void validateAllowedDepositRequests() { + final List request = List.of(depositRequest1, depositRequest2); final BlockDataGenerator.BlockOptions blockOptions = BlockDataGenerator.BlockOptions.create() .setRequests(Optional.of(request)) @@ -113,9 +113,9 @@ public void validateAllowedDeposits() { } @Test - public void validateAllowedDepositsSeparateReceipts() { + public void validateAllowedDepositRequestsSeparateReceipts() { - final List requests = List.of(DEPOSIT_1, DEPOSIT_2); + final List requests = List.of(depositRequest1, depositRequest2); final BlockDataGenerator.BlockOptions blockOptions = BlockDataGenerator.BlockOptions.create() @@ -135,9 +135,9 @@ public void validateAllowedDepositsSeparateReceipts() { } @Test - public void invalidateAllowedDeposits() { + public void invalidateAllowedDepositRequests() { 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 TransactionReceipt receipt1 = @@ -149,10 +149,10 @@ public void invalidateAllowedDeposits() { } @Test - public void invalidateAllowedDepositsMissingLogInReceipt() { + public void invalidateAllowedDepositRequestsMissingLogInReceipt() { final BlockDataGenerator.BlockOptions blockOptions = 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 TransactionReceipt receipt1 = @@ -164,9 +164,9 @@ public void invalidateAllowedDepositsMissingLogInReceipt() { } @Test - public void invalidateAllowedDepositsExtraLogInReceipt() { + public void invalidateAllowedDepositRequestsExtraLogInReceipt() { 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 TransactionReceipt receipt1 = @@ -178,10 +178,10 @@ public void invalidateAllowedDepositsExtraLogInReceipt() { } @Test - public void invalidateAllowedDepositsWrongOrder() { + public void invalidateAllowedDepositRequestsWrongOrder() { final BlockDataGenerator.BlockOptions blockOptions = 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 TransactionReceipt receipt1 = @@ -193,11 +193,11 @@ public void invalidateAllowedDepositsWrongOrder() { } @Test - public void invalidateAllowedDepositsMismatchContractAddress() { + public void invalidateAllowedDepositRequestsMismatchContractAddress() { final BlockDataGenerator.BlockOptions blockOptions = 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 TransactionReceipt receipt1 = @@ -210,24 +210,25 @@ public void invalidateAllowedDepositsMismatchContractAddress() { @Test public void validateAllowedDepositParams() { - final Optional> deposits = Optional.of(List.of(DEPOSIT_1, DEPOSIT_2)); - assertThat(depositsValidator.validateParameter(deposits)).isTrue(); + final Optional> depositRequests = + Optional.of(List.of(depositRequest1, depositRequest2)); + assertThat(depositRequestValidator.validateParameter(depositRequests)).isTrue(); - final Optional> emptyDeposits = Optional.of(List.of()); - assertThat(depositsValidator.validateParameter(emptyDeposits)).isTrue(); + final Optional> emptyDepositRequests = Optional.of(List.of()); + assertThat(depositRequestValidator.validateParameter(emptyDepositRequests)).isTrue(); } @Test public void invalidateAllowedDepositParams() { - final Optional> deposits = Optional.empty(); - assertThat(depositsValidator.validateParameter(deposits)).isFalse(); + final Optional> depositRequests = Optional.empty(); + assertThat(depositRequestValidator.validateParameter(depositRequests)).isFalse(); } static RequestsValidatorCoordinator createAllowDepositValidator() { - depositsValidator = new DepositsValidator(DEPOSIT_CONTRACT_ADDRESS); + depositRequestValidator = new DepositRequestValidator(DEPOSIT_CONTRACT_ADDRESS); return new RequestsValidatorCoordinator.Builder() .addValidator(RequestType.WITHDRAWAL, new WithdrawalRequestValidator()) - .addValidator(RequestType.DEPOSIT, depositsValidator) + .addValidator(RequestType.DEPOSIT, depositRequestValidator) .build(); } } diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/MainnetBlockBodyValidatorTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/MainnetBlockBodyValidatorTest.java index dfc1f2d0436..c116d545d80 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/MainnetBlockBodyValidatorTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/MainnetBlockBodyValidatorTest.java @@ -28,7 +28,7 @@ import org.hyperledger.besu.ethereum.core.BlockDataGenerator.BlockOptions; import org.hyperledger.besu.ethereum.core.BlockchainSetupUtil; 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.evm.log.LogsBloomFilter; @@ -53,7 +53,7 @@ class MainnetBlockBodyValidatorTest { @Mock private ProtocolSchedule protocolSchedule; @Mock private ProtocolSpec protocolSpec; @Mock private WithdrawalsValidator withdrawalsValidator; - @Mock private DepositsValidator depositsValidator; + @Mock private DepositRequestValidator depositRequestValidator; @Mock private RequestsValidatorCoordinator requestValidator; @BeforeEach @@ -64,7 +64,9 @@ public void setUp() { lenient().when(withdrawalsValidator.validateWithdrawals(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(requestValidator.validate(any(), any(), any())).thenReturn(true); diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/manager/task/GetBodiesFromPeerTaskTest.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/manager/task/GetBodiesFromPeerTaskTest.java index b6c635551dd..b8546ad532d 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/manager/task/GetBodiesFromPeerTaskTest.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/manager/task/GetBodiesFromPeerTaskTest.java @@ -24,7 +24,7 @@ import org.hyperledger.besu.ethereum.core.Block; import org.hyperledger.besu.ethereum.core.BlockBody; 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.Withdrawal; import org.hyperledger.besu.ethereum.core.WithdrawalRequest; @@ -89,9 +89,9 @@ public void assertBodyIdentifierUsesWithdrawalsToGenerateBodyIdentifiers() { } @Test - public void assertBodyIdentifierUsesDepositsToGenerateBodyIdentifiers() { + public void assertBodyIdentifierUsesDepositRequestsToGenerateBodyIdentifiers() { final Request deposit = - new Deposit( + new DepositRequest( BLSPublicKey.fromHexString( "0xb10a4a15bf67b328c9b101d09e5c6ee6672978fdad9ef0d9e2ceffaee99223555d8601f0cb3bcc4ce1af9864779a416e"), Bytes32.fromHexString( diff --git a/ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/T8nExecutor.java b/ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/T8nExecutor.java index ee84eba4d17..6e48aaf82ca 100644 --- a/ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/T8nExecutor.java +++ b/ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/T8nExecutor.java @@ -32,7 +32,7 @@ import org.hyperledger.besu.datatypes.Wei; import org.hyperledger.besu.ethereum.chain.Blockchain; 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.Transaction; import org.hyperledger.besu.ethereum.core.TransactionReceipt; @@ -466,7 +466,7 @@ static T8nResult runTest( resultObject.put("requestsRoot", requestRoot.toHexString()); var deposits = resultObject.putArray("depositRequests"); - RequestUtil.filterRequestsOfType(maybeRequests.orElse(List.of()), Deposit.class) + RequestUtil.filterRequestsOfType(maybeRequests.orElse(List.of()), DepositRequest.class) .forEach( deposit -> { var obj = deposits.addObject(); diff --git a/plugin-api/build.gradle b/plugin-api/build.gradle index a25774205b7..fd7f3291b3b 100644 --- a/plugin-api/build.gradle +++ b/plugin-api/build.gradle @@ -70,7 +70,7 @@ Calculated : ${currentHash} tasks.register('checkAPIChanges', FileStateChecker) { description = "Checks that the API for the Plugin-API project does not change without deliberate thought" files = sourceSets.main.allJava.files - knownHash = 'zgPAgf+ZxefbnCE9aYEQ5QoeBVsHySi3u+BlhHNHqn8=' + knownHash = 'p8jZoKgvi9o8JpVLXTlwh9HoIot4A62hKFHwSOaTF+k=' } check.dependsOn('checkAPIChanges') diff --git a/plugin-api/src/main/java/org/hyperledger/besu/plugin/data/Deposit.java b/plugin-api/src/main/java/org/hyperledger/besu/plugin/data/DepositRequest.java similarity index 98% rename from plugin-api/src/main/java/org/hyperledger/besu/plugin/data/Deposit.java rename to plugin-api/src/main/java/org/hyperledger/besu/plugin/data/DepositRequest.java index 6ad30217ac7..096554d3c74 100644 --- a/plugin-api/src/main/java/org/hyperledger/besu/plugin/data/Deposit.java +++ b/plugin-api/src/main/java/org/hyperledger/besu/plugin/data/DepositRequest.java @@ -27,7 +27,7 @@ * to beacon chain. */ @Unstable -public interface Deposit { +public interface DepositRequest { /** * Public key of the address that sends the deposit