6 "github.com/vapor/protocol/bc"
13 PayToWitnessPubKeyHashDataSize = 20
14 PayToWitnessScriptHashDataSize = 32
17 // BTMAssetID is BTM's asset id, the soul asset of Bytom
18 var BTMAssetID = &bc.AssetID{
19 V0: binary.BigEndian.Uint64([]byte{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}),
20 V1: binary.BigEndian.Uint64([]byte{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}),
21 V2: binary.BigEndian.Uint64([]byte{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}),
22 V3: binary.BigEndian.Uint64([]byte{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}),
25 // BTMDefinitionMap is the ....
26 var BTMDefinitionMap = map[string]interface{}{
30 "description": `Bytom Official Issue`,
33 // BasicConfig indicate the basic config
34 type BasicConfig struct {
36 MaxBlockGas uint64 // the max used gas for all transactions of a block
37 MaxGasAmount int64 // the max gas for a transaction
38 DefaultGasCredit int64 // the max default credit gas for a transaction with non-BTM asset
39 VMGasRate int64 // the gas rate for VM
40 StorageGasRate int64 // the gas rate for storage
43 VotePendingBlockNumber uint64 // the valid block interval for vote utxo after the vote transaction is confirmed
44 CoinbasePendingBlockNumber uint64 // the valid block interval for coinbase utxo after the coinbase transaction is confirmed
45 CoinbaseArbitrarySizeLimit int // the max size for coinbase arbitrary
48 // DPOSConfig indicate the dpos consensus config
49 type DPOSConfig struct {
50 NumOfConsensusNode int64 // the number of consensus node
51 BlockNumEachNode uint64 // the number of generated continuous blocks for each node
52 RoundVoteBlockNums uint64 // the block interval which count the vote result in a round
53 MinConsensusNodeVoteNum uint64 // the min BTM amount for becoming consensus node(the unit is neu)
54 MinVoteOutputAmount uint64 // the min BTM amount for voting output in a transaction(the unit is neu)
55 BlockTimeInterval uint64 // the block time interval for producting a block
56 MaxTimeOffsetMs uint64 // the max number of seconds a block time is allowed to be ahead of the current time
59 // Checkpoint identifies a known good point in the block chain. Using
60 // checkpoints allows a few optimizations for old blocks during initial download
61 // and also prevents forks from old blocks.
62 type Checkpoint struct {
67 // ProducerSubsidy is a subsidy to the producer of the generated block
68 type ProducerSubsidy struct {
74 // Params store the config for different network
76 // Name defines a human-readable identifier for the network.
79 // Bech32HRPSegwit defines the prefix of address for the network
80 Bech32HRPSegwit string
82 // DefaultPort defines the default peer-to-peer port for the network.
85 // BasicConfig defines the gas and utxo relatived paramters.
88 // DPOSConfig defines the dpos consensus paramters.
91 // DNSSeeds defines a list of DNS seeds for the network that are used
92 // as one method to discover peers.
95 // Checkpoints defines the checkpoint blocks
96 Checkpoints []Checkpoint
98 // ProducerSubsidys defines the producer subsidy by block height
99 ProducerSubsidys []ProducerSubsidy
102 // VaporDPOSConfig return the dpos consensus config
103 func VaporDPOSConfig() DPOSConfig {
105 NumOfConsensusNode: 10,
106 BlockNumEachNode: 12,
107 MinConsensusNodeVoteNum: uint64(100000000000000),
108 MinVoteOutputAmount: uint64(100000000),
109 BlockTimeInterval: 500,
112 dpos.RoundVoteBlockNums = uint64(uint64(dpos.NumOfConsensusNode) * dpos.BlockNumEachNode * 10)
113 dpos.MaxTimeOffsetMs = uint64(uint64(dpos.BlockTimeInterval) * dpos.BlockNumEachNode / 3)
117 // ActiveNetParams is the active NetParams
118 var ActiveNetParams = VaporNetParams
120 // NetParams is the correspondence between chain_id and Params
121 var NetParams = map[string]Params{
122 "vapor": VaporNetParams,
123 "solonet": SoloNetParams,
126 // VaporNetParams is the config for vapor-net
127 var VaporNetParams = Params{
129 Bech32HRPSegwit: "vp",
130 BasicConfig: BasicConfig{
131 MaxBlockGas: uint64(10000000),
132 MaxGasAmount: int64(200000),
133 DefaultGasCredit: int64(160000),
134 StorageGasRate: int64(1),
135 VMGasRate: int64(200),
136 VotePendingBlockNumber: uint64(10000),
137 CoinbasePendingBlockNumber: uint64(100),
138 CoinbaseArbitrarySizeLimit: 128,
140 DPOSConfig: VaporDPOSConfig(),
141 Checkpoints: []Checkpoint{},
142 ProducerSubsidys: []ProducerSubsidy{
143 {BeginBlock: 1, EndBlock: 63072000, Subsidy: 15000000},
147 // SoloNetParams is the config for solo test-net
148 var SoloNetParams = Params{
150 Bech32HRPSegwit: "sm",
151 BasicConfig: BasicConfig{
152 MaxBlockGas: uint64(10000000),
153 MaxGasAmount: int64(200000),
154 DefaultGasCredit: int64(160000),
155 StorageGasRate: int64(1),
156 VMGasRate: int64(200),
157 VotePendingBlockNumber: uint64(10000),
158 CoinbasePendingBlockNumber: uint64(100),
159 CoinbaseArbitrarySizeLimit: 128,
161 DPOSConfig: VaporDPOSConfig(),
162 Checkpoints: []Checkpoint{},
163 ProducerSubsidys: []ProducerSubsidy{
164 {BeginBlock: 0, EndBlock: 0, Subsidy: 24},
165 {BeginBlock: 1, EndBlock: 840000, Subsidy: 24},
166 {BeginBlock: 840001, EndBlock: 1680000, Subsidy: 12},
167 {BeginBlock: 1680001, EndBlock: 3360000, Subsidy: 6},
171 // BlockSubsidy calculate the coinbase rewards on given block height
172 func BlockSubsidy(height uint64) uint64 {
173 for _, subsidy := range ActiveNetParams.ProducerSubsidys {
174 if height >= subsidy.BeginBlock && height <= subsidy.EndBlock {
175 return subsidy.Subsidy