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
59f5fe56
Commit
59f5fe56
authored
Aug 26, 2019
by
mdj33
Committed by
vipwzw
Aug 28, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
filter nodegroup id
parent
4bd39400
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
190 additions
and
117 deletions
+190
-117
docker-compose.sh
build/docker-compose.sh
+25
-0
para.go
plugin/consensus/para/para.go
+4
-1
paramultidownload.go
plugin/consensus/para/paramultidownload.go
+2
-3
testcase.sh
plugin/dapp/paracross/cmd/build/testcase.sh
+12
-63
kv.go
plugin/dapp/paracross/executor/kv.go
+32
-6
query.go
plugin/dapp/paracross/executor/query.go
+68
-4
superaccount.go
plugin/dapp/paracross/executor/superaccount.go
+34
-40
superaccount_test.go
plugin/dapp/paracross/executor/superaccount_test.go
+13
-0
No files found.
build/docker-compose.sh
View file @
59f5fe56
...
...
@@ -234,6 +234,31 @@ function block_wait() {
echo
"wait new block
$count
s, cur height=
$expect
,old=
$cur_height
"
}
function
block_wait2height
()
{
if
[
"$#"
-lt
3
]
;
then
echo
"wrong block_wait params"
exit
1
fi
local
count
=
0
local
new_height
=
0
local
expect
=
${
2
}
local
isPara
=
${
3
}
while
true
;
do
new_height
=
$(${
1
}
block last_header | jq
".height"
)
if
[
$isPara
==
"1"
]
;
then
${
1
}
para blocks
-s
$new_height
-e
$new_height
new_height
=
$(${
1
}
para blocks
-s
$new_height
-e
$new_height
| jq
".items[0].mainHeight"
)
fi
if
[
"
${
new_height
}
"
-ge
"
${
expect
}
"
]
;
then
break
fi
count
=
$((
count
+
1
))
sleep
1
done
echo
"wait new block
$count
s, cur_height=
$new_height
,expect=
$expect
"
}
function
check_docker_status
()
{
status
=
$(
docker-compose ps |
grep
chain33_1 |
awk
'{print $6}'
)
statusPara
=
$(
docker-compose ps |
grep
chain33_1 |
awk
'{print $3}'
)
...
...
plugin/consensus/para/para.go
View file @
59f5fe56
...
...
@@ -131,7 +131,10 @@ func New(cfg *types.Consensus, sub []byte) queue.Module {
}
if
subcfg
.
BatchFetchBlockCount
<=
0
{
subcfg
.
BatchFetchBlockCount
=
batchFetchBlockCount
subcfg
.
BatchFetchBlockCount
=
types
.
MaxBlockCountPerTime
}
if
subcfg
.
BatchFetchBlockCount
>
types
.
MaxBlockCountPerTime
{
panic
(
fmt
.
Sprintf
(
"BatchFetchBlockCount=%d should be more than %d "
,
subcfg
.
BatchFetchBlockCount
,
types
.
MaxBlockCountPerTime
))
}
pk
,
err
:=
hex
.
DecodeString
(
minerPrivateKey
)
...
...
plugin/consensus/para/paramultidownload.go
View file @
59f5fe56
...
...
@@ -105,6 +105,7 @@ func (m *multiDldClient) testConn(conn *connectCli, inv *inventory) {
}()
t
:=
time
.
NewTimer
(
time
.
Second
*
time
.
Duration
(
conn
.
timeout
))
defer
t
.
Stop
()
select
{
case
<-
t
.
C
:
plog
.
Info
(
"multiServerDownload.testconn ip timeout"
,
"ip"
,
conn
.
ip
)
...
...
@@ -115,7 +116,6 @@ func (m *multiDldClient) testConn(conn *connectCli, inv *inventory) {
m
.
conns
=
append
(
m
.
conns
,
conn
)
m
.
mtx
.
Unlock
()
}
t
.
Stop
()
return
}
}
...
...
@@ -470,16 +470,15 @@ func requestMainBlockWithTime(inv *inventory) *types.ParaTxDetails {
}()
t
:=
time
.
NewTimer
(
time
.
Second
*
time
.
Duration
(
inv
.
connCli
.
timeout
))
defer
t
.
Stop
()
select
{
case
<-
t
.
C
:
plog
.
Debug
(
"requestMainBlockWithTime timeout"
,
"start"
,
inv
.
start
,
"end"
,
inv
.
end
,
"ip"
,
inv
.
connCli
.
ip
)
return
nil
case
ret
,
ok
:=
<-
retCh
:
if
!
ok
{
t
.
Stop
()
return
nil
}
t
.
Stop
()
return
ret
}
}
...
...
plugin/dapp/paracross/cmd/build/testcase.sh
View file @
59f5fe56
...
...
@@ -8,6 +8,7 @@ MAIN_CLI="docker exec ${NODE3} /root/chain33-cli"
PARANAME
=
"para"
PARA_COIN_FROZEN
=
"5.0000"
MainLoopCheckForkHeight
=
"60"
xsedfix
=
""
if
[
"
$(
uname
)
"
==
"Darwin"
]
;
then
...
...
@@ -40,7 +41,7 @@ function para_set_toml() {
sed
-i
$xsedfix
's/^MainForkParacrossCommitTx=.*/MainForkParacrossCommitTx=10/g'
"
${
1
}
"
sed
-i
$xsedfix
's/^MainParaSelfConsensusForkHeight=.*/MainParaSelfConsensusForkHeight=50/g'
"
${
1
}
"
sed
-i
$xsedfix
's/^MainLoopCheckCommitTxDoneForkHeight=.*/MainLoopCheckCommitTxDoneForkHeight=
60
/g'
"
${
1
}
"
sed
-i
$xsedfix
's/^MainLoopCheckCommitTxDoneForkHeight=.*/MainLoopCheckCommitTxDoneForkHeight=
'''
$MainLoopCheckForkHeight
'''
/g'
"
${
1
}
"
sed
-i
$xsedfix
's/^FetchFilterParaTxsEnable=.*/FetchFilterParaTxsEnable=1/g'
"
${
1
}
"
# rpc
...
...
@@ -448,13 +449,7 @@ function para_create_nodegroup_test() {
txhash
=
$(${
PARA_CLI
}
send para nodegroup
-o
1
-a
"1KSBd17H7ZK8iT37aJztFB22XGwsPTdwE4,1JRNjdEqp4LJ5fqycUBm9ayCKSeeskgMKR,1NLHPEcbTWWxxU3dGUZBhayjrCHD3psX7k,1MCftFynyvG2F4ED5mdHYgziDxx6vDrScs"
-c
5
-k
0xd165c84ed37c2a427fea487470ee671b7a0495d68d82607cafbc6348bf23bec5
)
echo
"tx=
$txhash
"
query_tx
"
${
PARA_CLI
}
"
"
${
txhash
}
"
id
=
$(${
PARA_CLI
}
tx query
-s
"
${
txhash
}
"
| jq
-r
".receipt.logs[0].log.current.id"
)
if
[
-z
"
$id
"
]
;
then
${
PARA_CLI
}
tx query
-s
"
${
txhash
}
"
echo
"group id not getted"
exit
1
fi
id
=
$txhash
balance
=
$(${
CLI
}
account balance
-a
1Ka7EPFRqs3v9yreXG6qA4RQbNmbPJCZPj
-e
paracross | jq
-r
".frozen"
)
if
[
"
$balance
"
!=
"20.0000"
]
;
then
...
...
@@ -489,13 +484,8 @@ function para_create_nodegroup() {
txhash
=
$(${
PARA_CLI
}
send para nodegroup
-o
1
-a
"1E5saiXVb9mW8wcWUUZjsHJPZs5GmdzuSY,1KSBd17H7ZK8iT37aJztFB22XGwsPTdwE4,1JRNjdEqp4LJ5fqycUBm9ayCKSeeskgMKR,1NLHPEcbTWWxxU3dGUZBhayjrCHD3psX7k,1MCftFynyvG2F4ED5mdHYgziDxx6vDrScs"
-c
6
-k
0xd165c84ed37c2a427fea487470ee671b7a0495d68d82607cafbc6348bf23bec5
)
echo
"tx=
$txhash
"
query_tx
"
${
PARA_CLI
}
"
"
${
txhash
}
"
id
=
$txhash
id
=
$(${
PARA_CLI
}
tx query
-s
"
${
txhash
}
"
| jq
-r
".receipt.logs[0].log.current.id"
)
if
[
-z
"
$id
"
]
;
then
${
PARA_CLI
}
tx query
-s
"
${
txhash
}
"
echo
"group id not getted"
exit
1
fi
balance
=
$(${
CLI
}
account balance
-a
1Ka7EPFRqs3v9yreXG6qA4RQbNmbPJCZPj
-e
paracross | jq
-r
".frozen"
)
if
[
"
$balance
"
!=
"30.0000"
]
;
then
echo
"apply coinfrozen error balance=
$balance
"
...
...
@@ -573,13 +563,7 @@ function para_nodegroup_behalf_quit_test() {
hash
=
$(${
PARA_CLI
}
send para node
-o
3
-a
1E5saiXVb9mW8wcWUUZjsHJPZs5GmdzuSY
-k
0x6da92a632ab7deb67d38c0f6560bcfed28167998f6496db64c258d5e8393a81b
)
echo
"
${
hash
}
"
query_tx
"
${
PARA_CLI
}
"
"
${
hash
}
"
id
=
$(${
PARA_CLI
}
tx query
-s
"
${
hash
}
"
| jq
-r
".receipt.logs[0].log.current.id"
)
if
[
-z
"
${
id
}
"
]
;
then
echo
"wrong id "
${
PARA_CLI
}
tx query
-s
"
${
hash
}
"
exit
1
fi
id
=
$hash
${
PARA_CLI
}
send para node
-o
2
-i
"
$id
"
-v
1
-k
0x6da92a632ab7deb67d38c0f6560bcfed28167998f6496db64c258d5e8393a81b
${
PARA_CLI
}
send para node
-o
2
-i
"
$id
"
-v
1
-k
0x19c069234f9d3e61135fefbeb7791b149cdf6af536f26bebb310d4cd22c3fee4
...
...
@@ -622,7 +606,7 @@ function para_nodemanage_cancel_test() {
hash
=
$(${
PARA_CLI
}
send para node
-o
1
-c
5
-a
1E5saiXVb9mW8wcWUUZjsHJPZs5GmdzuSY
-k
0x9c451df9e5cb05b88b28729aeaaeb3169a2414097401fcb4c79c1971df734588
)
echo
"
${
hash
}
"
query_tx
"
${
PARA_CLI
}
"
"
${
hash
}
"
id
=
$hash
balance
=
$(${
CLI
}
account balance
-a
1E5saiXVb9mW8wcWUUZjsHJPZs5GmdzuSY
-e
paracross | jq
-r
".frozen"
)
if
[
"
$balance
"
!=
"
$PARA_COIN_FROZEN
"
]
;
then
echo
"frozen coinfrozen error balance=
$balance
"
...
...
@@ -630,12 +614,6 @@ function para_nodemanage_cancel_test() {
fi
echo
"=========== # para chain node cancel ============="
id
=
$(${
PARA_CLI
}
tx query
-s
"
${
hash
}
"
| jq
-r
".receipt.logs[0].log.current.id"
)
if
[
-z
"
$id
"
]
;
then
echo
"id not found"
${
PARA_CLI
}
tx query
-s
"
${
hash
}
"
exit
1
fi
hash
=
$(${
PARA_CLI
}
send para node
-o
4
-i
"
$id
"
-k
0x9c451df9e5cb05b88b28729aeaaeb3169a2414097401fcb4c79c1971df734588
)
echo
"
${
hash
}
"
query_tx
"
${
PARA_CLI
}
"
"
${
hash
}
"
...
...
@@ -667,13 +645,7 @@ function para_nodemanage_test() {
echo
"frozen coinfrozen error balance=
$balance
"
exit
1
fi
id
=
$(${
PARA_CLI
}
tx query
-s
"
${
hash
}
"
| jq
-r
".receipt.logs[0].log.current.id"
)
if
[
-z
"
$id
"
]
;
then
echo
"id not found"
${
PARA_CLI
}
tx query
-s
"
${
hash
}
"
exit
1
fi
id
=
$hash
echo
"=========== # para chain node vote ============="
${
PARA_CLI
}
send para node
-o
2
-i
"
$id
"
-v
2
-k
0x6da92a632ab7deb67d38c0f6560bcfed28167998f6496db64c258d5e8393a81b
...
...
@@ -712,13 +684,7 @@ function para_nodemanage_test() {
txhash
=
$(${
PARA_CLI
}
send para node
-o
3
-a
1KSBd17H7ZK8iT37aJztFB22XGwsPTdwE4
-k
0x9c451df9e5cb05b88b28729aeaaeb3169a2414097401fcb4c79c1971df734588
)
echo
"
${
txhash
}
"
query_tx
"
${
PARA_CLI
}
"
"
${
txhash
}
"
id
=
$(${
PARA_CLI
}
tx query
-s
"
${
txhash
}
"
| jq
-r
".receipt.logs[0].log.current.id"
)
if
[
-z
"
$id
"
]
;
then
echo
"id not found"
${
PARA_CLI
}
tx query
-s
"
${
txhash
}
"
exit
1
fi
id
=
$txhash
echo
"=========== # para chain node vote quit ============="
${
PARA_CLI
}
send para node
-o
2
-i
"
$id
"
-v
2
-k
0x6da92a632ab7deb67d38c0f6560bcfed28167998f6496db64c258d5e8393a81b
...
...
@@ -755,6 +721,7 @@ function para_nodemanage_node_behalf_join() {
hash
=
$(${
PARA_CLI
}
send para node
-o
1
-c
8
-a
1NNaYHkscJaLJ2wUrFNeh6cQXBS4TrFYeB
-k
0xd165c84ed37c2a427fea487470ee671b7a0495d68d82607cafbc6348bf23bec5
)
echo
"
${
hash
}
"
query_tx
"
${
PARA_CLI
}
"
"
${
hash
}
"
node1_id
=
$hash
balance
=
$(${
CLI
}
account balance
-a
1Ka7EPFRqs3v9yreXG6qA4RQbNmbPJCZPj
-e
paracross | jq
-r
".frozen"
)
if
[
"
$balance
"
!=
"32.0000"
]
;
then
...
...
@@ -768,17 +735,11 @@ function para_nodemanage_node_behalf_join() {
exit
1
fi
node1_id
=
$(${
PARA_CLI
}
tx query
-s
"
${
hash
}
"
| jq
-r
".receipt.logs[0].log.current.id"
)
if
[
-z
"
$node1_id
"
]
;
then
echo
"id not found"
${
PARA_CLI
}
tx query
-s
"
${
hash
}
"
exit
1
fi
echo
"=========== # para chain new node join 2============="
hash
=
$(${
PARA_CLI
}
send para node
-o
1
-c
9
-a
1NNaYHkscJaLJ2wUrFNeh6cQXBS4TrFYeB
-k
0xd165c84ed37c2a427fea487470ee671b7a0495d68d82607cafbc6348bf23bec5
)
echo
"
${
hash
}
"
query_tx
"
${
PARA_CLI
}
"
"
${
hash
}
"
id
=
$hash
balance
=
$(${
CLI
}
account balance
-a
1Ka7EPFRqs3v9yreXG6qA4RQbNmbPJCZPj
-e
paracross | jq
-r
".frozen"
)
if
[
"
$balance
"
!=
"41.0000"
]
;
then
...
...
@@ -786,13 +747,6 @@ function para_nodemanage_node_behalf_join() {
exit
1
fi
id
=
$(${
PARA_CLI
}
tx query
-s
"
${
hash
}
"
| jq
-r
".receipt.logs[0].log.current.id"
)
if
[
-z
"
$id
"
]
;
then
echo
"id not found"
${
PARA_CLI
}
tx query
-s
"
${
hash
}
"
exit
1
fi
${
PARA_CLI
}
send para node
-o
2
-i
"
$id
"
-v
1
-k
0x6da92a632ab7deb67d38c0f6560bcfed28167998f6496db64c258d5e8393a81b
${
PARA_CLI
}
send para node
-o
2
-i
"
$id
"
-v
1
-k
0x19c069234f9d3e61135fefbeb7791b149cdf6af536f26bebb310d4cd22c3fee4
hash
=
$(${
PARA_CLI
}
send para node
-o
2
-i
"
$id
"
-v
1
-k
0x7a80a1f75d7360c6123c32a78ecf978c1ac55636f87892df38d8b85a9aeff115
)
...
...
@@ -854,13 +808,7 @@ function para_nodemanage_node_behalf_join() {
hash
=
$(${
PARA_CLI
}
send para node
-o
3
-a
1NNaYHkscJaLJ2wUrFNeh6cQXBS4TrFYeB
-k
0x794443611e7369a57b078881445b93b754cbc9b9b8f526535ab9c6d21d29203d
)
echo
"
${
hash
}
"
query_tx
"
${
PARA_CLI
}
"
"
${
hash
}
"
id
=
$(${
PARA_CLI
}
tx query
-s
"
${
hash
}
"
| jq
-r
".receipt.logs[0].log.current.id"
)
if
[
-z
"
$id
"
]
;
then
echo
"id not found"
${
PARA_CLI
}
tx query
-s
"
${
hash
}
"
exit
1
fi
id
=
$hash
echo
"=========== # para chain node2 vote quit ============="
${
PARA_CLI
}
send para node
-o
2
-i
"
$id
"
-v
1
-k
0x6da92a632ab7deb67d38c0f6560bcfed28167998f6496db64c258d5e8393a81b
...
...
@@ -950,6 +898,7 @@ function privacy_transfer_test() {
function
para_test
()
{
echo
"=========== # para chain test ============="
block_wait2height
"
${
PARA_CLI
}
"
$MainLoopCheckForkHeight
"1"
para_create_nodegroup
para_nodegroup_behalf_quit_test
para_nodemanage_cancel_test
...
...
plugin/dapp/paracross/executor/kv.go
View file @
59f5fe56
...
...
@@ -7,9 +7,15 @@ package executor
import
(
"fmt"
"strings"
"github.com/33cn/chain33/types"
)
const
(
paraNodeIDUnifyPrefix
=
"mavl-paracross-title-node"
)
var
(
title
string
titleHeight
string
...
...
@@ -17,8 +23,8 @@ var (
paraConfigNodes
string
//平行链自组织配置的nodes,最初是从manager同步过来
paraConfigNodeAddr
string
//平行链配置节点账户
paraNodeGroupStatusAddrs
string
//正在申请的addrs
paraNodeID
string
paraNodeGroupID
string
paraNodeID
Prefix
string
paraNodeGroupID
Prefix
string
localTx
string
localTitle
string
localTitleHeight
string
...
...
@@ -35,8 +41,8 @@ func setPrefix() {
paraConfigNodes
=
"mavl-paracross-nodes-title-"
paraConfigNodeAddr
=
"mavl-paracross-nodes-titleAddr-"
paraNodeGroupStatusAddrs
=
"mavl-paracross-nodegroup-apply-title-"
paraNodeID
=
"mavl-paracross-title-nodeid-"
paraNodeGroupID
=
"mavl-paracross-title-nodegroupid-"
paraNodeID
Prefix
=
"mavl-paracross-title-nodeid-"
paraNodeGroupID
Prefix
=
"mavl-paracross-title-nodegroupid-"
localTx
=
"LODB-paracross-titleHeightAddr-"
localTitle
=
"LODB-paracross-title-"
localTitleHeight
=
"LODB-paracross-titleHeight-"
...
...
@@ -79,11 +85,31 @@ func calcParaNodeGroupStatusKey(title string) []byte {
}
func
calcParaNodeIDKey
(
title
,
hash
string
)
string
{
return
fmt
.
Sprintf
(
paraNodeID
+
"%s-%s"
,
title
,
hash
)
return
fmt
.
Sprintf
(
paraNodeID
Prefix
+
"%s-%s"
,
title
,
hash
)
}
func
calcParaNodeGroupIDKey
(
title
,
hash
string
)
string
{
return
fmt
.
Sprintf
(
paraNodeGroupID
+
"%s-%s"
,
title
,
hash
)
return
fmt
.
Sprintf
(
paraNodeGroupIDPrefix
+
"%s-%s"
,
title
,
hash
)
}
func
getParaNodeIDSuffix
(
id
string
)
string
{
if
!
strings
.
HasPrefix
(
id
,
paraNodeIDUnifyPrefix
)
{
return
id
}
ids
:=
strings
.
Split
(
id
,
"-"
)
txId
:=
ids
[
len
(
ids
)
-
1
]
if
strings
.
HasPrefix
(
txId
,
"0x"
)
{
return
txId
}
//对于nodegroup 创建的"mavl-paracross-title-nodegroupid-user.p.para.-0xb6cd0274587...a61e444e9f848a4c02d7b-1"特殊场景
if
len
(
ids
)
>
1
{
txId
=
ids
[
len
(
ids
)
-
2
]
+
"-"
+
txId
if
strings
.
HasPrefix
(
txId
,
"0x"
)
{
return
txId
}
}
return
id
}
func
calcLocalTxKey
(
title
string
,
height
int64
,
addr
string
)
[]
byte
{
...
...
plugin/dapp/paracross/executor/query.go
View file @
59f5fe56
...
...
@@ -90,19 +90,46 @@ func (p *Paracross) Query_GetNodeAddrInfo(in *pt.ReqParacrossNodeInfo) (types.Me
if
err
!=
nil
{
return
nil
,
err
}
mainHeight
,
err
:=
p
.
getMainHeight
()
if
err
!=
nil
{
return
nil
,
err
}
if
pt
.
IsParaForkHeight
(
mainHeight
,
pt
.
ForkLoopCheckCommitTxDone
)
{
stat
.
QuitId
=
getParaNodeIDSuffix
(
stat
.
QuitId
)
stat
.
ProposalId
=
getParaNodeIDSuffix
(
stat
.
ProposalId
)
}
return
stat
,
nil
}
func
(
p
*
Paracross
)
getMainHeight
()
(
int64
,
error
)
{
mainHeight
:=
p
.
GetMainHeight
()
if
types
.
IsPara
()
{
block
,
err
:=
p
.
GetAPI
()
.
GetBlocks
(
&
types
.
ReqBlocks
{
Start
:
p
.
GetHeight
(),
End
:
p
.
GetHeight
()})
if
err
!=
nil
||
block
==
nil
||
len
(
block
.
Items
)
==
0
{
return
-
1
,
types
.
ErrBlockExist
}
mainHeight
=
block
.
Items
[
0
]
.
Block
.
MainHeight
}
return
mainHeight
,
nil
}
//Query_GetNodeIDInfo get specific node addr info
func
(
p
*
Paracross
)
Query_GetNodeIDInfo
(
in
*
pt
.
ReqParacrossNodeInfo
)
(
types
.
Message
,
error
)
{
if
in
==
nil
||
in
.
Title
==
""
||
in
.
Id
==
""
{
return
nil
,
types
.
ErrInvalidParam
}
stat
,
err
:=
getNodeID
(
p
.
GetStateDB
(),
in
.
Id
)
mainHeight
,
err
:=
p
.
getMainHeight
()
if
err
!=
nil
{
return
nil
,
err
}
stat
,
err
:=
getNodeIDWithFork
(
p
.
GetStateDB
(),
in
.
Title
,
mainHeight
,
in
.
Id
)
if
err
!=
nil
{
return
nil
,
err
}
if
pt
.
IsParaForkHeight
(
mainHeight
,
pt
.
ForkLoopCheckCommitTxDone
)
{
stat
.
Id
=
getParaNodeIDSuffix
(
stat
.
Id
)
}
return
stat
,
nil
}
...
...
@@ -111,7 +138,22 @@ func (p *Paracross) Query_ListNodeStatusInfo(in *pt.ReqParacrossNodeInfo) (types
if
in
==
nil
||
in
.
Title
==
""
{
return
nil
,
types
.
ErrInvalidParam
}
return
listLocalNodeStatus
(
p
.
GetLocalDB
(),
in
.
Title
,
in
.
Status
)
resp
,
err
:=
listLocalNodeStatus
(
p
.
GetLocalDB
(),
in
.
Title
,
in
.
Status
)
if
err
!=
nil
{
return
resp
,
err
}
mainHeight
,
err
:=
p
.
getMainHeight
()
if
err
!=
nil
{
return
nil
,
err
}
if
!
pt
.
IsParaForkHeight
(
mainHeight
,
pt
.
ForkLoopCheckCommitTxDone
)
{
return
resp
,
err
}
addrs
:=
resp
.
(
*
pt
.
RespParacrossNodeAddrs
)
for
_
,
id
:=
range
addrs
.
Ids
{
id
.
Id
=
getParaNodeIDSuffix
(
id
.
Id
)
}
return
resp
,
nil
}
//Query_GetNodeGroupStatus get specific node addr info
...
...
@@ -121,8 +163,15 @@ func (p *Paracross) Query_GetNodeGroupStatus(in *pt.ReqParacrossNodeInfo) (types
}
stat
,
err
:=
getNodeGroupStatus
(
p
.
GetStateDB
(),
in
.
Title
)
if
err
!=
nil
{
return
stat
,
err
}
mainHeight
,
err
:=
p
.
getMainHeight
()
if
err
!=
nil
{
return
nil
,
err
}
if
pt
.
IsParaForkHeight
(
mainHeight
,
pt
.
ForkLoopCheckCommitTxDone
)
{
stat
.
Id
=
getParaNodeIDSuffix
(
stat
.
Id
)
}
return
stat
,
nil
}
...
...
@@ -131,7 +180,22 @@ func (p *Paracross) Query_ListNodeGroupStatus(in *pt.ReqParacrossNodeInfo) (type
if
in
==
nil
{
return
nil
,
types
.
ErrInvalidParam
}
return
listLocalNodeGroupStatus
(
p
.
GetLocalDB
(),
in
.
Status
)
resp
,
err
:=
listLocalNodeGroupStatus
(
p
.
GetLocalDB
(),
in
.
Status
)
if
err
!=
nil
{
return
resp
,
err
}
mainHeight
,
err
:=
p
.
getMainHeight
()
if
err
!=
nil
{
return
nil
,
err
}
if
pt
.
IsParaForkHeight
(
mainHeight
,
pt
.
ForkLoopCheckCommitTxDone
)
{
addrs
:=
resp
.
(
*
pt
.
RespParacrossNodeGroups
)
for
_
,
id
:=
range
addrs
.
Ids
{
id
.
Id
=
getParaNodeIDSuffix
(
id
.
Id
)
}
}
return
resp
,
nil
}
//Query_ListTitles query paracross titles list
...
...
plugin/dapp/paracross/executor/superaccount.go
View file @
59f5fe56
...
...
@@ -57,6 +57,14 @@ func getNodeID(db dbm.KV, id string) (*pt.ParaNodeIdStatus, error) {
return
&
status
,
err
}
//分叉之前 id是"mavl-paracros-...0x12342308b"格式,分叉以后只支持输入为去掉了mavl-paracross前缀的交易id,系统会为id加上前缀
func
getNodeIDWithFork
(
db
dbm
.
KV
,
title
string
,
height
int64
,
id
string
)
(
*
pt
.
ParaNodeIdStatus
,
error
)
{
if
pt
.
IsParaForkHeight
(
height
,
pt
.
ForkLoopCheckCommitTxDone
)
{
id
=
calcParaNodeIDKey
(
title
,
id
)
}
return
getNodeID
(
db
,
id
)
}
func
getNodeGroupStatus
(
db
dbm
.
KV
,
title
string
)
(
*
pt
.
ParaNodeGroupStatus
,
error
)
{
key
:=
calcParaNodeGroupStatusKey
(
title
)
val
,
err
:=
db
.
Get
(
key
)
...
...
@@ -77,7 +85,11 @@ func getDb(db dbm.KV, key []byte) ([]byte, error) {
return
val
,
nil
}
func
getNodeGroupID
(
db
dbm
.
KV
,
id
string
)
(
*
pt
.
ParaNodeGroupStatus
,
error
)
{
//分叉之前 id是"mavl-paracros-...0x12342308b"格式,分叉以后只支持输入为去掉了mavl-paracross前缀的交易id,系统会为id加上前缀
func
getNodeGroupID
(
db
dbm
.
KV
,
title
string
,
height
int64
,
id
string
)
(
*
pt
.
ParaNodeGroupStatus
,
error
)
{
if
pt
.
IsParaForkHeight
(
height
,
pt
.
ForkLoopCheckCommitTxDone
)
{
id
=
calcParaNodeGroupIDKey
(
title
,
id
)
}
val
,
err
:=
getDb
(
db
,
[]
byte
(
id
))
if
err
!=
nil
{
return
nil
,
err
...
...
@@ -253,43 +265,25 @@ func (a *action) nodeJoin(config *pt.ParaNodeAddrConfig) (*types.Receipt, error)
}
addrStat
,
err
:=
getNodeAddr
(
a
.
db
,
config
.
Title
,
config
.
Addr
)
if
err
!=
nil
{
if
!
isNotFound
(
err
)
{
return
nil
,
err
}
clog
.
Info
(
"first time add node addr"
,
"title"
,
config
.
Title
,
"addr"
,
config
.
Addr
)
stat
:=
&
pt
.
ParaNodeIdStatus
{
Id
:
calcParaNodeIDKey
(
config
.
Title
,
common
.
ToHex
(
a
.
txhash
)),
Status
:
pt
.
ParacrossNodeJoining
,
Title
:
config
.
Title
,
TargetAddr
:
config
.
Addr
,
FromAddr
:
a
.
fromaddr
,
Votes
:
&
pt
.
ParaNodeVoteDetail
{},
CoinsFrozen
:
config
.
CoinsFrozen
,
Height
:
a
.
height
}
r
:=
makeNodeConfigReceipt
(
a
.
fromaddr
,
config
,
nil
,
stat
)
receipt
.
KV
=
append
(
receipt
.
KV
,
r
.
KV
...
)
receipt
.
Logs
=
append
(
receipt
.
Logs
,
r
.
Logs
...
)
return
receipt
,
nil
if
err
!=
nil
&&
!
isNotFound
(
err
)
{
return
nil
,
errors
.
Wrapf
(
err
,
"nodeJoin get title=%s,nodeAddr=%s"
,
config
.
Title
,
config
.
Addr
)
}
if
addrStat
.
Status
==
pt
.
ParacrossNodeQuited
{
stat
:=
&
pt
.
ParaNodeIdStatus
{
Id
:
calcParaNodeIDKey
(
config
.
Title
,
common
.
ToHex
(
a
.
txhash
)),
Status
:
pt
.
ParacrossNodeJoining
,
Title
:
config
.
Title
,
TargetAddr
:
config
.
Addr
,
FromAddr
:
a
.
fromaddr
,
Votes
:
&
pt
.
ParaNodeVoteDetail
{},
CoinsFrozen
:
config
.
CoinsFrozen
,
Height
:
a
.
height
}
r
:=
makeNodeConfigReceipt
(
a
.
fromaddr
,
config
,
nil
,
stat
)
receipt
.
KV
=
append
(
receipt
.
KV
,
r
.
KV
...
)
receipt
.
Logs
=
append
(
receipt
.
Logs
,
r
.
Logs
...
)
return
receipt
,
nil
if
addrStat
!=
nil
&&
addrStat
.
Status
!=
pt
.
ParacrossNodeQuited
{
return
nil
,
errors
.
Wrapf
(
pt
.
ErrParaNodeAddrExisted
,
"nodeJoin nodeAddr existed:%s,status:%d"
,
config
.
Addr
,
addrStat
.
Status
)
}
return
nil
,
errors
.
Wrapf
(
pt
.
ErrParaNodeAddrExisted
,
"nodeAddr existed:%s,status:%d"
,
config
.
Addr
,
addrStat
.
Status
)
stat
:=
&
pt
.
ParaNodeIdStatus
{
Id
:
calcParaNodeIDKey
(
config
.
Title
,
common
.
ToHex
(
a
.
txhash
)),
Status
:
pt
.
ParacrossNodeJoining
,
Title
:
config
.
Title
,
TargetAddr
:
config
.
Addr
,
FromAddr
:
a
.
fromaddr
,
Votes
:
&
pt
.
ParaNodeVoteDetail
{},
CoinsFrozen
:
config
.
CoinsFrozen
,
Height
:
a
.
height
}
r
:=
makeNodeConfigReceipt
(
a
.
fromaddr
,
config
,
nil
,
stat
)
receipt
.
KV
=
append
(
receipt
.
KV
,
r
.
KV
...
)
receipt
.
Logs
=
append
(
receipt
.
Logs
,
r
.
Logs
...
)
return
receipt
,
nil
}
...
...
@@ -323,7 +317,7 @@ func (a *action) nodeQuit(config *pt.ParaNodeAddrConfig) (*types.Receipt, error)
}
func
(
a
*
action
)
nodeCancel
(
config
*
pt
.
ParaNodeAddrConfig
)
(
*
types
.
Receipt
,
error
)
{
stat
,
err
:=
getNodeID
(
a
.
db
,
config
.
Id
)
stat
,
err
:=
getNodeID
WithFork
(
a
.
db
,
config
.
Title
,
a
.
exec
.
GetMainHeight
()
,
config
.
Id
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -504,7 +498,7 @@ func (a *action) nodeVote(config *pt.ParaNodeAddrConfig) (*types.Receipt, error)
return
nil
,
errors
.
Wrapf
(
pt
.
ErrNodeNotForTheTitle
,
"not validNode:%s"
,
a
.
fromaddr
)
}
stat
,
err
:=
getNodeID
(
a
.
db
,
config
.
Id
)
stat
,
err
:=
getNodeID
WithFork
(
a
.
db
,
config
.
Title
,
a
.
exec
.
GetMainHeight
()
,
config
.
Id
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -818,7 +812,7 @@ func (a *action) nodeGroupModify(config *pt.ParaNodeGroupConfig) (*types.Receipt
}
func
(
a
*
action
)
nodeGroupQuit
(
config
*
pt
.
ParaNodeGroupConfig
)
(
*
types
.
Receipt
,
error
)
{
status
,
err
:=
getNodeGroupID
(
a
.
db
,
config
.
Id
)
status
,
err
:=
getNodeGroupID
(
a
.
db
,
config
.
Title
,
a
.
exec
.
GetMainHeight
(),
config
.
Id
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -937,7 +931,7 @@ func (a *action) nodeGroupApprove(config *pt.ParaNodeGroupConfig) (*types.Receip
return
nil
,
errors
.
Wrapf
(
types
.
ErrNotAllow
,
"node group approve not super manager:%s"
,
a
.
fromaddr
)
}
id
,
err
:=
getNodeGroupID
(
a
.
db
,
config
.
Id
)
id
,
err
:=
getNodeGroupID
(
a
.
db
,
config
.
Title
,
a
.
exec
.
GetMainHeight
(),
config
.
Id
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
plugin/dapp/paracross/executor/superaccount_test.go
View file @
59f5fe56
...
...
@@ -354,3 +354,16 @@ func TestUpdateVotes(t *testing.T) {
assert
.
Equal
(
t
,
[]
string
{
"BB"
,
"CC"
},
stat
.
Votes
.
Addrs
)
assert
.
Equal
(
t
,
[]
string
{
"no"
,
"no"
},
stat
.
Votes
.
Votes
)
}
func
TestGetNodeIdSuffix
(
t
*
testing
.
T
)
{
txID
:=
"0xb6cd0274aa5f839fa2291ecfbfc626b494aacac7587a61e444e9f848a4c02d7b"
id
:=
"mavl-paracross-title-nodegroupid-user.p.para.-0xb6cd0274aa5f839fa2291ecfbfc626b494aacac7587a61e444e9f848a4c02d7b"
rtID
:=
getParaNodeIDSuffix
(
id
)
assert
.
Equal
(
t
,
txID
,
rtID
)
txID
=
"0xb6cd0274aa5f839fa2291ecfbfc626b494aacac7587a61e444e9f848a4c02d7b-1"
id
=
"mavl-paracross-title-nodegroupid-user.p.para.-0xb6cd0274aa5f839fa2291ecfbfc626b494aacac7587a61e444e9f848a4c02d7b-1"
rtID
=
getParaNodeIDSuffix
(
id
)
assert
.
Equal
(
t
,
txID
,
rtID
)
}
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