Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
plugin
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
link33
plugin
Commits
23c4e112
Commit
23c4e112
authored
Oct 22, 2021
by
mdj33
Committed by
vipwzw
Oct 25, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add bls trigger
parent
b57b7c5b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
31 deletions
+24
-31
build_paracross.yml
.github/workflows/build_paracross.yml
+0
-18
parablssign.go
plugin/consensus/para/parablssign.go
+10
-10
paracommitmsg.go
plugin/consensus/para/paracommitmsg.go
+14
-3
No files found.
.github/workflows/build_paracross.yml
View file @
23c4e112
...
...
@@ -19,21 +19,3 @@ 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
plugin/consensus/para/parablssign.go
View file @
23c4e112
...
...
@@ -182,7 +182,7 @@ func (b *blsClient) rcvLeaderSyncTx(sync *pt.LeaderSyncInfo) error {
if
len
(
nodes
)
<=
0
{
return
errors
.
Wrapf
(
pt
.
ErrParaNodeGroupNotSet
,
"id=%s"
,
b
.
selfID
)
}
plog
.
Info
(
"bls.event.rcvLeaderSync
Tx
"
,
"from.leader"
,
sync
.
ID
,
"self"
,
b
.
selfID
,
plog
.
Info
(
"bls.event.rcvLeaderSync"
,
"from.leader"
,
sync
.
ID
,
"self"
,
b
.
selfID
,
"fromBase"
,
sync
.
BaseIdx
,
"selfBase"
,
base
,
"from.Off"
,
sync
.
Offset
,
"selfOff"
,
off
,
"count"
,
sync
.
Count
)
//接受同步数据需要两个节点基本的共识高度相同, 两个共同leader需相同
if
sync
.
BaseIdx
!=
base
{
...
...
@@ -299,17 +299,17 @@ out:
b
.
clearDonePool
(
consensHeight
)
//支持可配的只部分nodegroup地址参与聚合,另一部分直接发送
calc
Nodes
:=
len
(
nodes
)
if
b
.
partNodeGroup
>
0
&&
int
(
b
.
partNodeGroup
)
<
calc
Nodes
{
calc
Nodes
=
int
(
b
.
partNodeGroup
)
done
Nodes
:=
len
(
nodes
)
if
b
.
partNodeGroup
>
0
&&
int
(
b
.
partNodeGroup
)
<
done
Nodes
{
done
Nodes
=
int
(
b
.
partNodeGroup
)
}
//commitsPool里面任一高度满足共识,则认为done
if
!
isMostCommitDone
(
calc
Nodes
,
b
.
commitsPool
,
isLeader
,
leader
)
{
if
!
isMostCommitDone
(
done
Nodes
,
b
.
commitsPool
,
isLeader
,
leader
)
{
continue
}
//自己是Leader,或共识高度超过阈值则聚合并发送交易
if
isLeader
||
int32
(
math
.
Abs
(
float64
(
b
.
paraClient
.
commitMsgClient
.
chainHeight
-
consensHeight
)))
>
b
.
consensHeightDiffThreshold
{
_
=
b
.
sendAggregateTx
(
nodes
)
_
=
b
.
sendAggregateTx
(
nodes
,
doneNodes
)
}
case
<-
b
.
quit
:
...
...
@@ -318,8 +318,8 @@ out:
}
}
func
(
b
*
blsClient
)
sendAggregateTx
(
nodes
[]
string
)
error
{
dones
:=
filterDoneCommits
(
len
(
nodes
)
,
b
.
commitsPool
)
func
(
b
*
blsClient
)
sendAggregateTx
(
nodes
[]
string
,
doneNodes
int
)
error
{
dones
:=
filterDoneCommits
(
doneNodes
,
b
.
commitsPool
)
if
len
(
dones
)
<=
0
{
return
nil
}
...
...
@@ -440,11 +440,11 @@ func isMostCommitDone(nodes int, txsBuff map[int64]*pt.ParaBlsSignSumDetails, is
}
//找出共识并达到2/3的commits, 并去除与共识不同的commits,为后面聚合签名做准备
func
filterDoneCommits
(
peer
s
int
,
pool
map
[
int64
]
*
pt
.
ParaBlsSignSumDetails
)
[]
*
pt
.
ParaBlsSignSumDetails
{
func
filterDoneCommits
(
node
s
int
,
pool
map
[
int64
]
*
pt
.
ParaBlsSignSumDetails
)
[]
*
pt
.
ParaBlsSignSumDetails
{
var
seq
[]
int64
for
i
,
v
:=
range
pool
{
most
,
hash
:=
util
.
GetMostCommit
(
v
.
Msgs
)
if
!
util
.
IsCommitDone
(
peer
s
,
most
)
{
if
!
util
.
IsCommitDone
(
node
s
,
most
)
{
continue
}
seq
=
append
(
seq
,
i
)
...
...
plugin/consensus/para/paracommitmsg.go
View file @
23c4e112
...
...
@@ -194,9 +194,7 @@ func (client *commitMsgClient) createCommitTx() {
}
//如果配置了blsSign 则发送到p2p的leader节点来聚合发送,否则发送到主链
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
))
client
.
pushCommitTx2P2P
(
tx
)
return
}
client
.
pushCommitTx
(
tx
)
...
...
@@ -255,6 +253,19 @@ func (client *commitMsgClient) pushCommitTx(signTx *types.Transaction) {
client
.
sendMsgCh
<-
signTx
}
//仍旧setCurrentTx, 这样在几个块之后仍旧会触发重发,重发只是广播,不然发送p2p之后,如果共识没增加,也没有其他触发的条件了
func
(
client
*
commitMsgClient
)
pushCommitTx2P2P
(
signTx
*
types
.
Transaction
)
{
client
.
mutex
.
Lock
()
defer
client
.
mutex
.
Unlock
()
client
.
checkTxCommitTimes
=
0
client
.
setCurrentTx
(
signTx
)
plog
.
Debug
(
"bls.event.para bls commitMs send to p2p"
,
"hash"
,
common
.
ToHex
(
signTx
.
Hash
()))
act
:=
&
pt
.
ParaP2PSubMsg
{
Ty
:
P2pSubCommitTx
,
Value
:
&
pt
.
ParaP2PSubMsg_CommitTx
{
CommitTx
:
signTx
}}
client
.
paraClient
.
SendPubP2PMsg
(
paraBlsSignTopic
,
types
.
Encode
(
act
))
}
//根据收集的commit action,签名发送, 比如BLS签名后的commit msg
func
(
client
*
commitMsgClient
)
sendCommitActions
(
acts
[]
*
pt
.
ParacrossCommitAction
)
{
//如果当前正在发送交易,则取消此次发送,待发送被确认或取消后再触发. 考虑到已经聚合共识成功,又收到某节点消息场景,会多发送交易
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment