github.com/DxChainNetwork/dxc@v0.8.1-0.20220824085222-1162e304b6e7/consensus/dpos/systemcontract/contracts/Base.sol (about) 1 // SPDX-License-Identifier: MIT 2 pragma solidity ^0.8.0; 3 4 contract Base { 5 uint256 public constant BLOCK_SECONDS = 6; 6 /// @notice min rate. base on 100 7 uint8 public constant MIN_RATE = 70; 8 /// @notice max rate. base on 100 9 uint8 public constant MAX_RATE = 100; 10 11 /// @notice 10 * 60 / BLOCK_SECONDS 12 uint256 public constant EPOCH_BLOCKS = 14400; 13 /// @notice min deposit for validator 14 uint256 public constant MIN_DEPOSIT = 4e7 ether; 15 uint256 public constant MAX_PUNISH_COUNT = 139; 16 17 /// @notice use blocks as units in code: RATE_SET_LOCK_EPOCHS * EPOCH_BLOCKS 18 uint256 public constant RATE_SET_LOCK_EPOCHS = 1; 19 /// @notice use blocks as units in code: VALIDATOR_UNSTAKE_LOCK_EPOCHS * EPOCH_BLOCKS 20 uint256 public constant VALIDATOR_UNSTAKE_LOCK_EPOCHS = 1; 21 /// @notice use blocks as units in code: PROPOSAL_DURATION_EPOCHS * EPOCH_BLOCKS 22 uint256 public constant PROPOSAL_DURATION_EPOCHS = 7; 23 /// @notice use epoch as units in code: VALIDATOR_REWARD_LOCK_EPOCHS 24 uint256 public constant VALIDATOR_REWARD_LOCK_EPOCHS = 7; 25 /// @notice use epoch as units in code: VOTE_CANCEL_EPOCHS 26 uint256 public constant VOTE_CANCEL_EPOCHS = 1; 27 28 uint256 public constant MAX_VALIDATORS_COUNT = 210; 29 uint256 public constant MAX_VALIDATOR_DETAIL_LENGTH = 1000; 30 uint256 public constant MAX_VALIDATOR_NAME_LENGTH = 100; 31 32 // total deposit 33 uint256 public constant TOTAL_DEPOSIT_LV1 = 1e18 * 1e8 * 150; 34 uint256 public constant TOTAL_DEPOSIT_LV2 = 1e18 * 1e8 * 200; 35 uint256 public constant TOTAL_DEPOSIT_LV3 = 1e18 * 1e8 * 250; 36 uint256 public constant TOTAL_DEPOSIT_LV4 = 1e18 * 1e8 * 300; 37 uint256 public constant TOTAL_DEPOSIT_LV5 = 1e18 * 1e8 * 350; 38 39 // block reward 40 uint256 public constant REWARD_DEPOSIT_UNDER_LV1 = 1e15 * 95250; 41 uint256 public constant REWARD_DEPOSIT_FROM_LV1_TO_LV2 = 1e15 * 128250; 42 uint256 public constant REWARD_DEPOSIT_FROM_LV2_TO_LV3 = 1e15 * 157125; 43 uint256 public constant REWARD_DEPOSIT_FROM_LV3_TO_LV4 = 1e15 * 180750; 44 uint256 public constant REWARD_DEPOSIT_FROM_LV4_TO_LV5 = 1e15 * 199875; 45 uint256 public constant REWARD_DEPOSIT_OVER_LV5 = 1e15 * 214125; 46 47 // validator count 48 uint256 public constant MAX_VALIDATOR_COUNT_LV1 = 21; 49 uint256 public constant MAX_VALIDATOR_COUNT_LV2 = 33; 50 uint256 public constant MAX_VALIDATOR_COUNT_LV3 = 66; 51 uint256 public constant MAX_VALIDATOR_COUNT_LV4 = 99; 52 uint256 public constant MIN_LEVEL_VALIDATOR_COUNT = 60; 53 uint256 public constant MEDIUM_LEVEL_VALIDATOR_COUNT = 90; 54 uint256 public constant MAX_LEVEL_VALIDATOR_COUNT = 120; 55 56 // dead address 57 address public constant BLACK_HOLE_ADDRESS = 0x0000000000000000000000000000000000000000; 58 59 uint256 public constant SAFE_MULTIPLIER = 1e18; 60 61 modifier onlySystem() { 62 require(tx.gasprice == 0, "Prohibit external calls"); 63 _; 64 } 65 66 modifier onlyMiner() { 67 require(msg.sender == block.coinbase, "msg.sender error"); 68 _; 69 } 70 71 /** 72 * @dev return current epoch 73 */ 74 function currentEpoch() public view returns (uint256) { 75 return block.number / EPOCH_BLOCKS; 76 } 77 }