From 9434708a9aa9134468ef5a9f01ac6b769ce561ee Mon Sep 17 00:00:00 2001 From: ninjaahhh <38544039+ninjaahhh@users.noreply.github.com> Date: Tue, 21 Apr 2020 11:47:38 -0700 Subject: [PATCH] Add PoSW stake decay enable timestamp (#885) --- .../singularity/cluster_config_bootnodes.json | 1 + .../cluster_config_p2p_crawling.json | 504 ------------------ .../singularity/cluster_config_template.json | 1 + .../cluster_config_template_8nodes.json | 1 + quarkchain/cluster/shard_state.py | 9 +- quarkchain/cluster/tests/test_shard_state.py | 43 +- quarkchain/config.py | 1 + quarkchain/tests/test_config.py | 1 + 8 files changed, 34 insertions(+), 527 deletions(-) delete mode 100644 mainnet/singularity/cluster_config_p2p_crawling.json diff --git a/mainnet/singularity/cluster_config_bootnodes.json b/mainnet/singularity/cluster_config_bootnodes.json index 54f7c2668..9e7e1c7f9 100644 --- a/mainnet/singularity/cluster_config_bootnodes.json +++ b/mainnet/singularity/cluster_config_bootnodes.json @@ -30,6 +30,7 @@ "ENABLE_QKCHASHX_HEIGHT": 1480000, "ENABLE_NON_RESERVED_NATIVE_TOKEN_TIMESTAMP": 1588291200, "ENABLE_GENERAL_NATIVE_TOKEN_TIMESTAMP": 1588291200, + "ENABLE_POSW_STAKING_DECAY_TIMESTAMP": 1588291200, "TX_WHITELIST_SENDERS": [ "b8C082828F51343299c9A4deEb2503AaC3bA074f", "3391A1796cB98D79A2Fde326F375DF900C959Ed0", diff --git a/mainnet/singularity/cluster_config_p2p_crawling.json b/mainnet/singularity/cluster_config_p2p_crawling.json deleted file mode 100644 index ead6d4e5c..000000000 --- a/mainnet/singularity/cluster_config_p2p_crawling.json +++ /dev/null @@ -1,504 +0,0 @@ -{ - "P2P_PORT": 38291, - "JSON_RPC_PORT": 38391, - "JSON_RPC_HOST": "127.0.0.1", - "PRIVATE_JSON_RPC_PORT": 38491, - "PRIVATE_JSON_RPC_HOST": "127.0.0.1", - "ENABLE_PRIVATE_JSON_RPC": true, - "ENABLE_PUBLIC_JSON_RPC": false, - "ENABLE_TRANSACTION_HISTORY": false, - "DB_PATH_ROOT": "./qkc-data/mainnet", - "LOG_LEVEL": "info", - "START_SIMULATED_MINING": false, - "CLEAN": false, - "GENESIS_DIR": null, - "QUARKCHAIN": { - "CHAIN_SIZE": 8, - "MAX_NEIGHBORS": 32, - "NETWORK_ID": 1, - "TRANSACTION_QUEUE_SIZE_LIMIT_PER_SHARD": 10000, - "BLOCK_EXTRA_DATA_SIZE_LIMIT": 1024, - "GUARDIAN_PUBLIC_KEY": "6f9ed23452ffb7902345ca8dc53292480274a22cc4625f783e84dd3a6e7082d3e17901c7dc1ba3286fbd1fbd295c17c0722c89e7693220e00587b0d96dd64647", - "ROOT_SIGNER_PRIVATE_KEY": null, - "P2P_PROTOCOL_VERSION": 0, - "P2P_COMMAND_SIZE_LIMIT": 134217728, - "SKIP_ROOT_DIFFICULTY_CHECK": false, - "SKIP_MINOR_DIFFICULTY_CHECK": false, - "GENESIS_TOKEN": "QKC", - "ENABLE_TX_TIMESTAMP": 1561791600, - "ENABLE_EVM_TIMESTAMP": 1569567600, - "ENABLE_QKCHASHX_HEIGHT": 1480000, - "TX_WHITELIST_SENDERS": [ - "b8C082828F51343299c9A4deEb2503AaC3bA074f", - "3391A1796cB98D79A2Fde326F375DF900C959Ed0", - "f9c9B4991A885cB7889074FA91E04AFe7d36b856", - "cd91b2C43D5943ad83e682eF723001F6B9Ec35F2", - "3A324dc1fb617eeA9b1EBc41408d87Fc44FbDd4a", - "bde653eFF19dE913AF8eA6AC4287a8Ec2c1f1e24", - "b505DBb1153449df0863cf72ace1a2a1898B7Bba", - "70FC830E4bCC9a4Dd15dE3faE7a8DF0a29b43321", - "13A83b461d7c612f5C120979cEf16335806d6EAc", - "62d4971dB0133dAC13dF915Be1D11FB9d0909a8B", - "7963EAcDC3FdD481db6018673A41a633636a3b69", - "Bb9bd7d3937712405cf74d044EcD1733eb8763d3", - "db7FD07891697f74A7E5102Cc2cC522c25dc06e9", - "248Dc97675f46Cb2AeCa53006F647ED94eF5B502", - "A3eBA5dBeC29f813171A1C4861B98DaBB12641C1", - "Ccf9296ed0e118BF3815f4aC27a0544ECE7E731F", - "Be4B98ABE5982AC6E453307c81CB47A316b78d89", - "9Cb0b9B9e707054C862272FC5f61B3F2E8d88BE9", - "26E2Fa524B85072eD7fb5D5d9237804dc6c0A140", - "75980402beDF9dca4d745fd8F2B06aeAAE97A8CB", - "bE9473d4Fd4FeD5F20DF43328da93d6dF4104E09", - "60aE18CedCdDd524Fc3448b5AA76634189625699", - "32c53C6c2B57B2026a51C87aDD0695F5AeEd3f2e", - "7DeB90eF2097D8A9e423516e199b9D95EB2b4D97", - "2b7aCC42b0dc2a1562601e2ed9957eAdff7A1347", - "F923ac88fc61837662BACe7E94720C7a071997E6", - "c4fbA3740f95d25B2196C9437fDb005359296D36", - "1f231b489a2d5A1Eb374D363D3Ac851c25Db8626", - "eeb4bBff983536039eda281A0ACCFAe360AeF1fA", - "b9385cA98F102Bd6B180cB76AA0ca8c1615053e7" - ], - "ROOT": { - "MAX_STALE_ROOT_BLOCK_HEIGHT_DIFF": 22500, - "CONSENSUS_TYPE": "POW_ETHASH", - "CONSENSUS_CONFIG": { - "TARGET_BLOCK_TIME": 60, - "REMOTE_MINE": true - }, - "GENESIS": { - "VERSION": 0, - "HEIGHT": 0, - "HASH_PREV_BLOCK": "0000000000000000000000000000000000000000000000000000000000000000", - "HASH_MERKLE_ROOT": "0000000000000000000000000000000000000000000000000000000000000000", - "TIMESTAMP": 1556639999, - "DIFFICULTY": 10000000000000, - "NONCE": 0 - }, - "COINBASE_ADDRESS": "000000000000000000000000000000000000000000000000", - "COINBASE_AMOUNT": 156000000000000000000, - "DIFFICULTY_ADJUSTMENT_CUTOFF_TIME": 40, - "DIFFICULTY_ADJUSTMENT_FACTOR": 1024, - "EPOCH_INTERVAL": 525600 - }, - "CHAINS": [ - { - "CHAIN_ID": 0, - "SHARD_SIZE": 1, - "DEFAULT_CHAIN_TOKEN": "QKC", - "CONSENSUS_TYPE": "POW_ETHASH", - "CONSENSUS_CONFIG": { - "TARGET_BLOCK_TIME": 10, - "REMOTE_MINE": true - }, - "GENESIS": { - "ROOT_HEIGHT": 0, - "VERSION": 0, - "HEIGHT": 0, - "HASH_PREV_MINOR_BLOCK": "0000000000000000000000000000000000000000000000000000000000000000", - "HASH_MERKLE_ROOT": "0000000000000000000000000000000000000000000000000000000000000000", - "EXTRA_DATA": "497420776173207468652062657374206f662074696d65732c206974207761732074686520776f727374206f662074696d65732c202e2e2e202d20436861726c6573204469636b656e73", - "TIMESTAMP": 1556639999, - "DIFFICULTY": 5000000000, - "GAS_LIMIT": 12000000, - "NONCE": 0, - "ALLOC": { - "32c53C6c2B57B2026a51C87aDD0695F5AeEd3f2e000075b2": { - "QKC": 600000000000000000000000000 - }, - "7DeB90eF2097D8A9e423516e199b9D95EB2b4D97000075b2": { - "QKC": 100000000000000000000000000 - }, - "c4fbA3740f95d25B2196C9437fDb005359296D36000075b2": { - "QKC": 50000000000000000000000000 - } - } - }, - "COINBASE_ADDRESS": "000000000000000000000000000000000000000000000000", - "COINBASE_AMOUNT": 6500000000000000000, - "DIFFICULTY_ADJUSTMENT_CUTOFF_TIME": 7, - "DIFFICULTY_ADJUSTMENT_FACTOR": 512, - "EXTRA_SHARD_BLOCKS_IN_ROOT_BLOCK": 12, - "POSW_CONFIG": { - "ENABLED": true, - "ENABLE_TIMESTAMP": 1569567600, - "DIFF_DIVIDER": 10000, - "WINDOW_SIZE": 512, - "TOTAL_STAKE_PER_BLOCK": 1000000000000000000000000 - }, - "EPOCH_INTERVAL": 3153600 - }, - { - "CHAIN_ID": 1, - "SHARD_SIZE": 1, - "DEFAULT_CHAIN_TOKEN": "QKC", - "CONSENSUS_TYPE": "POW_ETHASH", - "CONSENSUS_CONFIG": { - "TARGET_BLOCK_TIME": 10, - "REMOTE_MINE": true - }, - "GENESIS": { - "ROOT_HEIGHT": 0, - "VERSION": 0, - "HEIGHT": 0, - "HASH_PREV_MINOR_BLOCK": "0000000000000000000000000000000000000000000000000000000000000000", - "HASH_MERKLE_ROOT": "0000000000000000000000000000000000000000000000000000000000000000", - "EXTRA_DATA": "497420776173207468652062657374206f662074696d65732c206974207761732074686520776f727374206f662074696d65732c202e2e2e202d20436861726c6573204469636b656e73", - "TIMESTAMP": 1556639999, - "DIFFICULTY": 5000000000, - "GAS_LIMIT": 12000000, - "NONCE": 0, - "ALLOC": { - "32c53C6c2B57B2026a51C87aDD0695F5AeEd3f2e000175b2": { - "QKC": 600000000000000000000000000 - }, - "7DeB90eF2097D8A9e423516e199b9D95EB2b4D97000175b2": { - "QKC": 100000000000000000000000000 - }, - "c4fbA3740f95d25B2196C9437fDb005359296D36000175b2": { - "QKC": 50000000000000000000000000 - } - } - }, - "COINBASE_ADDRESS": "000000000000000000000000000000000000000000000000", - "COINBASE_AMOUNT": 6500000000000000000, - "DIFFICULTY_ADJUSTMENT_CUTOFF_TIME": 7, - "DIFFICULTY_ADJUSTMENT_FACTOR": 512, - "EXTRA_SHARD_BLOCKS_IN_ROOT_BLOCK": 12, - "POSW_CONFIG": { - "ENABLED": true, - "DIFF_DIVIDER": 20, - "WINDOW_SIZE": 256, - "TOTAL_STAKE_PER_BLOCK": 20000000000000000000000 - }, - "EPOCH_INTERVAL": 3153600 - }, - { - "CHAIN_ID": 2, - "SHARD_SIZE": 1, - "DEFAULT_CHAIN_TOKEN": "QKC", - "CONSENSUS_TYPE": "POW_ETHASH", - "CONSENSUS_CONFIG": { - "TARGET_BLOCK_TIME": 10, - "REMOTE_MINE": true - }, - "GENESIS": { - "ROOT_HEIGHT": 0, - "VERSION": 0, - "HEIGHT": 0, - "HASH_PREV_MINOR_BLOCK": "0000000000000000000000000000000000000000000000000000000000000000", - "HASH_MERKLE_ROOT": "0000000000000000000000000000000000000000000000000000000000000000", - "EXTRA_DATA": "497420776173207468652062657374206f662074696d65732c206974207761732074686520776f727374206f662074696d65732c202e2e2e202d20436861726c6573204469636b656e73", - "TIMESTAMP": 1556639999, - "DIFFICULTY": 5000000000, - "GAS_LIMIT": 12000000, - "NONCE": 0, - "ALLOC": { - "32c53C6c2B57B2026a51C87aDD0695F5AeEd3f2e000275b2": { - "QKC": 600000000000000000000000000 - }, - "7DeB90eF2097D8A9e423516e199b9D95EB2b4D97000275b2": { - "QKC": 100000000000000000000000000 - }, - "c4fbA3740f95d25B2196C9437fDb005359296D36000275b2": { - "QKC": 50000000000000000000000000 - } - } - }, - "COINBASE_ADDRESS": "000000000000000000000000000000000000000000000000", - "COINBASE_AMOUNT": 6500000000000000000, - "DIFFICULTY_ADJUSTMENT_CUTOFF_TIME": 7, - "DIFFICULTY_ADJUSTMENT_FACTOR": 512, - "EXTRA_SHARD_BLOCKS_IN_ROOT_BLOCK": 12, - "POSW_CONFIG": { - "ENABLED": true, - "DIFF_DIVIDER": 20, - "WINDOW_SIZE": 256, - "TOTAL_STAKE_PER_BLOCK": 40000000000000000000000 - }, - "EPOCH_INTERVAL": 3153600 - }, - { - "CHAIN_ID": 3, - "SHARD_SIZE": 1, - "DEFAULT_CHAIN_TOKEN": "QKC", - "CONSENSUS_TYPE": "POW_ETHASH", - "CONSENSUS_CONFIG": { - "TARGET_BLOCK_TIME": 10, - "REMOTE_MINE": true - }, - "GENESIS": { - "ROOT_HEIGHT": 0, - "VERSION": 0, - "HEIGHT": 0, - "HASH_PREV_MINOR_BLOCK": "0000000000000000000000000000000000000000000000000000000000000000", - "HASH_MERKLE_ROOT": "0000000000000000000000000000000000000000000000000000000000000000", - "EXTRA_DATA": "497420776173207468652062657374206f662074696d65732c206974207761732074686520776f727374206f662074696d65732c202e2e2e202d20436861726c6573204469636b656e73", - "TIMESTAMP": 1556639999, - "DIFFICULTY": 5000000000, - "GAS_LIMIT": 12000000, - "NONCE": 0, - "ALLOC": { - "32c53C6c2B57B2026a51C87aDD0695F5AeEd3f2e000375b2": { - "QKC": 600000000000000000000000000 - }, - "7DeB90eF2097D8A9e423516e199b9D95EB2b4D97000375b2": { - "QKC": 100000000000000000000000000 - }, - "c4fbA3740f95d25B2196C9437fDb005359296D36000375b2": { - "QKC": 50000000000000000000000000 - } - } - }, - "COINBASE_ADDRESS": "000000000000000000000000000000000000000000000000", - "COINBASE_AMOUNT": 6500000000000000000, - "DIFFICULTY_ADJUSTMENT_CUTOFF_TIME": 7, - "DIFFICULTY_ADJUSTMENT_FACTOR": 512, - "EXTRA_SHARD_BLOCKS_IN_ROOT_BLOCK": 12, - "POSW_CONFIG": { - "ENABLED": true, - "DIFF_DIVIDER": 20, - "WINDOW_SIZE": 256, - "TOTAL_STAKE_PER_BLOCK": 80000000000000000000000 - }, - "EPOCH_INTERVAL": 3153600 - }, - { - "CHAIN_ID": 4, - "SHARD_SIZE": 1, - "DEFAULT_CHAIN_TOKEN": "QKC", - "CONSENSUS_TYPE": "POW_ETHASH", - "CONSENSUS_CONFIG": { - "TARGET_BLOCK_TIME": 10, - "REMOTE_MINE": true - }, - "GENESIS": { - "ROOT_HEIGHT": 0, - "VERSION": 0, - "HEIGHT": 0, - "HASH_PREV_MINOR_BLOCK": "0000000000000000000000000000000000000000000000000000000000000000", - "HASH_MERKLE_ROOT": "0000000000000000000000000000000000000000000000000000000000000000", - "EXTRA_DATA": "497420776173207468652062657374206f662074696d65732c206974207761732074686520776f727374206f662074696d65732c202e2e2e202d20436861726c6573204469636b656e73", - "TIMESTAMP": 1556639999, - "DIFFICULTY": 5000000000, - "GAS_LIMIT": 12000000, - "NONCE": 0, - "ALLOC": { - "32c53C6c2B57B2026a51C87aDD0695F5AeEd3f2e000475b2": { - "QKC": 600000000000000000000000000 - }, - "7DeB90eF2097D8A9e423516e199b9D95EB2b4D97000475b2": { - "QKC": 100000000000000000000000000 - }, - "c4fbA3740f95d25B2196C9437fDb005359296D36000475b2": { - "QKC": 50000000000000000000000000 - } - } - }, - "COINBASE_ADDRESS": "000000000000000000000000000000000000000000000000", - "COINBASE_AMOUNT": 6500000000000000000, - "DIFFICULTY_ADJUSTMENT_CUTOFF_TIME": 7, - "DIFFICULTY_ADJUSTMENT_FACTOR": 512, - "EXTRA_SHARD_BLOCKS_IN_ROOT_BLOCK": 12, - "POSW_CONFIG": { - "ENABLED": true, - "DIFF_DIVIDER": 20, - "WINDOW_SIZE": 256, - "TOTAL_STAKE_PER_BLOCK": 160000000000000000000000 - }, - "EPOCH_INTERVAL": 3153600 - }, - { - "CHAIN_ID": 5, - "SHARD_SIZE": 1, - "DEFAULT_CHAIN_TOKEN": "QKC", - "CONSENSUS_TYPE": "POW_ETHASH", - "CONSENSUS_CONFIG": { - "TARGET_BLOCK_TIME": 10, - "REMOTE_MINE": true - }, - "GENESIS": { - "ROOT_HEIGHT": 0, - "VERSION": 0, - "HEIGHT": 0, - "HASH_PREV_MINOR_BLOCK": "0000000000000000000000000000000000000000000000000000000000000000", - "HASH_MERKLE_ROOT": "0000000000000000000000000000000000000000000000000000000000000000", - "EXTRA_DATA": "497420776173207468652062657374206f662074696d65732c206974207761732074686520776f727374206f662074696d65732c202e2e2e202d20436861726c6573204469636b656e73", - "TIMESTAMP": 1556639999, - "DIFFICULTY": 5000000000, - "GAS_LIMIT": 12000000, - "NONCE": 0, - "ALLOC": { - "32c53C6c2B57B2026a51C87aDD0695F5AeEd3f2e000575b2": { - "QKC": 600000000000000000000000000 - }, - "7DeB90eF2097D8A9e423516e199b9D95EB2b4D97000575b2": { - "QKC": 100000000000000000000000000 - }, - "c4fbA3740f95d25B2196C9437fDb005359296D36000575b2": { - "QKC": 50000000000000000000000000 - } - } - }, - "COINBASE_ADDRESS": "000000000000000000000000000000000000000000000000", - "COINBASE_AMOUNT": 6500000000000000000, - "DIFFICULTY_ADJUSTMENT_CUTOFF_TIME": 7, - "DIFFICULTY_ADJUSTMENT_FACTOR": 512, - "EXTRA_SHARD_BLOCKS_IN_ROOT_BLOCK": 12, - "POSW_CONFIG": { - "ENABLED": true, - "DIFF_DIVIDER": 20, - "WINDOW_SIZE": 256, - "TOTAL_STAKE_PER_BLOCK": 320000000000000000000000 - }, - "EPOCH_INTERVAL": 3153600 - }, - { - "CHAIN_ID": 6, - "SHARD_SIZE": 1, - "DEFAULT_CHAIN_TOKEN": "QKC", - "CONSENSUS_TYPE": "POW_QKCHASH", - "CONSENSUS_CONFIG": { - "TARGET_BLOCK_TIME": 10, - "REMOTE_MINE": true - }, - "GENESIS": { - "ROOT_HEIGHT": 0, - "VERSION": 0, - "HEIGHT": 0, - "HASH_PREV_MINOR_BLOCK": "0000000000000000000000000000000000000000000000000000000000000000", - "HASH_MERKLE_ROOT": "0000000000000000000000000000000000000000000000000000000000000000", - "EXTRA_DATA": "497420776173207468652062657374206f662074696d65732c206974207761732074686520776f727374206f662074696d65732c202e2e2e202d20436861726c6573204469636b656e73", - "TIMESTAMP": 1556639999, - "DIFFICULTY": 120000, - "GAS_LIMIT": 12000000, - "NONCE": 0, - "ALLOC": { - "32c53C6c2B57B2026a51C87aDD0695F5AeEd3f2e000675b2": { - "QKC": 600000000000000000000000000 - }, - "7DeB90eF2097D8A9e423516e199b9D95EB2b4D97000675b2": { - "QKC": 100000000000000000000000000 - }, - "c4fbA3740f95d25B2196C9437fDb005359296D36000675b2": { - "QKC": 50000000000000000000000000 - } - } - }, - "COINBASE_ADDRESS": "000000000000000000000000000000000000000000000000", - "COINBASE_AMOUNT": 6500000000000000000, - "DIFFICULTY_ADJUSTMENT_CUTOFF_TIME": 7, - "DIFFICULTY_ADJUSTMENT_FACTOR": 512, - "EXTRA_SHARD_BLOCKS_IN_ROOT_BLOCK": 12, - "POSW_CONFIG": { - "ENABLED": true, - "DIFF_DIVIDER": 20, - "WINDOW_SIZE": 256, - "TOTAL_STAKE_PER_BLOCK": 40000000000000000000000 - }, - "EPOCH_INTERVAL": 3153600 - }, - { - "CHAIN_ID": 7, - "SHARD_SIZE": 1, - "DEFAULT_CHAIN_TOKEN": "QKC", - "CONSENSUS_TYPE": "POW_QKCHASH", - "CONSENSUS_CONFIG": { - "TARGET_BLOCK_TIME": 10, - "REMOTE_MINE": true - }, - "GENESIS": { - "ROOT_HEIGHT": 0, - "VERSION": 0, - "HEIGHT": 0, - "HASH_PREV_MINOR_BLOCK": "0000000000000000000000000000000000000000000000000000000000000000", - "HASH_MERKLE_ROOT": "0000000000000000000000000000000000000000000000000000000000000000", - "EXTRA_DATA": "497420776173207468652062657374206f662074696d65732c206974207761732074686520776f727374206f662074696d65732c202e2e2e202d20436861726c6573204469636b656e73", - "TIMESTAMP": 1556639999, - "DIFFICULTY": 120000, - "GAS_LIMIT": 12000000, - "NONCE": 0, - "ALLOC": { - "32c53C6c2B57B2026a51C87aDD0695F5AeEd3f2e000775b2": { - "QKC": 600000000000000000000000000 - }, - "7DeB90eF2097D8A9e423516e199b9D95EB2b4D97000775b2": { - "QKC": 100000000000000000000000000 - }, - "c4fbA3740f95d25B2196C9437fDb005359296D36000775b2": { - "QKC": 50000000000000000000000000 - } - } - }, - "COINBASE_ADDRESS": "000000000000000000000000000000000000000000000000", - "COINBASE_AMOUNT": 6500000000000000000, - "DIFFICULTY_ADJUSTMENT_CUTOFF_TIME": 7, - "DIFFICULTY_ADJUSTMENT_FACTOR": 512, - "EXTRA_SHARD_BLOCKS_IN_ROOT_BLOCK": 12, - "POSW_CONFIG": { - "ENABLED": true, - "DIFF_DIVIDER": 20, - "WINDOW_SIZE": 256, - "TOTAL_STAKE_PER_BLOCK": 160000000000000000000000 - }, - "EPOCH_INTERVAL": 3153600 - } - ], - "REWARD_TAX_RATE": 0.5, - "BLOCK_REWARD_DECAY_FACTOR": 0.88 - }, - "MASTER": { - "MASTER_TO_SLAVE_CONNECT_RETRY_DELAY": 1.0 - }, - "SLAVE_LIST": [ - { - "HOST": "127.0.0.1", - "PORT": 38000, - "ID": "S0", - "FULL_SHARD_ID_LIST": [ - "0x1", "0x00040001" - ] - }, - { - "HOST": "127.0.0.1", - "PORT": 38001, - "ID": "S1", - "FULL_SHARD_ID_LIST": [ - "0x00010001", "0x00050001" - ] - }, - { - "HOST": "127.0.0.1", - "PORT": 38002, - "ID": "S2", - "FULL_SHARD_ID_LIST": [ - "0x00020001", "0x00060001" - ] - }, - { - "HOST": "127.0.0.1", - "PORT": 38003, - "ID": "S3", - "FULL_SHARD_ID_LIST": [ - "0x00030001", "0x00070001" - ] - } - ], - "P2P": { - "NEW_MODULE": true, - "MAX_PEERS": 0, - "BOOT_NODES": "enode://438d9a2349037e231ae7975f646a32c5b3d2032190a067762b35b8a039568fbb81981e4e2e43f1923a113834a4675919ed27fad68ca48203b4001fee049a9276@35.243.210.122:38291,enode://c093dee29400c0d114c3af600df80a7ad285e8b430f6768749600d55726d4b1562f624526c596b968e4520eaeadaa0d8be98940da065ac710a76d8fac58d5c00@35.246.213.180:38291,enode://48e1af232c290add043118edca45608589ef305f19a2d6d8a6126677ba573c1d5984c15962e8593b32e6ae2f1a89237f9691178e527cba0b07818ad5b01a13dc@52.34.48.64:38291,enode://69a887846c4f6540958c20d654b191b08c39e5624b93d8e94ec8e37da2ae7c0572c0741775e34cd17affa7e68532910e152e16361d22198f04aae2cceb105a03@13.124.15.123:38291,enode://5f81aac576814cac04701d418d9f127903cf75ed26c0433b9b1b35774efe7e2630e377baae156023d2448055e32678a472f6a25f5ead8a690f8cec1e7c9176e6@68.183.247.182:38291,enode://80a7f0960732dae69fa470cf950be636352166b9f016605b79bae4286f06a3fb0361f1293d6ea43df9b87f6e6397498e82c23d913464e2724e5c3adcce796e0d@165.227.240.113:38291", - "PRIV_KEY": "", - "UPNP": true, - "CRAWLING_ROUTING_TABLE_FILE_PATH": "./routing_table.pickle" - }, - "MONITORING": { - "NETWORK_NAME": "", - "CLUSTER_ID": "127.0.0.1", - "KAFKA_REST_ADDRESS": "", - "MINER_TOPIC": "qkc_miner", - "PROPAGATION_TOPIC": "block_propagation", - "ERRORS": "error" - } -} diff --git a/mainnet/singularity/cluster_config_template.json b/mainnet/singularity/cluster_config_template.json index 10bbac197..437da2289 100644 --- a/mainnet/singularity/cluster_config_template.json +++ b/mainnet/singularity/cluster_config_template.json @@ -28,6 +28,7 @@ "ENABLE_QKCHASHX_HEIGHT": 1480000, "ENABLE_NON_RESERVED_NATIVE_TOKEN_TIMESTAMP": 1588291200, "ENABLE_GENERAL_NATIVE_TOKEN_TIMESTAMP": 1588291200, + "ENABLE_POSW_STAKING_DECAY_TIMESTAMP": 1588291200, "TX_WHITELIST_SENDERS": [ "b8C082828F51343299c9A4deEb2503AaC3bA074f", "3391A1796cB98D79A2Fde326F375DF900C959Ed0", diff --git a/mainnet/singularity/cluster_config_template_8nodes.json b/mainnet/singularity/cluster_config_template_8nodes.json index b88151a36..f726b0a97 100644 --- a/mainnet/singularity/cluster_config_template_8nodes.json +++ b/mainnet/singularity/cluster_config_template_8nodes.json @@ -28,6 +28,7 @@ "ENABLE_QKCHASHX_HEIGHT": 1480000, "ENABLE_NON_RESERVED_NATIVE_TOKEN_TIMESTAMP": 1588291200, "ENABLE_GENERAL_NATIVE_TOKEN_TIMESTAMP": 1588291200, + "ENABLE_POSW_STAKING_DECAY_TIMESTAMP": 1588291200, "TX_WHITELIST_SENDERS": [ "b8C082828F51343299c9A4deEb2503AaC3bA074f", "3391A1796cB98D79A2Fde326F375DF900C959Ed0", diff --git a/quarkchain/cluster/shard_state.py b/quarkchain/cluster/shard_state.py index 1eb88ee83..b8537e7f6 100644 --- a/quarkchain/cluster/shard_state.py +++ b/quarkchain/cluster/shard_state.py @@ -1829,11 +1829,12 @@ def _posw_info(self, block: MinorBlock) -> Optional[PoSWInfo]: if header.height == 0: # genesis return None block_cnt = self._get_posw_coinbase_blockcnt(header.hash_prev_minor_block) - # TODO: required stakes will decay as our mining rewards - # stake_per_block = self.__decay_by_epoch( - # self.shard_config.POSW_CONFIG.TOTAL_STAKE_PER_BLOCK, header.height - # ) stake_per_block = self.shard_config.POSW_CONFIG.TOTAL_STAKE_PER_BLOCK + enable_decay_ts = ( + self.env.quark_chain_config.ENABLE_POSW_STAKING_DECAY_TIMESTAMP + ) + if enable_decay_ts is not None and block.header.create_time > enable_decay_ts: + stake_per_block = self.__decay_by_epoch(stake_per_block, header.height) return get_posw_info( self.shard_config.POSW_CONFIG, header, diff --git a/quarkchain/cluster/tests/test_shard_state.py b/quarkchain/cluster/tests/test_shard_state.py index c90dc77d8..624a10dc0 100644 --- a/quarkchain/cluster/tests/test_shard_state.py +++ b/quarkchain/cluster/tests/test_shard_state.py @@ -3723,22 +3723,27 @@ def tx_gen(to): ) def test_posw_stake_by_block_decay_by_epoch(self): - # TODO: will bring back those tests after 1.4.1 - pass - # acc = Address(b"\x01" * 20, full_shard_key=0) - # env = get_test_env(genesis_account=acc, genesis_minor_quarkash=200) - # state = create_default_shard_state(env=env, shard_id=0, posw_override=True) - - # state.shard_config.CONSENSUS_TYPE = ConsensusType.POW_DOUBLESHA256 - # state.shard_config.POSW_CONFIG.TOTAL_STAKE_PER_BLOCK = 100 - # state.shard_config.POSW_CONFIG.WINDOW_SIZE = 256 - - # b1 = state.get_tip().create_block_to_append(address=acc) - # posw_info = state._posw_info(b1) - # # 200 qkc with 100 required per block, should equal 2 mineable blocks - # self.assertEqual(posw_info.posw_mineable_blocks, 200 / 100) - - # # decay (factor = 0.5) should kick in and double mineable blocks - # b1.header.height = state.shard_config.EPOCH_INTERVAL - # posw_info = state._posw_info(b1) - # self.assertEqual(posw_info.posw_mineable_blocks, 200 / (100 / 2)) + acc = Address(b"\x01" * 20, full_shard_key=0) + env = get_test_env(genesis_account=acc, genesis_minor_quarkash=200) + env.quark_chain_config.ENABLE_POSW_STAKING_DECAY_TIMESTAMP = 100 + state = create_default_shard_state(env=env, shard_id=0, posw_override=True) + + state.shard_config.CONSENSUS_TYPE = ConsensusType.POW_DOUBLESHA256 + state.shard_config.POSW_CONFIG.TOTAL_STAKE_PER_BLOCK = 100 + state.shard_config.POSW_CONFIG.WINDOW_SIZE = 256 + + # created time is greater than threshold + b1 = state.get_tip().create_block_to_append(create_time=101, address=acc) + posw_info = state._posw_info(b1) + # 200 qkc with 100 required per block, should equal 2 mineable blocks + self.assertEqual(posw_info.posw_mineable_blocks, 200 / 100) + + # decay (factor = 0.5) should kick in and double mineable blocks + b1.header.height = state.shard_config.EPOCH_INTERVAL + posw_info = state._posw_info(b1) + self.assertEqual(posw_info.posw_mineable_blocks, 200 / (100 / 2)) + + # no effect before the enable timestamp + b1.header.create_time = 99 + posw_info = state._posw_info(b1) + self.assertEqual(posw_info.posw_mineable_blocks, 200 / 100) diff --git a/quarkchain/config.py b/quarkchain/config.py index 869e9a193..df6b775ae 100644 --- a/quarkchain/config.py +++ b/quarkchain/config.py @@ -312,6 +312,7 @@ class QuarkChainConfig(BaseConfig): ENABLE_QKCHASHX_HEIGHT = None ENABLE_NON_RESERVED_NATIVE_TOKEN_TIMESTAMP = None ENABLE_GENERAL_NATIVE_TOKEN_TIMESTAMP = None + ENABLE_POSW_STAKING_DECAY_TIMESTAMP = None MIN_TX_POOL_GAS_PRICE = 10 ** 9 # lowest gas price to accept, default 1 Gwei MIN_MINING_GAS_PRICE = 10 ** 9 # lowest gas price to pack tx for mining, 1 Gwei diff --git a/quarkchain/tests/test_config.py b/quarkchain/tests/test_config.py index df28d11dc..6cbf4be0a 100644 --- a/quarkchain/tests/test_config.py +++ b/quarkchain/tests/test_config.py @@ -200,6 +200,7 @@ def test_serialization(self): "ENABLE_QKCHASHX_HEIGHT": null, "ENABLE_NON_RESERVED_NATIVE_TOKEN_TIMESTAMP": null, "ENABLE_GENERAL_NATIVE_TOKEN_TIMESTAMP": null, + "ENABLE_POSW_STAKING_DECAY_TIMESTAMP": null, "MIN_TX_POOL_GAS_PRICE": 1000000000, "MIN_MINING_GAS_PRICE": 1000000000, "XSHARD_GAS_DDOS_FIX_ROOT_HEIGHT": 90000,