Commit 721cfedf authored by mdj33's avatar mdj33 Committed by vipwzw

cut commit status parameter

parent 5be6fba4
......@@ -687,12 +687,15 @@ func (client *client) addMinerTx(preStateHash []byte, block *types.Block, main *
status := &pt.ParacrossNodeStatus{
Title: types.GetTitle(),
Height: block.Height,
PreBlockHash: block.ParentHash,
PreStateHash: preStateHash,
MainBlockHash: main.Seq.Hash,
MainBlockHeight: main.Detail.Block.Height,
}
if !paracross.IsParaForkHeight(status.MainBlockHeight, pt.ForkLoopCheckCommitTxDone) {
status.PreBlockHash = block.ParentHash
status.PreStateHash = preStateHash
}
tx, err := pt.CreateRawMinerTx(&pt.ParacrossMinerAction{
Status: status,
IsSelfConsensus: isParaSelfConsensusForked(status.MainBlockHeight),
......
......@@ -445,7 +445,6 @@ func (client *commitMsgClient) getNodeStatus(start, end int64) ([]*pt.ParacrossN
return nil, errors.New("paracommitmsg wrong block result")
}
nodeList[block.Block.Height].BlockHash = block.Block.Hash()
nodeList[block.Block.Height].StateHash = block.Block.StateHash
}
var needSentTxs uint32
......@@ -462,6 +461,11 @@ func (client *commitMsgClient) getNodeStatus(start, end int64) ([]*pt.ParacrossN
return nil, nil
}
//clear flag
for _, v := range ret {
v.NonCommitTxCounts = 0
}
return ret, nil
}
......@@ -479,10 +483,8 @@ func (client *commitMsgClient) getGenesisNodeStatus() (*pt.ParacrossNodeStatus,
}
status.Title = types.GetTitle()
status.Height = block.Height
status.PreBlockHash = zeroHash[:]
status.BlockHash = block.Hash()
status.PreStateHash = zeroHash[:]
status.StateHash = block.StateHash
return &status, nil
}
......
This diff is collapsed.
......@@ -217,7 +217,6 @@ func setMinerTxResultFork(status *pt.ParacrossNodeStatus, txs []*types.Transacti
}
}
status.TxCounts = uint32(len(curTxHashs))
//有tx且全部是user.p.x.paracross的commit tx时候设为0
status.NonCommitTxCounts = 1
if len(curTxHashs) != 0 && len(curTxHashs) == len(isCommitTx) {
......@@ -227,12 +226,15 @@ func setMinerTxResultFork(status *pt.ParacrossNodeStatus, txs []*types.Transacti
//主链自己过滤平行链tx, 对平行链执行失败的tx主链无法识别,主链和平行链需要获取相同的最初的tx map
//全部平行链tx结果
status.TxResult = []byte(hex.EncodeToString(util.CalcBitMap(curTxHashs, curTxHashs, receipts)))
//跨链tx结果
status.CrossTxResult = []byte(hex.EncodeToString(util.CalcBitMap(crossTxHashs, curTxHashs, receipts)))
status.TxHashs = [][]byte{CalcTxHashsHash(curTxHashs)}
status.CrossTxHashs = [][]byte{CalcTxHashsHash(crossTxHashs)}
status.TxResult = []byte(hex.EncodeToString(util.CalcSingleBitMap(curTxHashs, receipts)))
//ForkLoopCheckCommitTxDone 后只保留全部txreseult 结果
if !pt.IsParaForkHeight(status.MainBlockHeight, pt.ForkLoopCheckCommitTxDone) {
//跨链tx结果
status.CrossTxResult = []byte(hex.EncodeToString(util.CalcBitMap(crossTxHashs, curTxHashs, receipts)))
status.TxHashs = [][]byte{CalcTxHashsHash(curTxHashs)}
status.CrossTxHashs = [][]byte{CalcTxHashsHash(crossTxHashs)}
}
return nil
}
......@@ -246,7 +248,7 @@ func (e *Paracross) ExecLocal_Miner(payload *pt.ParacrossMinerAction, tx *types.
var set types.LocalDBSet
txs := e.GetTxs()
forkHeight := getDappForkHeight(pt.ForkCommitTx)
forkHeight := pt.GetDappForkHeight(pt.ForkCommitTx)
//removed the 0 vote tx
if payload.Status.MainBlockHeight >= forkHeight {
......
......@@ -75,7 +75,7 @@ func filterParaTxGroup(title string, tx *types.Transaction, main *types.BlockDet
//FilterTxsForPara include some main tx in tx group before ForkParacrossCommitTx
func FilterTxsForPara(title string, main *types.BlockDetail) []*types.Transaction {
var txs []*types.Transaction
forkHeight := getDappForkHeight(pt.ForkCommitTx)
forkHeight := pt.GetDappForkHeight(pt.ForkCommitTx)
for i := 0; i < len(main.Block.Txs); i++ {
tx := main.Block.Txs[i]
if types.IsSpecificParaExecName(title, string(tx.Execer)) {
......
......@@ -97,9 +97,6 @@ func (c *Paracross) saveLocalParaTxsFork(commitDone *pt.ReceiptParacrossDone, is
Height: commitDone.Height,
BlockHash: commitDone.BlockHash,
TxResult: commitDone.TxResult,
TxHashs: commitDone.TxHashs,
CrossTxResult: commitDone.CrossTxResult,
CrossTxHashs: commitDone.CrossTxHashs,
}
crossTxHashs, crossTxResult, err := getCrossTxHashs(c.GetAPI(), status)
......
......@@ -226,8 +226,6 @@ func listLocalTitles(db dbm.KVDB) (types.Message, error) {
MostSameCommit: st.MostSameCommit,
Title: st.Title,
Height: st.Height,
StateHash: common.ToHex(st.StateHash),
TxCounts: st.TxCounts,
TxResult: hex.EncodeToString(st.TxResult),
}
......@@ -313,8 +311,6 @@ func loadLocalTitle(db dbm.KV, title string, height int64) (types.Message, error
MostSameCommit: st.MostSameCommit,
Title: st.Title,
Height: st.Height,
StateHash: common.ToHex(st.StateHash),
TxCounts: st.TxCounts,
TxResult: hex.EncodeToString(st.TxResult),
}, nil
}
......
......@@ -612,7 +612,7 @@ func (a *action) nodeVote(config *pt.ParaNodeAddrConfig) (*types.Receipt, error)
}
receipt = mergeReceipt(receipt, r)
if a.exec.GetMainHeight() > getDappForkHeight(pt.ForkLoopCheckCommitTxDone) {
if a.exec.GetMainHeight() > pt.GetDappForkHeight(pt.ForkLoopCheckCommitTxDone) {
//node quit后,如果committx满足2/3目标,自动触发commitDone
r, err = a.loopCommitTxDone(config.Title)
if err != nil {
......
......@@ -16,11 +16,9 @@ message ParacrossStatusDetails {
//记录不同blockHash的详细数据
message ParacrossStatusBlockDetails {
repeated bytes blockHashs = 1;
repeated bytes stateHashs = 2;
repeated bytes txResults = 3;
repeated bytes txHashs = 4;
repeated bytes crossTxResults = 5;
repeated bytes crossTxHashs = 6;
repeated bytes txResults = 2;
}
message ParacrossHeightStatus {
......
......@@ -308,3 +308,38 @@ func (p ParacrossType) CreateRawTransferTx(action string, param json.RawMessage)
return tx, nil
}
func GetDappForkHeight(forkKey string) int64 {
var forkHeight int64
if types.IsPara() {
key := forkKey
switch forkKey {
case ForkCommitTx:
key = MainForkParacrossCommitTx
case ForkLoopCheckCommitTxDone:
key = MainLoopCheckCommitTxDoneForkHeight
}
forkHeight = types.Conf("config.consensus.sub.para").GInt(key)
if forkHeight <= 0 {
forkHeight = types.MaxHeight
}
} else {
forkHeight = types.GetDappFork(ParaX, forkKey)
// CI特殊处理,主链是local,fork都是0,平行链有些配置项需要设置为非0,不然获取到的高度为MaxHeight
if types.IsLocal() {
switch forkKey {
case ForkCommitTx:
forkHeight = 10
case ForkLoopCheckCommitTxDone:
forkHeight = 60
}
}
}
return forkHeight
}
func IsParaForkHeight(height int64, forkKey string) bool {
return height >= GetDappForkHeight(forkKey)
}
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