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
0179fec6
Commit
0179fec6
authored
Oct 23, 2020
by
QM
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
supervisionaccount.go code to simplify
parent
6c82ccb0
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
141 additions
and
295 deletions
+141
-295
testcase.sh
plugin/dapp/paracross/cmd/build/testcase.sh
+44
-54
paracross.go
plugin/dapp/paracross/commands/paracross.go
+2
-2
action.go
plugin/dapp/paracross/executor/action.go
+57
-29
exec_del_local.go
plugin/dapp/paracross/executor/exec_del_local.go
+1
-1
exec_local.go
plugin/dapp/paracross/executor/exec_local.go
+1
-1
kv.go
plugin/dapp/paracross/executor/kv.go
+0
-8
supervisionaccount.go
plugin/dapp/paracross/executor/supervisionaccount.go
+21
-184
supervisionaccount_test.go
plugin/dapp/paracross/executor/supervisionaccount_test.go
+8
-8
paracross.proto
plugin/dapp/paracross/proto/paracross.proto
+3
-0
paracross.go
plugin/dapp/paracross/types/paracross.go
+3
-5
paracross.pb.go
plugin/dapp/paracross/types/paracross.pb.go
+0
-0
type.go
plugin/dapp/paracross/types/type.go
+1
-3
No files found.
plugin/dapp/paracross/cmd/build/testcase.sh
View file @
0179fec6
...
...
@@ -294,7 +294,7 @@ function query_tx() {
block_wait
"
${
1
}
"
1
local times
=
200
#
local times=10
#
local times=10
while
true
;
do
ret
=
$(${
1
}
tx query
-s
"
${
2
}
"
| jq
-r
".tx.hash"
)
echo
"query hash is
${
2
}
, return
${
ret
}
"
...
...
@@ -571,7 +571,6 @@ function para_create_nodegroup_gamechain() {
fi
${
PARA_CLI5
}
para nodegroup addrs
}
function
para_cross_transfer_from_parachain
()
{
...
...
@@ -794,7 +793,7 @@ function para_create_nodegroup() {
}
# $1 status, $2 hash
function
check_supervision_node_list
()
{
function
check_supervision_node_
group_
list
()
{
newid
=
$(${
PARA_CLI
}
para supervision_node list
-s
"
$1
"
| jq
-r
".ids[0].id"
)
if
[
"
$newid
"
!=
"
$2
"
]
;
then
${
PARA_CLI
}
para supervision_node list
-s
"
$1
"
...
...
@@ -804,7 +803,7 @@ function check_supervision_node_list() {
}
# $1 status
function
check_supervision_node_status
()
{
function
check_supervision_node_
group_
status
()
{
status
=
$(${
PARA_CLI
}
para supervision_node status | jq
-r
".status"
)
if
[
"
$status
"
!=
"
$1
"
]
;
then
${
PARA_CLI
}
para supervision_node status
...
...
@@ -844,9 +843,6 @@ function para_create_supervision_nodegroup_cancel() {
id
=
$txhash
check_balance_1ka
"
$balancePre
"
6
check_supervision_node_list 1
"
$id
"
check_supervision_node_status 1
check_supervision_node_addr_status 1
"
$ADDR_28
"
echo
"=========== # supervision node group cancel ============="
balancePre
=
$(${
CLI
}
account balance
-a
1Ka7EPFRqs3v9yreXG6qA4RQbNmbPJCZPj
-e
paracross | jq
-r
".frozen"
)
...
...
@@ -856,9 +852,43 @@ function para_create_supervision_nodegroup_cancel() {
query_tx
"
${
PARA_CLI
}
"
"
${
txhash
}
"
check_balance_1ka
"
$balancePre
"
-6
check_supervision_node_list 4
"
$id
"
check_supervision_node_status 4
check_supervision_node_addr_status 4
"
$ADDR_28
"
echo
"=========== #
${
FUNCNAME
}
end ============="
}
function
para_create_supervision_nodegroup_quit
()
{
echo
"=========== #
${
FUNCNAME
}
begin ============="
echo
"=========== # para chain apply supervision node group 25 ============="
balancePre
=
$(${
CLI
}
account balance
-a
1Ka7EPFRqs3v9yreXG6qA4RQbNmbPJCZPj
-e
paracross | jq
-r
".frozen"
)
##apply
txhash
=
$(${
PARA_CLI
}
send para supervision_node apply
-a
"
$ADDR_25
"
-c
6
-p
"
$BLSPUB_25
"
-k
"
${
ADDR_1KA_KEY
}
"
)
echo
"tx=
$txhash
"
query_tx
"
${
PARA_CLI
}
"
"
${
txhash
}
"
id
=
$txhash
check_balance_1ka
"
$balancePre
"
6
echo
"=========== # para chain approve supervision node group 25 ============="
##approve
txhash
=
$(${
PARA_CLI
}
send para supervision_node approve
-i
"
$id
"
-c
6
-k
"
${
SUPER_KEY
}
"
)
echo
"tx=
$txhash
"
query_tx
"
${
PARA_CLI
}
"
"
${
txhash
}
"
check_supervision_node_addr_status 2
"
$ADDR_25
"
check_supervision_node_group_list 2
"
$id
"
check_supervision_node_group_status 2
check_supervision_node_addrs
"
$ADDR_25
"
echo
"=========== # para chain quit supervision node group 25 ============="
balancePre
=
$(${
CLI
}
account balance
-a
1Ka7EPFRqs3v9yreXG6qA4RQbNmbPJCZPj
-e
paracross | jq
-r
".frozen"
)
txhash
=
$(${
PARA_CLI
}
send para supervision_node quit
-a
"
$ADDR_25
"
-k
"
${
SUPER_KEY
}
"
)
echo
"tx=
$txhash
"
query_tx
"
${
PARA_CLI
}
"
"
${
txhash
}
"
check_balance_1ka
"
$balancePre
"
-6
check_supervision_node_group_list 3
"
$id
"
check_supervision_node_group_status 3
check_supervision_node_addr_status 3
"
$ADDR_25
"
check_supervision_node_addrs null
echo
"=========== #
${
FUNCNAME
}
end ============="
}
...
...
@@ -873,9 +903,6 @@ function para_create_supervision_nodegroup_approve() {
id
=
$txhash
check_balance_1ka
"
$balancePre
"
6
check_supervision_node_list 1
"
$id
"
check_supervision_node_status 1
check_supervision_node_addr_status 1
"
$ADDR_28
"
echo
"=========== # para chain approve supervision node group 28 ============="
##approve
...
...
@@ -883,8 +910,8 @@ function para_create_supervision_nodegroup_approve() {
echo
"tx=
$txhash
"
query_tx
"
${
PARA_CLI
}
"
"
${
txhash
}
"
check_supervision_node_list 2
"
$id
"
check_supervision_node_status 2
check_supervision_node_
group_
list 2
"
$id
"
check_supervision_node_
group_
status 2
check_supervision_node_addr_status 2
"
$ADDR_28
"
check_supervision_node_addrs
"
$ADDR_28
"
...
...
@@ -897,7 +924,6 @@ function para_create_supervision_nodegroup_approve() {
id
=
$txhash
check_balance_1ka
"
$balancePre
"
6
check_supervision_node_addr_status 1
"
$ADDR_27
"
echo
"=========== # para chain approve supervision node group 27 ============="
##approve
...
...
@@ -917,7 +943,6 @@ function para_create_supervision_nodegroup_approve() {
id
=
$txhash
check_balance_1ka
"
$balancePre
"
6
check_supervision_node_addr_status 1
"
$ADDR_26
"
echo
"=========== # para chain approve supervision node group 26 ============="
##approve
...
...
@@ -928,40 +953,6 @@ function para_create_supervision_nodegroup_approve() {
check_supervision_node_addr_status 2
"
$ADDR_26
"
check_supervision_node_addrs
"
$ADDR_28
,
$ADDR_27
,
$ADDR_26
"
echo
"=========== #
${
FUNCNAME
}
end ============="
}
function
para_create_supervision_nodegroup_quit
()
{
echo
"=========== #
${
FUNCNAME
}
begin ============="
echo
"=========== # para chain apply supervision node group 25 ============="
balancePre
=
$(${
CLI
}
account balance
-a
1Ka7EPFRqs3v9yreXG6qA4RQbNmbPJCZPj
-e
paracross | jq
-r
".frozen"
)
##apply
txhash
=
$(${
PARA_CLI
}
send para supervision_node apply
-a
"
$ADDR_25
"
-c
6
-p
"
$BLSPUB_25
"
-k
"
${
ADDR_1KA_KEY
}
"
)
echo
"tx=
$txhash
"
query_tx
"
${
PARA_CLI
}
"
"
${
txhash
}
"
id
=
$txhash
check_balance_1ka
"
$balancePre
"
6
check_supervision_node_addr_status 1
"
$ADDR_25
"
echo
"=========== # para chain approve supervision node group 25 ============="
##approve
txhash
=
$(${
PARA_CLI
}
send para supervision_node approve
-i
"
$id
"
-c
6
-k
"
${
SUPER_KEY
}
"
)
echo
"tx=
$txhash
"
query_tx
"
${
PARA_CLI
}
"
"
${
txhash
}
"
check_supervision_node_addr_status 2
"
$ADDR_25
"
check_supervision_node_addrs
"
$ADDR_28
,
$ADDR_27
,
$ADDR_26
,
$ADDR_25
"
echo
"=========== # para chain quit supervision node group 25 ============="
balancePre
=
$(${
CLI
}
account balance
-a
1Ka7EPFRqs3v9yreXG6qA4RQbNmbPJCZPj
-e
paracross | jq
-r
".frozen"
)
txhash
=
$(${
PARA_CLI
}
send para supervision_node quit
-a
"
$ADDR_25
"
-k
"
${
SUPER_KEY
}
"
)
echo
"tx=
$txhash
"
query_tx
"
${
PARA_CLI
}
"
"
${
txhash
}
"
check_balance_1ka
"
$balancePre
"
-6
check_supervision_node_addr_status 3
"
$ADDR_25
"
check_supervision_node_addrs
"
$ADDR_28
,
$ADDR_27
,
$ADDR_26
"
echo
"=========== # para chain apply supervision node group 25 again ============="
balancePre
=
$(${
CLI
}
account balance
-a
1Ka7EPFRqs3v9yreXG6qA4RQbNmbPJCZPj
-e
paracross | jq
-r
".frozen"
)
...
...
@@ -972,7 +963,6 @@ function para_create_supervision_nodegroup_quit() {
id
=
$txhash
check_balance_1ka
"
$balancePre
"
6
check_supervision_node_addr_status 1
"
$ADDR_25
"
echo
"=========== # para chain approve supervision node group 25 again ============="
##approve
...
...
@@ -989,8 +979,8 @@ function para_create_supervision_nodegroup_quit() {
function
para_create_supervision_nodegroup
()
{
echo
"=========== #
${
FUNCNAME
}
begin ============="
para_create_supervision_nodegroup_cancel
para_create_supervision_nodegroup_approve
para_create_supervision_nodegroup_quit
para_create_supervision_nodegroup_approve
docker stop
"
${
NODE9
}
"
echo
"=========== #
${
FUNCNAME
}
end ============="
}
...
...
@@ -1330,8 +1320,8 @@ function privacy_transfer_test() {
function
para_test
()
{
echo
"=========== # para chain test ============="
para_create_nodegroup
para_create_supervision_nodegroup
para_nodegroup_behalf_quit_test
para_create_supervision_nodegroup
para_create_nodegroup_gamechain
token_create
"
${
PARA_CLI
}
"
token_transfer
"
${
PARA_CLI
}
"
...
...
plugin/dapp/paracross/commands/paracross.go
View file @
0179fec6
...
...
@@ -1741,7 +1741,7 @@ func supervisionNodeGroupListCmd() *cobra.Command {
}
func
getSupervisionNodeGroupListCmdFlags
(
cmd
*
cobra
.
Command
)
{
cmd
.
Flags
()
.
Int32P
(
"status"
,
"s"
,
0
,
"status:
1:apply, 2:approve, 3:quit, 4:cancel
"
)
cmd
.
Flags
()
.
Int32P
(
"status"
,
"s"
,
0
,
"status:
2:approve, 3:quit
"
)
_
=
cmd
.
MarkFlagRequired
(
"status"
)
}
...
...
@@ -1766,7 +1766,7 @@ func supervisionNodeGroupList(cmd *cobra.Command, args []string) {
func
getSupervisionNodeInfoCmd
()
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"addr_status"
,
Short
:
"Get node current status:
1:apply, 2:approve, 3:quit, 4:cancel
from supervision group"
,
Short
:
"Get node current status:
2:approve, 3:quit
from supervision group"
,
Run
:
supervisionNodeInfo
,
}
addSupervisionNodeInfoCmdFlags
(
cmd
)
...
...
plugin/dapp/paracross/executor/action.go
View file @
0179fec6
...
...
@@ -190,19 +190,22 @@ func makeRecordReceipt(addr string, commit *pt.ParacrossNodeStatus) *types.Recei
}
func
makeDoneReceipt
(
cfg
*
types
.
Chain33Config
,
execMainHeight
,
execHeight
int64
,
commit
*
pt
.
ParacrossNodeStatus
,
most
,
commitCount
,
totalCount
int32
)
*
types
.
Receipt
{
most
,
commitCount
,
totalCount
,
mostSupervisionCount
,
totalSupervisionCommit
,
totalSupervisionNodes
int32
)
*
types
.
Receipt
{
log
:=
&
pt
.
ReceiptParacrossDone
{
TotalNodes
:
totalCount
,
TotalCommit
:
commitCount
,
MostSameCommit
:
most
,
Title
:
commit
.
Title
,
Height
:
commit
.
Height
,
BlockHash
:
commit
.
BlockHash
,
TxResult
:
commit
.
TxResult
,
MainBlockHeight
:
commit
.
MainBlockHeight
,
MainBlockHash
:
commit
.
MainBlockHash
,
ChainExecHeight
:
execHeight
,
TotalNodes
:
totalCount
,
TotalCommit
:
commitCount
,
MostSameCommit
:
most
,
Title
:
commit
.
Title
,
Height
:
commit
.
Height
,
BlockHash
:
commit
.
BlockHash
,
TxResult
:
commit
.
TxResult
,
MainBlockHeight
:
commit
.
MainBlockHeight
,
MainBlockHash
:
commit
.
MainBlockHash
,
ChainExecHeight
:
execHeight
,
TotalSupervisionNodes
:
totalSupervisionNodes
,
TotalSupervisionCommit
:
totalSupervisionCommit
,
MostSupervisionCommit
:
mostSupervisionCount
,
}
key
:=
calcTitleKey
(
commit
.
Title
)
status
:=
&
pt
.
ParacrossStatus
{
...
...
@@ -567,9 +570,9 @@ func (a *action) Commit(commit *pt.ParacrossCommitAction) (*types.Receipt, error
bIsCommitSuperNode
=
true
}
// 获取监督节点的数据
监督节点在高度分叉后
// 获取监督节点的数据
supervisionNodesMap
,
supervisionNodesArry
,
err
:=
a
.
getSupervisionNodesGroup
(
commit
.
Status
.
Title
)
if
err
!=
nil
&&
errors
.
Cause
(
err
)
!=
pt
.
ErrTitleNotExist
&&
a
.
exec
.
GetMainHeight
()
>=
pt
.
GetDappForkHeight
(
cfg
,
pt
.
ForkCommitTx
)
{
if
err
!=
nil
&&
errors
.
Cause
(
err
)
!=
pt
.
ErrTitleNotExist
{
return
nil
,
errors
.
Wrap
(
err
,
"getSupervisionNodesGroup"
)
}
...
...
@@ -723,6 +726,7 @@ func (a *action) commitTxDone(nodeStatus *pt.ParacrossNodeStatus, stat *pt.Parac
clog
.
Debug
(
"paracross.Commit commit ----pass"
,
"most"
,
mostCount
,
"mostHash"
,
common
.
ToHex
([]
byte
(
mostHash
)))
// 如果已经有监督节点
mostSupervisionCount
:=
0
if
len
(
supervisionNodes
)
>
0
{
for
i
,
v
:=
range
stat
.
SupervisionDetails
.
Addrs
{
clog
.
Debug
(
"paracross.Commit commit SupervisionDetails"
,
"addr"
,
v
,
"hash"
,
common
.
ToHex
(
stat
.
SupervisionDetails
.
BlockHash
[
i
]))
...
...
@@ -733,12 +737,11 @@ func (a *action) commitTxDone(nodeStatus *pt.ParacrossNodeStatus, stat *pt.Parac
}
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"
)
if
mostHash
!=
mostSupervisionHash
{
clog
.
Error
(
"paracross.Commit commit mostSupervisionHash mostHash not equal"
,
"mostHash: "
,
common
.
ToHex
([]
byte
(
mostHash
)),
"mostSupervisionHash: "
,
common
.
ToHex
([]
byte
(
mostSupervisionHash
))
)
return
receipt
,
nil
}
}
clog
.
Debug
(
"paracross.Commit commit ----pass"
)
stat
.
Status
=
pt
.
ParacrossStatusCommitDone
_
=
saveTitleHeight
(
a
.
db
,
calcTitleHeightKey
(
stat
.
Title
,
stat
.
Height
),
stat
)
...
...
@@ -751,7 +754,9 @@ func (a *action) commitTxDone(nodeStatus *pt.ParacrossNodeStatus, stat *pt.Parac
}
//add commit done receipt
receiptDone
:=
makeDoneReceipt
(
cfg
,
a
.
exec
.
GetMainHeight
(),
a
.
height
,
nodeStatus
,
int32
(
mostCount
),
int32
(
len
(
stat
.
Details
.
Addrs
)),
int32
(
len
(
nodes
)))
receiptDone
:=
makeDoneReceipt
(
cfg
,
a
.
exec
.
GetMainHeight
(),
a
.
height
,
nodeStatus
,
int32
(
mostCount
),
int32
(
len
(
stat
.
Details
.
Addrs
)),
int32
(
len
(
nodes
)),
int32
(
mostSupervisionCount
),
int32
(
len
(
stat
.
SupervisionDetails
.
Addrs
)),
int32
(
len
(
supervisionNodes
)))
receipt
=
mergeReceipt
(
receipt
,
receiptDone
)
r
,
err
:=
a
.
commitTxDoneStep2
(
nodeStatus
,
stat
,
titleStatus
)
...
...
@@ -849,6 +854,11 @@ func (a *action) loopCommitTxDone(title string) (*types.Receipt, error) {
if
err
!=
nil
{
return
nil
,
errors
.
Wrapf
(
err
,
"getNodes for title:%s"
,
title
)
}
// 获取监督节点的数据
supervisionNodes
,
_
,
err
:=
a
.
getSupervisionNodesGroup
(
title
)
if
err
!=
nil
&&
errors
.
Cause
(
err
)
!=
pt
.
ErrTitleNotExist
{
return
nil
,
errors
.
Wrap
(
err
,
"getSupervisionNodesGroup"
)
}
//从当前共识高度开始遍历
titleStatus
,
err
:=
getTitle
(
a
.
db
,
calcTitleKey
(
title
))
if
err
!=
nil
{
...
...
@@ -876,7 +886,7 @@ func (a *action) loopCommitTxDone(title string) (*types.Receipt, error) {
return
receipt
,
nil
}
r
,
err
:=
a
.
checkCommitTxDone
(
title
,
stat
,
n
odes
)
r
,
err
:=
a
.
checkCommitTxDone
(
stat
,
nodes
,
supervisionN
odes
)
if
err
!=
nil
{
clog
.
Error
(
"paracross.loopCommitTxDone checkExecCommitTxDone"
,
"para title"
,
title
,
"height"
,
stat
.
Height
,
"error"
,
err
)
return
receipt
,
nil
...
...
@@ -888,10 +898,10 @@ func (a *action) loopCommitTxDone(title string) (*types.Receipt, error) {
}
}
func
(
a
*
action
)
checkCommitTxDone
(
title
string
,
stat
*
pt
.
ParacrossHeightStatus
,
n
odes
map
[
string
]
struct
{})
(
*
types
.
Receipt
,
error
)
{
status
,
err
:=
getTitle
(
a
.
db
,
calcTitleKey
(
t
itle
))
func
(
a
*
action
)
checkCommitTxDone
(
stat
*
pt
.
ParacrossHeightStatus
,
nodes
,
supervisionN
odes
map
[
string
]
struct
{})
(
*
types
.
Receipt
,
error
)
{
status
,
err
:=
getTitle
(
a
.
db
,
calcTitleKey
(
stat
.
T
itle
))
if
err
!=
nil
{
return
nil
,
errors
.
Wrapf
(
err
,
"getTitle:%s"
,
t
itle
)
return
nil
,
errors
.
Wrapf
(
err
,
"getTitle:%s"
,
stat
.
T
itle
)
}
//待共识的stat的高度大于当前status高度+1,说明共识不连续,退出,如果是平行链自共识首次切换场景,可以在正常流程里面再触发
...
...
@@ -899,28 +909,46 @@ func (a *action) checkCommitTxDone(title string, stat *pt.ParacrossHeightStatus,
return
nil
,
nil
}
return
a
.
commitTxDoneByStat
(
stat
,
status
,
nodes
)
return
a
.
commitTxDoneByStat
(
stat
,
status
,
nodes
,
supervisionNodes
)
}
//只根据stat的信息在commitDone之后重构一个commitMostStatus做后续处理
func
(
a
*
action
)
commitTxDoneByStat
(
stat
*
pt
.
ParacrossHeightStatus
,
titleStatus
*
pt
.
ParacrossStatus
,
nodes
map
[
string
]
struct
{})
(
*
types
.
Receipt
,
error
)
{
receipt
:=
&
types
.
Receipt
{}
func
(
a
*
action
)
commitTxDoneByStat
(
stat
*
pt
.
ParacrossHeightStatus
,
titleStatus
*
pt
.
ParacrossStatus
,
nodes
,
supervisionNodes
map
[
string
]
struct
{})
(
*
types
.
Receipt
,
error
)
{
clog
.
Debug
(
"paracross.commitTxDoneByStat"
,
"stat.title"
,
stat
.
Title
,
"stat.height"
,
stat
.
Height
,
"notes"
,
len
(
nodes
))
for
i
,
v
:=
range
stat
.
Details
.
Addrs
{
clog
.
Debug
(
"paracross.commitTxDoneByStat detail"
,
"addr"
,
v
,
"hash"
,
common
.
ToHex
(
stat
.
Details
.
BlockHash
[
i
]))
}
updateCommitAddrs
(
stat
,
nodes
)
commitCount
:=
len
(
stat
.
Details
.
Addrs
)
most
,
mostHash
:=
GetMostCommit
(
stat
.
Details
.
BlockHash
)
if
!
isCommitDone
(
len
(
nodes
),
most
)
{
return
nil
,
nil
}
clog
.
Debug
(
"paracross.commitTxDoneByStat ----pass"
,
"most"
,
most
,
"mostHash"
,
common
.
ToHex
([]
byte
(
mostHash
)))
mostSupervisionCount
:=
0
if
len
(
supervisionNodes
)
>
0
{
for
i
,
v
:=
range
stat
.
SupervisionDetails
.
Addrs
{
clog
.
Debug
(
"paracross.commitTxDoneByStat SupervisionDetails"
,
"addr"
,
v
,
"hash"
,
common
.
ToHex
(
stat
.
SupervisionDetails
.
BlockHash
[
i
]))
}
updateSupervisionDetailsCommitAddrs
(
stat
,
supervisionNodes
)
mostSupervisionCount
,
mostSupervisionHash
:=
GetMostCommit
(
stat
.
SupervisionDetails
.
BlockHash
)
if
!
isCommitDone
(
len
(
supervisionNodes
),
mostSupervisionCount
)
{
return
nil
,
nil
}
clog
.
Debug
(
"paracross.commitTxDoneByStat SupervisionDetails ----pass"
,
"mostSupervisionCount"
,
mostSupervisionCount
,
"mostSupervisionHash"
,
common
.
ToHex
([]
byte
(
mostSupervisionHash
)))
if
mostHash
!=
mostSupervisionHash
{
clog
.
Error
(
"paracross.commitTxDoneByStat mostSupervisionHash mostHash not equal"
,
"mostHash: "
,
common
.
ToHex
([]
byte
(
mostHash
)),
"mostSupervisionHash: "
,
common
.
ToHex
([]
byte
(
mostSupervisionHash
)))
return
nil
,
nil
}
}
stat
.
Status
=
pt
.
ParacrossStatusCommitDone
_
=
saveTitleHeight
(
a
.
db
,
calcTitleHeightKey
(
stat
.
Title
,
stat
.
Height
),
stat
)
r
:=
makeCommitStatReceipt
(
stat
)
receipt
:=
&
types
.
Receipt
{}
receipt
=
mergeReceipt
(
receipt
,
r
)
txRst
:=
getMostResults
([]
byte
(
mostHash
),
stat
)
...
...
@@ -935,7 +963,9 @@ func (a *action) commitTxDoneByStat(stat *pt.ParacrossHeightStatus, titleStatus
//add commit done receipt
cfg
:=
a
.
api
.
GetConfig
()
receiptDone
:=
makeDoneReceipt
(
cfg
,
a
.
exec
.
GetMainHeight
(),
a
.
height
,
mostStatus
,
int32
(
most
),
int32
(
commitCount
),
int32
(
len
(
nodes
)))
receiptDone
:=
makeDoneReceipt
(
cfg
,
a
.
exec
.
GetMainHeight
(),
a
.
height
,
mostStatus
,
int32
(
most
),
int32
(
len
(
stat
.
Details
.
Addrs
)),
int32
(
len
(
nodes
)),
int32
(
mostSupervisionCount
),
int32
(
len
(
stat
.
SupervisionDetails
.
Addrs
)),
int32
(
len
(
supervisionNodes
)))
receipt
=
mergeReceipt
(
receipt
,
receiptDone
)
r
,
err
:=
a
.
commitTxDoneStep2
(
mostStatus
,
stat
,
titleStatus
)
...
...
@@ -984,7 +1014,6 @@ func (a *action) isAllowConsensJump(commit *pt.ParacrossNodeStatus, titleStatus
return
a
.
isAllowParaConsensJump
(
commit
,
titleStatus
)
}
return
a
.
isAllowMainConsensJump
(
commit
,
titleStatus
),
nil
}
func
execCrossTx
(
a
*
action
,
cross
*
types
.
TransactionDetail
,
crossTxHash
[]
byte
)
(
*
types
.
Receipt
,
error
)
{
...
...
@@ -1028,7 +1057,6 @@ func execCrossTx(a *action, cross *types.TransactionDetail, crossTxHash []byte)
return
receiptWithdraw
,
nil
}
return
nil
,
nil
}
func
rollbackCrossTx
(
a
*
action
,
cross
*
types
.
TransactionDetail
,
crossTxHash
[]
byte
)
(
*
types
.
Receipt
,
error
)
{
...
...
plugin/dapp/paracross/executor/exec_del_local.go
View file @
0179fec6
...
...
@@ -142,7 +142,7 @@ func (e *Paracross) ExecDelLocal_NodeGroupConfig(payload *pt.ParaNodeGroupConfig
func
(
e
*
Paracross
)
ExecDelLocal_SupervisionNodeGroupConfig
(
payload
*
pt
.
ParaNodeAddrConfig
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
var
set
types
.
LocalDBSet
for
_
,
log
:=
range
receiptData
.
Logs
{
if
log
.
Ty
==
pt
.
TyLogParaSupervisionNodeGroup
Config
{
if
log
.
Ty
==
pt
.
TyLogParaSupervisionNodeGroup
StatusUpdate
{
var
g
pt
.
ReceiptParaNodeGroupConfig
err
:=
types
.
Decode
(
log
.
Log
,
&
g
)
if
err
!=
nil
{
...
...
plugin/dapp/paracross/executor/exec_local.go
View file @
0179fec6
...
...
@@ -143,7 +143,7 @@ func (e *Paracross) ExecLocal_NodeGroupConfig(payload *pt.ParaNodeGroupConfig, t
func
(
e
*
Paracross
)
ExecLocal_SupervisionNodeGroupConfig
(
payload
*
pt
.
ParaNodeAddrConfig
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
var
set
types
.
LocalDBSet
for
_
,
log
:=
range
receiptData
.
Logs
{
if
log
.
Ty
==
pt
.
TyLogParaSupervisionNodeGroup
Config
{
if
log
.
Ty
==
pt
.
TyLogParaSupervisionNodeGroup
StatusUpdate
{
var
g
pt
.
ReceiptParaNodeGroupConfig
err
:=
types
.
Decode
(
log
.
Log
,
&
g
)
if
err
!=
nil
{
...
...
plugin/dapp/paracross/executor/kv.go
View file @
0179fec6
...
...
@@ -42,9 +42,7 @@ var (
//监督节点
paraSupervisionNodes
string
paraSupervisionNodeGroupStatusAddrs
string
paraSupervisionNodeGroupIDPrefix
string
paraSupervisionNodeIDPrefix
string
paraSupervisionSelfConsensStages
string
localSupervisionNodeGroupStatusTitle
string
localSupervisionNodeStatusTitle
string
...
...
@@ -79,9 +77,7 @@ func setPrefix() {
paraSupervisionNodes
=
"mavl-paracross-supervision-nodes-title-"
paraSupervisionNodeGroupStatusAddrs
=
"mavl-paracross-supervision-nodegroup-status-title-"
paraSupervisionNodeGroupIDPrefix
=
"mavl-paracross-title-nodegroupid-supervision-"
paraSupervisionNodeIDPrefix
=
"mavl-paracross-title-nodeid-supervision-"
paraSupervisionSelfConsensStages
=
"mavl-paracross-supervision-selfconsens-stages-"
localSupervisionNodeGroupStatusTitle
=
"LODB-paracross-supervision-nodegroupStatusTitle-"
localSupervisionNodeStatusTitle
=
"LODB-paracross-supervision-nodeStatusTitle-"
...
...
@@ -238,10 +234,6 @@ func calcParaSupervisionNodeGroupStatusKey(title string) []byte {
return
[]
byte
(
fmt
.
Sprintf
(
paraSupervisionNodeGroupStatusAddrs
+
"%s"
,
title
))
}
func
calcParaSupervisionNodeGroupIDKey
(
title
,
hash
string
)
string
{
return
fmt
.
Sprintf
(
paraSupervisionNodeGroupIDPrefix
+
"%s-%s"
,
title
,
hash
)
}
func
calcParaSupervisionNodeIDKey
(
title
,
hash
string
)
string
{
return
fmt
.
Sprintf
(
paraSupervisionNodeIDPrefix
+
"%s-%s"
,
title
,
hash
)
}
plugin/dapp/paracross/executor/supervisionaccount.go
View file @
0179fec6
This diff is collapsed.
Click to expand it.
plugin/dapp/paracross/executor/supervisionaccount_test.go
View file @
0179fec6
...
...
@@ -20,7 +20,7 @@ func createRawSupervisionNodeConfigTx(config *pt.ParaNodeAddrConfig) *types.Tran
}
func
(
suite
*
NodeManageTestSuite
)
testSupervisionExec
()
{
suite
.
testSupervisionNodeConfigCancel
()
suite
.
testSupervisionNodeConfigCancel
(
Account14K
,
PrivKey14K
)
suite
.
testSupervisionNodeConfigApprove
(
Account14K
,
PrivKey14K
)
suite
.
testSupervisionNodeConfigApprove
(
Account1Ku
,
PrivKey1Ku
)
suite
.
testSupervisionNodeConfigApprove
(
Account1M3
,
PrivKey1M3
)
...
...
@@ -29,15 +29,15 @@ func (suite *NodeManageTestSuite) testSupervisionExec() {
suite
.
testSupervisionNodeQuit
()
}
func
(
suite
*
NodeManageTestSuite
)
testSupervisionNodeConfigCancel
()
{
func
(
suite
*
NodeManageTestSuite
)
testSupervisionNodeConfigCancel
(
addr
,
privKey
string
)
{
// Apply
config
:=
&
pt
.
ParaNodeAddrConfig
{
Title
:
chain33TestCfg
.
GetTitle
(),
Op
:
pt
.
ParacrossSupervisionNodeApply
,
Addr
:
Account14K
,
Addr
:
addr
,
}
tx
:=
createRawSupervisionNodeConfigTx
(
config
)
receipt
:=
nodeCommit
(
suite
,
PrivKey14K
,
tx
)
receipt
:=
nodeCommit
(
suite
,
privKey
,
tx
)
checkSupervisionGroupApplyReceipt
(
suite
,
receipt
)
var
g
pt
.
ReceiptParaNodeGroupConfig
...
...
@@ -51,7 +51,7 @@ func (suite *NodeManageTestSuite) testSupervisionNodeConfigCancel() {
Id
:
getParaNodeIDSuffix
(
g
.
Current
.
Id
),
}
tx
=
createRawSupervisionNodeConfigTx
(
config
)
receipt
=
nodeCommit
(
suite
,
PrivKey14K
,
tx
)
receipt
=
nodeCommit
(
suite
,
privKey
,
tx
)
assert
.
Equal
(
suite
.
T
(),
receipt
.
Ty
,
int32
(
types
.
ExecOk
))
}
...
...
@@ -123,9 +123,9 @@ func (suite *NodeManageTestSuite) testSupervisionNodeQuit() {
func
checkSupervisionGroupApplyReceipt
(
suite
*
NodeManageTestSuite
,
receipt
*
types
.
Receipt
)
{
assert
.
Equal
(
suite
.
T
(),
receipt
.
Ty
,
int32
(
types
.
ExecOk
))
//
assert.Len(suite.T(), receipt.KV, 1)
//
assert.Len(suite.T(), receipt.Logs, 1)
//
assert.Equal(suite.T(), int32(pt.TyLogParaSupervisionNodeConfig), receipt.Logs[0].Ty)
assert
.
Len
(
suite
.
T
(),
receipt
.
KV
,
1
)
assert
.
Len
(
suite
.
T
(),
receipt
.
Logs
,
1
)
assert
.
Equal
(
suite
.
T
(),
int32
(
pt
.
TyLogParaSupervisionNodeConfig
),
receipt
.
Logs
[
0
]
.
Ty
)
}
func
(
suite
*
NodeManageTestSuite
)
testSupervisionQuery
()
{
...
...
plugin/dapp/paracross/proto/paracross.proto
View file @
0179fec6
...
...
@@ -382,6 +382,9 @@ message ReceiptParacrossDone {
bytes
mainBlockHash
=
13
;
int64
mainBlockHeight
=
14
;
int64
chainExecHeight
=
15
;
int32
totalSupervisionNodes
=
16
;
int32
totalSupervisionCommit
=
17
;
int32
mostSupervisionCommit
=
18
;
}
message
ReceiptParacrossRecord
{
...
...
plugin/dapp/paracross/types/paracross.go
View file @
0179fec6
...
...
@@ -50,12 +50,10 @@ const (
TyLogParaBindMinerAddr
=
671
TyLogParaBindMinerNode
=
672
// Supervision Node
TyLogParaSupervisionNode
GroupConfig
=
680
TyLogParaSupervisionNode
Config
=
680
TyLogParaSupervisionNodeGroupAddrsUpdate
=
681
TyLogParaSupervisionNodeConfig
=
682
TyLogParaSupervisionNodeStatusUpdate
=
683
TyLogParaStageSupervisionGroupUpdate
=
684
TyLogParaSupervisionNodeGroupStatusUpdate
=
685
TyLogParaSupervisionNodeStatusUpdate
=
682
TyLogParaSupervisionNodeGroupStatusUpdate
=
683
)
// action type
...
...
plugin/dapp/paracross/types/paracross.pb.go
View file @
0179fec6
This diff is collapsed.
Click to expand it.
plugin/dapp/paracross/types/type.go
View file @
0179fec6
...
...
@@ -116,11 +116,9 @@ func (p *ParacrossType) GetLogMap() map[int64]*types.LogInfo {
TyLogParaStageGroupUpdate
:
{
Ty
:
reflect
.
TypeOf
(
ReceiptSelfConsStagesUpdate
{}),
Name
:
"LogParaSelfConfStagesUpdate"
},
TyLogParaBindMinerAddr
:
{
Ty
:
reflect
.
TypeOf
(
ReceiptParaBindMinerInfo
{}),
Name
:
"TyLogParaBindMinerAddrUpdate"
},
TyLogParaBindMinerNode
:
{
Ty
:
reflect
.
TypeOf
(
ReceiptParaNodeBindListUpdate
{}),
Name
:
"TyLogParaBindNodeListUpdate"
},
TyLogParaSupervisionNodeGroupConfig
:
{
Ty
:
reflect
.
TypeOf
(
ReceiptParaNodeGroupConfig
{}),
Name
:
"LogParaSupervisionNodeGroupConfig"
},
TyLogParaSupervisionNodeGroupAddrsUpdate
:
{
Ty
:
reflect
.
TypeOf
(
types
.
ReceiptConfig
{}),
Name
:
"LogParaSupervisionNodeGroupAddrsUpdate"
},
TyLogParaSupervisionNodeConfig
:
{
Ty
:
reflect
.
TypeOf
(
ReceiptParaNodeConfig
{}),
Name
:
"LogParaSupervisionNodeConfig"
},
TyLogParaSupervisionNodeGroupAddrsUpdate
:
{
Ty
:
reflect
.
TypeOf
(
types
.
ReceiptConfig
{}),
Name
:
"LogParaSupervisionNodeGroupAddrsUpdate"
},
TyLogParaSupervisionNodeStatusUpdate
:
{
Ty
:
reflect
.
TypeOf
(
ReceiptParaNodeAddrStatUpdate
{}),
Name
:
"LogParaSupervisionNodeStatusUpdate"
},
TyLogParaStageSupervisionGroupUpdate
:
{
Ty
:
reflect
.
TypeOf
(
ReceiptSelfConsStagesUpdate
{}),
Name
:
"LogParaStageSupervisionGroupUpdate"
},
TyLogParaSupervisionNodeGroupStatusUpdate
:
{
Ty
:
reflect
.
TypeOf
(
ReceiptParaNodeGroupConfig
{}),
Name
:
"LogParaSupervisionNodeGroupStatusUpdate"
},
}
}
...
...
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