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

Update helper functions documentation #557

Merged
merged 5 commits into from
Apr 5, 2019
Merged
Show file tree
Hide file tree
Changes from 4 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
Expand Up @@ -307,6 +307,12 @@ public static void init(ArtemisConfiguration config) {
: DEPOSIT_DATA_SIZE;
}

/**
* Return the epoch number of the given ``slot``.
*
* @param slot
* @return
*/
public static long slot_to_epoch(long slot) {
return slot / SLOTS_PER_EPOCH;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@

package tech.pegasys.artemis.datastructures.blocks;

import static tech.pegasys.artemis.datastructures.Constants.EMPTY_SIGNATURE;
import static tech.pegasys.artemis.datastructures.Constants.GENESIS_SLOT;
import static tech.pegasys.artemis.datastructures.Constants.ZERO_HASH;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Objects;
import net.consensys.cava.bytes.Bytes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class BeaconBlockBody {
private List<AttesterSlashing> attester_slashings;
private List<Attestation> attestations;
private List<Deposit> deposits;
private List<VoluntaryExit> voluntaryExits;
private List<VoluntaryExit> voluntary_exits;
private List<Transfer> transfers;

public BeaconBlockBody(
Expand All @@ -44,15 +44,15 @@ public BeaconBlockBody(
List<AttesterSlashing> attester_slashings,
List<Attestation> attestations,
List<Deposit> deposits,
List<VoluntaryExit> voluntaryExits,
List<VoluntaryExit> voluntary_exits,
List<Transfer> transfers) {
this.randao_reveal = randao_reveal;
this.eth1_data = eth1_data;
this.proposer_slashings = proposer_slashings;
this.attester_slashings = attester_slashings;
this.attestations = attestations;
this.deposits = deposits;
this.voluntaryExits = voluntaryExits;
this.voluntary_exits = voluntary_exits;
this.transfers = transfers;
}

Expand Down Expand Up @@ -93,7 +93,7 @@ public Bytes toBytes() {
List<Bytes> depositsBytes =
deposits.stream().map(item -> item.toBytes()).collect(Collectors.toList());
List<Bytes> voluntaryExitsBytes =
voluntaryExits.stream().map(item -> item.toBytes()).collect(Collectors.toList());
voluntary_exits.stream().map(item -> item.toBytes()).collect(Collectors.toList());
List<Bytes> transfersBytes =
transfers.stream().map(item -> item.toBytes()).collect(Collectors.toList());

Expand All @@ -119,7 +119,7 @@ public int hashCode() {
attester_slashings,
attestations,
deposits,
voluntaryExits,
voluntary_exits,
transfers);
}

Expand All @@ -144,7 +144,7 @@ public boolean equals(Object obj) {
&& Objects.equals(this.getAttester_slashings(), other.getAttester_slashings())
&& Objects.equals(this.getAttestations(), other.getAttestations())
&& Objects.equals(this.getDeposits(), other.getDeposits())
&& Objects.equals(this.getVoluntaryExits(), other.getVoluntaryExits())
&& Objects.equals(this.getVoluntary_exits(), other.getVoluntary_exits())
&& Objects.equals(this.getTransfers(), other.getTransfers());
}

Expand Down Expand Up @@ -197,12 +197,12 @@ public void setDeposits(List<Deposit> deposits) {
this.deposits = deposits;
}

public List<VoluntaryExit> getVoluntaryExits() {
return voluntaryExits;
public List<VoluntaryExit> getVoluntary_exits() {
return voluntary_exits;
}

public void setVoluntaryExits(List<VoluntaryExit> voluntaryExits) {
this.voluntaryExits = voluntaryExits;
public void setVoluntary_exits(List<VoluntaryExit> voluntary_exits) {
this.voluntary_exits = voluntary_exits;
}

public List<Transfer> getTransfers() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public void setSignature(BLSSignature signature) {
this.signature = signature;
}

public Bytes32 signedRoot(String truncationParam) {
public Bytes32 signed_root(String truncationParam) {
if (!truncationParam.equals("signature")) {
throw new UnsupportedOperationException(
"Only signed_root(BeaconBlockHeader, \"signature\") is currently supported for type BeaconBlockHeader.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@
public final class DepositInput {

// BLS pubkey
BLSPublicKey pubkey;
private BLSPublicKey pubkey;
// Withdrawal credentials
Bytes32 withdrawal_credentials;
private Bytes32 withdrawal_credentials;
// A BLS signature of this `DepositInput`
BLSSignature proof_of_possession;
private BLSSignature proof_of_possession;

public DepositInput(
BLSPublicKey pubkey, Bytes32 withdrawal_credentials, BLSSignature proof_of_possession) {
Expand Down Expand Up @@ -107,7 +107,7 @@ public void setProof_of_possession(BLSSignature proof_of_possession) {
this.proof_of_possession = proof_of_possession;
}

public Bytes32 signedRoot(String truncationParam) {
public Bytes32 signed_root(String truncationParam) {
if (!truncationParam.equals("proof_of_possession")) {
throw new UnsupportedOperationException(
"Only signed_root(proposal, \"proof_of_possession\") is currently supported for type Proposal.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public PendingAttestation(PendingAttestation pendingAttestation) {
this.aggregation_bitfield = pendingAttestation.getAggregation_bitfield().copy();
this.data = new AttestationData(pendingAttestation.getData());
this.custody_bitfield = pendingAttestation.getCustody_bitfield().copy();
this.inclusion_slot = pendingAttestation.getInclusionSlot();
this.inclusion_slot = pendingAttestation.getInclusion_slot();
}

@Override
Expand Down Expand Up @@ -94,7 +94,7 @@ public boolean equals(Object obj) {
return Objects.equals(this.getAggregation_bitfield(), other.getAggregation_bitfield())
&& Objects.equals(this.getData(), other.getData())
&& Objects.equals(this.getCustody_bitfield(), other.getCustody_bitfield())
&& Objects.equals(this.getInclusionSlot(), other.getInclusionSlot());
&& Objects.equals(this.getInclusion_slot(), other.getInclusion_slot());
}

/** ******************* * GETTERS & SETTERS * * ******************* */
Expand Down Expand Up @@ -122,7 +122,7 @@ public void setCustody_bitfield(Bytes custody_bitfield) {
this.custody_bitfield = custody_bitfield;
}

public UnsignedLong getInclusionSlot() {
public UnsignedLong getInclusion_slot() {
return inclusion_slot;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,10 @@

package tech.pegasys.artemis.datastructures.util;

import static com.google.common.base.Preconditions.checkArgument;

import com.google.common.primitives.UnsignedLong;
import java.nio.ByteOrder;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.PriorityQueue;
import net.consensys.cava.bytes.Bytes;
import net.consensys.cava.bytes.Bytes32;
Expand All @@ -34,7 +28,6 @@
import tech.pegasys.artemis.datastructures.state.BeaconState;
import tech.pegasys.artemis.datastructures.state.Crosslink;
import tech.pegasys.artemis.datastructures.state.CrosslinkCommittee;
import tech.pegasys.artemis.datastructures.state.PendingAttestation;
import tech.pegasys.artemis.util.bls.BLSKeyPair;
import tech.pegasys.artemis.util.bls.BLSPublicKey;
import tech.pegasys.artemis.util.bls.BLSSignature;
Expand Down Expand Up @@ -107,14 +100,14 @@ public static List<Attestation> createAttestations(
// Set attestation data
AttestationData attestationData =
new AttestationData(
slot,
headBlockRoot,
sourceEpoch,
sourceRoot,
epochBoundaryRoot,
shard,
previousCrosslink,
crosslinkDataRoot);
slot,
headBlockRoot,
sourceEpoch,
sourceRoot,
epochBoundaryRoot,
shard,
previousCrosslink,
crosslinkDataRoot);

// Create aggregation bitfield
int array_length = Math.toIntExact((crosslinkCommittee.getCommittee().size() + 7) / 8);
Expand Down
Loading