Skip to content

Commit

Permalink
Rename methods and variables to match json (#7134)
Browse files Browse the repository at this point in the history
Signed-off-by: Gabriel-Trintinalia <[email protected]>
  • Loading branch information
Gabriel-Trintinalia authored May 23, 2024
1 parent ebb8830 commit 5415463
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public static WithdrawalRequestParameter fromWithdrawalRequest(
final WithdrawalRequest withdrawalRequest) {
return new WithdrawalRequestParameter(
withdrawalRequest.getSourceAddress().toHexString(),
withdrawalRequest.getValidatorPubKey().toHexString(),
withdrawalRequest.getValidatorPublicKey().toHexString(),
withdrawalRequest.getAmount().toShortHexString());
}

Expand Down Expand Up @@ -92,7 +92,7 @@ public String toString() {
+ "sourceAddress='"
+ sourceAddress
+ '\''
+ ", validatorPubKey='"
+ ", validatorPublicKey='"
+ validatorPublicKey
+ '\''
+ ", amount='"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ public class WithdrawalRequest extends Request
implements org.hyperledger.besu.plugin.data.WithdrawalRequest {

private final Address sourceAddress;
private final BLSPublicKey validatorPubKey;
private final BLSPublicKey validatorPublicKey;
private final GWei amount;

public WithdrawalRequest(
final Address sourceAddress, final BLSPublicKey validatorPubKey, final GWei amount) {
final Address sourceAddress, final BLSPublicKey validatorPublicKey, final GWei amount) {
this.sourceAddress = sourceAddress;
this.validatorPubKey = validatorPubKey;
this.validatorPublicKey = validatorPublicKey;
this.amount = amount;
}

Expand All @@ -47,8 +47,8 @@ public Address getSourceAddress() {
}

@Override
public PublicKey getValidatorPubKey() {
return validatorPubKey;
public PublicKey getValidatorPublicKey() {
return validatorPublicKey;
}

@Override
Expand All @@ -61,8 +61,8 @@ public String toString() {
return "WithdrawalRequest{"
+ "sourceAddress="
+ sourceAddress
+ " validatorPubKey="
+ validatorPubKey
+ " validatorPublicKey="
+ validatorPublicKey
+ " amount="
+ amount
+ '}';
Expand All @@ -78,12 +78,12 @@ public boolean equals(final Object o) {
}
final WithdrawalRequest that = (WithdrawalRequest) o;
return Objects.equals(sourceAddress, that.sourceAddress)
&& Objects.equals(validatorPubKey, that.validatorPubKey)
&& Objects.equals(validatorPublicKey, that.validatorPublicKey)
&& Objects.equals(amount, that.amount);
}

@Override
public int hashCode() {
return Objects.hash(sourceAddress, validatorPubKey, amount);
return Objects.hash(sourceAddress, validatorPublicKey, amount);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ private static void encodeWithdrawalRequest(
final WithdrawalRequest withdrawalRequest, final RLPOutput rlpOutput) {
rlpOutput.startList();
rlpOutput.writeBytes(withdrawalRequest.getSourceAddress());
rlpOutput.writeBytes(withdrawalRequest.getValidatorPubKey());
rlpOutput.writeBytes(withdrawalRequest.getValidatorPublicKey());
rlpOutput.writeUInt64Scalar(withdrawalRequest.getAmount());
rlpOutput.endList();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ private static List<WithdrawalRequest> peekExpectedWithdrawalRequests(
queueHeadIndex.plus(i).multiply(WITHDRAWAL_REQUEST_STORAGE_SLOT_SIZE));
final Address sourceAddress =
Address.wrap(account.getStorageValue(queueStorageSlot).toBytes().slice(12, 20));
final BLSPublicKey validatorPubKey =
final BLSPublicKey validatorPublicKey =
BLSPublicKey.wrap(
Bytes.concatenate(
account
Expand All @@ -162,7 +162,7 @@ private static List<WithdrawalRequest> peekExpectedWithdrawalRequests(
UInt64.fromBytes(account.getStorageValue(queueStorageSlot.plus(2)).slice(16, 8));

withdrawalRequests.add(
new WithdrawalRequest(sourceAddress, validatorPubKey, GWei.of(amount)));
new WithdrawalRequest(sourceAddress, validatorPublicKey, GWei.of(amount)));
}

return withdrawalRequests;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,13 +186,14 @@ private void loadContractStorage(
Bytes.fromHexString("0x000000000000000000000000"), request.getSourceAddress())));
// validator_pubkey
contract.setStorageValue(
UInt256.valueOf(offset++), UInt256.fromBytes(request.getValidatorPubKey().slice(0, 32)));
UInt256.valueOf(offset++),
UInt256.fromBytes(request.getValidatorPublicKey().slice(0, 32)));
contract.setStorageValue(
// set public key to slot, with 16 bytes padding on the right
UInt256.valueOf(offset++),
UInt256.fromBytes(
Bytes.concatenate(
request.getValidatorPubKey().slice(32, 16),
request.getValidatorPublicKey().slice(32, 16),
request.getAmount().toBytes(), // 8 bytes for amount
Bytes.fromHexString("0x0000000000000000"))));
}
Expand Down
2 changes: 1 addition & 1 deletion plugin-api/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 = 'wMhttXj2aWFgpN9msxHz/FwQVovpYRxNysnZEpwZYxg='
knownHash = 'zgPAgf+ZxefbnCE9aYEQ5QoeBVsHySi3u+BlhHNHqn8='
}
check.dependsOn('checkAPIChanges')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public interface WithdrawalRequest {
*
* @return public key of validator
*/
PublicKey getValidatorPubKey();
PublicKey getValidatorPublicKey();

/**
* The amount for withdrawal
Expand Down

0 comments on commit 5415463

Please sign in to comment.