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 consolidation rules for devnet5 #8876

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -490,8 +490,8 @@ private void processConsolidationRequest(
return;
}

// Verify that target has execution withdrawal credentials
if (!predicatesElectra.hasExecutionWithdrawalCredential(targetValidator)) {
// Verify that target has compounding withdrawal credentials
if (!predicatesElectra.hasCompoundingWithdrawalCredential(targetValidator)) {
LOG.debug("process_consolidation_request: invalid target credentials");
return;
}
Expand Down Expand Up @@ -559,11 +559,6 @@ private void processConsolidationRequest(
SszUInt64.of(UInt64.valueOf(targetValidatorIndex)));
state.getPendingConsolidations().append(pendingConsolidation);

// Churn any target excess active balance of target and raise its max
if (predicatesElectra.hasEth1WithdrawalCredential(targetValidator)) {
beaconStateMutatorsElectra.switchToCompoundingValidator(state, targetValidatorIndex);
}

LOG.debug("process_consolidation_request: created {}", pendingConsolidation);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ MAX_ATTESTER_SLASHINGS_ELECTRA: 1
# `uint64(2**3)` (= 8)
MAX_ATTESTATIONS_ELECTRA: 8
# `uint64(2**0)` (= 1)
MAX_CONSOLIDATION_REQUESTS_PER_PAYLOAD: 1
MAX_CONSOLIDATION_REQUESTS_PER_PAYLOAD: 2

# Execution
# ---------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ MAX_ATTESTER_SLASHINGS_ELECTRA: 1
# `uint64(2**3)` (= 8)
MAX_ATTESTATIONS_ELECTRA: 8
# `uint64(2**0)` (= 1)
MAX_CONSOLIDATION_REQUESTS_PER_PAYLOAD: 1
MAX_CONSOLIDATION_REQUESTS_PER_PAYLOAD: 2

# Execution
# ---------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ MAX_ATTESTER_SLASHINGS_ELECTRA: 1
# `uint64(2**3)` (= 8)
MAX_ATTESTATIONS_ELECTRA: 8
# `uint64(2**0)` (= 1)
MAX_CONSOLIDATION_REQUESTS_PER_PAYLOAD: 1
MAX_CONSOLIDATION_REQUESTS_PER_PAYLOAD: 2

# Execution
# ---------------------------------------------------------------
Expand Down
2 changes: 2 additions & 0 deletions fuzz/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
dependencies {
api 'com.fasterxml.jackson.core:jackson-databind'
implementation project(':ethereum:networks')
implementation project(':ethereum:spec')
implementation testFixtures(project(':ethereum:spec'))
Expand All @@ -10,6 +11,7 @@ dependencies {

testImplementation 'org.xerial.snappy:snappy-java'
testImplementation testFixtures(project(':ethereum:spec'))
testImplementation project(':infrastructure:json')
}


Expand Down
38 changes: 24 additions & 14 deletions fuzz/src/test/java/tech/pegasys/teku/fuzz/FuzzUtilTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import static org.assertj.core.api.Assertions.assertThat;

import com.fasterxml.jackson.core.JsonProcessingException;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.nio.file.Path;
Expand All @@ -39,6 +40,7 @@
import tech.pegasys.teku.fuzz.input.SyncAggregateFuzzInput;
import tech.pegasys.teku.fuzz.input.VoluntaryExitFuzzInput;
import tech.pegasys.teku.fuzz.input.WithdrawalRequestFuzzInput;
import tech.pegasys.teku.infrastructure.json.JsonUtil;
import tech.pegasys.teku.infrastructure.ssz.SszData;
import tech.pegasys.teku.infrastructure.ssz.schema.SszSchema;
import tech.pegasys.teku.spec.Spec;
Expand All @@ -63,6 +65,7 @@
import tech.pegasys.teku.spec.datastructures.operations.SignedBlsToExecutionChange;
import tech.pegasys.teku.spec.datastructures.operations.SignedVoluntaryExit;
import tech.pegasys.teku.spec.datastructures.state.beaconstate.BeaconState;
import tech.pegasys.teku.spec.datastructures.state.beaconstate.versions.electra.BeaconStateElectra;
import tech.pegasys.teku.spec.datastructures.state.beaconstate.versions.electra.BeaconStateSchemaElectra;
import tech.pegasys.teku.spec.schemas.SchemaDefinitionsElectra;

Expand Down Expand Up @@ -167,23 +170,26 @@ public void fuzzBlock_minimal() {
}

@Test
public void fuzzBlockHeader_minimal() {
public void fuzzBlockHeader_minimal() throws JsonProcessingException {
final FuzzUtil fuzzUtil = new FuzzUtil(false, true);

final Path testCaseDir =
Path.of("minimal/operations/block_header/pyspec_tests/basic_block_header");
final BeaconBlock data = loadSsz(testCaseDir.resolve("block.ssz_snappy"), beaconBlockSchema);
final BeaconState preState = loadSsz(testCaseDir.resolve("pre.ssz_snappy"), beaconStateSchema);
final BeaconState postState =
final BeaconStateElectra postState =
loadSsz(testCaseDir.resolve("post.ssz_snappy"), beaconStateSchema);

BlockHeaderFuzzInput input = new BlockHeaderFuzzInput(spec, preState, data);
byte[] rawInput = input.sszSerialize().toArrayUnsafe();
Optional<Bytes> result = fuzzUtil.fuzzBlockHeader(rawInput).map(Bytes::wrap);
final BlockHeaderFuzzInput input = new BlockHeaderFuzzInput(spec, preState, data);
final byte[] rawInput = input.sszSerialize().toArrayUnsafe();
final Optional<Bytes> result = fuzzUtil.fuzzBlockHeader(rawInput).map(Bytes::wrap);

Bytes expected = postState.sszSerialize();
assertThat(result).isNotEmpty();
assertThat(result.get()).isEqualTo(expected);
final BeaconStateElectra resultState =
BeaconStateElectra.required(
spec.getGenesisSchemaDefinitions().getBeaconStateSchema().sszDeserialize(result.get()));
assertThat(JsonUtil.prettySerialize(resultState, beaconStateSchema.getJsonTypeDefinition()))
.isEqualTo(JsonUtil.prettySerialize(postState, beaconStateSchema.getJsonTypeDefinition()));
}

@Test
Expand Down Expand Up @@ -380,7 +386,7 @@ public void fuzzWithdrawalRequest_minimal() {
// TODO fix as part of https://github.com/Consensys/teku/pull/8876
@Disabled("Disabling until we have a fix for this")
@Test
public void fuzzConsolidationRequest_minimal() {
public void fuzzConsolidationRequest_minimal() throws JsonProcessingException {
final FuzzUtil fuzzUtil = new FuzzUtil(false, true);

final Path testCaseDir =
Expand All @@ -394,16 +400,20 @@ public void fuzzConsolidationRequest_minimal() {
.getConsolidationRequestsSchema()
.getElementSchema());
final BeaconState preState = loadSsz(testCaseDir.resolve("pre.ssz_snappy"), beaconStateSchema);
final BeaconState postState =
final BeaconStateElectra postState =
loadSsz(testCaseDir.resolve("post.ssz_snappy"), beaconStateSchema);

ConsolidationRequestFuzzInput input = new ConsolidationRequestFuzzInput(spec, preState, data);
byte[] rawInput = input.sszSerialize().toArrayUnsafe();
Optional<Bytes> result = fuzzUtil.fuzzConsolidationRequest(rawInput).map(Bytes::wrap);
final ConsolidationRequestFuzzInput input =
new ConsolidationRequestFuzzInput(spec, preState, data);
final byte[] rawInput = input.sszSerialize().toArrayUnsafe();
final Optional<Bytes> result = fuzzUtil.fuzzConsolidationRequest(rawInput).map(Bytes::wrap);

Bytes expected = postState.sszSerialize();
assertThat(result).isNotEmpty();
assertThat(result.get()).isEqualTo(expected);
final BeaconStateElectra resultState =
BeaconStateElectra.required(
spec.getGenesisSchemaDefinitions().getBeaconStateSchema().sszDeserialize(result.get()));
assertThat(JsonUtil.prettySerialize(resultState, beaconStateSchema.getJsonTypeDefinition()))
.isEqualTo(JsonUtil.prettySerialize(postState, beaconStateSchema.getJsonTypeDefinition()));
}

@Test
Expand Down
Loading