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

Midway merge 0.5.1 #687

Merged
merged 74 commits into from
Jun 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
c626aaa
Temporarily Disable Artemis Runtime CI Step for Spec Upgrade (#540)
schroedingerscode Apr 1, 2019
9b2bdc9
Change beacon state (#541)
cemozerr Apr 1, 2019
5e56756
Implement HistoricalBatch for use during epoch processing. (#546)
schroedingerscode Apr 2, 2019
e3c76c2
0.5.1 state transition changes (#547)
cemozerr Apr 4, 2019
ed5eb76
Rewrite helper functions (#556)
cemozerr Apr 5, 2019
2c5719f
Update helper functions documentation (#557)
Apr 5, 2019
b2b2fa2
Revert "Update helper functions documentation (#557)" (#559)
Apr 5, 2019
1f842b5
Updates function signatures, adds and updates docstrings, removes dup…
Apr 5, 2019
46ef4e4
Cleans up comments, consistent styling for function and param names (…
Apr 10, 2019
bad1baa
make get_beacon_proposer_index safe for next epoch. (#580)
Apr 11, 2019
2a481b2
Minor fixes to build errors in codebase (#577)
Apr 11, 2019
cfb3097
Slash proposers based on epoch instead of slot (#579)
Apr 11, 2019
f950e28
Align Datastructures to Spec and Add Fixed-Length Tuple Support (#554)
schroedingerscode Apr 15, 2019
a952307
Change lmdGhost & run spotlessApply (#585)
cemozerr Apr 16, 2019
4b610ac
Fix build errors (#587)
cemozerr Apr 16, 2019
21f3c84
Fixes indexing error from spec in verify_merkle_branch (#588)
Apr 16, 2019
3e9a5e9
Revert "Fixes indexing error from spec in verify_merkle_branch (#588)…
cemozerr Apr 16, 2019
4e260b1
Initialize branch as array of size 32. (#590)
Apr 16, 2019
dcd91ad
Fixes build errors from tests (#591)
Apr 16, 2019
881cc73
Fixes build errors related from tests (#593)
Apr 17, 2019
d2f190e
Upgrade SSZ to v0.5.1 (#611)
schroedingerscode May 6, 2019
a735c19
BeaconState SSZ fixes, and run spotless. (#626)
schroedingerscode May 6, 2019
fa3ebf5
SSZ Debugging (#627)
schroedingerscode May 6, 2019
eeb3d5d
Revert get_domain calculation order change after clarification. (#630)
schroedingerscode May 6, 2019
a08bb03
Revert "Revert get_domain calculation order change after clarificatio…
schroedingerscode May 6, 2019
9538cd7
Resolve genesis state transition bug. Got to set the state root... (#…
schroedingerscode May 8, 2019
c3f3ede
Resolve genesis state transition bug. Got to set the state root... (#…
schroedingerscode May 8, 2019
85e2bad
Remove expectation to pass length mixin when reading BLS primitives. …
schroedingerscode May 8, 2019
68153b2
Do not verify when producing (#643)
cemozerr May 8, 2019
f4af8ff
Remove unnecessary argument (#644)
cemozerr May 8, 2019
2c31f2a
Fix not finding parent (#646)
cemozerr May 8, 2019
00ad3bb
Fix helper function and npe (#648)
cemozerr May 8, 2019
5f85a3c
Fixes null pointer exception (#654)
May 9, 2019
e65d5fd
Fix attestation source root error (#655)
cemozerr May 9, 2019
a6cb304
Add hash_tree_root support to HistoricalBatch. (#658)
schroedingerscode May 9, 2019
5fadf23
Add hash_tree_root support to HistoricalBatch. (#659)
schroedingerscode May 9, 2019
19cfe44
Remove merkle_root in favor of hash_tree_root functions (#645)
May 13, 2019
1519f05
Refactor process slashings (#647)
May 13, 2019
fc1bbc2
Fix compile error (#669)
May 13, 2019
a553efa
Fix invalid randao error (#668)
cemozerr May 13, 2019
2b98a42
Fix Previous Epoch Error (#673)
cemozerr May 21, 2019
6c8cc9f
Fix process_attestation error (#674)
cemozerr May 22, 2019
80bd172
Add missing Merkleizable flag to remaining types. (#675)
schroedingerscode May 23, 2019
3073885
Fix deep copy error (#676)
cemozerr May 23, 2019
ae4ce1c
Add new event GenesisHeadStateEvent to await initial block creation. …
schroedingerscode May 23, 2019
0920a61
Fix equals error (#679)
cemozerr May 23, 2019
e6d70b5
Remove internal event bus from event and use external bus. (#680)
schroedingerscode May 23, 2019
67798ab
Break inheritance connection between events to fix duplicate event bu…
schroedingerscode May 24, 2019
d38fe5a
Implements validator changes from spec version 0.6.1
cemozerr May 24, 2019
9f18800
Fix justified epoch error
cemozerr May 25, 2019
7a975cc
Merge branch 'v0.5.1-integration'
cemozerr May 27, 2019
d70c81c
Midway merge fixes
cemozerr May 27, 2019
4156737
resolving issues from auto-merges
jrhea May 27, 2019
01fb555
updating to tuweni jar file and updating references
jrhea May 27, 2019
c6ebefb
fixing compile errors after ssz was imported
jrhea May 27, 2019
fee7ef6
Fix attestation npe & change test
cemozerr May 27, 2019
5279520
adding the updated initializeValidators() method
jrhea May 28, 2019
84c671a
Resolve SSZ discrepancies in BLS implementation.
schroedingerscode May 29, 2019
4899520
Update build.gradle files to resolve some IDE complaints.
schroedingerscode May 29, 2019
45c21c7
Add Plumtree fixes, add missing gradle dependency.
schroedingerscode May 31, 2019
6630214
Merge branch 'master' into midwayMerge
schroedingerscode May 31, 2019
3fca595
Fix failing roundtrip SSZ tests. We should be able to sync with our o…
schroedingerscode Jun 2, 2019
8816579
Fixes to BeaconStateTest
jrhea Jun 2, 2019
680a05b
Merge remote-tracking branch 'upstream/master' into midwayMerge
jrhea Jun 2, 2019
95d6c40
added null check to onNewUnprocessedAttestation in ChainStorageClient…
jrhea Jun 2, 2019
9efa559
Merge remote-tracking branch 'upstream/master' into midwayMerge
jrhea Jun 2, 2019
83bd82a
removed ssz dependency from data metrics to fix error. it can be add…
jrhea Jun 2, 2019
abef881
Auto-generate protobuf for grpc
cemozerr May 31, 2019
23820cd
Merge pull request #2 from cemozerr/addGrpcAutoGeneration
cemozerr Jun 3, 2019
755fca8
Add missing index update
cemozerr Jun 4, 2019
5a153fe
Add vertical run mode
cemozerr Jun 4, 2019
91c92e9
Enable client specific optimization
cemozerr Jun 4, 2019
b4a317d
Add crosslink committe caching
cemozerr Jun 4, 2019
e7f84d7
Merge branch 'master' into midwayMerge
jrhea Jun 4, 2019
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
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
*.pcap binary
*.blocks binary
*.json filter=lfs diff=lfs merge=lfs -text

3 changes: 2 additions & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ try {
}
stage('Test') {
sh './gradlew --no-daemon --parallel test'
sh './artemis/src/main/resources/artemisTestScript.sh'
// Disable Artemis Runtime Tests During Upgrade
// sh './artemis/src/main/resources/artemisTestScript.sh'
}
} finally {
archiveArtifacts '**/build/reports/**'
Expand Down
2 changes: 1 addition & 1 deletion artemis/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ dependencies {
api 'com.google.guava:guava:27.0.1-jre'
implementation 'org.apache.tuweni:tuweni-crypto'
implementation 'org.apache.tuweni:tuweni-plumtree'
implementation 'org.apache.tuweni:tuweni-ssz'
implementation files("../lib/tuweni-ssz-0.8.1-SNAPSHOT.jar")
implementation 'org.apache.tuweni:tuweni-toml'
implementation 'org.apache.tuweni:tuweni-units'
implementation 'info.picocli:picocli'
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
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ plugins {
id 'net.ltgt.errorprone' version '0.7' apply false
id 'net.researchgate.release' version '2.7.0'
id 'com.gradle.build-scan' version '2.1'

}

defaultTasks 'build','checkLicenses'
Expand Down Expand Up @@ -91,6 +92,7 @@ allprojects {
exclude 'web3j'
//Excluding tech.pegasys.artemis.datastructures due to preferred formatting overwritten by plugin in getConstantsAsString.
exclude '**/src/main/java/tech/pegasys/artemis/Constants.java'
exclude '**/proto'
}


Expand Down
15 changes: 7 additions & 8 deletions config/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,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 @@ -55,7 +55,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 @@ -70,9 +69,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
1 change: 0 additions & 1 deletion data/adapter/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ dependencies {

implementation 'org.apache.tuweni:tuweni-crypto'
implementation 'org.apache.tuweni:tuweni-units'
implementation 'org.apache.tuweni:tuweni-ssz'
implementation 'com.google.guava:guava'
implementation 'com.google.code.gson:gson'
implementation 'org.apache.logging.log4j:log4j-api'
Expand Down
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 @@ -24,7 +25,6 @@
import tech.pegasys.artemis.datastructures.state.BeaconState;
import tech.pegasys.artemis.datastructures.util.BeaconStateUtil;
import tech.pegasys.artemis.util.alogger.ALogger;
import tech.pegasys.artemis.util.hashtree.HashTreeUtil;

/** Transforms a data record into a time series record */
public class TimeSeriesAdapter implements DataAdapter<TimeSeriesRecord> {
Expand All @@ -38,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 @@ -48,10 +48,11 @@ public TimeSeriesRecord transform() {
BeaconState finalizedState = this.input.getFinalizedState();
int numValidators = headState.getValidator_registry().size();

Bytes32 lastJustifiedBlockRoot = HashTreeUtil.hash_tree_root(justifiedBlock.toBytes());
Bytes32 lastJustifiedStateRoot = HashTreeUtil.hash_tree_root(justifiedState.toBytes());
Bytes32 lastFinalizedBlockRoot = HashTreeUtil.hash_tree_root(finalizedBlock.toBytes());
Bytes32 lastFinalizedStateRoot = HashTreeUtil.hash_tree_root(finalizedState.toBytes());
Bytes32 headBlockRoot = headBlock.signed_root("signature");
Bytes32 lastJustifiedBlockRoot = justifiedBlock.signed_root("signature");
Bytes32 lastJustifiedStateRoot = justifiedState.hash_tree_root();
Bytes32 lastFinalizedBlockRoot = finalizedBlock.signed_root("signature");
Bytes32 lastFinalizedStateRoot = finalizedState.hash_tree_root();

List<ValidatorJoin> validators = new ArrayList<>();

Expand All @@ -62,17 +63,17 @@ 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().getParent_root().toHexString(),
HashTreeUtil.hash_tree_root(this.input.getHeadBlock().toBytes()).toHexString(),
this.input.getHeadBlock().getPrevious_block_root().toHexString(),
this.input.getHeadBlock().signed_root("signature").toHexString(),
lastJustifiedBlockRoot.toHexString(),
lastJustifiedStateRoot.toHexString(),
lastFinalizedBlockRoot.toHexString(),
Expand Down
4 changes: 2 additions & 2 deletions data/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ dependencies {

implementation 'org.apache.tuweni:tuweni-crypto'
implementation 'org.apache.tuweni:tuweni-units'
implementation 'org.apache.tuweni:tuweni-ssz'
implementation 'com.fasterxml.jackson.core:jackson-databind'
implementation files("../lib/tuweni-ssz-0.8.1-SNAPSHOT.jar")
implementation 'com.fasterxml.jackson.core:jackson-databind'
implementation 'com.google.guava:guava'
implementation 'org.apache.logging.log4j:log4j-api'
runtime 'org.apache.logging.log4j:log4j-core'
Expand Down
1 change: 0 additions & 1 deletion data/metrics/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ dependencies {
implementation 'io.vertx:vertx-web'
implementation 'org.apache.tuweni:tuweni-crypto'
implementation 'org.apache.tuweni:tuweni-units'
implementation 'org.apache.tuweni:tuweni-ssz'
implementation 'com.fasterxml.jackson.core:jackson-databind'
implementation 'com.google.guava:guava'
implementation 'io.prometheus:simpleclient'
Expand Down
2 changes: 1 addition & 1 deletion data/provider/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ dependencies {

implementation 'org.apache.tuweni:tuweni-crypto'
implementation 'org.apache.tuweni:tuweni-units'
implementation 'org.apache.tuweni:tuweni-ssz'
implementation files("../../lib/tuweni-ssz-0.8.1-SNAPSHOT.jar")
implementation 'com.fasterxml.jackson.core:jackson-databind'
implementation 'com.google.guava:guava'
implementation 'org.apache.logging.log4j:log4j-api'
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
2 changes: 1 addition & 1 deletion ethereum/datastructures/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ dependencies {

implementation 'org.apache.tuweni:tuweni-crypto'
implementation 'org.apache.tuweni:tuweni-units'
implementation 'org.apache.tuweni:tuweni-ssz'
implementation files("../../lib/tuweni-ssz-0.8.1-SNAPSHOT.jar")
implementation 'com.google.guava:guava'
implementation 'com.google.code.gson:gson'
implementation 'org.apache.logging.log4j:log4j-api'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,21 @@

package tech.pegasys.artemis.datastructures;

import com.google.common.primitives.UnsignedLong;
import org.apache.tuweni.bytes.Bytes;
import org.apache.tuweni.bytes.Bytes32;
import tech.pegasys.artemis.util.bls.BLSSignature;
import tech.pegasys.artemis.util.config.ArtemisConfiguration;

public class Constants {
// The constants below are correct as of spec v0.4
// TODO: Update config.toml setting of constants for 0.5, non-existing
// getter functions are purposefully being used here, so that we would
// need to create their actual getters before being able to run succesfully.

// Misc
public static int SHARD_COUNT = 1024; // 2^10 shards
public static int TARGET_COMMITTEE_SIZE = 128; // 2^7 validators
public static int MAX_BALANCE_CHURN_QUOTIENT = 32; // 2^5
public static long BEACON_CHAIN_SHARD_NUMBER = -1L; // 2^64 - 1
public static int MAX_INDICES_PER_SLASHABLE_VOTE = 4096; // 2^12 votes
public static int MAX_EXIT_DEQUEUES_PER_EPOCH = 4; // 2^2 withdrawals
public static int SHUFFLE_ROUND_COUNT = 90;
Expand All @@ -47,20 +49,21 @@ public class Constants {
public static int MIN_SEED_LOOKAHEAD = 1; // 2^0 epochs (6.4 minutes)
public static int ACTIVATION_EXIT_DELAY = 4; // 2^2 epochs (25.6 minutes)
public static int EPOCHS_PER_ETH1_VOTING_PERIOD = 16; // 2^4 epochs (~1.7 hours)
public static int SLOTS_PER_HISTORICAL_ROOT = 8192; // 2^13 slots (~13 hours)
public static int MIN_VALIDATOR_WITHDRAWABILITY_DELAY = 256; // 2^8 epochs (~27 hours)
public static int PERSISTENT_COMMITTEE_PERIOD = 2048; // 2^11 epochs (~9 days)

// Initial values
public static int GENESIS_FORK_VERSION = 0;
public static long GENESIS_SLOT = 0; // 2^32
public static long GENESIS_SLOT = 4294967296L; // 2^32
public static long GENESIS_EPOCH = slot_to_epoch(GENESIS_SLOT);
public static long GENESIS_START_SHARD = 0;
public static long FAR_FUTURE_EPOCH = -1L;
public static UnsignedLong FAR_FUTURE_EPOCH = UnsignedLong.MAX_VALUE;
public static Bytes32 ZERO_HASH = Bytes32.ZERO;
public static BLSSignature EMPTY_SIGNATURE = BLSSignature.empty();
public static Bytes BLS_WITHDRAWAL_PREFIX_BYTE = Bytes.EMPTY;

// State list lengths
public static int LATEST_BLOCK_ROOTS_LENGTH = 8192; // 2^13 slots (~13 hours)
public static int LATEST_RANDAO_MIXES_LENGTH = 8192; // 2^13 epochs (~36 days)
public static int LATEST_ACTIVE_INDEX_ROOTS_LENGTH = 8192; // 2^13 epochs (~36 days)
public static int LATEST_SLASHED_EXIT_LENGTH = 8192; // 2^13 epochs (~36 days)
Expand All @@ -81,11 +84,11 @@ public class Constants {
public static int MAX_TRANSFERS = 16; // 2^4

// Signature domains
public static int DOMAIN_DEPOSIT = 0;
public static int DOMAIN_ATTESTATION = 1;
public static int DOMAIN_PROPOSAL = 2;
public static int DOMAIN_EXIT = 3;
public static int DOMAIN_RANDAO = 4;
public static int DOMAIN_BEACON_BLOCK = 0;
public static int DOMAIN_RANDAO = 1;
public static int DOMAIN_ATTESTATION = 2;
public static int DOMAIN_DEPOSIT = 3;
public static int DOMAIN_VOLUNTARY_EXIT = 4;
public static int DOMAIN_TRANSFER = 5;

// Artemis specific
Expand All @@ -106,10 +109,6 @@ public static void init(ArtemisConfiguration config) {
config.getMaxBalanceChurnQuotient() != Integer.MIN_VALUE
? config.getMaxBalanceChurnQuotient()
: MAX_BALANCE_CHURN_QUOTIENT; // 2^5
BEACON_CHAIN_SHARD_NUMBER =
config.getBeaconChainShardNumber() != -1L
? config.getBeaconChainShardNumber()
: BEACON_CHAIN_SHARD_NUMBER; // 2^64 - 1
MAX_INDICES_PER_SLASHABLE_VOTE =
config.getMaxIndicesPerSlashableVote() != Integer.MIN_VALUE
? config.getMaxIndicesPerSlashableVote()
Expand Down Expand Up @@ -176,6 +175,10 @@ public static void init(ArtemisConfiguration config) {
config.getEpochsPerEth1VotingPeriod() != Integer.MIN_VALUE
? config.getEpochsPerEth1VotingPeriod()
: EPOCHS_PER_ETH1_VOTING_PERIOD; // 2^4 epochs (~1.7 hours)
SLOTS_PER_HISTORICAL_ROOT =
config.getSlotsPerHistoricalRoot() != Integer.MIN_VALUE
? config.getSlotsPerHistoricalRoot()
: SLOTS_PER_HISTORICAL_ROOT;
MIN_VALIDATOR_WITHDRAWABILITY_DELAY =
config.getMinValidatorWithdrawabilityDelay() != Integer.MIN_VALUE
? config.getMinValidatorWithdrawabilityDelay()
Expand All @@ -195,7 +198,9 @@ public static void init(ArtemisConfiguration config) {
? config.getGenesisStartShard()
: GENESIS_START_SHARD;
FAR_FUTURE_EPOCH =
config.getFarFutureEpoch() != -1L ? config.getFarFutureEpoch() : FAR_FUTURE_EPOCH;
config.getFarFutureEpoch() != Long.MAX_VALUE
? UnsignedLong.valueOf(config.getFarFutureEpoch())
: FAR_FUTURE_EPOCH;
ZERO_HASH =
!config.getZeroHash().equals(Bytes32.ZERO)
? (Bytes32) config.getZeroHash()
Expand All @@ -210,10 +215,6 @@ public static void init(ArtemisConfiguration config) {
: BLS_WITHDRAWAL_PREFIX_BYTE; // TODO Verify

// State list lengths
LATEST_BLOCK_ROOTS_LENGTH =
config.getLatestBlockRootsLength() != Integer.MIN_VALUE
? config.getLatestBlockRootsLength()
: LATEST_BLOCK_ROOTS_LENGTH; // 2^13 slots (~13 hours)
LATEST_RANDAO_MIXES_LENGTH =
config.getLatestRandaoMixesLength() != Integer.MIN_VALUE
? config.getLatestRandaoMixesLength()
Expand Down Expand Up @@ -276,20 +277,22 @@ public static void init(ArtemisConfiguration config) {
: MAX_TRANSFERS; // 2^4

// Signature domains
DOMAIN_DEPOSIT =
config.getDomainDeposit() != Integer.MIN_VALUE ? config.getDomainDeposit() : DOMAIN_DEPOSIT;
DOMAIN_BEACON_BLOCK =
config.getDomainBeaconBlock() != Integer.MIN_VALUE
? config.getDomainBeaconBlock()
: DOMAIN_BEACON_BLOCK;
DOMAIN_RANDAO =
config.getDomainRandao() != Integer.MIN_VALUE ? config.getDomainRandao() : DOMAIN_RANDAO;
DOMAIN_ATTESTATION =
config.getDomainAttestation() != Integer.MIN_VALUE
? config.getDomainAttestation()
: DOMAIN_ATTESTATION;
DOMAIN_PROPOSAL =
config.getDomainProposal() != Integer.MIN_VALUE
? config.getDomainProposal()
: DOMAIN_PROPOSAL;
DOMAIN_EXIT =
config.getDomainExit() != Integer.MIN_VALUE ? config.getDomainExit() : DOMAIN_EXIT;
DOMAIN_RANDAO =
config.getDomainRandao() != Integer.MIN_VALUE ? config.getDomainRandao() : DOMAIN_RANDAO;
DOMAIN_DEPOSIT =
config.getDomainDeposit() != Integer.MIN_VALUE ? config.getDomainDeposit() : DOMAIN_DEPOSIT;
DOMAIN_VOLUNTARY_EXIT =
config.getDomainVoluntaryExit() != Integer.MIN_VALUE
? config.getDomainVoluntaryExit()
: DOMAIN_VOLUNTARY_EXIT;
DOMAIN_TRANSFER =
config.getDomainTransfer() != Integer.MIN_VALUE
? config.getDomainTransfer()
Expand All @@ -304,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
Loading