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

Add test for passing merge with optimistic import after safe slots #5989

Merged
merged 2 commits into from
Jul 29, 2022
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
/*
* Copyright ConsenSys Software Inc., 2022
*
* 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.test.acceptance;

import com.google.common.io.Resources;
import java.net.URL;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import tech.pegasys.teku.infrastructure.time.SystemTimeProvider;
import tech.pegasys.teku.infrastructure.unsigned.UInt64;
import tech.pegasys.teku.test.acceptance.dsl.AcceptanceTestBase;
import tech.pegasys.teku.test.acceptance.dsl.BesuNode;
import tech.pegasys.teku.test.acceptance.dsl.TekuNode;

public class OptimisticSyncSafeSlotsAcceptanceTest extends AcceptanceTestBase {
private static final String NETWORK_NAME = "less-swift";
private static final Integer SAFE_SLOTS_TO_IMPORT_OPTIMISTICALLY = 8;
private static final URL JWT_FILE = Resources.getResource("auth/ee-jwt-secret.hex");
private static final int VALIDATORS = 64;

private final SystemTimeProvider timeProvider = new SystemTimeProvider();
private BesuNode executionNode1;
private BesuNode executionNode2;
private TekuNode tekuNode1;
private TekuNode tekuNode2;

@BeforeEach
void setup() throws Exception {
final int genesisTime = timeProvider.getTimeInSeconds().plus(10).intValue();
executionNode1 =
createBesuNode(
config ->
config
.withMiningEnabled(true)
.withMergeSupport(true)
.withP2pEnabled(false)
.withGenesisFile("besu/preMergeGenesis.json")
.withJwtTokenAuthorization(JWT_FILE));
executionNode1.start();
executionNode2 =
createBesuNode(
config ->
config
.withMergeSupport(true)
.withP2pEnabled(false)
.withGenesisFile("besu/preMergeGenesis.json")
.withJwtTokenAuthorization(JWT_FILE));
executionNode2.start();

tekuNode1 =
createTekuNode(
config ->
configureTekuNode(config, executionNode1, genesisTime)
.withInteropValidators(0, VALIDATORS));
tekuNode1.start();
tekuNode2 =
createTekuNode(
config ->
configureTekuNode(config, executionNode2, genesisTime)
.withInteropValidators(0, 0)
.withPeers(tekuNode1)
.withSafeSlotsToImportOptimistically(SAFE_SLOTS_TO_IMPORT_OPTIMISTICALLY));
tekuNode2.start();
}

@Test
void shouldPassMergeOptimisticallyAndBeginFinalizationAfterSafeSlotsToImport() {
tekuNode2.waitForNonDefaultExecutionPayload();
tekuNode2.waitForOptimisticBlock();
}

private TekuNode.Config configureTekuNode(
final TekuNode.Config config, final BesuNode executionEngine, final int genesisTime) {
return config
.withNetwork(NETWORK_NAME)
.withBellatrixEpoch(UInt64.ZERO)
.withTotalTerminalDifficulty(UInt64.valueOf(10001).toString())
.withGenesisTime(genesisTime)
.withRealNetwork()
.withStartupTargetPeerCount(0)
.withExecutionEngineEndpoint(executionEngine.getInternalEngineJsonRpcUrl())
.withJwtSecretFile(JWT_FILE);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,11 @@ public Config withPeers(final TekuNode... nodes) {
return this;
}

public Config withSafeSlotsToImportOptimistically(final Integer slots) {
configMap.put("Xnetwork-safe-slots-to-import-optimistically", slots);
return this;
}

public Config withStartupTargetPeerCount(Integer startupTargetPeerCount) {
configMap.put("Xstartup-target-peer-count", startupTargetPeerCount);
return this;
Expand Down