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

Merge branch 'master' into guess-rpc-test

parents 893f8745 95f6063b
......@@ -136,12 +136,12 @@ returnAddr="1KcCVZLSQYRUwE5EXTsAoQs9LuJW6xwfQa"
count=10000
[store]
name="mavl"
name="kvmvccmavl"
driver="leveldb"
dbPath="datadir/mavltree"
dbCache=128
# store数据库版本
storedbVersion="1.0.0"
storedbVersion="2.0.0"
[store.sub.mavl]
enableMavlPrefix=false
......@@ -154,6 +154,7 @@ enableMemTree=true
enableMemVal=true
[store.sub.kvmvccmavl]
enableMVCCIter=true
enableMavlPrefix=false
enableMVCC=false
enableMavlPrune=false
......
......@@ -34,7 +34,7 @@ const (
addAct int64 = 1 //add 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 (
......
......@@ -19,7 +19,7 @@ import (
var (
consensusInterval = 16 //about 1 new block interval
minerInterval = 2
minerInterval = 5
)
type commitMsgClient struct {
......@@ -130,6 +130,9 @@ out:
plog.Error("para commit msg read tick", "err", err.Error())
continue
}
if len(status) == 0 {
continue
}
signTx, count, err := client.calcCommitMsgTxs(status)
if err != nil || signTx == nil {
......@@ -426,9 +429,20 @@ func (client *commitMsgClient) getNodeStatus(start, end int64) ([]*pt.ParacrossN
nodeList[block.Block.Height].StateHash = block.Block.StateHash
}
var needSentTxs uint32
for i := 0; i < int(count); 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
}
......
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 = [
]
[exec.sub.paracross]
#平行链自共识停止n个块后,超级账户可以直接参与投票
paraConsensusStopBlocks=100
[pprof]
......
......@@ -415,7 +415,7 @@ func (a *action) Commit(commit *pt.ParacrossCommitAction) (*types.Receipt, error
saveTitle(a.db, calcTitleKey(commit.Status.Title), titleStatus)
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
if types.IsPara() {
......@@ -491,7 +491,13 @@ func getCrossTxHashs(api client.QueueProtocolAPI, commit *pt.ParacrossCommitActi
//只获取跨链tx
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
}
......
......@@ -7,6 +7,8 @@ package executor
import (
"bytes"
"encoding/hex"
"github.com/33cn/chain33/common"
"github.com/33cn/chain33/types"
"github.com/33cn/chain33/util"
......@@ -164,23 +166,44 @@ func setMinerTxResult(payload *pt.ParacrossMinerAction, txs []*types.Transaction
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
for _, tx := range txs {
hash := tx.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结果
payload.Status.TxResult = util.CalcBitMap(curTxHashs, curTxHashs, receipts)
status.TxResult = []byte(hex.EncodeToString(util.CalcBitMap(curTxHashs, curTxHashs, receipts)))
//跨链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)}
payload.Status.CrossTxHashs = [][]byte{CalcTxHashsHash(baseCrossTxHashs)}
return nil
}
//ExecLocal_Miner miner tx local db process
......@@ -196,7 +219,10 @@ func (e *Paracross) ExecLocal_Miner(payload *pt.ParacrossMinerAction, tx *types.
//removed the 0 vote tx
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 {
err := setMinerTxResult(payload, txs[1:], e.GetReceipt()[1:])
if err != nil {
......
......@@ -620,8 +620,8 @@ func (s *VoteTestSuite) TestVoteTxFork() {
if bytes.Equal(key, kv.Key) {
var rst pt.ParacrossNodeStatus
types.Decode(kv.GetValue(), &rst)
s.Equal([]uint8([]byte{0x8e}), rst.TxResult)
s.Equal([]uint8([]byte{0x22}), rst.CrossTxResult)
s.Equal([]byte("8e"), rst.TxResult)
s.Equal([]byte("22"), rst.CrossTxResult)
s.Equal(1, len(rst.TxHashs))
s.Equal(1, len(rst.CrossTxHashs))
......
......@@ -151,6 +151,7 @@ message ParacrossNodeStatus {
repeated bytes txHashs = 11;
bytes crossTxResult = 12;
repeated bytes crossTxHashs = 13;
uint32 nonCommitTxCounts = 14;
}
message ParacrossCommitAction {
......
This diff is collapsed.
......@@ -61,7 +61,7 @@ func DisableLog() {
func init() {
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
......
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