Search in sources :

Example 21 with SpecVersion

use of tech.pegasys.teku.spec.SpecVersion in project teku by ConsenSys.

the class SigningRootUtil method signingRootForSignAggregateAndProof.

public Bytes signingRootForSignAggregateAndProof(final AggregateAndProof aggregateAndProof, final ForkInfo forkInfo) {
    final UInt64 slot = aggregateAndProof.getAggregate().getData().getSlot();
    final SpecVersion specVersion = spec.atSlot(slot);
    final Bytes32 domain = spec.getDomain(Domain.AGGREGATE_AND_PROOF, spec.computeEpochAtSlot(slot), forkInfo.getFork(), forkInfo.getGenesisValidatorsRoot());
    return specVersion.miscHelpers().computeSigningRoot(aggregateAndProof, domain);
}
Also used : SpecVersion(tech.pegasys.teku.spec.SpecVersion) UInt64(tech.pegasys.teku.infrastructure.unsigned.UInt64) Bytes32(org.apache.tuweni.bytes.Bytes32)

Example 22 with SpecVersion

use of tech.pegasys.teku.spec.SpecVersion in project teku by ConsenSys.

the class WeakSubjectivityCalculator method computeWeakSubjectivityPeriod.

/**
 * @param checkpointState A trusted / effectively finalized checkpoint state
 * @return The weak subjectivity period in epochs
 */
public UInt64 computeWeakSubjectivityPeriod(final CheckpointState checkpointState) {
    final BeaconState state = checkpointState.getState();
    final int activeValidators = stateCalculator.getActiveValidators(state);
    final UInt64 totalActiveValidatorBalance = stateCalculator.getTotalActiveValidatorBalance(state, activeValidators);
    final SpecVersion specVersion = spec.atEpoch(checkpointState.getEpoch());
    return computeWeakSubjectivityPeriod(specVersion, activeValidators, totalActiveValidatorBalance);
}
Also used : SpecVersion(tech.pegasys.teku.spec.SpecVersion) UInt64(tech.pegasys.teku.infrastructure.unsigned.UInt64) BeaconState(tech.pegasys.teku.spec.datastructures.state.beaconstate.BeaconState)

Example 23 with SpecVersion

use of tech.pegasys.teku.spec.SpecVersion in project teku by ConsenSys.

the class DepositGenerator method createDepositData.

public DepositData createDepositData(final BLSKeyPair validatorKeyPair, final UInt64 amountInGwei, final BLSPublicKey withdrawalPublicKey) {
    final Bytes32 withdrawalCredentials = createWithdrawalCredentials(withdrawalPublicKey);
    final DepositMessage depositMessage = new DepositMessage(validatorKeyPair.getPublicKey(), withdrawalCredentials, amountInGwei);
    final SpecVersion specVersion = spec.getGenesisSpec();
    final Bytes32 depositDomain = specVersion.miscHelpers().computeDomain(Domain.DEPOSIT);
    final BLSSignature signature = signDeposit ? BLS.sign(validatorKeyPair.getSecretKey(), specVersion.miscHelpers().computeSigningRoot(depositMessage, depositDomain)) : BLSSignature.empty();
    return new DepositData(depositMessage, signature);
}
Also used : DepositData(tech.pegasys.teku.spec.datastructures.operations.DepositData) DepositMessage(tech.pegasys.teku.spec.datastructures.operations.DepositMessage) SpecVersion(tech.pegasys.teku.spec.SpecVersion) Bytes32(org.apache.tuweni.bytes.Bytes32) BLSSignature(tech.pegasys.teku.bls.BLSSignature)

Aggregations

SpecVersion (tech.pegasys.teku.spec.SpecVersion)23 Bytes32 (org.apache.tuweni.bytes.Bytes32)12 BeaconState (tech.pegasys.teku.spec.datastructures.state.beaconstate.BeaconState)7 UInt64 (tech.pegasys.teku.infrastructure.unsigned.UInt64)6 Bytes4 (tech.pegasys.teku.infrastructure.bytes.Bytes4)4 LogManager (org.apache.logging.log4j.LogManager)3 Logger (org.apache.logging.log4j.Logger)3 ValidatorStatusFactory (tech.pegasys.teku.spec.logic.common.statetransition.epoch.status.ValidatorStatusFactory)3 Optional (java.util.Optional)2 Bytes (org.apache.tuweni.bytes.Bytes)2 BLSSignature (tech.pegasys.teku.bls.BLSSignature)2 SafeFuture (tech.pegasys.teku.infrastructure.async.SafeFuture)2 Spec (tech.pegasys.teku.spec.Spec)2 EnrForkId (tech.pegasys.teku.spec.datastructures.networking.libp2p.rpc.EnrForkId)2 ValidatorStatuses (tech.pegasys.teku.spec.logic.common.statetransition.epoch.status.ValidatorStatuses)2 RecentChainData (tech.pegasys.teku.storage.client.RecentChainData)2 Preconditions.checkArgument (com.google.common.base.Preconditions.checkArgument)1 IntList (it.unimi.dsi.fastutil.ints.IntList)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 InputStream (java.io.InputStream)1