7 "github.com/bytom/vapor/protocol/bc"
14 PayToWitnessPubKeyHashDataSize = 20
15 PayToWitnessScriptHashDataSize = 32
21 // BTMAssetID is BTM's asset id, the soul asset of Bytom
22 var BTMAssetID = &bc.AssetID{
23 V0: binary.BigEndian.Uint64([]byte{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}),
24 V1: binary.BigEndian.Uint64([]byte{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}),
25 V2: binary.BigEndian.Uint64([]byte{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}),
26 V3: binary.BigEndian.Uint64([]byte{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}),
29 // BTMDefinitionMap is the ....
30 var BTMDefinitionMap = map[string]interface{}{
34 "description": `Bytom Official Issue`,
37 // BasicConfig indicate the basic config
38 type BasicConfig struct {
40 MaxBlockGas uint64 // the max used gas for all transactions of a block
41 MaxGasAmount int64 // the max gas for a transaction
42 DefaultGasCredit int64 // the max default credit gas for a transaction with non-BTM asset
43 VMGasRate int64 // the gas rate for VM
44 StorageGasRate int64 // the gas rate for storage
47 VotePendingBlockNumber uint64 // the valid block interval for vote utxo after the vote transaction is confirmed
48 CoinbasePendingBlockNumber uint64 // the valid block interval for coinbase utxo after the coinbase transaction is confirmed
49 CoinbaseArbitrarySizeLimit int // the max size for coinbase arbitrary
52 // DPOSConfig indicate the dpos consensus config
53 type DPOSConfig struct {
54 NumOfConsensusNode int64 // the number of consensus node
55 BlockNumEachNode uint64 // the number of generated continuous blocks for each node
56 RoundVoteBlockNums uint64 // the block interval which count the vote result in a round
57 MinConsensusNodeVoteNum uint64 // the min BTM amount for becoming consensus node(the unit is neu)
58 MinVoteOutputAmount uint64 // the min BTM amount for voting output in a transaction(the unit is neu)
59 BlockTimeInterval uint64 // the block time interval for producting a block
60 MaxTimeOffsetMs uint64 // the max number of seconds a block time is allowed to be ahead of the current time
63 // Checkpoint identifies a known good point in the block chain. Using
64 // checkpoints allows a few optimizations for old blocks during initial download
65 // and also prevents forks from old blocks.
66 type Checkpoint struct {
71 // ProducerSubsidy is a subsidy to the producer of the generated block
72 type ProducerSubsidy struct {
78 // Params store the config for different network
80 // Name defines a human-readable identifier for the network.
83 // Bech32HRPSegwit defines the prefix of address for the network
84 Bech32HRPSegwit string
86 // DefaultPort defines the default peer-to-peer port for the network.
89 // BasicConfig defines the gas and utxo relatived paramters.
92 // DPOSConfig defines the dpos consensus paramters.
95 // DNSSeeds defines a list of DNS seeds for the network that are used
96 // as one method to discover peers.
99 // Checkpoints defines the checkpoint blocks
100 Checkpoints []Checkpoint
102 // ProducerSubsidys defines the producer subsidy by block height
103 ProducerSubsidys []ProducerSubsidy
105 SoftForkPoint map[uint64]uint64
106 MovStartHeight uint64
109 // ActiveNetParams is the active NetParams
110 var ActiveNetParams = MainNetParams
112 // NetParams is the correspondence between chain_id and Params
113 var NetParams = map[string]Params{
114 "mainnet": MainNetParams,
115 "testnet": TestNetParams,
116 "solonet": SoloNetParams,
119 // MainNetParams is the config for vapor-mainnet
120 var MainNetParams = Params{
122 Bech32HRPSegwit: "vp",
123 DefaultPort: "56656",
124 DNSSeeds: []string{"www.mainnetseed.vapor.io"},
125 BasicConfig: BasicConfig{
126 MaxBlockGas: uint64(10000000),
127 MaxGasAmount: int64(640000),
128 DefaultGasCredit: int64(160000),
129 StorageGasRate: int64(1),
130 VMGasRate: int64(200),
131 VotePendingBlockNumber: uint64(3456000),
132 CoinbasePendingBlockNumber: uint64(7200),
133 CoinbaseArbitrarySizeLimit: 128,
135 DPOSConfig: DPOSConfig{
136 NumOfConsensusNode: 10,
137 BlockNumEachNode: 12,
138 MinConsensusNodeVoteNum: uint64(100000000000000),
139 MinVoteOutputAmount: uint64(100000000),
140 BlockTimeInterval: 500,
141 RoundVoteBlockNums: 1200,
142 MaxTimeOffsetMs: 2000,
144 Checkpoints: []Checkpoint{},
145 ProducerSubsidys: []ProducerSubsidy{
146 {BeginBlock: 1, EndBlock: 63072000, Subsidy: 9512938},
148 SoftForkPoint: map[uint64]uint64{SoftFork001: 10461600},
151 // TestNetParams is the config for vapor-testnet
152 var TestNetParams = Params{
154 Bech32HRPSegwit: "tp",
155 DefaultPort: "56657",
156 DNSSeeds: []string{"www.testnetseed.vapor.io"},
157 BasicConfig: BasicConfig{
158 MaxBlockGas: uint64(10000000),
159 MaxGasAmount: int64(640000),
160 DefaultGasCredit: int64(160000),
161 StorageGasRate: int64(1),
162 VMGasRate: int64(200),
163 VotePendingBlockNumber: uint64(3456000),
164 CoinbasePendingBlockNumber: uint64(7200),
165 CoinbaseArbitrarySizeLimit: 128,
167 DPOSConfig: DPOSConfig{
168 NumOfConsensusNode: 10,
169 BlockNumEachNode: 12,
170 MinConsensusNodeVoteNum: uint64(100000000000000),
171 MinVoteOutputAmount: uint64(100000000),
172 BlockTimeInterval: 500,
173 RoundVoteBlockNums: 1200,
174 MaxTimeOffsetMs: 2000,
176 Checkpoints: []Checkpoint{},
177 ProducerSubsidys: []ProducerSubsidy{
178 {BeginBlock: 1, EndBlock: 63072000, Subsidy: 15000000},
182 // SoloNetParams is the config for vapor solonet
183 var SoloNetParams = Params{
185 Bech32HRPSegwit: "sp",
186 DefaultPort: "56658",
187 BasicConfig: BasicConfig{
188 MaxBlockGas: uint64(10000000),
189 MaxGasAmount: int64(200000),
190 DefaultGasCredit: int64(160000),
191 StorageGasRate: int64(1),
192 VMGasRate: int64(200),
193 VotePendingBlockNumber: uint64(10000),
194 CoinbasePendingBlockNumber: uint64(1200),
195 CoinbaseArbitrarySizeLimit: 128,
197 DPOSConfig: DPOSConfig{
198 NumOfConsensusNode: 10,
199 BlockNumEachNode: 12,
200 MinConsensusNodeVoteNum: uint64(100000000000000),
201 MinVoteOutputAmount: uint64(100000000),
202 BlockTimeInterval: 500,
203 RoundVoteBlockNums: 1200,
204 MaxTimeOffsetMs: 2000,
206 Checkpoints: []Checkpoint{},
207 ProducerSubsidys: []ProducerSubsidy{
208 {BeginBlock: 0, EndBlock: 0, Subsidy: 24},
209 {BeginBlock: 1, EndBlock: 840000, Subsidy: 24},
210 {BeginBlock: 840001, EndBlock: 1680000, Subsidy: 12},
211 {BeginBlock: 1680001, EndBlock: 3360000, Subsidy: 6},
215 // BlockSubsidy calculate the coinbase rewards on given block height
216 func BlockSubsidy(height uint64) uint64 {
217 for _, subsidy := range ActiveNetParams.ProducerSubsidys {
218 if height >= subsidy.BeginBlock && height <= subsidy.EndBlock {
219 return subsidy.Subsidy
225 // BytomMainNetParams is the config for bytom mainnet
226 func BytomMainNetParams(vaporParam *Params) *Params {
227 bech32HRPSegwit := "sm"
228 switch vaporParam.Name {
230 bech32HRPSegwit = "bm"
232 bech32HRPSegwit = "tm"
234 return &Params{Bech32HRPSegwit: bech32HRPSegwit}
237 func InitActiveNetParams(chainID string) error {
239 if ActiveNetParams, exist = NetParams[chainID]; !exist {
240 return fmt.Errorf("chain_id[%v] don't exist", chainID)