Skip to content

Commit

Permalink
Merge branch 'master' into new-requests-2
Browse files Browse the repository at this point in the history
  • Loading branch information
lucassaldanha committed Sep 24, 2024
2 parents 3f0600c + fd599c4 commit 908f6b7
Show file tree
Hide file tree
Showing 30 changed files with 1,471 additions and 50 deletions.
12 changes: 11 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,16 @@ executors:
architecture: "amd64"
platform: "linux/amd64"

machine_large_executor_amd64:
machine:
image: ubuntu-2204:2024.01.1 # https://circleci.com/developer/machine/image/ubuntu-2204
docker_layer_caching: true
resource_class: large
working_directory: ~/project
environment:
architecture: "amd64"
platform: "linux/amd64"

machine_executor_arm64:
machine:
image: ubuntu-2204:2024.01.1 # https://circleci.com/developer/machine/image/ubuntu-2204
Expand Down Expand Up @@ -354,7 +364,7 @@ jobs:

acceptanceTests:
parallelism: 5
executor: machine_executor_amd64
executor: machine_large_executor_amd64
steps:
- install_java_21
- prepare
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
- Added support for [Ephemery Testnet](https://github.com/ephemery.dev) `--network=ephemery`
- Renamed metrics `validator_attestation_publication_delay`,`validator_block_publication_delay` and `beacon_block_import_delay_counter` to include the suffix `_total` added by the current version of prometheus.
- Updated bootnodes for Holesky network
- Added new `--p2p-flood-publish-enabled` parameter to control whenever flood publishing behaviour is enabled (applies to all subnets). Previous teku versions always had this behaviour enabled. Default is `true`.

### Bug Fixes
- removed a warning from logs about non blinded blocks being requested (#8562)
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class CapellaUpgradeAcceptanceTest extends AcceptanceTestBase {
@Test
void shouldUpgradeToCapella() throws Exception {
final UInt64 currentTime = timeProvider.getTimeInSeconds();
final int genesisTime = currentTime.plus(30).intValue(); // magic node startup time
final int genesisTime = currentTime.plus(60).intValue(); // magic node startup time
final int shanghaiTime = genesisTime + 4 * 2; // 4 slots, 2 seconds each
final Map<String, String> genesisOverrides =
Map.of("shanghaiTime", String.valueOf(shanghaiTime));
Expand All @@ -51,6 +51,15 @@ void shouldUpgradeToCapella() throws Exception {
genesisOverrides);
primaryEL.start();

TekuBeaconNode primaryNode =
createTekuBeaconNode(
beaconNodeConfigWithForks(genesisTime, primaryEL)
.withStartupTargetPeerCount(0)
.build());

primaryNode.start();
primaryNode.waitForMilestone(SpecMilestone.CAPELLA);

BesuNode secondaryEL =
createBesuNode(
BesuDockerVersion.STABLE,
Expand All @@ -64,15 +73,6 @@ void shouldUpgradeToCapella() throws Exception {
secondaryEL.start();
secondaryEL.addPeer(primaryEL);

TekuBeaconNode primaryNode =
createTekuBeaconNode(
beaconNodeConfigWithForks(genesisTime, primaryEL)
.withStartupTargetPeerCount(0)
.build());

primaryNode.start();
primaryNode.waitForMilestone(SpecMilestone.CAPELLA);

final int primaryNodeGenesisTime = primaryNode.getGenesisTime().intValue();

TekuBeaconNode lateJoiningNode =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class DenebUpgradeAcceptanceTest extends AcceptanceTestBase {
@Test
void shouldUpgradeToDeneb() throws Exception {
final UInt64 currentTime = timeProvider.getTimeInSeconds();
final int genesisTime = currentTime.plus(30).intValue(); // magic node startup time
final int genesisTime = currentTime.plus(60).intValue(); // magic node startup time
final int epochDuration = 4 * 2; // 4 slots, 2 seconds each for swift
final int shanghaiTime = genesisTime + epochDuration;
final Map<String, String> genesisOverrides =
Expand All @@ -56,6 +56,15 @@ void shouldUpgradeToDeneb() throws Exception {
genesisOverrides);
primaryEL.start();

TekuBeaconNode primaryNode =
createTekuBeaconNode(
beaconNodeWithTrustedSetup(genesisTime, primaryEL)
.withStartupTargetPeerCount(0)
.build());

primaryNode.start();
primaryNode.waitForMilestone(SpecMilestone.DENEB);

BesuNode secondaryEL =
createBesuNode(
BesuDockerVersion.STABLE,
Expand All @@ -69,15 +78,6 @@ void shouldUpgradeToDeneb() throws Exception {
secondaryEL.start();
secondaryEL.addPeer(primaryEL);

TekuBeaconNode primaryNode =
createTekuBeaconNode(
beaconNodeWithTrustedSetup(genesisTime, primaryEL)
.withStartupTargetPeerCount(0)
.build());

primaryNode.start();
primaryNode.waitForMilestone(SpecMilestone.DENEB);

final int primaryNodeGenesisTime = primaryNode.getGenesisTime().intValue();

TekuBeaconNode lateJoiningNode =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@ public boolean isGreaterThanOrEqualTo(final SpecMilestone other) {
return compareTo(other) >= 0;
}

public boolean isGreaterThan(final SpecMilestone other) {
return compareTo(other) > 0;
}

public boolean isLessThanOrEqualTo(final SpecMilestone other) {
return compareTo(other) <= 0;
}

/** Returns the milestone prior to this milestone */
public SpecMilestone getPreviousMilestone() {
if (equals(PHASE0)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,4 @@ public class Domain {

// Capella
public static final Bytes4 DOMAIN_BLS_TO_EXECUTION_CHANGE = Bytes4.fromHexString("0x0A000000");

// Electra
public static final Bytes4 DOMAIN_CONSOLIDATION = Bytes4.fromHexString("0x0B000000");
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
/*
* Copyright Consensys Software Inc., 2024
*
* 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.schemas.registry;

import static com.google.common.base.Preconditions.checkArgument;

import java.util.Map;
import java.util.NavigableMap;
import java.util.TreeMap;
import tech.pegasys.teku.spec.SpecMilestone;
import tech.pegasys.teku.spec.config.SpecConfig;
import tech.pegasys.teku.spec.schemas.registry.SchemaTypes.SchemaId;

abstract class AbstractSchemaProvider<T> implements SchemaProvider<T> {
private final NavigableMap<SpecMilestone, SpecMilestone> milestoneToEffectiveMilestone =
new TreeMap<>();
private final SchemaId<T> schemaId;

protected AbstractSchemaProvider(final SchemaId<T> schemaId) {
this.schemaId = schemaId;
}

protected void addMilestoneMapping(
final SpecMilestone milestone, final SpecMilestone untilMilestone) {
checkArgument(
untilMilestone.isGreaterThan(milestone),
"%s must be earlier than %s",
milestone,
untilMilestone);

checkOverlappingVersionMappings(milestone, untilMilestone);

SpecMilestone currentMilestone = untilMilestone;
while (currentMilestone.isGreaterThan(milestone)) {
milestoneToEffectiveMilestone.put(currentMilestone, milestone);
currentMilestone = currentMilestone.getPreviousMilestone();
}
}

private void checkOverlappingVersionMappings(
final SpecMilestone milestone, final SpecMilestone untilMilestone) {
final Map.Entry<SpecMilestone, SpecMilestone> floorEntry =
milestoneToEffectiveMilestone.floorEntry(untilMilestone);
if (floorEntry != null && floorEntry.getValue().isGreaterThanOrEqualTo(milestone)) {
throw new IllegalArgumentException(
String.format(
"Milestone %s is already mapped to %s",
floorEntry.getKey(), getEffectiveMilestone(floorEntry.getValue())));
}
final Map.Entry<SpecMilestone, SpecMilestone> ceilingEntry =
milestoneToEffectiveMilestone.ceilingEntry(milestone);
if (ceilingEntry != null && ceilingEntry.getKey().isLessThanOrEqualTo(untilMilestone)) {
throw new IllegalArgumentException(
String.format(
"Milestone %s is already mapped to %s",
ceilingEntry.getKey(), getEffectiveMilestone(ceilingEntry.getValue())));
}
}

@Override
public SpecMilestone getEffectiveMilestone(final SpecMilestone milestone) {
return milestoneToEffectiveMilestone.getOrDefault(milestone, milestone);
}

@Override
public T getSchema(final SchemaRegistry registry) {
final SpecMilestone milestone = registry.getMilestone();
final SpecMilestone effectiveMilestone = getEffectiveMilestone(milestone);
return createSchema(registry, effectiveMilestone, registry.getSpecConfig());
}

@Override
public SchemaId<T> getSchemaId() {
return schemaId;
}

protected abstract T createSchema(
SchemaRegistry registry, SpecMilestone effectiveMilestone, SpecConfig specConfig);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* Copyright Consensys Software Inc., 2024
*
* 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.schemas.registry;

import java.util.EnumMap;
import java.util.HashMap;
import java.util.Map;
import tech.pegasys.teku.spec.SpecMilestone;
import tech.pegasys.teku.spec.schemas.registry.SchemaTypes.SchemaId;

interface SchemaCache {
static SchemaCache createDefault() {
return new SchemaCache() {
private final Map<SpecMilestone, Map<SchemaId<?>, Object>> cache =
new EnumMap<>(SpecMilestone.class);

@SuppressWarnings("unchecked")
@Override
public <T> T get(final SpecMilestone milestone, final SchemaId<T> schemaId) {
final Map<?, ?> milestoneSchemaIds = cache.get(milestone);
if (milestoneSchemaIds == null) {
return null;
}
return (T) milestoneSchemaIds.get(schemaId);
}

@Override
public <T> void put(
final SpecMilestone milestone, final SchemaId<T> schemaId, final T schema) {
cache.computeIfAbsent(milestone, __ -> new HashMap<>()).put(schemaId, schema);
}
};
}

<T> T get(SpecMilestone milestone, SchemaId<T> schemaId);

<T> void put(SpecMilestone milestone, SchemaId<T> schemaId, T schema);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Copyright Consensys Software Inc., 2024
*
* 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.schemas.registry;

import static tech.pegasys.teku.spec.SpecMilestone.BELLATRIX;
import static tech.pegasys.teku.spec.SpecMilestone.CAPELLA;
import static tech.pegasys.teku.spec.SpecMilestone.DENEB;
import static tech.pegasys.teku.spec.SpecMilestone.ELECTRA;

import java.util.EnumSet;
import java.util.Set;
import tech.pegasys.teku.spec.SpecMilestone;
import tech.pegasys.teku.spec.schemas.registry.SchemaTypes.SchemaId;

interface SchemaProvider<T> {
Set<SpecMilestone> ALL_MILESTONES = EnumSet.allOf(SpecMilestone.class);
Set<SpecMilestone> FROM_BELLATRIX = from(BELLATRIX);
Set<SpecMilestone> FROM_CAPELLA = from(CAPELLA);
Set<SpecMilestone> FROM_DENEB = from(DENEB);
Set<SpecMilestone> FROM_ELECTRA = from(ELECTRA);

static Set<SpecMilestone> from(final SpecMilestone milestone) {
return EnumSet.copyOf(SpecMilestone.getAllMilestonesFrom(milestone));
}

static Set<SpecMilestone> fromTo(
final SpecMilestone fromMilestone, final SpecMilestone toMilestone) {
return EnumSet.copyOf(
SpecMilestone.getAllMilestonesFrom(fromMilestone).stream()
.filter(toMilestone::isLessThanOrEqualTo)
.toList());
}

T getSchema(SchemaRegistry registry);

Set<SpecMilestone> getSupportedMilestones();

SpecMilestone getEffectiveMilestone(SpecMilestone version);

SchemaId<T> getSchemaId();
}
Loading

0 comments on commit 908f6b7

Please sign in to comment.