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