use of tech.pegasys.teku.spec.datastructures.operations.VoluntaryExit in project teku by ConsenSys.
the class LocalSignerTest method shouldSignVoluntaryExit.
@Test
public void shouldSignVoluntaryExit() {
final VoluntaryExit voluntaryExit = dataStructureUtil.randomVoluntaryExit();
final BLSSignature expectedSignature = BLSSignature.fromBytesCompressed(Bytes.fromBase64String("qumUYTSgi8hmsS3/a1oDLGSIfOQ4+PgByZpDprnvlQKaDTXnlzGQloQ/W0kAeMa8EhXvGvF0OiGkQxEEznpVsFNhZ01H+3S2StWqq7S0mbRcbJhT6fEcyrOMqRer36q8"));
final SafeFuture<BLSSignature> result = signer.signVoluntaryExit(voluntaryExit, fork);
asyncRunner.executeQueuedActions();
assertThat(result).isCompletedWithValue(expectedSignature);
}
use of tech.pegasys.teku.spec.datastructures.operations.VoluntaryExit in project teku by ConsenSys.
the class DeletableSignerTest method signVoluntaryExit_shouldSignWhenActive.
@Test
void signVoluntaryExit_shouldSignWhenActive() {
final VoluntaryExit aggregateAndProof = dataStructureUtil.randomVoluntaryExit();
when(delegate.signVoluntaryExit(aggregateAndProof, forkInfo)).thenReturn(signatureFuture);
assertThatSafeFuture(signer.signVoluntaryExit(aggregateAndProof, forkInfo)).isCompletedWithValue(signature);
}
use of tech.pegasys.teku.spec.datastructures.operations.VoluntaryExit in project teku by ConsenSys.
the class VoluntaryExitGenerator method create.
private SignedVoluntaryExit create(ForkInfo forkInfo, UInt64 epoch, int validatorIndex, boolean valid) {
VoluntaryExit exit = new VoluntaryExit(epoch, UInt64.valueOf(validatorIndex));
BLSSignature exitSignature = new LocalSigner(spec, getKeypair(validatorIndex, valid), SYNC_RUNNER).signVoluntaryExit(exit, forkInfo).join();
return new SignedVoluntaryExit(exit, exitSignature);
}
use of tech.pegasys.teku.spec.datastructures.operations.VoluntaryExit in project teku by ConsenSys.
the class VoluntaryExitCommand method submitExitForValidator.
private void submitExitForValidator(final BLSPublicKey publicKey, final int validatorIndex) {
try {
final ForkInfo forkInfo = new ForkInfo(fork, genesisRoot);
final VoluntaryExit message = new VoluntaryExit(epoch, UInt64.valueOf(validatorIndex));
final BLSSignature signature = validators.getValidator(publicKey).orElseThrow().getSigner().signVoluntaryExit(message, forkInfo).join();
apiClient.sendVoluntaryExit(new SignedVoluntaryExit(message, signature));
SUB_COMMAND_LOG.display("Exit for validator " + publicKey.toAbbreviatedString() + " submitted.");
} catch (IllegalArgumentException ex) {
SUB_COMMAND_LOG.error("Failed to submit exit for validator " + publicKey.toAbbreviatedString());
SUB_COMMAND_LOG.error(ex.getMessage());
}
}
use of tech.pegasys.teku.spec.datastructures.operations.VoluntaryExit in project teku by ConsenSys.
the class OperationSignatureVerifier method verifyVoluntaryExitSignature.
public boolean verifyVoluntaryExitSignature(Fork fork, BeaconState state, SignedVoluntaryExit signedExit, BLSSignatureVerifier signatureVerifier) {
final VoluntaryExit exit = signedExit.getMessage();
Optional<BLSPublicKey> maybePublicKey = beaconStateAccessors.getValidatorPubKey(state, exit.getValidatorIndex());
if (maybePublicKey.isEmpty()) {
return false;
}
final Bytes32 domain = beaconStateAccessors.getDomain(Domain.VOLUNTARY_EXIT, exit.getEpoch(), fork, state.getGenesis_validators_root());
final Bytes signing_root = miscHelpers.computeSigningRoot(exit, domain);
return signatureVerifier.verify(maybePublicKey.get(), signing_root, signedExit.getSignature());
}
Aggregations