|
| 1 | +/* |
| 2 | + * Copyright 2018 ConsenSys AG. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with |
| 5 | + * the License. You may obtain a copy of the License at |
| 6 | + * |
| 7 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | + * |
| 9 | + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on |
| 10 | + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the |
| 11 | + * specific language governing permissions and limitations under the License. |
| 12 | + */ |
| 13 | + |
| 14 | +package net.consensys.artemis; |
| 15 | + |
| 16 | +import net.consensys.artemis.util.bytes.Bytes32; |
| 17 | + |
| 18 | +public final class Constants { |
| 19 | + |
| 20 | + // The constants below are correct as of spec dated 2018/12/5 |
| 21 | + |
| 22 | + // Misc |
| 23 | + public static final int SHARD_COUNT = (int) Math.pow(2, 10); // 1,024 Shards |
| 24 | + public static final int TARGET_COMMITTEE_SIZE = (int) Math.pow(2, 8); // 256 validators |
| 25 | + public static final int EJECTION_BALANCE = (int) Math.pow(2, 4); // 16 Eth |
| 26 | + public static final int MAX_BALANCE_CHURN_QUOTIENT = (int) Math.pow(2, 5); // 32 |
| 27 | + public static final int GWEI_PER_ETH = (int) Math.pow(10, 9); // 1,000,000,000 Wei |
| 28 | + public static final int BEACON_CHAIN_SHARD_NUMBER = (int) Math.pow(2, 64) - 1; |
| 29 | + public static final String BLS_WITHDRAWAL_PREFIX_BYTE = "0x00"; |
| 30 | + public static final int MAX_CASPER_VOTES = (int) Math.pow(2, 10); // 1,024 votes |
| 31 | + |
| 32 | + // Deposit contract |
| 33 | + // static final Address DEPOSIT_CONTRACT_ADDRESS = Value is still TBD |
| 34 | + public static final int DEPOSIT_CONTRACT_TREE_DEPTH = (int) Math.pow(2, 5); // 32 |
| 35 | + public static final int MIN_DEPOSIT = (int) Math.pow(2, 0); // 1 Eth |
| 36 | + public static final int MAX_DEPOSIT = (int) Math.pow(2, 5); // 32 Eth |
| 37 | + |
| 38 | + // Initial values |
| 39 | + public static final int INITIAL_FORK_VERSION = 0; |
| 40 | + public static final int INITIAL_SLOT_NUMBER = 0; |
| 41 | + public static final Bytes32 ZERO_HASH = Bytes32.ZERO; |
| 42 | + |
| 43 | + // Time parameters |
| 44 | + public static final int SLOT_DURATION = 6; // 6 seconds |
| 45 | + public static final int MIN_ATTESTATION_INCLUSION_DELAY = (int) Math.pow(2, 2); // 4 slots |
| 46 | + public static final int EPOCH_LENGTH = (int) Math.pow(2, 6); // 64 slots |
| 47 | + public static final int MIN_VALIDATOR_REGISTRY_CHANGE_INTERVAL = (int) Math.pow(2, 8); // 256 slots |
| 48 | + public static final int POW_RECEIPT_ROOT_VOTING_PERIOD = (int) Math.pow(2, 10); // 1,024 slots |
| 49 | + public static final int SHARD_PERSISTENT_COMMITTEE_CHANGE_PERIOD = (int) Math.pow(2, 17); // 131,072 slots |
| 50 | + public static final int COLLECTIVE_PENALTY_CALCULATION_PERIOD = (int) Math.pow(2, 20); // 1,048,576 slots |
| 51 | + public static final int ZERO_BALANCE_VALIDATOR_TTL = (int) Math.pow(2, 22); // 4,194,304 slots |
| 52 | + |
| 53 | + // Reward and penalty quotients |
| 54 | + public static final int BASE_REWARD_QUOTIENT = (int) Math.pow(2, 11); // 2,048 |
| 55 | + public static final int WHISTLEBLOWER_REWARD_QUOTIENT = (int) Math.pow(2, 9); // 512 |
| 56 | + public static final int INCLUDER_REWARD_QUOTIENT = (int) Math.pow(2, 3); // 8 |
| 57 | + public static final int INACTIVITY_PENALTY_QUOTIENT = (int) Math.pow(2, 34); // 131,072 |
| 58 | + |
| 59 | + // Status codes |
| 60 | + public static final int PENDING_ACTIVATION = 0; |
| 61 | + public static final int ACTIVE = 1; |
| 62 | + public static final int ACTIVE_PENDING_EXIT = 2; |
| 63 | + public static final int EXITED_WITHOUT_PENALTY = 3; |
| 64 | + public static final int EXITED_WITH_PENALTY = 4; |
| 65 | + |
| 66 | + // Max operations per block |
| 67 | + public static final int MAX_PROPOSER_SLASHINGS = (int) Math.pow(2, 4); // 16 |
| 68 | + public static final int MAX_CASPER_SLASHINGS = (int) Math.pow(2, 4); // 16 |
| 69 | + public static final int MAX_ATTESTATIONS = (int) Math.pow(2, 7); // 128 |
| 70 | + public static final int MAX_DEPOSITS = (int) Math.pow(2, 4); // 16 |
| 71 | + public static final int MAX_EXITS = (int) Math.pow(2, 4); // 16 |
| 72 | + |
| 73 | + |
| 74 | + // Validator registry delta flags |
| 75 | + public static final int ACTIVATION = 0; |
| 76 | + public static final int EXIT = 1; |
| 77 | + |
| 78 | + // Signature domains |
| 79 | + public static final int DOMAIN_DEPOSIT = 0; |
| 80 | + public static final int DOMAIN_ATTESTATION = 1; |
| 81 | + public static final int DOMAIN_PROPOSAL = 2; |
| 82 | + public static final int DOMAIN_EXIT = 3; |
| 83 | + |
| 84 | + public static String getConstantsAsString() { |
| 85 | + return "--Misc--" |
| 86 | + + "\nSHARD_COUNT: " + SHARD_COUNT |
| 87 | + + "\nTARGET_COMMITTEE_SIZE: " + TARGET_COMMITTEE_SIZE |
| 88 | + + "\nMIN_BALANCE: " + EJECTION_BALANCE |
| 89 | + + "\nMAX_BALANCE_CHURN_QUOTIENT: " + MAX_BALANCE_CHURN_QUOTIENT |
| 90 | + + "\nGWEI_PER_ETH: " + GWEI_PER_ETH |
| 91 | + + "\nBEACON_CHAIN_SHARD_NUMBER: " + BEACON_CHAIN_SHARD_NUMBER |
| 92 | + + "\nBLS_WITHDRAWAL_CREDENTIALS: " + BLS_WITHDRAWAL_PREFIX_BYTE |
| 93 | + + "\nMAX_CASPER_VOTES: " + MAX_CASPER_VOTES |
| 94 | + |
| 95 | + + "\n\n--Deposit contract--" |
| 96 | +// + "\nDEPOSIT_CONTRACT_ADDRESS: " + DEPOSIT_CONTRACT_ADDRESS |
| 97 | + + "\nDEPOSIT_CONTRACT_TREE_DEPTH: " + DEPOSIT_CONTRACT_TREE_DEPTH |
| 98 | + + "\nMIN_DEPOSIT: " + MIN_DEPOSIT |
| 99 | + + "\nMAX_DEPOSIT: " + MAX_DEPOSIT |
| 100 | + |
| 101 | + + "\n\n--Initial values--" |
| 102 | + + "\nINITIAL_FORK_VERSION: " + INITIAL_FORK_VERSION |
| 103 | + + "\nINITIAL_SLOT_NUMBER: " + INITIAL_SLOT_NUMBER |
| 104 | + + "\nZERO_HASH: " + ZERO_HASH |
| 105 | + |
| 106 | + + "\n\n--Time parameters--" |
| 107 | + + "\nSLOT_DURATION: " + SLOT_DURATION |
| 108 | + + "\nMIN_ATTESTATION_INCLUSION_DELAY: " + MIN_ATTESTATION_INCLUSION_DELAY |
| 109 | + + "\nEPOCH_LENGTH: " + EPOCH_LENGTH |
| 110 | + + "\nMIN_VALIDATOR_REGISTRY_CHANGE_INTERVAL: " + MIN_VALIDATOR_REGISTRY_CHANGE_INTERVAL |
| 111 | + + "\nPOW_RECEIPT_ROOT_VOTING_PERIOD: " + POW_RECEIPT_ROOT_VOTING_PERIOD |
| 112 | + + "\nSHARD_PERSISTENT_COMMITTEE_CHANGE_PERIOD: " + SHARD_PERSISTENT_COMMITTEE_CHANGE_PERIOD |
| 113 | + + "\nCOLLECTIVE_PENALTY_CALCULATION_PERIOD: " + COLLECTIVE_PENALTY_CALCULATION_PERIOD |
| 114 | + + "\nZERO_BALANCE_VALIDATOR_TTL: " + ZERO_BALANCE_VALIDATOR_TTL |
| 115 | + |
| 116 | + + "\n\n--Reward and penalty quotients--" |
| 117 | + + "\nBASE_REWARD_QUOTIENT: " + BASE_REWARD_QUOTIENT |
| 118 | + + "\nWHISTLEBLOWER_REWARD_QUOTIENT: " + WHISTLEBLOWER_REWARD_QUOTIENT |
| 119 | + + "\nINCLUDER_REWARD_QUOTIENT: " + INCLUDER_REWARD_QUOTIENT |
| 120 | + + "\nINACTIVITY_PENALTY_QUOTIENT: " + INACTIVITY_PENALTY_QUOTIENT |
| 121 | + |
| 122 | + + "\n\n--Status codes--" |
| 123 | + + "\nPENDING_ACTIVATION: " + PENDING_ACTIVATION |
| 124 | + + "\nACTIVE: " + ACTIVE |
| 125 | + + "\nACTIVE_PENDING_EXIT: " + ACTIVE_PENDING_EXIT |
| 126 | + + "\nEXITED_WITHOUT_PENALTY: " + EXITED_WITHOUT_PENALTY |
| 127 | + + "\nEXITED_WITH_PENALTY: " + EXITED_WITH_PENALTY |
| 128 | + |
| 129 | + |
| 130 | + + "\n\n--Max operations per block--" |
| 131 | + + "\nMAX_PROPOSER_SLASHINGS: " + MAX_PROPOSER_SLASHINGS |
| 132 | + + "\nMAX_CASPER_SLASHINGS: " + MAX_CASPER_SLASHINGS |
| 133 | + + "\nMAX_ATTESTATIONS: " + MAX_ATTESTATIONS |
| 134 | + + "\nMAX_DEPOSITS: " + MAX_DEPOSITS |
| 135 | + + "\nMAX_EXITS: " + MAX_EXITS |
| 136 | + |
| 137 | + |
| 138 | + + "\n\n--Validator registry delta flags--" |
| 139 | + + "\nACTIVATION: " + ACTIVATION |
| 140 | + + "\nEXIT: " + EXIT |
| 141 | + |
| 142 | + + "\n\n--Signature domains--" |
| 143 | + + "\nDOMAIN_DEPOSIT: " + DOMAIN_DEPOSIT |
| 144 | + + "\nDOMAIN_ATTESTATION: " + DOMAIN_ATTESTATION |
| 145 | + + "\nDOMAIN_PROPOSAL: " + DOMAIN_PROPOSAL |
| 146 | + + "\nDOMAIN_EXIT: " + DOMAIN_EXIT |
| 147 | + + "\n"; |
| 148 | + } |
| 149 | + |
| 150 | +} |
0 commit comments