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
8738c5a7
Commit
8738c5a7
authored
Apr 30, 2019
by
mdj33
Committed by
vipwzw
May 05, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added super manager height process
parent
3417653c
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
73 additions
and
29 deletions
+73
-29
paracross.go
plugin/dapp/paracross/commands/paracross.go
+1
-1
action.go
plugin/dapp/paracross/executor/action.go
+30
-10
exec.go
plugin/dapp/paracross/executor/exec.go
+1
-1
exec_del_local.go
plugin/dapp/paracross/executor/exec_del_local.go
+1
-1
exec_local.go
plugin/dapp/paracross/executor/exec_local.go
+2
-5
query.go
plugin/dapp/paracross/executor/query.go
+12
-7
superaccount.go
plugin/dapp/paracross/executor/superaccount.go
+0
-0
paracross.proto
plugin/dapp/paracross/proto/paracross.proto
+19
-2
paracross.go
plugin/dapp/paracross/types/paracross.go
+6
-1
type.go
plugin/dapp/paracross/types/type.go
+1
-1
No files found.
plugin/dapp/paracross/commands/paracross.go
View file @
8738c5a7
...
...
@@ -329,7 +329,7 @@ func nodeGroupApply(cmd *cobra.Command, args []string) {
return
}
payload
:=
&
pt
.
ParaNodeGroup
Apply
{
Op
:
op
,
Addrs
:
addrs
,
CoinsFrozen
:
int64
(
math
.
Trunc
((
coins
+
0.0000001
)
*
1e4
))
*
1e4
}
payload
:=
&
pt
.
ParaNodeGroup
Config
{
Op
:
op
,
Addrs
:
addrs
,
CoinsFrozen
:
int64
(
math
.
Trunc
((
coins
+
0.0000001
)
*
1e4
))
*
1e4
}
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
types
.
ExecName
(
pt
.
ParaX
),
ActionName
:
"NodeGroupApply"
,
...
...
plugin/dapp/paracross/executor/action.go
View file @
8738c5a7
...
...
@@ -71,6 +71,16 @@ func getNodes(db dbm.KV, key []byte) (map[string]struct{}, []string, error) {
return
nodesMap
,
nodesArray
,
nil
}
func
getConfigManageNodes
(
db
dbm
.
KV
,
title
string
)
(
map
[
string
]
struct
{},
[]
string
,
error
)
{
key
:=
calcManageConfigNodesKey
(
title
)
return
getNodes
(
db
,
key
)
}
func
getParacrossNodes
(
db
dbm
.
KV
,
title
string
)
(
map
[
string
]
struct
{},
[]
string
,
error
)
{
key
:=
calcParaNodeGroupKey
(
title
)
return
getNodes
(
db
,
key
)
}
func
validTitle
(
title
string
)
bool
{
if
types
.
IsPara
()
{
return
types
.
GetTitle
()
==
title
...
...
@@ -214,31 +224,38 @@ func hasCommited(addrs []string, addr string) (bool, int) {
return
false
,
0
}
func
(
a
*
action
)
getNodesGroup
(
title
string
)
(
map
[
string
]
struct
{},
error
)
{
forkHeight
:=
types
.
GetDappFork
(
pt
.
ParaX
,
pt
.
ForkCommitTx
)
func
getDappForkHeight
(
fork
string
)
int64
{
paraConfigFork
:=
""
if
fork
==
pt
.
ForkCommitTx
{
paraConfigFork
=
"MainForkParacrossCommitTx"
}
var
forkHeight
int64
if
types
.
IsPara
()
{
forkHeight
=
types
.
Conf
(
"config.consensus.sub.para"
)
.
GInt
(
"MainForkParacrossCommitTx"
)
forkHeight
=
types
.
Conf
(
"config.consensus.sub.para"
)
.
GInt
(
paraConfigFork
)
if
forkHeight
<=
0
{
forkHeight
=
types
.
MaxHeight
}
}
else
{
forkHeight
=
types
.
GetDappFork
(
pt
.
ParaX
,
fork
)
}
if
a
.
exec
.
GetMainHeight
()
<
forkHeight
{
key
:=
calcManageConfigNodesKey
(
title
)
nodes
,
_
,
err
:=
getNodes
(
a
.
db
,
key
)
return
forkHeight
}
func
(
a
*
action
)
getNodesGroup
(
title
string
)
(
map
[
string
]
struct
{},
error
)
{
if
a
.
exec
.
GetMainHeight
()
<
getDappForkHeight
(
pt
.
ForkCommitTx
)
{
nodes
,
_
,
err
:=
getConfigManageNodes
(
a
.
db
,
title
)
if
err
!=
nil
{
return
nil
,
errors
.
Wrapf
(
err
,
"getNodes for title:%s"
,
title
)
}
return
nodes
,
nil
}
key
:=
calcParaNodeGroupKey
(
title
)
nodes
,
_
,
err
:=
getNodes
(
a
.
db
,
key
)
nodes
,
_
,
err
:=
getParacrossNodes
(
a
.
db
,
title
)
if
err
!=
nil
{
if
errors
.
Cause
(
err
)
!=
pt
.
ErrTitleNotExist
{
return
nil
,
errors
.
Wrapf
(
err
,
"getNodes para for title:%s"
,
title
)
}
key
=
calcManageConfigNodesKey
(
title
)
nodes
,
_
,
err
=
getNodes
(
a
.
db
,
key
)
nodes
,
_
,
err
=
getConfigManageNodes
(
a
.
db
,
title
)
if
err
!=
nil
{
return
nil
,
errors
.
Wrapf
(
err
,
"getNodes manager for title:%s"
,
title
)
}
...
...
@@ -329,6 +346,9 @@ func (a *action) Commit(commit *pt.ParacrossCommitAction) (*types.Receipt, error
BlockHash
:
[][]
byte
{
commit
.
Status
.
BlockHash
},
},
}
if
a
.
exec
.
GetMainHeight
()
>=
getDappForkHeight
(
pt
.
ForkCommitTx
)
{
stat
.
MainHeight
=
commit
.
Status
.
MainBlockHeight
}
receipt
=
makeCommitReceipt
(
a
.
fromaddr
,
commit
,
nil
,
stat
)
}
else
{
var
copyStat
pt
.
ParacrossHeightStatus
...
...
plugin/dapp/paracross/executor/exec.go
View file @
8738c5a7
...
...
@@ -94,7 +94,7 @@ func (e *Paracross) Exec_NodeConfig(payload *pt.ParaNodeAddrConfig, tx *types.Tr
}
//Exec_NodeGroupConfig node group config process
func
(
e
*
Paracross
)
Exec_NodeGroupConfig
(
payload
*
pt
.
ParaNodeGroup
Apply
,
tx
*
types
.
Transaction
,
index
int
)
(
*
types
.
Receipt
,
error
)
{
func
(
e
*
Paracross
)
Exec_NodeGroupConfig
(
payload
*
pt
.
ParaNodeGroup
Config
,
tx
*
types
.
Transaction
,
index
int
)
(
*
types
.
Receipt
,
error
)
{
a
:=
newAction
(
e
,
tx
)
return
a
.
NodeGroupConfig
(
payload
)
}
plugin/dapp/paracross/executor/exec_del_local.go
View file @
8738c5a7
...
...
@@ -80,7 +80,7 @@ func (e *Paracross) ExecDelLocal_NodeConfig(payload *pt.ParaNodeAddrConfig, tx *
}
// ExecDelLocal_NodeGroupConfig node group config tx delete process
func
(
e
*
Paracross
)
ExecDelLocal_NodeGroupConfig
(
payload
*
pt
.
ParaNodeGroup
Apply
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
func
(
e
*
Paracross
)
ExecDelLocal_NodeGroupConfig
(
payload
*
pt
.
ParaNodeGroup
Config
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
var
set
types
.
LocalDBSet
for
_
,
log
:=
range
receiptData
.
Logs
{
if
log
.
Ty
==
pt
.
TyLogParaNodeGroupApply
||
log
.
Ty
==
pt
.
TyLogParaNodeGroupApprove
||
...
...
plugin/dapp/paracross/executor/exec_local.go
View file @
8738c5a7
...
...
@@ -81,7 +81,7 @@ func (e *Paracross) ExecLocal_NodeConfig(payload *pt.ParaNodeAddrConfig, tx *typ
}
//ExecLocal_NodeGroupConfig node group config add process
func
(
e
*
Paracross
)
ExecLocal_NodeGroupConfig
(
payload
*
pt
.
ParaNodeGroup
Apply
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
func
(
e
*
Paracross
)
ExecLocal_NodeGroupConfig
(
payload
*
pt
.
ParaNodeGroup
Config
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
var
set
types
.
LocalDBSet
for
_
,
log
:=
range
receiptData
.
Logs
{
if
log
.
Ty
==
pt
.
TyLogParaNodeGroupApply
||
log
.
Ty
==
pt
.
TyLogParaNodeGroupApprove
||
...
...
@@ -169,10 +169,7 @@ func (e *Paracross) ExecLocal_Miner(payload *pt.ParacrossMinerAction, tx *types.
var
set
types
.
LocalDBSet
txs
:=
e
.
GetTxs
()
forkHeight
:=
types
.
Conf
(
"config.consensus.sub.para"
)
.
GInt
(
"MainForkParacrossCommitTx"
)
if
forkHeight
==
-
1
||
forkHeight
==
0
{
forkHeight
=
types
.
MaxHeight
}
forkHeight
:=
getDappForkHeight
(
pt
.
ForkCommitTx
)
//removed the 0 vote tx
if
payload
.
Status
.
MainBlockHeight
>=
forkHeight
{
...
...
plugin/dapp/paracross/executor/query.go
View file @
8738c5a7
...
...
@@ -40,8 +40,7 @@ func (p *Paracross) Query_GetNodeGroupAddrs(in *pt.ReqParacrossNodeInfo) (types.
if
in
==
nil
{
return
nil
,
types
.
ErrInvalidParam
}
key
:=
calcParaNodeGroupKey
(
in
.
GetTitle
())
ret
,
_
,
err
:=
getNodes
(
p
.
GetStateDB
(),
key
)
ret
,
_
,
err
:=
getParacrossNodes
(
p
.
GetStateDB
(),
in
.
GetTitle
())
if
err
!=
nil
{
return
nil
,
errors
.
Cause
(
err
)
}
...
...
@@ -50,7 +49,7 @@ func (p *Paracross) Query_GetNodeGroupAddrs(in *pt.ReqParacrossNodeInfo) (types.
nodes
=
append
(
nodes
,
k
)
}
var
reply
types
.
ReplyConfig
reply
.
Key
=
string
(
key
)
reply
.
Key
=
string
(
calcParaNodeGroupKey
(
in
.
GetTitle
())
)
reply
.
Value
=
fmt
.
Sprint
(
nodes
)
return
&
reply
,
nil
}
...
...
@@ -60,8 +59,7 @@ func (p *Paracross) Query_GetNodeAddrInfo(in *pt.ReqParacrossNodeInfo) (types.Me
if
in
==
nil
||
in
.
Title
==
""
||
in
.
Addr
==
""
{
return
nil
,
types
.
ErrInvalidParam
}
key
:=
calcParaNodeAddrKey
(
in
.
Title
,
in
.
Addr
)
stat
,
err
:=
getNodeAddr
(
p
.
GetStateDB
(),
key
)
stat
,
err
:=
getNodeAddr
(
p
.
GetStateDB
(),
in
.
Title
,
in
.
Addr
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -81,8 +79,7 @@ func (p *Paracross) Query_GetNodeGroupStatus(in *pt.ReqParacrossNodeInfo) (types
if
in
==
nil
||
in
.
Title
==
""
{
return
nil
,
types
.
ErrInvalidParam
}
key
:=
calcParaNodeGroupApplyKey
(
in
.
Title
)
stat
,
err
:=
getNodeAddr
(
p
.
GetStateDB
(),
key
)
stat
,
err
:=
getNodeGroupStatus
(
p
.
GetStateDB
(),
in
.
Title
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -158,6 +155,14 @@ func (p *Paracross) paracrossGetHeight(title string) (types.Message, error) {
return
ret
,
nil
}
func
(
p
*
Paracross
)
paracrossGetStateTitleHeight
(
title
string
,
height
int64
)
(
types
.
Message
,
error
)
{
ret
,
err
:=
getTitleHeight
(
p
.
GetStateDB
(),
calcTitleHeightKey
(
title
,
height
))
if
err
!=
nil
{
return
nil
,
errors
.
Cause
(
err
)
}
return
ret
,
nil
}
func
(
p
*
Paracross
)
paracrossListTitles
()
(
types
.
Message
,
error
)
{
return
listLocalTitles
(
p
.
GetLocalDB
())
}
...
...
plugin/dapp/paracross/executor/superaccount.go
View file @
8738c5a7
This diff is collapsed.
Click to expand it.
plugin/dapp/paracross/proto/paracross.proto
View file @
8738c5a7
...
...
@@ -82,7 +82,7 @@ message ReceiptParaNodeVoteDone {
}
message
ParaNodeGroup
Apply
{
message
ParaNodeGroup
Config
{
string
title
=
1
;
uint32
op
=
2
;
string
addrs
=
3
;
...
...
@@ -91,6 +91,23 @@ message ParaNodeGroupApply{
}
message
ParaNodeGroupStatus
{
int32
status
=
1
;
string
title
=
2
;
string
applyAddr
=
3
;
int64
coinsFrozen
=
4
;
uint32
emptyBlockInterval
=
5
;
int64
mainHeight
=
6
;
}
message
ReceiptParaNodeGroupConfig
{
string
addr
=
1
;
ParaNodeGroupConfig
config
=
2
;
ParaNodeGroupStatus
prev
=
3
;
ParaNodeGroupStatus
current
=
4
;
}
// node query
message
ReqParacrossNodeInfo
{
string
title
=
1
;
...
...
@@ -149,7 +166,7 @@ message ParacrossAction {
AssetsWithdraw
withdraw
=
7
;
AssetsTransferToExec
transferToExec
=
8
;
ParaNodeAddrConfig
nodeConfig
=
9
;
ParaNodeGroup
Apply
nodeGroupConfig
=
10
;
ParaNodeGroup
Config
nodeGroupConfig
=
10
;
}
...
...
plugin/dapp/paracross/types/paracross.go
View file @
8738c5a7
...
...
@@ -190,8 +190,13 @@ func CreateRawNodeConfigTx(config *ParaNodeAddrConfig) (*types.Transaction, erro
}
//CreateRawNodeGroupApplyTx create raw tx for node group
func
CreateRawNodeGroupApplyTx
(
apply
*
ParaNodeGroup
Apply
)
(
*
types
.
Transaction
,
error
)
{
func
CreateRawNodeGroupApplyTx
(
apply
*
ParaNodeGroup
Config
)
(
*
types
.
Transaction
,
error
)
{
apply
.
Title
=
types
.
GetTitle
()
apply
.
EmptyBlockInterval
=
4
interval
:=
types
.
Conf
(
"config.consensus.sub.para"
)
.
GInt
(
"emptyBlockInterval"
)
if
interval
>
0
{
apply
.
EmptyBlockInterval
=
uint32
(
interval
)
}
action
:=
&
ParacrossAction
{
Ty
:
ParacrossActionNodeGroupApply
,
...
...
plugin/dapp/paracross/types/type.go
View file @
8738c5a7
...
...
@@ -130,7 +130,7 @@ func (p ParacrossType) CreateTx(action string, message json.RawMessage) (*types.
if
!
types
.
IsPara
()
{
return
nil
,
types
.
ErrNotSupport
}
var
param
ParaNodeGroup
Apply
var
param
ParaNodeGroup
Config
err
:=
types
.
JSONToPB
(
message
,
&
param
)
//err := json.Unmarshal(message, ¶m)
if
err
!=
nil
{
...
...
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