• R/O
  • HTTP
  • SSH
  • HTTPS

vapor: Commit

Golang implemented sidechain for Bytom


Commit MetaInfo

Revision4bd838524ac21991ed954cc0e01c5729a63931ad (tree)
Time2019-07-12 16:11:51
Authoroysheng <33340252+oysheng@user...>
CommiterPaladz

Log Message

modify config (#265)

* modify config

* modify bytom mainnet

Change Summary

Incremental Difference

--- a/blockchain/txbuilder/actions.go
+++ b/blockchain/txbuilder/actions.go
@@ -168,7 +168,7 @@ func (a *crossOutAction) Build(ctx context.Context, b *TemplateBuilder) error {
168168 return MissingFieldsError(missing...)
169169 }
170170
171- address, err := common.DecodeAddress(a.Address, &consensus.MainNetParams)
171+ address, err := common.DecodeAddress(a.Address, &consensus.BytomMainNetParams)
172172 if err != nil {
173173 return err
174174 }
--- a/blockchain/txbuilder/txbuilder_test.go
+++ b/blockchain/txbuilder/txbuilder_test.go
@@ -88,7 +88,7 @@ func TestBuildIntra(t *testing.T) {
8888 }
8989
9090 func newCrossOutAction(assetAmt bc.AssetAmount, redeemContract []byte) *crossOutAction {
91- address, err := common.NewAddressWitnessPubKeyHash(redeemContract, &consensus.MainNetParams)
91+ address, err := common.NewAddressWitnessPubKeyHash(redeemContract, &consensus.BytomMainNetParams)
9292 if err != nil {
9393 panic(err)
9494 }
--- a/common/address_test.go
+++ b/common/address_test.go
@@ -24,8 +24,8 @@ func TestAddresses(t *testing.T) {
2424 // Segwit address tests.
2525 {
2626 name: "segwit mainnet p2wpkh v0",
27- addr: "BM1QW508D6QEJXTDG4Y5R3ZARVARY0C5XW7K23GYYF",
28- encoded: "bm1qw508d6qejxtdg4y5r3zarvary0c5xw7k23gyyf",
27+ addr: "VP1QW508D6QEJXTDG4Y5R3ZARVARY0C5XW7KPSCEPL",
28+ encoded: "vp1qw508d6qejxtdg4y5r3zarvary0c5xw7kpscepl",
2929 valid: true,
3030 result: tstAddressWitnessPubKeyHash(
3131 0,
@@ -43,8 +43,8 @@ func TestAddresses(t *testing.T) {
4343 },
4444 {
4545 name: "segwit mainnet p2wsh v0",
46- addr: "bm1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3qk5egtg",
47- encoded: "bm1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3qk5egtg",
46+ addr: "vp1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3ql5u263",
47+ encoded: "vp1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3ql5u263",
4848 valid: true,
4949 result: tstAddressWitnessScriptHash(
5050 0,
@@ -66,8 +66,8 @@ func TestAddresses(t *testing.T) {
6666 },
6767 {
6868 name: "segwit testnet p2wpkh v0",
69- addr: "tm1qw508d6qejxtdg4y5r3zarvary0c5xw7kw8fqyc",
70- encoded: "tm1qw508d6qejxtdg4y5r3zarvary0c5xw7kw8fqyc",
69+ addr: "tp1qw508d6qejxtdg4y5r3zarvary0c5xw7kvj35pt",
70+ encoded: "tp1qw508d6qejxtdg4y5r3zarvary0c5xw7kvj35pt",
7171 valid: true,
7272 result: tstAddressWitnessPubKeyHash(
7373 0,
@@ -85,8 +85,8 @@ func TestAddresses(t *testing.T) {
8585 },
8686 {
8787 name: "segwit testnet p2wsh v0",
88- addr: "tm1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3qqq379v",
89- encoded: "tm1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3qqq379v",
88+ addr: "tp1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3qayxglu",
89+ encoded: "tp1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3qayxglu",
9090 valid: true,
9191 result: tstAddressWitnessScriptHash(
9292 0,
@@ -108,8 +108,8 @@ func TestAddresses(t *testing.T) {
108108 },
109109 {
110110 name: "segwit testnet p2wsh witness v0",
111- addr: "tm1qqqqqp399et2xygdj5xreqhjjvcmzhxw4aywxecjdzew6hylgvsesvkesyk",
112- encoded: "tm1qqqqqp399et2xygdj5xreqhjjvcmzhxw4aywxecjdzew6hylgvsesvkesyk",
111+ addr: "tp1qqqqqp399et2xygdj5xreqhjjvcmzhxw4aywxecjdzew6hylgvses3jwx7x",
112+ encoded: "tp1qqqqqp399et2xygdj5xreqhjjvcmzhxw4aywxecjdzew6hylgvses3jwx7x",
113113 valid: true,
114114 result: tstAddressWitnessScriptHash(
115115 0,
@@ -132,19 +132,19 @@ func TestAddresses(t *testing.T) {
132132 // Unsupported witness versions (version 0 only supported at this point)
133133 {
134134 name: "segwit mainnet witness v1",
135- addr: "bm1pw508d6qejxtdg4y5r3zarvary0c5xw7kw508d6qejxtdg4y5r3zarvary0c5xw7k7grplx",
135+ addr: "vp1pw508d6qejxtdg4y5r3zarvary0c5xw7kw508d6qejxtdg4y5r3zarvary0c5xw7k7grplx",
136136 valid: false,
137137 net: &consensus.MainNetParams,
138138 },
139139 {
140140 name: "segwit mainnet witness v16",
141- addr: "BM1SW50QA3JX3S",
141+ addr: "VP1SW50QA3JX3S",
142142 valid: false,
143143 net: &consensus.MainNetParams,
144144 },
145145 {
146146 name: "segwit mainnet witness v2",
147- addr: "bm1zw508d6qejxtdg4y5r3zarvaryvg6kdaj",
147+ addr: "vp1zw508d6qejxtdg4y5r3zarvaryvg6kdaj",
148148 valid: false,
149149 net: &consensus.MainNetParams,
150150 },
@@ -157,49 +157,49 @@ func TestAddresses(t *testing.T) {
157157 },
158158 {
159159 name: "segwit invalid checksum",
160- addr: "bm1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t5",
160+ addr: "vp1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t5",
161161 valid: false,
162162 net: &consensus.MainNetParams,
163163 },
164164 {
165165 name: "segwit invalid witness version",
166- addr: "BM13W508D6QEJXTDG4Y5R3ZARVARY0C5XW7KN40WF2",
166+ addr: "VP13W508D6QEJXTDG4Y5R3ZARVARY0C5XW7KN40WF2",
167167 valid: false,
168168 net: &consensus.MainNetParams,
169169 },
170170 {
171171 name: "segwit invalid program length",
172- addr: "bm1rw5uspcuh",
172+ addr: "vp1rw5uspcuh",
173173 valid: false,
174174 net: &consensus.MainNetParams,
175175 },
176176 {
177177 name: "segwit invalid program length",
178- addr: "bm10w508d6qejxtdg4y5r3zarvary0c5xw7kw508d6qejxtdg4y5r3zarvary0c5xw7kw5rljs90",
178+ addr: "vp10w508d6qejxtdg4y5r3zarvary0c5xw7kw508d6qejxtdg4y5r3zarvary0c5xw7kw5rljs90",
179179 valid: false,
180180 net: &consensus.MainNetParams,
181181 },
182182 {
183183 name: "segwit invalid program length for witness version 0 (per BIP141)",
184- addr: "BM1QR508D6QEJXTDG4Y5R3ZARVARYV98GJ9P",
184+ addr: "VP1QR508D6QEJXTDG4Y5R3ZARVARYV98GJ9P",
185185 valid: false,
186186 net: &consensus.MainNetParams,
187187 },
188188 {
189189 name: "segwit mixed case",
190- addr: "tm1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3q0sL5k7",
190+ addr: "tp1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3q0sL5k7",
191191 valid: false,
192192 net: &consensus.TestNetParams,
193193 },
194194 {
195195 name: "segwit zero padding of more than 4 bits",
196- addr: "tm1pw508d6qejxtdg4y5r3zarqfsj6c3",
196+ addr: "tp1pw508d6qejxtdg4y5r3zarqfsj6c3",
197197 valid: false,
198198 net: &consensus.TestNetParams,
199199 },
200200 {
201201 name: "segwit non-zero padding in 8-to-5 conversion",
202- addr: "tm1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3pjxtptv",
202+ addr: "tp1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3pjxtptv",
203203 valid: false,
204204 net: &consensus.TestNetParams,
205205 },
--- a/config/toml.go
+++ b/config/toml.go
@@ -27,23 +27,31 @@ api_addr = "0.0.0.0:9889"
2727 moniker = ""
2828 `
2929
30-var soloNetConfigTmpl = `chain_id = "solonet"
30+var mainNetConfigTmpl = `chain_id = "mainnet"
31+[p2p]
32+laddr = "tcp://0.0.0.0:56656"
33+seeds = "52.82.28.25:56656,52.82.31.195:56656,52.82.31.247:56656"
34+`
35+
36+var testNetConfigTmpl = `chain_id = "testnet"
3137 [p2p]
32-laddr = "tcp://0.0.0.0:46658"
38+laddr = "tcp://0.0.0.0:56657"
3339 seeds = ""
3440 `
3541
36-var vaporNetConfigTmpl = `chain_id = "vapor"
42+var soloNetConfigTmpl = `chain_id = "solonet"
3743 [p2p]
38-laddr = "tcp://0.0.0.0:56656"
39-seeds = "52.82.28.25:56656,52.82.31.195:56656,52.82.31.247:56656"
44+laddr = "tcp://0.0.0.0:56658"
45+seeds = ""
4046 `
4147
4248 // Select network seeds to merge a new string.
4349 func selectNetwork(network string) string {
4450 switch network {
45- case "vapor":
46- return defaultConfigTmpl + vaporNetConfigTmpl
51+ case "mainnet":
52+ return defaultConfigTmpl + mainNetConfigTmpl
53+ case "testnet":
54+ return defaultConfigTmpl + testNetConfigTmpl
4755 default:
4856 return defaultConfigTmpl + soloNetConfigTmpl
4957 }
--- a/consensus/general.go
+++ b/consensus/general.go
@@ -115,38 +115,44 @@ func VaporDPOSConfig() DPOSConfig {
115115 }
116116
117117 // ActiveNetParams is the active NetParams
118-var ActiveNetParams = VaporNetParams
118+var ActiveNetParams = MainNetParams
119119
120120 // NetParams is the correspondence between chain_id and Params
121121 var NetParams = map[string]Params{
122122 "mainnet": MainNetParams,
123- "wisdom": TestNetParams,
124- "vapor": VaporNetParams,
123+ "testnet": TestNetParams,
125124 "solonet": SoloNetParams,
126125 }
127126
128-// MainNetParams is the config for bytom main-net
127+// MainNetParams is the config for vapor-mainnet
129128 var MainNetParams = Params{
130129 Name: "main",
131- Bech32HRPSegwit: "bm",
132- DefaultPort: "46657",
133- DNSSeeds: []string{"www.mainnetseed.bytom.io"},
134- Checkpoints: []Checkpoint{},
130+ Bech32HRPSegwit: "vp",
131+ DefaultPort: "56656",
132+ DNSSeeds: []string{"www.mainnetseed.vapor.io"},
133+ BasicConfig: BasicConfig{
134+ MaxBlockGas: uint64(10000000),
135+ MaxGasAmount: int64(200000),
136+ DefaultGasCredit: int64(160000),
137+ StorageGasRate: int64(1),
138+ VMGasRate: int64(200),
139+ VotePendingBlockNumber: uint64(10000),
140+ CoinbasePendingBlockNumber: uint64(100),
141+ CoinbaseArbitrarySizeLimit: 128,
142+ },
143+ DPOSConfig: VaporDPOSConfig(),
144+ Checkpoints: []Checkpoint{},
145+ ProducerSubsidys: []ProducerSubsidy{
146+ {BeginBlock: 1, EndBlock: 63072000, Subsidy: 15000000},
147+ },
135148 }
136149
137-// TestNetParams is the config for bytom test-net
150+// TestNetParams is the config for vapor-testnet
138151 var TestNetParams = Params{
139152 Name: "test",
140- Bech32HRPSegwit: "tm",
141- DefaultPort: "46656",
142- DNSSeeds: []string{"www.testnetseed.bytom.io"},
143- Checkpoints: []Checkpoint{},
144-}
145-
146-// VaporNetParams is the config for vapor-net
147-var VaporNetParams = Params{
148- Name: "vapor",
149- Bech32HRPSegwit: "vp",
153+ Bech32HRPSegwit: "tp",
154+ DefaultPort: "56657",
155+ DNSSeeds: []string{"www.testnetseed.vapor.io"},
150156 BasicConfig: BasicConfig{
151157 MaxBlockGas: uint64(10000000),
152158 MaxGasAmount: int64(200000),
@@ -164,10 +170,11 @@ var VaporNetParams = Params{
164170 },
165171 }
166172
167-// SoloNetParams is the config for solo test-net
173+// SoloNetParams is the config for vapor solonet
168174 var SoloNetParams = Params{
169175 Name: "solo",
170- Bech32HRPSegwit: "sm",
176+ Bech32HRPSegwit: "sp",
177+ DefaultPort: "56658",
171178 BasicConfig: BasicConfig{
172179 MaxBlockGas: uint64(10000000),
173180 MaxGasAmount: int64(200000),
@@ -197,3 +204,9 @@ func BlockSubsidy(height uint64) uint64 {
197204 }
198205 return 0
199206 }
207+
208+// BytomMainNetParams is the config for bytom mainnet
209+var BytomMainNetParams = Params{
210+ Name: "main",
211+ Bech32HRPSegwit: "bm",
212+}
--- a/federation/synchron/mainchain_keeper.go
+++ b/federation/synchron/mainchain_keeper.go
@@ -224,13 +224,13 @@ func (m *mainchainKeeper) getCrossChainReqs(crossTransactionID uint64, tx *types
224224 switch {
225225 case segwit.IsP2WPKHScript(prog):
226226 if pubHash, err := segwit.GetHashFromStandardProg(prog); err == nil {
227- fromAddress = wallet.BuildP2PKHAddress(pubHash, &vaporConsensus.MainNetParams)
228- toAddress = wallet.BuildP2PKHAddress(pubHash, &vaporConsensus.VaporNetParams)
227+ fromAddress = wallet.BuildP2PKHAddress(pubHash, &vaporConsensus.BytomMainNetParams)
228+ toAddress = wallet.BuildP2PKHAddress(pubHash, &vaporConsensus.MainNetParams)
229229 }
230230 case segwit.IsP2WSHScript(prog):
231231 if scriptHash, err := segwit.GetHashFromStandardProg(prog); err == nil {
232- fromAddress = wallet.BuildP2SHAddress(scriptHash, &vaporConsensus.MainNetParams)
233- toAddress = wallet.BuildP2SHAddress(scriptHash, &vaporConsensus.VaporNetParams)
232+ fromAddress = wallet.BuildP2SHAddress(scriptHash, &vaporConsensus.BytomMainNetParams)
233+ toAddress = wallet.BuildP2SHAddress(scriptHash, &vaporConsensus.MainNetParams)
234234 }
235235 }
236236
--- a/federation/synchron/sidechain_keeper.go
+++ b/federation/synchron/sidechain_keeper.go
@@ -230,11 +230,11 @@ func (s *sidechainKeeper) getCrossChainReqs(crossTransactionID uint64, tx *types
230230 switch {
231231 case segwit.IsP2WPKHScript(inputCP):
232232 if pubHash, err := segwit.GetHashFromStandardProg(inputCP); err == nil {
233- fromAddress = wallet.BuildP2PKHAddress(pubHash, &consensus.VaporNetParams)
233+ fromAddress = wallet.BuildP2PKHAddress(pubHash, &consensus.MainNetParams)
234234 }
235235 case segwit.IsP2WSHScript(inputCP):
236236 if scriptHash, err := segwit.GetHashFromStandardProg(inputCP); err == nil {
237- fromAddress = wallet.BuildP2SHAddress(scriptHash, &consensus.VaporNetParams)
237+ fromAddress = wallet.BuildP2SHAddress(scriptHash, &consensus.MainNetParams)
238238 }
239239 }
240240
@@ -259,11 +259,11 @@ func (s *sidechainKeeper) getCrossChainReqs(crossTransactionID uint64, tx *types
259259 switch {
260260 case segwit.IsP2WPKHScript(outputCP):
261261 if pubHash, err := segwit.GetHashFromStandardProg(outputCP); err == nil {
262- toAddress = wallet.BuildP2PKHAddress(pubHash, &consensus.MainNetParams)
262+ toAddress = wallet.BuildP2PKHAddress(pubHash, &consensus.BytomMainNetParams)
263263 }
264264 case segwit.IsP2WSHScript(outputCP):
265265 if scriptHash, err := segwit.GetHashFromStandardProg(outputCP); err == nil {
266- toAddress = wallet.BuildP2SHAddress(scriptHash, &consensus.MainNetParams)
266+ toAddress = wallet.BuildP2SHAddress(scriptHash, &consensus.BytomMainNetParams)
267267 }
268268 }
269269
--- a/p2p/discover/dht/dns_seeds_test.go
+++ b/p2p/discover/dht/dns_seeds_test.go
@@ -26,39 +26,39 @@ func lookupHostErrIP(host string) ([]string, error) {
2626 return errAddr, nil
2727 }
2828
29-var testCases = []struct {
30- chainID string
31- lookupHost func(host string) (addrs []string, err error)
32- wantErr error
33- wantAddr []string
34-}{
35- {
36- chainID: "wisdom",
37- lookupHost: lookupHostNormal,
38- wantErr: nil,
39- wantAddr: []string{"1.2.3.4:46656", "5.6.7.8:46656"},
40- },
41- {
42- chainID: "mainnet",
43- lookupHost: lookupHostNormal,
44- wantErr: nil,
45- wantAddr: []string{"11.22.33.44:46657", "55.66.77.88:46657"},
46- },
47- {
48- chainID: "solonet",
49- lookupHost: lookupHostNormal,
50- wantErr: errDNSSeedsEmpty,
51- wantAddr: nil,
52- },
53- {
54- chainID: "wisdom",
55- lookupHost: lookupHostErrIP,
56- wantErr: errDNSTimeout,
57- wantAddr: nil,
58- },
59-}
60-
6129 func TestQueryDNSSeeds(t *testing.T) {
30+ testCases := []struct {
31+ chainID string
32+ lookupHost func(host string) (addrs []string, err error)
33+ wantErr error
34+ wantAddr []string
35+ }{
36+ {
37+ chainID: "testnet",
38+ lookupHost: lookupHostNormal,
39+ wantErr: nil,
40+ wantAddr: []string{"1.2.3.4:56657", "5.6.7.8:56657"},
41+ },
42+ {
43+ chainID: "mainnet",
44+ lookupHost: lookupHostNormal,
45+ wantErr: nil,
46+ wantAddr: []string{"11.22.33.44:56656", "55.66.77.88:56656"},
47+ },
48+ {
49+ chainID: "solonet",
50+ lookupHost: lookupHostNormal,
51+ wantErr: errDNSSeedsEmpty,
52+ wantAddr: nil,
53+ },
54+ {
55+ chainID: "testnet",
56+ lookupHost: lookupHostErrIP,
57+ wantErr: errDNSTimeout,
58+ wantAddr: nil,
59+ },
60+ }
61+
6262 for i, tc := range testCases {
6363 consensus.ActiveNetParams = consensus.NetParams[tc.chainID]
6464 addresses, err := QueryDNSSeeds(tc.lookupHost)
--- a/wallet/annotated.go
+++ b/wallet/annotated.go
@@ -192,7 +192,7 @@ func (w *Wallet) BuildAnnotatedInput(tx *types.Tx, i uint32) *query.AnnotatedInp
192192 func (w *Wallet) getAddressFromControlProgram(prog []byte, isMainchain bool) string {
193193 netParams := &consensus.ActiveNetParams
194194 if isMainchain {
195- netParams = &consensus.MainNetParams
195+ netParams = &consensus.BytomMainNetParams
196196 }
197197
198198 if segwit.IsP2WPKHScript(prog) {
Show on old repository browser