Search in sources :

Example 1 with Checkpoint

use of tech.pegasys.teku.api.schema.Checkpoint in project web3signer by ConsenSys.

the class Eth2RequestUtils method createAttestationRequest.

public static Eth2SigningRequestBody createAttestationRequest(final int sourceEpoch, final int targetEpoch, final UInt64 slot) {
    final ForkInfo forkInfo = forkInfo();
    final AttestationData attestationData = new AttestationData(UInt64.valueOf(32), slot, Bytes32.fromHexString("0xb2eedb01adbd02c828d5eec09b4c70cbba12ffffba525ebf48aca33028e8ad89"), new Checkpoint(UInt64.valueOf(sourceEpoch), Bytes32.ZERO), new Checkpoint(UInt64.valueOf(targetEpoch), Bytes32.fromHexString("0xb2eedb01adbd02c828d5eec09b4c70cbba12ffffba525ebf48aca33028e8ad89")));
    final Bytes signingRoot = signingRootUtil.signingRootForSignAttestationData(attestationData.asInternalAttestationData(), forkInfo.asInternalForkInfo());
    return new Eth2SigningRequestBody(ArtifactType.ATTESTATION, signingRoot, forkInfo, null, null, attestationData, null, null, null, null, null, null, null, null);
}
Also used : AttestationData(tech.pegasys.teku.api.schema.AttestationData) Bytes(org.apache.tuweni.bytes.Bytes) Checkpoint(tech.pegasys.teku.api.schema.Checkpoint) ForkInfo(tech.pegasys.web3signer.core.service.http.handlers.signing.eth2.ForkInfo) Eth2SigningRequestBody(tech.pegasys.web3signer.core.service.http.handlers.signing.eth2.Eth2SigningRequestBody)

Example 2 with Checkpoint

use of tech.pegasys.teku.api.schema.Checkpoint in project web3signer by ConsenSys.

the class Eth2RequestUtils method createAggregateAndProof.

private static Eth2SigningRequestBody createAggregateAndProof() {
    final ForkInfo forkInfo = forkInfo();
    final Bytes sszBytes = Bytes.of(0, 0, 1, 1);
    final Attestation attestation = new Attestation(sszBytes, new AttestationData(UInt64.ZERO, UInt64.ZERO, Bytes32.fromHexString("0x100814c335d0ced5014cfa9d2e375e6d9b4e197381f8ce8af0473200fdc917fd"), new Checkpoint(UInt64.ZERO, Bytes32.ZERO), new Checkpoint(UInt64.ZERO, Bytes32.fromHexString("0x100814c335d0ced5014cfa9d2e375e6d9b4e197381f8ce8af0473200fdc917fd"))), BLSSignature.fromHexString("0xa627242e4a5853708f4ebf923960fb8192f93f2233cd347e05239d86dd9fb66b721ceec1baeae6647f498c9126074f1101a87854d674b6eebc220fd8c3d8405bdfd8e286b707975d9e00a56ec6cbbf762f23607d490f0bbb16c3e0e483d51875"));
    final BLSSignature selectionProof = BLSSignature.fromHexString("0xa63f73a03f1f42b1fd0a988b614d511eb346d0a91c809694ef76df5ae021f0f144d64e612d735bc8820950cf6f7f84cd0ae194bfe3d4242fe79688f83462e3f69d9d33de71aab0721b7dab9d6960875e5fdfd26b171a75fb51af822043820c47");
    final AggregateAndProof aggregateAndProof = new AggregateAndProof(UInt64.ONE, attestation, selectionProof);
    final Bytes signingRoot = signingRootUtil.signingRootForSignAggregateAndProof(aggregateAndProof.asInternalAggregateAndProof(spec), forkInfo.asInternalForkInfo());
    return new Eth2SigningRequestBody(ArtifactType.AGGREGATE_AND_PROOF, signingRoot, forkInfo, null, null, null, null, aggregateAndProof, null, null, null, null, null, null);
}
Also used : Bytes(org.apache.tuweni.bytes.Bytes) AttestationData(tech.pegasys.teku.api.schema.AttestationData) Checkpoint(tech.pegasys.teku.api.schema.Checkpoint) ForkInfo(tech.pegasys.web3signer.core.service.http.handlers.signing.eth2.ForkInfo) Eth2SigningRequestBody(tech.pegasys.web3signer.core.service.http.handlers.signing.eth2.Eth2SigningRequestBody) Attestation(tech.pegasys.teku.api.schema.Attestation) BLSSignature(tech.pegasys.teku.api.schema.BLSSignature) AggregateAndProof(tech.pegasys.teku.api.schema.AggregateAndProof)

Example 3 with Checkpoint

use of tech.pegasys.teku.api.schema.Checkpoint in project teku by ConsenSys.

the class GetStateFinalityCheckpointsTest method shouldReturnFinalityCheckpointsInfo.

@Test
public void shouldReturnFinalityCheckpointsInfo() throws Exception {
    final GetStateFinalityCheckpoints handler = new GetStateFinalityCheckpoints(chainDataProvider, jsonProvider);
    when(context.pathParamMap()).thenReturn(Map.of("state_id", "head"));
    when(chainDataProvider.getStateFinalityCheckpoints("head")).thenReturn(SafeFuture.completedFuture(Optional.of(new ObjectAndMetaData<>(FinalityCheckpointsResponse.fromState(state), spec.getGenesisSpec().getMilestone(), false, spec.isMilestoneSupported(SpecMilestone.BELLATRIX)))));
    handler.handle(context);
    final FinalityCheckpointsResponse expectedResponse = new FinalityCheckpointsResponse(new Checkpoint(state.getPrevious_justified_checkpoint()), new Checkpoint(state.getCurrent_justified_checkpoint()), new Checkpoint(state.getFinalized_checkpoint()));
    final GetStateFinalityCheckpointsResponse response = getResponseFromFuture(GetStateFinalityCheckpointsResponse.class);
    assertThat(response.data).isEqualTo(expectedResponse);
}
Also used : Checkpoint(tech.pegasys.teku.api.schema.Checkpoint) FinalityCheckpointsResponse(tech.pegasys.teku.api.response.v1.beacon.FinalityCheckpointsResponse) GetStateFinalityCheckpointsResponse(tech.pegasys.teku.api.response.v1.beacon.GetStateFinalityCheckpointsResponse) GetStateFinalityCheckpointsResponse(tech.pegasys.teku.api.response.v1.beacon.GetStateFinalityCheckpointsResponse) AbstractBeaconHandlerTest(tech.pegasys.teku.beaconrestapi.AbstractBeaconHandlerTest) Test(org.junit.jupiter.api.Test)

Aggregations

Checkpoint (tech.pegasys.teku.api.schema.Checkpoint)3 Bytes (org.apache.tuweni.bytes.Bytes)2 AttestationData (tech.pegasys.teku.api.schema.AttestationData)2 Eth2SigningRequestBody (tech.pegasys.web3signer.core.service.http.handlers.signing.eth2.Eth2SigningRequestBody)2 ForkInfo (tech.pegasys.web3signer.core.service.http.handlers.signing.eth2.ForkInfo)2 Test (org.junit.jupiter.api.Test)1 FinalityCheckpointsResponse (tech.pegasys.teku.api.response.v1.beacon.FinalityCheckpointsResponse)1 GetStateFinalityCheckpointsResponse (tech.pegasys.teku.api.response.v1.beacon.GetStateFinalityCheckpointsResponse)1 AggregateAndProof (tech.pegasys.teku.api.schema.AggregateAndProof)1 Attestation (tech.pegasys.teku.api.schema.Attestation)1 BLSSignature (tech.pegasys.teku.api.schema.BLSSignature)1 AbstractBeaconHandlerTest (tech.pegasys.teku.beaconrestapi.AbstractBeaconHandlerTest)1