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
0409f6d5
Commit
0409f6d5
authored
Jan 16, 2020
by
mdj33
Committed by
vipwzw
Feb 18, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add para chain exec check
parent
83a7a649
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
46 additions
and
108 deletions
+46
-108
testcase.sh
plugin/dapp/paracross/cmd/build/testcase.sh
+6
-9
test-rpc.sh
plugin/dapp/paracross/cmd/test/test-rpc.sh
+2
-2
paracross.go
plugin/dapp/paracross/commands/paracross.go
+6
-6
action.go
plugin/dapp/paracross/executor/action.go
+6
-0
paracross_test.go
plugin/dapp/paracross/executor/paracross_test.go
+11
-0
stage.go
plugin/dapp/paracross/executor/stage.go
+3
-4
superaccount.go
plugin/dapp/paracross/executor/superaccount.go
+6
-0
paracross.proto
plugin/dapp/paracross/proto/paracross.proto
+1
-1
paracross.go
plugin/dapp/paracross/types/paracross.go
+0
-36
type.go
plugin/dapp/paracross/types/type.go
+5
-50
No files found.
plugin/dapp/paracross/cmd/build/testcase.sh
View file @
0409f6d5
...
@@ -39,7 +39,7 @@ function para_set_toml() {
...
@@ -39,7 +39,7 @@ function para_set_toml() {
cp
chain33.para.toml
"
${
1
}
"
cp
chain33.para.toml
"
${
1
}
"
local
paraname
=
"
$2
"
local
paraname
=
"
$2
"
sed
-i
$xsedfix
's/^Title.*/Title="user.p.'''
$paraname
'''."/g'
"
${
1
}
"
sed
-i
$xsedfix
's/^Title.*/Title="user.p.'''
"
$paraname
"
'''."/g'
"
${
1
}
"
sed
-i
$xsedfix
's/^# TestNet=.*/TestNet=true/g'
"
${
1
}
"
sed
-i
$xsedfix
's/^# TestNet=.*/TestNet=true/g'
"
${
1
}
"
sed
-i
$xsedfix
's/^startHeight=.*/startHeight=1/g'
"
${
1
}
"
sed
-i
$xsedfix
's/^startHeight=.*/startHeight=1/g'
"
${
1
}
"
sed
-i
$xsedfix
's/^interval=.*/interval=4/g'
"
${
1
}
"
sed
-i
$xsedfix
's/^interval=.*/interval=4/g'
"
${
1
}
"
...
@@ -101,9 +101,7 @@ function para_set_wallet() {
...
@@ -101,9 +101,7 @@ function para_set_wallet() {
para_import_key
"
${
PARA_CLI
}
"
"0x794443611e7369a57b078881445b93b754cbc9b9b8f526535ab9c6d21d29203d"
"othernode2"
para_import_key
"
${
PARA_CLI
}
"
"0x794443611e7369a57b078881445b93b754cbc9b9b8f526535ab9c6d21d29203d"
"othernode2"
#cross_transfer
#cross_transfer
#14KEKbYtKKQm4wMthSK9J4La4nAiidGozt
#1KSBd17H7ZK8iT37aJztFB22XGwsPTdwE4
# para_import_key "${PARA_CLI5}" "0xCC38546E9E659D15E6B4893F0AB32A06D103931A8230B0BDE71459D2B27D6944" "genesis"
#1KS
para_import_wallet
"
${
PARA_CLI5
}
"
"0x6da92a632ab7deb67d38c0f6560bcfed28167998f6496db64c258d5e8393a81b"
"paraAuthAccount"
para_import_wallet
"
${
PARA_CLI5
}
"
"0x6da92a632ab7deb67d38c0f6560bcfed28167998f6496db64c258d5e8393a81b"
"paraAuthAccount"
#1BM2xhBk95qoae8zKNDWwAVGgBERhb7DQu
#1BM2xhBk95qoae8zKNDWwAVGgBERhb7DQu
para_import_key
"
${
PARA_CLI5
}
"
"0x128de4afa7c061c00d854a1bca51b58e80a2c292583739e5aebf4c0f778959e1"
"cross_transfer"
para_import_key
"
${
PARA_CLI5
}
"
"0x128de4afa7c061c00d854a1bca51b58e80a2c292583739e5aebf4c0f778959e1"
"cross_transfer"
...
@@ -910,7 +908,7 @@ function para_nodemanage_node_behalf_join() {
...
@@ -910,7 +908,7 @@ function para_nodemanage_node_behalf_join() {
node1_id
=
$hash
node1_id
=
$hash
balance
=
$(${
CLI
}
account balance
-a
1Ka7EPFRqs3v9yreXG6qA4RQbNmbPJCZPj
-e
paracross | jq
-r
".frozen"
)
balance
=
$(${
CLI
}
account balance
-a
1Ka7EPFRqs3v9yreXG6qA4RQbNmbPJCZPj
-e
paracross | jq
-r
".frozen"
)
if
[
"
$balance
"
!=
"3
2
.0000"
]
;
then
if
[
"
$balance
"
!=
"3
7
.0000"
]
;
then
echo
"1Ka frozen coinfrozen error balance=
$balance
"
echo
"1Ka frozen coinfrozen error balance=
$balance
"
exit
1
exit
1
fi
fi
...
@@ -928,7 +926,7 @@ function para_nodemanage_node_behalf_join() {
...
@@ -928,7 +926,7 @@ function para_nodemanage_node_behalf_join() {
id
=
$hash
id
=
$hash
balance
=
$(${
CLI
}
account balance
-a
1Ka7EPFRqs3v9yreXG6qA4RQbNmbPJCZPj
-e
paracross | jq
-r
".frozen"
)
balance
=
$(${
CLI
}
account balance
-a
1Ka7EPFRqs3v9yreXG6qA4RQbNmbPJCZPj
-e
paracross | jq
-r
".frozen"
)
if
[
"
$balance
"
!=
"4
1
.0000"
]
;
then
if
[
"
$balance
"
!=
"4
6
.0000"
]
;
then
echo
"frozen coinfrozen error balance=
$balance
"
echo
"frozen coinfrozen error balance=
$balance
"
exit
1
exit
1
fi
fi
...
@@ -979,7 +977,7 @@ function para_nodemanage_node_behalf_join() {
...
@@ -979,7 +977,7 @@ function para_nodemanage_node_behalf_join() {
query_tx
"
${
PARA_CLI
}
"
"
${
hash
}
"
query_tx
"
${
PARA_CLI
}
"
"
${
hash
}
"
balance
=
$(${
CLI
}
account balance
-a
1Ka7EPFRqs3v9yreXG6qA4RQbNmbPJCZPj
-e
paracross | jq
-r
".frozen"
)
balance
=
$(${
CLI
}
account balance
-a
1Ka7EPFRqs3v9yreXG6qA4RQbNmbPJCZPj
-e
paracross | jq
-r
".frozen"
)
if
[
"
$balance
"
!=
"3
3
.0000"
]
;
then
if
[
"
$balance
"
!=
"3
8
.0000"
]
;
then
echo
"unfrozen coinfrozen error balance=
$balance
"
echo
"unfrozen coinfrozen error balance=
$balance
"
exit
1
exit
1
fi
fi
...
@@ -1005,7 +1003,7 @@ function para_nodemanage_node_behalf_join() {
...
@@ -1005,7 +1003,7 @@ function para_nodemanage_node_behalf_join() {
query_tx
"
${
PARA_CLI
}
"
"
${
hash
}
"
query_tx
"
${
PARA_CLI
}
"
"
${
hash
}
"
balance
=
$(${
CLI
}
account balance
-a
1Ka7EPFRqs3v9yreXG6qA4RQbNmbPJCZPj
-e
paracross | jq
-r
".frozen"
)
balance
=
$(${
CLI
}
account balance
-a
1Ka7EPFRqs3v9yreXG6qA4RQbNmbPJCZPj
-e
paracross | jq
-r
".frozen"
)
if
[
"
$balance
"
!=
"2
4
.0000"
]
;
then
if
[
"
$balance
"
!=
"2
9
.0000"
]
;
then
echo
"unfrozen coinfrozen error balance=
$balance
"
echo
"unfrozen coinfrozen error balance=
$balance
"
exit
1
exit
1
fi
fi
...
@@ -1084,7 +1082,6 @@ function privacy_transfer_test() {
...
@@ -1084,7 +1082,6 @@ function privacy_transfer_test() {
function
para_test
()
{
function
para_test
()
{
echo
"=========== # para chain test ============="
echo
"=========== # para chain test ============="
# block_wait2height "${PARA_CLI}" $MainLoopCheckForkHeight "1"
para_create_nodegroup
para_create_nodegroup
para_nodegroup_behalf_quit_test
para_nodegroup_behalf_quit_test
para_create_nodegroup_gamechain
para_create_nodegroup_gamechain
...
...
plugin/dapp/paracross/cmd/test/test-rpc.sh
View file @
0409f6d5
...
@@ -382,7 +382,7 @@ paracross_testSelfConsensStages() {
...
@@ -382,7 +382,7 @@ paracross_testSelfConsensStages() {
chainheight
=
$(
jq
'(.result.chainHeight)'
<<<
"
$resp
"
)
chainheight
=
$(
jq
'(.result.chainHeight)'
<<<
"
$resp
"
)
newHeight
=
$((
chainheight
+
2000
))
newHeight
=
$((
chainheight
+
2000
))
echo
"apply stage startHeight=
$newHeight
"
echo
"apply stage startHeight=
$newHeight
"
req
=
'"method":"Chain33.CreateTransaction","params":[{"execer" : "user.p.para.paracross","actionName" : "
selfCons
StageConfig","payload" : {"title":"user.p.para.","op" : "1", "stage" : {"startHeight":'
"
$newHeight
"
',"enable":2} }}]'
req
=
'"method":"Chain33.CreateTransaction","params":[{"execer" : "user.p.para.paracross","actionName" : "
Self
StageConfig","payload" : {"title":"user.p.para.","op" : "1", "stage" : {"startHeight":'
"
$newHeight
"
',"enable":2} }}]'
resp
=
$(
curl
-ksd
"{
$req
}"
"
${
para_ip
}
"
)
resp
=
$(
curl
-ksd
"{
$req
}"
"
${
para_ip
}
"
)
rawtx
=
$(
jq
-r
".result"
<<<
"
$resp
"
)
rawtx
=
$(
jq
-r
".result"
<<<
"
$resp
"
)
chain33_SignAndSendTx
"
$rawtx
"
"
$para_test_prikey
"
"
${
para_ip
}
"
chain33_SignAndSendTx
"
$rawtx
"
"
$para_test_prikey
"
"
${
para_ip
}
"
...
@@ -402,7 +402,7 @@ paracross_testSelfConsensStages() {
...
@@ -402,7 +402,7 @@ paracross_testSelfConsensStages() {
JR_PRI
=
"0x19c069234f9d3e61135fefbeb7791b149cdf6af536f26bebb310d4cd22c3fee4"
JR_PRI
=
"0x19c069234f9d3e61135fefbeb7791b149cdf6af536f26bebb310d4cd22c3fee4"
NL_PRI
=
"0x7a80a1f75d7360c6123c32a78ecf978c1ac55636f87892df38d8b85a9aeff115"
NL_PRI
=
"0x7a80a1f75d7360c6123c32a78ecf978c1ac55636f87892df38d8b85a9aeff115"
req
=
'"method":"Chain33.CreateTransaction","params":[{"execer" : "user.p.para.paracross","actionName" : "
selfCons
StageConfig","payload":{"title":"user.p.para.","op":"2","vote":{"id":"'
"
$id
"
'","value":1} }}]'
req
=
'"method":"Chain33.CreateTransaction","params":[{"execer" : "user.p.para.paracross","actionName" : "
Self
StageConfig","payload":{"title":"user.p.para.","op":"2","vote":{"id":"'
"
$id
"
'","value":1} }}]'
resp
=
$(
curl
-ksd
"{
$req
}"
"
${
para_ip
}
"
)
resp
=
$(
curl
-ksd
"{
$req
}"
"
${
para_ip
}
"
)
rawtx
=
$(
jq
-r
".result"
<<<
"
$resp
"
)
rawtx
=
$(
jq
-r
".result"
<<<
"
$resp
"
)
echo
"send vote 1"
echo
"send vote 1"
...
...
plugin/dapp/paracross/commands/paracross.go
View file @
0409f6d5
...
@@ -596,12 +596,12 @@ func selfConsStage(cmd *cobra.Command, args []string) {
...
@@ -596,12 +596,12 @@ func selfConsStage(cmd *cobra.Command, args []string) {
var
config
pt
.
ParaStageConfig
var
config
pt
.
ParaStageConfig
config
.
Title
=
paraName
config
.
Title
=
paraName
config
.
Op
=
pt
.
ParaOpNewApply
config
.
Ty
=
pt
.
ParaOpNewApply
config
.
Value
=
&
pt
.
ParaStageConfig_Stage
{
Stage
:
&
pt
.
SelfConsensStage
{
StartHeight
:
height
,
Enable
:
enable
}}
config
.
Value
=
&
pt
.
ParaStageConfig_Stage
{
Stage
:
&
pt
.
SelfConsensStage
{
StartHeight
:
height
,
Enable
:
enable
}}
params
:=
&
rpctypes
.
CreateTxIn
{
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
getRealExecName
(
paraName
,
pt
.
ParaX
),
Execer
:
getRealExecName
(
paraName
,
pt
.
ParaX
),
ActionName
:
"
selfCons
StageConfig"
,
ActionName
:
"
Self
StageConfig"
,
Payload
:
types
.
MustPBToJSON
(
&
config
),
Payload
:
types
.
MustPBToJSON
(
&
config
),
}
}
...
@@ -635,12 +635,12 @@ func createVoteTx(cmd *cobra.Command, args []string) {
...
@@ -635,12 +635,12 @@ func createVoteTx(cmd *cobra.Command, args []string) {
var
config
pt
.
ParaStageConfig
var
config
pt
.
ParaStageConfig
config
.
Title
=
paraName
config
.
Title
=
paraName
config
.
Op
=
pt
.
ParaOpVote
config
.
Ty
=
pt
.
ParaOpVote
config
.
Value
=
&
pt
.
ParaStageConfig_Vote
{
Vote
:
&
pt
.
ConfigVoteInfo
{
Id
:
id
,
Value
:
val
}}
config
.
Value
=
&
pt
.
ParaStageConfig_Vote
{
Vote
:
&
pt
.
ConfigVoteInfo
{
Id
:
id
,
Value
:
val
}}
params
:=
&
rpctypes
.
CreateTxIn
{
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
getRealExecName
(
paraName
,
pt
.
ParaX
),
Execer
:
getRealExecName
(
paraName
,
pt
.
ParaX
),
ActionName
:
"
selfCons
StageConfig"
,
ActionName
:
"
Self
StageConfig"
,
Payload
:
types
.
MustPBToJSON
(
&
config
),
Payload
:
types
.
MustPBToJSON
(
&
config
),
}
}
...
@@ -666,12 +666,12 @@ func stageCancelTx(cmd *cobra.Command, args []string) {
...
@@ -666,12 +666,12 @@ func stageCancelTx(cmd *cobra.Command, args []string) {
var
config
pt
.
ParaStageConfig
var
config
pt
.
ParaStageConfig
config
.
Title
=
paraName
config
.
Title
=
paraName
config
.
Op
=
pt
.
ParaOpCancel
config
.
Ty
=
pt
.
ParaOpCancel
config
.
Value
=
&
pt
.
ParaStageConfig_Cancel
{
Cancel
:
&
pt
.
ConfigCancelInfo
{
Id
:
id
}}
config
.
Value
=
&
pt
.
ParaStageConfig_Cancel
{
Cancel
:
&
pt
.
ConfigCancelInfo
{
Id
:
id
}}
params
:=
&
rpctypes
.
CreateTxIn
{
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
getRealExecName
(
paraName
,
pt
.
ParaX
),
Execer
:
getRealExecName
(
paraName
,
pt
.
ParaX
),
ActionName
:
"
selfCons
StageConfig"
,
ActionName
:
"
Self
StageConfig"
,
Payload
:
types
.
MustPBToJSON
(
&
config
),
Payload
:
types
.
MustPBToJSON
(
&
config
),
}
}
...
...
plugin/dapp/paracross/executor/action.go
View file @
0409f6d5
...
@@ -1149,6 +1149,7 @@ func getTitleFrom(exec []byte) ([]byte, error) {
...
@@ -1149,6 +1149,7 @@ func getTitleFrom(exec []byte) ([]byte, error) {
}
}
func
(
a
*
action
)
isAllowTransfer
()
error
{
func
(
a
*
action
)
isAllowTransfer
()
error
{
//1. 没有配置nodegroup 不允许
tit
,
err
:=
getTitleFrom
(
a
.
tx
.
Execer
)
tit
,
err
:=
getTitleFrom
(
a
.
tx
.
Execer
)
if
err
!=
nil
{
if
err
!=
nil
{
return
errors
.
Wrapf
(
types
.
ErrInvalidParam
,
"CrossAssetTransfer, not para chain exec=%s"
,
string
(
a
.
tx
.
Execer
))
return
errors
.
Wrapf
(
types
.
ErrInvalidParam
,
"CrossAssetTransfer, not para chain exec=%s"
,
string
(
a
.
tx
.
Execer
))
...
@@ -1160,6 +1161,11 @@ func (a *action) isAllowTransfer() error {
...
@@ -1160,6 +1161,11 @@ func (a *action) isAllowTransfer() error {
if
len
(
nodes
)
==
0
{
if
len
(
nodes
)
==
0
{
return
errors
.
Wrapf
(
err
,
"CrossAssetTransfer nodegroup not create,title=%s"
,
tit
)
return
errors
.
Wrapf
(
err
,
"CrossAssetTransfer nodegroup not create,title=%s"
,
tit
)
}
}
//2. 非跨链执行器不允许
if
!
types
.
IsParaExecName
(
string
(
a
.
tx
.
Execer
))
{
return
errors
.
Wrapf
(
types
.
ErrInvalidParam
,
"exec=%s,should prefix with user.p."
,
string
(
a
.
tx
.
Execer
))
}
return
nil
return
nil
}
}
...
...
plugin/dapp/paracross/executor/paracross_test.go
View file @
0409f6d5
...
@@ -822,3 +822,13 @@ func TestUpdateCommitBlockHashs(t *testing.T) {
...
@@ -822,3 +822,13 @@ func TestUpdateCommitBlockHashs(t *testing.T) {
assert
.
Equal
(
t
,
commit2
.
BlockHash
,
stat
.
BlockDetails
.
BlockHashs
[
1
])
assert
.
Equal
(
t
,
commit2
.
BlockHash
,
stat
.
BlockDetails
.
BlockHashs
[
1
])
}
}
func
TestValidParaCrossExec
(
t
*
testing
.
T
){
exec
:=
[]
byte
(
"paracross"
)
valid
:=
types
.
IsParaExecName
(
string
(
exec
))
assert
.
Equal
(
t
,
false
,
valid
)
exec
=
[]
byte
(
"user.p.para.paracross"
)
valid
=
types
.
IsParaExecName
(
string
(
exec
))
assert
.
Equal
(
t
,
true
,
valid
)
}
\ No newline at end of file
plugin/dapp/paracross/executor/stage.go
View file @
0409f6d5
...
@@ -300,16 +300,15 @@ func (a *action) stageVote(config *pt.ConfigVoteInfo) (*types.Receipt, error) {
...
@@ -300,16 +300,15 @@ func (a *action) stageVote(config *pt.ConfigVoteInfo) (*types.Receipt, error) {
//SelfConsensStageConfig support self consens stage config
//SelfConsensStageConfig support self consens stage config
func
(
a
*
action
)
SelfStageConfig
(
config
*
pt
.
ParaStageConfig
)
(
*
types
.
Receipt
,
error
)
{
func
(
a
*
action
)
SelfStageConfig
(
config
*
pt
.
ParaStageConfig
)
(
*
types
.
Receipt
,
error
)
{
if
config
.
Op
==
pt
.
ParaOpNewApply
{
if
config
.
Ty
==
pt
.
ParaOpNewApply
{
return
a
.
stageApply
(
config
.
GetStage
())
return
a
.
stageApply
(
config
.
GetStage
())
}
else
if
config
.
Op
==
pt
.
ParaOpCancel
{
}
else
if
config
.
Ty
==
pt
.
ParaOpCancel
{
return
a
.
stageCancel
(
config
.
GetCancel
())
return
a
.
stageCancel
(
config
.
GetCancel
())
}
else
if
config
.
Op
==
pt
.
ParaOpVote
{
}
else
if
config
.
Ty
==
pt
.
ParaOpVote
{
return
a
.
stageVote
(
config
.
GetVote
())
return
a
.
stageVote
(
config
.
GetVote
())
}
}
return
nil
,
pt
.
ErrParaUnSupportNodeOper
return
nil
,
pt
.
ErrParaUnSupportNodeOper
}
}
plugin/dapp/paracross/executor/superaccount.go
View file @
0409f6d5
...
@@ -990,6 +990,9 @@ func (a *action) NodeGroupConfig(config *pt.ParaNodeGroupConfig) (*types.Receipt
...
@@ -990,6 +990,9 @@ func (a *action) NodeGroupConfig(config *pt.ParaNodeGroupConfig) (*types.Receipt
if
!
validTitle
(
cfg
,
config
.
Title
)
{
if
!
validTitle
(
cfg
,
config
.
Title
)
{
return
nil
,
pt
.
ErrInvalidTitle
return
nil
,
pt
.
ErrInvalidTitle
}
}
if
!
types
.
IsParaExecName
(
string
(
a
.
tx
.
Execer
))
&&
cfg
.
IsDappFork
(
a
.
exec
.
GetMainHeight
(),
pt
.
ParaX
,
pt
.
ForkParaAssetTransferRbk
)
{
return
nil
,
errors
.
Wrapf
(
types
.
ErrInvalidParam
,
"exec=%s,should prefix with user.p."
,
string
(
a
.
tx
.
Execer
))
}
if
config
.
Op
==
pt
.
ParacrossNodeGroupApply
{
if
config
.
Op
==
pt
.
ParacrossNodeGroupApply
{
s
:=
strings
.
Trim
(
config
.
Addrs
,
" "
)
s
:=
strings
.
Trim
(
config
.
Addrs
,
" "
)
...
@@ -1028,6 +1031,9 @@ func (a *action) NodeConfig(config *pt.ParaNodeAddrConfig) (*types.Receipt, erro
...
@@ -1028,6 +1031,9 @@ func (a *action) NodeConfig(config *pt.ParaNodeAddrConfig) (*types.Receipt, erro
if
!
validTitle
(
cfg
,
config
.
Title
)
{
if
!
validTitle
(
cfg
,
config
.
Title
)
{
return
nil
,
pt
.
ErrInvalidTitle
return
nil
,
pt
.
ErrInvalidTitle
}
}
if
!
types
.
IsParaExecName
(
string
(
a
.
tx
.
Execer
))
&&
cfg
.
IsDappFork
(
a
.
exec
.
GetMainHeight
(),
pt
.
ParaX
,
pt
.
ForkParaAssetTransferRbk
)
{
return
nil
,
errors
.
Wrapf
(
types
.
ErrInvalidParam
,
"exec=%s,should prefix with user.p."
,
string
(
a
.
tx
.
Execer
))
}
if
config
.
Op
==
pt
.
ParaOpNewApply
{
if
config
.
Op
==
pt
.
ParaOpNewApply
{
return
a
.
nodeJoin
(
config
)
return
a
.
nodeJoin
(
config
)
...
...
plugin/dapp/paracross/proto/paracross.proto
View file @
0409f6d5
...
@@ -218,7 +218,7 @@ message ConfigCancelInfo {
...
@@ -218,7 +218,7 @@ message ConfigCancelInfo {
message
ParaStageConfig
{
message
ParaStageConfig
{
string
title
=
1
;
string
title
=
1
;
// 配置类型
// 配置类型
uint32
op
=
2
;
uint32
ty
=
2
;
oneof
value
{
oneof
value
{
SelfConsensStage
stage
=
10
;
SelfConsensStage
stage
=
10
;
ConfigVoteInfo
vote
=
11
;
ConfigVoteInfo
vote
=
11
;
...
...
plugin/dapp/paracross/types/paracross.go
View file @
0409f6d5
...
@@ -190,14 +190,6 @@ func CreateRawCommitTx4MainChain(cfg *types.Chain33Config, status *ParacrossNode
...
@@ -190,14 +190,6 @@ func CreateRawCommitTx4MainChain(cfg *types.Chain33Config, status *ParacrossNode
return
createRawCommitTx
(
cfg
,
status
,
name
,
fee
)
return
createRawCommitTx
(
cfg
,
status
,
name
,
fee
)
}
}
func
createRawParacrossCommitTx
(
cfg
*
types
.
Chain33Config
,
parm
*
paracrossCommitTx
)
(
*
types
.
Transaction
,
error
)
{
if
parm
==
nil
{
tlog
.
Error
(
"createRawParacrossCommitTx"
,
"parm"
,
parm
)
return
nil
,
types
.
ErrInvalidParam
}
return
createRawCommitTx
(
cfg
,
&
parm
.
Status
,
cfg
.
ExecName
(
ParaX
),
parm
.
Fee
)
}
func
createRawCommitTx
(
cfg
*
types
.
Chain33Config
,
status
*
ParacrossNodeStatus
,
name
string
,
feeRate
int64
)
(
*
types
.
Transaction
,
error
)
{
func
createRawCommitTx
(
cfg
*
types
.
Chain33Config
,
status
*
ParacrossNodeStatus
,
name
string
,
feeRate
int64
)
(
*
types
.
Transaction
,
error
)
{
v
:=
&
ParacrossCommitAction
{
v
:=
&
ParacrossCommitAction
{
Status
:
status
,
Status
:
status
,
...
@@ -258,21 +250,6 @@ func CreateRawNodeGroupApplyTx(apply *ParaNodeGroupConfig) (*types.Transaction,
...
@@ -258,21 +250,6 @@ func CreateRawNodeGroupApplyTx(apply *ParaNodeGroupConfig) (*types.Transaction,
}
}
//CreateRawSelfConsStageApplyTx create raw tx for self consens stage
func
CreateRawSelfConsStageApplyTx
(
apply
*
ParaStageConfig
)
(
*
types
.
Transaction
,
error
)
{
action
:=
&
ParacrossAction
{
Ty
:
ParacrossActionSelfStageConfig
,
Value
:
&
ParacrossAction_SelfStageConfig
{
apply
},
}
tx
:=
&
types
.
Transaction
{
Payload
:
types
.
Encode
(
action
),
}
return
tx
,
nil
}
// CreateRawAssetTransferTx create asset transfer tx
// CreateRawAssetTransferTx create asset transfer tx
func
CreateRawAssetTransferTx
(
cfg
*
types
.
Chain33Config
,
param
*
types
.
CreateTx
)
(
*
types
.
Transaction
,
error
)
{
func
CreateRawAssetTransferTx
(
cfg
*
types
.
Chain33Config
,
param
*
types
.
CreateTx
)
(
*
types
.
Transaction
,
error
)
{
// 跨链交易需要在主链和平行链上执行, 所以应该可以在主链和平行链上构建
// 跨链交易需要在主链和平行链上执行, 所以应该可以在主链和平行链上构建
...
@@ -354,20 +331,7 @@ func (p ParacrossType) CreateRawTransferTx(action string, param json.RawMessage)
...
@@ -354,20 +331,7 @@ func (p ParacrossType) CreateRawTransferTx(action string, param json.RawMessage)
return
tx
,
nil
return
tx
,
nil
}
}
//CreateRawCrossAssetTransferTx create raw cross asset transfer tx
func
CreateRawCrossAssetTransferTx
(
apply
*
CrossAssetTransfer
)
(
*
types
.
Transaction
,
error
)
{
action
:=
&
ParacrossAction
{
Ty
:
ParacrossActionCrossAssetTransfer
,
Value
:
&
ParacrossAction_CrossAssetTransfer
{
apply
},
}
tx
:=
&
types
.
Transaction
{
Payload
:
types
.
Encode
(
action
),
}
return
tx
,
nil
}
//GetDappForkHeight get paracross dapp fork height
//GetDappForkHeight get paracross dapp fork height
func
GetDappForkHeight
(
cfg
*
types
.
Chain33Config
,
forkKey
string
)
int64
{
func
GetDappForkHeight
(
cfg
*
types
.
Chain33Config
,
forkKey
string
)
int64
{
...
...
plugin/dapp/paracross/types/type.go
View file @
0409f6d5
...
@@ -135,16 +135,8 @@ func (p *ParacrossType) GetPayload() types.Message {
...
@@ -135,16 +135,8 @@ func (p *ParacrossType) GetPayload() types.Message {
// CreateTx paracross create tx by different action
// CreateTx paracross create tx by different action
func
(
p
ParacrossType
)
CreateTx
(
action
string
,
message
json
.
RawMessage
)
(
*
types
.
Transaction
,
error
)
{
func
(
p
ParacrossType
)
CreateTx
(
action
string
,
message
json
.
RawMessage
)
(
*
types
.
Transaction
,
error
)
{
cfg
:=
p
.
GetConfig
()
cfg
:=
p
.
GetConfig
()
if
action
==
"ParacrossCommit"
{
//保留老的ParacrossAssetTransfer接口,默认的AssetTransfer 也可以
var
param
paracrossCommitTx
if
action
==
"ParacrossAssetTransfer"
||
action
==
"ParacrossAssetWithdraw"
{
err
:=
json
.
Unmarshal
(
message
,
&
param
)
if
err
!=
nil
{
glog
.
Error
(
"CreateTx"
,
"Error"
,
err
)
return
nil
,
types
.
ErrInvalidParam
}
return
createRawParacrossCommitTx
(
cfg
,
&
param
)
}
else
if
action
==
"ParacrossAssetTransfer"
||
action
==
"ParacrossAssetWithdraw"
{
var
param
types
.
CreateTx
var
param
types
.
CreateTx
err
:=
json
.
Unmarshal
(
message
,
&
param
)
err
:=
json
.
Unmarshal
(
message
,
&
param
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -152,46 +144,9 @@ func (p ParacrossType) CreateTx(action string, message json.RawMessage) (*types.
...
@@ -152,46 +144,9 @@ func (p ParacrossType) CreateTx(action string, message json.RawMessage) (*types.
return
nil
,
types
.
ErrInvalidParam
return
nil
,
types
.
ErrInvalidParam
}
}
return
CreateRawAssetTransferTx
(
cfg
,
&
param
)
return
CreateRawAssetTransferTx
(
cfg
,
&
param
)
}
else
if
action
==
"Transfer"
||
action
==
"Withdraw"
||
action
==
"TransferToExec"
{
}
else
if
action
==
"ParacrossTransfer"
||
action
==
"Transfer"
||
//transfer/withdraw/toExec 需要特殊处理主链上的tx.to场景
action
==
"ParacrossWithdraw"
||
action
==
"Withdraw"
||
action
==
"ParacrossTransferToExec"
||
action
==
"TransferToExec"
{
return
p
.
CreateRawTransferTx
(
action
,
message
)
return
p
.
CreateRawTransferTx
(
action
,
message
)
}
else
if
action
==
"CrossAssetTransfer"
{
var
param
CrossAssetTransfer
err
:=
types
.
JSONToPB
(
message
,
&
param
)
if
err
!=
nil
{
glog
.
Error
(
"CreateTx.CrossAssetTransfer"
,
"Error"
,
err
)
return
nil
,
types
.
ErrInvalidParam
}
return
CreateRawCrossAssetTransferTx
(
&
param
)
}
else
if
action
==
"NodeConfig"
{
var
param
ParaNodeAddrConfig
err
:=
types
.
JSONToPB
(
message
,
&
param
)
if
err
!=
nil
{
glog
.
Error
(
"CreateTx.NodeConfig"
,
"Error"
,
err
)
return
nil
,
types
.
ErrInvalidParam
}
return
CreateRawNodeConfigTx
(
&
param
)
}
else
if
action
==
"NodeGroupConfig"
{
var
param
ParaNodeGroupConfig
err
:=
types
.
JSONToPB
(
message
,
&
param
)
//err := json.Unmarshal(message, ¶m)
if
err
!=
nil
{
glog
.
Error
(
"CreateTx.NodeGroupApply"
,
"Error"
,
err
)
return
nil
,
types
.
ErrInvalidParam
}
return
CreateRawNodeGroupApplyTx
(
&
param
)
}
else
if
action
==
"selfConsStageConfig"
{
var
param
ParaStageConfig
err
:=
types
.
JSONToPB
(
message
,
&
param
)
//err := json.Unmarshal(message, ¶m)
if
err
!=
nil
{
glog
.
Error
(
"CreateTx.selfConsStageConfig"
,
"Error"
,
err
)
return
nil
,
types
.
ErrInvalidParam
}
return
CreateRawSelfConsStageApplyTx
(
&
param
)
}
}
return
nil
,
types
.
ErrNotSupport
return
p
.
ExecTypeBase
.
CreateTx
(
action
,
message
)
}
}
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