Search in sources :

Example 1 with ValidatorKeystores

use of tech.pegasys.teku.test.acceptance.dsl.tools.deposits.ValidatorKeystores in project teku by ConsenSys.

the class VoluntaryExitAcceptanceTest method shouldChangeValidatorStatusAfterSubmittingVoluntaryExit.

@Test
void shouldChangeValidatorStatusAfterSubmittingVoluntaryExit() throws Exception {
    final String networkName = "less-swift";
    final BesuNode eth1Node = createBesuNode();
    eth1Node.start();
    final ValidatorKeystores validatorKeystores = createTekuDepositSender(networkName).sendValidatorDeposits(eth1Node, 4);
    final TekuNode beaconNode = createTekuNode(config -> config.withNetwork(networkName).withDepositsFrom(eth1Node));
    final TekuVoluntaryExit voluntaryExitProcessFailing = createVoluntaryExit(config -> config.withBeaconNode(beaconNode)).withValidatorKeystores(validatorKeystores);
    final TekuVoluntaryExit voluntaryExitProcessSuccessful = createVoluntaryExit(config -> config.withBeaconNode(beaconNode)).withValidatorKeystores(validatorKeystores);
    final TekuValidatorNode validatorClient = createValidatorNode(config -> config.withNetwork(networkName).withInteropModeDisabled().withBeaconNode(beaconNode)).withValidatorKeystores(validatorKeystores);
    beaconNode.start();
    validatorClient.start();
    validatorClient.waitForLogMessageContaining("Published block");
    validatorClient.waitForLogMessageContaining("Published attestation");
    validatorClient.waitForLogMessageContaining("Published aggregate");
    beaconNode.waitForLogMessageContaining("Epoch: 1");
    voluntaryExitProcessFailing.start();
    beaconNode.waitForLogMessageContaining("Epoch: 3");
    voluntaryExitProcessSuccessful.start();
    validatorClient.waitForLogMessageContaining("has changed status from");
    assertThat(voluntaryExitProcessFailing.getLoggedErrors()).contains("Failed to submit exit for validator");
}
Also used : Test(org.junit.jupiter.api.Test) AcceptanceTestBase(tech.pegasys.teku.test.acceptance.dsl.AcceptanceTestBase) TekuNode(tech.pegasys.teku.test.acceptance.dsl.TekuNode) TekuValidatorNode(tech.pegasys.teku.test.acceptance.dsl.TekuValidatorNode) ValidatorKeystores(tech.pegasys.teku.test.acceptance.dsl.tools.deposits.ValidatorKeystores) BesuNode(tech.pegasys.teku.test.acceptance.dsl.BesuNode) TekuVoluntaryExit(tech.pegasys.teku.test.acceptance.dsl.TekuVoluntaryExit) AssertionsForClassTypes.assertThat(org.assertj.core.api.AssertionsForClassTypes.assertThat) BesuNode(tech.pegasys.teku.test.acceptance.dsl.BesuNode) TekuVoluntaryExit(tech.pegasys.teku.test.acceptance.dsl.TekuVoluntaryExit) TekuNode(tech.pegasys.teku.test.acceptance.dsl.TekuNode) TekuValidatorNode(tech.pegasys.teku.test.acceptance.dsl.TekuValidatorNode) ValidatorKeystores(tech.pegasys.teku.test.acceptance.dsl.tools.deposits.ValidatorKeystores) Test(org.junit.jupiter.api.Test)

Example 2 with ValidatorKeystores

use of tech.pegasys.teku.test.acceptance.dsl.tools.deposits.ValidatorKeystores in project teku by ConsenSys.

the class TekuDepositSender method sendValidatorDeposits.

public ValidatorKeystores sendValidatorDeposits(final BesuNode eth1Node, final int numberOfValidators, UInt64 amount) throws InterruptedException, ExecutionException, TimeoutException {
    final Eth1Address eth1Address = Eth1Address.fromHexString(eth1Node.getDepositContractAddress());
    final Credentials eth1Credentials = Credentials.create(eth1Node.getRichBenefactorKey());
    try (final DepositGenerator depositGenerator = new DepositGenerator(spec, eth1Node.getExternalJsonRpcUrl(), eth1Address, eth1Credentials, numberOfValidators, amount)) {
        final SafeFuture<Void> future = depositGenerator.generate();
        Waiter.waitFor(future, Duration.ofMinutes(2));
        return new ValidatorKeystores(depositGenerator.getKeys());
    }
}
Also used : DepositGenerator(tech.pegasys.teku.test.acceptance.dsl.tools.deposits.DepositGenerator) ValidatorKeystores(tech.pegasys.teku.test.acceptance.dsl.tools.deposits.ValidatorKeystores) Eth1Address(tech.pegasys.teku.spec.datastructures.eth1.Eth1Address) Credentials(org.web3j.crypto.Credentials)

Example 3 with ValidatorKeystores

use of tech.pegasys.teku.test.acceptance.dsl.tools.deposits.ValidatorKeystores in project teku by ConsenSys.

the class RemoteValidatorKeysAcceptanceTest method shouldMaintainValidatorsInMutableClient.

@Test
void shouldMaintainValidatorsInMutableClient() throws Exception {
    final String networkName = "less-swift";
    final BesuNode eth1Node = createBesuNode();
    eth1Node.start();
    final URL resource = Resources.getResource("tech/pegasys/teku/spec/config/configs/less-swift.yaml");
    final ValidatorKeystores validatorKeystores = createTekuDepositSender(networkName).sendValidatorDeposits(eth1Node, 8);
    final TekuNode beaconNode = createTekuNode(config -> {
        try {
            config.withNetwork(resource.openStream(), networkName).withDepositsFrom(eth1Node);
        } catch (IOException e) {
            LOG.error("BN configuration failed", e);
        }
    });
    final Web3SignerNode web3SignerNode = createWeb3SignerNode(config -> {
        try {
            config.withNetwork(resource.openStream());
        } catch (IOException e) {
            LOG.error("Signer configuration failed", e);
        }
    });
    web3SignerNode.start();
    final ValidatorKeysApi signerApi = web3SignerNode.getValidatorKeysApi();
    final TekuValidatorNode validatorClient = createValidatorNode(config -> {
        try {
            config.withNetwork(resource.openStream()).withValidatorApiEnabled().withExternalSignerUrl(web3SignerNode.getValidatorRestApiUrl()).withInteropModeDisabled().withBeaconNode(beaconNode);
        } catch (IOException e) {
            LOG.error("VC configuration failed", e);
        }
    });
    beaconNode.start();
    validatorClient.start();
    signerApi.addLocalValidatorsAndExpect(validatorKeystores, "imported");
    signerApi.assertLocalValidatorListing(validatorKeystores.getPublicKeys());
    final ValidatorKeysApi validatorNodeApi = validatorClient.getValidatorKeysApi();
    validatorNodeApi.assertLocalValidatorListing(Collections.emptyList());
    validatorNodeApi.assertRemoteValidatorListing(Collections.emptyList());
    validatorNodeApi.addRemoteValidatorsAndExpect(validatorKeystores.getPublicKeys(), web3SignerNode.getValidatorRestApiUrl(), "imported");
    validatorClient.waitForLogMessageContaining("Added validator");
    validatorNodeApi.assertLocalValidatorListing(Collections.emptyList());
    validatorNodeApi.assertRemoteValidatorListing(validatorKeystores.getPublicKeys());
    // add Local should see duplicates, as they're already loaded
    validatorNodeApi.addLocalValidatorsAndExpect(validatorKeystores, "duplicate");
    // second remote add should also see as duplicates
    validatorNodeApi.addRemoteValidatorsAndExpect(validatorKeystores.getPublicKeys(), web3SignerNode.getValidatorRestApiUrl(), "duplicate");
    validatorClient.waitForLogMessageContaining("Published block");
    // remove a validator
    final BLSPublicKey removedPubKey = validatorKeystores.getPublicKeys().get(0);
    validatorNodeApi.removeRemoteValidatorAndCheckStatus(removedPubKey, "deleted");
    // should only be 7 validators left
    validatorClient.waitForLogMessageContaining("Removed remote validator");
    validatorClient.waitForLogMessageContaining("Published block");
    validatorNodeApi.assertRemoteValidatorListing(validatorKeystores.getPublicKeys().subList(1, 7));
    // remove validator that doesn't exist
    validatorNodeApi.removeRemoteValidatorAndCheckStatus(removedPubKey, "not_found");
    validatorClient.stop();
    web3SignerNode.stop();
    beaconNode.stop();
    eth1Node.stop();
}
Also used : BesuNode(tech.pegasys.teku.test.acceptance.dsl.BesuNode) Web3SignerNode(tech.pegasys.teku.test.acceptance.dsl.Web3SignerNode) ValidatorKeysApi(tech.pegasys.teku.test.acceptance.dsl.tools.ValidatorKeysApi) TekuNode(tech.pegasys.teku.test.acceptance.dsl.TekuNode) TekuValidatorNode(tech.pegasys.teku.test.acceptance.dsl.TekuValidatorNode) ValidatorKeystores(tech.pegasys.teku.test.acceptance.dsl.tools.deposits.ValidatorKeystores) IOException(java.io.IOException) BLSPublicKey(tech.pegasys.teku.bls.BLSPublicKey) URL(java.net.URL) Test(org.junit.jupiter.api.Test)

Example 4 with ValidatorKeystores

use of tech.pegasys.teku.test.acceptance.dsl.tools.deposits.ValidatorKeystores in project teku by ConsenSys.

the class LocalValidatorKeysAcceptanceTest method shouldMaintainValidatorsInMutableClient.

@Test
void shouldMaintainValidatorsInMutableClient() throws Exception {
    final String networkName = "less-swift";
    final BesuNode eth1Node = createBesuNode();
    eth1Node.start();
    final ValidatorKeystores validatorKeystores = createTekuDepositSender(networkName).sendValidatorDeposits(eth1Node, 8);
    final ValidatorKeystores extraKeys = createTekuDepositSender(networkName).sendValidatorDeposits(eth1Node, 1);
    final TekuNode beaconNode = createTekuNode(config -> config.withNetwork(networkName).withDepositsFrom(eth1Node));
    final TekuValidatorNode validatorClient = createValidatorNode(config -> config.withNetwork(networkName).withValidatorApiEnabled().withInteropModeDisabled().withBeaconNode(beaconNode));
    final ValidatorKeysApi api = validatorClient.getValidatorKeysApi();
    beaconNode.start();
    validatorClient.start();
    api.assertLocalValidatorListing(Collections.emptyList());
    api.addLocalValidatorsAndExpect(validatorKeystores, "imported");
    validatorClient.waitForLogMessageContaining("Added validator");
    validatorClient.waitForLogMessageContaining("Published block");
    api.assertLocalValidatorListing(validatorKeystores.getPublicKeys());
    // second add attempt would be duplicates
    api.addLocalValidatorsAndExpect(validatorKeystores, "duplicate");
    // a random key won't be found, remove should give not_found
    api.removeLocalValidatorAndCheckStatus(extraKeys.getPublicKeys().get(0), "not_found");
    beaconNode.waitForEpoch(2);
    // remove a validator
    final BLSPublicKey removedPubkey = validatorKeystores.getPublicKeys().get(0);
    api.removeLocalValidatorAndCheckStatus(removedPubkey, "deleted");
    // should only be 7 validators left
    validatorClient.waitForLogMessageContaining("Removed validator");
    validatorClient.waitForLogMessageContaining("Published block");
    api.assertLocalValidatorListing(validatorKeystores.getPublicKeys().subList(1, 7));
    // remove the same validator again
    api.removeLocalValidatorAndCheckStatus(removedPubkey, "not_active");
    validatorClient.stop();
    beaconNode.stop();
    eth1Node.stop();
}
Also used : BesuNode(tech.pegasys.teku.test.acceptance.dsl.BesuNode) ValidatorKeysApi(tech.pegasys.teku.test.acceptance.dsl.tools.ValidatorKeysApi) TekuNode(tech.pegasys.teku.test.acceptance.dsl.TekuNode) TekuValidatorNode(tech.pegasys.teku.test.acceptance.dsl.TekuValidatorNode) ValidatorKeystores(tech.pegasys.teku.test.acceptance.dsl.tools.deposits.ValidatorKeystores) BLSPublicKey(tech.pegasys.teku.bls.BLSPublicKey) Test(org.junit.jupiter.api.Test)

Example 5 with ValidatorKeystores

use of tech.pegasys.teku.test.acceptance.dsl.tools.deposits.ValidatorKeystores in project teku by ConsenSys.

the class AddValidatorsAcceptanceTest method shouldLoadAdditionalValidatorsWithoutRestart.

@Test
void shouldLoadAdditionalValidatorsWithoutRestart() throws Exception {
    final String networkName = "less-swift";
    final BesuNode eth1Node = createBesuNode();
    eth1Node.start();
    final ValidatorKeystores initialKeystores = createTekuDepositSender(networkName).sendValidatorDeposits(eth1Node, 2);
    final ValidatorKeystores additionalKeystores = createTekuDepositSender(networkName).sendValidatorDeposits(eth1Node, 2);
    final TekuNode node = createTekuNode(config -> config.withNetwork(networkName).withDepositsFrom(eth1Node).withValidatorKeystores(initialKeystores));
    node.start();
    node.waitForOwnedValidatorCount(2);
    node.waitForGenesis();
    node.addValidators(additionalKeystores);
    node.waitForOwnedValidatorCount(4);
    // If the added validators perform their duties properly, the network will finalize.
    node.waitForNewFinalization();
    // Check loading new validators a second time still works and that they don't have to be active
    final ValidatorKeystores evenMoreKeystores = createTekuDepositSender(networkName).sendValidatorDeposits(eth1Node, 1);
    node.addValidators(evenMoreKeystores);
    node.waitForOwnedValidatorCount(5);
}
Also used : BesuNode(tech.pegasys.teku.test.acceptance.dsl.BesuNode) TekuNode(tech.pegasys.teku.test.acceptance.dsl.TekuNode) ValidatorKeystores(tech.pegasys.teku.test.acceptance.dsl.tools.deposits.ValidatorKeystores) Test(org.junit.jupiter.api.Test)

Aggregations

ValidatorKeystores (tech.pegasys.teku.test.acceptance.dsl.tools.deposits.ValidatorKeystores)5 Test (org.junit.jupiter.api.Test)4 BesuNode (tech.pegasys.teku.test.acceptance.dsl.BesuNode)4 TekuNode (tech.pegasys.teku.test.acceptance.dsl.TekuNode)4 TekuValidatorNode (tech.pegasys.teku.test.acceptance.dsl.TekuValidatorNode)3 BLSPublicKey (tech.pegasys.teku.bls.BLSPublicKey)2 ValidatorKeysApi (tech.pegasys.teku.test.acceptance.dsl.tools.ValidatorKeysApi)2 IOException (java.io.IOException)1 URL (java.net.URL)1 AssertionsForClassTypes.assertThat (org.assertj.core.api.AssertionsForClassTypes.assertThat)1 Credentials (org.web3j.crypto.Credentials)1 Eth1Address (tech.pegasys.teku.spec.datastructures.eth1.Eth1Address)1 AcceptanceTestBase (tech.pegasys.teku.test.acceptance.dsl.AcceptanceTestBase)1 TekuVoluntaryExit (tech.pegasys.teku.test.acceptance.dsl.TekuVoluntaryExit)1 Web3SignerNode (tech.pegasys.teku.test.acceptance.dsl.Web3SignerNode)1 DepositGenerator (tech.pegasys.teku.test.acceptance.dsl.tools.deposits.DepositGenerator)1