Rename ValidatorPublicKey to ValidatorPubKey (#7280)

Adapt to EIP-7002 name change for validator public key in all places.

Signed-off-by: Danno Ferrin <danno@numisight.com>
release-24.7.0
Danno Ferrin 5 months ago committed by GitHub
parent fa63fc45b4
commit 20b82a40c9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/WithdrawalRequestParameter.java
  2. 18
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/WithdrawalRequest.java
  3. 4
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/WithdrawalRequestDecoder.java
  4. 2
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/WithdrawalRequestEncoder.java
  5. 4
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/WithdrawalRequestContractHelper.java
  6. 22
      ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/WithdrawalRequestContractHelperTest.java
  7. 6
      ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/T8nExecutor.java
  8. 8
      ethereum/evmtool/src/test/resources/org/hyperledger/besu/evmtool/t8n/prague-deposit.json
  9. 42
      ethereum/evmtool/src/test/resources/org/hyperledger/besu/evmtool/t8n/prague-withdrawal.json
  10. 2
      plugin-api/build.gradle
  11. 2
      plugin-api/src/main/java/org/hyperledger/besu/plugin/data/WithdrawalRequest.java

@ -45,7 +45,7 @@ public class WithdrawalRequestParameter {
final WithdrawalRequest withdrawalRequest) {
return new WithdrawalRequestParameter(
withdrawalRequest.getSourceAddress().toHexString(),
withdrawalRequest.getValidatorPublicKey().toHexString(),
withdrawalRequest.getValidatorPubkey().toHexString(),
withdrawalRequest.getAmount().toShortHexString());
}

@ -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;
}
@ -47,8 +47,8 @@ public class WithdrawalRequest extends Request
}
@Override
public PublicKey getValidatorPublicKey() {
return validatorPublicKey;
public PublicKey getValidatorPubkey() {
return validatorPubkey;
}
@Override
@ -61,8 +61,8 @@ public class WithdrawalRequest extends Request
return "WithdrawalRequest{"
+ "sourceAddress="
+ sourceAddress
+ " validatorPublicKey="
+ validatorPublicKey
+ " validatorPubkey="
+ validatorPubkey
+ " amount="
+ amount
+ '}';
@ -78,12 +78,12 @@ public class WithdrawalRequest extends Request
}
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);
}
}

@ -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) {

@ -48,7 +48,7 @@ public class WithdrawalRequestEncoder {
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();
}

@ -153,7 +153,7 @@ public class WithdrawalRequestContractHelper {
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
@ -165,7 +165,7 @@ public class WithdrawalRequestContractHelper {
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;

@ -31,7 +31,6 @@ import org.hyperledger.besu.evm.account.MutableAccount;
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;
@ -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);
@ -64,7 +63,7 @@ class WithdrawalRequestContractHelperTest {
}
@Test
public void
void
popWithdrawalRequestsFromQueue_whenContractCodeIsEmpty_ReturnsEmptyListOfWithdrawalRequests() {
// Create account with empty code
final WorldUpdater updater = worldState.updater();
@ -76,10 +75,10 @@ class WithdrawalRequestContractHelperTest {
}
@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
@ -102,7 +101,7 @@ class WithdrawalRequestContractHelperTest {
}
@Test
public void popWithdrawalRequestsFromQueue_WhenNoMoreWithdrawalRequests_ZeroQueuePointers() {
void popWithdrawalRequestsFromQueue_WhenNoMoreWithdrawalRequests_ZeroQueuePointers() {
final List<WithdrawalRequest> withdrawalRequests =
List.of(createExit(), createExit(), createExit());
loadContractStorage(worldState, withdrawalRequests);
@ -126,7 +125,7 @@ class WithdrawalRequestContractHelperTest {
}
@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
@ -135,7 +134,7 @@ class WithdrawalRequestContractHelperTest {
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);
@ -186,14 +185,13 @@ class WithdrawalRequestContractHelperTest {
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"))));
}

@ -110,7 +110,9 @@ public class T8nExecutor {
* 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
@ -531,7 +533,7 @@ public class T8nExecutor {
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());
});
}

@ -180,12 +180,6 @@
"balance": "0x0",
"nonce": "0x1"
},
"0x25a219378dad9b3503c8268c9ca836a52427a4fb": {
"storage": {
"0x0000000000000000000000000000000000000000000000000000000000000000": "0xe4fb5d47f70d54b4f36777ea4c882cf767f93d8f8170285d97a1b8275dfe4dbb"
},
"balance": "0x0"
},
"0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b": {
"balance": "0xaa00be18c288efd690",
"nonce": "0x2"
@ -193,7 +187,7 @@
},
"body": "0xf90404f901ff8007830f42409400000000219ab540356cbb839cbe05303d7705fa8901bc16d674ec800000b9019422895118000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000d0000000000000000000000000000000000000000000000000000000000000011085acb6376c2707b118225da41825974c12b5924a05c6a53b988c9cbc33c55b05000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000325a0ffeb1d6e7ef8e9ee9b64dcdc3b056f9a1d2b94c1572f1949954e712364604575a03d0f42bad795205de84db8d4ab10b9abd0d081ffe560cbf45f6c281768112a69f901ff0107830f42409400000000219ab540356cbb839cbe05303d7705fa8901bc16d674ec800000b9019422895118000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000d0000000000000000000000000000000000000000000000000000000000000011085acb6376c2707b118225da41825974c12b5924a05c6a53b988c9cbc33c55b05000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000326a05bb08e348c9c4b0a2e15d04f4a89d1a210d013205de8d3d93e38e5c1b0c8d8aba04300c0f575d9908d2cbc3413ab82895678bb8f3ef356224dd1e7cb972f2c4855",
"result": {
"stateRoot": "0x0dd3e32e0081ff7ca5a0236b257676f277999ec2b8da5b31e19400715de907f1",
"stateRoot": "0x83bc620ec3d5ff77109b241f561e233a5c4f35bfc3337594c12958f51ff2c1c8",
"txRoot": "0x2b790bf82ef7259a0e4513d1b89a77d81e99672ba68758ef2ba3fde32851d023",
"receiptsRoot": "0x9c8d7a917ecb3ff2566f264abbf39131e51b08b07eb2b69cb46989d79d985593",
"logsHash": "0x43e31613bfefc1f55d8b3ca2b61f933f3838d523dc11cb5d7ffdd2ecf0ab5d49",

@ -64,6 +64,12 @@
"code": "0x3373fffffffffffffffffffffffffffffffffffffffe14604d57602036146024575f5ffd5b5f35801560495762001fff810690815414603c575f5ffd5b62001fff01545f5260205ff35b5f5ffd5b62001fff42064281555f359062001fff015500",
"storage": {}
},
"0x25a219378dad9b3503c8268c9ca836a52427a4fb": {
"nonce": "0x00",
"balance": "0x1",
"code": "0x",
"storage": {}
},
"0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b": {
"nonce": "0x00",
"balance": "0xad78ebc5ac62000000",
@ -213,7 +219,7 @@
"storage": {
"0x0000000000000000000000000000000000000000000000000000000000000000": "0x10715cfbefdb8a0cb2f7d7ca5ee6d1ea65515ecb41cff0a22d1e11716a9d27fb"
},
"balance": "0x0"
"balance": "0x1"
},
"0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b": {
"balance": "0xad78ebc5ac619bbcea",
@ -222,7 +228,7 @@
},
"body": "0xf903e5f903e28007830f424094000000000000000000000000000000000000020080b90380000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001fffffffffffffffe0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003fffffffffffffffe0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005fffffffffffffffe0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007fffffffffffffffe0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000009fffffffffffffffe00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000bfffffffffffffffe00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000dfffffffffffffffe00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffffffffffffffe000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000026a0963cb6620fe5828cbc93bb7139d3f4501067d76275dff648bf48c3c100ca8dd4a04ac396104a5be4643406718f59a6e74d62a32777f5f6135e55e805e87612013c",
"result": {
"stateRoot": "0xf682e4f8f820f44fb43a20c3db274bc3c9fcb9e52cc1af3c3ea7cb21fdb2250b",
"stateRoot": "0x69dc2041a0a7e71f9e5f916c26cb6b2d7d1e255509af793337d4010d19b4b87c",
"txRoot": "0x8521df63211790726b6f1a437bb0fd4b27c00e13e7678d324c4cfddb8d834ad2",
"receiptsRoot": "0x4bd8bd5580caf4ed45f873794ad7ff9d6fd2363ae529269b17b891b68d349d75",
"logsHash": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
@ -252,82 +258,82 @@
"withdrawalRequests": [
{
"sourceAddress": "0x0000000000000000000000000000000000000200",
"validatorPublicKey": "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001",
"validatorPubkey": "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001",
"amount": "0xfffffffffffffffe"
},
{
"sourceAddress": "0x0000000000000000000000000000000000000200",
"validatorPublicKey": "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002",
"validatorPubkey": "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002",
"amount": "0x0000000000000000"
},
{
"sourceAddress": "0x0000000000000000000000000000000000000200",
"validatorPublicKey": "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003",
"validatorPubkey": "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003",
"amount": "0xfffffffffffffffe"
},
{
"sourceAddress": "0x0000000000000000000000000000000000000200",
"validatorPublicKey": "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004",
"validatorPubkey": "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004",
"amount": "0x0000000000000000"
},
{
"sourceAddress": "0x0000000000000000000000000000000000000200",
"validatorPublicKey": "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005",
"validatorPubkey": "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005",
"amount": "0xfffffffffffffffe"
},
{
"sourceAddress": "0x0000000000000000000000000000000000000200",
"validatorPublicKey": "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006",
"validatorPubkey": "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006",
"amount": "0x0000000000000000"
},
{
"sourceAddress": "0x0000000000000000000000000000000000000200",
"validatorPublicKey": "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007",
"validatorPubkey": "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007",
"amount": "0xfffffffffffffffe"
},
{
"sourceAddress": "0x0000000000000000000000000000000000000200",
"validatorPublicKey": "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008",
"validatorPubkey": "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008",
"amount": "0x0000000000000000"
},
{
"sourceAddress": "0x0000000000000000000000000000000000000200",
"validatorPublicKey": "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000009",
"validatorPubkey": "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000009",
"amount": "0xfffffffffffffffe"
},
{
"sourceAddress": "0x0000000000000000000000000000000000000200",
"validatorPublicKey": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a",
"validatorPubkey": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a",
"amount": "0x0000000000000000"
},
{
"sourceAddress": "0x0000000000000000000000000000000000000200",
"validatorPublicKey": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000b",
"validatorPubkey": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000b",
"amount": "0xfffffffffffffffe"
},
{
"sourceAddress": "0x0000000000000000000000000000000000000200",
"validatorPublicKey": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c",
"validatorPubkey": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c",
"amount": "0x0000000000000000"
},
{
"sourceAddress": "0x0000000000000000000000000000000000000200",
"validatorPublicKey": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000d",
"validatorPubkey": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000d",
"amount": "0xfffffffffffffffe"
},
{
"sourceAddress": "0x0000000000000000000000000000000000000200",
"validatorPublicKey": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e",
"validatorPubkey": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e",
"amount": "0x0000000000000000"
},
{
"sourceAddress": "0x0000000000000000000000000000000000000200",
"validatorPublicKey": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f",
"validatorPubkey": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f",
"amount": "0xfffffffffffffffe"
},
{
"sourceAddress": "0x0000000000000000000000000000000000000200",
"validatorPublicKey": "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010",
"validatorPubkey": "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010",
"amount": "0x0000000000000000"
}
]

@ -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 = 'p8jZoKgvi9o8JpVLXTlwh9HoIot4A62hKFHwSOaTF+k='
knownHash = 'Q6EK5By3BNKNa/JYqYjFw43VXWL0KVBUV3dGEQBjZ70='
}
check.dependsOn('checkAPIChanges')

@ -38,7 +38,7 @@ public interface WithdrawalRequest {
*
* @return public key of validator
*/
PublicKey getValidatorPublicKey();
PublicKey getValidatorPubkey();
/**
* The amount for withdrawal

Loading…
Cancel
Save