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
d84308aa
Commit
d84308aa
authored
Jun 19, 2020
by
madengji
Committed by
33cn
Jun 29, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix ut
parent
6ef4b91d
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
29 additions
and
117 deletions
+29
-117
chain33.para.toml
chain33.para.toml
+2
-1
parablssign.go
plugin/consensus/para/parablssign.go
+10
-70
parablssign_test.go
plugin/consensus/para/parablssign_test.go
+8
-25
paracommitmsg.go
plugin/consensus/para/paracommitmsg.go
+5
-2
bls.go
plugin/crypto/bls/bls.go
+1
-1
Dockerfile
plugin/dapp/paracross/cmd/build/Dockerfile
+0
-1
action.go
plugin/dapp/paracross/executor/action.go
+2
-2
paracross_test.go
plugin/dapp/paracross/executor/paracross_test.go
+1
-0
superaccount.go
plugin/dapp/paracross/executor/superaccount.go
+0
-15
No files found.
chain33.para.toml
View file @
d84308aa
...
@@ -56,7 +56,7 @@ grpcLogFile="grpc33.log"
...
@@ -56,7 +56,7 @@ grpcLogFile="grpc33.log"
[p2p.sub.dht]
[p2p.sub.dht]
isSeed
=
true
isSeed
=
true
DHTDataPath
=
"paradatadir/p2pstore"
[rpc]
[rpc]
# 避免与主链配置冲突
# 避免与主链配置冲突
...
@@ -112,6 +112,7 @@ mainForkParacrossCommitTx=2270000
...
@@ -112,6 +112,7 @@ mainForkParacrossCommitTx=2270000
mainLoopCheckCommitTxDoneForkHeight
=
4320000
mainLoopCheckCommitTxDoneForkHeight
=
4320000
#无平行链交易的主链区块间隔,平行链产生一个空块,从高度0开始,配置[blockHeight:interval],比如["0:50","1000:100"]
#无平行链交易的主链区块间隔,平行链产生一个空块,从高度0开始,配置[blockHeight:interval],比如["0:50","1000:100"]
emptyBlockInterval
=
["0:50"]
emptyBlockInterval
=
["0:50"]
blsSign
=
true
[store]
[store]
...
...
plugin/consensus/para/parablssign.go
View file @
d84308aa
...
@@ -6,13 +6,14 @@ package para
...
@@ -6,13 +6,14 @@ package para
import
(
import
(
"bytes"
"bytes"
"math/big"
"sort"
"sort"
"strings"
"strings"
"sync"
"sync"
"sync/atomic"
"sync/atomic"
"time"
"time"
"github.com/33cn/chain33/util"
"github.com/33cn/chain33/common"
"github.com/33cn/chain33/common"
"github.com/33cn/chain33/common/crypto"
"github.com/33cn/chain33/common/crypto"
"github.com/33cn/chain33/types"
"github.com/33cn/chain33/types"
...
@@ -36,7 +37,6 @@ type blsClient struct {
...
@@ -36,7 +37,6 @@ type blsClient struct {
cryptoCli
crypto
.
Crypto
cryptoCli
crypto
.
Crypto
blsPriKey
crypto
.
PrivKey
blsPriKey
crypto
.
PrivKey
blsPubKey
crypto
.
PubKey
blsPubKey
crypto
.
PubKey
peers
map
[
string
]
bool
peersBlsPubKey
map
[
string
]
crypto
.
PubKey
peersBlsPubKey
map
[
string
]
crypto
.
PubKey
commitsPool
map
[
int64
]
*
pt
.
ParaBlsSignSumDetails
commitsPool
map
[
int64
]
*
pt
.
ParaBlsSignSumDetails
rcvCommitTxCh
chan
[]
*
pt
.
ParacrossCommitAction
rcvCommitTxCh
chan
[]
*
pt
.
ParacrossCommitAction
...
@@ -50,7 +50,6 @@ type blsClient struct {
...
@@ -50,7 +50,6 @@ type blsClient struct {
func
newBlsClient
(
para
*
client
,
cfg
*
subConfig
)
*
blsClient
{
func
newBlsClient
(
para
*
client
,
cfg
*
subConfig
)
*
blsClient
{
b
:=
&
blsClient
{
paraClient
:
para
}
b
:=
&
blsClient
{
paraClient
:
para
}
b
.
selfID
=
cfg
.
AuthAccount
b
.
selfID
=
cfg
.
AuthAccount
b
.
peers
=
make
(
map
[
string
]
bool
)
cli
,
err
:=
crypto
.
New
(
"bls"
)
cli
,
err
:=
crypto
.
New
(
"bls"
)
if
err
!=
nil
{
if
err
!=
nil
{
panic
(
"new bls crypto fail"
)
panic
(
"new bls crypto fail"
)
...
@@ -231,7 +230,6 @@ func (b *blsClient) sendAggregateTx(nodes []string) error {
...
@@ -231,7 +230,6 @@ func (b *blsClient) sendAggregateTx(nodes []string) error {
func
(
b
*
blsClient
)
rcvCommitTx
(
tx
*
types
.
Transaction
)
error
{
func
(
b
*
blsClient
)
rcvCommitTx
(
tx
*
types
.
Transaction
)
error
{
if
!
b
.
isValidNodes
(
tx
.
From
())
{
if
!
b
.
isValidNodes
(
tx
.
From
())
{
b
.
updatePeers
(
tx
.
From
(),
false
)
plog
.
Error
(
"rcvCommitTx is not valid node"
,
"addr"
,
tx
.
From
())
plog
.
Error
(
"rcvCommitTx is not valid node"
,
"addr"
,
tx
.
From
())
return
pt
.
ErrParaNodeAddrNotExisted
return
pt
.
ErrParaNodeAddrNotExisted
}
}
...
@@ -251,7 +249,7 @@ func (b *blsClient) rcvCommitTx(tx *types.Transaction) error {
...
@@ -251,7 +249,7 @@ func (b *blsClient) rcvCommitTx(tx *types.Transaction) error {
plog
.
Error
(
"rcvCommitTx checkCommitTx "
,
"err"
,
err
)
plog
.
Error
(
"rcvCommitTx checkCommitTx "
,
"err"
,
err
)
return
errors
.
Wrap
(
err
,
"checkCommitTx"
)
return
errors
.
Wrap
(
err
,
"checkCommitTx"
)
}
}
b
.
updatePeers
(
tx
.
From
(),
true
)
if
len
(
commits
)
>
0
{
if
len
(
commits
)
>
0
{
plog
.
Debug
(
"rcvCommitTx tx"
,
"addr"
,
tx
.
From
(),
"height"
,
commits
[
0
]
.
Status
.
Height
)
plog
.
Debug
(
"rcvCommitTx tx"
,
"addr"
,
tx
.
From
(),
"height"
,
commits
[
0
]
.
Status
.
Height
)
}
}
...
@@ -328,8 +326,8 @@ func isMostCommitDone(peers int, txsBuff map[int64]*pt.ParaBlsSignSumDetails) bo
...
@@ -328,8 +326,8 @@ func isMostCommitDone(peers int, txsBuff map[int64]*pt.ParaBlsSignSumDetails) bo
}
}
for
i
,
v
:=
range
txsBuff
{
for
i
,
v
:=
range
txsBuff
{
most
,
_
:=
g
etMostCommit
(
v
.
Msgs
)
most
,
_
:=
util
.
G
etMostCommit
(
v
.
Msgs
)
if
i
sCommitDone
(
peers
,
most
)
{
if
util
.
I
sCommitDone
(
peers
,
most
)
{
plog
.
Info
(
"blssign.isMostCommitDone"
,
"height"
,
i
,
"most"
,
most
,
"peers"
,
peers
)
plog
.
Info
(
"blssign.isMostCommitDone"
,
"height"
,
i
,
"most"
,
most
,
"peers"
,
peers
)
return
true
return
true
}
}
...
@@ -341,8 +339,8 @@ func isMostCommitDone(peers int, txsBuff map[int64]*pt.ParaBlsSignSumDetails) bo
...
@@ -341,8 +339,8 @@ func isMostCommitDone(peers int, txsBuff map[int64]*pt.ParaBlsSignSumDetails) bo
func
filterDoneCommits
(
peers
int
,
pool
map
[
int64
]
*
pt
.
ParaBlsSignSumDetails
)
[]
*
pt
.
ParaBlsSignSumDetails
{
func
filterDoneCommits
(
peers
int
,
pool
map
[
int64
]
*
pt
.
ParaBlsSignSumDetails
)
[]
*
pt
.
ParaBlsSignSumDetails
{
var
seq
[]
int64
var
seq
[]
int64
for
i
,
v
:=
range
pool
{
for
i
,
v
:=
range
pool
{
most
,
hash
:=
g
etMostCommit
(
v
.
Msgs
)
most
,
hash
:=
util
.
G
etMostCommit
(
v
.
Msgs
)
if
!
i
sCommitDone
(
peers
,
most
)
{
if
!
util
.
I
sCommitDone
(
peers
,
most
)
{
plog
.
Debug
(
"blssign.filterDoneCommits not commit done"
,
"height"
,
i
)
plog
.
Debug
(
"blssign.filterDoneCommits not commit done"
,
"height"
,
i
)
continue
continue
}
}
...
@@ -393,7 +391,7 @@ func (b *blsClient) aggregateCommit2Action(nodes []string, commits []*pt.ParaBls
...
@@ -393,7 +391,7 @@ func (b *blsClient) aggregateCommit2Action(nodes []string, commits []*pt.ParaBls
return
nil
,
errors
.
Wrapf
(
err
,
"bls aggregate=%s"
,
v
.
Addrs
)
return
nil
,
errors
.
Wrapf
(
err
,
"bls aggregate=%s"
,
v
.
Addrs
)
}
}
a
.
Bls
.
Sign
=
sign
.
Bytes
()
a
.
Bls
.
Sign
=
sign
.
Bytes
()
bits
,
remains
:=
s
etAddrsBitMap
(
nodes
,
v
.
Addrs
)
bits
,
remains
:=
util
.
S
etAddrsBitMap
(
nodes
,
v
.
Addrs
)
plog
.
Debug
(
"AggregateCommit2Action"
,
"nodes"
,
nodes
,
"addr"
,
v
.
Addrs
,
"bits"
,
common
.
ToHex
(
bits
),
"height"
,
v
.
Height
)
plog
.
Debug
(
"AggregateCommit2Action"
,
"nodes"
,
nodes
,
"addr"
,
v
.
Addrs
,
"bits"
,
common
.
ToHex
(
bits
),
"height"
,
v
.
Height
)
if
len
(
remains
)
>
0
{
if
len
(
remains
)
>
0
{
plog
.
Info
(
"bls.signDoneCommits"
,
"remains"
,
remains
)
plog
.
Info
(
"bls.signDoneCommits"
,
"remains"
,
remains
)
...
@@ -421,22 +419,6 @@ func (b *blsClient) aggregateSigns(signs [][]byte) (crypto.Signature, error) {
...
@@ -421,22 +419,6 @@ func (b *blsClient) aggregateSigns(signs [][]byte) (crypto.Signature, error) {
return
agg
.
Aggregate
(
signatures
)
return
agg
.
Aggregate
(
signatures
)
}
}
func
(
b
*
blsClient
)
updatePeers
(
id
string
,
add
bool
)
{
b
.
mutex
.
Lock
()
defer
b
.
mutex
.
Unlock
()
if
_
,
ok
:=
b
.
peers
[
id
];
ok
{
if
!
add
{
delete
(
b
.
peers
,
id
)
}
return
}
if
add
{
b
.
peers
[
id
]
=
true
}
}
func
(
b
*
blsClient
)
setBlsPriKey
(
secpPrkKey
[]
byte
)
{
func
(
b
*
blsClient
)
setBlsPriKey
(
secpPrkKey
[]
byte
)
{
b
.
blsPriKey
=
b
.
getBlsPriKey
(
secpPrkKey
)
b
.
blsPriKey
=
b
.
getBlsPriKey
(
secpPrkKey
)
b
.
blsPubKey
=
b
.
blsPriKey
.
PubKey
()
b
.
blsPubKey
=
b
.
blsPriKey
.
PubKey
()
...
@@ -448,9 +430,9 @@ func (b *blsClient) getBlsPriKey(key []byte) crypto.PrivKey {
...
@@ -448,9 +430,9 @@ func (b *blsClient) getBlsPriKey(key []byte) crypto.PrivKey {
var
newKey
[
common
.
Sha256Len
]
byte
var
newKey
[
common
.
Sha256Len
]
byte
copy
(
newKey
[
:
],
key
)
copy
(
newKey
[
:
],
key
)
for
{
for
{
plog
.
Info
(
"para commit getBlsPriKey try"
,
"key"
,
common
.
ToHex
(
newKey
[
:
]))
pri
,
err
:=
b
.
cryptoCli
.
PrivKeyFromBytes
(
newKey
[
:
])
pri
,
err
:=
b
.
cryptoCli
.
PrivKeyFromBytes
(
newKey
[
:
])
if
nil
!=
err
{
if
nil
!=
err
{
plog
.
Debug
(
"para commit getBlsPriKey try"
,
"key"
,
common
.
ToHex
(
newKey
[
:
]))
copy
(
newKey
[
:
],
common
.
Sha256
(
newKey
[
:
]))
copy
(
newKey
[
:
],
common
.
Sha256
(
newKey
[
:
]))
continue
continue
}
}
...
@@ -482,53 +464,11 @@ func (b *blsClient) blsSign(commits []*pt.ParacrossCommitAction) error {
...
@@ -482,53 +464,11 @@ func (b *blsClient) blsSign(commits []*pt.ParacrossCommitAction) error {
return
errors
.
Wrapf
(
types
.
ErrInvalidParam
,
"addr=%s,height=%d"
,
b
.
selfID
,
cmt
.
Status
.
Height
)
return
errors
.
Wrapf
(
types
.
ErrInvalidParam
,
"addr=%s,height=%d"
,
b
.
selfID
,
cmt
.
Status
.
Height
)
}
}
cmt
.
Bls
.
Sign
=
sign
cmt
.
Bls
.
Sign
=
sign
plog
.
Debug
(
"bl
sign msg"
,
"data"
,
common
.
ToHex
(
data
),
"height"
,
cmt
.
Status
.
Height
,
"sign"
,
len
(
cmt
.
Bls
.
Sign
),
"src"
,
len
(
sign
))
plog
.
Info
(
"bls
sign msg"
,
"data"
,
common
.
ToHex
(
data
),
"height"
,
cmt
.
Status
.
Height
,
"sign"
,
len
(
cmt
.
Bls
.
Sign
),
"src"
,
len
(
sign
))
}
}
return
nil
return
nil
}
}
//设置nodes范围内的bitmap,如果addrs在node不存在,也不设置,返回未命中的addrs
func
setAddrsBitMap
(
nodes
,
addrs
[]
string
)
([]
byte
,
map
[
string
]
bool
)
{
rst
:=
big
.
NewInt
(
0
)
addrsMap
:=
make
(
map
[
string
]
bool
)
for
_
,
n
:=
range
addrs
{
addrsMap
[
n
]
=
true
}
for
i
,
a
:=
range
nodes
{
if
_
,
exist
:=
addrsMap
[
a
];
exist
{
rst
.
SetBit
(
rst
,
i
,
1
)
delete
(
addrsMap
,
a
)
}
}
return
rst
.
Bytes
(),
addrsMap
}
func
getMostCommit
(
commits
[][]
byte
)
(
int
,
string
)
{
stats
:=
make
(
map
[
string
]
int
)
n
:=
len
(
commits
)
for
i
:=
0
;
i
<
n
;
i
++
{
if
_
,
ok
:=
stats
[
string
(
commits
[
i
])];
ok
{
stats
[
string
(
commits
[
i
])]
++
}
else
{
stats
[
string
(
commits
[
i
])]
=
1
}
}
most
:=
-
1
var
hash
string
for
k
,
v
:=
range
stats
{
if
v
>
most
{
most
=
v
hash
=
k
}
}
return
most
,
hash
}
func
isCommitDone
(
nodes
,
mostSame
int
)
bool
{
return
3
*
mostSame
>
2
*
nodes
}
func
(
b
*
blsClient
)
getBlsPubKey
(
addr
string
)
(
crypto
.
PubKey
,
error
)
{
func
(
b
*
blsClient
)
getBlsPubKey
(
addr
string
)
(
crypto
.
PubKey
,
error
)
{
//先从缓存中获取
//先从缓存中获取
if
v
,
ok
:=
b
.
peersBlsPubKey
[
addr
];
ok
{
if
v
,
ok
:=
b
.
peersBlsPubKey
[
addr
];
ok
{
...
...
plugin/consensus/para/parablssign_test.go
View file @
d84308aa
...
@@ -11,33 +11,11 @@ import (
...
@@ -11,33 +11,11 @@ import (
"github.com/33cn/chain33/types"
"github.com/33cn/chain33/types"
"github.com/33cn/chain33/common/crypto"
"github.com/33cn/chain33/common/crypto"
_
"github.com/33cn/plugin/plugin/crypto/bls"
pt
"github.com/33cn/plugin/plugin/dapp/paracross/types"
pt
"github.com/33cn/plugin/plugin/dapp/paracross/types"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/assert"
)
)
func
TestSetAddrsBitMap
(
t
*
testing
.
T
)
{
nodes
:=
[]
string
{
"aa"
,
"bb"
,
"cc"
,
"dd"
}
addrs
:=
[]
string
{}
rst
,
rem
:=
setAddrsBitMap
(
nodes
,
addrs
)
assert
.
Equal
(
t
,
len
(
rst
),
0
)
assert
.
Equal
(
t
,
len
(
rem
),
0
)
addrs
=
[]
string
{
"aa"
}
rst
,
rem
=
setAddrsBitMap
(
nodes
,
addrs
)
assert
.
Equal
(
t
,
rst
,
[]
byte
{
0x1
})
assert
.
Equal
(
t
,
len
(
rem
),
0
)
addrs
=
[]
string
{
"aa"
,
"cc"
}
rst
,
rem
=
setAddrsBitMap
(
nodes
,
addrs
)
assert
.
Equal
(
t
,
rst
,
[]
byte
{
0x5
})
assert
.
Equal
(
t
,
len
(
rem
),
0
)
addrs
=
[]
string
{
"aa"
,
"cc"
,
"dd"
}
rst
,
rem
=
setAddrsBitMap
(
nodes
,
addrs
)
assert
.
Equal
(
t
,
rst
,
[]
byte
{
0xd
})
assert
.
Equal
(
t
,
len
(
rem
),
0
)
}
func
TestIntegrateCommits
(
t
*
testing
.
T
)
{
func
TestIntegrateCommits
(
t
*
testing
.
T
)
{
pool
:=
make
(
map
[
int64
]
*
pt
.
ParaBlsSignSumDetails
)
pool
:=
make
(
map
[
int64
]
*
pt
.
ParaBlsSignSumDetails
)
var
commits
[]
*
pt
.
ParacrossCommitAction
var
commits
[]
*
pt
.
ParacrossCommitAction
...
@@ -135,12 +113,17 @@ func testVerifyBlsSign(t *testing.T, cryptCli crypto.Crypto) {
...
@@ -135,12 +113,17 @@ func testVerifyBlsSign(t *testing.T, cryptCli crypto.Crypto) {
commit
:=
&
pt
.
ParacrossCommitAction
{}
commit
:=
&
pt
.
ParacrossCommitAction
{}
blsInfo
:=
&
pt
.
ParacrossCommitBlsInfo
{}
blsInfo
:=
&
pt
.
ParacrossCommitBlsInfo
{}
signData
:=
"0x82753675393576758571cbbaefada498614b4a0a967ca2dd5724eb46ecfd1c89f1e49792ebbe1866c1d6d6ceaf3054c7189751477a5b7312218eb77dcab1bfb6287c6fbf2e1c6cf8fe2ade7c17596b081dc98be785a34db5b45a5cca08e7e744"
//bls-cgo sign data
//signData := "0x82753675393576758571cbbaefada498614b4a0a967ca2dd5724eb46ecfd1c89f1e49792ebbe1866c1d6d6ceaf3054c7189751477a5b7312218eb77dcab1bfb6287c6fbf2e1c6cf8fe2ade7c17596b081dc98be785a34db5b45a5cca08e7e744"
//g1pubs' sign data
signData
:=
"0x90b4510399b16e6b3c3129593b29f88bfbc6bb1ab3fe44f682f7ff32a9b8e7086c07d28a25efc29b460fb40ea2674c7910d63293f0d57670276b7baabe4c95c92143063296371b8ba2a0e540f7956d569740bc08553a0dc6bf2fff4f4241c082"
blsInfo
.
Sign
,
err
=
common
.
FromHex
(
signData
)
blsInfo
.
Sign
,
err
=
common
.
FromHex
(
signData
)
assert
.
NoError
(
t
,
err
)
assert
.
NoError
(
t
,
err
)
status
:=
&
pt
.
ParacrossNodeStatus
{}
status
:=
&
pt
.
ParacrossNodeStatus
{}
data
:=
"0x1a0c757365722e702e706172612e322097162f9d4a888121fdba2fb1ab402596acdbcb602121bd12284adb739d85f225"
//data := "0x1a0c757365722e702e706172612e322097162f9d4a888121fdba2fb1ab402596acdbcb602121bd12284adb739d85f225"
data
:=
"0x1a0c757365722e702e706172612e"
msg
,
err
:=
common
.
FromHex
(
data
)
msg
,
err
:=
common
.
FromHex
(
data
)
assert
.
NoError
(
t
,
err
)
assert
.
NoError
(
t
,
err
)
types
.
Decode
(
msg
,
status
)
types
.
Decode
(
msg
,
status
)
...
...
plugin/consensus/para/paracommitmsg.go
View file @
d84308aa
...
@@ -927,11 +927,13 @@ func (client *commitMsgClient) getNodeGroupAddrs() (string, error) {
...
@@ -927,11 +927,13 @@ func (client *commitMsgClient) getNodeGroupAddrs() (string, error) {
func
(
client
*
commitMsgClient
)
onWalletStatus
(
status
*
types
.
WalletStatus
)
{
func
(
client
*
commitMsgClient
)
onWalletStatus
(
status
*
types
.
WalletStatus
)
{
if
status
==
nil
||
client
.
authAccount
==
""
{
if
status
==
nil
||
client
.
authAccount
==
""
{
plog
.
Info
(
"para onWalletStatus"
,
"status"
,
status
==
nil
,
"auth"
,
client
.
authAccount
==
""
)
return
return
}
}
if
!
status
.
IsWalletLock
&&
client
.
privateKey
==
nil
{
if
!
status
.
IsWalletLock
&&
client
.
privateKey
==
nil
{
plog
.
Info
(
"para commit fetchPriKey try"
)
client
.
fetchPriKey
()
client
.
fetchPriKey
()
plog
.
Info
(
"para commit fetchPriKey"
)
plog
.
Info
(
"para commit fetchPriKey
ok
"
)
}
}
if
client
.
privateKey
==
nil
{
if
client
.
privateKey
==
nil
{
...
@@ -951,9 +953,10 @@ func (client *commitMsgClient) onWalletAccount(acc *types.Account) {
...
@@ -951,9 +953,10 @@ func (client *commitMsgClient) onWalletAccount(acc *types.Account) {
if
acc
==
nil
||
client
.
authAccount
==
""
||
client
.
authAccount
!=
acc
.
Addr
||
client
.
privateKey
!=
nil
{
if
acc
==
nil
||
client
.
authAccount
==
""
||
client
.
authAccount
!=
acc
.
Addr
||
client
.
privateKey
!=
nil
{
return
return
}
}
plog
.
Error
(
"para onWalletAccount try fetch prikey"
)
err
:=
client
.
fetchPriKey
()
err
:=
client
.
fetchPriKey
()
if
err
!=
nil
{
if
err
!=
nil
{
plog
.
Error
(
"para
commit fetchPriKey
"
,
"err"
,
err
.
Error
())
plog
.
Error
(
"para
onWalletAccount
"
,
"err"
,
err
.
Error
())
return
return
}
}
...
...
plugin/crypto/bls/bls.go
View file @
d84308aa
...
@@ -44,7 +44,7 @@ func (d Driver) PrivKeyFromBytes(b []byte) (privKey crypto.PrivKey, err error) {
...
@@ -44,7 +44,7 @@ func (d Driver) PrivKeyFromBytes(b []byte) (privKey crypto.PrivKey, err error) {
privKeyBytes
:=
new
([
BLSPrivateKeyLength
]
byte
)
privKeyBytes
:=
new
([
BLSPrivateKeyLength
]
byte
)
copy
(
privKeyBytes
[
:
],
b
[
:
BLSPrivateKeyLength
])
copy
(
privKeyBytes
[
:
],
b
[
:
BLSPrivateKeyLength
])
priv
:=
g1pubs
.
DeserializeSecretKey
(
*
privKeyBytes
)
priv
:=
g1pubs
.
DeserializeSecretKey
(
*
privKeyBytes
)
if
priv
==
nil
{
if
priv
.
GetFRElement
()
==
nil
{
return
nil
,
errors
.
New
(
"invalid bls privkey"
)
return
nil
,
errors
.
New
(
"invalid bls privkey"
)
}
}
privBytes
:=
priv
.
Serialize
()
privBytes
:=
priv
.
Serialize
()
...
...
plugin/dapp/paracross/cmd/build/Dockerfile
View file @
d84308aa
...
@@ -3,7 +3,6 @@ FROM ubuntu:16.04
...
@@ -3,7 +3,6 @@ FROM ubuntu:16.04
WORKDIR
/root
WORKDIR
/root
COPY
chain33 chain33
COPY
chain33 chain33
COPY
chain33-cli chain33-cli
COPY
chain33-cli chain33-cli
COPY
chain33-para-cli chain33-para-cli
COPY
chain33.toml chain33*.toml ./
COPY
chain33.toml chain33*.toml ./
COPY
entrypoint.sh entrypoint.sh
COPY
entrypoint.sh entrypoint.sh
...
...
plugin/dapp/paracross/executor/action.go
View file @
d84308aa
...
@@ -415,7 +415,7 @@ func getValidAddrs(nodes map[string]struct{}, addrs []string) []string {
...
@@ -415,7 +415,7 @@ func getValidAddrs(nodes map[string]struct{}, addrs []string) []string {
//bls签名共识交易验证 大约平均耗时30ms (20~40ms)
//bls签名共识交易验证 大约平均耗时30ms (20~40ms)
func
(
a
*
action
)
procBlsSign
(
nodesArry
[]
string
,
commit
*
pt
.
ParacrossCommitAction
)
([]
string
,
error
)
{
func
(
a
*
action
)
procBlsSign
(
nodesArry
[]
string
,
commit
*
pt
.
ParacrossCommitAction
)
([]
string
,
error
)
{
signAddrs
:=
g
etAddrsByBitMap
(
nodesArry
,
commit
.
Bls
.
AddrsMap
)
signAddrs
:=
util
.
G
etAddrsByBitMap
(
nodesArry
,
commit
.
Bls
.
AddrsMap
)
var
pubs
[]
string
var
pubs
[]
string
for
_
,
addr
:=
range
signAddrs
{
for
_
,
addr
:=
range
signAddrs
{
pub
,
err
:=
getAddrBlsPubKey
(
a
.
db
,
commit
.
Status
.
Title
,
addr
)
pub
,
err
:=
getAddrBlsPubKey
(
a
.
db
,
commit
.
Status
.
Title
,
addr
)
...
@@ -468,7 +468,7 @@ func verifyBlsSign(cryptoCli crypto.Crypto, pubs []string, commit *pt.ParacrossC
...
@@ -468,7 +468,7 @@ func verifyBlsSign(cryptoCli crypto.Crypto, pubs []string, commit *pt.ParacrossC
"addrsMap"
,
common
.
ToHex
(
commit
.
Bls
.
AddrsMap
),
"sign"
,
common
.
ToHex
(
commit
.
Bls
.
Sign
),
"data"
,
common
.
ToHex
(
msg
))
"addrsMap"
,
common
.
ToHex
(
commit
.
Bls
.
AddrsMap
),
"sign"
,
common
.
ToHex
(
commit
.
Bls
.
Sign
),
"data"
,
common
.
ToHex
(
msg
))
return
pt
.
ErrBlsSignVerify
return
pt
.
ErrBlsSignVerify
}
}
clog
.
Info
(
"paracross procBlsSign success"
,
"title"
,
commit
.
Status
.
Title
,
"height"
,
commit
.
Status
.
Height
,
"time"
,
types
.
Since
(
t1
))
clog
.
Debug
(
"paracross procBlsSign success"
,
"title"
,
commit
.
Status
.
Title
,
"height"
,
commit
.
Status
.
Height
,
"time"
,
types
.
Since
(
t1
))
return
nil
return
nil
}
}
...
...
plugin/dapp/paracross/executor/paracross_test.go
View file @
d84308aa
...
@@ -18,6 +18,7 @@ import (
...
@@ -18,6 +18,7 @@ import (
"github.com/33cn/chain33/common/log"
"github.com/33cn/chain33/common/log"
mty
"github.com/33cn/chain33/system/dapp/manage/types"
mty
"github.com/33cn/chain33/system/dapp/manage/types"
"github.com/33cn/chain33/types"
"github.com/33cn/chain33/types"
_
"github.com/33cn/plugin/plugin/crypto/bls"
"github.com/33cn/plugin/plugin/dapp/paracross/testnode"
"github.com/33cn/plugin/plugin/dapp/paracross/testnode"
pt
"github.com/33cn/plugin/plugin/dapp/paracross/types"
pt
"github.com/33cn/plugin/plugin/dapp/paracross/types"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/assert"
...
...
plugin/dapp/paracross/executor/superaccount.go
View file @
d84308aa
...
@@ -9,8 +9,6 @@ import (
...
@@ -9,8 +9,6 @@ import (
"strconv"
"strconv"
"math/big"
"github.com/33cn/chain33/common"
"github.com/33cn/chain33/common"
dbm
"github.com/33cn/chain33/common/db"
dbm
"github.com/33cn/chain33/common/db"
"github.com/33cn/chain33/system/dapp"
"github.com/33cn/chain33/system/dapp"
...
@@ -210,19 +208,6 @@ func makeParaNodeGroupReceipt(title string, prev, current *types.ConfigItem) *ty
...
@@ -210,19 +208,6 @@ func makeParaNodeGroupReceipt(title string, prev, current *types.ConfigItem) *ty
}
}
}
}
//获取nodes范围内的bitmap,如果bitmap超出了nodes范围,也不处理,防止越界
func
getAddrsByBitMap
(
nodes
[]
string
,
bitmap
[]
byte
)
[]
string
{
rst
:=
big
.
NewInt
(
0
)
.
SetBytes
(
bitmap
)
addrs
:=
make
([]
string
,
0
)
for
i
,
a
:=
range
nodes
{
if
rst
.
Bit
(
i
)
==
uint
(
0x1
)
{
addrs
=
append
(
addrs
,
a
)
}
}
return
addrs
}
//get secp256 addr's bls pubkey
//get secp256 addr's bls pubkey
func
getAddrBlsPubKey
(
db
dbm
.
KV
,
title
,
addr
string
)
(
string
,
error
)
{
func
getAddrBlsPubKey
(
db
dbm
.
KV
,
title
,
addr
string
)
(
string
,
error
)
{
addrStat
,
err
:=
getNodeAddr
(
db
,
title
,
addr
)
addrStat
,
err
:=
getNodeAddr
(
db
,
title
,
addr
)
...
...
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