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
48dbbc8b
Commit
48dbbc8b
authored
Jun 04, 2019
by
张振华
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into guess-rpc-test
parents
16d381fc
e3d68c56
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
294 additions
and
183 deletions
+294
-183
paracommitmsg.go
plugin/consensus/para/paracommitmsg.go
+2
-2
testcase.sh
plugin/dapp/paracross/cmd/build/testcase.sh
+0
-0
paracross.go
plugin/dapp/paracross/commands/paracross.go
+18
-34
action.go
plugin/dapp/paracross/executor/action.go
+22
-8
exec_del_local.go
plugin/dapp/paracross/executor/exec_del_local.go
+5
-6
exec_local.go
plugin/dapp/paracross/executor/exec_local.go
+5
-6
kv.go
plugin/dapp/paracross/executor/kv.go
+31
-11
query.go
plugin/dapp/paracross/executor/query.go
+39
-10
reward.go
plugin/dapp/paracross/executor/reward.go
+3
-1
superaccount.go
plugin/dapp/paracross/executor/superaccount.go
+0
-0
superaccount_test.go
plugin/dapp/paracross/executor/superaccount_test.go
+64
-42
paracross.proto
plugin/dapp/paracross/proto/paracross.proto
+49
-41
rpc.go
plugin/dapp/paracross/rpc/rpc.go
+29
-3
errors.go
plugin/dapp/paracross/types/errors.go
+0
-2
paracross.go
plugin/dapp/paracross/types/paracross.go
+24
-13
paracross.pb.go
plugin/dapp/paracross/types/paracross.pb.go
+0
-0
type.go
plugin/dapp/paracross/types/type.go
+3
-4
No files found.
plugin/consensus/para/paracommitmsg.go
View file @
48dbbc8b
...
@@ -18,8 +18,8 @@ import (
...
@@ -18,8 +18,8 @@ import (
)
)
var
(
var
(
consensusInterval
=
1
6
//about 1 new block interval
consensusInterval
=
1
0
//about 1 new block interval
minerInterval
=
5
minerInterval
=
10
//5s的主块间隔后分叉概率增加,10s可以消除一些分叉回退
)
)
type
commitMsgClient
struct
{
type
commitMsgClient
struct
{
...
...
plugin/dapp/paracross/cmd/build/testcase.sh
View file @
48dbbc8b
This diff is collapsed.
Click to expand it.
plugin/dapp/paracross/commands/paracross.go
View file @
48dbbc8b
...
@@ -251,36 +251,25 @@ func CreateRawNodeManageCmd() *cobra.Command {
...
@@ -251,36 +251,25 @@ func CreateRawNodeManageCmd() *cobra.Command {
}
}
func
addNodeManageFlags
(
cmd
*
cobra
.
Command
)
{
func
addNodeManageFlags
(
cmd
*
cobra
.
Command
)
{
cmd
.
Flags
()
.
StringP
(
"operation"
,
"o"
,
""
,
"operation:join,quit,vote
"
)
cmd
.
Flags
()
.
Uint32P
(
"operation"
,
"o"
,
0
,
"operation:1:join,2:vote,3:quit
"
)
cmd
.
MarkFlagRequired
(
"operation"
)
cmd
.
MarkFlagRequired
(
"operation"
)
cmd
.
Flags
()
.
StringP
(
"addr"
,
"a"
,
""
,
"operating target addr"
)
cmd
.
Flags
()
.
StringP
(
"addr"
,
"a"
,
""
,
"operating target addr"
)
cmd
.
MarkFlagRequired
(
"addrs"
)
cmd
.
Flags
()
.
StringP
(
"value"
,
"v"
,
""
,
"vote value: yes,no"
)
cmd
.
Flags
()
.
StringP
(
"id"
,
"i"
,
""
,
"operating target id"
)
cmd
.
Flags
()
.
Float64P
(
"coins_frozen"
,
"c"
,
0
,
"join to frozen coins amount, not less config"
)
cmd
.
Flags
()
.
Uint32P
(
"value"
,
"v"
,
1
,
"vote value: 1:yes,2:no"
)
cmd
.
Flags
()
.
Float64P
(
"coins_frozen"
,
"c"
,
0
,
"frozen coins amount, should not less nodegroup's"
)
}
}
func
createNodeTx
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
createNodeTx
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
op
,
_
:=
cmd
.
Flags
()
.
Get
String
(
"operation"
)
op
,
_
:=
cmd
.
Flags
()
.
Get
Uint32
(
"operation"
)
opAddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"addr"
)
opAddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"addr"
)
val
,
_
:=
cmd
.
Flags
()
.
GetString
(
"value"
)
id
,
_
:=
cmd
.
Flags
()
.
GetString
(
"id"
)
val
,
_
:=
cmd
.
Flags
()
.
GetUint32
(
"value"
)
coins
,
_
:=
cmd
.
Flags
()
.
GetFloat64
(
"coins_frozen"
)
coins
,
_
:=
cmd
.
Flags
()
.
GetFloat64
(
"coins_frozen"
)
if
op
!=
"vote"
&&
op
!=
"quit"
&&
op
!=
"join"
{
payload
:=
&
pt
.
ParaNodeAddrConfig
{
Op
:
op
,
Id
:
id
,
Value
:
val
,
Addr
:
opAddr
,
CoinsFrozen
:
int64
(
math
.
Trunc
((
coins
+
0.0000001
)
*
1e4
))
*
1e4
}
fmt
.
Println
(
"operation should be one of join,quit,vote"
)
return
}
if
opAddr
==
""
{
fmt
.
Println
(
"addr parameter should not be null"
)
return
}
if
op
==
"vote"
&&
(
val
!=
"yes"
&&
val
!=
"no"
)
{
fmt
.
Println
(
"vote operation value parameter require yes or no value"
)
return
}
payload
:=
&
pt
.
ParaNodeAddrConfig
{
Op
:
op
,
Value
:
val
,
Addr
:
opAddr
,
CoinsFrozen
:
int64
(
math
.
Trunc
((
coins
+
0.0000001
)
*
1e4
))
*
1e4
}
params
:=
&
rpctypes
.
CreateTxIn
{
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
pt
.
ParaX
),
Execer
:
types
.
ExecName
(
pt
.
ParaX
),
ActionName
:
"NodeConfig"
,
ActionName
:
"NodeConfig"
,
...
@@ -305,11 +294,12 @@ func CreateNodeGroupApplyCmd() *cobra.Command {
...
@@ -305,11 +294,12 @@ func CreateNodeGroupApplyCmd() *cobra.Command {
}
}
func
addNodeGroupApplyCmdFlags
(
cmd
*
cobra
.
Command
)
{
func
addNodeGroupApplyCmdFlags
(
cmd
*
cobra
.
Command
)
{
cmd
.
Flags
()
.
Uint32P
(
"operation"
,
"o"
,
0
,
"operation:1:apply,2:approve,3:quit"
)
cmd
.
Flags
()
.
Uint32P
(
"operation"
,
"o"
,
0
,
"operation:1:apply,2:approve,3:quit
,4:modify
"
)
cmd
.
MarkFlagRequired
(
"operation"
)
cmd
.
MarkFlagRequired
(
"operation"
)
cmd
.
Flags
()
.
StringP
(
"id"
,
"i"
,
""
,
"apply id for nodegroup "
)
cmd
.
Flags
()
.
StringP
(
"addrs"
,
"a"
,
""
,
"addrs apply for super node,split by ',' "
)
cmd
.
Flags
()
.
StringP
(
"addrs"
,
"a"
,
""
,
"addrs apply for super node,split by ',' "
)
cmd
.
MarkFlagRequired
(
"addrs"
)
cmd
.
Flags
()
.
Float64P
(
"coins_frozen"
,
"c"
,
0
,
"coins amount to frozen, not less config"
)
cmd
.
Flags
()
.
Float64P
(
"coins_frozen"
,
"c"
,
0
,
"coins amount to frozen, not less config"
)
...
@@ -318,18 +308,10 @@ func addNodeGroupApplyCmdFlags(cmd *cobra.Command) {
...
@@ -318,18 +308,10 @@ func addNodeGroupApplyCmdFlags(cmd *cobra.Command) {
func
nodeGroupApply
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
nodeGroupApply
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
op
,
_
:=
cmd
.
Flags
()
.
GetUint32
(
"operation"
)
op
,
_
:=
cmd
.
Flags
()
.
GetUint32
(
"operation"
)
addrs
,
_
:=
cmd
.
Flags
()
.
GetString
(
"addrs"
)
addrs
,
_
:=
cmd
.
Flags
()
.
GetString
(
"addrs"
)
id
,
_
:=
cmd
.
Flags
()
.
GetString
(
"id"
)
coins
,
_
:=
cmd
.
Flags
()
.
GetFloat64
(
"coins_frozen"
)
coins
,
_
:=
cmd
.
Flags
()
.
GetFloat64
(
"coins_frozen"
)
if
op
==
0
||
op
>
3
{
payload
:=
&
pt
.
ParaNodeGroupConfig
{
Op
:
op
,
Id
:
id
,
Addrs
:
addrs
,
CoinsFrozen
:
int64
(
math
.
Trunc
((
coins
+
0.0000001
)
*
1e4
))
*
1e4
}
fmt
.
Println
(
"operation should be one of 1:apply,2:approve,3:quit"
)
return
}
if
addrs
==
""
{
fmt
.
Println
(
"addrs should not be nil"
)
return
}
payload
:=
&
pt
.
ParaNodeGroupConfig
{
Op
:
op
,
Addrs
:
addrs
,
CoinsFrozen
:
int64
(
math
.
Trunc
((
coins
+
0.0000001
)
*
1e4
))
*
1e4
}
params
:=
&
rpctypes
.
CreateTxIn
{
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
pt
.
ParaX
),
Execer
:
types
.
ExecName
(
pt
.
ParaX
),
ActionName
:
"NodeGroupConfig"
,
ActionName
:
"NodeGroupConfig"
,
...
@@ -486,7 +468,7 @@ func addNodeBodyCmdFlags(cmd *cobra.Command) {
...
@@ -486,7 +468,7 @@ func addNodeBodyCmdFlags(cmd *cobra.Command) {
cmd
.
MarkFlagRequired
(
"title"
)
cmd
.
MarkFlagRequired
(
"title"
)
cmd
.
Flags
()
.
StringP
(
"addr"
,
"a"
,
""
,
"addr apply for super user"
)
cmd
.
Flags
()
.
StringP
(
"addr"
,
"a"
,
""
,
"addr apply for super user"
)
cmd
.
MarkFlagRequired
(
"add
r"
)
cmd
.
Flags
()
.
StringP
(
"id"
,
"i"
,
""
,
"id apply for super use
r"
)
}
}
...
@@ -494,12 +476,14 @@ func nodeInfo(cmd *cobra.Command, args []string) {
...
@@ -494,12 +476,14 @@ func nodeInfo(cmd *cobra.Command, args []string) {
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
title
,
_
:=
cmd
.
Flags
()
.
GetString
(
"title"
)
title
,
_
:=
cmd
.
Flags
()
.
GetString
(
"title"
)
addr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"addr"
)
addr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"addr"
)
id
,
_
:=
cmd
.
Flags
()
.
GetString
(
"id"
)
params
:=
pt
.
ReqParacrossNodeInfo
{
params
:=
pt
.
ReqParacrossNodeInfo
{
Title
:
title
,
Title
:
title
,
Addr
:
addr
,
Addr
:
addr
,
Id
:
id
,
}
}
var
res
pt
.
ParaNode
Addr
Status
var
res
pt
.
ParaNode
Id
Status
ctx
:=
jsonclient
.
NewRPCCtx
(
rpcLaddr
,
"paracross.GetNodeStatus"
,
params
,
&
res
)
ctx
:=
jsonclient
.
NewRPCCtx
(
rpcLaddr
,
"paracross.GetNodeStatus"
,
params
,
&
res
)
ctx
.
Run
()
ctx
.
Run
()
}
}
...
...
plugin/dapp/paracross/executor/action.go
View file @
48dbbc8b
...
@@ -77,7 +77,7 @@ func getConfigManageNodes(db dbm.KV, title string) (map[string]struct{}, []strin
...
@@ -77,7 +77,7 @@ func getConfigManageNodes(db dbm.KV, title string) (map[string]struct{}, []strin
}
}
func
getParacrossNodes
(
db
dbm
.
KV
,
title
string
)
(
map
[
string
]
struct
{},
[]
string
,
error
)
{
func
getParacrossNodes
(
db
dbm
.
KV
,
title
string
)
(
map
[
string
]
struct
{},
[]
string
,
error
)
{
key
:=
calcParaNodeGroupKey
(
title
)
key
:=
calcParaNodeGroup
Addrs
Key
(
title
)
return
getNodes
(
db
,
key
)
return
getNodes
(
db
,
key
)
}
}
...
@@ -418,7 +418,12 @@ func (a *action) Commit(commit *pt.ParacrossCommitAction) (*types.Receipt, error
...
@@ -418,7 +418,12 @@ func (a *action) Commit(commit *pt.ParacrossCommitAction) (*types.Receipt, error
return
receipt
,
nil
return
receipt
,
nil
}
}
if
enableParacrossTransfer
&&
commit
.
Status
.
Height
>
0
&&
len
(
commit
.
Status
.
CrossTxHashs
)
>
0
{
haveCrossTxs
:=
len
(
commit
.
Status
.
CrossTxHashs
)
>
0
if
commit
.
Status
.
Height
>
0
&&
types
.
IsDappFork
(
commit
.
Status
.
MainBlockHeight
,
pt
.
ParaX
,
pt
.
ForkCommitTx
)
&&
commit
.
Status
.
CrossTxHashs
[
0
]
==
nil
{
haveCrossTxs
=
false
}
if
enableParacrossTransfer
&&
commit
.
Status
.
Height
>
0
&&
haveCrossTxs
{
clog
.
Debug
(
"paracross.Commit commitDone"
,
"do cross"
,
""
)
clog
.
Debug
(
"paracross.Commit commitDone"
,
"do cross"
,
""
)
crossTxReceipt
,
err
:=
a
.
execCrossTxs
(
commit
)
crossTxReceipt
,
err
:=
a
.
execCrossTxs
(
commit
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -459,10 +464,10 @@ func (a *action) execCrossTx(tx *types.TransactionDetail, commit *pt.ParacrossCo
...
@@ -459,10 +464,10 @@ func (a *action) execCrossTx(tx *types.TransactionDetail, commit *pt.ParacrossCo
}
}
func
getCrossTxHashs
(
api
client
.
QueueProtocolAPI
,
commit
*
pt
.
ParacrossCommitAction
)
([][]
byte
,
[]
byte
,
error
)
{
func
getCrossTxHashs
(
api
client
.
QueueProtocolAPI
,
commit
*
pt
.
ParacrossCommitAction
)
([][]
byte
,
[]
byte
,
error
)
{
crossTxHashs
:=
commit
.
Status
.
CrossTxHashs
crossTxResult
:=
commit
.
Status
.
CrossTxResult
if
types
.
IsDappFork
(
commit
.
Status
.
MainBlockHeight
,
pt
.
ParaX
,
pt
.
ForkCommitTx
)
{
if
types
.
IsDappFork
(
commit
.
Status
.
MainBlockHeight
,
pt
.
ParaX
,
pt
.
ForkCommitTx
)
{
if
len
(
commit
.
Status
.
CrossTxHashs
)
==
0
{
if
len
(
commit
.
Status
.
CrossTxHashs
)
==
0
{
clog
.
Error
(
"getCrossTxHashs len=0"
,
"paraHeight"
,
commit
.
Status
.
Height
,
"mainHeight"
,
commit
.
Status
.
MainBlockHeight
,
"mainHash"
,
hex
.
EncodeToString
(
commit
.
Status
.
MainBlockHash
))
return
nil
,
nil
,
types
.
ErrCheckTxHash
return
nil
,
nil
,
types
.
ErrCheckTxHash
}
}
blockDetail
,
err
:=
GetBlock
(
api
,
commit
.
Status
.
MainBlockHash
)
blockDetail
,
err
:=
GetBlock
(
api
,
commit
.
Status
.
MainBlockHash
)
...
@@ -479,23 +484,32 @@ func getCrossTxHashs(api client.QueueProtocolAPI, commit *pt.ParacrossCommitActi
...
@@ -479,23 +484,32 @@ func getCrossTxHashs(api client.QueueProtocolAPI, commit *pt.ParacrossCommitActi
baseCheckTxHash
:=
CalcTxHashsHash
(
baseHashs
)
baseCheckTxHash
:=
CalcTxHashsHash
(
baseHashs
)
crossCheckHash
:=
CalcTxHashsHash
(
paraCrossHashs
)
crossCheckHash
:=
CalcTxHashsHash
(
paraCrossHashs
)
if
!
bytes
.
Equal
(
commit
.
Status
.
CrossTxHashs
[
0
],
crossCheckHash
)
{
if
!
bytes
.
Equal
(
commit
.
Status
.
CrossTxHashs
[
0
],
crossCheckHash
)
{
clog
.
Error
(
"getCrossTxHashs para hash not equal"
,
"main.crossHash"
,
hex
.
EncodeToString
(
crossCheckHash
),
clog
.
Error
(
"getCrossTxHashs para hash not equal"
,
"paraHeight"
,
commit
.
Status
.
Height
,
"mainHeight"
,
commit
.
Status
.
MainBlockHeight
,
"mainHash"
,
hex
.
EncodeToString
(
commit
.
Status
.
MainBlockHash
),
"main.crossHash"
,
hex
.
EncodeToString
(
crossCheckHash
),
"commit.crossHash"
,
hex
.
EncodeToString
(
commit
.
Status
.
CrossTxHashs
[
0
]),
"commit.crossHash"
,
hex
.
EncodeToString
(
commit
.
Status
.
CrossTxHashs
[
0
]),
"main.baseHash"
,
hex
.
EncodeToString
(
baseCheckTxHash
),
"commit.baseHash"
,
hex
.
EncodeToString
(
commit
.
Status
.
TxHashs
[
0
]))
"main.baseHash"
,
hex
.
EncodeToString
(
baseCheckTxHash
),
"commit.baseHash"
,
hex
.
EncodeToString
(
commit
.
Status
.
TxHashs
[
0
]))
for
_
,
hash
:=
range
baseHashs
{
clog
.
Error
(
"getCrossTxHashs base tx hash"
,
"txhash"
,
hex
.
EncodeToString
(
hash
))
}
for
_
,
hash
:=
range
paraCrossHashs
{
clog
.
Error
(
"getCrossTxHashs paracross tx hash"
,
"txhash"
,
hex
.
EncodeToString
(
hash
))
}
return
nil
,
nil
,
types
.
ErrCheckTxHash
return
nil
,
nil
,
types
.
ErrCheckTxHash
}
}
//只获取跨链tx
//只获取跨链tx
crossTxHashs
=
paraCrossHashs
rst
,
err
:=
hex
.
DecodeString
(
string
(
commit
.
Status
.
CrossTxResult
))
rst
,
err
:=
hex
.
DecodeString
(
string
(
commit
.
Status
.
CrossTxResult
))
if
err
!=
nil
{
if
err
!=
nil
{
clog
.
Error
(
"getCrossTxHashs decode string"
,
"CrossTxResult"
,
string
(
commit
.
Status
.
CrossTxResult
),
clog
.
Error
(
"getCrossTxHashs decode string"
,
"CrossTxResult"
,
string
(
commit
.
Status
.
CrossTxResult
),
"commit.height"
,
commit
.
Status
.
Height
)
"commit.height"
,
commit
.
Status
.
Height
)
return
nil
,
nil
,
types
.
ErrInvalidParam
return
nil
,
nil
,
types
.
ErrInvalidParam
}
}
crossTxResult
=
rst
return
paraCrossHashs
,
rst
,
nil
}
}
return
crossTxHashs
,
crossTxResult
,
nil
return
commit
.
Status
.
CrossTxHashs
,
commit
.
Status
.
CrossTxResult
,
nil
}
}
func
(
a
*
action
)
execCrossTxs
(
commit
*
pt
.
ParacrossCommitAction
)
(
*
types
.
Receipt
,
error
)
{
func
(
a
*
action
)
execCrossTxs
(
commit
*
pt
.
ParacrossCommitAction
)
(
*
types
.
Receipt
,
error
)
{
...
...
plugin/dapp/paracross/executor/exec_del_local.go
View file @
48dbbc8b
...
@@ -64,11 +64,11 @@ func (e *Paracross) ExecDelLocal_NodeConfig(payload *pt.ParaNodeAddrConfig, tx *
...
@@ -64,11 +64,11 @@ func (e *Paracross) ExecDelLocal_NodeConfig(payload *pt.ParaNodeAddrConfig, tx *
}
}
if
g
.
Prev
!=
nil
{
if
g
.
Prev
!=
nil
{
set
.
KV
=
append
(
set
.
KV
,
&
types
.
KeyValue
{
set
.
KV
=
append
(
set
.
KV
,
&
types
.
KeyValue
{
Key
:
calcLocalNodeTitleStatus
(
g
.
Current
.
Title
,
g
.
Current
.
ApplyAddr
,
g
.
Prev
.
Status
),
Value
:
types
.
Encode
(
g
.
Prev
)})
Key
:
calcLocalNodeTitleStatus
(
g
.
Current
.
Title
,
g
.
Prev
.
Status
,
g
.
Prev
.
Id
),
Value
:
types
.
Encode
(
g
.
Prev
)})
}
}
set
.
KV
=
append
(
set
.
KV
,
&
types
.
KeyValue
{
set
.
KV
=
append
(
set
.
KV
,
&
types
.
KeyValue
{
Key
:
calcLocalNodeTitleStatus
(
g
.
Current
.
Title
,
g
.
Current
.
ApplyAddr
,
g
.
Current
.
Status
),
Value
:
nil
})
Key
:
calcLocalNodeTitleStatus
(
g
.
Current
.
Title
,
g
.
Current
.
Status
,
g
.
Current
.
Id
),
Value
:
nil
})
}
else
if
log
.
Ty
==
pt
.
TyLogParaNodeVoteDone
{
}
else
if
log
.
Ty
==
pt
.
TyLogParaNodeVoteDone
{
var
g
pt
.
ReceiptParaNodeVoteDone
var
g
pt
.
ReceiptParaNodeVoteDone
err
:=
types
.
Decode
(
log
.
Log
,
&
g
)
err
:=
types
.
Decode
(
log
.
Log
,
&
g
)
...
@@ -86,8 +86,7 @@ func (e *Paracross) ExecDelLocal_NodeConfig(payload *pt.ParaNodeAddrConfig, tx *
...
@@ -86,8 +86,7 @@ func (e *Paracross) ExecDelLocal_NodeConfig(payload *pt.ParaNodeAddrConfig, tx *
func
(
e
*
Paracross
)
ExecDelLocal_NodeGroupConfig
(
payload
*
pt
.
ParaNodeGroupConfig
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
func
(
e
*
Paracross
)
ExecDelLocal_NodeGroupConfig
(
payload
*
pt
.
ParaNodeGroupConfig
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
var
set
types
.
LocalDBSet
var
set
types
.
LocalDBSet
for
_
,
log
:=
range
receiptData
.
Logs
{
for
_
,
log
:=
range
receiptData
.
Logs
{
if
log
.
Ty
==
pt
.
TyLogParaNodeGroupApply
||
log
.
Ty
==
pt
.
TyLogParaNodeGroupApprove
||
if
log
.
Ty
==
pt
.
TyLogParaNodeGroupConfig
{
log
.
Ty
==
pt
.
TyLogParaNodeGroupQuit
{
var
g
pt
.
ReceiptParaNodeGroupConfig
var
g
pt
.
ReceiptParaNodeGroupConfig
err
:=
types
.
Decode
(
log
.
Log
,
&
g
)
err
:=
types
.
Decode
(
log
.
Log
,
&
g
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -95,11 +94,11 @@ func (e *Paracross) ExecDelLocal_NodeGroupConfig(payload *pt.ParaNodeGroupConfig
...
@@ -95,11 +94,11 @@ func (e *Paracross) ExecDelLocal_NodeGroupConfig(payload *pt.ParaNodeGroupConfig
}
}
if
g
.
Prev
!=
nil
{
if
g
.
Prev
!=
nil
{
set
.
KV
=
append
(
set
.
KV
,
&
types
.
KeyValue
{
set
.
KV
=
append
(
set
.
KV
,
&
types
.
KeyValue
{
Key
:
calcLocalNodeGroupStatusTitle
(
g
.
Prev
.
Status
,
g
.
Current
.
Title
),
Value
:
types
.
Encode
(
g
.
Prev
)})
Key
:
calcLocalNodeGroupStatusTitle
(
g
.
Prev
.
Status
,
g
.
Current
.
Title
,
g
.
Current
.
Id
),
Value
:
types
.
Encode
(
g
.
Prev
)})
}
}
set
.
KV
=
append
(
set
.
KV
,
&
types
.
KeyValue
{
set
.
KV
=
append
(
set
.
KV
,
&
types
.
KeyValue
{
Key
:
calcLocalNodeGroupStatusTitle
(
g
.
Current
.
Status
,
g
.
Current
.
Title
),
Value
:
nil
})
Key
:
calcLocalNodeGroupStatusTitle
(
g
.
Current
.
Status
,
g
.
Current
.
Title
,
g
.
Current
.
Id
),
Value
:
nil
})
}
}
}
}
return
&
set
,
nil
return
&
set
,
nil
...
...
plugin/dapp/paracross/executor/exec_local.go
View file @
48dbbc8b
...
@@ -67,11 +67,11 @@ func (e *Paracross) ExecLocal_NodeConfig(payload *pt.ParaNodeAddrConfig, tx *typ
...
@@ -67,11 +67,11 @@ func (e *Paracross) ExecLocal_NodeConfig(payload *pt.ParaNodeAddrConfig, tx *typ
}
}
if
g
.
Prev
!=
nil
{
if
g
.
Prev
!=
nil
{
set
.
KV
=
append
(
set
.
KV
,
&
types
.
KeyValue
{
set
.
KV
=
append
(
set
.
KV
,
&
types
.
KeyValue
{
Key
:
calcLocalNodeTitleStatus
(
g
.
Current
.
Title
,
g
.
Current
.
ApplyAddr
,
g
.
Prev
.
Status
),
Value
:
nil
})
Key
:
calcLocalNodeTitleStatus
(
g
.
Current
.
Title
,
g
.
Prev
.
Status
,
g
.
Current
.
Id
),
Value
:
nil
})
}
}
set
.
KV
=
append
(
set
.
KV
,
&
types
.
KeyValue
{
set
.
KV
=
append
(
set
.
KV
,
&
types
.
KeyValue
{
Key
:
calcLocalNodeTitleStatus
(
g
.
Current
.
Title
,
g
.
Current
.
ApplyAddr
,
g
.
Current
.
Status
),
Key
:
calcLocalNodeTitleStatus
(
g
.
Current
.
Title
,
g
.
Current
.
Status
,
g
.
Current
.
Id
),
Value
:
types
.
Encode
(
g
.
Current
)})
Value
:
types
.
Encode
(
g
.
Current
)})
}
else
if
log
.
Ty
==
pt
.
TyLogParaNodeVoteDone
{
}
else
if
log
.
Ty
==
pt
.
TyLogParaNodeVoteDone
{
var
g
pt
.
ReceiptParaNodeVoteDone
var
g
pt
.
ReceiptParaNodeVoteDone
...
@@ -90,8 +90,7 @@ func (e *Paracross) ExecLocal_NodeConfig(payload *pt.ParaNodeAddrConfig, tx *typ
...
@@ -90,8 +90,7 @@ func (e *Paracross) ExecLocal_NodeConfig(payload *pt.ParaNodeAddrConfig, tx *typ
func
(
e
*
Paracross
)
ExecLocal_NodeGroupConfig
(
payload
*
pt
.
ParaNodeGroupConfig
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
func
(
e
*
Paracross
)
ExecLocal_NodeGroupConfig
(
payload
*
pt
.
ParaNodeGroupConfig
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
var
set
types
.
LocalDBSet
var
set
types
.
LocalDBSet
for
_
,
log
:=
range
receiptData
.
Logs
{
for
_
,
log
:=
range
receiptData
.
Logs
{
if
log
.
Ty
==
pt
.
TyLogParaNodeGroupApply
||
log
.
Ty
==
pt
.
TyLogParaNodeGroupApprove
||
if
log
.
Ty
==
pt
.
TyLogParaNodeGroupConfig
{
log
.
Ty
==
pt
.
TyLogParaNodeGroupQuit
{
var
g
pt
.
ReceiptParaNodeGroupConfig
var
g
pt
.
ReceiptParaNodeGroupConfig
err
:=
types
.
Decode
(
log
.
Log
,
&
g
)
err
:=
types
.
Decode
(
log
.
Log
,
&
g
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -99,11 +98,11 @@ func (e *Paracross) ExecLocal_NodeGroupConfig(payload *pt.ParaNodeGroupConfig, t
...
@@ -99,11 +98,11 @@ func (e *Paracross) ExecLocal_NodeGroupConfig(payload *pt.ParaNodeGroupConfig, t
}
}
if
g
.
Prev
!=
nil
{
if
g
.
Prev
!=
nil
{
set
.
KV
=
append
(
set
.
KV
,
&
types
.
KeyValue
{
set
.
KV
=
append
(
set
.
KV
,
&
types
.
KeyValue
{
Key
:
calcLocalNodeGroupStatusTitle
(
g
.
Prev
.
Status
,
g
.
Current
.
Title
),
Value
:
nil
})
Key
:
calcLocalNodeGroupStatusTitle
(
g
.
Prev
.
Status
,
g
.
Current
.
Title
,
g
.
Current
.
Id
),
Value
:
nil
})
}
}
set
.
KV
=
append
(
set
.
KV
,
&
types
.
KeyValue
{
set
.
KV
=
append
(
set
.
KV
,
&
types
.
KeyValue
{
Key
:
calcLocalNodeGroupStatusTitle
(
g
.
Current
.
Status
,
g
.
Current
.
Title
),
Value
:
types
.
Encode
(
g
.
Current
)})
Key
:
calcLocalNodeGroupStatusTitle
(
g
.
Current
.
Status
,
g
.
Current
.
Title
,
g
.
Current
.
Id
),
Value
:
types
.
Encode
(
g
.
Current
)})
}
}
}
}
return
&
set
,
nil
return
&
set
,
nil
...
...
plugin/dapp/paracross/executor/kv.go
View file @
48dbbc8b
...
@@ -16,7 +16,9 @@ var (
...
@@ -16,7 +16,9 @@ var (
managerConfigNodes
string
//manager 合约配置的nodes
managerConfigNodes
string
//manager 合约配置的nodes
paraConfigNodes
string
//平行链自组织配置的nodes,最初是从manager同步过来
paraConfigNodes
string
//平行链自组织配置的nodes,最初是从manager同步过来
paraConfigNodeAddr
string
//平行链配置节点账户
paraConfigNodeAddr
string
//平行链配置节点账户
paraNodeGroupApplyAddrs
string
paraNodeGroupStatusAddrs
string
//正在申请的addrs
paraNodeID
string
paraNodeGroupID
string
localTx
string
localTx
string
localTitle
string
localTitle
string
localTitleHeight
string
localTitleHeight
string
...
@@ -32,7 +34,9 @@ func setPrefix() {
...
@@ -32,7 +34,9 @@ func setPrefix() {
managerConfigNodes
=
"paracross-nodes-"
managerConfigNodes
=
"paracross-nodes-"
paraConfigNodes
=
"mavl-paracross-nodes-title-"
paraConfigNodes
=
"mavl-paracross-nodes-title-"
paraConfigNodeAddr
=
"mavl-paracross-nodes-titleAddr-"
paraConfigNodeAddr
=
"mavl-paracross-nodes-titleAddr-"
paraNodeGroupApplyAddrs
=
"mavl-paracross-nodegroup-apply-title-"
paraNodeGroupStatusAddrs
=
"mavl-paracross-nodegroup-apply-title-"
paraNodeID
=
"mavl-paracross-title-nodeid-"
paraNodeGroupID
=
"mavl-paracross-title-nodegroupid-"
localTx
=
"LODB-paracross-titleHeightAddr-"
localTx
=
"LODB-paracross-titleHeightAddr-"
localTitle
=
"LODB-paracross-title-"
localTitle
=
"LODB-paracross-title-"
localTitleHeight
=
"LODB-paracross-titleHeight-"
localTitleHeight
=
"LODB-paracross-titleHeight-"
...
@@ -62,7 +66,7 @@ func calcManageConfigNodesKey(title string) []byte {
...
@@ -62,7 +66,7 @@ func calcManageConfigNodesKey(title string) []byte {
return
[]
byte
(
types
.
ManageKey
(
key
))
return
[]
byte
(
types
.
ManageKey
(
key
))
}
}
func
calcParaNodeGroupKey
(
title
string
)
[]
byte
{
func
calcParaNodeGroup
Addrs
Key
(
title
string
)
[]
byte
{
return
[]
byte
(
fmt
.
Sprintf
(
paraConfigNodes
+
"%s"
,
title
))
return
[]
byte
(
fmt
.
Sprintf
(
paraConfigNodes
+
"%s"
,
title
))
}
}
...
@@ -70,8 +74,16 @@ func calcParaNodeAddrKey(title string, addr string) []byte {
...
@@ -70,8 +74,16 @@ func calcParaNodeAddrKey(title string, addr string) []byte {
return
[]
byte
(
fmt
.
Sprintf
(
paraConfigNodeAddr
+
"%s-%s"
,
title
,
addr
))
return
[]
byte
(
fmt
.
Sprintf
(
paraConfigNodeAddr
+
"%s-%s"
,
title
,
addr
))
}
}
func
calcParaNodeGroupApplyKey
(
title
string
)
[]
byte
{
func
calcParaNodeGroupStatusKey
(
title
string
)
[]
byte
{
return
[]
byte
(
fmt
.
Sprintf
(
paraNodeGroupApplyAddrs
+
"%s"
,
title
))
return
[]
byte
(
fmt
.
Sprintf
(
paraNodeGroupStatusAddrs
+
"%s"
,
title
))
}
func
calcParaNodeIDKey
(
title
,
hash
string
)
string
{
return
fmt
.
Sprintf
(
paraNodeID
+
"%s-%s"
,
title
,
hash
)
}
func
calcParaNodeGroupIDKey
(
title
,
hash
string
)
string
{
return
fmt
.
Sprintf
(
paraNodeGroupID
+
"%s-%s"
,
title
,
hash
)
}
}
func
calcLocalTxKey
(
title
string
,
height
int64
,
addr
string
)
[]
byte
{
func
calcLocalTxKey
(
title
string
,
height
int64
,
addr
string
)
[]
byte
{
...
@@ -90,22 +102,30 @@ func calcLocalAssetKey(hash []byte) []byte {
...
@@ -90,22 +102,30 @@ func calcLocalAssetKey(hash []byte) []byte {
return
[]
byte
(
fmt
.
Sprintf
(
localAssetKey
+
"%s"
,
hash
))
return
[]
byte
(
fmt
.
Sprintf
(
localAssetKey
+
"%s"
,
hash
))
}
}
func
calcLocalNodeTitleStatus
(
title
,
addr
string
,
status
int32
)
[]
byte
{
func
calcLocalNodeTitleStatus
(
title
string
,
status
int32
,
id
string
)
[]
byte
{
return
[]
byte
(
fmt
.
Sprintf
(
localNodeTitleStatus
+
"%s-%02d-%s"
,
title
,
status
,
addr
))
return
[]
byte
(
fmt
.
Sprintf
(
localNodeTitleStatus
+
"%s-%02d-%s"
,
title
,
status
,
id
))
}
}
func
calcLocalNodeStatusPrefix
(
title
string
,
status
int32
)
[]
byte
{
func
calcLocalNodeStatusPrefix
(
title
string
,
status
int32
)
[]
byte
{
return
[]
byte
(
fmt
.
Sprintf
(
localNodeTitleStatus
+
"%s-%02d"
,
title
,
status
))
return
[]
byte
(
fmt
.
Sprintf
(
localNodeTitleStatus
+
"%s-%02d-"
,
title
,
status
))
}
func
calcLocalNodeTitlePrefix
(
title
string
)
[]
byte
{
return
[]
byte
(
fmt
.
Sprintf
(
localNodeTitleStatus
+
"%s-"
,
title
))
}
}
func
calcLocalNodeTitleDone
(
title
,
addr
string
)
[]
byte
{
func
calcLocalNodeTitleDone
(
title
,
addr
string
)
[]
byte
{
return
[]
byte
(
fmt
.
Sprintf
(
localNodeTitleDone
+
"%s-%s"
,
title
,
addr
))
return
[]
byte
(
fmt
.
Sprintf
(
localNodeTitleDone
+
"%s-%s"
,
title
,
addr
))
}
}
func
calcLocalNodeGroupStatusTitle
(
status
int32
,
title
string
)
[]
byte
{
func
calcLocalNodeGroupStatusTitle
(
status
int32
,
title
,
id
string
)
[]
byte
{
return
[]
byte
(
fmt
.
Sprintf
(
localNodeGroupStatusTitle
+
"%02d-%s
"
,
status
,
title
))
return
[]
byte
(
fmt
.
Sprintf
(
localNodeGroupStatusTitle
+
"%02d-%s
-%s"
,
status
,
title
,
id
))
}
}
func
calcLocalNodeGroupStatusPrefix
(
status
int32
)
[]
byte
{
func
calcLocalNodeGroupStatusPrefix
(
status
int32
)
[]
byte
{
return
[]
byte
(
fmt
.
Sprintf
(
localNodeGroupStatusTitle
+
"%02d"
,
status
))
return
[]
byte
(
fmt
.
Sprintf
(
localNodeGroupStatusTitle
+
"%02d-"
,
status
))
}
func
calcLocalNodeGroupAllPrefix
()
[]
byte
{
return
[]
byte
(
fmt
.
Sprintf
(
localNodeGroupStatusTitle
))
}
}
plugin/dapp/paracross/executor/query.go
View file @
48dbbc8b
...
@@ -75,7 +75,7 @@ func (p *Paracross) Query_GetNodeGroupAddrs(in *pt.ReqParacrossNodeInfo) (types.
...
@@ -75,7 +75,7 @@ func (p *Paracross) Query_GetNodeGroupAddrs(in *pt.ReqParacrossNodeInfo) (types.
nodes
=
append
(
nodes
,
k
)
nodes
=
append
(
nodes
,
k
)
}
}
var
reply
types
.
ReplyConfig
var
reply
types
.
ReplyConfig
reply
.
Key
=
string
(
calcParaNodeGroupKey
(
in
.
GetTitle
()))
reply
.
Key
=
string
(
calcParaNodeGroup
Addrs
Key
(
in
.
GetTitle
()))
reply
.
Value
=
fmt
.
Sprint
(
nodes
)
reply
.
Value
=
fmt
.
Sprint
(
nodes
)
return
&
reply
,
nil
return
&
reply
,
nil
}
}
...
@@ -85,7 +85,24 @@ func (p *Paracross) Query_GetNodeAddrInfo(in *pt.ReqParacrossNodeInfo) (types.Me
...
@@ -85,7 +85,24 @@ func (p *Paracross) Query_GetNodeAddrInfo(in *pt.ReqParacrossNodeInfo) (types.Me
if
in
==
nil
||
in
.
Title
==
""
||
in
.
Addr
==
""
{
if
in
==
nil
||
in
.
Title
==
""
||
in
.
Addr
==
""
{
return
nil
,
types
.
ErrInvalidParam
return
nil
,
types
.
ErrInvalidParam
}
}
stat
,
err
:=
getNodeAddr
(
p
.
GetStateDB
(),
in
.
Title
,
in
.
Addr
)
addrStat
,
err
:=
getNodeAddr
(
p
.
GetStateDB
(),
in
.
Title
,
in
.
Addr
)
if
err
!=
nil
{
return
nil
,
err
}
stat
,
err
:=
getNodeID
(
p
.
GetStateDB
(),
addrStat
.
ProposalId
)
if
err
!=
nil
{
return
nil
,
err
}
return
stat
,
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
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
@@ -114,7 +131,7 @@ func (p *Paracross) Query_GetNodeGroupStatus(in *pt.ReqParacrossNodeInfo) (types
...
@@ -114,7 +131,7 @@ func (p *Paracross) Query_GetNodeGroupStatus(in *pt.ReqParacrossNodeInfo) (types
//Query_ListNodeGroupStatus list node info by status
//Query_ListNodeGroupStatus list node info by status
func
(
p
*
Paracross
)
Query_ListNodeGroupStatus
(
in
*
pt
.
ReqParacrossNodeInfo
)
(
types
.
Message
,
error
)
{
func
(
p
*
Paracross
)
Query_ListNodeGroupStatus
(
in
*
pt
.
ReqParacrossNodeInfo
)
(
types
.
Message
,
error
)
{
if
in
==
nil
||
in
.
Status
==
0
{
if
in
==
nil
{
return
nil
,
types
.
ErrInvalidParam
return
nil
,
types
.
ErrInvalidParam
}
}
return
listLocalNodeGroupStatus
(
p
.
GetLocalDB
(),
in
.
Status
)
return
listLocalNodeGroupStatus
(
p
.
GetLocalDB
(),
in
.
Status
)
...
@@ -212,7 +229,7 @@ func listLocalTitles(db dbm.KVDB) (types.Message, error) {
...
@@ -212,7 +229,7 @@ func listLocalTitles(db dbm.KVDB) (types.Message, error) {
MostSameCommit
:
st
.
MostSameCommit
,
MostSameCommit
:
st
.
MostSameCommit
,
Title
:
st
.
Title
,
Title
:
st
.
Title
,
Height
:
st
.
Height
,
Height
:
st
.
Height
,
StateHash
:
hex
.
EncodeToString
(
st
.
StateHash
),
StateHash
:
common
.
ToHex
(
st
.
StateHash
),
TxCounts
:
st
.
TxCounts
,
TxCounts
:
st
.
TxCounts
,
TxResult
:
hex
.
EncodeToString
(
st
.
TxResult
),
TxResult
:
hex
.
EncodeToString
(
st
.
TxResult
),
}
}
...
@@ -230,12 +247,12 @@ func listNodeStatus(db dbm.KVDB, prefix []byte) (types.Message, error) {
...
@@ -230,12 +247,12 @@ func listNodeStatus(db dbm.KVDB, prefix []byte) (types.Message, error) {
var
resp
pt
.
RespParacrossNodeAddrs
var
resp
pt
.
RespParacrossNodeAddrs
for
_
,
r
:=
range
res
{
for
_
,
r
:=
range
res
{
var
st
pt
.
ParaNode
Addr
Status
var
st
pt
.
ParaNode
Id
Status
err
=
types
.
Decode
(
r
,
&
st
)
err
=
types
.
Decode
(
r
,
&
st
)
if
err
!=
nil
{
if
err
!=
nil
{
panic
(
err
)
panic
(
err
)
}
}
resp
.
Addrs
=
append
(
resp
.
Addr
s
,
&
st
)
resp
.
Ids
=
append
(
resp
.
Id
s
,
&
st
)
}
}
return
&
resp
,
nil
return
&
resp
,
nil
}
}
...
@@ -253,19 +270,31 @@ func listNodeGroupStatus(db dbm.KVDB, prefix []byte) (types.Message, error) {
...
@@ -253,19 +270,31 @@ func listNodeGroupStatus(db dbm.KVDB, prefix []byte) (types.Message, error) {
if
err
!=
nil
{
if
err
!=
nil
{
panic
(
err
)
panic
(
err
)
}
}
resp
.
Addrs
=
append
(
resp
.
Addr
s
,
&
st
)
resp
.
Ids
=
append
(
resp
.
Id
s
,
&
st
)
}
}
return
&
resp
,
nil
return
&
resp
,
nil
}
}
//按状态遍历
//按状态遍历
func
listLocalNodeStatus
(
db
dbm
.
KVDB
,
title
string
,
status
int32
)
(
types
.
Message
,
error
)
{
func
listLocalNodeStatus
(
db
dbm
.
KVDB
,
title
string
,
status
int32
)
(
types
.
Message
,
error
)
{
prefix
:=
calcLocalNodeStatusPrefix
(
title
,
status
)
var
prefix
[]
byte
if
status
==
0
{
prefix
=
calcLocalNodeTitlePrefix
(
title
)
}
else
{
prefix
=
calcLocalNodeStatusPrefix
(
title
,
status
)
}
return
listNodeStatus
(
db
,
prefix
)
return
listNodeStatus
(
db
,
prefix
)
}
}
func
listLocalNodeGroupStatus
(
db
dbm
.
KVDB
,
status
int32
)
(
types
.
Message
,
error
)
{
func
listLocalNodeGroupStatus
(
db
dbm
.
KVDB
,
status
int32
)
(
types
.
Message
,
error
)
{
prefix
:=
calcLocalNodeGroupStatusPrefix
(
status
)
var
prefix
[]
byte
if
status
==
0
{
prefix
=
calcLocalNodeGroupAllPrefix
()
}
else
{
prefix
=
calcLocalNodeGroupStatusPrefix
(
status
)
}
return
listNodeGroupStatus
(
db
,
prefix
)
return
listNodeGroupStatus
(
db
,
prefix
)
}
}
...
@@ -287,7 +316,7 @@ func loadLocalTitle(db dbm.KV, title string, height int64) (types.Message, error
...
@@ -287,7 +316,7 @@ func loadLocalTitle(db dbm.KV, title string, height int64) (types.Message, error
MostSameCommit
:
st
.
MostSameCommit
,
MostSameCommit
:
st
.
MostSameCommit
,
Title
:
st
.
Title
,
Title
:
st
.
Title
,
Height
:
st
.
Height
,
Height
:
st
.
Height
,
StateHash
:
hex
.
EncodeToString
(
st
.
StateHash
),
StateHash
:
common
.
ToHex
(
st
.
StateHash
),
TxCounts
:
st
.
TxCounts
,
TxCounts
:
st
.
TxCounts
,
TxResult
:
hex
.
EncodeToString
(
st
.
TxResult
),
TxResult
:
hex
.
EncodeToString
(
st
.
TxResult
),
},
nil
},
nil
...
...
plugin/dapp/paracross/executor/reward.go
View file @
48dbbc8b
...
@@ -62,8 +62,10 @@ func getMiners(detail *pt.ParacrossStatusDetails, blockHash []byte) []string {
...
@@ -62,8 +62,10 @@ func getMiners(detail *pt.ParacrossStatusDetails, blockHash []byte) []string {
//
//
func
mergeReceipt
(
receipt1
,
receipt2
*
types
.
Receipt
)
*
types
.
Receipt
{
func
mergeReceipt
(
receipt1
,
receipt2
*
types
.
Receipt
)
*
types
.
Receipt
{
if
receipt2
!=
nil
{
receipt1
.
KV
=
append
(
receipt1
.
KV
,
receipt2
.
KV
...
)
receipt1
.
KV
=
append
(
receipt1
.
KV
,
receipt2
.
KV
...
)
receipt1
.
Logs
=
append
(
receipt1
.
Logs
,
receipt2
.
Logs
...
)
receipt1
.
Logs
=
append
(
receipt1
.
Logs
,
receipt2
.
Logs
...
)
}
return
receipt1
return
receipt1
}
}
plugin/dapp/paracross/executor/superaccount.go
View file @
48dbbc8b
This diff is collapsed.
Click to expand it.
plugin/dapp/paracross/executor/superaccount_test.go
View file @
48dbbc8b
...
@@ -74,7 +74,7 @@ func (suite *NodeManageTestSuite) SetupSuite() {
...
@@ -74,7 +74,7 @@ func (suite *NodeManageTestSuite) SetupSuite() {
}
}
func
(
suite
*
NodeManageTestSuite
)
TestSetup
()
{
func
(
suite
*
NodeManageTestSuite
)
TestSetup
()
{
nodeConfigKey
:=
calcParaNodeGroupKey
(
Title
)
nodeConfigKey
:=
calcParaNodeGroup
Addrs
Key
(
Title
)
suite
.
T
()
.
Log
(
string
(
nodeConfigKey
))
suite
.
T
()
.
Log
(
string
(
nodeConfigKey
))
_
,
err
:=
suite
.
stateDB
.
Get
(
nodeConfigKey
)
_
,
err
:=
suite
.
stateDB
.
Get
(
nodeConfigKey
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -96,6 +96,11 @@ func nodeCommitImpl(suite suite.Suite, exec *Paracross, privkeyStr string, tx *t
...
@@ -96,6 +96,11 @@ func nodeCommitImpl(suite suite.Suite, exec *Paracross, privkeyStr string, tx *t
assert
.
NotNil
(
suite
.
T
(),
receipt
)
assert
.
NotNil
(
suite
.
T
(),
receipt
)
assert
.
Nil
(
suite
.
T
(),
err
)
assert
.
Nil
(
suite
.
T
(),
err
)
for
_
,
v
:=
range
receipt
.
KV
{
if
err
:=
exec
.
GetStateDB
()
.
Set
(
v
.
Key
,
v
.
Value
);
err
!=
nil
{
panic
(
err
)
}
}
return
return
}
}
...
@@ -104,52 +109,52 @@ func checkGroupApplyReceipt(suite *NodeManageTestSuite, receipt *types.Receipt)
...
@@ -104,52 +109,52 @@ func checkGroupApplyReceipt(suite *NodeManageTestSuite, receipt *types.Receipt)
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
)
var
stat
pt
.
ParaNode
Addr
Status
var
stat
pt
.
ParaNode
Id
Status
err
:=
types
.
Decode
(
receipt
.
KV
[
0
]
.
Value
,
&
stat
)
err
:=
types
.
Decode
(
receipt
.
KV
[
0
]
.
Value
,
&
stat
)
assert
.
Nil
(
suite
.
T
(),
err
,
"decode ParaNodeAddrStatus failed"
)
assert
.
Nil
(
suite
.
T
(),
err
,
"decode ParaNodeAddrStatus failed"
)
//suite.T().Log("titleHeight", titleHeight)
//suite.T().Log("titleHeight", titleHeight)
assert
.
Equal
(
suite
.
T
(),
int32
(
pt
.
TyLogParaNodeGroup
Apply
),
receipt
.
Logs
[
0
]
.
Ty
)
assert
.
Equal
(
suite
.
T
(),
int32
(
pt
.
TyLogParaNodeGroup
Config
),
receipt
.
Logs
[
0
]
.
Ty
)
assert
.
Equal
(
suite
.
T
(),
int32
(
pt
.
ParacrossNodeGroupApply
),
stat
.
Status
)
assert
.
Equal
(
suite
.
T
(),
int32
(
pt
.
ParacrossNodeGroupApply
),
stat
.
Status
)
}
}
func
checkGroupApproveReceipt
(
suite
*
NodeManageTestSuite
,
receipt
*
types
.
Receipt
)
{
func
checkGroupApproveReceipt
(
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
,
6
)
assert
.
Len
(
suite
.
T
(),
receipt
.
KV
,
11
)
assert
.
Len
(
suite
.
T
(),
receipt
.
Logs
,
6
)
assert
.
Len
(
suite
.
T
(),
receipt
.
Logs
,
7
)
len
:=
len
(
receipt
.
KV
)
len
:=
len
(
receipt
.
KV
)
var
stat
pt
.
ParaNode
Addr
Status
var
stat
pt
.
ParaNode
Id
Status
err
:=
types
.
Decode
(
receipt
.
KV
[
len
-
1
]
.
Value
,
&
stat
)
err
:=
types
.
Decode
(
receipt
.
KV
[
len
-
1
]
.
Value
,
&
stat
)
assert
.
Nil
(
suite
.
T
(),
err
,
"decode ParaNodeAddrStatus failed"
)
assert
.
Nil
(
suite
.
T
(),
err
,
"decode ParaNodeAddrStatus failed"
)
//suite.T().Log("t
itleHeight", titleHeight
)
//suite.T().Log("t
y len-1", receipt.Logs[lenLogs-1].Ty,"len",lenLogs
)
assert
.
Equal
(
suite
.
T
(),
int32
(
pt
.
TyLogParaNodeGroup
Approve
),
receipt
.
Logs
[
len
-
1
]
.
Ty
)
assert
.
Equal
(
suite
.
T
(),
int32
(
pt
.
TyLogParaNodeGroup
StatusUpdate
),
receipt
.
Logs
[
7
-
1
]
.
Ty
)
assert
.
Equal
(
suite
.
T
(),
int32
(
pt
.
ParacrossNodeGroupApprove
),
stat
.
Status
)
assert
.
Equal
(
suite
.
T
(),
int32
(
pt
.
ParacrossNodeGroupApprove
),
stat
.
Status
)
}
}
func
checkJoinReceipt
(
suite
*
NodeManageTestSuite
,
receipt
*
types
.
Receipt
)
{
func
checkJoinReceipt
(
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
,
2
)
assert
.
Len
(
suite
.
T
(),
receipt
.
Logs
,
1
)
assert
.
Len
(
suite
.
T
(),
receipt
.
Logs
,
1
)
var
stat
pt
.
ParaNode
Addr
Status
var
stat
pt
.
ParaNode
Id
Status
err
:=
types
.
Decode
(
receipt
.
KV
[
0
]
.
Value
,
&
stat
)
err
:=
types
.
Decode
(
receipt
.
KV
[
0
]
.
Value
,
&
stat
)
assert
.
Nil
(
suite
.
T
(),
err
,
"decode ParaNodeAddrStatus failed"
)
assert
.
Nil
(
suite
.
T
(),
err
,
"decode ParaNodeAddrStatus failed"
)
//suite.T().Log("titleHeight", titleHeight)
//suite.T().Log("titleHeight", titleHeight)
assert
.
Equal
(
suite
.
T
(),
int32
(
pt
.
TyLogParaNodeConfig
),
receipt
.
Logs
[
0
]
.
Ty
)
assert
.
Equal
(
suite
.
T
(),
int32
(
pt
.
TyLogParaNodeConfig
),
receipt
.
Logs
[
0
]
.
Ty
)
assert
.
Equal
(
suite
.
T
(),
int32
(
pt
.
ParacrossNode
Add
ing
),
stat
.
Status
)
assert
.
Equal
(
suite
.
T
(),
int32
(
pt
.
ParacrossNode
Join
ing
),
stat
.
Status
)
assert
.
NotNil
(
suite
.
T
(),
stat
.
Votes
)
assert
.
NotNil
(
suite
.
T
(),
stat
.
Votes
)
}
}
func
checkQuitReceipt
(
suite
*
NodeManageTestSuite
,
receipt
*
types
.
Receipt
)
{
func
checkQuitReceipt
(
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
,
2
)
assert
.
Len
(
suite
.
T
(),
receipt
.
Logs
,
1
)
assert
.
Len
(
suite
.
T
(),
receipt
.
Logs
,
1
)
var
stat
pt
.
ParaNode
Addr
Status
var
stat
pt
.
ParaNode
Id
Status
err
:=
types
.
Decode
(
receipt
.
KV
[
0
]
.
Value
,
&
stat
)
err
:=
types
.
Decode
(
receipt
.
KV
[
0
]
.
Value
,
&
stat
)
assert
.
Nil
(
suite
.
T
(),
err
,
"decode ParaNodeAddrStatus failed"
)
assert
.
Nil
(
suite
.
T
(),
err
,
"decode ParaNodeAddrStatus failed"
)
//suite.T().Log("titleHeight", titleHeight)
//suite.T().Log("titleHeight", titleHeight)
...
@@ -161,10 +166,8 @@ func checkQuitReceipt(suite *NodeManageTestSuite, receipt *types.Receipt) {
...
@@ -161,10 +166,8 @@ func checkQuitReceipt(suite *NodeManageTestSuite, receipt *types.Receipt) {
func
checkVoteReceipt
(
suite
*
NodeManageTestSuite
,
receipt
*
types
.
Receipt
,
count
int
)
{
func
checkVoteReceipt
(
suite
*
NodeManageTestSuite
,
receipt
*
types
.
Receipt
,
count
int
)
{
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
.
Logs
,
1
)
var
stat
pt
.
ParaNode
Addr
Status
var
stat
pt
.
ParaNode
Id
Status
err
:=
types
.
Decode
(
receipt
.
KV
[
0
]
.
Value
,
&
stat
)
err
:=
types
.
Decode
(
receipt
.
KV
[
0
]
.
Value
,
&
stat
)
assert
.
Nil
(
suite
.
T
(),
err
,
"decode ParaNodeAddrStatus failed"
)
assert
.
Nil
(
suite
.
T
(),
err
,
"decode ParaNodeAddrStatus failed"
)
assert
.
Len
(
suite
.
T
(),
stat
.
Votes
.
Votes
,
count
)
assert
.
Len
(
suite
.
T
(),
stat
.
Votes
.
Votes
,
count
)
...
@@ -172,43 +175,47 @@ func checkVoteReceipt(suite *NodeManageTestSuite, receipt *types.Receipt, count
...
@@ -172,43 +175,47 @@ func checkVoteReceipt(suite *NodeManageTestSuite, receipt *types.Receipt, count
}
}
func
checkVoteDoneReceipt
(
suite
*
NodeManageTestSuite
,
receipt
*
types
.
Receipt
,
count
int
,
join
bool
)
{
func
checkVoteDoneReceipt
(
suite
*
NodeManageTestSuite
,
receipt
*
types
.
Receipt
,
count
int
,
join
bool
)
{
suite
.
NotNil
(
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
,
2
)
assert
.
Len
(
suite
.
T
(),
receipt
.
Logs
,
3
)
var
stat
pt
.
ParaNodeAddrStatus
suite
.
T
()
.
Log
(
"checkVoteDoneReceipt"
,
"kvlen"
,
len
(
receipt
.
KV
))
err
:=
types
.
Decode
(
receipt
.
KV
[
0
]
.
Value
,
&
stat
)
assert
.
Nil
(
suite
.
T
(),
err
,
"decode ParaNodeAddrStatus failed"
)
assert
.
Len
(
suite
.
T
(),
stat
.
Votes
.
Votes
,
count
)
var
item
types
.
ConfigItem
_
,
arry
,
err
:=
getParacrossNodes
(
suite
.
stateDB
,
Title
)
err
=
types
.
Decode
(
receipt
.
KV
[
1
]
.
Value
,
&
item
)
suite
.
Suite
.
Nil
(
err
)
assert
.
Nil
(
suite
.
T
(),
err
,
"decode ParaNodeAddrStatus failed"
)
if
join
{
if
join
{
suite
.
Contains
(
item
.
GetArr
()
.
Value
,
Account14K
)
suite
.
Contains
(
arry
,
Account14K
)
}
else
{
}
else
{
suite
.
NotContains
(
item
.
GetArr
()
.
Value
,
Account14K
)
suite
.
NotContains
(
arry
,
Account14K
)
}
}
}
}
func
voteTest
(
suite
*
NodeManageTestSuite
,
addr
string
,
join
bool
)
{
func
voteTest
(
suite
*
NodeManageTestSuite
,
id
string
,
join
bool
)
{
var
count
int
config
:=
&
pt
.
ParaNodeAddrConfig
{
config
:=
&
pt
.
ParaNodeAddrConfig
{
Op
:
pt
.
ParaNodeVote
,
Op
:
pt
.
ParaNodeVote
,
Addr
:
addr
,
Id
:
id
,
Value
:
pt
.
ParaNodeVoteYes
,
Value
:
pt
.
ParaNodeVoteYes
,
}
}
tx
,
err
:=
pt
.
CreateRawNodeConfigTx
(
config
)
tx
,
err
:=
pt
.
CreateRawNodeConfigTx
(
config
)
suite
.
Nil
(
err
)
suite
.
Nil
(
err
)
count
++
receipt
:=
nodeCommit
(
suite
,
PrivKeyA
,
tx
)
receipt
:=
nodeCommit
(
suite
,
PrivKeyA
,
tx
)
checkVoteReceipt
(
suite
,
receipt
,
1
)
checkVoteReceipt
(
suite
,
receipt
,
count
)
count
++
receipt
=
nodeCommit
(
suite
,
PrivKeyB
,
tx
)
receipt
=
nodeCommit
(
suite
,
PrivKeyB
,
tx
)
checkVoteReceipt
(
suite
,
receipt
,
2
)
checkVoteReceipt
(
suite
,
receipt
,
count
)
count
++
if
!
join
{
receipt
=
nodeCommit
(
suite
,
PrivKey14K
,
tx
)
checkVoteReceipt
(
suite
,
receipt
,
count
)
count
++
}
receipt
=
nodeCommit
(
suite
,
PrivKeyC
,
tx
)
receipt
=
nodeCommit
(
suite
,
PrivKeyC
,
tx
)
checkVoteDoneReceipt
(
suite
,
receipt
,
3
,
join
)
checkVoteDoneReceipt
(
suite
,
receipt
,
count
,
join
)
}
}
func
(
suite
*
NodeManageTestSuite
)
testNodeGroupConfigQuit
()
{
func
(
suite
*
NodeManageTestSuite
)
testNodeGroupConfigQuit
()
{
...
@@ -222,8 +229,13 @@ func (suite *NodeManageTestSuite) testNodeGroupConfigQuit() {
...
@@ -222,8 +229,13 @@ func (suite *NodeManageTestSuite) testNodeGroupConfigQuit() {
receipt
:=
nodeCommit
(
suite
,
PrivKeyB
,
tx
)
receipt
:=
nodeCommit
(
suite
,
PrivKeyB
,
tx
)
checkGroupApplyReceipt
(
suite
,
receipt
)
checkGroupApplyReceipt
(
suite
,
receipt
)
suite
.
Equal
(
int32
(
pt
.
TyLogParaNodeGroupConfig
),
receipt
.
Logs
[
0
]
.
Ty
)
var
g
pt
.
ReceiptParaNodeGroupConfig
err
=
types
.
Decode
(
receipt
.
Logs
[
0
]
.
Log
,
&
g
)
suite
.
Nil
(
err
)
config
=
&
pt
.
ParaNodeGroupConfig
{
config
=
&
pt
.
ParaNodeGroupConfig
{
Addrs
:
applyAddrs
,
Id
:
g
.
Current
.
Id
,
Op
:
pt
.
ParacrossNodeGroupQuit
,
Op
:
pt
.
ParacrossNodeGroupQuit
,
}
}
tx
,
err
=
pt
.
CreateRawNodeGroupApplyTx
(
config
)
tx
,
err
=
pt
.
CreateRawNodeGroupApplyTx
(
config
)
...
@@ -247,8 +259,13 @@ func (suite *NodeManageTestSuite) testNodeGroupConfig() {
...
@@ -247,8 +259,13 @@ func (suite *NodeManageTestSuite) testNodeGroupConfig() {
receipt
:=
nodeCommit
(
suite
,
PrivKeyB
,
tx
)
receipt
:=
nodeCommit
(
suite
,
PrivKeyB
,
tx
)
checkGroupApplyReceipt
(
suite
,
receipt
)
checkGroupApplyReceipt
(
suite
,
receipt
)
suite
.
Equal
(
int32
(
pt
.
TyLogParaNodeGroupConfig
),
receipt
.
Logs
[
0
]
.
Ty
)
var
g
pt
.
ReceiptParaNodeGroupConfig
err
=
types
.
Decode
(
receipt
.
Logs
[
0
]
.
Log
,
&
g
)
suite
.
Nil
(
err
)
config
=
&
pt
.
ParaNodeGroupConfig
{
config
=
&
pt
.
ParaNodeGroupConfig
{
Addrs
:
applyAddrs
,
Id
:
g
.
Current
.
Id
,
Op
:
pt
.
ParacrossNodeGroupApprove
,
Op
:
pt
.
ParacrossNodeGroupApprove
,
}
}
tx
,
err
=
pt
.
CreateRawNodeGroupApplyTx
(
config
)
tx
,
err
=
pt
.
CreateRawNodeGroupApplyTx
(
config
)
...
@@ -271,13 +288,18 @@ func (suite *NodeManageTestSuite) testNodeConfig() {
...
@@ -271,13 +288,18 @@ func (suite *NodeManageTestSuite) testNodeConfig() {
receipt
:=
nodeCommit
(
suite
,
PrivKey14K
,
tx
)
receipt
:=
nodeCommit
(
suite
,
PrivKey14K
,
tx
)
checkJoinReceipt
(
suite
,
receipt
)
checkJoinReceipt
(
suite
,
receipt
)
suite
.
Equal
(
int32
(
pt
.
TyLogParaNodeConfig
),
receipt
.
Logs
[
0
]
.
Ty
)
var
g
pt
.
ReceiptParaNodeConfig
err
=
types
.
Decode
(
receipt
.
Logs
[
0
]
.
Log
,
&
g
)
suite
.
Nil
(
err
)
//vote test
//vote test
voteTest
(
suite
,
Account14K
,
true
)
voteTest
(
suite
,
g
.
Current
.
Id
,
true
)
//Quit test
//Quit test
config
=
&
pt
.
ParaNodeAddrConfig
{
config
=
&
pt
.
ParaNodeAddrConfig
{
Op
:
pt
.
ParaNodeQuit
,
Op
:
pt
.
ParaNodeQuit
,
Addr
:
Account1MC
,
Id
:
g
.
Current
.
Id
,
}
}
tx
,
err
=
pt
.
CreateRawNodeConfigTx
(
config
)
tx
,
err
=
pt
.
CreateRawNodeConfigTx
(
config
)
suite
.
Nil
(
err
)
suite
.
Nil
(
err
)
...
@@ -285,7 +307,7 @@ func (suite *NodeManageTestSuite) testNodeConfig() {
...
@@ -285,7 +307,7 @@ func (suite *NodeManageTestSuite) testNodeConfig() {
checkQuitReceipt
(
suite
,
receipt
)
checkQuitReceipt
(
suite
,
receipt
)
//vote test
//vote test
voteTest
(
suite
,
Account1MC
,
false
)
voteTest
(
suite
,
g
.
Current
.
Id
,
false
)
}
}
func
(
suite
*
NodeManageTestSuite
)
TestExec
()
{
func
(
suite
*
NodeManageTestSuite
)
TestExec
()
{
...
@@ -310,22 +332,22 @@ func (suite *NodeManageTestSuite) TearDownSuite() {
...
@@ -310,22 +332,22 @@ func (suite *NodeManageTestSuite) TearDownSuite() {
func
TestGetAddrGroup
(
t
*
testing
.
T
)
{
func
TestGetAddrGroup
(
t
*
testing
.
T
)
{
addrs
:=
" 1KSBd17H7ZK8iT37aJztFB22XGwsPTdwE4, 1JRNjdEqp4LJ5fqycUBm9ayCKSeeskgMKR, 1NLHPEcbTWWxxU3dGUZBhayjrCHD3psX7k, ,,, 1MCftFynyvG2F4ED5mdHYgziDxx6vDrScs , "
addrs
:=
" 1KSBd17H7ZK8iT37aJztFB22XGwsPTdwE4, 1JRNjdEqp4LJ5fqycUBm9ayCKSeeskgMKR, 1NLHPEcbTWWxxU3dGUZBhayjrCHD3psX7k, ,,, 1MCftFynyvG2F4ED5mdHYgziDxx6vDrScs , "
retAddrs
:=
get
AddrGroup
(
addrs
)
retAddrs
:=
get
ConfigAddrs
(
addrs
)
expectAddrs
:=
[]
string
{
"1KSBd17H7ZK8iT37aJztFB22XGwsPTdwE4"
,
"1JRNjdEqp4LJ5fqycUBm9ayCKSeeskgMKR"
,
"1NLHPEcbTWWxxU3dGUZBhayjrCHD3psX7k"
,
"1MCftFynyvG2F4ED5mdHYgziDxx6vDrScs"
}
expectAddrs
:=
[]
string
{
"1KSBd17H7ZK8iT37aJztFB22XGwsPTdwE4"
,
"1JRNjdEqp4LJ5fqycUBm9ayCKSeeskgMKR"
,
"1NLHPEcbTWWxxU3dGUZBhayjrCHD3psX7k"
,
"1MCftFynyvG2F4ED5mdHYgziDxx6vDrScs"
}
assert
.
Equal
(
t
,
expectAddrs
,
retAddrs
)
assert
.
Equal
(
t
,
expectAddrs
,
retAddrs
)
addrs
=
" 1KSBd17H7ZK8iT37aJztFB22XGwsPTdwE4 , , "
addrs
=
" 1KSBd17H7ZK8iT37aJztFB22XGwsPTdwE4 , , "
retAddrs
=
get
AddrGroup
(
addrs
)
retAddrs
=
get
ConfigAddrs
(
addrs
)
expectAddrs
=
[]
string
{
"1KSBd17H7ZK8iT37aJztFB22XGwsPTdwE4"
}
expectAddrs
=
[]
string
{
"1KSBd17H7ZK8iT37aJztFB22XGwsPTdwE4"
}
assert
.
Equal
(
t
,
expectAddrs
,
retAddrs
)
assert
.
Equal
(
t
,
expectAddrs
,
retAddrs
)
addrs
=
" , "
addrs
=
" , "
ret
:=
get
AddrGroup
(
addrs
)
ret
:=
get
ConfigAddrs
(
addrs
)
assert
.
Equal
(
t
,
[]
string
(
nil
),
ret
)
assert
.
Equal
(
t
,
[]
string
(
nil
),
ret
)
assert
.
Equal
(
t
,
0
,
len
(
ret
))
assert
.
Equal
(
t
,
0
,
len
(
ret
))
addrs
=
" "
addrs
=
" "
ret
=
get
AddrGroup
(
addrs
)
ret
=
get
ConfigAddrs
(
addrs
)
assert
.
Equal
(
t
,
[]
string
(
nil
),
ret
)
assert
.
Equal
(
t
,
[]
string
(
nil
),
ret
)
assert
.
Equal
(
t
,
0
,
len
(
ret
))
assert
.
Equal
(
t
,
0
,
len
(
ret
))
...
...
plugin/dapp/paracross/proto/paracross.proto
View file @
48dbbc8b
...
@@ -47,71 +47,77 @@ message ParacrossConsensusStatus {
...
@@ -47,71 +47,77 @@ message ParacrossConsensusStatus {
string
consensBlockHash
=
4
;
string
consensBlockHash
=
4
;
}
}
message
ParaNodeAddrConfig
{
message
ParaNodeAddrConfig
{
string
title
=
1
;
string
title
=
1
;
string
op
=
2
;
uint32
op
=
2
;
string
addr
=
3
;
string
id
=
3
;
string
value
=
4
;
string
addr
=
4
;
int64
coinsFrozen
=
5
;
uint32
value
=
5
;
int64
coinsFrozen
=
6
;
}
}
message
ParaNodeVoteDetail
{
message
ParaNodeVoteDetail
{
repeated
string
addrs
=
1
;
repeated
string
addrs
=
1
;
repeated
string
votes
=
2
;
repeated
string
votes
=
2
;
}
}
message
ParaNodeAddrStatus
{
message
ParaNodeAddrIdStatus
{
int32
status
=
1
;
string
proposalId
=
1
;
string
title
=
2
;
}
string
applyAddr
=
3
;
int64
coinsFrozen
=
4
;
message
ParaNodeIdStatus
{
ParaNodeVoteDetail
votes
=
5
;
string
id
=
1
;
string
fromAddr
=
6
;
int32
status
=
2
;
string
title
=
3
;
string
targetAddr
=
4
;
int64
coinsFrozen
=
5
;
ParaNodeVoteDetail
votes
=
6
;
string
fromAddr
=
7
;
int64
height
=
8
;
}
}
message
ReceiptParaNodeConfig
{
message
ReceiptParaNodeConfig
{
string
addr
=
1
;
string
addr
=
1
;
ParaNodeAddrConfig
config
=
2
;
ParaNodeAddrConfig
config
=
2
;
ParaNode
AddrStatus
prev
=
3
;
ParaNode
IdStatus
prev
=
3
;
ParaNode
AddrStatus
current
=
4
;
ParaNode
IdStatus
current
=
4
;
}
}
message
ReceiptParaNodeVoteRecord
{
string
fromAddr
=
1
;
string
voteAddr
=
2
;
int32
value
=
3
;
}
message
ReceiptParaNodeVoteDone
{
message
ReceiptParaNodeVoteDone
{
string
title
=
1
;
string
id
=
1
;
string
targetAddr
=
2
;
string
title
=
2
;
int32
totalNodes
=
3
;
string
targetAddr
=
3
;
int32
totalVote
=
4
;
int32
totalNodes
=
4
;
int32
mostVote
=
5
;
int32
totalVote
=
5
;
string
voteRst
=
6
;
int32
mostVote
=
6
;
int32
doneStatus
=
7
;
string
voteRst
=
7
;
int32
doneStatus
=
8
;
}
}
message
ParaNodeGroupConfig
{
message
ParaNodeGroupConfig
{
string
title
=
1
;
string
title
=
1
;
uint32
op
=
2
;
uint32
op
=
2
;
string
addrs
=
3
;
string
id
=
3
;
int64
coinsFrozen
=
4
;
string
addrs
=
4
;
uint32
emptyBlockInterval
=
5
;
int64
coinsFrozen
=
5
;
uint32
emptyBlockInterval
=
6
;
}
}
message
ParaNodeGroupStatus
{
message
ParaNodeGroupStatus
{
int32
status
=
1
;
string
id
=
1
;
string
title
=
2
;
int32
status
=
2
;
string
applyAddr
=
3
;
string
title
=
3
;
int64
coinsFrozen
=
4
;
string
targetAddrs
=
4
;
uint32
emptyBlockInterval
=
5
;
int64
coinsFrozen
=
5
;
int64
mainHeight
=
6
;
uint32
emptyBlockInterval
=
6
;
string
fromAddr
=
7
;
int64
mainHeight
=
7
;
string
fromAddr
=
8
;
int64
height
=
9
;
}
}
message
ReceiptParaNodeGroupConfig
{
message
ReceiptParaNodeGroupConfig
{
...
@@ -125,16 +131,18 @@ message ReceiptParaNodeGroupConfig {
...
@@ -125,16 +131,18 @@ message ReceiptParaNodeGroupConfig {
// node query
// node query
message
ReqParacrossNodeInfo
{
message
ReqParacrossNodeInfo
{
string
title
=
1
;
string
title
=
1
;
string
addr
=
2
;
string
id
=
2
;
int32
status
=
3
;
string
addr
=
3
;
int32
status
=
4
;
}
}
message
RespParacrossNodeAddrs
{
message
RespParacrossNodeAddrs
{
repeated
ParaNode
AddrStatus
addr
s
=
1
;
repeated
ParaNode
IdStatus
id
s
=
1
;
}
}
message
RespParacrossNodeGroups
{
message
RespParacrossNodeGroups
{
repeated
ParaNodeGroupStatus
addr
s
=
1
;
repeated
ParaNodeGroupStatus
id
s
=
1
;
}
}
message
ParaBlock2MainMap
{
message
ParaBlock2MainMap
{
...
...
plugin/dapp/paracross/rpc/rpc.go
View file @
48dbbc8b
...
@@ -180,13 +180,26 @@ func (c *Jrpc) GetBlock2MainInfo(req *types.ReqBlocks, result *interface{}) erro
...
@@ -180,13 +180,26 @@ func (c *Jrpc) GetBlock2MainInfo(req *types.ReqBlocks, result *interface{}) erro
}
}
// GetNodeStatus get super node status
// GetNodeStatus get super node status
func
(
c
*
channelClient
)
GetNodeStatus
(
ctx
context
.
Context
,
req
*
pt
.
ReqParacrossNodeInfo
)
(
*
pt
.
ParaNode
Addr
Status
,
error
)
{
func
(
c
*
channelClient
)
GetNodeStatus
(
ctx
context
.
Context
,
req
*
pt
.
ReqParacrossNodeInfo
)
(
*
pt
.
ParaNode
Id
Status
,
error
)
{
r
:=
*
req
r
:=
*
req
data
,
err
:=
c
.
Query
(
pt
.
GetExecName
(),
"GetNodeAddrInfo"
,
&
r
)
data
,
err
:=
c
.
Query
(
pt
.
GetExecName
(),
"GetNodeAddrInfo"
,
&
r
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
if
resp
,
ok
:=
data
.
(
*
pt
.
ParaNodeAddrStatus
);
ok
{
if
resp
,
ok
:=
data
.
(
*
pt
.
ParaNodeIdStatus
);
ok
{
return
resp
,
nil
}
return
nil
,
types
.
ErrDecode
}
// GetNodeStatus get super node status
func
(
c
*
channelClient
)
GetNodeIDStatus
(
ctx
context
.
Context
,
req
*
pt
.
ReqParacrossNodeInfo
)
(
*
pt
.
ParaNodeIdStatus
,
error
)
{
r
:=
*
req
data
,
err
:=
c
.
Query
(
pt
.
GetExecName
(),
"GetNodeIdInfo"
,
&
r
)
if
err
!=
nil
{
return
nil
,
err
}
if
resp
,
ok
:=
data
.
(
*
pt
.
ParaNodeIdStatus
);
ok
{
return
resp
,
nil
return
resp
,
nil
}
}
return
nil
,
types
.
ErrDecode
return
nil
,
types
.
ErrDecode
...
@@ -194,7 +207,20 @@ func (c *channelClient) GetNodeStatus(ctx context.Context, req *pt.ReqParacrossN
...
@@ -194,7 +207,20 @@ func (c *channelClient) GetNodeStatus(ctx context.Context, req *pt.ReqParacrossN
// GetNodeStatus get super node status
// GetNodeStatus get super node status
func
(
c
*
Jrpc
)
GetNodeStatus
(
req
*
pt
.
ReqParacrossNodeInfo
,
result
*
interface
{})
error
{
func
(
c
*
Jrpc
)
GetNodeStatus
(
req
*
pt
.
ReqParacrossNodeInfo
,
result
*
interface
{})
error
{
data
,
err
:=
c
.
cli
.
GetNodeStatus
(
context
.
Background
(),
req
)
if
req
==
nil
||
(
req
.
Addr
==
""
&&
req
.
Id
==
""
)
{
return
types
.
ErrInvalidParam
}
var
data
*
pt
.
ParaNodeIdStatus
var
err
error
if
req
.
Addr
!=
""
{
data
,
err
=
c
.
cli
.
GetNodeStatus
(
context
.
Background
(),
req
)
}
if
req
.
Id
!=
""
{
data
,
err
=
c
.
cli
.
GetNodeIDStatus
(
context
.
Background
(),
req
)
}
*
result
=
data
*
result
=
data
return
err
return
err
}
}
...
...
plugin/dapp/paracross/types/errors.go
View file @
48dbbc8b
...
@@ -47,8 +47,6 @@ var (
...
@@ -47,8 +47,6 @@ var (
ErrParaNodeGroupFrozenCoinsNotEnough
=
errors
.
New
(
"ErrParaNodeGroupFrozenCoinsNotEnough"
)
ErrParaNodeGroupFrozenCoinsNotEnough
=
errors
.
New
(
"ErrParaNodeGroupFrozenCoinsNotEnough"
)
//ErrParaNodeGroupStatusWrong node group process wrong status
//ErrParaNodeGroupStatusWrong node group process wrong status
ErrParaNodeGroupStatusWrong
=
errors
.
New
(
"ErrParaNodeGroupStatusWrong"
)
ErrParaNodeGroupStatusWrong
=
errors
.
New
(
"ErrParaNodeGroupStatusWrong"
)
//ErrParaNodeGroupAddrNotMatch group addrs not match with apply
ErrParaNodeGroupAddrNotMatch
=
errors
.
New
(
"ErrParaNodeGroupAddrNotMatch"
)
//ErrParaConsensStopBlocksNotReach consensus stop blocks not reach
//ErrParaConsensStopBlocksNotReach consensus stop blocks not reach
ErrParaConsensStopBlocksNotReach
=
errors
.
New
(
"ErrParaConsensStopBlocksNotReach"
)
ErrParaConsensStopBlocksNotReach
=
errors
.
New
(
"ErrParaConsensStopBlocksNotReach"
)
)
)
plugin/dapp/paracross/types/paracross.go
View file @
48dbbc8b
...
@@ -39,10 +39,9 @@ const (
...
@@ -39,10 +39,9 @@ const (
// TyLogParaNodeConfig config super node log key
// TyLogParaNodeConfig config super node log key
TyLogParaNodeConfig
=
657
TyLogParaNodeConfig
=
657
TyLogParaNodeVoteDone
=
658
TyLogParaNodeVoteDone
=
658
TyLogParaNodeGroupUpdate
=
659
TyLogParaNodeGroupAddrsUpdate
=
659
TyLogParaNodeGroupApply
=
660
TyLogParaNodeGroupConfig
=
660
TyLogParaNodeGroupApprove
=
661
TyLogParaNodeGroupStatusUpdate
=
664
TyLogParaNodeGroupQuit
=
662
)
)
type
paracrossCommitTx
struct
{
type
paracrossCommitTx
struct
{
...
@@ -90,19 +89,27 @@ const (
...
@@ -90,19 +89,27 @@ const (
// node config op
// node config op
const
(
const
(
ParaNodeJoin
=
"join"
ParaNodeJoin
=
iota
+
1
ParaNodeQuit
=
"quit"
ParaNodeVote
ParaNodeVote
=
"vote"
ParaNodeQuit
)
ParaNodeVoteYes
=
"yes"
// node vote op
ParaNodeVoteNo
=
"no"
const
(
ParaNodeVoteInvalid
=
iota
ParaNodeVoteYes
ParaNodeVoteNo
ParaNodeVoteEnd
)
)
// ParaNodeVoteStr ...
var
ParaNodeVoteStr
=
[]
string
{
"invalid"
,
"yes"
,
"no"
}
const
(
const
(
// ParacrossNode
Add
ing apply for adding group
// ParacrossNode
Join
ing apply for adding group
ParacrossNode
Add
ing
=
iota
+
1
ParacrossNode
Join
ing
=
iota
+
1
// ParacrossNode
Add
ed pass to add by votes
// ParacrossNode
Join
ed pass to add by votes
ParacrossNode
Add
ed
ParacrossNode
Join
ed
// ParacrossNodeQuiting apply for quiting
// ParacrossNodeQuiting apply for quiting
ParacrossNodeQuiting
ParacrossNodeQuiting
// ParacrossNodeQuited pass to quite by votes
// ParacrossNodeQuited pass to quite by votes
...
@@ -116,6 +123,8 @@ const (
...
@@ -116,6 +123,8 @@ const (
ParacrossNodeGroupApprove
ParacrossNodeGroupApprove
//ParacrossNodeGroupQuit applyer quit the apply when not be approved
//ParacrossNodeGroupQuit applyer quit the apply when not be approved
ParacrossNodeGroupQuit
ParacrossNodeGroupQuit
//ParacrossNodeGroupModify applyer modify some parameters
ParacrossNodeGroupModify
)
)
var
(
var
(
...
@@ -179,6 +188,7 @@ func createRawCommitTx(status *ParacrossNodeStatus, name string, fee int64) (*ty
...
@@ -179,6 +188,7 @@ func createRawCommitTx(status *ParacrossNodeStatus, name string, fee int64) (*ty
func
CreateRawNodeConfigTx
(
config
*
ParaNodeAddrConfig
)
(
*
types
.
Transaction
,
error
)
{
func
CreateRawNodeConfigTx
(
config
*
ParaNodeAddrConfig
)
(
*
types
.
Transaction
,
error
)
{
config
.
Title
=
types
.
GetTitle
()
config
.
Title
=
types
.
GetTitle
()
config
.
Addr
=
strings
.
Trim
(
config
.
Addr
,
" "
)
config
.
Addr
=
strings
.
Trim
(
config
.
Addr
,
" "
)
config
.
Id
=
strings
.
Trim
(
config
.
Id
,
" "
)
action
:=
&
ParacrossAction
{
action
:=
&
ParacrossAction
{
Ty
:
ParacrossActionNodeConfig
,
Ty
:
ParacrossActionNodeConfig
,
...
@@ -195,6 +205,7 @@ func CreateRawNodeConfigTx(config *ParaNodeAddrConfig) (*types.Transaction, erro
...
@@ -195,6 +205,7 @@ func CreateRawNodeConfigTx(config *ParaNodeAddrConfig) (*types.Transaction, erro
func
CreateRawNodeGroupApplyTx
(
apply
*
ParaNodeGroupConfig
)
(
*
types
.
Transaction
,
error
)
{
func
CreateRawNodeGroupApplyTx
(
apply
*
ParaNodeGroupConfig
)
(
*
types
.
Transaction
,
error
)
{
apply
.
Title
=
types
.
GetTitle
()
apply
.
Title
=
types
.
GetTitle
()
apply
.
EmptyBlockInterval
=
4
apply
.
EmptyBlockInterval
=
4
apply
.
Id
=
strings
.
Trim
(
apply
.
Id
,
" "
)
interval
:=
types
.
Conf
(
"config.consensus.sub.para"
)
.
GInt
(
"emptyBlockInterval"
)
interval
:=
types
.
Conf
(
"config.consensus.sub.para"
)
.
GInt
(
"emptyBlockInterval"
)
if
interval
>
0
{
if
interval
>
0
{
apply
.
EmptyBlockInterval
=
uint32
(
interval
)
apply
.
EmptyBlockInterval
=
uint32
(
interval
)
...
...
plugin/dapp/paracross/types/paracross.pb.go
View file @
48dbbc8b
This diff is collapsed.
Click to expand it.
plugin/dapp/paracross/types/type.go
View file @
48dbbc8b
...
@@ -62,11 +62,10 @@ func (p *ParacrossType) GetLogMap() map[int64]*types.LogInfo {
...
@@ -62,11 +62,10 @@ func (p *ParacrossType) GetLogMap() map[int64]*types.LogInfo {
TyLogParaAssetDeposit
:
{
Ty
:
reflect
.
TypeOf
(
types
.
ReceiptAccountTransfer
{}),
Name
:
"LogParaAssetDeposit"
},
TyLogParaAssetDeposit
:
{
Ty
:
reflect
.
TypeOf
(
types
.
ReceiptAccountTransfer
{}),
Name
:
"LogParaAssetDeposit"
},
TyLogParacrossMiner
:
{
Ty
:
reflect
.
TypeOf
(
ReceiptParacrossMiner
{}),
Name
:
"LogParacrossMiner"
},
TyLogParacrossMiner
:
{
Ty
:
reflect
.
TypeOf
(
ReceiptParacrossMiner
{}),
Name
:
"LogParacrossMiner"
},
TyLogParaNodeConfig
:
{
Ty
:
reflect
.
TypeOf
(
ReceiptParaNodeConfig
{}),
Name
:
"LogParaNodeConfig"
},
TyLogParaNodeConfig
:
{
Ty
:
reflect
.
TypeOf
(
ReceiptParaNodeConfig
{}),
Name
:
"LogParaNodeConfig"
},
TyLogParaNodeGroup
Update
:
{
Ty
:
reflect
.
TypeOf
(
types
.
ReceiptConfig
{}),
Name
:
"LogParaNodeGroup
Update"
},
TyLogParaNodeGroup
AddrsUpdate
:
{
Ty
:
reflect
.
TypeOf
(
types
.
ReceiptConfig
{}),
Name
:
"LogParaNodeGroupAddrs
Update"
},
TyLogParaNodeVoteDone
:
{
Ty
:
reflect
.
TypeOf
(
ReceiptParaNodeVoteDone
{}),
Name
:
"LogParaNodeVoteDone"
},
TyLogParaNodeVoteDone
:
{
Ty
:
reflect
.
TypeOf
(
ReceiptParaNodeVoteDone
{}),
Name
:
"LogParaNodeVoteDone"
},
TyLogParaNodeGroupApply
:
{
Ty
:
reflect
.
TypeOf
(
ReceiptParaNodeGroupConfig
{}),
Name
:
"LogParaNodeGroupApply"
},
TyLogParaNodeGroupConfig
:
{
Ty
:
reflect
.
TypeOf
(
ReceiptParaNodeGroupConfig
{}),
Name
:
"LogParaNodeGroupConfig"
},
TyLogParaNodeGroupApprove
:
{
Ty
:
reflect
.
TypeOf
(
ReceiptParaNodeGroupConfig
{}),
Name
:
"LogParaNodeGroupApprove"
},
TyLogParaNodeGroupStatusUpdate
:
{
Ty
:
reflect
.
TypeOf
(
ReceiptParaNodeGroupConfig
{}),
Name
:
"LogParaNodeGroupStatusUpdate"
},
TyLogParaNodeGroupQuit
:
{
Ty
:
reflect
.
TypeOf
(
ReceiptParaNodeGroupConfig
{}),
Name
:
"LogParaNodeGroupQuit"
},
}
}
}
}
...
...
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