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

[Merge] Fix reference tests #4368

Merged
merged 3 commits into from
Sep 15, 2021
Merged
Show file tree
Hide file tree
Changes from 2 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 @@ -61,9 +61,7 @@ public abstract class Eth2ReferenceTestCase {
.build();

private final ImmutableMap<String, TestExecutor> MERGE_TEST_TYPES =
ImmutableMap.<String, TestExecutor>builder()
.putAll(RewardsTestExecutorPhase0.REWARDS_TEST_TYPES)
.build();
ImmutableMap.<String, TestExecutor>builder().putAll(ALTAIR_TEST_TYPES).build();

protected void runReferenceTest(final TestDefinition testDefinition) throws Throwable {
setConstants(testDefinition.getConfigName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class ManualReferenceTestRunner extends Eth2ReferenceTestCase {
* <p>e.g. set to "ssz_static" to run only ssz static tests or "ssz_static/Attestation" for only
* attestation ssz tests.
*/
private static final String TEST_TYPE = "ssz_static/ExecutionPayload";
private static final String TEST_TYPE = "";

/** Filter test to run to those from the specified spec. One of general, minimal or mainnet */
private static final String SPEC = "";
Expand All @@ -59,7 +59,6 @@ static Stream<Arguments> loadReferenceTests() throws IOException {
testDefinition ->
SPEC.isBlank() || testDefinition.getConfigName().equalsIgnoreCase(SPEC))
.filter(testDefinition -> testDefinition.getTestType().startsWith(TEST_TYPE))
.filter(testDefinition -> testDefinition.getDisplayName().contains("merge"))
.map(testDefinition -> Arguments.of(testDefinition.getDisplayName(), testDefinition));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
package tech.pegasys.teku.spec.config;

import java.util.Map;
import java.util.Optional;
import org.apache.tuweni.bytes.Bytes;
import tech.pegasys.teku.infrastructure.unsigned.UInt64;
import tech.pegasys.teku.ssz.type.Bytes4;
Expand Down Expand Up @@ -290,14 +289,4 @@ public int getDepositNetworkId() {
public Bytes getDepositContractAddress() {
return specConfig.getDepositContractAddress();
}

@Override
public Optional<SpecConfigAltair> toVersionAltair() {
return specConfig.toVersionAltair();
}

@Override
public Optional<SpecConfigMerge> toVersionMerge() {
return specConfig.toVersionMerge();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/*
* Copyright 2021 ConsenSys AG.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*/

package tech.pegasys.teku.spec.config;

import java.util.Optional;
import tech.pegasys.teku.infrastructure.unsigned.UInt64;
import tech.pegasys.teku.ssz.type.Bytes4;

public class DelegatingSpecConfigAltair extends DelegatingSpecConfig implements SpecConfigAltair {

private final SpecConfigAltair specConfigAltair;

public DelegatingSpecConfigAltair(final SpecConfigAltair specConfig) {
super(specConfig);
this.specConfigAltair = specConfig;
}

@Override
public Bytes4 getAltairForkVersion() {
return specConfigAltair.getAltairForkVersion();
}

@Override
public UInt64 getAltairForkEpoch() {
return specConfigAltair.getAltairForkEpoch();
}

@Override
public UInt64 getInactivityPenaltyQuotientAltair() {
return specConfigAltair.getInactivityPenaltyQuotientAltair();
}

@Override
public int getMinSlashingPenaltyQuotientAltair() {
return specConfigAltair.getMinSlashingPenaltyQuotientAltair();
}

@Override
public int getProportionalSlashingMultiplierAltair() {
return specConfigAltair.getProportionalSlashingMultiplierAltair();
}

@Override
public int getSyncCommitteeSize() {
return specConfigAltair.getSyncCommitteeSize();
}

@Override
public UInt64 getInactivityScoreBias() {
return specConfigAltair.getInactivityScoreBias();
}

@Override
public UInt64 getInactivityScoreRecoveryRate() {
return specConfigAltair.getInactivityScoreRecoveryRate();
}

@Override
public int getEpochsPerSyncCommitteePeriod() {
return specConfigAltair.getEpochsPerSyncCommitteePeriod();
}

@Override
public int getMinSyncCommitteeParticipants() {
return specConfigAltair.getMinSyncCommitteeParticipants();
}

@Override
public Optional<SpecConfigAltair> toVersionAltair() {
return Optional.of(this);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,59 +13,13 @@

package tech.pegasys.teku.spec.config;

import java.util.Objects;
import java.util.Optional;
import tech.pegasys.teku.infrastructure.unsigned.UInt64;
import tech.pegasys.teku.ssz.type.Bytes4;

public class SpecConfigAltair extends DelegatingSpecConfig {
public interface SpecConfigAltair extends SpecConfig {

// Updated penalties
private final UInt64 inactivityPenaltyQuotientAltair;
private final int minSlashingPenaltyQuotientAltair;
private final int proportionalSlashingMultiplierAltair;

// Misc
private final int syncCommitteeSize;
private final UInt64 inactivityScoreBias;
private final UInt64 inactivityScoreRecoveryRate;

// Time
private final int epochsPerSyncCommitteePeriod;

// Fork
private final Bytes4 altairForkVersion;
private final UInt64 altairForkEpoch;

// Sync protocol
private final int minSyncCommitteeParticipants;

public SpecConfigAltair(
final SpecConfig specConfig,
final UInt64 inactivityPenaltyQuotientAltair,
final int altairMinSlashingPenaltyQuotient,
final int proportionalSlashingMultiplierAltair,
final int syncCommitteeSize,
final UInt64 inactivityScoreBias,
final UInt64 inactivityScoreRecoveryRate,
final int epochsPerSyncCommitteePeriod,
final Bytes4 altairForkVersion,
final UInt64 altairForkEpoch,
final int minSyncCommitteeParticipants) {
super(specConfig);
this.inactivityPenaltyQuotientAltair = inactivityPenaltyQuotientAltair;
this.minSlashingPenaltyQuotientAltair = altairMinSlashingPenaltyQuotient;
this.proportionalSlashingMultiplierAltair = proportionalSlashingMultiplierAltair;
this.syncCommitteeSize = syncCommitteeSize;
this.inactivityScoreBias = inactivityScoreBias;
this.inactivityScoreRecoveryRate = inactivityScoreRecoveryRate;
this.epochsPerSyncCommitteePeriod = epochsPerSyncCommitteePeriod;
this.altairForkVersion = altairForkVersion;
this.altairForkEpoch = altairForkEpoch;
this.minSyncCommitteeParticipants = minSyncCommitteeParticipants;
}

public static SpecConfigAltair required(final SpecConfig specConfig) {
static SpecConfigAltair required(SpecConfig specConfig) {
return specConfig
.toVersionAltair()
.orElseThrow(
Expand All @@ -75,82 +29,26 @@ public static SpecConfigAltair required(final SpecConfig specConfig) {
+ specConfig.getClass().getSimpleName()));
}

public Bytes4 getAltairForkVersion() {
return altairForkVersion;
}

public UInt64 getAltairForkEpoch() {
return altairForkEpoch;
}

public UInt64 getInactivityPenaltyQuotientAltair() {
return inactivityPenaltyQuotientAltair;
}
Bytes4 getAltairForkVersion();

public int getMinSlashingPenaltyQuotientAltair() {
return minSlashingPenaltyQuotientAltair;
}
UInt64 getAltairForkEpoch();

public int getProportionalSlashingMultiplierAltair() {
return proportionalSlashingMultiplierAltair;
}
UInt64 getInactivityPenaltyQuotientAltair();

public int getSyncCommitteeSize() {
return syncCommitteeSize;
}
int getMinSlashingPenaltyQuotientAltair();

public UInt64 getInactivityScoreBias() {
return inactivityScoreBias;
}
int getProportionalSlashingMultiplierAltair();

public UInt64 getInactivityScoreRecoveryRate() {
return inactivityScoreRecoveryRate;
}
int getSyncCommitteeSize();

public int getEpochsPerSyncCommitteePeriod() {
return epochsPerSyncCommitteePeriod;
}
UInt64 getInactivityScoreBias();

public int getMinSyncCommitteeParticipants() {
return minSyncCommitteeParticipants;
}
UInt64 getInactivityScoreRecoveryRate();

@Override
public Optional<SpecConfigAltair> toVersionAltair() {
return Optional.of(this);
}
int getEpochsPerSyncCommitteePeriod();

@Override
public boolean equals(final Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
final SpecConfigAltair that = (SpecConfigAltair) o;
return Objects.equals(specConfig, that.specConfig)
&& minSlashingPenaltyQuotientAltair == that.minSlashingPenaltyQuotientAltair
&& proportionalSlashingMultiplierAltair == that.proportionalSlashingMultiplierAltair
&& syncCommitteeSize == that.syncCommitteeSize
&& Objects.equals(inactivityScoreBias, that.inactivityScoreBias)
&& Objects.equals(inactivityScoreRecoveryRate, that.inactivityScoreRecoveryRate)
&& epochsPerSyncCommitteePeriod == that.epochsPerSyncCommitteePeriod
&& minSyncCommitteeParticipants == that.minSyncCommitteeParticipants
&& Objects.equals(inactivityPenaltyQuotientAltair, that.inactivityPenaltyQuotientAltair)
&& Objects.equals(altairForkVersion, that.altairForkVersion)
&& Objects.equals(altairForkEpoch, that.altairForkEpoch);
}
int getMinSyncCommitteeParticipants();

@Override
public int hashCode() {
return Objects.hash(
specConfig,
inactivityPenaltyQuotientAltair,
minSlashingPenaltyQuotientAltair,
proportionalSlashingMultiplierAltair,
syncCommitteeSize,
inactivityScoreBias,
inactivityScoreRecoveryRate,
epochsPerSyncCommitteePeriod,
altairForkVersion,
altairForkEpoch,
minSyncCommitteeParticipants);
}
Optional<SpecConfigAltair> toVersionAltair();
}
Loading