Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename ValidatorPublicKey to ValidatorPubKey #7280

Merged
merged 3 commits into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.getValidatorPublicKey().toHexString(),
withdrawalRequest.getValidatorPubkey().toHexString(),
withdrawalRequest.getAmount().toShortHexString());
}

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 validatorPublicKey;
private final BLSPublicKey validatorPubkey;
private final GWei amount;

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

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

@Override
public PublicKey getValidatorPublicKey() {
return validatorPublicKey;
public PublicKey getValidatorPubkey() {
return validatorPubkey;
}

@Override
Expand All @@ -61,8 +61,8 @@ public String toString() {
return "WithdrawalRequest{"
+ "sourceAddress="
+ sourceAddress
+ " validatorPublicKey="
+ validatorPublicKey
+ " validatorPubkey="
+ validatorPubkey
+ " 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(validatorPublicKey, that.validatorPublicKey)
&& Objects.equals(validatorPubkey, that.validatorPubkey)
&& Objects.equals(amount, that.amount);
}

@Override
public int hashCode() {
return Objects.hash(sourceAddress, validatorPublicKey, amount);
return Objects.hash(sourceAddress, validatorPubkey, amount);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ public class WithdrawalRequestDecoder {
public static WithdrawalRequest decode(final RLPInput rlpInput) {
rlpInput.enterList();
final Address sourceAddress = Address.readFrom(rlpInput);
final BLSPublicKey validatorPublicKey = BLSPublicKey.readFrom(rlpInput);
final BLSPublicKey validatorPubkey = BLSPublicKey.readFrom(rlpInput);
final GWei amount = GWei.of(rlpInput.readUInt64Scalar());
rlpInput.leaveList();

return new WithdrawalRequest(sourceAddress, validatorPublicKey, amount);
return new WithdrawalRequest(sourceAddress, validatorPubkey, amount);
}

public static WithdrawalRequest decodeOpaqueBytes(final Bytes input) {
Expand Down
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.getValidatorPublicKey());
rlpOutput.writeBytes(withdrawalRequest.getValidatorPubkey());
rlpOutput.writeUInt64Scalar(withdrawalRequest.getAmount());
rlpOutput.endList();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,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 validatorPublicKey =
final BLSPublicKey validatorPubkey =
BLSPublicKey.wrap(
Bytes.concatenate(
account
Expand All @@ -165,7 +165,7 @@ private static List<WithdrawalRequest> peekExpectedWithdrawalRequests(
UInt64.fromBytes(account.getStorageValue(queueStorageSlot.plus(2)).slice(16, 8));

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

return withdrawalRequests;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import org.hyperledger.besu.evm.worldstate.WorldUpdater;

import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

import org.apache.tuweni.bytes.Bytes;
Expand All @@ -47,12 +46,12 @@ class WithdrawalRequestContractHelperTest {
private MutableAccount contract;

@BeforeEach
public void setUp() {
void setUp() {
worldState = createInMemoryWorldStateArchive().getMutable();
}

@Test
public void popWithdrawalRequestsFromQueue_ReadWithdrawalRequestsCorrectly() {
void popWithdrawalRequestsFromQueue_ReadWithdrawalRequestsCorrectly() {
final List<WithdrawalRequest> validatorWithdrawalRequests =
List.of(createExit(), createExit(), createExit());
loadContractStorage(worldState, validatorWithdrawalRequests);
Expand All @@ -64,7 +63,7 @@ public void popWithdrawalRequestsFromQueue_ReadWithdrawalRequestsCorrectly() {
}

@Test
public void
void
popWithdrawalRequestsFromQueue_whenContractCodeIsEmpty_ReturnsEmptyListOfWithdrawalRequests() {
// Create account with empty code
final WorldUpdater updater = worldState.updater();
Expand All @@ -76,10 +75,10 @@ public void popWithdrawalRequestsFromQueue_ReadWithdrawalRequestsCorrectly() {
}

@Test
public void popWithdrawalRequestsFromQueue_WhenMoreWithdrawalRequests_UpdatesQueuePointers() {
void popWithdrawalRequestsFromQueue_WhenMoreWithdrawalRequests_UpdatesQueuePointers() {
// Loading contract with more than 16 WithdrawalRequests
final List<WithdrawalRequest> validatorWithdrawalRequests =
IntStream.range(0, 30).mapToObj(__ -> createExit()).collect(Collectors.toList());
IntStream.range(0, 30).mapToObj(__ -> createExit()).toList();
loadContractStorage(worldState, validatorWithdrawalRequests);
// After loading the contract, the WithdrawalRequests count since last block should match the
// size of the list
Expand All @@ -102,7 +101,7 @@ public void popWithdrawalRequestsFromQueue_WhenMoreWithdrawalRequests_UpdatesQue
}

@Test
public void popWithdrawalRequestsFromQueue_WhenNoMoreWithdrawalRequests_ZeroQueuePointers() {
void popWithdrawalRequestsFromQueue_WhenNoMoreWithdrawalRequests_ZeroQueuePointers() {
final List<WithdrawalRequest> withdrawalRequests =
List.of(createExit(), createExit(), createExit());
loadContractStorage(worldState, withdrawalRequests);
Expand All @@ -126,7 +125,7 @@ public void popWithdrawalRequestsFromQueue_WhenNoMoreWithdrawalRequests_ZeroQueu
}

@Test
public void popWithdrawalRequestsFromQueue_WhenNoWithdrawalRequests_DoesNothing() {
void popWithdrawalRequestsFromQueue_WhenNoWithdrawalRequests_DoesNothing() {
// Loading contract with 0 WithdrawalRequests
loadContractStorage(worldState, List.of());
// After loading storage, we have the WithdrawalRequests count as zero because no
Expand All @@ -135,7 +134,7 @@ public void popWithdrawalRequestsFromQueue_WhenNoWithdrawalRequests_DoesNothing(

final List<WithdrawalRequest> poppedWithdrawalRequests =
WithdrawalRequestContractHelper.popWithdrawalRequestsFromQueue(worldState);
assertThat(poppedWithdrawalRequests).hasSize(0);
assertThat(poppedWithdrawalRequests).isEmpty();

// Check that queue pointers are correct (head and tail are zero)
assertContractStorageValue(WITHDRAWAL_REQUEST_QUEUE_HEAD_STORAGE_SLOT, 0);
Expand Down Expand Up @@ -186,14 +185,13 @@ private void loadContractStorage(
Bytes.fromHexString("0x000000000000000000000000"), request.getSourceAddress())));
// validator_pubkey
contract.setStorageValue(
UInt256.valueOf(offset++),
UInt256.fromBytes(request.getValidatorPublicKey().slice(0, 32)));
UInt256.valueOf(offset++), UInt256.fromBytes(request.getValidatorPubkey().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.getValidatorPublicKey().slice(32, 16),
request.getValidatorPubkey().slice(32, 16),
request.getAmount().toBytes(), // 8 bytes for amount
Bytes.fromHexString("0x0000000000000000"))));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,9 @@ public record RejectedTransaction(int index, String error) {}
* Default constructor for the T8nExecutor class. This constructor does not perform any
* operations.
*/
public T8nExecutor() {}
public T8nExecutor() {
// Default constructor required for Javadoc linting
}

/**
* Extracts transactions from a given JSON iterator and adds them to the provided transactions
Expand Down Expand Up @@ -531,7 +533,7 @@ static T8nResult runTest(
wr -> {
var obj = withdrawlRequests.addObject();
obj.put("sourceAddress", wr.getSourceAddress().toHexString());
obj.put("validatorPublicKey", wr.getValidatorPublicKey().toHexString());
obj.put("validatorPubkey", wr.getValidatorPubkey().toHexString());
obj.put("amount", wr.getAmount().toHexString());
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@
"code": "0x3373fffffffffffffffffffffffffffffffffffffffe14604d57602036146024575f5ffd5b5f35801560495762001fff810690815414603c575f5ffd5b62001fff01545f5260205ff35b5f5ffd5b62001fff42064281555f359062001fff015500",
"storage": {}
},
"0x25a219378dad9b3503c8268c9ca836a52427a4fb": {
"nonce": "0x00",
"balance": "0x1",
"code": "0x",
"storage": {}
},
"0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b": {
"nonce": "0x00",
"balance": "0xad78ebc5ac62000000",
Expand Down Expand Up @@ -184,7 +190,7 @@
"storage": {
"0x0000000000000000000000000000000000000000000000000000000000000000": "0xe4fb5d47f70d54b4f36777ea4c882cf767f93d8f8170285d97a1b8275dfe4dbb"
},
"balance": "0x0"
"balance": "0x1"
},
"0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b": {
"balance": "0xaa00be18c288efd690",
Expand All @@ -193,7 +199,7 @@
},
"body": "0xf90404f901ff8007830f42409400000000219ab540356cbb839cbe05303d7705fa8901bc16d674ec800000b9019422895118000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000d0000000000000000000000000000000000000000000000000000000000000011085acb6376c2707b118225da41825974c12b5924a05c6a53b988c9cbc33c55b05000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000325a0ffeb1d6e7ef8e9ee9b64dcdc3b056f9a1d2b94c1572f1949954e712364604575a03d0f42bad795205de84db8d4ab10b9abd0d081ffe560cbf45f6c281768112a69f901ff0107830f42409400000000219ab540356cbb839cbe05303d7705fa8901bc16d674ec800000b9019422895118000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000d0000000000000000000000000000000000000000000000000000000000000011085acb6376c2707b118225da41825974c12b5924a05c6a53b988c9cbc33c55b05000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000326a05bb08e348c9c4b0a2e15d04f4a89d1a210d013205de8d3d93e38e5c1b0c8d8aba04300c0f575d9908d2cbc3413ab82895678bb8f3ef356224dd1e7cb972f2c4855",
"result": {
"stateRoot": "0x0dd3e32e0081ff7ca5a0236b257676f277999ec2b8da5b31e19400715de907f1",
"stateRoot": "0x357733745f987f38d73c64d381698e0e4f45cd1352f1d27fa0d823b9dc0967b8",
"txRoot": "0x2b790bf82ef7259a0e4513d1b89a77d81e99672ba68758ef2ba3fde32851d023",
"receiptsRoot": "0x9c8d7a917ecb3ff2566f264abbf39131e51b08b07eb2b69cb46989d79d985593",
"logsHash": "0x43e31613bfefc1f55d8b3ca2b61f933f3838d523dc11cb5d7ffdd2ecf0ab5d49",
Expand Down
Loading