Skip to content

Commit

Permalink
Error prone final - ethereum module (Consensys#8219)
Browse files Browse the repository at this point in the history
* add missing final

Signed-off-by: Gabriel Fukushima <[email protected]>

---------

Signed-off-by: Gabriel Fukushima <[email protected]>
  • Loading branch information
gfukushima authored Apr 22, 2024
1 parent 147b431 commit a3f7ebc
Show file tree
Hide file tree
Showing 259 changed files with 1,188 additions and 1,085 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ private StateGenerator(
}

public static StateGenerator create(
Spec spec,
final Spec spec,
final HashTree blockTree,
final StateAndBlockSummary rootBlockAndState,
final BlockProvider blockProvider) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public interface BlockProvider {

BlockProvider NOOP = (roots) -> SafeFuture.completedFuture(Collections.emptyMap());

static BlockProvider fromDynamicMap(Supplier<Map<Bytes32, SignedBeaconBlock>> mapSupplier) {
static BlockProvider fromDynamicMap(final Supplier<Map<Bytes32, SignedBeaconBlock>> mapSupplier) {
return (roots) -> fromMap(mapSupplier.get()).getBlocks(roots);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,24 @@ public class Eth1Address extends Bytes20 {

private final String encodedAddress;

private Eth1Address(String value) {
private Eth1Address(final String value) {
super(Bytes.fromHexString(value));
String valueWithPrefix = value;
if (!value.startsWith("0x")) {
value = "0x" + value;
valueWithPrefix = "0x" + value;
}
this.encodedAddress = toChecksumAddress(value);
validate(value);
this.encodedAddress = toChecksumAddress(valueWithPrefix);
validate(valueWithPrefix);
}

private Eth1Address(Bytes bytes) {
private Eth1Address(final Bytes bytes) {
super(bytes);
final String value = bytes.toHexString();
this.encodedAddress = toChecksumAddress(value);
validate(value);
}

private void validate(String value) {
private void validate(final String value) {
if (isMixedCase(value.substring("0x".length()))) {
checkArgument(
value.equals(encodedAddress),
Expand All @@ -56,11 +57,11 @@ private void validate(String value) {
}
}

public static Eth1Address fromBytes(Bytes value) {
public static Eth1Address fromBytes(final Bytes value) {
return new Eth1Address(value);
}

public static Eth1Address fromHexString(String value) {
public static Eth1Address fromHexString(final String value) {
try {
return new Eth1Address(value);
} catch (RuntimeException ex) {
Expand All @@ -75,7 +76,7 @@ public static Eth1Address fromHexString(String value) {
* @param value The string representation of an Ethereum address.
* @return The encoded address with mixed-case checksum.
*/
private static String toChecksumAddress(String value) {
private static String toChecksumAddress(final String value) {
final String address = value.replace("0x", "").toLowerCase(Locale.ROOT);
final String hashString =
Hash.keccak256(Bytes.wrap(address.getBytes(StandardCharsets.US_ASCII)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public String getJwtToken() {
}

@Override
public boolean equals(Object o) {
public boolean equals(final Object o) {
if (this == o) {
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ public class ClientVersionV1 {
public final Bytes4 commit;

public ClientVersionV1(
@JsonProperty("code") String code,
@JsonProperty("name") String name,
@JsonProperty("version") String version,
@JsonProperty("commit") Bytes4 commit) {
final @JsonProperty("code") String code,
final @JsonProperty("name") String name,
final @JsonProperty("version") String version,
final @JsonProperty("commit") Bytes4 commit) {
checkNotNull(code, "code");
checkNotNull(name, "name");
checkNotNull(version, "version");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,19 +89,19 @@ public class ExecutionPayloadCommon {
public final Bytes32 blockHash;

public ExecutionPayloadCommon(
@JsonProperty("parentHash") Bytes32 parentHash,
@JsonProperty("feeRecipient") Bytes20 feeRecipient,
@JsonProperty("stateRoot") Bytes32 stateRoot,
@JsonProperty("receiptsRoot") Bytes32 receiptsRoot,
@JsonProperty("logsBloom") Bytes logsBloom,
@JsonProperty("prevRandao") Bytes32 prevRandao,
@JsonProperty("blockNumber") UInt64 blockNumber,
@JsonProperty("gasLimit") UInt64 gasLimit,
@JsonProperty("gasUsed") UInt64 gasUsed,
@JsonProperty("timestamp") UInt64 timestamp,
@JsonProperty("extraData") Bytes extraData,
@JsonProperty("baseFeePerGas") UInt256 baseFeePerGas,
@JsonProperty("blockHash") Bytes32 blockHash) {
final @JsonProperty("parentHash") Bytes32 parentHash,
final @JsonProperty("feeRecipient") Bytes20 feeRecipient,
final @JsonProperty("stateRoot") Bytes32 stateRoot,
final @JsonProperty("receiptsRoot") Bytes32 receiptsRoot,
final @JsonProperty("logsBloom") Bytes logsBloom,
final @JsonProperty("prevRandao") Bytes32 prevRandao,
final @JsonProperty("blockNumber") UInt64 blockNumber,
final @JsonProperty("gasLimit") UInt64 gasLimit,
final @JsonProperty("gasUsed") UInt64 gasUsed,
final @JsonProperty("timestamp") UInt64 timestamp,
final @JsonProperty("extraData") Bytes extraData,
final @JsonProperty("baseFeePerGas") UInt256 baseFeePerGas,
final @JsonProperty("blockHash") Bytes32 blockHash) {
checkNotNull(parentHash, "parentHash");
checkNotNull(feeRecipient, "feeRecipient");
checkNotNull(stateRoot, "stateRoot");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,20 @@ public class ExecutionPayloadV1 extends ExecutionPayloadCommon {
public final List<Bytes> transactions;

public ExecutionPayloadV1(
@JsonProperty("parentHash") Bytes32 parentHash,
@JsonProperty("feeRecipient") Bytes20 feeRecipient,
@JsonProperty("stateRoot") Bytes32 stateRoot,
@JsonProperty("receiptsRoot") Bytes32 receiptsRoot,
@JsonProperty("logsBloom") Bytes logsBloom,
@JsonProperty("prevRandao") Bytes32 prevRandao,
@JsonProperty("blockNumber") UInt64 blockNumber,
@JsonProperty("gasLimit") UInt64 gasLimit,
@JsonProperty("gasUsed") UInt64 gasUsed,
@JsonProperty("timestamp") UInt64 timestamp,
@JsonProperty("extraData") Bytes extraData,
@JsonProperty("baseFeePerGas") UInt256 baseFeePerGas,
@JsonProperty("blockHash") Bytes32 blockHash,
@JsonProperty("transactions") List<Bytes> transactions) {
final @JsonProperty("parentHash") Bytes32 parentHash,
final @JsonProperty("feeRecipient") Bytes20 feeRecipient,
final @JsonProperty("stateRoot") Bytes32 stateRoot,
final @JsonProperty("receiptsRoot") Bytes32 receiptsRoot,
final @JsonProperty("logsBloom") Bytes logsBloom,
final @JsonProperty("prevRandao") Bytes32 prevRandao,
final @JsonProperty("blockNumber") UInt64 blockNumber,
final @JsonProperty("gasLimit") UInt64 gasLimit,
final @JsonProperty("gasUsed") UInt64 gasUsed,
final @JsonProperty("timestamp") UInt64 timestamp,
final @JsonProperty("extraData") Bytes extraData,
final @JsonProperty("baseFeePerGas") UInt256 baseFeePerGas,
final @JsonProperty("blockHash") Bytes32 blockHash,
final @JsonProperty("transactions") List<Bytes> transactions) {
super(
parentHash,
feeRecipient,
Expand All @@ -69,7 +69,7 @@ public ExecutionPayloadV1(
}

public ExecutionPayload asInternalExecutionPayload(
ExecutionPayloadSchema<?> executionPayloadSchema) {
final ExecutionPayloadSchema<?> executionPayloadSchema) {
return executionPayloadSchema.createExecutionPayload(
builder -> applyToBuilder(executionPayloadSchema, builder));
}
Expand All @@ -94,7 +94,8 @@ protected ExecutionPayloadBuilder applyToBuilder(
.transactions(transactions);
}

public static ExecutionPayloadV1 fromInternalExecutionPayload(ExecutionPayload executionPayload) {
public static ExecutionPayloadV1 fromInternalExecutionPayload(
final ExecutionPayload executionPayload) {
return new ExecutionPayloadV1(
executionPayload.getParentHash(),
executionPayload.getFeeRecipient(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,21 @@ public class ExecutionPayloadV2 extends ExecutionPayloadV1 {
public final List<WithdrawalV1> withdrawals;

public ExecutionPayloadV2(
@JsonProperty("parentHash") Bytes32 parentHash,
@JsonProperty("feeRecipient") Bytes20 feeRecipient,
@JsonProperty("stateRoot") Bytes32 stateRoot,
@JsonProperty("receiptsRoot") Bytes32 receiptsRoot,
@JsonProperty("logsBloom") Bytes logsBloom,
@JsonProperty("prevRandao") Bytes32 prevRandao,
@JsonProperty("blockNumber") UInt64 blockNumber,
@JsonProperty("gasLimit") UInt64 gasLimit,
@JsonProperty("gasUsed") UInt64 gasUsed,
@JsonProperty("timestamp") UInt64 timestamp,
@JsonProperty("extraData") Bytes extraData,
@JsonProperty("baseFeePerGas") UInt256 baseFeePerGas,
@JsonProperty("blockHash") Bytes32 blockHash,
@JsonProperty("transactions") List<Bytes> transactions,
@JsonProperty("withdrawals") List<WithdrawalV1> withdrawals) {
final @JsonProperty("parentHash") Bytes32 parentHash,
final @JsonProperty("feeRecipient") Bytes20 feeRecipient,
final @JsonProperty("stateRoot") Bytes32 stateRoot,
final @JsonProperty("receiptsRoot") Bytes32 receiptsRoot,
final @JsonProperty("logsBloom") Bytes logsBloom,
final @JsonProperty("prevRandao") Bytes32 prevRandao,
final @JsonProperty("blockNumber") UInt64 blockNumber,
final @JsonProperty("gasLimit") UInt64 gasLimit,
final @JsonProperty("gasUsed") UInt64 gasUsed,
final @JsonProperty("timestamp") UInt64 timestamp,
final @JsonProperty("extraData") Bytes extraData,
final @JsonProperty("baseFeePerGas") UInt256 baseFeePerGas,
final @JsonProperty("blockHash") Bytes32 blockHash,
final @JsonProperty("transactions") List<Bytes> transactions,
final @JsonProperty("withdrawals") List<WithdrawalV1> withdrawals) {
super(
parentHash,
feeRecipient,
Expand All @@ -68,7 +68,8 @@ public ExecutionPayloadV2(
this.withdrawals = withdrawals;
}

public static ExecutionPayloadV2 fromInternalExecutionPayload(ExecutionPayload executionPayload) {
public static ExecutionPayloadV2 fromInternalExecutionPayload(
final ExecutionPayload executionPayload) {
List<WithdrawalV1> withdrawalsList = getWithdrawals(executionPayload.getOptionalWithdrawals());
return new ExecutionPayloadV2(
executionPayload.getParentHash(),
Expand Down Expand Up @@ -103,7 +104,7 @@ protected ExecutionPayloadBuilder applyToBuilder(
}

private Withdrawal createInternalWithdrawal(
final WithdrawalV1 withdrawalV1, ExecutionPayloadSchema<?> executionPayloadSchema) {
final WithdrawalV1 withdrawalV1, final ExecutionPayloadSchema<?> executionPayloadSchema) {
return executionPayloadSchema
.getWithdrawalSchemaRequired()
.create(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,23 +42,23 @@ public class ExecutionPayloadV3 extends ExecutionPayloadV2 {
public final UInt64 excessBlobGas;

public ExecutionPayloadV3(
@JsonProperty("parentHash") Bytes32 parentHash,
@JsonProperty("feeRecipient") Bytes20 feeRecipient,
@JsonProperty("stateRoot") Bytes32 stateRoot,
@JsonProperty("receiptsRoot") Bytes32 receiptsRoot,
@JsonProperty("logsBloom") Bytes logsBloom,
@JsonProperty("prevRandao") Bytes32 prevRandao,
@JsonProperty("blockNumber") UInt64 blockNumber,
@JsonProperty("gasLimit") UInt64 gasLimit,
@JsonProperty("gasUsed") UInt64 gasUsed,
@JsonProperty("timestamp") UInt64 timestamp,
@JsonProperty("extraData") Bytes extraData,
@JsonProperty("baseFeePerGas") UInt256 baseFeePerGas,
@JsonProperty("blockHash") Bytes32 blockHash,
@JsonProperty("transactions") List<Bytes> transactions,
@JsonProperty("withdrawals") List<WithdrawalV1> withdrawals,
@JsonProperty("blobGasUsed") UInt64 blobGasUsed,
@JsonProperty("excessBlobGas") UInt64 excessBlobGas) {
final @JsonProperty("parentHash") Bytes32 parentHash,
final @JsonProperty("feeRecipient") Bytes20 feeRecipient,
final @JsonProperty("stateRoot") Bytes32 stateRoot,
final @JsonProperty("receiptsRoot") Bytes32 receiptsRoot,
final @JsonProperty("logsBloom") Bytes logsBloom,
final @JsonProperty("prevRandao") Bytes32 prevRandao,
final @JsonProperty("blockNumber") UInt64 blockNumber,
final @JsonProperty("gasLimit") UInt64 gasLimit,
final @JsonProperty("gasUsed") UInt64 gasUsed,
final @JsonProperty("timestamp") UInt64 timestamp,
final @JsonProperty("extraData") Bytes extraData,
final @JsonProperty("baseFeePerGas") UInt256 baseFeePerGas,
final @JsonProperty("blockHash") Bytes32 blockHash,
final @JsonProperty("transactions") List<Bytes> transactions,
final @JsonProperty("withdrawals") List<WithdrawalV1> withdrawals,
final @JsonProperty("blobGasUsed") UInt64 blobGasUsed,
final @JsonProperty("excessBlobGas") UInt64 excessBlobGas) {
super(
parentHash,
feeRecipient,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,25 +41,25 @@ public class ExecutionPayloadV4 extends ExecutionPayloadV3 {
public final List<WithdrawalRequestV1> withdrawalRequests;

public ExecutionPayloadV4(
@JsonProperty("parentHash") Bytes32 parentHash,
@JsonProperty("feeRecipient") Bytes20 feeRecipient,
@JsonProperty("stateRoot") Bytes32 stateRoot,
@JsonProperty("receiptsRoot") Bytes32 receiptsRoot,
@JsonProperty("logsBloom") Bytes logsBloom,
@JsonProperty("prevRandao") Bytes32 prevRandao,
@JsonProperty("blockNumber") UInt64 blockNumber,
@JsonProperty("gasLimit") UInt64 gasLimit,
@JsonProperty("gasUsed") UInt64 gasUsed,
@JsonProperty("timestamp") UInt64 timestamp,
@JsonProperty("extraData") Bytes extraData,
@JsonProperty("baseFeePerGas") UInt256 baseFeePerGas,
@JsonProperty("blockHash") Bytes32 blockHash,
@JsonProperty("transactions") List<Bytes> transactions,
@JsonProperty("withdrawals") List<WithdrawalV1> withdrawals,
@JsonProperty("blobGasUsed") UInt64 blobGasUsed,
@JsonProperty("excessBlobGas") UInt64 excessBlobGas,
@JsonProperty("depositReceipts") List<DepositReceiptV1> depositReceipts,
@JsonProperty("withdrawalRequests") List<WithdrawalRequestV1> withdrawalRequests) {
final @JsonProperty("parentHash") Bytes32 parentHash,
final @JsonProperty("feeRecipient") Bytes20 feeRecipient,
final @JsonProperty("stateRoot") Bytes32 stateRoot,
final @JsonProperty("receiptsRoot") Bytes32 receiptsRoot,
final @JsonProperty("logsBloom") Bytes logsBloom,
final @JsonProperty("prevRandao") Bytes32 prevRandao,
final @JsonProperty("blockNumber") UInt64 blockNumber,
final @JsonProperty("gasLimit") UInt64 gasLimit,
final @JsonProperty("gasUsed") UInt64 gasUsed,
final @JsonProperty("timestamp") UInt64 timestamp,
final @JsonProperty("extraData") Bytes extraData,
final @JsonProperty("baseFeePerGas") UInt256 baseFeePerGas,
final @JsonProperty("blockHash") Bytes32 blockHash,
final @JsonProperty("transactions") List<Bytes> transactions,
final @JsonProperty("withdrawals") List<WithdrawalV1> withdrawals,
final @JsonProperty("blobGasUsed") UInt64 blobGasUsed,
final @JsonProperty("excessBlobGas") UInt64 excessBlobGas,
final @JsonProperty("depositReceipts") List<DepositReceiptV1> depositReceipts,
final @JsonProperty("withdrawalRequests") List<WithdrawalRequestV1> withdrawalRequests) {
super(
parentHash,
feeRecipient,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ public class ForkChoiceStateV1 {
private final Bytes32 finalizedBlockHash;

public ForkChoiceStateV1(
@JsonProperty("headBlockHash") Bytes32 headBlockHash,
@JsonProperty("safeBlockHash") Bytes32 safeBlockHash,
@JsonProperty("finalizedBlockHash") Bytes32 finalizedBlockHash) {
final @JsonProperty("headBlockHash") Bytes32 headBlockHash,
final @JsonProperty("safeBlockHash") Bytes32 safeBlockHash,
final @JsonProperty("finalizedBlockHash") Bytes32 finalizedBlockHash) {
checkNotNull(headBlockHash, "headBlockHash");
checkNotNull(safeBlockHash, "safeBlockHash");
checkNotNull(finalizedBlockHash, "finalizedBlockHash");
Expand All @@ -50,7 +50,8 @@ public ForkChoiceStateV1(
this.finalizedBlockHash = finalizedBlockHash;
}

public static ForkChoiceStateV1 fromInternalForkChoiceState(ForkChoiceState forkChoiceState) {
public static ForkChoiceStateV1 fromInternalForkChoiceState(
final ForkChoiceState forkChoiceState) {
return new ForkChoiceStateV1(
forkChoiceState.getHeadExecutionBlockHash(),
forkChoiceState.getSafeExecutionBlockHash(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ public class ForkChoiceUpdatedResult {
private final Bytes8 payloadId;

public ForkChoiceUpdatedResult(
@JsonProperty("payloadStatus") PayloadStatusV1 payloadStatus,
@JsonProperty("payloadId") Bytes8 payloadId) {
final @JsonProperty("payloadStatus") PayloadStatusV1 payloadStatus,
final @JsonProperty("payloadId") Bytes8 payloadId) {
checkNotNull(payloadStatus, "payloadStatus cannot be null");
this.payloadStatus = payloadStatus;
this.payloadId = payloadId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ public class PayloadAttributesV1 {
public final Bytes20 suggestedFeeRecipient;

public PayloadAttributesV1(
@JsonProperty("timestamp") UInt64 timestamp,
@JsonProperty("prevRandao") Bytes32 prevRandao,
@JsonProperty("suggestedFeeRecipient") Bytes20 suggestedFeeRecipient) {
final @JsonProperty("timestamp") UInt64 timestamp,
final @JsonProperty("prevRandao") Bytes32 prevRandao,
final @JsonProperty("suggestedFeeRecipient") Bytes20 suggestedFeeRecipient) {
checkNotNull(timestamp, "timestamp");
checkNotNull(prevRandao, "prevRandao");
checkNotNull(suggestedFeeRecipient, "suggestedFeeRecipient");
Expand All @@ -58,7 +58,7 @@ public PayloadAttributesV1(
}

public static Optional<PayloadAttributesV1> fromInternalPayloadBuildingAttributes(
Optional<PayloadBuildingAttributes> payloadBuildingAttributes) {
final Optional<PayloadBuildingAttributes> payloadBuildingAttributes) {
return payloadBuildingAttributes.map(
(payloadAttributes) ->
new PayloadAttributesV1(
Expand Down
Loading

0 comments on commit a3f7ebc

Please sign in to comment.