Skip to content

Commit

Permalink
fixing compile errors after ssz was imported
Browse files Browse the repository at this point in the history
  • Loading branch information
jrhea committed May 27, 2019
1 parent 01fb555 commit c649bd5
Show file tree
Hide file tree
Showing 50 changed files with 417 additions and 394 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ ganache-cli/
pow/src/main/resources/keys.json
*.csv*
*.json*
!lib/tuweni-ssz-0.8.1-SNAPSHOT.jar
!validator_test_data.json
*.vscode/
pow/truffle/.vscode/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ void testTwoNodes() throws InterruptedException, JsonProcessingException, IOExce
node1.start();
node2.start();

Thread.sleep(20000);
Thread.sleep(10000);

P2PNetwork net1 = node1.p2pNetwork();
P2PNetwork net2 = node2.p2pNetwork();
Expand Down
15 changes: 7 additions & 8 deletions config/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ MAX_DEPOSIT_AMOUNT = 32000000000
FORK_CHOICE_BALANCE_INCREMENT = 1000000000
EJECTION_BALANCE = 16000000000
GENESIS_FORK_VERSION = 0
GENESIS_SLOT = 0
GENESIS_EPOCH = 0
GENESIS_SLOT = 4294967296
GENESIS_EPOCH = 536870912
GENESIS_START_SHARD = 0
SECONDS_PER_SLOT = 6
MIN_ATTESTATION_INCLUSION_DELAY = 1
Expand All @@ -47,7 +47,6 @@ EPOCHS_PER_ETH1_VOTING_PERIOD = 16
SLOTS_PER_HISTORICAL_ROOT = 64
MIN_VALIDATOR_WITHDRAWABILITY_DELAY = 256
PERSISTENT_COMMITTEE_PERIOD = 2048
LATEST_BLOCK_ROOTS_LENGTH = 64
LATEST_RANDAO_MIXES_LENGTH = 64
LATEST_ACTIVE_INDEX_ROOTS_LENGTH = 64
LATEST_SLASHED_EXIT_LENGTH = 64
Expand All @@ -62,9 +61,9 @@ MAX_ATTESTATIONS = 128
MAX_DEPOSITS = 16
MAX_VOLUNTARY_EXITS = 16
MAX_TRANSFERS = 16
DOMAIN_DEPOSIT = 0
DOMAIN_ATTESTATION = 1
DOMAIN_PROPOSAL = 2
DOMAIN_EXIT = 3
DOMAIN_RANDAO = 4
DOMAIN_BEACON_BLOCK = 0
DOMAIN_RANDAO = 1
DOMAIN_ATTESTATION = 2
DOMAIN_DEPOSIT = 3
DOMAIN_VOLUNTARY_EXIT = 4
DOMAIN_TRANSFER = 5
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

package tech.pegasys.artemis.data.adapter;

import com.google.common.primitives.UnsignedLong;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.IntStream;
Expand All @@ -37,8 +38,8 @@ public TimeSeriesAdapter(RawRecord input) {
@Override
public TimeSeriesRecord transform() {

long slot = this.input.getHeadBlock().getSlot();
long epoch = BeaconStateUtil.slot_to_epoch(this.input.getHeadBlock().getSlot());
UnsignedLong slot = UnsignedLong.valueOf(this.input.getHeadBlock().getSlot());
UnsignedLong epoch = BeaconStateUtil.slot_to_epoch(slot);
BeaconBlock headBlock = this.input.getHeadBlock();
BeaconState headState = this.input.getHeadState();
BeaconBlock justifiedBlock = this.input.getJustifiedBlock();
Expand All @@ -50,7 +51,7 @@ public TimeSeriesRecord transform() {
Bytes32 headBlockRoot = headBlock.signed_root("signature");
Bytes32 lastJustifiedBlockRoot = justifiedBlock.signed_root("signature");
Bytes32 lastJustifiedStateRoot = justifiedState.hash_tree_root();
Bytes32 lastFinalizedBlockRoot = finalizedBlock.signature("signature");
Bytes32 lastFinalizedBlockRoot = finalizedBlock.signed_root("signature");
Bytes32 lastFinalizedStateRoot = finalizedState.hash_tree_root();

List<ValidatorJoin> validators = new ArrayList<>();
Expand All @@ -62,14 +63,14 @@ public TimeSeriesRecord transform() {
validators.add(
new ValidatorJoin(
headState.getValidator_registry().get(i),
headState.getValidator_balances().get(i))));
headState.getValidator_balances().get(i).longValue())));
}

return new TimeSeriesRecord(
this.input.getDate(),
this.input.getIndex(),
slot,
epoch,
slot.longValue(),
epoch.longValue(),
this.input.getHeadBlock().getState_root().toHexString(),
this.input.getHeadBlock().getPrevious_block_root().toHexString(),
this.input.getHeadBlock().signed_root("signature").toHexString(),
Expand Down
2 changes: 1 addition & 1 deletion eth-reference-tests/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ dependencies {

compile group: 'com.fasterxml.jackson.dataformat', name: 'jackson-dataformat-yaml', version: '2.9.8'
testCompile 'org.miracl.milagro.amcl:milagro-crypto-java:0.4.0'
testCompile 'org.apache.tuweni:tuweni-bytes'
implementation 'org.apache.tuweni:tuweni-bytes'
testCompile 'com.fasterxml.jackson.core:jackson-databind'
testCompile 'com.fasterxml.jackson.dataformat:jackson-dataformat-yaml'
testCompile 'org.junit.jupiter:junit-jupiter-api'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class BLSTestSuite {

// TODO: reinstate the official tests once they have been updated
// private static String testFile = "**/bls/test_bls.yml";
private static final String testFile = "**/test_bls_tmp.yml";
private static String testFile = "**/test_bls_tmp.yml";

@ParameterizedTest(name = "{index}. message hash to G2 uncompressed {0} -> {1}")
@MethodSource("readMessageHashG2Uncompressed")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
public class PermutedIndexTestSuite {

// TODO: point this to the official test file repo when it is available and correct
private static final String testFile = "**/test_vector_permutated_index_tmp.yml";
private static String testFile = "**/test_vector_permutated_index_tmp.yml";

@ParameterizedTest(name = "{index}. Test permuted index {0}")
@MethodSource("readPermutedIndexTestVectors")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ public static void init(ArtemisConfiguration config) {
? config.getGenesisStartShard()
: GENESIS_START_SHARD;
FAR_FUTURE_EPOCH =
!UnsignedLong.valueOf(config.getFarFutureEpoch()).equals(UnsignedLong.MAX_VALUE)
config.getFarFutureEpoch() != Long.MAX_VALUE
? UnsignedLong.valueOf(config.getFarFutureEpoch())
: FAR_FUTURE_EPOCH;
ZERO_HASH =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import tech.pegasys.artemis.util.hashtree.HashTreeUtil.SSZTypes;
import tech.pegasys.artemis.util.hashtree.Merkleizable;

public final class Validator implements Copyable<Validator>, Merkleizable {
public class Validator implements Copyable<Validator>, Merkleizable {

// BLS public key
private BLSPublicKey pubkey;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,16 @@ class BeaconBlockBodyTest {
private Eth1Data eth1Data = randomEth1Data();
private List<ProposerSlashing> proposerSlashings =
Arrays.asList(randomProposerSlashing(), randomProposerSlashing(), randomProposerSlashing());
private final List<AttesterSlashing> attesterSlashings =
private List<AttesterSlashing> attesterSlashings =
Arrays.asList(randomAttesterSlashing(), randomAttesterSlashing(), randomAttesterSlashing());
private final List<Attestation> attestations =
private List<Attestation> attestations =
Arrays.asList(randomAttestation(), randomAttestation(), randomAttestation());
private final List<Deposit> deposits =
Arrays.asList(randomDeposit(), randomDeposit(), randomDeposit());
private final List<VoluntaryExit> voluntaryExits =
private List<Deposit> deposits = Arrays.asList(randomDeposit(), randomDeposit(), randomDeposit());
private List<VoluntaryExit> voluntaryExits =
Arrays.asList(randomVoluntaryExit(), randomVoluntaryExit(), randomVoluntaryExit());
private final List<Transfer> transfers = Arrays.asList(randomTransfer(), randomTransfer());
private List<Transfer> transfers = Arrays.asList(randomTransfer(), randomTransfer());

private final BeaconBlockBody beaconBlockBody =
private BeaconBlockBody beaconBlockBody =
new BeaconBlockBody(
blsSignature,
eth1Data,
Expand Down Expand Up @@ -170,7 +169,7 @@ void equalsReturnsFalseWhenDepositsAreDifferent() {
@Test
void equalsReturnsFalseWhenExitsAreDifferent() {
// Create copy of exits and reverse to ensure it is different.
List<VoluntaryExit> reverseVoluntaryExits = new ArrayList<>(voluntaryExits);
List<VoluntaryExit> reverseVoluntaryExits = new ArrayList<VoluntaryExit>(voluntaryExits);
Collections.reverse(reverseVoluntaryExits);

BeaconBlockBody testBeaconBlockBody =
Expand All @@ -190,7 +189,7 @@ void equalsReturnsFalseWhenExitsAreDifferent() {
@Test
void equalsReturnsFalseWhenTransfersAreDifferent() {
// Create copy of exits and reverse to ensure it is different.
List<Transfer> reverseTransfers = new ArrayList<>(transfers);
List<Transfer> reverseTransfers = new ArrayList<Transfer>(transfers);
Collections.reverse(reverseTransfers);

BeaconBlockBody testBeaconBlockBody =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@

class Eth1DataTest {

private final Bytes32 depositRoot = Bytes32.random();
private final Bytes32 blockHash = Bytes32.random();
private Bytes32 depositRoot = Bytes32.random();
private Bytes32 blockHash = Bytes32.random();

private final Eth1Data eth1Data = new Eth1Data(depositRoot, blockHash);
private Eth1Data eth1Data = new Eth1Data(depositRoot, blockHash);

@Test
void equalsReturnsTrueWhenObjectAreSame() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,19 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static tech.pegasys.artemis.datastructures.util.DataStructureUtil.randomEth1Data;
import static tech.pegasys.artemis.datastructures.util.DataStructureUtil.randomLong;
import static tech.pegasys.artemis.datastructures.util.DataStructureUtil.randomUnsignedLong;

import com.google.common.primitives.UnsignedLong;
import java.util.Objects;
import org.apache.tuweni.bytes.Bytes;
import org.junit.jupiter.api.Test;

class Eth1DataVoteTest {

private final Eth1Data eth1Data = randomEth1Data();
private final long voteCount = randomLong();
private Eth1Data eth1Data = randomEth1Data();
private UnsignedLong voteCount = randomUnsignedLong();

private final Eth1DataVote eth1DataVote = new Eth1DataVote(eth1Data, voteCount);
private Eth1DataVote eth1DataVote = new Eth1DataVote(eth1Data, voteCount);

@Test
void equalsReturnsTrueWhenObjectAreSame() {
Expand Down Expand Up @@ -58,7 +59,8 @@ void equalsReturnsFalseWhenEth1DataIsDifferent() {

@Test
void equalsReturnsFalseWhenVoteCountsAreDifferent() {
Eth1DataVote testEth1DataVote = new Eth1DataVote(eth1Data, voteCount + randomLong());
Eth1DataVote testEth1DataVote =
new Eth1DataVote(eth1Data, voteCount.plus(randomUnsignedLong()));

assertNotEquals(eth1DataVote, testEth1DataVote);
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@

class AttestationDataAndCustodyBitTest {

private final AttestationData data = randomAttestationData();
private final boolean custodyBit = false;
private AttestationData data = randomAttestationData();
private boolean custodyBit = false;

private final AttestationDataAndCustodyBit attestationDataAndCustodyBit =
private AttestationDataAndCustodyBit attestationDataAndCustodyBit =
new AttestationDataAndCustodyBit(data, custodyBit);

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static tech.pegasys.artemis.datastructures.util.DataStructureUtil.randomCrosslink;
import static tech.pegasys.artemis.datastructures.util.DataStructureUtil.randomInt;
import static tech.pegasys.artemis.datastructures.util.DataStructureUtil.randomLong;
import static tech.pegasys.artemis.datastructures.util.DataStructureUtil.randomUnsignedLong;

import com.google.common.primitives.UnsignedLong;
import org.apache.tuweni.bytes.Bytes;
import org.apache.tuweni.bytes.Bytes32;
import org.junit.jupiter.api.Test;
Expand All @@ -35,7 +36,7 @@ class AttestationDataTest {
private Crosslink latestCrosslink = randomCrosslink();
private Bytes32 justifiedBlockRoot = Bytes32.random();

private final AttestationData attestationData =
private AttestationData attestationData =
new AttestationData(
slot,
beaconBlockRoot,
Expand Down Expand Up @@ -153,7 +154,7 @@ void equalsReturnsFalseWhenCrosslinkDataRootsAreDifferent() {
void equalsReturnsFalseWhenLatestCrosslinkRootsAreDifferent() {
Crosslink diffCrosslink =
new Crosslink(
latestCrosslink.getEpoch() + randomLong(),
latestCrosslink.getEpoch().plus(randomUnsignedLong()),
Bytes32.wrap(latestCrosslink.getCrosslink_data_root(), randomInt(0)));

AttestationData testAttestationData =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@

class AttestationTest {

private final Bytes aggregationBitfield = Bytes32.random();
private final AttestationData data = randomAttestationData();
private final Bytes custodyBitfield = Bytes32.random();
private final BLSSignature aggregateSignature = BLSSignature.random();
private Bytes aggregationBitfield = Bytes32.random();
private AttestationData data = randomAttestationData();
private Bytes custodyBitfield = Bytes32.random();
private BLSSignature aggregateSignature = BLSSignature.random();

private final Attestation attestation =
private Attestation attestation =
new Attestation(aggregationBitfield, data, custodyBitfield, aggregateSignature);

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@

class AttesterSlashingTest {

private final SlashableAttestation slashableAttestation1 = randomSlashableAttestation();
private final SlashableAttestation slashableAttestation2 = randomSlashableAttestation();
private SlashableAttestation slashableAttestation1 = randomSlashableAttestation();
private SlashableAttestation slashableAttestation2 = randomSlashableAttestation();

private final AttesterSlashing attesterSlashing =
private AttesterSlashing attesterSlashing =
new AttesterSlashing(slashableAttestation1, slashableAttestation2);

@Test
Expand Down
Loading

0 comments on commit c649bd5

Please sign in to comment.