Commit 83f86a48 authored by 张振华's avatar 张振华

Merge branch 'master' into guess-rpc-test

parents 893f8745 95f6063b
...@@ -136,12 +136,12 @@ returnAddr="1KcCVZLSQYRUwE5EXTsAoQs9LuJW6xwfQa" ...@@ -136,12 +136,12 @@ returnAddr="1KcCVZLSQYRUwE5EXTsAoQs9LuJW6xwfQa"
count=10000 count=10000
[store] [store]
name="mavl" name="kvmvccmavl"
driver="leveldb" driver="leveldb"
dbPath="datadir/mavltree" dbPath="datadir/mavltree"
dbCache=128 dbCache=128
# store数据库版本 # store数据库版本
storedbVersion="1.0.0" storedbVersion="2.0.0"
[store.sub.mavl] [store.sub.mavl]
enableMavlPrefix=false enableMavlPrefix=false
...@@ -154,6 +154,7 @@ enableMemTree=true ...@@ -154,6 +154,7 @@ enableMemTree=true
enableMemVal=true enableMemVal=true
[store.sub.kvmvccmavl] [store.sub.kvmvccmavl]
enableMVCCIter=true
enableMavlPrefix=false enableMavlPrefix=false
enableMVCC=false enableMVCC=false
enableMavlPrune=false enableMavlPrune=false
......
...@@ -34,7 +34,7 @@ const ( ...@@ -34,7 +34,7 @@ const (
addAct int64 = 1 //add para block action addAct int64 = 1 //add para block action
delAct int64 = 2 //reference blockstore.go, del para block action delAct int64 = 2 //reference blockstore.go, del para block action
minBlockNum = 6 //min block number startHeight before lastHeight in mainchain minBlockNum = 100 //min block number startHeight before lastHeight in mainchain
) )
var ( var (
......
...@@ -19,7 +19,7 @@ import ( ...@@ -19,7 +19,7 @@ import (
var ( var (
consensusInterval = 16 //about 1 new block interval consensusInterval = 16 //about 1 new block interval
minerInterval = 2 minerInterval = 5
) )
type commitMsgClient struct { type commitMsgClient struct {
...@@ -130,6 +130,9 @@ out: ...@@ -130,6 +130,9 @@ out:
plog.Error("para commit msg read tick", "err", err.Error()) plog.Error("para commit msg read tick", "err", err.Error())
continue continue
} }
if len(status) == 0 {
continue
}
signTx, count, err := client.calcCommitMsgTxs(status) signTx, count, err := client.calcCommitMsgTxs(status)
if err != nil || signTx == nil { if err != nil || signTx == nil {
...@@ -426,9 +429,20 @@ func (client *commitMsgClient) getNodeStatus(start, end int64) ([]*pt.ParacrossN ...@@ -426,9 +429,20 @@ func (client *commitMsgClient) getNodeStatus(start, end int64) ([]*pt.ParacrossN
nodeList[block.Block.Height].StateHash = block.Block.StateHash nodeList[block.Block.Height].StateHash = block.Block.StateHash
} }
var needSentTxs uint32
for i := 0; i < int(count); i++ { for i := 0; i < int(count); i++ {
ret = append(ret, nodeList[req.Start+int64(i)]) ret = append(ret, nodeList[req.Start+int64(i)])
needSentTxs += nodeList[req.Start+int64(i)].NonCommitTxCounts
} }
//1.如果是只有commit tx的空块,推迟发送,直到等到一个完全没有commit tx的空块或者其他tx的块
//2,如果20个块都是 commit tx的空块,20个块打包一次发送,尽量减少commit tx造成的空块
//3,如果形如xxoxx的块排列,x代表commit空块,o代表实际的块,即只要不全部是commit块,也要全部打包一起发出去
//如果=0 意味着全部是paracross commit tx,延迟发送
if needSentTxs == 0 && count < types.TxGroupMaxCount {
plog.Debug("para commitmsg getNodeStatus all self consensus commit tx,send delay", "start", start, "end", end)
return nil, nil
}
return ret, nil return ret, nil
} }
......
all:
chmod +x ./build.sh
./build.sh $(OUT) $(FLAG)
\ No newline at end of file
#!/usr/bin/env bash
strpwd=$(pwd)
strcmd=${strpwd##*dapp/}
strapp=${strcmd%/cmd*}
OUT_DIR="${1}/$strapp"
OUT_TESTDIR="${1}/dapptest/$strapp"
PARACLI="${OUT_DIR}/chain33-para-cli"
PARANAME=para
SRC_CLI=github.com/33cn/plugin/cli
go build -v -o "${PARACLI}" -ldflags "-X ${SRC_CLI}/buildflags.ParaName=user.p.${PARANAME}. -X ${SRC_CLI}/buildflags.RPCAddr=http://localhost:8901" "${SRC_CLI}"
# shellcheck disable=SC2086
cp ./build/* "${OUT_DIR}"
mkdir -p "${OUT_TESTDIR}"
cp ./build/* "${OUT_TESTDIR}"
This diff is collapsed.
all:
chmod +x ./build.sh
./build.sh $(OUT) $(FLAG)
\ No newline at end of file
#!/bin/sh
strpwd=$(pwd)
strcmd=${strpwd##*dapp/}
strapp=${strcmd%/cmd*}
OUT_DIR="${1}/$strapp"
#FLAG=$2
mkdir -p "${OUT_DIR}"
cp ./build/* "${OUT_DIR}"
OUT_TESTDIR="${1}/dapptest/$strapp"
mkdir -p "${OUT_TESTDIR}"
cp ./build/test-rpc.sh "${OUT_TESTDIR}"
This diff is collapsed.
...@@ -154,6 +154,7 @@ tokenApprs = [ ...@@ -154,6 +154,7 @@ tokenApprs = [
] ]
[exec.sub.paracross] [exec.sub.paracross]
#平行链自共识停止n个块后,超级账户可以直接参与投票
paraConsensusStopBlocks=100 paraConsensusStopBlocks=100
[pprof] [pprof]
......
...@@ -415,7 +415,7 @@ func (a *action) Commit(commit *pt.ParacrossCommitAction) (*types.Receipt, error ...@@ -415,7 +415,7 @@ func (a *action) Commit(commit *pt.ParacrossCommitAction) (*types.Receipt, error
saveTitle(a.db, calcTitleKey(commit.Status.Title), titleStatus) saveTitle(a.db, calcTitleKey(commit.Status.Title), titleStatus)
clog.Info("paracross.Commit commit done", "height", commit.Status.Height, clog.Info("paracross.Commit commit done", "height", commit.Status.Height,
"cross tx bitmap", hex.EncodeToString(commit.Status.CrossTxResult), "statusBlockHash", hex.EncodeToString(titleStatus.BlockHash)) "cross tx bitmap", string(commit.Status.CrossTxResult), "statusBlockHash", hex.EncodeToString(titleStatus.BlockHash))
//parallel chain not need to process cross commit tx here //parallel chain not need to process cross commit tx here
if types.IsPara() { if types.IsPara() {
...@@ -491,7 +491,13 @@ func getCrossTxHashs(api client.QueueProtocolAPI, commit *pt.ParacrossCommitActi ...@@ -491,7 +491,13 @@ func getCrossTxHashs(api client.QueueProtocolAPI, commit *pt.ParacrossCommitActi
//只获取跨链tx //只获取跨链tx
crossTxHashs = paraCrossHashs crossTxHashs = paraCrossHashs
crossTxResult = commit.Status.CrossTxResult rst, err := hex.DecodeString(string(commit.Status.CrossTxResult))
if err != nil {
clog.Error("getCrossTxHashs decode string", "CrossTxResult", string(commit.Status.CrossTxResult),
"commit.height", commit.Status.Height)
return nil, nil, types.ErrInvalidParam
}
crossTxResult = rst
} }
return crossTxHashs, crossTxResult, nil return crossTxHashs, crossTxResult, nil
} }
......
...@@ -7,6 +7,8 @@ package executor ...@@ -7,6 +7,8 @@ package executor
import ( import (
"bytes" "bytes"
"encoding/hex"
"github.com/33cn/chain33/common" "github.com/33cn/chain33/common"
"github.com/33cn/chain33/types" "github.com/33cn/chain33/types"
"github.com/33cn/chain33/util" "github.com/33cn/chain33/util"
...@@ -164,23 +166,44 @@ func setMinerTxResult(payload *pt.ParacrossMinerAction, txs []*types.Transaction ...@@ -164,23 +166,44 @@ func setMinerTxResult(payload *pt.ParacrossMinerAction, txs []*types.Transaction
return nil return nil
} }
func setMinerTxResultFork(payload *pt.ParacrossMinerAction, txs []*types.Transaction, receipts []*types.ReceiptData) { func setMinerTxResultFork(status *pt.ParacrossNodeStatus, txs []*types.Transaction, receipts []*types.ReceiptData) error {
isCommitTx := make(map[string]bool)
var curTxHashs [][]byte var curTxHashs [][]byte
for _, tx := range txs { for _, tx := range txs {
hash := tx.Hash() hash := tx.Hash()
curTxHashs = append(curTxHashs, hash) curTxHashs = append(curTxHashs, hash)
if types.IsMyParaExecName(string(tx.Execer)) && bytes.HasSuffix(tx.Execer, []byte(pt.ParaX)) {
var payload pt.ParacrossAction
err := types.Decode(tx.Payload, &payload)
if err != nil {
clog.Error("setMinerTxResultFork", "txHash", common.ToHex(hash))
return err
}
if payload.Ty == pt.ParacrossActionCommit {
isCommitTx[string(hash)] = true
}
}
} }
baseCrossTxHashs := FilterParaCrossTxHashes(types.GetTitle(), txs) status.TxCounts = uint32(len(curTxHashs))
//有tx且全部是user.p.x.paracross的commit tx时候设为0
status.NonCommitTxCounts = 1
if len(curTxHashs) != 0 && len(curTxHashs) == len(isCommitTx) {
status.NonCommitTxCounts = 0
}
crossTxHashs := FilterParaCrossTxHashes(types.GetTitle(), txs)
//主链自己过滤平行链tx, 对平行链执行失败的tx主链无法识别,主链和平行链需要获取相同的最初的tx map //主链自己过滤平行链tx, 对平行链执行失败的tx主链无法识别,主链和平行链需要获取相同的最初的tx map
//全部平行链tx结果 //全部平行链tx结果
payload.Status.TxResult = util.CalcBitMap(curTxHashs, curTxHashs, receipts) status.TxResult = []byte(hex.EncodeToString(util.CalcBitMap(curTxHashs, curTxHashs, receipts)))
//跨链tx结果 //跨链tx结果
payload.Status.CrossTxResult = util.CalcBitMap(baseCrossTxHashs, curTxHashs, receipts) status.CrossTxResult = []byte(hex.EncodeToString(util.CalcBitMap(crossTxHashs, curTxHashs, receipts)))
status.TxHashs = [][]byte{CalcTxHashsHash(curTxHashs)}
status.CrossTxHashs = [][]byte{CalcTxHashsHash(crossTxHashs)}
payload.Status.TxHashs = [][]byte{CalcTxHashsHash(curTxHashs)} return nil
payload.Status.CrossTxHashs = [][]byte{CalcTxHashsHash(baseCrossTxHashs)}
} }
//ExecLocal_Miner miner tx local db process //ExecLocal_Miner miner tx local db process
...@@ -196,7 +219,10 @@ func (e *Paracross) ExecLocal_Miner(payload *pt.ParacrossMinerAction, tx *types. ...@@ -196,7 +219,10 @@ func (e *Paracross) ExecLocal_Miner(payload *pt.ParacrossMinerAction, tx *types.
//removed the 0 vote tx //removed the 0 vote tx
if payload.Status.MainBlockHeight >= forkHeight { if payload.Status.MainBlockHeight >= forkHeight {
setMinerTxResultFork(payload, txs[1:], e.GetReceipt()[1:]) err := setMinerTxResultFork(payload.Status, txs[1:], e.GetReceipt()[1:])
if err != nil {
return nil, err
}
} else { } else {
err := setMinerTxResult(payload, txs[1:], e.GetReceipt()[1:]) err := setMinerTxResult(payload, txs[1:], e.GetReceipt()[1:])
if err != nil { if err != nil {
......
...@@ -620,8 +620,8 @@ func (s *VoteTestSuite) TestVoteTxFork() { ...@@ -620,8 +620,8 @@ func (s *VoteTestSuite) TestVoteTxFork() {
if bytes.Equal(key, kv.Key) { if bytes.Equal(key, kv.Key) {
var rst pt.ParacrossNodeStatus var rst pt.ParacrossNodeStatus
types.Decode(kv.GetValue(), &rst) types.Decode(kv.GetValue(), &rst)
s.Equal([]uint8([]byte{0x8e}), rst.TxResult) s.Equal([]byte("8e"), rst.TxResult)
s.Equal([]uint8([]byte{0x22}), rst.CrossTxResult) s.Equal([]byte("22"), rst.CrossTxResult)
s.Equal(1, len(rst.TxHashs)) s.Equal(1, len(rst.TxHashs))
s.Equal(1, len(rst.CrossTxHashs)) s.Equal(1, len(rst.CrossTxHashs))
......
...@@ -151,6 +151,7 @@ message ParacrossNodeStatus { ...@@ -151,6 +151,7 @@ message ParacrossNodeStatus {
repeated bytes txHashs = 11; repeated bytes txHashs = 11;
bytes crossTxResult = 12; bytes crossTxResult = 12;
repeated bytes crossTxHashs = 13; repeated bytes crossTxHashs = 13;
uint32 nonCommitTxCounts = 14;
} }
message ParacrossCommitAction { message ParacrossCommitAction {
......
This diff is collapsed.
...@@ -61,7 +61,7 @@ func DisableLog() { ...@@ -61,7 +61,7 @@ func DisableLog() {
func init() { func init() {
drivers.Reg("kvmvccmavl", New) drivers.Reg("kvmvccmavl", New)
types.RegisterDappFork("store-kvmvccmavl", "ForkKvmvccmavl", 186*10000) types.RegisterDappFork("store-kvmvccmavl", "ForkKvmvccmavl", 187*10000)
} }
// KVmMavlStore provide kvmvcc and mavl store interface implementation // KVmMavlStore provide kvmvcc and mavl store interface implementation
......
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