Commit b57b7c5b authored by mdj33's avatar mdj33 Committed by vipwzw

fix ut

parent 51a3e896
......@@ -2,7 +2,7 @@ name: ci_paracross
on: [push,pull_request]
jobs:
ci_paracross:
paracross:
name: ci_paracross
runs-on: ubuntu-latest
steps:
......@@ -19,3 +19,21 @@ jobs:
run: |
make docker-compose dapp=paracross
make docker-compose-down dapp=paracross
bls:
name: bls
runs-on: ubuntu-latest
steps:
- name: Set up Golang
uses: actions/setup-go@v2
with:
go-version: 1.15
id: go
- name: set go env
run: export PATH=${PATH}:`go env GOPATH`/bin
- name: checkout
uses: actions/checkout@v2
- name: deploy
run: |
make docker-compose dapp=paracross extra=1
make docker-compose-down dapp=paracross
name: ci_paracross_bls
on: [push,pull_request]
jobs:
ci_paracross:
name: ci_paracross_bls
runs-on: ubuntu-latest
steps:
- name: Set up Golang
uses: actions/setup-go@v2
with:
go-version: 1.15
id: go
- name: set go env
run: export PATH=${PATH}:`go env GOPATH`/bin
- name: checkout
uses: actions/checkout@v2
- name: deploy
run: |
make docker-compose dapp=paracross extra=1
make docker-compose-down dapp=paracross
......@@ -131,7 +131,9 @@ mainLoopCheckCommitTxDoneForkHeight=4320000
#无平行链交易的主链区块间隔,平行链产生一个空块,从高度0开始,配置[blockHeight:interval],比如["0:50","1000:100"]
emptyBlockInterval=["0:50"]
#平行链共识节点聚合签名配置
[consensus.sub.para.bls]
#是否开启聚合签名,缺省不开启
blsSign=false
......
......@@ -340,6 +340,10 @@ func (client *client) ProcEvent(msg *queue.Message) bool {
return true
}
plog.Info("paracross ProcEvent", "from", req.GetFrom(), "topic:", req.GetTopic(), "ty", sub.GetTy())
if !client.blsSignCli.blsSignOn {
plog.Error("paracross ProcEvent bls is closed")
return true
}
switch sub.GetTy() {
case P2pSubCommitTx:
go client.blsSignCli.rcvCommitTx(sub.GetCommitTx())
......
......@@ -50,6 +50,7 @@ type blsClient struct {
peersBlsPubKey map[string]crypto.PubKey
commitsPool map[int64]*pt.ParaBlsSignSumDetails
rcvCommitTxCh chan []*pt.ParacrossCommitAction
blsSignOn bool
leaderOffset int32
leaderSwitchInt int32
leaderHeardTickInt int32
......@@ -74,23 +75,27 @@ func newBlsClient(para *client, cfg *subConfig) *blsClient {
b.rcvCommitTxCh = make(chan []*pt.ParacrossCommitAction, maxRcvTxCount)
b.quit = make(chan struct{})
b.leaderSwitchInt = defLeaderSwitchInt
if cfg.Bls.LeaderSwitchInt > 0 {
b.leaderSwitchInt = cfg.Bls.LeaderSwitchInt
}
b.leaderHeardTickInt = defLeaderHeardTickInt
if cfg.Bls.LeaderHeardTickInt > 0 {
b.leaderHeardTickInt = cfg.Bls.LeaderHeardTickInt
}
b.watchLeaderSyncInt = defWatchLeaderSyncInt
if cfg.Bls.WatchLeaderSyncInt > 0 {
b.watchLeaderSyncInt = cfg.Bls.WatchLeaderSyncInt
}
b.consensHeightDiffThreshold = defConsensHeightThreshold
if cfg.Bls.ConsensHeightDiffThreshold > 0 {
b.consensHeightDiffThreshold = cfg.Bls.ConsensHeightDiffThreshold
}
if cfg.Bls.PartNodeGroup > 0 {
b.partNodeGroup = cfg.Bls.PartNodeGroup
if cfg.Bls != nil {
b.blsSignOn = cfg.Bls.BlsSign
if cfg.Bls.LeaderSwitchInt > 0 {
b.leaderSwitchInt = cfg.Bls.LeaderSwitchInt
}
if cfg.Bls.LeaderHeardTickInt > 0 {
b.leaderHeardTickInt = cfg.Bls.LeaderHeardTickInt
}
if cfg.Bls.WatchLeaderSyncInt > 0 {
b.watchLeaderSyncInt = cfg.Bls.WatchLeaderSyncInt
}
if cfg.Bls.ConsensHeightDiffThreshold > 0 {
b.consensHeightDiffThreshold = cfg.Bls.ConsensHeightDiffThreshold
}
if cfg.Bls.PartNodeGroup > 0 {
b.partNodeGroup = cfg.Bls.PartNodeGroup
}
}
b.typeNode = pt.ParaCommitNode
......@@ -107,7 +112,7 @@ func newBlsClient(para *client, cfg *subConfig) *blsClient {
*/
func (b *blsClient) procLeaderSync() {
defer b.paraClient.wg.Done()
if len(b.selfID) <= 0 {
if len(b.selfID) <= 0 || !b.blsSignOn {
return
}
......@@ -279,7 +284,7 @@ func (b *blsClient) clearDonePool(consensHeight int64) {
//1. 要等到达成共识了才发送,不然处理未达成共识的各种场景会比较复杂,而且浪费手续费
func (b *blsClient) procAggregateTxs() {
defer b.paraClient.wg.Done()
if len(b.selfID) <= 0 {
if len(b.selfID) <= 0 || !b.blsSignOn {
return
}
......
......@@ -193,7 +193,7 @@ func (client *commitMsgClient) createCommitTx() {
return
}
//如果配置了blsSign 则发送到p2p的leader节点来聚合发送,否则发送到主链
if client.paraClient.subCfg.Bls.BlsSign {
if client.paraClient.blsSignCli.blsSignOn {
plog.Debug("bls.event.para bls commitMs send to p2p", "hash", common.ToHex(tx.Hash()))
act := &pt.ParaP2PSubMsg{Ty: P2pSubCommitTx, Value: &pt.ParaP2PSubMsg_CommitTx{CommitTx: tx}}
client.paraClient.SendPubP2PMsg(paraBlsSignTopic, types.Encode(act))
......@@ -260,7 +260,7 @@ func (client *commitMsgClient) sendCommitActions(acts []*pt.ParacrossCommitActio
//如果当前正在发送交易,则取消此次发送,待发送被确认或取消后再触发. 考虑到已经聚合共识成功,又收到某节点消息场景,会多发送交易
curTx := client.getCurrentTx()
if curTx != nil {
plog.Info("paracommitmsg isSendingCommitMsg, cancel this operation", "sending.tx", common.ToHex(curTx.Hash()))
plog.Info("bls.event.paracommitmsg isSendingCommitMsg, cancel this operation", "sending.tx", common.ToHex(curTx.Hash()))
return
}
......@@ -268,7 +268,7 @@ func (client *commitMsgClient) sendCommitActions(acts []*pt.ParacrossCommitActio
if err != nil {
return
}
plog.Info("paracommitmsg sendCommitActions", "txhash", common.ToHex(txs.Hash()))
plog.Info("bls.event.paracommitmsg sendCommitActions", "txhash", common.ToHex(txs.Hash()))
for i, msg := range acts {
plog.Debug("paracommitmsg sendCommitActions", "idx", i, "height", msg.Status.Height, "mainheight", msg.Status.MainBlockHeight,
"blockhash", common.HashHex(msg.Status.BlockHash), "mainHash", common.HashHex(msg.Status.MainBlockHash),
......@@ -436,7 +436,7 @@ func (client *commitMsgClient) getSendingTx(startHeight, endHeight int64) (*type
commits = append(commits, &pt.ParacrossCommitAction{Status: stat})
}
if client.paraClient.subCfg.Bls.BlsSign {
if client.paraClient.blsSignCli.blsSignOn {
err = client.paraClient.blsSignCli.blsSign(commits)
if err != nil {
plog.Error("paracommitmsg bls sign", "err", err)
......
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