7 "github.com/bytom/vapor/protocol/bc"
14 PayToWitnessPubKeyHashDataSize = 20
15 PayToWitnessScriptHashDataSize = 32
17 CrossInForkHeight = 128957600
23 // BTMAssetID is BTM's asset id, the soul asset of Bytom
24 var BTMAssetID = &bc.AssetID{
25 V0: binary.BigEndian.Uint64([]byte{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}),
26 V1: binary.BigEndian.Uint64([]byte{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}),
27 V2: binary.BigEndian.Uint64([]byte{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}),
28 V3: binary.BigEndian.Uint64([]byte{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}),
31 // BTMDefinitionMap is the ....
32 var BTMDefinitionMap = map[string]interface{}{
36 "description": `Bytom Official Issue`,
39 // BasicConfig indicate the basic config
40 type BasicConfig struct {
42 MaxBlockGas uint64 // the max used gas for all transactions of a block
43 MaxGasAmount int64 // the max gas for a transaction
44 DefaultGasCredit int64 // the max default credit gas for a transaction with non-BTM asset
45 VMGasRate int64 // the gas rate for VM
46 StorageGasRate int64 // the gas rate for storage
49 VotePendingBlockNumber uint64 // the valid block interval for vote utxo after the vote transaction is confirmed
50 CoinbasePendingBlockNumber uint64 // the valid block interval for coinbase utxo after the coinbase transaction is confirmed
51 CoinbaseArbitrarySizeLimit int // the max size for coinbase arbitrary
54 // DPOSConfig indicate the dpos consensus config
55 type DPOSConfig struct {
56 NumOfConsensusNode int64 // the number of consensus node
57 BlockNumEachNode uint64 // the number of generated continuous blocks for each node
58 RoundVoteBlockNums uint64 // the block interval which count the vote result in a round
59 MinConsensusNodeVoteNum uint64 // the min BTM amount for becoming consensus node(the unit is neu)
60 MinVoteOutputAmount uint64 // the min BTM amount for voting output in a transaction(the unit is neu)
61 BlockTimeInterval uint64 // the block time interval for producting a block
62 MaxTimeOffsetMs uint64 // the max number of seconds a block time is allowed to be ahead of the current time
65 // Checkpoint identifies a known good point in the block chain. Using
66 // checkpoints allows a few optimizations for old blocks during initial download
67 // and also prevents forks from old blocks.
68 type Checkpoint struct {
73 // ProducerSubsidy is a subsidy to the producer of the generated block
74 type ProducerSubsidy struct {
80 // MovRewardProgram is a reward address corresponding to the range of the specified block height when matching transactions
81 type MovRewardProgram struct {
87 // Params store the config for different network
89 // Name defines a human-readable identifier for the network.
92 // Bech32HRPSegwit defines the prefix of address for the network
93 Bech32HRPSegwit string
95 // DefaultPort defines the default peer-to-peer port for the network.
98 // BasicConfig defines the gas and utxo relatived paramters.
101 // DPOSConfig defines the dpos consensus paramters.
104 // DNSSeeds defines a list of DNS seeds for the network that are used
105 // as one method to discover peers.
108 // Checkpoints defines the checkpoint blocks
109 Checkpoints []Checkpoint
111 // ProducerSubsidys defines the producer subsidy by block height
112 ProducerSubsidys []ProducerSubsidy
114 SoftForkPoint map[uint64]uint64
116 // Mov will only start when the block height is greater than this value
117 MovStartHeight uint64
119 // Used to receive rewards for matching transactions
120 MovRewardPrograms []MovRewardProgram
123 // ActiveNetParams is the active NetParams
124 var ActiveNetParams = MainNetParams
126 // NetParams is the correspondence between chain_id and Params
127 var NetParams = map[string]Params{
128 "mainnet": MainNetParams,
129 "testnet": TestNetParams,
130 "solonet": SoloNetParams,
133 // MainNetParams is the config for vapor-mainnet
134 var MainNetParams = Params{
136 Bech32HRPSegwit: "vp",
137 DefaultPort: "56656",
138 DNSSeeds: []string{"www.mainnetseed.vapor.io"},
139 BasicConfig: BasicConfig{
140 MaxBlockGas: uint64(10000000),
141 MaxGasAmount: int64(640000),
142 DefaultGasCredit: int64(160000),
143 StorageGasRate: int64(1),
144 VMGasRate: int64(200),
145 VotePendingBlockNumber: uint64(3456000),
146 CoinbasePendingBlockNumber: uint64(7200),
147 CoinbaseArbitrarySizeLimit: 128,
149 DPOSConfig: DPOSConfig{
150 NumOfConsensusNode: 10,
151 BlockNumEachNode: 12,
152 MinConsensusNodeVoteNum: uint64(100000000000000),
153 MinVoteOutputAmount: uint64(100000000),
154 BlockTimeInterval: 500,
155 RoundVoteBlockNums: 1200,
156 MaxTimeOffsetMs: 2000,
158 Checkpoints: []Checkpoint{},
159 ProducerSubsidys: []ProducerSubsidy{
160 {BeginBlock: 1, EndBlock: 63072000, Subsidy: 9512938},
161 {BeginBlock: 63072001, EndBlock: 126144000, Subsidy: 9512938},
163 SoftForkPoint: map[uint64]uint64{SoftFork001: 10461600},
164 MovStartHeight: 42884800,
165 MovRewardPrograms: []MovRewardProgram{
169 Program: "00141d00f85e220e35a23282cfc7f91fe7b34bf6dc18",
174 // TestNetParams is the config for vapor-testnet
175 var TestNetParams = Params{
177 Bech32HRPSegwit: "tp",
178 DefaultPort: "56657",
179 DNSSeeds: []string{"www.testnetseed.vapor.io"},
180 BasicConfig: BasicConfig{
181 MaxBlockGas: uint64(10000000),
182 MaxGasAmount: int64(640000),
183 DefaultGasCredit: int64(160000),
184 StorageGasRate: int64(1),
185 VMGasRate: int64(200),
186 VotePendingBlockNumber: uint64(3456000),
187 CoinbasePendingBlockNumber: uint64(7200),
188 CoinbaseArbitrarySizeLimit: 128,
190 DPOSConfig: DPOSConfig{
191 NumOfConsensusNode: 10,
192 BlockNumEachNode: 12,
193 MinConsensusNodeVoteNum: uint64(100000000000000),
194 MinVoteOutputAmount: uint64(100000000),
195 BlockTimeInterval: 500,
196 RoundVoteBlockNums: 1200,
197 MaxTimeOffsetMs: 2000,
199 Checkpoints: []Checkpoint{},
200 ProducerSubsidys: []ProducerSubsidy{
201 {BeginBlock: 1, EndBlock: 63072000, Subsidy: 15000000},
205 // SoloNetParams is the config for vapor solonet
206 var SoloNetParams = Params{
208 Bech32HRPSegwit: "sp",
209 DefaultPort: "56658",
210 BasicConfig: BasicConfig{
211 MaxBlockGas: uint64(10000000),
212 MaxGasAmount: int64(200000),
213 DefaultGasCredit: int64(160000),
214 StorageGasRate: int64(1),
215 VMGasRate: int64(200),
216 VotePendingBlockNumber: uint64(10000),
217 CoinbasePendingBlockNumber: uint64(1200),
218 CoinbaseArbitrarySizeLimit: 128,
220 DPOSConfig: DPOSConfig{
221 NumOfConsensusNode: 10,
222 BlockNumEachNode: 12,
223 MinConsensusNodeVoteNum: uint64(100000000000000),
224 MinVoteOutputAmount: uint64(100000000),
225 BlockTimeInterval: 500,
226 RoundVoteBlockNums: 1200,
227 MaxTimeOffsetMs: 2000,
229 Checkpoints: []Checkpoint{},
230 ProducerSubsidys: []ProducerSubsidy{
231 {BeginBlock: 0, EndBlock: 0, Subsidy: 24},
232 {BeginBlock: 1, EndBlock: 840000, Subsidy: 24},
233 {BeginBlock: 840001, EndBlock: 1680000, Subsidy: 12},
234 {BeginBlock: 1680001, EndBlock: 3360000, Subsidy: 6},
238 // BlockSubsidy calculate the coinbase rewards on given block height
239 func BlockSubsidy(height uint64) uint64 {
240 for _, subsidy := range ActiveNetParams.ProducerSubsidys {
241 if height >= subsidy.BeginBlock && height <= subsidy.EndBlock {
242 return subsidy.Subsidy
248 // BytomMainNetParams is the config for bytom mainnet
249 func BytomMainNetParams(vaporParam *Params) *Params {
250 bech32HRPSegwit := "sn"
251 switch vaporParam.Name {
253 bech32HRPSegwit = "bn"
255 bech32HRPSegwit = "tn"
257 return &Params{Bech32HRPSegwit: bech32HRPSegwit}
260 // InitActiveNetParams load the config by chain ID
261 func InitActiveNetParams(chainID string) error {
263 if ActiveNetParams, exist = NetParams[chainID]; !exist {
264 return fmt.Errorf("chain_id[%v] don't exist", chainID)