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
a98fbca6
Commit
a98fbca6
authored
Oct 10, 2020
by
QM
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updata
parent
9147f853
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
144 additions
and
130 deletions
+144
-130
parablssign.go
plugin/consensus/para/parablssign.go
+5
-18
testcase.sh
plugin/dapp/paracross/cmd/build/testcase.sh
+8
-8
test-rpc.sh
plugin/dapp/paracross/cmd/test/test-rpc.sh
+1
-1
paracross.go
plugin/dapp/paracross/commands/paracross.go
+38
-3
action.go
plugin/dapp/paracross/executor/action.go
+41
-53
kv.go
plugin/dapp/paracross/executor/kv.go
+0
-8
paracross_test.go
plugin/dapp/paracross/executor/paracross_test.go
+2
-1
query.go
plugin/dapp/paracross/executor/query.go
+4
-23
superaccount.go
plugin/dapp/paracross/executor/superaccount.go
+9
-10
supervisionaccount.go
plugin/dapp/paracross/executor/supervisionaccount.go
+0
-0
supervisionaccount_test.go
plugin/dapp/paracross/executor/supervisionaccount_test.go
+27
-5
paracross.proto
plugin/dapp/paracross/proto/paracross.proto
+2
-0
errors.go
plugin/dapp/paracross/types/errors.go
+2
-0
paracross.go
plugin/dapp/paracross/types/paracross.go
+5
-0
paracross.pb.go
plugin/dapp/paracross/types/paracross.pb.go
+0
-0
No files found.
plugin/consensus/para/parablssign.go
View file @
a98fbca6
...
@@ -212,9 +212,8 @@ func (b *blsClient) getSuperNodes() ([]string, string) {
...
@@ -212,9 +212,8 @@ func (b *blsClient) getSuperNodes() ([]string, string) {
nodes
,
nodeStr
:=
b
.
getSuperGroupNodes
()
nodes
,
nodeStr
:=
b
.
getSuperGroupNodes
()
if
len
(
nodes
)
>
0
{
if
len
(
nodes
)
>
0
{
return
nodes
,
nodeStr
return
nodes
,
nodeStr
}
else
{
return
b
.
getSupervisionGroupNodes
()
}
}
return
b
.
getSupervisionGroupNodes
()
}
else
if
b
.
typeNode
==
pt
.
ParaCommitSuperNode
{
}
else
if
b
.
typeNode
==
pt
.
ParaCommitSuperNode
{
return
b
.
getSuperGroupNodes
()
return
b
.
getSuperGroupNodes
()
}
else
if
b
.
typeNode
==
pt
.
ParaCommitSupervisionNode
{
}
else
if
b
.
typeNode
==
pt
.
ParaCommitSupervisionNode
{
...
@@ -521,14 +520,6 @@ func (b *blsClient) blsSign(commits []*pt.ParacrossCommitAction) error {
...
@@ -521,14 +520,6 @@ func (b *blsClient) blsSign(commits []*pt.ParacrossCommitAction) error {
}
}
func
(
b
*
blsClient
)
getBlsPubKey
(
addr
string
)
(
crypto
.
PubKey
,
error
)
{
func
(
b
*
blsClient
)
getBlsPubKey
(
addr
string
)
(
crypto
.
PubKey
,
error
)
{
if
b
.
typeNode
==
pt
.
ParaCommitSuperNode
||
b
.
typeNode
==
pt
.
ParaCommitSupervisionNode
{
var
funcName
string
if
b
.
typeNode
==
pt
.
ParaCommitSuperNode
{
funcName
=
"GetNodeAddrInfo"
}
else
{
funcName
=
"GetSupervisionNodeAddrInfo"
}
//先从缓存中获取
//先从缓存中获取
if
v
,
ok
:=
b
.
peersBlsPubKey
[
addr
];
ok
{
if
v
,
ok
:=
b
.
peersBlsPubKey
[
addr
];
ok
{
return
v
,
nil
return
v
,
nil
...
@@ -538,22 +529,22 @@ func (b *blsClient) getBlsPubKey(addr string) (crypto.PubKey, error) {
...
@@ -538,22 +529,22 @@ func (b *blsClient) getBlsPubKey(addr string) (crypto.PubKey, error) {
cfg
:=
b
.
paraClient
.
GetAPI
()
.
GetConfig
()
cfg
:=
b
.
paraClient
.
GetAPI
()
.
GetConfig
()
ret
,
err
:=
b
.
paraClient
.
GetAPI
()
.
QueryChain
(
&
types
.
ChainExecutor
{
ret
,
err
:=
b
.
paraClient
.
GetAPI
()
.
QueryChain
(
&
types
.
ChainExecutor
{
Driver
:
"paracross"
,
Driver
:
"paracross"
,
FuncName
:
funcName
,
FuncName
:
"GetNodeAddrInfo"
,
Param
:
types
.
Encode
(
&
pt
.
ReqParacrossNodeInfo
{
Title
:
cfg
.
GetTitle
(),
Addr
:
addr
}),
Param
:
types
.
Encode
(
&
pt
.
ReqParacrossNodeInfo
{
Title
:
cfg
.
GetTitle
(),
Addr
:
addr
}),
})
})
if
err
!=
nil
{
if
err
!=
nil
{
plog
.
Error
(
"commitmsg.GetNodeAddrInfo "
,
"funcName"
,
funcName
,
"err"
,
err
.
Error
())
plog
.
Error
(
"commitmsg.GetNodeAddrInfo "
,
"err"
,
err
.
Error
())
return
nil
,
err
return
nil
,
err
}
}
resp
,
ok
:=
ret
.
(
*
pt
.
ParaNodeAddrIdStatus
)
resp
,
ok
:=
ret
.
(
*
pt
.
ParaNodeAddrIdStatus
)
if
!
ok
{
if
!
ok
{
plog
.
Error
(
"commitmsg.getNodeGroupAddrs rsp nok"
,
"funcName"
,
funcName
)
plog
.
Error
(
"commitmsg.getNodeGroupAddrs rsp nok"
)
return
nil
,
err
return
nil
,
err
}
}
s
,
err
:=
common
.
FromHex
(
resp
.
BlsPubKey
)
s
,
err
:=
common
.
FromHex
(
resp
.
BlsPubKey
)
if
err
!=
nil
{
if
err
!=
nil
{
plog
.
Error
(
"commitmsg.getNode pubkey nok"
,
"pubkey"
,
resp
.
BlsPubKey
,
"funcName"
,
funcName
)
plog
.
Error
(
"commitmsg.getNode pubkey nok"
,
"pubkey"
,
resp
.
BlsPubKey
)
return
nil
,
err
return
nil
,
err
}
}
pubKey
,
err
:=
b
.
cryptoCli
.
PubKeyFromBytes
(
s
)
pubKey
,
err
:=
b
.
cryptoCli
.
PubKeyFromBytes
(
s
)
...
@@ -565,10 +556,6 @@ func (b *blsClient) getBlsPubKey(addr string) (crypto.PubKey, error) {
...
@@ -565,10 +556,6 @@ func (b *blsClient) getBlsPubKey(addr string) (crypto.PubKey, error) {
b
.
peersBlsPubKey
[
addr
]
=
pubKey
b
.
peersBlsPubKey
[
addr
]
=
pubKey
return
pubKey
,
nil
return
pubKey
,
nil
}
return
nil
,
errors
.
New
(
"b.typeNode = pt.ParaCommitNode"
)
}
}
func
(
b
*
blsClient
)
verifyBlsSign
(
addr
string
,
commit
*
pt
.
ParacrossCommitAction
)
error
{
func
(
b
*
blsClient
)
verifyBlsSign
(
addr
string
,
commit
*
pt
.
ParacrossCommitAction
)
error
{
...
...
plugin/dapp/paracross/cmd/build/testcase.sh
View file @
a98fbca6
...
@@ -260,7 +260,7 @@ function para_configkey() {
...
@@ -260,7 +260,7 @@ function para_configkey() {
function
query_tx
()
{
function
query_tx
()
{
block_wait
"
${
1
}
"
1
block_wait
"
${
1
}
"
1
local times
=
20
0
local times
=
20
while
true
;
do
while
true
;
do
ret
=
$(${
1
}
tx query
-s
"
${
2
}
"
| jq
-r
".tx.hash"
)
ret
=
$(${
1
}
tx query
-s
"
${
2
}
"
| jq
-r
".tx.hash"
)
echo
"query hash is
${
2
}
, return
${
ret
}
"
echo
"query hash is
${
2
}
, return
${
ret
}
"
...
@@ -770,17 +770,17 @@ function para_create_supervision_nodegroup() {
...
@@ -770,17 +770,17 @@ function para_create_supervision_nodegroup() {
check_balance_1ka
"
$balancePre
"
6
check_balance_1ka
"
$balancePre
"
6
echo
"=========== # para chain
quit
supervision node group ============="
echo
"=========== # para chain
cancel
supervision node group ============="
balancePre
=
$(${
CLI
}
account balance
-a
1Ka7EPFRqs3v9yreXG6qA4RQbNmbPJCZPj
-e
paracross | jq
-r
".frozen"
)
balancePre
=
$(${
CLI
}
account balance
-a
1Ka7EPFRqs3v9yreXG6qA4RQbNmbPJCZPj
-e
paracross | jq
-r
".frozen"
)
##
quit
##
cancel
txhash
=
$(${
PARA_CLI
}
send para supervision_node
quit
-i
"
$id
"
-k
0xd165c84ed37c2a427fea487470ee671b7a0495d68d82607cafbc6348bf23bec5
)
txhash
=
$(${
PARA_CLI
}
send para supervision_node
cancel
-i
"
$id
"
-k
0xd165c84ed37c2a427fea487470ee671b7a0495d68d82607cafbc6348bf23bec5
)
echo
"tx=
$txhash
"
echo
"tx=
$txhash
"
query_tx
"
${
PARA_CLI
}
"
"
${
txhash
}
"
query_tx
"
${
PARA_CLI
}
"
"
${
txhash
}
"
newid
=
$(${
PARA_CLI
}
para supervision_node list
-s
3
| jq
-r
".ids[0].id"
)
newid
=
$(${
PARA_CLI
}
para supervision_node list
-s
4
| jq
-r
".ids[0].id"
)
if
[
-z
"
$newid
"
]
;
then
if
[
-z
"
$newid
"
]
;
then
${
PARA_CLI
}
para supervision_node list
-s
3
${
PARA_CLI
}
para supervision_node list
-s
4
echo
"
quit
status error "
echo
"
cancel
status error "
exit
1
#
exit 1
fi
fi
check_balance_1ka
"
$balancePre
"
-6
check_balance_1ka
"
$balancePre
"
-6
...
...
plugin/dapp/paracross/cmd/test/test-rpc.sh
View file @
a98fbca6
...
@@ -237,7 +237,7 @@ function paracross_GetSupervisionInfo() {
...
@@ -237,7 +237,7 @@ function paracross_GetSupervisionInfo() {
chain33_Http
'{"method":"Chain33.Query","params":[{ "execer":"paracross", "funcName":"GetSupervisionNodeGroupAddrs","payload":{"title":"user.p.para."}}]}'
${
UNIT_HTTP
}
'(.error|not) and (.result| [has("key","value"),true])'
"GetSupervisionNodeGroupAddrs"
chain33_Http
'{"method":"Chain33.Query","params":[{ "execer":"paracross", "funcName":"GetSupervisionNodeGroupAddrs","payload":{"title":"user.p.para."}}]}'
${
UNIT_HTTP
}
'(.error|not) and (.result| [has("key","value"),true])'
"GetSupervisionNodeGroupAddrs"
chain33_Http
'{"method":"Chain33.Query","params":[{ "execer":"paracross", "funcName":"GetSupervisionNodeGroupStatus","payload":{"title":"user.p.para."}}]}'
${
UNIT_HTTP
}
'(.error|not) and (.result| [has("status"),true])'
"GetSupervisionNodeGroupStatus"
chain33_Http
'{"method":"Chain33.Query","params":[{ "execer":"paracross", "funcName":"GetSupervisionNodeGroupStatus","payload":{"title":"user.p.para."}}]}'
${
UNIT_HTTP
}
'(.error|not) and (.result| [has("status"),true])'
"GetSupervisionNodeGroupStatus"
chain33_Http
'{"method":"Chain33.Query","params":[{ "execer":"paracross", "funcName":"ListSupervisionNodeGroupStatus","payload":{"title":"user.p.para.","status":2}}]}'
${
UNIT_HTTP
}
'(.error|not) and (.result| [has("status"),true])'
"ListSupervisionNodeGroupStatus status:2"
chain33_Http
'{"method":"Chain33.Query","params":[{ "execer":"paracross", "funcName":"ListSupervisionNodeGroupStatus","payload":{"title":"user.p.para.","status":2}}]}'
${
UNIT_HTTP
}
'(.error|not) and (.result| [has("status"),true])'
"ListSupervisionNodeGroupStatus status:2"
chain33_Http
'{"method":"Chain33.Query","params":[{ "execer":"paracross", "funcName":"ListSupervisionNodeGroupStatus","payload":{"title":"user.p.para.","status":
3}}]}'
${
UNIT_HTTP
}
'(.error|not) and (.result| [has("status"),true])'
"ListSupervisionNodeGroupStatus status:3
"
chain33_Http
'{"method":"Chain33.Query","params":[{ "execer":"paracross", "funcName":"ListSupervisionNodeGroupStatus","payload":{"title":"user.p.para.","status":
4}}]}'
${
UNIT_HTTP
}
'(.error|not) and (.result| [has("status"),true])'
"ListSupervisionNodeGroupStatus status:4
"
}
}
para_test_addr
=
"1MAuE8QSbbech3bVKK2JPJJxYxNtT95oSU"
para_test_addr
=
"1MAuE8QSbbech3bVKK2JPJJxYxNtT95oSU"
...
...
plugin/dapp/paracross/commands/paracross.go
View file @
a98fbca6
...
@@ -1522,6 +1522,7 @@ func supervisionNodeCmd() *cobra.Command {
...
@@ -1522,6 +1522,7 @@ func supervisionNodeCmd() *cobra.Command {
cmd
.
AddCommand
(
supervisionNodeApplyCmd
())
cmd
.
AddCommand
(
supervisionNodeApplyCmd
())
cmd
.
AddCommand
(
supervisionNodeApproveCmd
())
cmd
.
AddCommand
(
supervisionNodeApproveCmd
())
cmd
.
AddCommand
(
supervisionNodeQuitCmd
())
cmd
.
AddCommand
(
supervisionNodeQuitCmd
())
cmd
.
AddCommand
(
supervisionNodeCancelCmd
())
cmd
.
AddCommand
(
getSupervisionNodeGroupAddrsCmd
())
cmd
.
AddCommand
(
getSupervisionNodeGroupAddrsCmd
())
cmd
.
AddCommand
(
supervisionNodeGroupStatusCmd
())
cmd
.
AddCommand
(
supervisionNodeGroupStatusCmd
())
...
@@ -1623,18 +1624,52 @@ func supervisionNodeQuitCmd() *cobra.Command {
...
@@ -1623,18 +1624,52 @@ func supervisionNodeQuitCmd() *cobra.Command {
}
}
func
addSupervisionNodeQuitCmdFlags
(
cmd
*
cobra
.
Command
)
{
func
addSupervisionNodeQuitCmdFlags
(
cmd
*
cobra
.
Command
)
{
cmd
.
Flags
()
.
StringP
(
"
id"
,
"i
"
,
""
,
"apply quit id for supervision node"
)
cmd
.
Flags
()
.
StringP
(
"
addr"
,
"a
"
,
""
,
"apply quit id for supervision node"
)
_
=
cmd
.
MarkFlagRequired
(
"
id
"
)
_
=
cmd
.
MarkFlagRequired
(
"
addr
"
)
}
}
func
supervisionNodeQuit
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
supervisionNodeQuit
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
paraName
,
_
:=
cmd
.
Flags
()
.
GetString
(
"paraName"
)
paraName
,
_
:=
cmd
.
Flags
()
.
GetString
(
"paraName"
)
opAddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"addr"
)
if
!
strings
.
HasPrefix
(
paraName
,
"user.p"
)
{
_
,
_
=
fmt
.
Fprintln
(
os
.
Stderr
,
"paraName is not right, paraName format like `user.p.guodun.`"
)
return
}
payload
:=
&
pt
.
ParaNodeAddrConfig
{
Title
:
paraName
,
Op
:
3
,
Addr
:
opAddr
}
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
getRealExecName
(
paraName
,
pt
.
ParaX
),
ActionName
:
"SupervisionNodeGroupConfig"
,
Payload
:
types
.
MustPBToJSON
(
payload
),
}
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
ctx
:=
jsonclient
.
NewRPCCtx
(
rpcLaddr
,
"Chain33.CreateTransaction"
,
params
,
nil
)
ctx
.
RunWithoutMarshal
()
}
func
supervisionNodeCancelCmd
()
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"cancel"
,
Short
:
"cancel for para chain's supervision node application"
,
Run
:
supervisionNodeCancel
,
}
addSupervisionNodeCancelCmdFlags
(
cmd
)
return
cmd
}
func
addSupervisionNodeCancelCmdFlags
(
cmd
*
cobra
.
Command
)
{
cmd
.
Flags
()
.
StringP
(
"id"
,
"i"
,
""
,
"apply cancel id for supervision node"
)
_
=
cmd
.
MarkFlagRequired
(
"id"
)
}
func
supervisionNodeCancel
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
paraName
,
_
:=
cmd
.
Flags
()
.
GetString
(
"paraName"
)
id
,
_
:=
cmd
.
Flags
()
.
GetString
(
"id"
)
id
,
_
:=
cmd
.
Flags
()
.
GetString
(
"id"
)
if
!
strings
.
HasPrefix
(
paraName
,
"user.p"
)
{
if
!
strings
.
HasPrefix
(
paraName
,
"user.p"
)
{
_
,
_
=
fmt
.
Fprintln
(
os
.
Stderr
,
"paraName is not right, paraName format like `user.p.guodun.`"
)
_
,
_
=
fmt
.
Fprintln
(
os
.
Stderr
,
"paraName is not right, paraName format like `user.p.guodun.`"
)
return
return
}
}
payload
:=
&
pt
.
ParaNodeAddrConfig
{
Title
:
paraName
,
Op
:
3
,
Id
:
id
}
payload
:=
&
pt
.
ParaNodeAddrConfig
{
Title
:
paraName
,
Op
:
4
,
Id
:
id
}
params
:=
&
rpctypes
.
CreateTxIn
{
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
getRealExecName
(
paraName
,
pt
.
ParaX
),
Execer
:
getRealExecName
(
paraName
,
pt
.
ParaX
),
ActionName
:
"SupervisionNodeGroupConfig"
,
ActionName
:
"SupervisionNodeGroupConfig"
,
...
...
plugin/dapp/paracross/executor/action.go
View file @
a98fbca6
...
@@ -452,30 +452,20 @@ func getValidAddrs(nodes map[string]struct{}, addrs []string) []string {
...
@@ -452,30 +452,20 @@ func getValidAddrs(nodes map[string]struct{}, addrs []string) []string {
}
}
//get secp256 addr's bls pubkey
//get secp256 addr's bls pubkey
func
getAddrBlsPubKey
(
db
dbm
.
KV
,
title
,
addr
string
,
commitNodeType
uint32
)
(
string
,
error
)
{
func
getAddrBlsPubKey
(
db
dbm
.
KV
,
title
,
addr
string
)
(
string
,
error
)
{
if
commitNodeType
==
pt
.
ParaCommitSuperNode
{
addrStat
,
err
:=
getNodeAddr
(
db
,
title
,
addr
)
addrStat
,
err
:=
getNodeAddr
(
db
,
title
,
addr
)
if
err
!=
nil
{
if
err
!=
nil
{
return
""
,
errors
.
Wrapf
(
err
,
"nodeAddr:%s-%s get error"
,
title
,
addr
)
return
""
,
errors
.
Wrapf
(
err
,
"nodeAddr:%s-%s get error"
,
title
,
addr
)
}
}
return
addrStat
.
BlsPubKey
,
nil
return
addrStat
.
BlsPubKey
,
nil
}
else
if
commitNodeType
==
pt
.
ParaCommitSupervisionNode
{
addrStat
,
err
:=
getSupervisionNodeAddr
(
db
,
title
,
addr
)
if
err
!=
nil
{
return
""
,
errors
.
Wrapf
(
err
,
"Supervision nodeAddr:%s-%s get error"
,
title
,
addr
)
}
return
addrStat
.
BlsPubKey
,
nil
}
else
{
return
""
,
errors
.
New
(
"commitNodeType is ParaCommitNode"
)
}
}
}
//bls签名共识交易验证 大约平均耗时3ms (2~4ms)
//bls签名共识交易验证 大约平均耗时3ms (2~4ms)
func
(
a
*
action
)
procBlsSign
(
nodesArry
[]
string
,
commit
*
pt
.
ParacrossCommitAction
,
commitNodeType
uint32
)
([]
string
,
error
)
{
func
(
a
*
action
)
procBlsSign
(
nodesArry
[]
string
,
commit
*
pt
.
ParacrossCommitAction
)
([]
string
,
error
)
{
signAddrs
:=
util
.
GetAddrsByBitMap
(
nodesArry
,
commit
.
Bls
.
AddrsMap
)
signAddrs
:=
util
.
GetAddrsByBitMap
(
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
,
commitNodeType
)
pub
,
err
:=
getAddrBlsPubKey
(
a
.
db
,
commit
.
Status
.
Title
,
addr
/*, commitNodeType*/
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
errors
.
Wrapf
(
err
,
"pubkey not exist to addr=%s"
,
addr
)
return
nil
,
errors
.
Wrapf
(
err
,
"pubkey not exist to addr=%s"
,
addr
)
}
}
...
@@ -529,6 +519,25 @@ func verifyBlsSign(cryptoCli crypto.Crypto, pubs []string, commit *pt.ParacrossC
...
@@ -529,6 +519,25 @@ func verifyBlsSign(cryptoCli crypto.Crypto, pubs []string, commit *pt.ParacrossC
return
nil
return
nil
}
}
func
(
a
*
action
)
getValidCommitAddrs
(
commit
*
pt
.
ParacrossCommitAction
,
nodesMap
map
[
string
]
struct
{},
nodesArry
[]
string
)
([]
string
,
error
)
{
//获取commitAddrs, bls sign 包含多个账户的聚合签名
commitAddrs
:=
[]
string
{
a
.
fromaddr
}
if
commit
.
Bls
!=
nil
{
addrs
,
err
:=
a
.
procBlsSign
(
nodesArry
,
commit
)
if
err
!=
nil
{
return
nil
,
errors
.
Wrap
(
err
,
"procBlsSign"
)
}
commitAddrs
=
addrs
}
validAddrs
:=
getValidAddrs
(
nodesMap
,
commitAddrs
)
if
len
(
validAddrs
)
<=
0
{
return
nil
,
errors
.
Wrapf
(
errors
.
New
(
"getValidAddrs error"
),
"getValidAddrs nil commitAddrs=%s "
,
strings
.
Join
(
commitAddrs
,
","
))
}
return
validAddrs
,
nil
}
//共识commit msg 处理
//共识commit msg 处理
func
(
a
*
action
)
Commit
(
commit
*
pt
.
ParacrossCommitAction
)
(
*
types
.
Receipt
,
error
)
{
func
(
a
*
action
)
Commit
(
commit
*
pt
.
ParacrossCommitAction
)
(
*
types
.
Receipt
,
error
)
{
cfg
:=
a
.
api
.
GetConfig
()
cfg
:=
a
.
api
.
GetConfig
()
...
@@ -545,31 +554,17 @@ func (a *action) Commit(commit *pt.ParacrossCommitAction) (*types.Receipt, error
...
@@ -545,31 +554,17 @@ func (a *action) Commit(commit *pt.ParacrossCommitAction) (*types.Receipt, error
return
nil
,
errors
.
Wrap
(
err
,
"getNodesGroup"
)
return
nil
,
errors
.
Wrap
(
err
,
"getNodesGroup"
)
}
}
var
commitAddrs
,
commitSupervisionAddrs
,
validAddrs
,
supervisionValidAddrs
[]
string
var
validAddrs
,
supervisionValidAddrs
[]
string
bIsCommitSuperNode
:=
false
bIsCommitSuperNode
:=
false
bIsCommitSupervisionNode
:=
false
bIsCommitSupervisionNode
:=
false
for
_
,
addr
:=
range
nodesArry
{
if
_
,
exist
:=
nodesMap
[
a
.
fromaddr
];
exist
{
if
addr
==
a
.
fromaddr
{
validAddrs
,
err
=
a
.
getValidCommitAddrs
(
commit
,
nodesMap
,
nodesArry
)
// 授权节点共识
//获取commitAddrs, bls sign 包含多个账户的聚合签名
commitAddrs
=
[]
string
{
a
.
fromaddr
}
if
commit
.
Bls
!=
nil
{
addrs
,
err
:=
a
.
procBlsSign
(
nodesArry
,
commit
,
pt
.
ParaCommitSuperNode
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
errors
.
Wrap
(
err
,
"procBlsSign"
)
return
nil
,
errors
.
Wrap
(
err
,
"getValidCommitAddrs"
)
}
commitAddrs
=
addrs
}
validAddrs
=
getValidAddrs
(
nodesMap
,
commitAddrs
)
if
len
(
validAddrs
)
<=
0
{
return
nil
,
errors
.
Wrapf
(
err
,
"getValidAddrs nil commitAddrs=%s "
,
strings
.
Join
(
commitAddrs
,
","
))
}
}
bIsCommitSuperNode
=
true
bIsCommitSuperNode
=
true
break
}
}
}
// 获取监督节点的数据 监督节点在高度分叉后
// 获取监督节点的数据 监督节点在高度分叉后
...
@@ -579,27 +574,12 @@ func (a *action) Commit(commit *pt.ParacrossCommitAction) (*types.Receipt, error
...
@@ -579,27 +574,12 @@ func (a *action) Commit(commit *pt.ParacrossCommitAction) (*types.Receipt, error
}
}
if
!
bIsCommitSuperNode
{
if
!
bIsCommitSuperNode
{
for
_
,
addr
:=
range
supervisionNodesArry
{
if
_
,
exist
:=
supervisionNodesMap
[
a
.
fromaddr
];
exist
{
if
addr
==
a
.
fromaddr
{
supervisionValidAddrs
,
err
=
a
.
getValidCommitAddrs
(
commit
,
supervisionNodesMap
,
supervisionNodesArry
)
// 监督节点共识
//获取commitAddrs, bls sign 包含多个账户的聚合签名
commitSupervisionAddrs
=
[]
string
{
a
.
fromaddr
}
if
commit
.
Bls
!=
nil
{
addrs
,
err
:=
a
.
procBlsSign
(
supervisionNodesArry
,
commit
,
pt
.
ParaCommitSupervisionNode
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
errors
.
Wrap
(
err
,
"procBlsSign
"
)
return
nil
,
errors
.
Wrap
(
err
,
"getValidCommitAddrs
"
)
}
}
commitSupervisionAddrs
=
addrs
}
supervisionValidAddrs
=
getValidAddrs
(
supervisionNodesMap
,
commitSupervisionAddrs
)
if
len
(
supervisionValidAddrs
)
<=
0
{
return
nil
,
errors
.
Wrapf
(
err
,
"getValidAddrs nil commitSupervisionAddrs=%s"
,
strings
.
Join
(
commitSupervisionAddrs
,
","
))
}
bIsCommitSupervisionNode
=
true
bIsCommitSupervisionNode
=
true
break
}
}
}
}
}
...
@@ -650,12 +630,14 @@ func (a *action) proCommitMsg(commit *pt.ParacrossNodeStatus, nodes map[string]s
...
@@ -650,12 +630,14 @@ func (a *action) proCommitMsg(commit *pt.ParacrossNodeStatus, nodes map[string]s
Title
:
commit
.
Title
,
Title
:
commit
.
Title
,
Height
:
commit
.
Height
,
Height
:
commit
.
Height
,
Details
:
&
pt
.
ParacrossStatusDetails
{},
Details
:
&
pt
.
ParacrossStatusDetails
{},
SupervisionDetails
:
&
pt
.
ParacrossStatusDetails
{},
}
}
if
pt
.
IsParaForkHeight
(
cfg
,
a
.
exec
.
GetMainHeight
(),
pt
.
ForkCommitTx
)
{
if
pt
.
IsParaForkHeight
(
cfg
,
a
.
exec
.
GetMainHeight
(),
pt
.
ForkCommitTx
)
{
stat
.
MainHeight
=
commit
.
MainBlockHeight
stat
.
MainHeight
=
commit
.
MainBlockHeight
stat
.
MainHash
=
commit
.
MainBlockHash
stat
.
MainHash
=
commit
.
MainBlockHash
}
}
if
pt
.
IsParaForkHeight
(
cfg
,
a
.
exec
.
GetMainHeight
(),
pt
.
ForkParaSupervision
)
{
stat
.
SupervisionDetails
=
&
pt
.
ParacrossStatusDetails
{}
}
}
else
{
}
else
{
copyStat
=
proto
.
Clone
(
stat
)
.
(
*
pt
.
ParacrossHeightStatus
)
copyStat
=
proto
.
Clone
(
stat
)
.
(
*
pt
.
ParacrossHeightStatus
)
}
}
...
@@ -692,7 +674,7 @@ func (a *action) proCommitMsg(commit *pt.ParacrossNodeStatus, nodes map[string]s
...
@@ -692,7 +674,7 @@ func (a *action) proCommitMsg(commit *pt.ParacrossNodeStatus, nodes map[string]s
//平行链fork pt.ForkCommitTx=0,主链在ForkCommitTx后支持nodegroup,这里平行链dappFork一定为true
//平行链fork pt.ForkCommitTx=0,主链在ForkCommitTx后支持nodegroup,这里平行链dappFork一定为true
if
cfg
.
IsDappFork
(
commit
.
MainBlockHeight
,
pt
.
ParaX
,
pt
.
ForkCommitTx
)
{
if
cfg
.
IsDappFork
(
commit
.
MainBlockHeight
,
pt
.
ParaX
,
pt
.
ForkCommitTx
)
{
updateCommitAddrs
(
stat
,
nodes
)
updateCommitAddrs
(
stat
,
nodes
)
updateSupervisionDetailsCommitAddrs
(
stat
,
supervisionNodes
)
//updateSupervisionDetailsCommitAddrs(stat, supervisionNodes) // ???
}
}
_
=
saveTitleHeight
(
a
.
db
,
calcTitleHeightKey
(
stat
.
Title
,
stat
.
Height
),
stat
)
_
=
saveTitleHeight
(
a
.
db
,
calcTitleHeightKey
(
stat
.
Title
,
stat
.
Height
),
stat
)
//fork之前记录的stat 没有根据nodes更新而更新
//fork之前记录的stat 没有根据nodes更新而更新
...
@@ -736,6 +718,7 @@ func (a *action) commitTxDone(nodeStatus *pt.ParacrossNodeStatus, stat *pt.Parac
...
@@ -736,6 +718,7 @@ func (a *action) commitTxDone(nodeStatus *pt.ParacrossNodeStatus, stat *pt.Parac
return
receipt
,
nil
return
receipt
,
nil
}
}
clog
.
Debug
(
"paracross.Commit commit ----pass"
,
"most"
,
mostCount
,
"mostHash"
,
common
.
ToHex
([]
byte
(
mostHash
)))
// 如果已经有监督节点
// 如果已经有监督节点
if
len
(
supervisionNodes
)
>
0
{
if
len
(
supervisionNodes
)
>
0
{
for
i
,
v
:=
range
stat
.
SupervisionDetails
.
Addrs
{
for
i
,
v
:=
range
stat
.
SupervisionDetails
.
Addrs
{
...
@@ -746,9 +729,14 @@ func (a *action) commitTxDone(nodeStatus *pt.ParacrossNodeStatus, stat *pt.Parac
...
@@ -746,9 +729,14 @@ func (a *action) commitTxDone(nodeStatus *pt.ParacrossNodeStatus, stat *pt.Parac
return
receipt
,
nil
return
receipt
,
nil
}
}
clog
.
Debug
(
"paracross.Commit commit SupervisionDetails ----pass"
,
"mostSupervisionCount"
,
mostSupervisionCount
,
"mostSupervisionHash"
,
common
.
ToHex
([]
byte
(
mostSupervisionHash
)))
clog
.
Debug
(
"paracross.Commit commit SupervisionDetails ----pass"
,
"mostSupervisionCount"
,
mostSupervisionCount
,
"mostSupervisionHash"
,
common
.
ToHex
([]
byte
(
mostSupervisionHash
)))
if
common
.
ToHex
([]
byte
(
mostHash
))
!=
common
.
ToHex
([]
byte
(
mostSupervisionHash
))
{
clog
.
Debug
(
"paracross.Commit commit mostSupervisionHash mostHash not equal"
)
return
receipt
,
nil
}
}
}
clog
.
Debug
(
"paracross.Commit commit ----pass"
)
clog
.
Debug
(
"paracross.Commit commit ----pass"
,
"most"
,
mostCount
,
"mostHash"
,
common
.
ToHex
([]
byte
(
mostHash
)))
stat
.
Status
=
pt
.
ParacrossStatusCommitDone
stat
.
Status
=
pt
.
ParacrossStatusCommitDone
_
=
saveTitleHeight
(
a
.
db
,
calcTitleHeightKey
(
stat
.
Title
,
stat
.
Height
),
stat
)
_
=
saveTitleHeight
(
a
.
db
,
calcTitleHeightKey
(
stat
.
Title
,
stat
.
Height
),
stat
)
...
@@ -929,7 +917,7 @@ func (a *action) commitTxDoneByStat(stat *pt.ParacrossHeightStatus, titleStatus
...
@@ -929,7 +917,7 @@ func (a *action) commitTxDoneByStat(stat *pt.ParacrossHeightStatus, titleStatus
}
}
clog
.
Debug
(
"paracross.commitTxDoneByStat ----pass"
,
"most"
,
most
,
"mostHash"
,
common
.
ToHex
([]
byte
(
mostHash
)))
clog
.
Debug
(
"paracross.commitTxDoneByStat ----pass"
,
"most"
,
most
,
"mostHash"
,
common
.
ToHex
([]
byte
(
mostHash
)))
stat
.
Status
=
pt
.
ParacrossStatusCommitDone
stat
.
Status
=
pt
.
ParacrossStatusCommitDone
saveTitleHeight
(
a
.
db
,
calcTitleHeightKey
(
stat
.
Title
,
stat
.
Height
),
stat
)
_
=
saveTitleHeight
(
a
.
db
,
calcTitleHeightKey
(
stat
.
Title
,
stat
.
Height
),
stat
)
r
:=
makeCommitStatReceipt
(
stat
)
r
:=
makeCommitStatReceipt
(
stat
)
receipt
=
mergeReceipt
(
receipt
,
r
)
receipt
=
mergeReceipt
(
receipt
,
r
)
...
...
plugin/dapp/paracross/executor/kv.go
View file @
a98fbca6
...
@@ -41,11 +41,9 @@ var (
...
@@ -41,11 +41,9 @@ var (
//监督节点
//监督节点
paraSupervisionNodes
string
paraSupervisionNodes
string
paraSupervisionNodeAddr
string
paraSupervisionNodeGroupStatusAddrs
string
paraSupervisionNodeGroupStatusAddrs
string
paraSupervisionNodeGroupIDPrefix
string
paraSupervisionNodeGroupIDPrefix
string
paraSupervisionSelfConsensStages
string
paraSupervisionSelfConsensStages
string
paraSupervisionSelfConsensStageIDPrefix
string
localSupervisionNodeGroupStatusTitle
string
localSupervisionNodeGroupStatusTitle
string
)
)
...
@@ -78,11 +76,9 @@ func setPrefix() {
...
@@ -78,11 +76,9 @@ func setPrefix() {
localNodeGroupStatusTitle
=
"LODB-paracross-nodegroupStatusTitle-"
localNodeGroupStatusTitle
=
"LODB-paracross-nodegroupStatusTitle-"
paraSupervisionNodes
=
"mavl-paracross-supervision-nodes-title-"
paraSupervisionNodes
=
"mavl-paracross-supervision-nodes-title-"
paraSupervisionNodeAddr
=
"mavl-paracross-supervision-nodes-titleAddr-"
paraSupervisionNodeGroupStatusAddrs
=
"mavl-paracross-supervision-nodegroup-apply-title-"
paraSupervisionNodeGroupStatusAddrs
=
"mavl-paracross-supervision-nodegroup-apply-title-"
paraSupervisionNodeGroupIDPrefix
=
"mavl-paracross-title-nodegroupid-supervision-"
paraSupervisionNodeGroupIDPrefix
=
"mavl-paracross-title-nodegroupid-supervision-"
paraSupervisionSelfConsensStages
=
"mavl-paracross-supervision-selfconsens-stages-"
paraSupervisionSelfConsensStages
=
"mavl-paracross-supervision-selfconsens-stages-"
paraSupervisionSelfConsensStageIDPrefix
=
"mavl-paracross-selfconsens-id-supervision-"
localSupervisionNodeGroupStatusTitle
=
"LODB-paracross-supervision-nodegroupStatusTitle-"
localSupervisionNodeGroupStatusTitle
=
"LODB-paracross-supervision-nodegroupStatusTitle-"
}
}
...
@@ -234,10 +230,6 @@ func calcParaSupervisionNodeGroupStatusKey(title string) []byte {
...
@@ -234,10 +230,6 @@ func calcParaSupervisionNodeGroupStatusKey(title string) []byte {
return
[]
byte
(
fmt
.
Sprintf
(
paraSupervisionNodeGroupStatusAddrs
+
"%s"
,
title
))
return
[]
byte
(
fmt
.
Sprintf
(
paraSupervisionNodeGroupStatusAddrs
+
"%s"
,
title
))
}
}
func
calcParaSupervisionNodeAddrKey
(
title
string
,
addr
string
)
[]
byte
{
return
[]
byte
(
fmt
.
Sprintf
(
paraSupervisionNodeAddr
+
"%s-%s"
,
title
,
addr
))
}
func
calcParaSupervisionNodeGroupIDKey
(
title
,
hash
string
)
string
{
func
calcParaSupervisionNodeGroupIDKey
(
title
,
hash
string
)
string
{
return
fmt
.
Sprintf
(
paraSupervisionNodeGroupIDPrefix
+
"%s-%s"
,
title
,
hash
)
return
fmt
.
Sprintf
(
paraSupervisionNodeGroupIDPrefix
+
"%s-%s"
,
title
,
hash
)
}
}
plugin/dapp/paracross/executor/paracross_test.go
View file @
a98fbca6
...
@@ -295,7 +295,9 @@ func checkCommitReceipt(suite *CommitTestSuite, receipt *types.Receipt, commitCn
...
@@ -295,7 +295,9 @@ func checkCommitReceipt(suite *CommitTestSuite, receipt *types.Receipt, commitCn
assert
.
Equal
(
suite
.
T
(),
int32
(
pt
.
ParacrossStatusCommiting
),
titleHeight
.
Status
)
assert
.
Equal
(
suite
.
T
(),
int32
(
pt
.
ParacrossStatusCommiting
),
titleHeight
.
Status
)
assert
.
Equal
(
suite
.
T
(),
Title
,
titleHeight
.
Title
)
assert
.
Equal
(
suite
.
T
(),
Title
,
titleHeight
.
Title
)
assert
.
Equal
(
suite
.
T
(),
commitCnt
,
len
(
titleHeight
.
Details
.
Addrs
))
assert
.
Equal
(
suite
.
T
(),
commitCnt
,
len
(
titleHeight
.
Details
.
Addrs
))
if
commitSupervisionCnt
>
0
{
assert
.
Equal
(
suite
.
T
(),
commitSupervisionCnt
,
len
(
titleHeight
.
SupervisionDetails
.
Addrs
))
assert
.
Equal
(
suite
.
T
(),
commitSupervisionCnt
,
len
(
titleHeight
.
SupervisionDetails
.
Addrs
))
}
}
}
func
checkDoneReceipt
(
suite
suite
.
Suite
,
receipt
*
types
.
Receipt
,
commitCnt
int
)
{
func
checkDoneReceipt
(
suite
suite
.
Suite
,
receipt
*
types
.
Receipt
,
commitCnt
int
)
{
...
@@ -375,7 +377,6 @@ func (suite *CommitTestSuite) TestExec() {
...
@@ -375,7 +377,6 @@ func (suite *CommitTestSuite) TestExec() {
receipt
=
commitOnce
(
suite
,
PrivKeyD
)
receipt
=
commitOnce
(
suite
,
PrivKeyD
)
checkRecordReceipt
(
suite
,
receipt
,
4
)
checkRecordReceipt
(
suite
,
receipt
,
4
)
}
}
func
TestCommitSuite
(
t
*
testing
.
T
)
{
func
TestCommitSuite
(
t
*
testing
.
T
)
{
...
...
plugin/dapp/paracross/executor/query.go
View file @
a98fbca6
...
@@ -48,6 +48,10 @@ func (p *Paracross) Query_GetTitleHeight(in *pt.ReqParacrossTitleHeight) (types.
...
@@ -48,6 +48,10 @@ func (p *Paracross) Query_GetTitleHeight(in *pt.ReqParacrossTitleHeight) (types.
res
.
CommitAddrs
=
append
(
res
.
CommitAddrs
,
addr
)
res
.
CommitAddrs
=
append
(
res
.
CommitAddrs
,
addr
)
res
.
CommitBlockHash
=
append
(
res
.
CommitBlockHash
,
common
.
ToHex
(
status
.
Details
.
BlockHash
[
i
]))
res
.
CommitBlockHash
=
append
(
res
.
CommitBlockHash
,
common
.
ToHex
(
status
.
Details
.
BlockHash
[
i
]))
}
}
for
i
,
addr
:=
range
status
.
SupervisionDetails
.
Addrs
{
res
.
CommitSupervisionAddrs
=
append
(
res
.
CommitSupervisionAddrs
,
addr
)
res
.
CommitSupervisionBlockHash
=
append
(
res
.
CommitSupervisionBlockHash
,
common
.
ToHex
(
status
.
SupervisionDetails
.
BlockHash
[
i
]))
}
return
res
,
nil
return
res
,
nil
}
}
...
@@ -154,29 +158,6 @@ func (p *Paracross) Query_GetNodeAddrInfo(in *pt.ReqParacrossNodeInfo) (types.Me
...
@@ -154,29 +158,6 @@ func (p *Paracross) Query_GetNodeAddrInfo(in *pt.ReqParacrossNodeInfo) (types.Me
return
stat
,
nil
return
stat
,
nil
}
}
//Query_GetSupervisionNodeAddrInfo get specific node addr info
func
(
p
*
Paracross
)
Query_GetSupervisionNodeAddrInfo
(
in
*
pt
.
ReqParacrossNodeInfo
)
(
types
.
Message
,
error
)
{
if
in
==
nil
||
in
.
Addr
==
""
{
return
nil
,
types
.
ErrInvalidParam
}
cfg
:=
p
.
GetAPI
()
.
GetConfig
()
if
cfg
.
IsPara
()
{
in
.
Title
=
cfg
.
GetTitle
()
}
else
if
in
.
Title
==
""
{
return
nil
,
types
.
ErrInvalidParam
}
stat
,
err
:=
getSupervisionNodeAddr
(
p
.
GetStateDB
(),
in
.
Title
,
in
.
Addr
)
if
err
!=
nil
{
return
nil
,
err
}
stat
.
QuitId
=
getParaNodeIDSuffix
(
stat
.
QuitId
)
stat
.
ProposalId
=
getParaNodeIDSuffix
(
stat
.
ProposalId
)
return
stat
,
nil
}
func
(
p
*
Paracross
)
getMainHeight
()
(
int64
,
error
)
{
func
(
p
*
Paracross
)
getMainHeight
()
(
int64
,
error
)
{
mainHeight
:=
p
.
GetMainHeight
()
mainHeight
:=
p
.
GetMainHeight
()
cfg
:=
p
.
GetAPI
()
.
GetConfig
()
cfg
:=
p
.
GetAPI
()
.
GetConfig
()
...
...
plugin/dapp/paracross/executor/superaccount.go
View file @
a98fbca6
...
@@ -445,7 +445,6 @@ func updateVotes(in *pt.ParaNodeVoteDetail, nodes map[string]struct{}) *pt.ParaN
...
@@ -445,7 +445,6 @@ func updateVotes(in *pt.ParaNodeVoteDetail, nodes map[string]struct{}) *pt.ParaN
//由于propasal id 和quit id分开,quit id不知道对应addr proposal id的coinfrozen信息,需要维护一个围绕addr的数据库结构信息
//由于propasal id 和quit id分开,quit id不知道对应addr proposal id的coinfrozen信息,需要维护一个围绕addr的数据库结构信息
func
(
a
*
action
)
updateNodeAddrStatus
(
stat
*
pt
.
ParaNodeIdStatus
)
(
*
types
.
Receipt
,
error
)
{
func
(
a
*
action
)
updateNodeAddrStatus
(
stat
*
pt
.
ParaNodeIdStatus
)
(
*
types
.
Receipt
,
error
)
{
cfg
:=
a
.
api
.
GetConfig
()
addrStat
,
err
:=
getNodeAddr
(
a
.
db
,
stat
.
Title
,
stat
.
TargetAddr
)
addrStat
,
err
:=
getNodeAddr
(
a
.
db
,
stat
.
Title
,
stat
.
TargetAddr
)
if
err
!=
nil
{
if
err
!=
nil
{
if
!
isNotFound
(
err
)
{
if
!
isNotFound
(
err
)
{
...
@@ -479,6 +478,7 @@ func (a *action) updateNodeAddrStatus(stat *pt.ParaNodeIdStatus) (*types.Receipt
...
@@ -479,6 +478,7 @@ func (a *action) updateNodeAddrStatus(stat *pt.ParaNodeIdStatus) (*types.Receipt
addrStat
.
QuitId
=
stat
.
Id
addrStat
.
QuitId
=
stat
.
Id
receipt
:=
makeParaNodeStatusReceipt
(
a
.
fromaddr
,
&
preStat
,
addrStat
)
receipt
:=
makeParaNodeStatusReceipt
(
a
.
fromaddr
,
&
preStat
,
addrStat
)
cfg
:=
a
.
api
.
GetConfig
()
if
!
cfg
.
IsPara
()
{
if
!
cfg
.
IsPara
()
{
r
,
err
:=
a
.
nodeGroupCoinsActive
(
proposalStat
.
FromAddr
,
proposalStat
.
CoinsFrozen
,
1
)
r
,
err
:=
a
.
nodeGroupCoinsActive
(
proposalStat
.
FromAddr
,
proposalStat
.
CoinsFrozen
,
1
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -592,7 +592,7 @@ func (a *action) nodeVote(config *pt.ParaNodeAddrConfig) (*types.Receipt, error)
...
@@ -592,7 +592,7 @@ func (a *action) nodeVote(config *pt.ParaNodeAddrConfig) (*types.Receipt, error)
}
}
}
else
{
}
else
{
if
stat
.
Status
==
pt
.
ParaApplyJoining
{
if
stat
.
Status
==
pt
.
ParaApplyJoining
{
r
,
err
:=
u
n
pdateNodeGroup
(
a
.
db
,
config
.
Title
,
stat
.
TargetAddr
,
true
)
r
,
err
:=
updateNodeGroup
(
a
.
db
,
config
.
Title
,
stat
.
TargetAddr
,
true
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
@@ -607,7 +607,7 @@ func (a *action) nodeVote(config *pt.ParaNodeAddrConfig) (*types.Receipt, error)
...
@@ -607,7 +607,7 @@ func (a *action) nodeVote(config *pt.ParaNodeAddrConfig) (*types.Receipt, error)
stat
.
Status
=
pt
.
ParaApplyClosed
stat
.
Status
=
pt
.
ParaApplyClosed
stat
.
Height
=
a
.
height
stat
.
Height
=
a
.
height
}
else
if
stat
.
Status
==
pt
.
ParaApplyQuiting
{
}
else
if
stat
.
Status
==
pt
.
ParaApplyQuiting
{
r
,
err
:=
u
n
pdateNodeGroup
(
a
.
db
,
config
.
Title
,
stat
.
TargetAddr
,
false
)
r
,
err
:=
updateNodeGroup
(
a
.
db
,
config
.
Title
,
stat
.
TargetAddr
,
false
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
@@ -623,7 +623,7 @@ func (a *action) nodeVote(config *pt.ParaNodeAddrConfig) (*types.Receipt, error)
...
@@ -623,7 +623,7 @@ func (a *action) nodeVote(config *pt.ParaNodeAddrConfig) (*types.Receipt, error)
//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
{
clog
.
Error
(
"u
n
pdateNodeGroup.loopCommitTxDone"
,
"title"
,
title
,
"err"
,
err
.
Error
())
clog
.
Error
(
"updateNodeGroup.loopCommitTxDone"
,
"title"
,
title
,
"err"
,
err
.
Error
())
}
}
receipt
=
mergeReceipt
(
receipt
,
r
)
receipt
=
mergeReceipt
(
receipt
,
r
)
}
}
...
@@ -640,7 +640,7 @@ func (a *action) nodeVote(config *pt.ParaNodeAddrConfig) (*types.Receipt, error)
...
@@ -640,7 +640,7 @@ func (a *action) nodeVote(config *pt.ParaNodeAddrConfig) (*types.Receipt, error)
return
receipt
,
nil
return
receipt
,
nil
}
}
func
u
n
pdateNodeGroup
(
db
dbm
.
KV
,
title
,
addr
string
,
add
bool
)
(
*
types
.
Receipt
,
error
)
{
func
updateNodeGroup
(
db
dbm
.
KV
,
title
,
addr
string
,
add
bool
)
(
*
types
.
Receipt
,
error
)
{
var
item
types
.
ConfigItem
var
item
types
.
ConfigItem
key
:=
calcParaNodeGroupAddrsKey
(
title
)
key
:=
calcParaNodeGroupAddrsKey
(
title
)
...
@@ -651,7 +651,7 @@ func unpdateNodeGroup(db dbm.KV, title, addr string, add bool) (*types.Receipt,
...
@@ -651,7 +651,7 @@ func unpdateNodeGroup(db dbm.KV, title, addr string, add bool) (*types.Receipt,
if
value
!=
nil
{
if
value
!=
nil
{
err
=
types
.
Decode
(
value
,
&
item
)
err
=
types
.
Decode
(
value
,
&
item
)
if
err
!=
nil
{
if
err
!=
nil
{
clog
.
Error
(
"u
n
pdateNodeGroup"
,
"decode db key"
,
key
)
clog
.
Error
(
"updateNodeGroup"
,
"decode db key"
,
key
)
return
nil
,
err
// types.ErrBadConfigValue
return
nil
,
err
// types.ErrBadConfigValue
}
}
}
}
...
@@ -663,8 +663,7 @@ func unpdateNodeGroup(db dbm.KV, title, addr string, add bool) (*types.Receipt,
...
@@ -663,8 +663,7 @@ func unpdateNodeGroup(db dbm.KV, title, addr string, add bool) (*types.Receipt,
if
add
{
if
add
{
item
.
GetArr
()
.
Value
=
append
(
item
.
GetArr
()
.
Value
,
addr
)
item
.
GetArr
()
.
Value
=
append
(
item
.
GetArr
()
.
Value
,
addr
)
item
.
Addr
=
addr
item
.
Addr
=
addr
clog
.
Info
(
"unpdateNodeGroup add"
,
"addr"
,
addr
,
"from"
,
copyItem
.
GetArr
()
.
Value
,
"to"
,
item
.
GetArr
()
.
Value
)
clog
.
Info
(
"updateNodeGroup add"
,
"addr"
,
addr
,
"from"
,
copyItem
.
GetArr
()
.
Value
,
"to"
,
item
.
GetArr
()
.
Value
)
}
else
{
}
else
{
//必须保留至少1个授权账户
//必须保留至少1个授权账户
if
len
(
item
.
GetArr
()
.
Value
)
<=
1
{
if
len
(
item
.
GetArr
()
.
Value
)
<=
1
{
...
@@ -677,11 +676,11 @@ func unpdateNodeGroup(db dbm.KV, title, addr string, add bool) (*types.Receipt,
...
@@ -677,11 +676,11 @@ func unpdateNodeGroup(db dbm.KV, title, addr string, add bool) (*types.Receipt,
item
.
GetArr
()
.
Value
=
append
(
item
.
GetArr
()
.
Value
,
value
)
item
.
GetArr
()
.
Value
=
append
(
item
.
GetArr
()
.
Value
,
value
)
}
}
}
}
clog
.
Info
(
"u
n
pdateNodeGroup delete"
,
"addr"
,
addr
)
clog
.
Info
(
"updateNodeGroup delete"
,
"addr"
,
addr
)
}
}
err
=
db
.
Set
(
key
,
types
.
Encode
(
&
item
))
err
=
db
.
Set
(
key
,
types
.
Encode
(
&
item
))
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
errors
.
Wrapf
(
err
,
"u
n
pdateNodeGroup set dbkey=%s"
,
key
)
return
nil
,
errors
.
Wrapf
(
err
,
"updateNodeGroup set dbkey=%s"
,
key
)
}
}
return
makeParaNodeGroupReceipt
(
title
,
&
copyItem
,
&
item
),
nil
return
makeParaNodeGroupReceipt
(
title
,
&
copyItem
,
&
item
),
nil
}
}
...
...
plugin/dapp/paracross/executor/supervisionaccount.go
View file @
a98fbca6
This diff is collapsed.
Click to expand it.
plugin/dapp/paracross/executor/supervisionaccount_test.go
View file @
a98fbca6
...
@@ -20,15 +20,16 @@ func createRawSupervisionNodeConfigTx(config *pt.ParaNodeAddrConfig) *types.Tran
...
@@ -20,15 +20,16 @@ func createRawSupervisionNodeConfigTx(config *pt.ParaNodeAddrConfig) *types.Tran
}
}
func
(
suite
*
NodeManageTestSuite
)
testSupervisionExec
()
{
func
(
suite
*
NodeManageTestSuite
)
testSupervisionExec
()
{
suite
.
testSupervisionNodeConfig
Quit
()
suite
.
testSupervisionNodeConfig
Cancel
()
suite
.
testSupervisionNodeConfigApprove
(
Account14K
,
PrivKey14K
)
suite
.
testSupervisionNodeConfigApprove
(
Account14K
,
PrivKey14K
)
suite
.
testSupervisionNodeConfigApprove
(
Account1Ku
,
PrivKey1Ku
)
suite
.
testSupervisionNodeConfigApprove
(
Account1Ku
,
PrivKey1Ku
)
suite
.
testSupervisionNodeConfigApprove
(
Account1M3
,
PrivKey1M3
)
suite
.
testSupervisionNodeConfigApprove
(
Account1M3
,
PrivKey1M3
)
suite
.
testSupervisionNodeError
()
suite
.
testSupervisionNodeError
()
suite
.
testSupervisionQuery
()
suite
.
testSupervisionQuery
()
suite
.
testSupervisionNodeQuit
()
}
}
func
(
suite
*
NodeManageTestSuite
)
testSupervisionNodeConfig
Quit
()
{
func
(
suite
*
NodeManageTestSuite
)
testSupervisionNodeConfig
Cancel
()
{
// Apply
// Apply
config
:=
&
pt
.
ParaNodeAddrConfig
{
config
:=
&
pt
.
ParaNodeAddrConfig
{
Title
:
chain33TestCfg
.
GetTitle
(),
Title
:
chain33TestCfg
.
GetTitle
(),
...
@@ -46,7 +47,7 @@ func (suite *NodeManageTestSuite) testSupervisionNodeConfigQuit() {
...
@@ -46,7 +47,7 @@ func (suite *NodeManageTestSuite) testSupervisionNodeConfigQuit() {
// Quit
// Quit
config
=
&
pt
.
ParaNodeAddrConfig
{
config
=
&
pt
.
ParaNodeAddrConfig
{
Title
:
chain33TestCfg
.
GetTitle
(),
Title
:
chain33TestCfg
.
GetTitle
(),
Op
:
pt
.
ParacrossSupervisionNode
Quit
,
Op
:
pt
.
ParacrossSupervisionNode
Cancel
,
Id
:
g
.
Current
.
Id
,
Id
:
g
.
Current
.
Id
,
}
}
tx
=
createRawSupervisionNodeConfigTx
(
config
)
tx
=
createRawSupervisionNodeConfigTx
(
config
)
...
@@ -100,11 +101,32 @@ func (suite *NodeManageTestSuite) testSupervisionNodeError() {
...
@@ -100,11 +101,32 @@ func (suite *NodeManageTestSuite) testSupervisionNodeError() {
assert
.
Equal
(
suite
.
T
(),
err
,
pt
.
ErrParaNodeAddrExisted
)
assert
.
Equal
(
suite
.
T
(),
err
,
pt
.
ErrParaNodeAddrExisted
)
}
}
func
(
suite
*
NodeManageTestSuite
)
testSupervisionNodeQuit
()
{
config
:=
&
pt
.
ParaNodeAddrConfig
{
Title
:
chain33TestCfg
.
GetTitle
(),
Op
:
pt
.
ParacrossSupervisionNodeQuit
,
Addr
:
Account1Ku
,
}
tx
:=
createRawSupervisionNodeConfigTx
(
config
)
receipt
:=
nodeCommit
(
suite
,
PrivKey14K
,
tx
)
assert
.
Equal
(
suite
.
T
(),
receipt
.
Ty
,
int32
(
types
.
ExecOk
))
assert
.
Len
(
suite
.
T
(),
receipt
.
KV
,
3
)
assert
.
Len
(
suite
.
T
(),
receipt
.
Logs
,
3
)
assert
.
Equal
(
suite
.
T
(),
int32
(
pt
.
TyLogParaSupervisionNodeGroupAddrsUpdate
),
receipt
.
Logs
[
0
]
.
Ty
)
ret
,
err
:=
suite
.
exec
.
Query_GetSupervisionNodeGroupAddrs
(
&
pt
.
ReqParacrossNodeInfo
{
Title
:
chain33TestCfg
.
GetTitle
()})
suite
.
Nil
(
err
)
resp
,
ok
:=
ret
.
(
*
types
.
ReplyConfig
)
assert
.
Equal
(
suite
.
T
(),
ok
,
true
)
assert
.
Equal
(
suite
.
T
(),
resp
.
Value
,
"14KEKbYtKKQm4wMthSK9J4La4nAiidGozt,1M3XCbWVxAPBH5AR8VmLky4ZtDdGgC6ugD"
)
}
func
checkSupervisionGroupApplyReceipt
(
suite
*
NodeManageTestSuite
,
receipt
*
types
.
Receipt
)
{
func
checkSupervisionGroupApplyReceipt
(
suite
*
NodeManageTestSuite
,
receipt
*
types
.
Receipt
)
{
assert
.
Equal
(
suite
.
T
(),
receipt
.
Ty
,
int32
(
types
.
ExecOk
))
assert
.
Equal
(
suite
.
T
(),
receipt
.
Ty
,
int32
(
types
.
ExecOk
))
assert
.
Len
(
suite
.
T
(),
receipt
.
KV
,
1
)
assert
.
Len
(
suite
.
T
(),
receipt
.
KV
,
1
)
assert
.
Len
(
suite
.
T
(),
receipt
.
Logs
,
1
)
assert
.
Len
(
suite
.
T
(),
receipt
.
Logs
,
1
)
assert
.
Equal
(
suite
.
T
(),
int32
(
pt
.
TyLogParaSupervisionNode
Group
Config
),
receipt
.
Logs
[
0
]
.
Ty
)
assert
.
Equal
(
suite
.
T
(),
int32
(
pt
.
TyLogParaSupervisionNodeConfig
),
receipt
.
Logs
[
0
]
.
Ty
)
}
}
func
(
suite
*
NodeManageTestSuite
)
testSupervisionQuery
()
{
func
(
suite
*
NodeManageTestSuite
)
testSupervisionQuery
()
{
...
@@ -114,7 +136,7 @@ func (suite *NodeManageTestSuite) testSupervisionQuery() {
...
@@ -114,7 +136,7 @@ func (suite *NodeManageTestSuite) testSupervisionQuery() {
assert
.
Equal
(
suite
.
T
(),
ok
,
true
)
assert
.
Equal
(
suite
.
T
(),
ok
,
true
)
assert
.
Equal
(
suite
.
T
(),
resp
.
Value
,
"14KEKbYtKKQm4wMthSK9J4La4nAiidGozt,1KufZaLTKVAy37AsXNd9bsva5WZvP8w5uG,1M3XCbWVxAPBH5AR8VmLky4ZtDdGgC6ugD"
)
assert
.
Equal
(
suite
.
T
(),
resp
.
Value
,
"14KEKbYtKKQm4wMthSK9J4La4nAiidGozt,1KufZaLTKVAy37AsXNd9bsva5WZvP8w5uG,1M3XCbWVxAPBH5AR8VmLky4ZtDdGgC6ugD"
)
ret
,
err
=
suite
.
exec
.
Query_Get
Supervision
NodeAddrInfo
(
&
pt
.
ReqParacrossNodeInfo
{
Title
:
chain33TestCfg
.
GetTitle
(),
Addr
:
Account14K
})
ret
,
err
=
suite
.
exec
.
Query_GetNodeAddrInfo
(
&
pt
.
ReqParacrossNodeInfo
{
Title
:
chain33TestCfg
.
GetTitle
(),
Addr
:
Account14K
})
suite
.
Nil
(
err
)
suite
.
Nil
(
err
)
resp2
,
ok
:=
ret
.
(
*
pt
.
ParaNodeAddrIdStatus
)
resp2
,
ok
:=
ret
.
(
*
pt
.
ParaNodeAddrIdStatus
)
assert
.
Equal
(
suite
.
T
(),
ok
,
true
)
assert
.
Equal
(
suite
.
T
(),
ok
,
true
)
...
...
plugin/dapp/paracross/proto/paracross.proto
View file @
a98fbca6
...
@@ -38,6 +38,8 @@ message ParacrossHeightStatusRsp {
...
@@ -38,6 +38,8 @@ message ParacrossHeightStatusRsp {
string
mainHash
=
5
;
string
mainHash
=
5
;
repeated
string
commitAddrs
=
6
;
repeated
string
commitAddrs
=
6
;
repeated
string
commitBlockHash
=
7
;
repeated
string
commitBlockHash
=
7
;
repeated
string
commitSupervisionAddrs
=
8
;
repeated
string
commitSupervisionBlockHash
=
9
;
}
}
message
ParacrossStatus
{
message
ParacrossStatus
{
...
...
plugin/dapp/paracross/types/errors.go
View file @
a98fbca6
...
@@ -65,4 +65,6 @@ var (
...
@@ -65,4 +65,6 @@ var (
ErrParaSupervisionNodeGroupNotSet
=
errors
.
New
(
"ErrParaSupervisionNodeGroupNotSet"
)
ErrParaSupervisionNodeGroupNotSet
=
errors
.
New
(
"ErrParaSupervisionNodeGroupNotSet"
)
//ErrParaSupervisionNodeGroupExisted para config group taked over alreay
//ErrParaSupervisionNodeGroupExisted para config group taked over alreay
ErrParaSupervisionNodeGroupExisted
=
errors
.
New
(
"ErrParaSupervisionNodesExisted"
)
ErrParaSupervisionNodeGroupExisted
=
errors
.
New
(
"ErrParaSupervisionNodesExisted"
)
//ErrParaSupervisionNodeAddrNotExisted node addr not exist in supervision group
ErrParaSupervisionNodeAddrNotExisted
=
errors
.
New
(
"ErrParaSupervisionNodeAddrNotExisted"
)
)
)
plugin/dapp/paracross/types/paracross.go
View file @
a98fbca6
...
@@ -177,6 +177,7 @@ const (
...
@@ -177,6 +177,7 @@ const (
ParacrossSupervisionNodeApply
=
iota
+
1
ParacrossSupervisionNodeApply
=
iota
+
1
ParacrossSupervisionNodeApprove
ParacrossSupervisionNodeApprove
ParacrossSupervisionNodeQuit
ParacrossSupervisionNodeQuit
ParacrossSupervisionNodeCancel
)
)
// 0 普通节点共识 1 授权节点正在共识 2 监督节点正在共识
// 0 普通节点共识 1 授权节点正在共识 2 监督节点正在共识
...
@@ -334,6 +335,10 @@ func GetDappForkHeight(cfg *types.Chain33Config, forkKey string) int64 {
...
@@ -334,6 +335,10 @@ func GetDappForkHeight(cfg *types.Chain33Config, forkKey string) int64 {
if
forkHeight
<=
0
{
if
forkHeight
<=
0
{
forkHeight
=
types
.
MaxHeight
forkHeight
=
types
.
MaxHeight
}
}
if
key
==
ForkParaSupervision
{
// ????
forkHeight
=
types
.
Conf
(
cfg
,
ParaPrefixConsSubConf
)
.
GInt
(
key
)
}
}
else
{
}
else
{
forkHeight
=
cfg
.
GetDappFork
(
ParaX
,
forkKey
)
forkHeight
=
cfg
.
GetDappFork
(
ParaX
,
forkKey
)
...
...
plugin/dapp/paracross/types/paracross.pb.go
View file @
a98fbca6
This diff is collapsed.
Click to expand it.
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