Skip to content

Commit

Permalink
Merge branch 'master' into 8891_fix
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanBratanov authored Dec 16, 2024
2 parents 8441b42 + 2148be9 commit 577e8e5
Show file tree
Hide file tree
Showing 95 changed files with 896 additions and 1,862 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,9 @@
### Breaking Changes

### Additions and Improvements
- Optimized blobs validation pipeline

### Bug Fixes
- Updated the gas change check for block building so that warnings only get raised if the change is off spec.
- Fixed an issue with the `/eth/v1/config/spec` API not returning all previously included configuration parameters.
- Increase the maximum size of a compressed message for libp2p to ensure uncompressed blocks can grow to max size.
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,7 @@ private void validateBlobSidecars(final SignedBeaconBlock block) {
final List<BlobSidecar> blobSidecars =
blobSidecarsBySlotToImport.getOrDefault(
block.getSlotAndBlockRoot(), Collections.emptyList());

LOG.trace("Validating {} blob sidecars for block {}", blobSidecars.size(), block.getRoot());
final BlobSidecarsAndValidationResult validationResult =
blobSidecarManager.createAvailabilityCheckerAndValidateImmediately(block, blobSidecars);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public void setup() {
.map(SignedBlockAndState::getBlock)
.collect(Collectors.toList());
lastBlockInBatch = chainBuilder.getLatestBlockAndState().getBlock();
firstBlockInBatch = blockBatch.get(0);
firstBlockInBatch = blockBatch.getFirst();
blobSidecarsBatch =
chainBuilder
.streamBlobSidecars(10, 20)
Expand Down Expand Up @@ -202,7 +202,7 @@ public void run_returnAllBlocksAndBlobSidecarsOnFirstRequest() {
earliestBlobSidecarSlotCaptor.capture());
assertThat(blockCaptor.getValue()).containsExactlyElementsOf(blockBatch);
assertThat(blobSidecarCaptor.getValue()).isEqualTo(blobSidecarsBatch);
assertThat(earliestBlobSidecarSlotCaptor.getValue()).contains(blockBatch.get(0).getSlot());
assertThat(earliestBlobSidecarSlotCaptor.getValue()).contains(blockBatch.getFirst().getSlot());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,8 @@ void shouldCreateBlobSidecarsForBlockContents() {
assertThat(blobSidecar.getSszKZGCommitment())
.isEqualTo(expectedCommitments.get(index));
// verify the merkle proof
assertThat(miscHelpersDeneb.verifyBlobSidecarMerkleProof(blobSidecar)).isTrue();
assertThat(miscHelpersDeneb.verifyBlobKzgCommitmentInclusionProof(blobSidecar))
.isTrue();
});
}

Expand Down Expand Up @@ -921,7 +922,8 @@ void shouldCreateBlobSidecarsForBlindedBlock(final boolean useLocalFallback) {
assertThat(blobSidecar.getSszKZGCommitment())
.isEqualTo(expectedCommitments.get(index));
// verify the merkle proof
assertThat(miscHelpersDeneb.verifyBlobSidecarMerkleProof(blobSidecar)).isTrue();
assertThat(miscHelpersDeneb.verifyBlobKzgCommitmentInclusionProof(blobSidecar))
.isTrue();
});
}

Expand Down
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
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public GetSpec(final DataProvider dataProvider) {
@Override
public void handleRequest(final RestApiRequest request) throws JsonProcessingException {
try {
final SpecConfigData responseContext = new SpecConfigData(configProvider.getGenesisSpec());
final SpecConfigData responseContext = new SpecConfigData(configProvider.getSpecConfig());
request.respondOk(responseContext.getConfigMap());
} catch (JsonProcessingException e) {
String message =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public class EventSubscriber {
private final AtomicBoolean processingQueue;
private final AsyncRunner asyncRunner;
private final AtomicLong excessiveQueueingDisconnectionTime = new AtomicLong(Long.MAX_VALUE);
private volatile AtomicInteger successiveFailureCounter = new AtomicInteger(0);
private final AtomicInteger successiveFailureCounter = new AtomicInteger(0);

public EventSubscriber(
final List<String> eventTypes,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,27 @@

package tech.pegasys.teku.beaconrestapi.handlers.v1.config;

import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.assertj.core.api.Assertions.assertThat;
import static tech.pegasys.teku.infrastructure.http.HttpStatusCodes.SC_BAD_REQUEST;
import static tech.pegasys.teku.infrastructure.http.HttpStatusCodes.SC_INTERNAL_SERVER_ERROR;
import static tech.pegasys.teku.infrastructure.http.HttpStatusCodes.SC_OK;
import static tech.pegasys.teku.infrastructure.json.JsonTestUtil.parseStringMap;
import static tech.pegasys.teku.infrastructure.restapi.MetadataTestUtil.verifyMetadataErrorResponse;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.google.common.io.Resources;
import java.util.Map;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import tech.pegasys.teku.api.ConfigProvider;
import tech.pegasys.teku.api.SpecConfigData;
import tech.pegasys.teku.beaconrestapi.AbstractMigratedBeaconHandlerTest;
import tech.pegasys.teku.spec.SpecFactory;

class GetSpecTest extends AbstractMigratedBeaconHandlerTest {
private final ConfigProvider configProvider = new ConfigProvider(spec);
private final SpecConfigData response = new SpecConfigData(configProvider.getGenesisSpecConfig());
private final SpecConfigData response = new SpecConfigData(configProvider.getSpecConfig());

@BeforeEach
void setUp() {
Expand All @@ -51,4 +56,20 @@ void metadata_shouldHandle400() throws JsonProcessingException {
void metadata_shouldHandle500() throws JsonProcessingException {
verifyMetadataErrorResponse(handler, SC_INTERNAL_SERVER_ERROR);
}

@Test
@SuppressWarnings("unchecked")
void shouldGetCorrectMainnetConfig() throws Exception {
final ConfigProvider configProvider = new ConfigProvider(SpecFactory.create("mainnet"));
setHandler(new GetSpec(configProvider));
handler.handleRequest(request);

final Map<String, String> result = (Map<String, String>) request.getResponseBody();
final Map<String, String> expected =
parseStringMap(
Resources.toString(
Resources.getResource(GetSpecTest.class, "mainnetConfig.json"), UTF_8));

assertThat(result).containsExactlyInAnyOrderEntriesOf(expected);
}
}

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
{
"SLOTS_PER_EPOCH" : "32",
"PRESET_BASE" : "mainnet",
"TERMINAL_TOTAL_DIFFICULTY" : "58750000000000000000000",
"INACTIVITY_SCORE_BIAS" : "4",
"MAX_ATTESTER_SLASHINGS" : "2",
"MAX_WITHDRAWALS_PER_PAYLOAD" : "16",
"INACTIVITY_PENALTY_QUOTIENT_BELLATRIX" : "16777216",
"PENDING_PARTIAL_WITHDRAWALS_LIMIT" : "134217728",
"INACTIVITY_PENALTY_QUOTIENT" : "67108864",
"SAFE_SLOTS_TO_UPDATE_JUSTIFIED" : "8",
"SECONDS_PER_ETH1_BLOCK" : "14",
"MIN_SEED_LOOKAHEAD" : "1",
"VALIDATOR_REGISTRY_LIMIT" : "1099511627776",
"REORG_MAX_EPOCHS_SINCE_FINALIZATION" : "2",
"SLOTS_PER_HISTORICAL_ROOT" : "8192",
"RESP_TIMEOUT" : "10",
"DOMAIN_VOLUNTARY_EXIT" : "0x04000000",
"MAX_VALIDATORS_PER_COMMITTEE" : "2048",
"MIN_GENESIS_TIME" : "1606824000",
"ALTAIR_FORK_EPOCH" : "74240",
"MAX_PER_EPOCH_ACTIVATION_EXIT_CHURN_LIMIT" : "256000000000",
"HYSTERESIS_QUOTIENT" : "4",
"ALTAIR_FORK_VERSION" : "0x01000000",
"MAX_BYTES_PER_TRANSACTION" : "1073741824",
"MAX_CHUNK_SIZE" : "10485760",
"TTFB_TIMEOUT" : "5",
"WHISTLEBLOWER_REWARD_QUOTIENT" : "512",
"PROPOSER_REWARD_QUOTIENT" : "8",
"MAX_VALIDATORS_PER_WITHDRAWALS_SWEEP" : "16384",
"EPOCHS_PER_HISTORICAL_VECTOR" : "65536",
"MIN_PER_EPOCH_CHURN_LIMIT" : "4",
"MAX_ATTESTER_SLASHINGS_ELECTRA" : "1",
"TARGET_AGGREGATORS_PER_SYNC_SUBCOMMITTEE" : "16",
"MAX_DEPOSITS" : "16",
"BELLATRIX_FORK_EPOCH" : "144896",
"MAX_REQUEST_BLOB_SIDECARS" : "768",
"REORG_HEAD_WEIGHT_THRESHOLD" : "20",
"TARGET_AGGREGATORS_PER_COMMITTEE" : "16",
"DOMAIN_SYNC_COMMITTEE_SELECTION_PROOF" : "0x08000000",
"MESSAGE_DOMAIN_INVALID_SNAPPY" : "0x00000000",
"EPOCHS_PER_SLASHINGS_VECTOR" : "8192",
"MIN_SLASHING_PENALTY_QUOTIENT" : "128",
"MAX_BLS_TO_EXECUTION_CHANGES" : "16",
"GOSSIP_MAX_SIZE" : "10485760",
"TARGET_BLOBS_PER_BLOCK_ELECTRA" : "3",
"DOMAIN_BEACON_ATTESTER" : "0x01000000",
"EPOCHS_PER_SUBNET_SUBSCRIPTION" : "256",
"PENDING_DEPOSITS_LIMIT" : "134217728",
"MAX_ATTESTATIONS_ELECTRA" : "8",
"ATTESTATION_SUBNET_COUNT" : "64",
"GENESIS_DELAY" : "604800",
"MAX_SEED_LOOKAHEAD" : "4",
"ETH1_FOLLOW_DISTANCE" : "2048",
"SECONDS_PER_SLOT" : "12",
"REORG_PARENT_WEIGHT_THRESHOLD" : "160",
"MIN_SYNC_COMMITTEE_PARTICIPANTS" : "1",
"MAX_PENDING_DEPOSITS_PER_EPOCH" : "16",
"BELLATRIX_FORK_VERSION" : "0x02000000",
"PROPORTIONAL_SLASHING_MULTIPLIER_BELLATRIX" : "3",
"EFFECTIVE_BALANCE_INCREMENT" : "1000000000",
"MIN_PER_EPOCH_CHURN_LIMIT_ELECTRA" : "128000000000",
"FIELD_ELEMENTS_PER_BLOB" : "4096",
"MIN_EPOCHS_TO_INACTIVITY_PENALTY" : "4",
"BASE_REWARD_FACTOR" : "64",
"MAX_EXTRA_DATA_BYTES" : "32",
"CONFIG_NAME" : "mainnet",
"MAX_PROPOSER_SLASHINGS" : "16",
"INACTIVITY_SCORE_RECOVERY_RATE" : "16",
"MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS" : "4096",
"MAX_TRANSACTIONS_PER_PAYLOAD" : "1048576",
"DEPOSIT_CONTRACT_ADDRESS" : "0x00000000219ab540356cBB839Cbe05303d7705Fa",
"MIN_ATTESTATION_INCLUSION_DELAY" : "1",
"SHUFFLE_ROUND_COUNT" : "90",
"TERMINAL_BLOCK_HASH_ACTIVATION_EPOCH" : "18446744073709551615",
"MAX_EFFECTIVE_BALANCE" : "32000000000",
"DOMAIN_BEACON_PROPOSER" : "0x00000000",
"DENEB_FORK_EPOCH" : "269568",
"DOMAIN_SYNC_COMMITTEE" : "0x07000000",
"PROPOSER_SCORE_BOOST" : "40",
"DOMAIN_SELECTION_PROOF" : "0x05000000",
"MIN_SLASHING_PENALTY_QUOTIENT_BELLATRIX" : "32",
"MAX_PER_EPOCH_ACTIVATION_CHURN_LIMIT" : "8",
"HYSTERESIS_UPWARD_MULTIPLIER" : "5",
"SUBNETS_PER_NODE" : "2",
"MIN_DEPOSIT_AMOUNT" : "1000000000",
"MIN_SLASHING_PENALTY_QUOTIENT_ELECTRA" : "4096",
"PROPORTIONAL_SLASHING_MULTIPLIER_ALTAIR" : "2",
"MAX_BLOBS_PER_BLOCK" : "6",
"MIN_VALIDATOR_WITHDRAWABILITY_DELAY" : "256",
"MAXIMUM_GOSSIP_CLOCK_DISPARITY" : "500",
"TARGET_COMMITTEE_SIZE" : "128",
"TERMINAL_BLOCK_HASH" : "0x0000000000000000000000000000000000000000000000000000000000000000",
"DOMAIN_DEPOSIT" : "0x03000000",
"DOMAIN_CONTRIBUTION_AND_PROOF" : "0x09000000",
"UPDATE_TIMEOUT" : "8192",
"ELECTRA_FORK_EPOCH" : "18446744073709551615",
"SYNC_COMMITTEE_BRANCH_LENGTH" : "5",
"DEPOSIT_CHAIN_ID" : "1",
"MAX_BLOB_COMMITMENTS_PER_BLOCK" : "4096",
"DOMAIN_RANDAO" : "0x02000000",
"CAPELLA_FORK_VERSION" : "0x03000000",
"MAX_EFFECTIVE_BALANCE_ELECTRA" : "2048000000000",
"MIN_SLASHING_PENALTY_QUOTIENT_ALTAIR" : "64",
"EPOCHS_PER_ETH1_VOTING_PERIOD" : "64",
"WHISTLEBLOWER_REWARD_QUOTIENT_ELECTRA" : "4096",
"HISTORICAL_ROOTS_LIMIT" : "16777216",
"ATTESTATION_PROPAGATION_SLOT_RANGE" : "32",
"MAX_BLOBS_PER_BLOCK_ELECTRA" : "6",
"SYNC_COMMITTEE_SIZE" : "512",
"ATTESTATION_SUBNET_PREFIX_BITS" : "6",
"PROPORTIONAL_SLASHING_MULTIPLIER" : "1",
"MAX_WITHDRAWAL_REQUESTS_PER_PAYLOAD" : "16",
"MESSAGE_DOMAIN_VALID_SNAPPY" : "0x01000000",
"MAX_VOLUNTARY_EXITS" : "16",
"PENDING_CONSOLIDATIONS_LIMIT" : "262144",
"HYSTERESIS_DOWNWARD_MULTIPLIER" : "1",
"DOMAIN_APPLICATION_BUILDER" : "0x00000001",
"MAX_PENDING_PARTIALS_PER_WITHDRAWALS_SWEEP" : "8",
"EPOCHS_PER_SYNC_COMMITTEE_PERIOD" : "256",
"BYTES_PER_LOGS_BLOOM" : "256",
"MAX_DEPOSIT_REQUESTS_PER_PAYLOAD" : "8192",
"MIN_GENESIS_ACTIVE_VALIDATOR_COUNT" : "16384",
"MAX_REQUEST_BLOB_SIDECARS_ELECTRA" : "768",
"BLOB_SIDECAR_SUBNET_COUNT_ELECTRA" : "6",
"MAX_ATTESTATIONS" : "128",
"MIN_EPOCHS_FOR_BLOCK_REQUESTS" : "33024",
"DENEB_FORK_VERSION" : "0x04000000",
"ELECTRA_FORK_VERSION" : "0x05000000",
"MAX_REQUEST_BLOCKS" : "1024",
"GENESIS_FORK_VERSION" : "0x00000000",
"KZG_COMMITMENT_INCLUSION_PROOF_DEPTH" : "17",
"DEPOSIT_NETWORK_ID" : "1",
"MAX_CONSOLIDATION_REQUESTS_PER_PAYLOAD" : "1",
"MAX_REQUEST_BLOCKS_DENEB" : "128",
"BLOB_SIDECAR_SUBNET_COUNT" : "6",
"SYNC_COMMITTEE_SUBNET_COUNT" : "4",
"CAPELLA_FORK_EPOCH" : "194048",
"EJECTION_BALANCE" : "16000000000",
"ATTESTATION_SUBNET_EXTRA_BITS" : "0",
"MAX_COMMITTEES_PER_SLOT" : "64",
"SHARD_COMMITTEE_PERIOD" : "256",
"INACTIVITY_PENALTY_QUOTIENT_ALTAIR" : "50331648",
"DOMAIN_AGGREGATE_AND_PROOF" : "0x06000000",
"CHURN_LIMIT_QUOTIENT" : "65536",
"BLS_WITHDRAWAL_PREFIX" : "0x00",
"MIN_ACTIVATION_BALANCE" : "32000000000"
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,13 @@ public ConfigProvider(final Spec spec) {
}

public Map<String, String> getConfig() {
final SpecConfigData configuration = new SpecConfigData(spec.getGenesisSpecConfig());
final SpecConfigData configuration =
new SpecConfigData(spec.getSpecConfigAndParent().specConfig());
return configuration.getConfigMap();
}

public SpecConfig getGenesisSpec() {
return spec.atEpoch(UInt64.ZERO).getConfig();
public SpecConfig getSpecConfig() {
return spec.getSpecConfigAndParent().specConfig();
}

public static String formatValue(final Object v) {
Expand Down
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 @@ -98,12 +98,6 @@ public SafeFuture<BlobSidecarsAndValidationResult> getAvailabilityCheckResult()
return SafeFuture.completedFuture(validateImmediately(block, blobsAndProofs));
}

@Override
public BlobSidecarsAndValidationResult validateImmediately(
final List<BlobSidecar> blobSidecars) {
throw new UnsupportedOperationException("Not available in fork choice reference tests");
}

private BlobSidecarsAndValidationResult validateImmediately(
final SignedBeaconBlock block, final BlobsAndProofs blobsAndProofs) {
final List<KZGCommitment> kzgCommitments =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ public class ReferenceTestFinder {
Path.of("src", "referenceTest", "resources", "consensus-spec-tests", "tests");
private static final List<String> SUPPORTED_FORKS =
List.of(
TestFork.PHASE0, TestFork.ALTAIR, TestFork.BELLATRIX, TestFork.CAPELLA, TestFork.DENEB);
TestFork.PHASE0,
TestFork.ALTAIR,
TestFork.BELLATRIX,
TestFork.CAPELLA,
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 @@ -30,7 +30,6 @@
import tech.pegasys.teku.ethereum.executionclient.schema.PayloadAttributesV1;
import tech.pegasys.teku.ethereum.executionclient.schema.PayloadAttributesV2;
import tech.pegasys.teku.ethereum.executionclient.schema.PayloadAttributesV3;
import tech.pegasys.teku.ethereum.executionclient.schema.PayloadAttributesV4;
import tech.pegasys.teku.ethereum.executionclient.schema.PayloadStatusV1;
import tech.pegasys.teku.ethereum.executionclient.schema.Response;
import tech.pegasys.teku.infrastructure.async.SafeFuture;
Expand Down Expand Up @@ -77,9 +76,6 @@ SafeFuture<Response<ForkChoiceUpdatedResult>> forkChoiceUpdatedV2(
SafeFuture<Response<ForkChoiceUpdatedResult>> forkChoiceUpdatedV3(
ForkChoiceStateV1 forkChoiceState, Optional<PayloadAttributesV3> payloadAttributes);

SafeFuture<Response<ForkChoiceUpdatedResult>> forkChoiceUpdatedV4(
ForkChoiceStateV1 forkChoiceState, Optional<PayloadAttributesV4> payloadAttributes);

SafeFuture<Response<List<String>>> exchangeCapabilities(List<String> capabilities);

SafeFuture<Response<List<ClientVersionV1>>> getClientVersionV1(ClientVersionV1 clientVersion);
Expand Down
Loading

0 comments on commit 577e8e5

Please sign in to comment.