OSDN Git Service

edit the config for prod (#1174)
[bytom/bytom-spv.git] / consensus / general.go
1 package consensus
2
3 import (
4         "strings"
5
6         "github.com/bytom/protocol/bc"
7 )
8
9 //consensus variables
10 const (
11         // Max gas that one block contains
12         MaxBlockGas      = uint64(10000000)
13         VMGasRate        = int64(200)
14         StorageGasRate   = int64(1)
15         MaxGasAmount     = int64(200000)
16         DefaultGasCredit = int64(30000)
17
18         //config parameter for coinbase reward
19         CoinbasePendingBlockNumber = uint64(100)
20         subsidyReductionInterval   = uint64(840000)
21         baseSubsidy                = uint64(41250000000)
22         InitialBlockSubsidy        = uint64(140700041250000000)
23
24         // config for pow mining
25         BlocksPerRetarget     = uint64(2016)
26         TargetSecondsPerBlock = uint64(150)
27         SeedPerRetarget       = uint64(256)
28
29         // MaxTimeOffsetSeconds is the maximum number of seconds a block time is allowed to be ahead of the current time
30         MaxTimeOffsetSeconds = uint64(60 * 60)
31         MedianTimeBlocks     = 11
32
33         PayToWitnessPubKeyHashDataSize = 20
34         PayToWitnessScriptHashDataSize = 32
35         CoinbaseArbitrarySizeLimit     = 128
36
37         BTMAlias = "BTM"
38 )
39
40 // BTMAssetID is BTM's asset id, the soul asset of Bytom
41 var BTMAssetID = &bc.AssetID{
42         V0: uint64(18446744073709551615),
43         V1: uint64(18446744073709551615),
44         V2: uint64(18446744073709551615),
45         V3: uint64(18446744073709551615),
46 }
47
48 // InitialSeed is SHA3-256 of Byte[0^32]
49 var InitialSeed = &bc.Hash{
50         V0: uint64(11412844483649490393),
51         V1: uint64(4614157290180302959),
52         V2: uint64(1780246333311066183),
53         V3: uint64(9357197556716379726),
54 }
55
56 // BTMDefinitionMap is the ....
57 var BTMDefinitionMap = map[string]interface{}{
58         "name":        BTMAlias,
59         "symbol":      BTMAlias,
60         "decimals":    8,
61         "description": `Bytom Official Issue`,
62 }
63
64 // BlockSubsidy calculate the coinbase rewards on given block height
65 func BlockSubsidy(height uint64) uint64 {
66         if height == 0 {
67                 return InitialBlockSubsidy
68         }
69         return baseSubsidy >> uint(height/subsidyReductionInterval)
70 }
71
72 // IsBech32SegwitPrefix returns whether the prefix is a known prefix for segwit
73 // addresses on any default or registered network.  This is used when decoding
74 // an address string into a specific address type.
75 func IsBech32SegwitPrefix(prefix string, params *Params) bool {
76         prefix = strings.ToLower(prefix)
77         return prefix == params.Bech32HRPSegwit+"1"
78 }
79
80 // Checkpoint identifies a known good point in the block chain.  Using
81 // checkpoints allows a few optimizations for old blocks during initial download
82 // and also prevents forks from old blocks.
83 type Checkpoint struct {
84         Height uint64
85         Hash   bc.Hash
86 }
87
88 // Params store the config for different network
89 type Params struct {
90         // Name defines a human-readable identifier for the network.
91         Name            string
92         Bech32HRPSegwit string
93         Checkpoints     []Checkpoint
94 }
95
96 // ActiveNetParams is ...
97 var ActiveNetParams = MainNetParams
98
99 // NetParams is the correspondence between chain_id and Params
100 var NetParams = map[string]Params{
101         "mainnet": MainNetParams,
102         "wisdom":  TestNetParams,
103         "solonet": SoloNetParams,
104 }
105
106 // MainNetParams is the config for production
107 var MainNetParams = Params{
108         Name:            "main",
109         Bech32HRPSegwit: "bm",
110         Checkpoints: []Checkpoint{
111                 {10000, bc.NewHash([32]byte{0x93, 0xe1, 0xeb, 0x78, 0x21, 0xd2, 0xb4, 0xad, 0x0f, 0x5b, 0x1c, 0xea, 0x82, 0xe8, 0x43, 0xad, 0x8c, 0x09, 0x9a, 0xb6, 0x5d, 0x8f, 0x70, 0xc5, 0x84, 0xca, 0xa2, 0xdd, 0xf1, 0x74, 0x65, 0x2c})},
112                 {20000, bc.NewHash([32]byte{0x7d, 0x38, 0x61, 0xf3, 0x2c, 0xc0, 0x03, 0x81, 0xbb, 0xcd, 0x9a, 0x37, 0x6f, 0x10, 0x5d, 0xfe, 0x6f, 0xfe, 0x2d, 0xa5, 0xea, 0x88, 0xa5, 0xe3, 0x42, 0xed, 0xa1, 0x17, 0x9b, 0xa8, 0x0b, 0x7c})},
113                 {30000, bc.NewHash([32]byte{0x32, 0x36, 0x06, 0xd4, 0x27, 0x2e, 0x35, 0x24, 0x46, 0x26, 0x7b, 0xe0, 0xfa, 0x48, 0x10, 0xa4, 0x3b, 0xb2, 0x40, 0xf1, 0x09, 0x51, 0x5b, 0x22, 0x9f, 0xf3, 0xc3, 0x83, 0x28, 0xaa, 0x4a, 0x00})},
114                 {40000, bc.NewHash([32]byte{0x7f, 0xe2, 0xde, 0x11, 0x21, 0xf3, 0xa9, 0xa0, 0xee, 0x60, 0x8d, 0x7d, 0x4b, 0xea, 0xcc, 0x33, 0xfe, 0x41, 0x25, 0xdc, 0x2f, 0x26, 0xc2, 0xf2, 0x9c, 0x07, 0x17, 0xf9, 0xe4, 0x4f, 0x9d, 0x46})},
115                 {50000, bc.NewHash([32]byte{0x5e, 0xfb, 0xdf, 0xf5, 0x35, 0x38, 0xa6, 0x0b, 0x75, 0x32, 0x02, 0x61, 0x83, 0x54, 0x34, 0xff, 0x3e, 0x82, 0x2e, 0xf8, 0x64, 0xae, 0x2d, 0xc7, 0x6c, 0x9d, 0x5e, 0xbd, 0xa3, 0xd4, 0x50, 0xcf})},
116                 {62000, bc.NewHash([32]byte{0xd7, 0x39, 0x8f, 0x23, 0x57, 0xf9, 0x4c, 0xa0, 0x28, 0xa7, 0x00, 0x2b, 0x53, 0x9e, 0x51, 0x2d, 0x3e, 0xca, 0xc9, 0x22, 0x59, 0xfc, 0xd0, 0x3f, 0x67, 0x1a, 0x0a, 0xb1, 0x02, 0xbf, 0x2b, 0x03})},
117         },
118 }
119
120 // TestNetParams is the config for test-net
121 var TestNetParams = Params{
122         Name:            "test",
123         Bech32HRPSegwit: "tm",
124         Checkpoints: []Checkpoint{
125                 {1000, bc.NewHash([32]byte{0x28, 0x29, 0xc9, 0xe2, 0x19, 0x0f, 0xfe, 0xb6, 0xf2, 0x73, 0xde, 0x1a, 0xe8, 0x1f, 0xa6, 0xbc, 0x15, 0xaa, 0x08, 0xa9, 0xb8, 0x4c, 0x43, 0x25, 0x9a, 0xa0, 0x24, 0x8a, 0xd8, 0x55, 0x73, 0xca})},
126                 {1500, bc.NewHash([32]byte{0xc2, 0x94, 0x02, 0xd1, 0x6c, 0xa8, 0x18, 0xc4, 0x95, 0x67, 0x48, 0xb8, 0xa8, 0x42, 0xa2, 0x69, 0x8e, 0xdd, 0xb2, 0xa9, 0xb6, 0xd9, 0x30, 0xf4, 0x12, 0xdb, 0x0f, 0x1e, 0x58, 0xc9, 0x69, 0x3b})},
127                 {10303, bc.NewHash([32]byte{0x3e, 0x94, 0x5d, 0x35, 0x70, 0x30, 0xd4, 0x3b, 0x3d, 0xe3, 0xdd, 0x80, 0x67, 0x29, 0x9a, 0x5e, 0x09, 0xf9, 0xfb, 0x2b, 0xad, 0x5f, 0x92, 0xc8, 0x69, 0xd1, 0x42, 0x39, 0x74, 0x9a, 0xd1, 0x1c})},
128         },
129 }
130
131 // SoloNetParams is the config for test-net
132 var SoloNetParams = Params{
133         Name:            "solo",
134         Bech32HRPSegwit: "sm",
135         Checkpoints:     []Checkpoint{},
136 }