Unverified Commit c05c19a5 authored by 33cn's avatar 33cn Committed by GitHub

Merge pull request #664 from 33cn/release-6.3.0

Release 6.3.0
parents ff6ed7b4 06dbd798
...@@ -10,6 +10,7 @@ datadir* ...@@ -10,6 +10,7 @@ datadir*
build/chain33* build/chain33*
chain33_raft-1 chain33_raft-1
build/datadir build/datadir
build/fork-config
build/bityuan* build/bityuan*
build/para build/para
build/cli build/cli
......
...@@ -36,7 +36,8 @@ dbCache=64 ...@@ -36,7 +36,8 @@ dbCache=64
isStrongConsistency=true isStrongConsistency=true
singleMode=true singleMode=true
batchsync=false batchsync=false
isRecordBlockSequence=false #平行链钱包通过平行链区块seqence索引高度,缺省是true
isRecordBlockSequence=true
isParaChain = true isParaChain = true
enableTxQuickIndex=true enableTxQuickIndex=true
# 升级storedb是否重新执行localdb,bityuan主链升级不需要开启,平行链升级需要开启 # 升级storedb是否重新执行localdb,bityuan主链升级不需要开启,平行链升级需要开启
...@@ -99,8 +100,6 @@ startHeight=345850 ...@@ -99,8 +100,6 @@ startHeight=345850
writeBlockSeconds=2 writeBlockSeconds=2
#验证账户,验证节点需要配置自己的账户,并且钱包导入对应种子,非验证节点留空 #验证账户,验证节点需要配置自己的账户,并且钱包导入对应种子,非验证节点留空
authAccount="" authAccount=""
#云端主链节点切换后,平行链适配新主链节点block,回溯查找和自己记录的相同blockhash的深度
searchHashMatchedBlockDepth=10000
#创世地址额度 #创世地址额度
genesisAmount=100000000 genesisAmount=100000000
#主链支持平行链共识tx分叉高度,需要和主链保持严格一致,不可修改,2270000是bityuan主链对应高度, ycc或其他按实际修改 #主链支持平行链共识tx分叉高度,需要和主链保持严格一致,不可修改,2270000是bityuan主链对应高度, ycc或其他按实际修改
...@@ -140,7 +139,9 @@ enableMVCCIter=true ...@@ -140,7 +139,9 @@ enableMVCCIter=true
enableMavlPrefix=false enableMavlPrefix=false
enableMVCC=false enableMVCC=false
enableMavlPrune=false enableMavlPrune=false
pruneHeight=10000 pruneMavlHeight=10000
enableMVCCPrune=false
pruneMVCCHeight=10000
# 是否使能mavl数据载入内存 # 是否使能mavl数据载入内存
enableMemTree=true enableMemTree=true
# 是否使能mavl叶子节点数据载入内存 # 是否使能mavl叶子节点数据载入内存
......
...@@ -171,7 +171,9 @@ enableMVCCIter=true ...@@ -171,7 +171,9 @@ enableMVCCIter=true
enableMavlPrefix=false enableMavlPrefix=false
enableMVCC=false enableMVCC=false
enableMavlPrune=false enableMavlPrune=false
pruneHeight=10000 pruneMavlHeight=10000
enableMVCCPrune=false
pruneMVCCHeight=10000
# 是否使能mavl数据载入内存 # 是否使能mavl数据载入内存
enableMemTree=true enableMemTree=true
# 是否使能mavl叶子节点数据载入内存 # 是否使能mavl叶子节点数据载入内存
......
...@@ -3,7 +3,7 @@ module github.com/33cn/plugin ...@@ -3,7 +3,7 @@ module github.com/33cn/plugin
go 1.12 go 1.12
require ( require (
github.com/33cn/chain33 v0.0.0-20191011025601-06dbefe7d2e8 github.com/33cn/chain33 v0.0.0-20191017025459-6d5c61c7d134
github.com/BurntSushi/toml v0.3.1 github.com/BurntSushi/toml v0.3.1
github.com/NebulousLabs/Sia v1.3.7 github.com/NebulousLabs/Sia v1.3.7
github.com/btcsuite/btcd v0.0.0-20181013004428-67e573d211ac github.com/btcsuite/btcd v0.0.0-20181013004428-67e573d211ac
...@@ -11,15 +11,17 @@ require ( ...@@ -11,15 +11,17 @@ require (
github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d // indirect github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d // indirect
github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd // indirect github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd // indirect
github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792 // indirect github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792 // indirect
github.com/coreos/etcd v3.3.13+incompatible github.com/coreos/etcd v3.3.15+incompatible
github.com/coreos/go-semver v0.3.0 // indirect github.com/coreos/go-semver v0.3.0 // indirect
github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f // indirect github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f // indirect
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f // indirect github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f // indirect
github.com/davecgh/go-spew v1.1.1 github.com/davecgh/go-spew v1.1.1
github.com/gogo/protobuf v1.2.1 github.com/gogo/protobuf v1.3.0
github.com/golang-collections/collections v0.0.0-20130729185459-604e922904d3 github.com/golang-collections/collections v0.0.0-20130729185459-604e922904d3
github.com/golang/protobuf v1.3.2 github.com/golang/protobuf v1.3.2
github.com/hashicorp/golang-lru v0.5.0 github.com/hashicorp/golang-lru v0.5.0
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.1 // indirect
github.com/pkg/errors v0.8.0 github.com/pkg/errors v0.8.0
github.com/prometheus/client_golang v1.1.0 // indirect github.com/prometheus/client_golang v1.1.0 // indirect
github.com/robertkrimen/otto v0.0.0-20180617131154-15f95af6e78d github.com/robertkrimen/otto v0.0.0-20180617131154-15f95af6e78d
...@@ -27,11 +29,14 @@ require ( ...@@ -27,11 +29,14 @@ require (
github.com/spf13/cobra v0.0.3 github.com/spf13/cobra v0.0.3
github.com/stretchr/testify v1.3.0 github.com/stretchr/testify v1.3.0
github.com/tjfoc/gmsm v0.0.0-20171124023159-98aa888b79d8 github.com/tjfoc/gmsm v0.0.0-20171124023159-98aa888b79d8
github.com/valyala/fasthttp v1.4.0 github.com/valyala/fasthttp v1.5.0
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2 // indirect github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2 // indirect
go.uber.org/atomic v1.4.0 // indirect
go.uber.org/multierr v1.2.0 // indirect
go.uber.org/zap v1.10.0 // indirect
golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4 golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4
golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7 golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4 // indirect golang.org/x/time v0.0.0-20190921001708-c4c64cad1fd0 // indirect
google.golang.org/grpc v1.22.1 google.golang.org/grpc v1.22.1
gopkg.in/sourcemap.v1 v1.0.5 // indirect gopkg.in/sourcemap.v1 v1.0.5 // indirect
) )
This diff is collapsed.
...@@ -40,7 +40,6 @@ const ( ...@@ -40,7 +40,6 @@ const (
defaultSearchMatchedBlockDepth int32 = 10000 defaultSearchMatchedBlockDepth int32 = 10000
defaultMainBlockHashForkHeight int64 = 209186 //calc block hash fork height in main chain defaultMainBlockHashForkHeight int64 = 209186 //calc block hash fork height in main chain
mainParaSelfConsensusForkHeight int64 = types.MaxHeight //para chain self consensus height switch, must >= ForkParacrossCommitTx of main mainParaSelfConsensusForkHeight int64 = types.MaxHeight //para chain self consensus height switch, must >= ForkParacrossCommitTx of main
mainForkParacrossCommitTx int64 = types.MaxHeight //support paracross commit tx fork height in main chain: ForkParacrossCommitTx
) )
var ( var (
...@@ -78,18 +77,17 @@ type subConfig struct { ...@@ -78,18 +77,17 @@ type subConfig struct {
WriteBlockSeconds int64 `json:"writeBlockSeconds,omitempty"` WriteBlockSeconds int64 `json:"writeBlockSeconds,omitempty"`
ParaRemoteGrpcClient string `json:"paraRemoteGrpcClient,omitempty"` ParaRemoteGrpcClient string `json:"paraRemoteGrpcClient,omitempty"`
StartHeight int64 `json:"startHeight,omitempty"` StartHeight int64 `json:"startHeight,omitempty"`
GenesisStartHeightSame bool `json:"genesisStartHeightSame,omitempty"`
EmptyBlockInterval []*emptyBlockInterval `json:"emptyBlockInterval,omitempty"` EmptyBlockInterval []*emptyBlockInterval `json:"emptyBlockInterval,omitempty"`
AuthAccount string `json:"authAccount,omitempty"` AuthAccount string `json:"authAccount,omitempty"`
WaitBlocks4CommitMsg int32 `json:"waitBlocks4CommitMsg,omitempty"` WaitBlocks4CommitMsg int32 `json:"waitBlocks4CommitMsg,omitempty"`
SearchHashMatchedBlockDepth int32 `json:"searchHashMatchedBlockDepth,omitempty"`
GenesisAmount int64 `json:"genesisAmount,omitempty"` GenesisAmount int64 `json:"genesisAmount,omitempty"`
MainBlockHashForkHeight int64 `json:"mainBlockHashForkHeight,omitempty"` MainBlockHashForkHeight int64 `json:"mainBlockHashForkHeight,omitempty"`
MainParaSelfConsensusForkHeight int64 `json:"mainParaSelfConsensusForkHeight,omitempty"` MainParaSelfConsensusForkHeight int64 `json:"mainParaSelfConsensusForkHeight,omitempty"`
MainForkParacrossCommitTx int64 `json:"mainForkParacrossCommitTx,omitempty"`
WaitConsensStopTimes uint32 `json:"waitConsensStopTimes,omitempty"` WaitConsensStopTimes uint32 `json:"waitConsensStopTimes,omitempty"`
MaxCacheCount int64 `json:"maxCacheCount,omitempty"` MaxCacheCount int64 `json:"maxCacheCount,omitempty"`
MaxSyncErrCount int32 `json:"maxSyncErrCount,omitempty"` MaxSyncErrCount int32 `json:"maxSyncErrCount,omitempty"`
FetchFilterParaTxsEnable bool `json:"fetchFilterParaTxsEnable,omitempty"` FetchFilterParaTxsClose bool `json:"fetchFilterParaTxsClose,omitempty"`
BatchFetchBlockCount int64 `json:"batchFetchBlockCount,omitempty"` BatchFetchBlockCount int64 `json:"batchFetchBlockCount,omitempty"`
ParaConsensStartHeight int64 `json:"paraConsensStartHeight,omitempty"` ParaConsensStartHeight int64 `json:"paraConsensStartHeight,omitempty"`
MultiDownloadOpen bool `json:"multiDownloadOpen,omitempty"` MultiDownloadOpen bool `json:"multiDownloadOpen,omitempty"`
...@@ -121,9 +119,6 @@ func New(cfg *types.Consensus, sub []byte) queue.Module { ...@@ -121,9 +119,6 @@ func New(cfg *types.Consensus, sub []byte) queue.Module {
panic("para EmptyBlockInterval config not correct") panic("para EmptyBlockInterval config not correct")
} }
if subcfg.SearchHashMatchedBlockDepth <= 0 {
subcfg.SearchHashMatchedBlockDepth = defaultSearchMatchedBlockDepth
}
if subcfg.MainBlockHashForkHeight <= 0 { if subcfg.MainBlockHashForkHeight <= 0 {
subcfg.MainBlockHashForkHeight = defaultMainBlockHashForkHeight subcfg.MainBlockHashForkHeight = defaultMainBlockHashForkHeight
} }
...@@ -132,10 +127,6 @@ func New(cfg *types.Consensus, sub []byte) queue.Module { ...@@ -132,10 +127,6 @@ func New(cfg *types.Consensus, sub []byte) queue.Module {
subcfg.MainParaSelfConsensusForkHeight = mainParaSelfConsensusForkHeight subcfg.MainParaSelfConsensusForkHeight = mainParaSelfConsensusForkHeight
} }
if subcfg.MainForkParacrossCommitTx <= 0 {
subcfg.MainForkParacrossCommitTx = mainForkParacrossCommitTx
}
if subcfg.BatchFetchBlockCount <= 0 { if subcfg.BatchFetchBlockCount <= 0 {
subcfg.BatchFetchBlockCount = types.MaxBlockCountPerTime subcfg.BatchFetchBlockCount = types.MaxBlockCountPerTime
} }
...@@ -304,7 +295,12 @@ func (client *client) InitBlock() { ...@@ -304,7 +295,12 @@ func (client *client) InitBlock() {
newblock.BlockTime = genesisBlockTime newblock.BlockTime = genesisBlockTime
newblock.ParentHash = zeroHash[:] newblock.ParentHash = zeroHash[:]
newblock.MainHash = mainHash newblock.MainHash = mainHash
//缺省是减1,但有些特殊项目方6.2.0版本升级上来要求blockhash不变,则需与6.2.0保持一致,不减一
newblock.MainHeight = client.subCfg.StartHeight - 1 newblock.MainHeight = client.subCfg.StartHeight - 1
if client.subCfg.GenesisStartHeightSame {
newblock.MainHeight = client.subCfg.StartHeight
}
tx := client.CreateGenesisTx() tx := client.CreateGenesisTx()
newblock.Txs = tx newblock.Txs = tx
newblock.TxHash = merkle.CalcMerkleRoot(newblock.Txs) newblock.TxHash = merkle.CalcMerkleRoot(newblock.Txs)
...@@ -322,7 +318,6 @@ func (client *client) InitBlock() { ...@@ -322,7 +318,6 @@ func (client *client) InitBlock() {
} }
plog.Debug("para consensus init parameter", "mainBlockHashForkHeight", client.subCfg.MainBlockHashForkHeight) plog.Debug("para consensus init parameter", "mainBlockHashForkHeight", client.subCfg.MainBlockHashForkHeight)
plog.Debug("para consensus init parameter", "mainParaSelfConsensusForkHeight", client.subCfg.MainParaSelfConsensusForkHeight)
} }
......
...@@ -213,7 +213,7 @@ func (client *client) getMatchedBlockOnChain(startHeight int64) (int64, *types.B ...@@ -213,7 +213,7 @@ func (client *client) getMatchedBlockOnChain(startHeight int64) (int64, *types.B
startHeight = lastBlock.Height startHeight = lastBlock.Height
} }
depth := client.subCfg.SearchHashMatchedBlockDepth depth := defaultSearchMatchedBlockDepth
for height := startHeight; height > 0 && depth > 0; height-- { for height := startHeight; height > 0 && depth > 0; height-- {
block, err := client.GetBlockByHeight(height) block, err := client.GetBlockByHeight(height)
if err != nil { if err != nil {
...@@ -228,7 +228,7 @@ func (client *client) getMatchedBlockOnChain(startHeight int64) (int64, *types.B ...@@ -228,7 +228,7 @@ func (client *client) getMatchedBlockOnChain(startHeight int64) (int64, *types.B
if depth == 0 { if depth == 0 {
plog.Error("switchHashMatchedBlock depth overflow", "last info:mainHeight", block.MainHeight, plog.Error("switchHashMatchedBlock depth overflow", "last info:mainHeight", block.MainHeight,
"mainHash", hex.EncodeToString(block.MainHash), "search startHeight", lastBlock.Height, "curHeight", height, "mainHash", hex.EncodeToString(block.MainHash), "search startHeight", lastBlock.Height, "curHeight", height,
"search depth", client.subCfg.SearchHashMatchedBlockDepth) "search depth", defaultSearchMatchedBlockDepth)
panic("search HashMatchedBlock overflow, re-setting search depth and restart to try") panic("search HashMatchedBlock overflow, re-setting search depth and restart to try")
} }
if height == 1 { if height == 1 {
...@@ -318,7 +318,7 @@ func (client *client) getBatchSeqCount(currSeq int64) (int64, error) { ...@@ -318,7 +318,7 @@ func (client *client) getBatchSeqCount(currSeq int64) (int64, error) {
} else { } else {
atomic.StoreInt32(&client.caughtUp, 1) atomic.StoreInt32(&client.caughtUp, 1)
} }
if client.subCfg.FetchFilterParaTxsEnable && lastSeq-currSeq > client.subCfg.BatchFetchBlockCount { if !client.subCfg.FetchFilterParaTxsClose && lastSeq-currSeq > client.subCfg.BatchFetchBlockCount {
return client.subCfg.BatchFetchBlockCount - 1, nil return client.subCfg.BatchFetchBlockCount - 1, nil
} }
return 0, nil return 0, nil
...@@ -432,7 +432,7 @@ func (client *client) requestFilterParaTxs(currSeq int64, count int64, preMainBl ...@@ -432,7 +432,7 @@ func (client *client) requestFilterParaTxs(currSeq int64, count int64, preMainBl
} }
func (client *client) RequestTx(currSeq int64, count int64, preMainBlockHash []byte) (*types.ParaTxDetails, error) { func (client *client) RequestTx(currSeq int64, count int64, preMainBlockHash []byte) (*types.ParaTxDetails, error) {
if client.subCfg.FetchFilterParaTxsEnable { if !client.subCfg.FetchFilterParaTxsClose {
return client.requestFilterParaTxs(currSeq, count, preMainBlockHash) return client.requestFilterParaTxs(currSeq, count, preMainBlockHash)
} }
......
...@@ -155,6 +155,7 @@ func (m *multiDldClient) getConns(inv *inventory) error { ...@@ -155,6 +155,7 @@ func (m *multiDldClient) getConns(inv *inventory) error {
return nil return nil
} }
//缺省不打开,因为有些节点下载时间不稳定,容易超时出错,后面看怎么优化
func (m *multiDldClient) tryMultiServerDownload() { func (m *multiDldClient) tryMultiServerDownload() {
if !m.paraClient.subCfg.MultiDownloadOpen { if !m.paraClient.subCfg.MultiDownloadOpen {
return return
......
...@@ -84,6 +84,8 @@ func serveHTTPRaftAPI(ctx context.Context, port int, confChangeC chan<- raftpb.C ...@@ -84,6 +84,8 @@ func serveHTTPRaftAPI(ctx context.Context, port int, confChangeC chan<- raftpb.C
srv.Close() srv.Close()
case err := <-errorC: case err := <-errorC:
srv.Close() srv.Close()
rlog.Error(fmt.Sprintf("the errorC chan receive a err (%v)\n", err.Error())) if err != nil {
rlog.Error(fmt.Sprintf("the errorC chan receive a err (%v)\n", err.Error()))
}
} }
} }
...@@ -8,7 +8,6 @@ import ( ...@@ -8,7 +8,6 @@ import (
"github.com/33cn/chain33/pluginmgr" "github.com/33cn/chain33/pluginmgr"
"github.com/33cn/plugin/plugin/dapp/autonomy/commands" "github.com/33cn/plugin/plugin/dapp/autonomy/commands"
"github.com/33cn/plugin/plugin/dapp/autonomy/executor" "github.com/33cn/plugin/plugin/dapp/autonomy/executor"
"github.com/33cn/plugin/plugin/dapp/autonomy/rpc"
"github.com/33cn/plugin/plugin/dapp/autonomy/types" "github.com/33cn/plugin/plugin/dapp/autonomy/types"
) )
...@@ -18,6 +17,5 @@ func init() { ...@@ -18,6 +17,5 @@ func init() {
ExecName: executor.GetName(), ExecName: executor.GetName(),
Exec: executor.Init, Exec: executor.Init,
Cmd: commands.AutonomyCmd, Cmd: commands.AutonomyCmd,
RPC: rpc.Init,
}) })
} }
// Copyright Fuzamei Corp. 2018 All Rights Reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package rpc
import (
"github.com/33cn/chain33/rpc/types"
)
// Jrpc json rpc struct
type Jrpc struct {
cli *channelClient
}
// Grpc grpc struct
type Grpc struct {
*channelClient
}
type channelClient struct {
types.ChannelClient
}
// Init init grpc param
func Init(name string, s types.RPCServer) {
cli := &channelClient{}
grpc := &Grpc{channelClient: cli}
cli.Init(name, s, &Jrpc{cli: cli}, grpc)
}
...@@ -47,7 +47,7 @@ func checkReceiptExecOk(receipt *types.ReceiptData) bool { ...@@ -47,7 +47,7 @@ func checkReceiptExecOk(receipt *types.ReceiptData) bool {
// 1, 主链+平行链 user.p.xx.paracross 交易组 混合跨链资产转移 paracross主链执行成功 // 1, 主链+平行链 user.p.xx.paracross 交易组 混合跨链资产转移 paracross主链执行成功
// 2, 平行链 user.p.xx.paracross + user.p.xx.other 混合平行链组合 paracross主链执行成功 // 2, 平行链 user.p.xx.paracross + user.p.xx.other 混合平行链组合 paracross主链执行成功
// 3, 平行链 user.p.xx.other 交易组 混合平行链组合 other主链pack // 3, 平行链 user.p.xx.other 交易组 混合平行链组合 other主链pack
func filterParaTxGroup(tx *types.Transaction, allTxs []*types.TxDetail, index int, blockHeight, forkHeight int64) ([]*types.Transaction, int) { func filterParaTxGroup(tx *types.Transaction, allTxs []*types.TxDetail, index int, mainBlockHeight, forkHeight int64) ([]*types.Transaction, int) {
var headIdx int var headIdx int
for i := index; i >= 0; i-- { for i := index; i >= 0; i-- {
...@@ -59,7 +59,8 @@ func filterParaTxGroup(tx *types.Transaction, allTxs []*types.TxDetail, index in ...@@ -59,7 +59,8 @@ func filterParaTxGroup(tx *types.Transaction, allTxs []*types.TxDetail, index in
endIdx := headIdx + int(tx.GroupCount) endIdx := headIdx + int(tx.GroupCount)
for i := headIdx; i < endIdx; i++ { for i := headIdx; i < endIdx; i++ {
if types.IsPara() && blockHeight < forkHeight { //缺省是在forkHeight之前与更老版本一致,不检查平行链交易,但有些特殊平行链6.2.0版本升级上来无更老版本且要求blockhash不变,则需与6.2.0保持一致,不检查
if types.IsPara() && mainBlockHeight < forkHeight && !types.Conf("config.consensus.sub.para").IsEnable("FilterIgnoreParaTxGroup") {
if types.IsParaExecName(string(allTxs[i].Tx.Execer)) { if types.IsParaExecName(string(allTxs[i].Tx.Execer)) {
continue continue
} }
......
// Copyright Fuzamei Corp. 2018 All Rights Reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package rpc_test
import (
"strings"
"testing"
"github.com/33cn/chain33/rpc/jsonclient"
rpctypes "github.com/33cn/chain33/rpc/types"
_ "github.com/33cn/chain33/system"
"github.com/33cn/chain33/types"
"github.com/33cn/chain33/util/testnode"
_ "github.com/33cn/plugin/plugin"
"github.com/stretchr/testify/assert"
)
var mocker *testnode.Chain33Mock
func TestMain(m *testing.M) {
cfg, sub := testnode.GetDefaultConfig()
cfg.Consensus.Name = "ticket"
mocker = testnode.NewWithConfig(cfg, sub, nil)
mocker.Listen()
m.Run()
mocker.Close()
}
func TestJRPCChannel(t *testing.T) {
jrpcClient := mocker.GetJSONC()
testCases := []struct {
fn func(*testing.T, *jsonclient.JSONClient) error
}{
{fn: testCountTicketCmd},
{fn: testCloseTicketCmd},
{fn: testGetColdAddrByMinerCmd},
}
for index, testCase := range testCases {
err := testCase.fn(t, jrpcClient)
if err == nil {
continue
}
assert.NotEqualf(t, err, types.ErrActionNotSupport, "test index %d", index)
if strings.Contains(err.Error(), "rpc: can't find") {
assert.FailNowf(t, err.Error(), "test index %d", index)
}
t.Log(err.Error())
}
}
func testCountTicketCmd(t *testing.T, jrpc *jsonclient.JSONClient) error {
var res int64
return jrpc.Call("ticket.GetTicketCount", nil, &res)
}
func testCloseTicketCmd(t *testing.T, jrpc *jsonclient.JSONClient) error {
var res types.ReplyHashes
return jrpc.Call("ticket.CloseTickets", nil, &res)
}
func testGetColdAddrByMinerCmd(t *testing.T, jrpc *jsonclient.JSONClient) error {
var rep interface{}
var params rpctypes.Query4Jrpc
req := &types.ReqString{}
params.Execer = "ticket"
params.FuncName = "MinerSourceList"
params.Payload = types.MustPBToJSON(req)
rep = &types.ReplyStrings{}
return jrpc.Call("Chain33.Query", params, rep)
}
...@@ -42,6 +42,10 @@ func (g *channelClient) CreateBindMiner(ctx context.Context, in *ty.ReqBindMiner ...@@ -42,6 +42,10 @@ func (g *channelClient) CreateBindMiner(ctx context.Context, in *ty.ReqBindMiner
if err != nil { if err != nil {
return nil, err return nil, err
} }
price := ty.GetTicketMinerParam(header.Height).TicketPrice
if price == 0 {
return nil, types.ErrInvalidParam
}
if in.Amount%ty.GetTicketMinerParam(header.Height).TicketPrice != 0 || in.Amount < 0 { if in.Amount%ty.GetTicketMinerParam(header.Height).TicketPrice != 0 || in.Amount < 0 {
return nil, types.ErrAmount return nil, types.ErrAmount
} }
......
// Copyright Fuzamei Corp. 2018 All Rights Reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package rpc_test package rpc_test
//only load all plugin and system
import ( import (
"testing"
rpctypes "github.com/33cn/chain33/rpc/types"
_ "github.com/33cn/chain33/system" _ "github.com/33cn/chain33/system"
_ "github.com/33cn/plugin/plugin" _ "github.com/33cn/plugin/plugin"
ty "github.com/33cn/plugin/plugin/dapp/ticket/types"
"github.com/stretchr/testify/assert"
) )
func TestNewTicket(t *testing.T) {
//选票(可以用hotwallet 关闭选票)
in := &ty.TicketClose{MinerAddress: mocker.GetHotAddress()}
var res rpctypes.ReplyHashes
err := mocker.GetJSONC().Call("ticket.CloseTickets", in, &res)
assert.Nil(t, err)
}
...@@ -23,88 +23,6 @@ import ( ...@@ -23,88 +23,6 @@ import (
"google.golang.org/grpc" "google.golang.org/grpc"
) )
var cfgstring = `
Title="test"
[mempool]
poolCacheSize=102400
minTxFee=100000
maxTxNumPerAccount=100
[exec]
isFree=false
minExecFee=100000
enableStat=false
enableMVCC=false
[wallet]
minFee=100000
driver="leveldb"
dbPath="wallet"
dbCache=16
signType="secp256k1"
minerdisable=false
minerwhitelist=["*"]
[mver.consensus]
fundKeyAddr = "1BQXS6TxaYYG5mADaWij4AxhZZUTpw95a5"
powLimitBits = "0x1f00ffff"
maxTxNumber = 10000
[mver.consensus.ticket]
coinReward = 18
coinDevFund = 12
ticketPrice = 10000
retargetAdjustmentFactor = 4
futureBlockTime = 16
ticketFrozenTime = 5
ticketWithdrawTime = 10
ticketMinerWaitTime = 2
targetTimespan = 2304
targetTimePerBlock = 16
[mver.consensus.ticket.ForkChainParamV1]
ticketPrice = 3000
[mver.consensus.ticket.ForkChainParamV2]
ticketPrice = 6000
[fork.system]
ForkChainParamV1= 10
ForkChainParamV2= 20
ForkStateDBSet=-1
ForkCheckTxDup=0
ForkBlockHash= 1
ForkMinerTime= 10
ForkTransferExec= 100000
ForkExecKey= 200000
ForkTxGroup= 200000
ForkResetTx0= 200000
ForkWithdraw= 200000
ForkExecRollback= 450000
ForkTxHeight= -1
ForkTxGroupPara= -1
ForkCheckBlockTime=1200000
ForkMultiSignAddress=1298600
ForkBlockCheck=1
ForkLocalDBAccess=0
ForkBase58AddressCheck=1800000
ForkEnableParaRegExec=0
ForkCacheDriver=0
ForkTicketFundAddrV1=-1
[fork.sub.coins]
Enable=0
[fork.sub.manage]
Enable=0
ForkManageExec=100000
[fork.sub.store-kvmvccmavl]
ForkKvmvccmavl=1
`
func newGrpc(api client.QueueProtocolAPI) *channelClient { func newGrpc(api client.QueueProtocolAPI) *channelClient {
return &channelClient{ return &channelClient{
ChannelClient: rpctypes.ChannelClient{QueueProtocolAPI: api}, ChannelClient: rpctypes.ChannelClient{QueueProtocolAPI: api},
...@@ -128,30 +46,16 @@ func TestChannelClient_BindMiner(t *testing.T) { ...@@ -128,30 +46,16 @@ func TestChannelClient_BindMiner(t *testing.T) {
storevalue.Values = append(storevalue.Values, accv) storevalue.Values = append(storevalue.Values, accv)
api.On("StoreGet", mock.Anything).Return(storevalue, nil).Twice() api.On("StoreGet", mock.Anything).Return(storevalue, nil).Twice()
types.SetTitleOnlyForTest("test")
cfg, _ := types.InitCfgString(cfgstring)
types.Init("test", cfg)
//var addrs = make([]string, 1) //var addrs = make([]string, 1)
//addrs = append(addrs, "1Jn2qu84Z1SUUosWjySggBS9pKWdAP3tZt") //addrs = append(addrs, "1Jn2qu84Z1SUUosWjySggBS9pKWdAP3tZt")
var in = &ty.ReqBindMiner{ var in = &ty.ReqBindMiner{
BindAddr: "1Jn2qu84Z1SUUosWjySggBS9pKWdAP3tZt", BindAddr: "1Jn2qu84Z1SUUosWjySggBS9pKWdAP3tZt",
OriginAddr: "1Jn2qu84Z1SUUosWjySggBS9pKWdAP3tZt", OriginAddr: "1Jn2qu84Z1SUUosWjySggBS9pKWdAP3tZt",
Amount: 10000 * types.Coin, Amount: 10000 * types.Coin,
CheckBalance: true, CheckBalance: false,
} }
_, err := client.CreateBindMiner(context.Background(), in) _, err := client.CreateBindMiner(context.Background(), in)
assert.Nil(t, err) assert.Nil(t, err)
in.Amount = 200000 * types.Coin
_, err = client.CreateBindMiner(context.Background(), in)
assert.Equal(t, types.ErrNoBalance, err)
head.Height = 20 //ForkChainParamV2
api.On("GetLastHeader").Return(head, nil).Times(2)
_, err = client.CreateBindMiner(context.Background(), in)
assert.Equal(t, types.ErrAmount, err)
} }
func testGetTicketCountOK(t *testing.T) { func testGetTicketCountOK(t *testing.T) {
......
...@@ -74,7 +74,7 @@ type KVmMavlStore struct { ...@@ -74,7 +74,7 @@ type KVmMavlStore struct {
type subKVMVCCConfig struct { type subKVMVCCConfig struct {
EnableMVCCIter bool `json:"enableMVCCIter"` EnableMVCCIter bool `json:"enableMVCCIter"`
EnableMavlPrune bool `json:"enableMavlPrune"` EnableMVCCPrune bool `json:"enableMVCCPrune"`
PruneHeight int32 `json:"pruneHeight"` PruneHeight int32 `json:"pruneHeight"`
} }
...@@ -96,7 +96,9 @@ type subConfig struct { ...@@ -96,7 +96,9 @@ type subConfig struct {
EnableMavlPrefix bool `json:"enableMavlPrefix"` EnableMavlPrefix bool `json:"enableMavlPrefix"`
EnableMVCC bool `json:"enableMVCC"` EnableMVCC bool `json:"enableMVCC"`
EnableMavlPrune bool `json:"enableMavlPrune"` EnableMavlPrune bool `json:"enableMavlPrune"`
PruneHeight int32 `json:"pruneHeight"` PruneMavlHeight int32 `json:"pruneMavlHeight"`
EnableMVCCPrune bool `json:"enableMVCCPrune"`
PruneMVCCHeight int32 `json:"pruneMVCCHeight"`
// 是否使能内存树 // 是否使能内存树
EnableMemTree bool `json:"enableMemTree"` EnableMemTree bool `json:"enableMemTree"`
// 是否使能内存树中叶子节点 // 是否使能内存树中叶子节点
...@@ -114,13 +116,13 @@ func New(cfg *types.Store, sub []byte) queue.Module { ...@@ -114,13 +116,13 @@ func New(cfg *types.Store, sub []byte) queue.Module {
if sub != nil { if sub != nil {
types.MustDecode(sub, &subcfg) types.MustDecode(sub, &subcfg)
subKVMVCCcfg.EnableMVCCIter = subcfg.EnableMVCCIter subKVMVCCcfg.EnableMVCCIter = subcfg.EnableMVCCIter
subKVMVCCcfg.EnableMavlPrune = subcfg.EnableMavlPrune subKVMVCCcfg.EnableMVCCPrune = subcfg.EnableMVCCPrune
subKVMVCCcfg.PruneHeight = subcfg.PruneHeight subKVMVCCcfg.PruneHeight = subcfg.PruneMVCCHeight
subMavlcfg.EnableMavlPrefix = subcfg.EnableMavlPrefix subMavlcfg.EnableMavlPrefix = subcfg.EnableMavlPrefix
subMavlcfg.EnableMVCC = subcfg.EnableMVCC subMavlcfg.EnableMVCC = subcfg.EnableMVCC
subMavlcfg.EnableMavlPrune = subcfg.EnableMavlPrune subMavlcfg.EnableMavlPrune = subcfg.EnableMavlPrune
subMavlcfg.PruneHeight = subcfg.PruneHeight subMavlcfg.PruneHeight = subcfg.PruneMavlHeight
subMavlcfg.EnableMemTree = subcfg.EnableMemTree subMavlcfg.EnableMemTree = subcfg.EnableMemTree
subMavlcfg.EnableMemVal = subcfg.EnableMemVal subMavlcfg.EnableMemVal = subcfg.EnableMemVal
subMavlcfg.TkCloseCacheLen = subcfg.TkCloseCacheLen subMavlcfg.TkCloseCacheLen = subcfg.TkCloseCacheLen
......
...@@ -52,7 +52,7 @@ type KVMVCCStore struct { ...@@ -52,7 +52,7 @@ type KVMVCCStore struct {
mvcc dbm.MVCC mvcc dbm.MVCC
kvsetmap map[string][]*types.KeyValue kvsetmap map[string][]*types.KeyValue
enableMVCCIter bool enableMVCCIter bool
enableMavlPrune bool enableMVCCPrune bool
pruneHeight int32 pruneHeight int32
sync bool sync bool
} }
...@@ -66,12 +66,12 @@ func NewKVMVCC(sub *subKVMVCCConfig, db dbm.DB) *KVMVCCStore { ...@@ -66,12 +66,12 @@ func NewKVMVCC(sub *subKVMVCCConfig, db dbm.DB) *KVMVCCStore {
} }
if enable { if enable {
kvs = &KVMVCCStore{db, dbm.NewMVCCIter(db), make(map[string][]*types.KeyValue), kvs = &KVMVCCStore{db, dbm.NewMVCCIter(db), make(map[string][]*types.KeyValue),
true, sub.EnableMavlPrune, sub.PruneHeight, false} true, sub.EnableMVCCPrune, sub.PruneHeight, false}
} else { } else {
kvs = &KVMVCCStore{db, dbm.NewMVCC(db), make(map[string][]*types.KeyValue), kvs = &KVMVCCStore{db, dbm.NewMVCC(db), make(map[string][]*types.KeyValue),
false, sub.EnableMavlPrune, sub.PruneHeight, false} false, sub.EnableMVCCPrune, sub.PruneHeight, false}
} }
EnablePrune(sub.EnableMavlPrune) EnablePrune(sub.EnableMVCCPrune)
SetPruneHeight(int(sub.PruneHeight)) SetPruneHeight(int(sub.PruneHeight))
return kvs return kvs
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment