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
70d84651
Commit
70d84651
authored
Mar 07, 2019
by
mdj33
Committed by
vipwzw
Apr 02, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update para title status cmd
parent
c715a827
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
189 additions
and
89 deletions
+189
-89
paracross.go
plugin/dapp/paracross/commands/paracross.go
+13
-17
action.go
plugin/dapp/paracross/executor/action.go
+6
-1
exec_del_local.go
plugin/dapp/paracross/executor/exec_del_local.go
+1
-0
exec_local.go
plugin/dapp/paracross/executor/exec_local.go
+1
-0
kv.go
plugin/dapp/paracross/executor/kv.go
+4
-5
query.go
plugin/dapp/paracross/executor/query.go
+32
-5
superaccount.go
plugin/dapp/paracross/executor/superaccount.go
+55
-24
superaccount.md
plugin/dapp/paracross/executor/superaccount.md
+22
-5
paracross.proto
plugin/dapp/paracross/proto/paracross.proto
+17
-5
rpc.go
plugin/dapp/paracross/rpc/rpc.go
+14
-8
errors.go
plugin/dapp/paracross/types/errors.go
+15
-9
paracross.go
plugin/dapp/paracross/types/paracross.go
+9
-10
No files found.
plugin/dapp/paracross/commands/paracross.go
View file @
70d84651
...
...
@@ -248,35 +248,31 @@ func CreateRawNodeManageCmd() *cobra.Command {
}
func
addNodeManageFlags
(
cmd
*
cobra
.
Command
)
{
cmd
.
Flags
()
.
StringP
(
"operation"
,
"o"
,
""
,
"
add,delete,vote,takeover operation
"
)
cmd
.
Flags
()
.
StringP
(
"operation"
,
"o"
,
""
,
"
operation:join,quit,vote,takeover
"
)
cmd
.
MarkFlagRequired
(
"operation"
)
cmd
.
Flags
()
.
StringP
(
"addr"
,
"a"
,
""
,
"operating
addr object
"
)
cmd
.
Flags
()
.
StringP
(
"value"
,
"v"
,
"
pass"
,
"vote value: pas
s,no"
)
cmd
.
Flags
()
.
StringP
(
"addr"
,
"a"
,
""
,
"operating
target addr
"
)
cmd
.
Flags
()
.
StringP
(
"value"
,
"v"
,
"
"
,
"vote value: ye
s,no"
)
}
func
createNodeTx
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
op
,
_
:=
cmd
.
Flags
()
.
GetString
(
"operation"
)
opAddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"addr"
)
val
,
_
:=
cmd
.
Flags
()
.
GetString
(
"value"
)
if
op
!=
"vote"
&&
op
!=
"delete"
&&
op
!=
"add"
&&
op
!=
"takeover"
{
fmt
.
Println
(
os
.
Stderr
,
"operation should be one of add, delete,vote,takeover"
)
if
op
!=
"vote"
&&
op
!=
"quit"
&&
op
!=
"join"
&&
op
!=
"takeover"
{
fmt
.
Println
(
"operation should be one of join,quit,vote,takeover"
)
return
}
if
(
op
==
"vote"
||
op
==
"
add"
||
op
==
"delete
"
)
&&
opAddr
==
""
{
fmt
.
Println
(
os
.
Stderr
,
"addr parameter should not be null"
)
if
(
op
==
"vote"
||
op
==
"
join"
||
op
==
"quit
"
)
&&
opAddr
==
""
{
fmt
.
Println
(
"addr parameter should not be null"
)
return
}
if
op
==
"vote"
&&
(
val
!=
"
pas
s"
&&
val
!=
"no"
)
{
fmt
.
Println
(
os
.
Stderr
,
"vote operation value parameter require pas
s or no value"
)
if
op
==
"vote"
&&
(
val
!=
"
ye
s"
&&
val
!=
"no"
)
{
fmt
.
Println
(
"vote operation value parameter require ye
s or no value"
)
return
}
payload
:=
&
pt
.
ParaNodeAddrConfig
{
Op
:
op
,
Value
:
val
,
Addr
:
opAddr
}
//modify := &pt.ParacrossAction{
// Ty: pt.ParacrossActionNodeConfig,
// Value: &pt.ParacrossAction_NodeConfig{NodeConfig: v},
//}
params
:=
&
rpcTypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
pt
.
ParaX
),
ActionName
:
"NodeConfig"
,
...
...
@@ -393,7 +389,7 @@ func paraInfo(cmd *cobra.Command, args []string) {
Title
:
title
,
Height
:
height
,
}
var
res
pt
.
Re
ceipt
ParacrossDone
var
res
pt
.
Re
sp
ParacrossDone
ctx
:=
jsonclient
.
NewRPCCtx
(
rpcLaddr
,
"paracross.GetTitleHeight"
,
params
,
&
res
)
ctx
.
Run
()
}
...
...
@@ -466,7 +462,7 @@ func addNodeListCmdFlags(cmd *cobra.Command) {
cmd
.
Flags
()
.
StringP
(
"title"
,
"t"
,
""
,
"parallel chain's title"
)
cmd
.
MarkFlagRequired
(
"title"
)
cmd
.
Flags
()
.
Int32P
(
"status"
,
"s"
,
0
,
"status:
0:add,1:added,2:quit,3:quited,4:refus
ed"
)
cmd
.
Flags
()
.
Int32P
(
"status"
,
"s"
,
0
,
"status:
1:adding,2:added,3:quiting,4:quit
ed"
)
cmd
.
MarkFlagRequired
(
"status"
)
}
...
...
@@ -485,7 +481,7 @@ func nodeList(cmd *cobra.Command, args []string) {
ctx
.
Run
()
}
// GetNode
ListCmd get node list by status
// GetNode
GroupCmd get node group addr
func
GetNodeGroupCmd
()
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"node_group"
,
...
...
plugin/dapp/paracross/executor/action.go
View file @
70d84651
...
...
@@ -298,7 +298,12 @@ func (a *action) Commit(commit *pt.ParacrossCommitAction) (*types.Receipt, error
}
receipt
=
makeCommitReceipt
(
a
.
fromaddr
,
commit
,
nil
,
stat
)
}
else
{
copyStat
:=
*
stat
var
copyStat
pt
.
ParacrossHeightStatus
err
=
deepCopy
(
&
copyStat
,
stat
)
if
err
!=
nil
{
clog
.
Error
(
"paracross.Commit deep copy fail"
,
"copy"
,
copyStat
,
"stat"
,
stat
)
return
nil
,
err
}
// 如有分叉, 同一个节点可能再次提交commit交易
found
,
index
:=
hasCommited
(
stat
.
Details
.
Addrs
,
a
.
fromaddr
)
if
found
{
...
...
plugin/dapp/paracross/executor/exec_del_local.go
View file @
70d84651
...
...
@@ -49,6 +49,7 @@ func (e *Paracross) ExecDelLocal_Commit(payload *pt.ParacrossCommitAction, tx *t
return
&
set
,
nil
}
// ExecDelLocal_NodeConfig node config tx delete process
func
(
e
*
Paracross
)
ExecDelLocal_NodeConfig
(
payload
*
pt
.
ParaNodeAddrConfig
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
var
set
types
.
LocalDBSet
for
_
,
log
:=
range
receiptData
.
Logs
{
...
...
plugin/dapp/paracross/executor/exec_local.go
View file @
70d84651
...
...
@@ -51,6 +51,7 @@ func (e *Paracross) ExecLocal_Commit(payload *pt.ParacrossCommitAction, tx *type
return
&
set
,
nil
}
//ExecLocal_NodeConfig node config add process
func
(
e
*
Paracross
)
ExecLocal_NodeConfig
(
payload
*
pt
.
ParaNodeAddrConfig
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
var
set
types
.
LocalDBSet
for
_
,
log
:=
range
receiptData
.
Logs
{
...
...
plugin/dapp/paracross/executor/kv.go
View file @
70d84651
...
...
@@ -17,11 +17,10 @@ var (
managerConfigNodes
string
//manager 合约配置的nodes
paraConfigNodes
string
//平行链自组织配置的nodes,最初是从manager同步过来
paraConfigNodeAddr
string
//平行链配置节点账户
localTx
string
localTitle
string
localTitleHeight
string
localAssetKey
string
localNodeTitle
string
localTx
string
localTitle
string
localTitleHeight
string
localAssetKey
string
localNodeTitleStatus
string
localNodeTitleDone
string
)
...
...
plugin/dapp/paracross/executor/query.go
View file @
70d84651
...
...
@@ -8,6 +8,9 @@ import (
"encoding/hex"
"fmt"
"math/big"
"strconv"
dbm
"github.com/33cn/chain33/common/db"
"github.com/33cn/chain33/types"
pt
"github.com/33cn/plugin/plugin/dapp/paracross/types"
...
...
@@ -40,6 +43,7 @@ func (p *Paracross) Query_GetTitleByHash(in *pt.ReqParacrossTitleHash) (types.Me
}
//Query_GetNodeGroup get node group addrs
func
(
p
*
Paracross
)
Query_GetNodeGroup
(
in
*
types
.
ReqString
)
(
types
.
Message
,
error
)
{
if
in
==
nil
{
return
nil
,
types
.
ErrInvalidParam
...
...
@@ -59,6 +63,7 @@ func (p *Paracross) Query_GetNodeGroup(in *types.ReqString) (types.Message, erro
return
&
reply
,
nil
}
//Query_GetNodeAddrInfo get specific node addr info
func
(
p
*
Paracross
)
Query_GetNodeAddrInfo
(
in
*
pt
.
ReqParacrossNodeInfo
)
(
types
.
Message
,
error
)
{
if
in
==
nil
||
in
.
Title
==
""
||
in
.
Addr
==
""
{
return
nil
,
types
.
ErrInvalidParam
...
...
@@ -71,6 +76,7 @@ func (p *Paracross) Query_GetNodeAddrInfo(in *pt.ReqParacrossNodeInfo) (types.Me
return
stat
,
nil
}
//Query_ListNodeStatusInfo list node info by status
func
(
p
*
Paracross
)
Query_ListNodeStatusInfo
(
in
*
pt
.
ReqParacrossNodeInfo
)
(
types
.
Message
,
error
)
{
if
in
==
nil
||
in
.
Title
==
""
{
return
nil
,
types
.
ErrInvalidParam
...
...
@@ -165,7 +171,18 @@ func listLocalTitles(db dbm.KVDB) (types.Message, error) {
if
err
!=
nil
{
panic
(
err
)
}
resp
.
Titles
=
append
(
resp
.
Titles
,
&
st
)
rst
:=
&
pt
.
RespParacrossDone
{
TotalNodes
:
st
.
TotalNodes
,
TotalCommit
:
st
.
TotalCommit
,
MostSameCommit
:
st
.
MostSameCommit
,
Title
:
st
.
Title
,
Height
:
st
.
Height
,
StateHash
:
hex
.
EncodeToString
(
st
.
StateHash
),
TxCounts
:
st
.
TxCounts
,
TxResult
:
strconv
.
FormatUint
(
big
.
NewInt
(
0
)
.
SetBytes
(
st
.
TxResult
)
.
Uint64
(),
2
),
}
resp
.
Titles
=
append
(
resp
.
Titles
,
rst
)
}
return
&
resp
,
nil
}
...
...
@@ -180,7 +197,7 @@ func listLocalNodeStatus(db dbm.KVDB, title string, status int32) (types.Message
var
resp
pt
.
RespParacrossNodeAddrs
for
_
,
r
:=
range
res
{
var
st
pt
.
ReceiptParaNodeVoteDone
var
st
pt
.
ParaNodeAddrStatus
err
=
types
.
Decode
(
r
,
&
st
)
if
err
!=
nil
{
panic
(
err
)
...
...
@@ -197,12 +214,22 @@ func loadLocalTitle(db dbm.KV, title string, height int64) (types.Message, error
if
err
!=
nil
{
return
nil
,
err
}
var
resp
pt
.
ReceiptParacrossDone
err
=
types
.
Decode
(
res
,
&
resp
)
var
st
pt
.
ReceiptParacrossDone
err
=
types
.
Decode
(
res
,
&
st
)
if
err
!=
nil
{
panic
(
err
)
}
return
&
resp
,
nil
return
&
pt
.
RespParacrossDone
{
TotalNodes
:
st
.
TotalNodes
,
TotalCommit
:
st
.
TotalCommit
,
MostSameCommit
:
st
.
MostSameCommit
,
Title
:
st
.
Title
,
Height
:
st
.
Height
,
StateHash
:
hex
.
EncodeToString
(
st
.
StateHash
),
TxCounts
:
st
.
TxCounts
,
TxResult
:
strconv
.
FormatUint
(
big
.
NewInt
(
0
)
.
SetBytes
(
st
.
TxResult
)
.
Uint64
(),
2
),
},
nil
}
func
(
p
*
Paracross
)
paracrossGetTitleHeight
(
title
string
,
height
int64
)
(
types
.
Message
,
error
)
{
...
...
plugin/dapp/paracross/executor/superaccount.go
View file @
70d84651
...
...
@@ -5,12 +5,23 @@
package
executor
import
(
"bytes"
"encoding/gob"
dbm
"github.com/33cn/chain33/common/db"
"github.com/33cn/chain33/types"
pt
"github.com/33cn/plugin/plugin/dapp/paracross/types"
"github.com/pkg/errors"
)
func
deepCopy
(
dst
,
src
interface
{})
error
{
var
buf
bytes
.
Buffer
if
err
:=
gob
.
NewEncoder
(
&
buf
)
.
Encode
(
src
);
err
!=
nil
{
return
err
}
return
gob
.
NewDecoder
(
bytes
.
NewBuffer
(
buf
.
Bytes
()))
.
Decode
(
dst
)
}
func
getNodeAddr
(
db
dbm
.
KV
,
key
[]
byte
)
(
*
pt
.
ParaNodeAddrStatus
,
error
)
{
val
,
err
:=
db
.
Get
(
key
)
if
err
!=
nil
{
...
...
@@ -23,20 +34,18 @@ func getNodeAddr(db dbm.KV, key []byte) (*pt.ParaNodeAddrStatus, error) {
}
func
saveNodeAddr
(
db
dbm
.
KV
,
key
[]
byte
,
status
types
.
Message
)
error
{
// use as a types.Message
val
:=
types
.
Encode
(
status
)
return
db
.
Set
(
key
,
val
)
}
func
makeVoteDoneReceipt
(
config
*
pt
.
ParaNodeAddrConfig
,
totalCount
,
commitCount
,
most
int
,
ok
bool
,
status
int32
)
*
types
.
Receipt
{
func
makeVoteDoneReceipt
(
config
*
pt
.
ParaNodeAddrConfig
,
totalCount
,
commitCount
,
most
int
,
pass
string
,
status
int32
)
*
types
.
Receipt
{
log
:=
&
pt
.
ReceiptParaNodeVoteDone
{
Title
:
config
.
Title
,
TargetAddr
:
config
.
Addr
,
TotalNodes
:
int32
(
totalCount
),
TotalVote
:
int32
(
commitCount
),
MostVote
:
int32
(
most
),
VoteRst
:
ok
,
VoteRst
:
pass
,
DoneStatus
:
status
,
}
...
...
@@ -116,7 +125,12 @@ func (a *action) nodeAdd(config *pt.ParaNodeAddrConfig) (*types.Receipt, error)
return
makeNodeConfigReceipt
(
a
.
fromaddr
,
config
,
nil
,
stat
),
nil
}
copyStatus
:=
*
stat
var
copyStat
pt
.
ParaNodeAddrStatus
err
=
deepCopy
(
&
copyStat
,
stat
)
if
err
!=
nil
{
clog
.
Error
(
"nodeaccount.nodeAdd deep copy fail"
,
"copy"
,
copyStat
,
"stat"
,
stat
)
return
nil
,
err
}
if
stat
.
Status
!=
pt
.
ParacrossNodeQuited
{
clog
.
Error
(
"nodeaccount.nodeAdd key exist"
,
"key"
,
string
(
key
),
"status"
,
stat
)
return
nil
,
pt
.
ErrParaNodeAddrExisted
...
...
@@ -124,7 +138,7 @@ func (a *action) nodeAdd(config *pt.ParaNodeAddrConfig) (*types.Receipt, error)
stat
.
Status
=
pt
.
ParacrossNodeAdding
stat
.
Votes
=
&
pt
.
ParaNodeVoteDetail
{}
saveNodeAddr
(
a
.
db
,
key
,
stat
)
return
makeNodeConfigReceipt
(
a
.
fromaddr
,
config
,
&
copyStat
us
,
stat
),
nil
return
makeNodeConfigReceipt
(
a
.
fromaddr
,
config
,
&
copyStat
,
stat
),
nil
}
...
...
@@ -150,9 +164,14 @@ func (a *action) nodeDelete(config *pt.ParaNodeAddrConfig) (*types.Receipt, erro
//refused or quiting
if
stat
.
Status
!=
pt
.
ParacrossNodeAdded
{
clog
.
Error
(
"nodeaccount.nodeDelete wrong status"
,
"key"
,
string
(
key
),
"status"
,
stat
)
return
nil
,
errors
.
Wrapf
(
pt
.
ErrParaNodeGroupRefuseByVote
,
"nodeAddr refused by vote:%s"
,
a
.
fromaddr
)
return
nil
,
errors
.
Wrapf
(
pt
.
ErrParaUnSupportNodeOper
,
"nodeAddr %s not be added status:%d"
,
a
.
fromaddr
,
stat
.
Status
)
}
var
copyStat
pt
.
ParaNodeAddrStatus
err
=
deepCopy
(
&
copyStat
,
stat
)
if
err
!=
nil
{
clog
.
Error
(
"nodeaccount.nodeDelete deep copy fail"
,
"copy"
,
copyStat
,
"stat"
,
stat
)
return
nil
,
err
}
copyStat
:=
*
stat
stat
.
Status
=
pt
.
ParacrossNodeQuiting
stat
.
Votes
=
&
pt
.
ParaNodeVoteDetail
{}
saveNodeAddr
(
a
.
db
,
key
,
stat
)
...
...
@@ -160,19 +179,19 @@ func (a *action) nodeDelete(config *pt.ParaNodeAddrConfig) (*types.Receipt, erro
}
func
getMostVote
(
stat
*
pt
.
ParaNodeAddrStatus
)
(
int
,
bool
)
{
func
getMostVote
(
stat
*
pt
.
ParaNodeAddrStatus
)
(
int
,
string
)
{
var
ok
,
nok
int
for
_
,
v
:=
range
stat
.
GetVotes
()
.
Votes
{
if
v
==
pt
.
ParaNodeVote
Pas
s
{
if
v
==
pt
.
ParaNodeVote
Ye
s
{
ok
++
}
else
{
nok
++
}
}
if
ok
>
nok
{
return
ok
,
true
return
ok
,
pt
.
ParaNodeVoteYes
}
return
nok
,
false
return
nok
,
pt
.
ParaNodeVoteNo
}
...
...
@@ -211,7 +230,13 @@ func (a *action) nodeVote(config *pt.ParaNodeAddrConfig) (*types.Receipt, error)
return
nil
,
err
}
copyStat
:=
*
stat
var
copyStat
pt
.
ParaNodeAddrStatus
err
=
deepCopy
(
&
copyStat
,
stat
)
if
err
!=
nil
{
clog
.
Error
(
"nodeaccount.nodevOTE deep copy fail"
,
"copy"
,
copyStat
,
"stat"
,
stat
)
return
nil
,
err
}
if
stat
.
Votes
==
nil
{
stat
.
Votes
=
&
pt
.
ParaNodeVoteDetail
{}
}
...
...
@@ -222,17 +247,24 @@ func (a *action) nodeVote(config *pt.ParaNodeAddrConfig) (*types.Receipt, error)
stat
.
Votes
.
Addrs
=
append
(
stat
.
Votes
.
Addrs
,
a
.
fromaddr
)
stat
.
Votes
.
Votes
=
append
(
stat
.
Votes
.
Votes
,
config
.
Value
)
}
receipt
:=
makeNodeConfigReceipt
(
config
.
A
ddr
,
config
,
&
copyStat
,
stat
)
most
,
ok
:=
getMostVote
(
stat
)
receipt
:=
makeNodeConfigReceipt
(
a
.
froma
ddr
,
config
,
&
copyStat
,
stat
)
most
,
vote
:=
getMostVote
(
stat
)
if
!
isCommitDone
(
stat
,
nodes
,
most
)
{
saveNodeAddr
(
a
.
db
,
key
,
stat
)
return
receipt
,
nil
}
clog
.
Info
(
"paracross.nodeVote
commit ----pass"
,
"most"
,
most
,
"pass"
,
ok
)
clog
.
Info
(
"paracross.nodeVote
----pass"
,
"most"
,
most
,
"pass"
,
vote
)
var
receiptGroup
*
types
.
Receipt
if
!
ok
{
stat
.
Status
=
pt
.
ParacrossNodeRefused
if
vote
==
pt
.
ParaNodeVoteNo
{
// 对已经在group里面的node,直接投票remove,对正在申请中的adding or quiting状态保持不变,对quited的保持不变
if
stat
.
Status
==
pt
.
ParacrossNodeAdded
{
receiptGroup
,
err
=
unpdateNodeGroup
(
a
.
db
,
config
.
Title
,
config
.
Addr
,
false
)
if
err
!=
nil
{
return
nil
,
err
}
stat
.
Status
=
pt
.
ParacrossNodeQuited
}
}
else
{
if
stat
.
Status
==
pt
.
ParacrossNodeAdding
{
receiptGroup
,
err
=
unpdateNodeGroup
(
a
.
db
,
config
.
Title
,
config
.
Addr
,
true
)
...
...
@@ -248,14 +280,13 @@ func (a *action) nodeVote(config *pt.ParaNodeAddrConfig) (*types.Receipt, error)
stat
.
Status
=
pt
.
ParacrossNodeQuited
}
}
saveNodeAddr
(
a
.
db
,
key
,
stat
)
receipt
=
makeNodeConfigReceipt
(
config
.
A
ddr
,
config
,
&
copyStat
,
stat
)
receipt
=
makeNodeConfigReceipt
(
a
.
froma
ddr
,
config
,
&
copyStat
,
stat
)
if
receiptGroup
!=
nil
{
receipt
.
KV
=
append
(
receipt
.
KV
,
receiptGroup
.
KV
...
)
receipt
.
Logs
=
append
(
receipt
.
Logs
,
receiptGroup
.
Logs
...
)
}
receiptDone
:=
makeVoteDoneReceipt
(
config
,
len
(
nodes
),
len
(
stat
.
Votes
.
Addrs
),
most
,
ok
,
stat
.
Status
)
receiptDone
:=
makeVoteDoneReceipt
(
config
,
len
(
nodes
),
len
(
stat
.
Votes
.
Addrs
),
most
,
vote
,
stat
.
Status
)
receipt
.
KV
=
append
(
receipt
.
KV
,
receiptDone
.
KV
...
)
receipt
.
Logs
=
append
(
receipt
.
Logs
,
receiptDone
.
Logs
...
)
return
receipt
,
nil
...
...
@@ -295,7 +326,7 @@ func unpdateNodeGroup(db dbm.KV, title, addr string, add bool) (*types.Receipt,
item
.
Addr
=
addr
item
.
GetArr
()
.
Value
=
make
([]
string
,
0
)
for
_
,
value
:=
range
copyItem
.
GetArr
()
.
Value
{
clog
.
Info
(
"unpdateNodeGroup"
,
"key delete"
,
key
,
"current"
,
value
)
clog
.
Info
(
"unpdateNodeGroup"
,
"key delete"
,
string
(
key
)
,
"current"
,
value
)
if
value
!=
addr
{
item
.
GetArr
()
.
Value
=
append
(
item
.
GetArr
()
.
Value
,
value
)
}
...
...
@@ -357,13 +388,13 @@ func (a *action) NodeConfig(config *pt.ParaNodeAddrConfig) (*types.Receipt, erro
return
nil
,
pt
.
ErrInvalidTitle
}
if
config
.
Op
==
pt
.
ParaNode
Add
{
if
config
.
Op
==
pt
.
ParaNode
Join
{
if
config
.
Addr
!=
a
.
fromaddr
{
return
nil
,
types
.
ErrFromAddr
}
return
a
.
nodeAdd
(
config
)
}
else
if
config
.
Op
==
pt
.
ParaNode
Delete
{
}
else
if
config
.
Op
==
pt
.
ParaNode
Quit
{
if
config
.
Addr
!=
a
.
fromaddr
{
return
nil
,
types
.
ErrFromAddr
}
...
...
plugin/dapp/paracross/executor/superaccount.md
View file @
70d84651
# paracross 执行器 授权账户管理
## 执行逻辑
## 场景
1.
平行链申请开链之前申请几个授权账户,没有授权账户无法做跨链交易,目前没有押金机制
1.
主链超级用户会分别向主链和平行链的manager合约发送账户添加tx,作为平行链的初始授权账户
1.
平行链开链后在做跨链tx之前需要任何一个初始授权账户在平行链上发送takeover tx把初始授权账户接管到平行链,
...
...
@@ -13,5 +10,24 @@
1.
当前授权账户有投票删除某一个授权账户的权利,2/3数同意的规则
1.
特殊或异常场景:
1.
新申请节点还没投票就退出,不允许,必须都投完票之后再申请
1.
申请节点退出后重新申请,允许重新加入,但需要重新投票
1.
申请节点退出后重新申请,允许重新加入,但需要重新投票
1.
新申请节点投票超过2/3否决,后来又投票超过2/3同意,可以加入或退出
## 四个状态
+-----------------------------------
| |
adding --+ added --+ quiting --+ quited
| |
-----------------------+
adding: 新授权账户申请状态,若投票超过2/3否决停留在此状态,后续可以继续投赞成票
added: 授权账户被当前授权账户组超过2/3票通过状态
quiting: 当前授权账户申请退出账户组状态,投票超过2/3否决停留在此状态,后续可以继续投赞成票
quited: 授权账户quiting被账户组除自己外账户投票超过2/3通过状态,或added的账户被账户组除自己外投票超过2/3否决除名状态
## 测试场景:
1.
新节点发tx申请加入,超2/3同意,新节点加入成功处于added状态
1.
已加入节点申请退出,超2/3同意,已加入节点退出管理组处于quited状态
1.
新节点重新申请加入,超2/3否决,新节点仍停留在adding状态,后来投票节点又2/3同意,新节点加入
1.
投票节点一起投某一个账户组里面的账户否决票,超2/3数后,此账户退出账户组,又超过2/3同意后,仍处于退出状态(需自己申请加入)
1.
账户组里面账户申请退出,当是最后一个时候退出失败
\ No newline at end of file
plugin/dapp/paracross/proto/paracross.proto
View file @
70d84651
...
...
@@ -43,7 +43,7 @@ message ParaNodeAddrConfig{
}
message
ParaNodeVoteDetail
{
repeated
string
addrs
=
1
;
repeated
string
addrs
=
1
;
repeated
string
votes
=
2
;
}
...
...
@@ -74,7 +74,7 @@ message ReceiptParaNodeVoteDone {
int32
totalNodes
=
3
;
int32
totalVote
=
4
;
int32
mostVote
=
5
;
bool
voteRst
=
6
;
string
voteRst
=
6
;
int32
doneStatus
=
7
;
}
...
...
@@ -87,7 +87,7 @@ message ReqParacrossNodeInfo {
}
message
RespParacrossNodeAddrs
{
repeated
ReceiptParaNodeVoteDone
addrs
=
1
;
repeated
ParaNodeAddrStatus
addrs
=
1
;
}
message
ParaBlock2MainMap
{
...
...
@@ -181,8 +181,19 @@ message ReqParacrossTitleHeight {
int64
height
=
2
;
}
message
RespParacrossDone
{
int32
totalNodes
=
1
;
int32
totalCommit
=
2
;
int32
mostSameCommit
=
3
;
string
title
=
4
;
int64
height
=
5
;
string
stateHash
=
6
;
uint32
txCounts
=
7
;
string
txResult
=
8
;
}
message
RespParacrossTitles
{
repeated
Re
ceipt
ParacrossDone
titles
=
1
;
repeated
Re
sp
ParacrossDone
titles
=
1
;
}
message
ReqParacrossTitleHash
{
...
...
@@ -213,7 +224,7 @@ message ParacrossAsset {
service
paracross
{
rpc
GetTitle
(
ReqString
)
returns
(
ParacrossConsensusStatus
)
{}
rpc
ListTitles
(
ReqNil
)
returns
(
RespParacrossTitles
)
{}
rpc
GetTitleHeight
(
ReqParacrossTitleHeight
)
returns
(
Re
ceipt
ParacrossDone
)
{}
rpc
GetTitleHeight
(
ReqParacrossTitleHeight
)
returns
(
Re
sp
ParacrossDone
)
{}
rpc
GetAssetTxResult
(
ReqHash
)
returns
(
ParacrossAsset
)
{}
rpc
IsSync
(
ReqNil
)
returns
(
IsCaughtUp
)
{}
}
\ No newline at end of file
plugin/dapp/paracross/rpc/rpc.go
View file @
70d84651
...
...
@@ -72,12 +72,12 @@ func (c *Jrpc) ListTitles(req *types.ReqNil, result *interface{}) error {
return
err
}
func
(
c
*
channelClient
)
GetTitleHeight
(
ctx
context
.
Context
,
req
*
pt
.
ReqParacrossTitleHeight
)
(
*
pt
.
Re
ceipt
ParacrossDone
,
error
)
{
func
(
c
*
channelClient
)
GetTitleHeight
(
ctx
context
.
Context
,
req
*
pt
.
ReqParacrossTitleHeight
)
(
*
pt
.
Re
sp
ParacrossDone
,
error
)
{
data
,
err
:=
c
.
Query
(
pt
.
GetExecName
(),
"GetTitleHeight"
,
req
)
if
err
!=
nil
{
return
nil
,
err
}
if
resp
,
ok
:=
data
.
(
*
pt
.
Re
ceipt
ParacrossDone
);
ok
{
if
resp
,
ok
:=
data
.
(
*
pt
.
Re
sp
ParacrossDone
);
ok
{
return
resp
,
nil
}
return
nil
,
types
.
ErrDecode
...
...
@@ -168,8 +168,10 @@ func (c *Jrpc) GetBlock2MainInfo(req *types.ReqBlocks, result *interface{}) erro
return
err
}
// GetNodeGroup get super node group
func
(
c
*
channelClient
)
GetNodeGroup
(
ctx
context
.
Context
,
req
*
types
.
ReqString
)
(
*
types
.
ReplyConfig
,
error
)
{
data
,
err
:=
c
.
Query
(
pt
.
GetExecName
(),
"GetNodeGroup"
,
req
)
r
:=
*
req
data
,
err
:=
c
.
Query
(
pt
.
GetExecName
(),
"GetNodeGroup"
,
&
r
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -179,15 +181,17 @@ func (c *channelClient) GetNodeGroup(ctx context.Context, req *types.ReqString)
return
nil
,
types
.
ErrDecode
}
//
ListTitles get paracross consensus titles list
//
GetNodeGroup get super node group
func
(
c
*
Jrpc
)
GetNodeGroup
(
req
*
types
.
ReqString
,
result
*
interface
{})
error
{
data
,
err
:=
c
.
cli
.
GetNodeGroup
(
context
.
Background
(),
req
)
*
result
=
data
return
err
}
// GetNodeStatus get super node status
func
(
c
*
channelClient
)
GetNodeStatus
(
ctx
context
.
Context
,
req
*
pt
.
ReqParacrossNodeInfo
)
(
*
pt
.
ParaNodeAddrStatus
,
error
)
{
data
,
err
:=
c
.
Query
(
pt
.
GetExecName
(),
"GetNodeAddrInfo"
,
req
)
r
:=
*
req
data
,
err
:=
c
.
Query
(
pt
.
GetExecName
(),
"GetNodeAddrInfo"
,
&
r
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -197,15 +201,17 @@ func (c *channelClient) GetNodeStatus(ctx context.Context, req *pt.ReqParacrossN
return
nil
,
types
.
ErrDecode
}
//
ListTitles get paracross consensus titles list
//
GetNodeStatus get super node status
func
(
c
*
Jrpc
)
GetNodeStatus
(
req
*
pt
.
ReqParacrossNodeInfo
,
result
*
interface
{})
error
{
data
,
err
:=
c
.
cli
.
GetNodeStatus
(
context
.
Background
(),
req
)
*
result
=
data
return
err
}
//ListNodeStatus list super node by status
func
(
c
*
channelClient
)
ListNodeStatus
(
ctx
context
.
Context
,
req
*
pt
.
ReqParacrossNodeInfo
)
(
*
pt
.
RespParacrossNodeAddrs
,
error
)
{
data
,
err
:=
c
.
Query
(
pt
.
GetExecName
(),
"ListNodeStatusInfo"
,
req
)
r
:=
*
req
data
,
err
:=
c
.
Query
(
pt
.
GetExecName
(),
"ListNodeStatusInfo"
,
&
r
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -215,7 +221,7 @@ func (c *channelClient) ListNodeStatus(ctx context.Context, req *pt.ReqParacross
return
nil
,
types
.
ErrDecode
}
//
ListTitles get paracross consensus titles list
//
ListNodeStatus list super node by status
func
(
c
*
Jrpc
)
ListNodeStatus
(
req
*
pt
.
ReqParacrossNodeInfo
,
result
*
interface
{})
error
{
data
,
err
:=
c
.
cli
.
ListNodeStatus
(
context
.
Background
(),
req
)
*
result
=
data
...
...
plugin/dapp/paracross/types/errors.go
View file @
70d84651
...
...
@@ -28,13 +28,19 @@ var (
// ErrParaCurHashNotMatch para curr main hash not match with pre, main node may switched
ErrParaCurHashNotMatch
=
errors
.
New
(
"ErrParaCurHashNotMatch"
)
// ErrParaUnSupportNodeOper unsupport node operation
ErrParaUnSupportNodeOper
=
errors
.
New
(
"ErrParaUnSupportNodeOper"
)
ErrParaNodeAddrExisted
=
errors
.
New
(
"ErrParaNodeAddrExisted"
)
ErrParaNodeAddrNotExisted
=
errors
.
New
(
"ErrParaNodeAddrNotExisted"
)
ErrParaManageNodesNotSet
=
errors
.
New
(
"ErrParaManageNodesNotSet"
)
ErrParaNodeGroupNotSet
=
errors
.
New
(
"ErrParaManageNodesNotSet"
)
ErrParaNodeGroupExisted
=
errors
.
New
(
"ErrParaNodesExisted"
)
ErrParaNodeGroupLastAddr
=
errors
.
New
(
"ErrParaNodeGroupLastAddr"
)
ErrParaNodeGroupRefuseByVote
=
errors
.
New
(
"ErrParaNodeGroupRefuseByVote"
)
ErrParaNodeVoteSelf
=
errors
.
New
(
"ErrParaNodeVoteSelf"
)
ErrParaUnSupportNodeOper
=
errors
.
New
(
"ErrParaUnSupportNodeOper"
)
//ErrParaNodeAddrExisted node addr exist in group
ErrParaNodeAddrExisted
=
errors
.
New
(
"ErrParaNodeAddrExisted"
)
//ErrParaNodeAddrNotExisted node addr not exist in group
ErrParaNodeAddrNotExisted
=
errors
.
New
(
"ErrParaNodeAddrNotExisted"
)
//ErrParaManageNodesNotSet config manage node not set
ErrParaManageNodesNotSet
=
errors
.
New
(
"ErrParaManageNodesNotSet"
)
//ErrParaNodeGroupNotSet para config node group not set by take over
ErrParaNodeGroupNotSet
=
errors
.
New
(
"ErrParaManageNodesNotSet"
)
//ErrParaNodeGroupExisted para config group taked over alreay
ErrParaNodeGroupExisted
=
errors
.
New
(
"ErrParaNodesExisted"
)
//ErrParaNodeGroupLastAddr last super node not be allow to quite
ErrParaNodeGroupLastAddr
=
errors
.
New
(
"ErrParaNodeGroupLastAddr"
)
//ErrParaNodeVoteSelf vote self not allow
ErrParaNodeVoteSelf
=
errors
.
New
(
"ErrParaNodeVoteSelf"
)
)
plugin/dapp/paracross/types/paracross.go
View file @
70d84651
...
...
@@ -70,6 +70,7 @@ const (
ParacrossActionAssetTransfer
=
iota
+
paraCrossTransferActionTypeStart
// ParacrossActionAssetWithdraw paracross asset withdraw key
ParacrossActionAssetWithdraw
//ParacrossActionNodeConfig para super node config
ParacrossActionNodeConfig
)
...
...
@@ -83,26 +84,24 @@ const (
// node config op
const
(
ParaNode
Add
=
"add
"
ParaNode
Delete
=
"delete
"
ParaNode
Join
=
"join
"
ParaNode
Quit
=
"quit
"
ParaNodeVote
=
"vote"
ParaNodeTakeover
=
"takeover"
ParaNodeVote
Pass
=
"pas
s"
ParaNodeVoteNo
=
"no"
ParaNodeVote
Yes
=
"ye
s"
ParaNodeVoteNo
=
"no"
)
const
(
// ParacrossNodeAdding apply for adding group
ParacrossNodeAdding
=
iota
// ParacrossNodeAdded
,
pass to add by votes
ParacrossNodeAdding
=
iota
+
1
// ParacrossNodeAdded pass to add by votes
ParacrossNodeAdded
// ParacrossNodeQuiting
,
apply for quiting
// ParacrossNodeQuiting apply for quiting
ParacrossNodeQuiting
// ParacrossNodeQuited
,
pass to quite by votes
// ParacrossNodeQuited pass to quite by votes
ParacrossNodeQuited
// ParacrossNodeRefused, refused by votes, add or quite
ParacrossNodeRefused
)
var
(
...
...
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