You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

156 lines
6.3 KiB

  1. // Copyright 2017-2018 DERO Project. All rights reserved.
  2. // Use of this source code in any form is governed by RESEARCH license.
  3. // license can be found in the LICENSE file.
  4. // GPG: 0F39 E425 8C65 3947 702A 8234 08B2 0360 A03A 9DE8
  5. //
  6. //
  7. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
  8. // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  9. // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
  10. // THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  11. // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  12. // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  13. // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  14. // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  15. // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  16. package config
  17. import "github.com/satori/go.uuid"
  18. import "github.com/deroproject/derosuite/crypto"
  19. // all global configuration variables are picked from here
  20. var BLOCK_TIME = uint64(120)
  21. // we are ignoring leap seconds from calculations
  22. // coin emiision related settings
  23. var COIN_MONEY_SUPPLY = uint64(18446744073709551615) // 2^64-1
  24. var COIN_EMISSION_SPEED_FACTOR = uint64(20)
  25. var COIN_DIFFICULTY_TARGET = uint64(120) // this is a feeder to emission formula
  26. var COIN_FINAL_SUBSIDY_PER_MINUTE = uint64(300000000000) // 0.3 DERO per minute = 157680 per year roughly
  27. var CRYPTONOTE_REWARD_BLOCKS_WINDOW = uint64(100) // last 100 blocks are used to create
  28. var MINER_TX_AMOUNT_UNLOCK = uint64(60) // miner tx will need 60 blocks to mature
  29. var NORMAL_TX_AMOUNT_UNLOCK = uint64(10) // normal transfers will mature at 10th (9 blocks distance) blocks to mature
  30. // this is used to find whether output is locked to height or time
  31. // see input maturity to find how it works
  32. // if locked is less than this, then it is considered locked to height else epoch
  33. var CRYPTONOTE_MAX_BLOCK_NUMBER = uint64(500000000)
  34. var MAX_CHAIN_HEIGHT = uint64(2147483648) // 2^31
  35. // we use this for scheduled hardforks
  36. var CURRENT_BLOCK_MAJOR_VERSION = 6
  37. var CURRENT_BLOCK_MINOR_VERSION = 6
  38. // this is also the minimum block size
  39. var CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE = uint64(300000) // after this block size , reward calculated differently
  40. var CRYPTONOTE_MAX_TX_SIZE = uint64(100 * 1024 * 1024) // 100 MB, we must rationalize it
  41. // we only accept blocks which are this much into future, 2 hours
  42. const CRYPTONOTE_BLOCK_FUTURE_TIME_LIMIT = 60 * 60 * 20
  43. // block is checked that the timestamp is not less than the median of this many blocks
  44. const BLOCKCHAIN_TIMESTAMP_CHECK_WINDOW = 60
  45. // consider last 30 blocks for calculating difficulty
  46. const DIFFICULTY_BLOCKS_COUNT_V2 = 30
  47. // FEE calculation constants are here
  48. // the constants can be found in cryptonote_config.h
  49. const DYNAMIC_FEE_PER_KB_BASE_FEE_V5 = uint64((2000000000 * 60000) / 300000)
  50. const DYNAMIC_FEE_PER_KB_BASE_BLOCK_REWARD = uint64(10000000000000) // 10 * pow(10,12)
  51. const PROJECT_NAME = "dero"
  52. const POOLDATA_FILENAME = "poolstate.bin"
  53. //const CRYPTONOTE_BLOCKCHAINDATA_FILENAME "data.mdb" // these decisions are made by storage layer
  54. //#define CRYPTONOTE_BLOCKCHAINDATA_LOCK_FILENAME "lock.mdb"
  55. const P2P_NET_DATA_FILENAME = "p2pstate.bin"
  56. // we can have number of chains running for testing reasons
  57. type CHAIN_CONFIG struct {
  58. Name string
  59. Network_ID uuid.UUID // network ID
  60. Public_Address_Prefix uint64
  61. Public_Address_Prefix_Integrated uint64
  62. P2P_Default_Port uint32
  63. RPC_Default_Port uint32
  64. Genesis_Nonce uint32
  65. Genesis_Block_Hash crypto.Hash
  66. Genesis_Tx string
  67. }
  68. var Mainnet = CHAIN_CONFIG{Name: "mainnet",
  69. Network_ID: uuid.FromBytesOrNil([]byte{0x59, 0xd7, 0xf7, 0xe9, 0xdd, 0x48, 0xd5, 0xfd, 0x13, 0x0a, 0xf6, 0xe0, 0x9a, 0xec, 0xb9, 0x23}),
  70. Public_Address_Prefix: 0xc8ed8, //for dERo
  71. Public_Address_Prefix_Integrated: 0xa0ed8, //for dERi
  72. P2P_Default_Port: 18090,
  73. RPC_Default_Port: 18091,
  74. Genesis_Nonce: 10000,
  75. Genesis_Block_Hash: crypto.Hash([32]byte{0x36, 0x2d, 0x61, 0x48, 0xd6, 0x83, 0x08, 0x2d,
  76. 0x94, 0x2e, 0x53, 0xdd, 0xb5, 0x0d, 0xaf, 0x54,
  77. 0x6a, 0x10, 0x92, 0xda, 0x76, 0x98, 0x2d, 0x5b,
  78. 0xd4, 0xf1, 0x3d, 0x0d, 0xf0, 0x74, 0xec, 0x2f}),
  79. Genesis_Tx: "" +
  80. "02" + // version
  81. "3c" + // unlock time
  82. "01" + // vin length
  83. "ff" + // vin #1
  84. "00" + // height gen input
  85. "01" + // vout length
  86. "ffffffffffff07" + // output #1 amount
  87. "02" + // output 1 type
  88. "0bf6522f9152fa26cd1fc5c022b1a9e13dab697f3acf4b4d0ca6950a867a1943" + // output #1 key
  89. "21" + // extra length in bytes
  90. "01" + // extra pubkey tag
  91. "1d92826d0656958865a035264725799f39f6988faa97d532f972895de849496d" + // tx pubkey
  92. "00", // RCT signature none
  93. }
  94. var Testnet = CHAIN_CONFIG{Name: "testnet",
  95. Network_ID: uuid.FromBytesOrNil([]byte{0x59, 0xd7, 0xf7, 0xe9, 0xdd, 0x48, 0xd5, 0xfd, 0x13, 0x0a, 0xf6, 0xe0, 0x9a, 0xec, 0xb9, 0x24}),
  96. Public_Address_Prefix: 0x6cf58, // for dETo
  97. Public_Address_Prefix_Integrated: 0x44f58, //for dETi
  98. P2P_Default_Port: 28090,
  99. RPC_Default_Port: 28091,
  100. Genesis_Nonce: 10001,
  101. Genesis_Block_Hash: crypto.Hash([32]byte{0x63, 0x34, 0x12, 0xde, 0x21, 0xea, 0xcb, 0xf0,
  102. 0x03, 0xe0, 0xfb, 0x9b, 0x7f, 0xcb, 0xca, 0x97,
  103. 0x6d, 0xff, 0xd4, 0x3e, 0x3f, 0x06, 0x9e, 0x55,
  104. 0xfa, 0xf1, 0xc5, 0xb4, 0x46, 0x2b, 0x59, 0x3a}),
  105. Genesis_Tx: "" +
  106. "02" + // version
  107. "3c" + // unlock time
  108. "01" + // vin length
  109. "ff" + // vin #1
  110. "00" + // height gen input
  111. "01" + // vout length
  112. "ffffffffffff07" + // output #1 amount
  113. "02" + // output 1 type
  114. "0bf6522f9152fa26cd1fc5c022b1a9e13dab697f3acf4b4d0ca6950a867a1943" + // output #1 key
  115. "21" + // extra length in bytes
  116. "01" + // extra pubkey tag
  117. "1d92826d0656958865a035264725799f39f6988faa97d532f972895de849496d" + // tx pubkey
  118. "00", // RCT signature none
  119. }
  120. // on init this variable is updated to setup global config in 1 go
  121. //var Current_Config CHAIN_CONFIG
  122. func init() {
  123. //Current_Config = Mainnet // default is mainnnet
  124. //Current_Config = Testnet // default is mainnnet
  125. }