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
586a3ff1
Commit
586a3ff1
authored
Nov 14, 2019
by
mdj33
Committed by
vipwzw
Nov 15, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add ci rpc test
parent
3bd22644
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
118 additions
and
51 deletions
+118
-51
paracommitmsg.go
plugin/consensus/para/paracommitmsg.go
+1
-1
test-rpc.sh
plugin/dapp/paracross/cmd/test/test-rpc.sh
+78
-14
paracross.go
plugin/dapp/paracross/commands/paracross.go
+15
-9
action.go
plugin/dapp/paracross/executor/action.go
+1
-1
paracross_test.go
plugin/dapp/paracross/executor/paracross_test.go
+2
-2
stage.go
plugin/dapp/paracross/executor/stage.go
+13
-13
stage_test.go
plugin/dapp/paracross/executor/stage_test.go
+4
-4
paracross.proto
plugin/dapp/paracross/proto/paracross.proto
+4
-4
type.go
plugin/dapp/paracross/types/type.go
+0
-3
No files found.
plugin/consensus/para/paracommitmsg.go
View file @
586a3ff1
...
...
@@ -755,7 +755,7 @@ func (client *commitMsgClient) getSelfConsensus() (*pt.ParacrossStatus, error) {
return
nil
,
err
}
//开启自共识后也要等到自共识真正切换之后再使用,如果本地区块已经过了自共识高度,但自共识的高度还没达成,就会导致共识机制出错
if
resp
.
Height
>
stage
.
Block
Height
{
if
resp
.
Height
>
stage
.
Start
Height
{
return
resp
,
nil
}
}
...
...
plugin/dapp/paracross/cmd/test/test-rpc.sh
View file @
586a3ff1
...
...
@@ -289,6 +289,10 @@ function paracross_ListNodeStatus() {
echo_rst
"
$FUNCNAME
"
"
$rst
"
}
#main chain import pri key
para_test_addr
=
"1MAuE8QSbbech3bVKK2JPJJxYxNtT95oSU"
para_test_prikey
=
"0x24d1fad138be98eebee31440f144aa38c404533f40862995282162bc538e91c8"
function
paracross_testTxGroup
()
{
local
para_ip
=
$1
...
...
@@ -300,27 +304,24 @@ function paracross_testTxGroup() {
paracross_addr
=
$(
curl
-ksd
'{"method":"Chain33.ConvertExectoAddr","params":[{"execname":"paracross"}]}'
"
${
main_ip
}
"
| jq
-r
".result"
)
echo
"paracross_addr=
$paracross_addr
"
#main chain import pri key
local
test_addr
=
"1MAuE8QSbbech3bVKK2JPJJxYxNtT95oSU"
local
test_prikey
=
"0x24d1fad138be98eebee31440f144aa38c404533f40862995282162bc538e91c8"
#execer
local
paracross_execer_name
=
"user.p.para.paracross"
local
trade_exec_name
=
"user.p.para.trade"
local
trade_exec_addr
=
"12bihjzbaYWjcpDiiy9SuAWeqNksQdiN13"
local
amount_trade
=
100000000
local
amount_transfer
=
800000000
chain33_ImportPrivkey
"
${
test_prikey
}
"
"
${
test_addr
}
"
"paracross-transfer6"
"
${
main_ip
}
"
chain33_ImportPrivkey
"
${
para_test_prikey
}
"
"
${
para_
test_addr
}
"
"paracross-transfer6"
"
${
main_ip
}
"
# tx fee + transfer 10 coins
chain33_applyCoins
"
${
test_addr
}
"
1000000000
"
${
main_ip
}
"
chain33_QueryBalance
"
${
test_addr
}
"
"
$main_ip
"
chain33_applyCoins
"
${
para_
test_addr
}
"
1000000000
"
${
main_ip
}
"
chain33_QueryBalance
"
${
para_
test_addr
}
"
"
$main_ip
"
#deposit 8 coins to paracross
chain33_SendToAddress
"
${
test_addr
}
"
"
$paracross_addr
"
"
$amount_transfer
"
"
${
main_ip
}
"
chain33_QueryExecBalance
"
${
test_addr
}
"
"paracross"
"
${
main_ip
}
"
chain33_SendToAddress
"
${
para_
test_addr
}
"
"
$paracross_addr
"
"
$amount_transfer
"
"
${
main_ip
}
"
chain33_QueryExecBalance
"
${
para_
test_addr
}
"
"paracross"
"
${
main_ip
}
"
# 资产从主链转移到平行链
tx_hash_asset
=
$(
curl
-ksd
'{"method":"Chain33.CreateTransaction","params":[{"execer":"'
"
${
paracross_execer_name
}
"
'","actionName":"ParacrossAssetTransfer","payload":{"execName":"'
"
${
paracross_execer_name
}
"
'","to":"'
"
$test_addr
"
'","amount":'
${
amount_transfer
}
'}}]}'
"
${
para_ip
}
"
| jq
-r
".result"
)
tx_hash_asset
=
$(
curl
-ksd
'{"method":"Chain33.CreateTransaction","params":[{"execer":"'
"
${
paracross_execer_name
}
"
'","actionName":"ParacrossAssetTransfer","payload":{"execName":"'
"
${
paracross_execer_name
}
"
'","to":"'
"
$
para_
test_addr
"
'","amount":'
${
amount_transfer
}
'}}]}'
"
${
para_ip
}
"
| jq
-r
".result"
)
#curl -ksd '{"method":"Chain33.CreateTransaction","params":[{"execer":"user.p.para.paracross","actionName":"ParacrossAssetTransfer","payload":{"execName":"user.p.para.paracross","to":"1MAuE8QSbbech3bVKK2JPJJxYxNtT95oSU","amount":100000000}}]}' http://172.20.0.5:8901
# 资产从平行链转移到平行链合约
...
...
@@ -336,7 +337,7 @@ function paracross_testTxGroup() {
tx_hash_transferExec
=
$(
jq
-r
".result"
<<<
"
$resp
"
)
#create tx group with none
req
=
'"method":"Chain33.CreateNoBlanaceTxs","params":[{"txHexs":["'
"
${
tx_hash_asset
}
"
'","'
"
${
tx_hash_transferExec
}
"
'"],"privkey":"'
"
${
test_prikey
}
"
'","expire":"120s"}]'
req
=
'"method":"Chain33.CreateNoBlanaceTxs","params":[{"txHexs":["'
"
${
tx_hash_asset
}
"
'","'
"
${
tx_hash_transferExec
}
"
'"],"privkey":"'
"
${
para_
test_prikey
}
"
'","expire":"120s"}]'
resp
=
$(
curl
-ksd
"{
$req
}"
"
${
para_ip
}
"
)
err
=
$(
jq
'(.error)'
<<<
"
$resp
"
)
if
[
"
$err
"
!=
null
]
;
then
...
...
@@ -346,10 +347,10 @@ function paracross_testTxGroup() {
tx_hash_group
=
$(
jq
-r
".result"
<<<
"
$resp
"
)
#sign 1
tx_sign
=
$(
curl
-ksd
'{"method":"Chain33.SignRawTx","params":[{"privkey":"'
"
$test_prikey
"
'","txHex":"'
"
$tx_hash_group
"
'","index":2,"expire":"120s"}]}'
"
${
para_ip
}
"
| jq
-r
".result"
)
tx_sign
=
$(
curl
-ksd
'{"method":"Chain33.SignRawTx","params":[{"privkey":"'
"
$
para_
test_prikey
"
'","txHex":"'
"
$tx_hash_group
"
'","index":2,"expire":"120s"}]}'
"
${
para_ip
}
"
| jq
-r
".result"
)
#curl -ksd '{"method":"Chain33.SignRawTx","params":[{"privkey":"0x24d1fad138be98eebee31440f144aa38c404533f40862995282162bc538e91c8","txHex":"0a10757365722e702e706172612e6e6f6e6512126e6f2d6665652d7472616e73616374696f6e1a6e080112210320bbac09528e19c55b0f89cb37ab265e7e856b1a8c388780322dbbfd194b52ba1a473045022100fe7763b2fa5b42eddccf1a3434cb6d6bb60a5c5c32e5498219e99be01bb94ad302201ecb9931a2bb4e1b0d49ec50ee552a774c1db8a1eb9b2dff47e4b931625e3af220e0a71230a89780b2a5b187990a3a2231466a58697076505142754e6f7a4133506150724b6846703854343166717141707640034a8c050a8e020a10757365722e702e706172612e6e6f6e6512126e6f2d6665652d7472616e73616374696f6e1a6e080112210320bbac09528e19c55b0f89cb37ab265e7e856b1a8c388780322dbbfd194b52ba1a473045022100fe7763b2fa5b42eddccf1a3434cb6d6bb60a5c5c32e5498219e99be01bb94ad302201ecb9931a2bb4e1b0d49ec50ee552a774c1db8a1eb9b2dff47e4b931625e3af220e0a71230a89780b2a5b187990a3a2231466a58697076505142754e6f7a4133506150724b6846703854343166717141707640034a2054ba4451fb8f226dd54b52ec086f4eaa4990d66876899b1badec8ce96ef55208522000f2e5970b5b1854da143f4f3e91bf7eb87d1d62869ef08a2ce3b109994ec3650abb010a15757365722e702e706172612e7061726163726f7373122e10904e22291080c2d72f2222314d41754538515362626563683362564b4b324a504a4a7859784e745439356f535530d195faf7d3a1ec9a4c3a223139574a4a7639366e4b4155347348465771476d7371666a786433376a617a71696940034a2054ba4451fb8f226dd54b52ec086f4eaa4990d66876899b1badec8ce96ef5520852208fb7939bf2701e5af9cef05da33020be682e10c84fde9bd8d24765031fad530b0aba010a15757365722e702e706172612e7061726163726f7373124f1004424b0a09636f696e732e6274791080ade2042215757365722e702e706172612e7061726163726f73732a2231326269686a7a626159576a637044696979395375415765714e6b735164694e313330a8c984ebb2bb90a5613a223139574a4a7639366e4b4155347348465771476d7371666a786433376a617a71696940034a2054ba4451fb8f226dd54b52ec086f4eaa4990d66876899b1badec8ce96ef55208522000f2e5970b5b1854da143f4f3e91bf7eb87d1d62869ef08a2ce3b109994ec365","index":2,"expire":"120s"}]}' http://172.20.0.5:8901
#sign 2
tx_sign2
=
$(
curl
-ksd
'{"method":"Chain33.SignRawTx","params":[{"privkey":"'
"
$test_prikey
"
'","txHex":"'
"
$tx_sign
"
'","index":3,"expire":"120s"}]}'
"
${
para_ip
}
"
| jq
-r
".result"
)
tx_sign2
=
$(
curl
-ksd
'{"method":"Chain33.SignRawTx","params":[{"privkey":"'
"
$
para_
test_prikey
"
'","txHex":"'
"
$tx_sign
"
'","index":3,"expire":"120s"}]}'
"
${
para_ip
}
"
| jq
-r
".result"
)
#curl -ksd '{"method":"Chain33.SignRawTx","params":[{"privkey":"0x24d1fad138be98eebee31440f144aa38c404533f40862995282162bc538e91c8","txHex":"0a10757365722e702e706172612e6e6f6e6512126e6f2d6665652d7472616e73616374696f6e1a6e080112210320bbac09528e19c55b0f89cb37ab265e7e856b1a8c388780322dbbfd194b52ba1a473045022100fe7763b2fa5b42eddccf1a3434cb6d6bb60a5c5c32e5498219e99be01bb94ad302201ecb9931a2bb4e1b0d49ec50ee552a774c1db8a1eb9b2dff47e4b931625e3af220e0a71230a89780b2a5b187990a3a2231466a58697076505142754e6f7a4133506150724b6846703854343166717141707640034afc050a8e020a10757365722e702e706172612e6e6f6e6512126e6f2d6665652d7472616e73616374696f6e1a6e080112210320bbac09528e19c55b0f89cb37ab265e7e856b1a8c388780322dbbfd194b52ba1a473045022100fe7763b2fa5b42eddccf1a3434cb6d6bb60a5c5c32e5498219e99be01bb94ad302201ecb9931a2bb4e1b0d49ec50ee552a774c1db8a1eb9b2dff47e4b931625e3af220e0a71230a89780b2a5b187990a3a2231466a58697076505142754e6f7a4133506150724b6846703854343166717141707640034a2054ba4451fb8f226dd54b52ec086f4eaa4990d66876899b1badec8ce96ef55208522000f2e5970b5b1854da143f4f3e91bf7eb87d1d62869ef08a2ce3b109994ec3650aab020a15757365722e702e706172612e7061726163726f7373122e10904e22291080c2d72f2222314d41754538515362626563683362564b4b324a504a4a7859784e745439356f53551a6e0801122103589ebf581958aeb8a72ff517f823c878aee16139ecbf0001a4611e9c004fecdf1a473045022100da5ad2bdc6e1e43a01d32c44f116e5d0bf96aa4c16debad49381ea5d11a49835022055a510460df9b63f8f585393d6603abf1388fac0e122b53ef3533f242287915730d195faf7d3a1ec9a4c3a223139574a4a7639366e4b4155347348465771476d7371666a786433376a617a71696940034a2054ba4451fb8f226dd54b52ec086f4eaa4990d66876899b1badec8ce96ef5520852208fb7939bf2701e5af9cef05da33020be682e10c84fde9bd8d24765031fad530b0aba010a15757365722e702e706172612e7061726163726f7373124f1004424b0a09636f696e732e6274791080ade2042215757365722e702e706172612e7061726163726f73732a2231326269686a7a626159576a637044696979395375415765714e6b735164694e313330a8c984ebb2bb90a5613a223139574a4a7639366e4b4155347348465771476d7371666a786433376a617a71696940034a2054ba4451fb8f226dd54b52ec086f4eaa4990d66876899b1badec8ce96ef55208522000f2e5970b5b1854da143f4f3e91bf7eb87d1d62869ef08a2ce3b109994ec365","index":3,"expire":"120s"}]}' http://172.20.0.5:8901
#send
...
...
@@ -358,8 +359,8 @@ function paracross_testTxGroup() {
local
transfer_expect
=
"700000000"
local
exec_expect
=
"100000000"
transfer_val
=
$(
paracross_QueryParaBalance
"
${
test_addr
}
"
"
$paracross_execer_name
"
)
transfer_exec_val
=
$(
paracross_QueryParaBalance
"
${
test_addr
}
"
"
$trade_exec_name
"
)
transfer_val
=
$(
paracross_QueryParaBalance
"
${
para_
test_addr
}
"
"
$paracross_execer_name
"
)
transfer_exec_val
=
$(
paracross_QueryParaBalance
"
${
para_
test_addr
}
"
"
$trade_exec_name
"
)
if
[
"
${
transfer_val
}
"
!=
$transfer_expect
]
;
then
echo
"paracross_testTxGroup trasfer failed, get=
$transfer_val
,expec=
$transfer_expect
"
exit
1
...
...
@@ -372,6 +373,68 @@ function paracross_testTxGroup() {
echo_rst
"
$FUNCNAME
"
0
}
paracross_testSelfConsensStages
()
{
local
para_ip
=
$1
req
=
'"method":"paracross.GetHeight","params":[]'
resp
=
$(
curl
-ksd
"{
$req
}"
"
${
para_ip
}
"
)
err
=
$(
jq
'(.error)'
<<<
"
$resp
"
)
if
[
"
$err
"
!=
null
]
;
then
echo
"
$resp
"
exit
1
fi
chainheight
=
$(
jq
'(.result.chainHeight)'
<<<
"
$resp
"
)
newHeight
=
$((
chainheight
+
2000
))
echo
"apply stage startHeight=
$newHeight
"
req
=
'"method":"Chain33.CreateTransaction","params":[{"execer" : "user.p.para.paracross","actionName" : "selfConsStageConfig","payload" : {"title":"user.p.para.","op" : "1", "stage" : {"startHeight":'
"
$newHeight
"
',"enable":2} }}]'
resp
=
$(
curl
-ksd
"{
$req
}"
"
${
para_ip
}
"
)
rawtx
=
$(
jq
-r
".result"
<<<
"
$resp
"
)
chain33_SignRawTx
"
$rawtx
"
"
$para_test_prikey
"
"
${
para_ip
}
"
echo
"get stage apply id"
req
=
'"method":"paracross.ListSelfStages","params":[{"status":1,"count":1}]'
resp
=
$(
curl
-ksd
"{
$req
}"
"
${
para_ip
}
"
)
echo
"
$resp
"
id
=
$(
jq
-r
".result.stageInfo[0].id"
<<<
"
$resp
"
)
echo
"vote id"
KS_PRI
=
"0x6da92a632ab7deb67d38c0f6560bcfed28167998f6496db64c258d5e8393a81b"
JR_PRI
=
"0x19c069234f9d3e61135fefbeb7791b149cdf6af536f26bebb310d4cd22c3fee4"
NL_PRI
=
"0x7a80a1f75d7360c6123c32a78ecf978c1ac55636f87892df38d8b85a9aeff115"
req
=
'"method":"Chain33.CreateTransaction","params":[{"execer" : "user.p.para.paracross","actionName" : "selfConsStageConfig","payload":{"title":"user.p.para.","op":"2","vote":{"id":"'
"
$id
"
'","value":1} }}]'
resp
=
$(
curl
-ksd
"{
$req
}"
"
${
para_ip
}
"
)
rawtx
=
$(
jq
-r
".result"
<<<
"
$resp
"
)
chain33_SignRawTx
"
$rawtx
"
"
$KS_PRI
"
"
${
para_ip
}
"
chain33_SignRawTx
"
$rawtx
"
"
$JR_PRI
"
"
${
para_ip
}
"
chain33_SignRawTx
"
$rawtx
"
"
$NL_PRI
"
"
${
para_ip
}
"
echo
"query status"
req
=
'"method":"paracross.ListSelfStages","params":[{"status":3,"count":1}]'
resp
=
$(
curl
-ksd
"{
$req
}"
"
${
para_ip
}
"
)
echo
"
$resp
"
ok1
=
$(
jq
'(.error|not) and (.result| [has("id"),true])'
<<<
"
$resp
"
)
req
=
'"method":"paracross.GetSelfConsStages","params":[]'
resp
=
$(
curl
-ksd
"{
$req
}"
"
${
para_ip
}
"
)
echo
"
$resp
"
ok2
=
$(
jq
'(.error|not) and (.result| [has("startHeight"),true])'
<<<
"
$resp
"
)
req
=
'"method":"paracross.GetSelfConsOneStage","params":[{"data":1000}]'
resp
=
$(
curl
-ksd
"{
$req
}"
"
${
para_ip
}
"
)
echo
"
$resp
"
ok3
=
$(
jq
'(.error|not) and (.result.enable==1)'
<<<
"
$resp
"
)
req
=
'"method":"paracross.GetSelfConsOneStage","params":[{"data":'
"
$newHeight
"
'}]'
resp
=
$(
curl
-ksd
"{
$req
}"
"
${
para_ip
}
"
)
echo
"
$resp
"
ok4
=
$(
jq
'(.error|not) and (.result.enable==2)'
<<<
"
$resp
"
)
echo
"1=
$ok1
,2=
$ok2
,3=
$ok3
,4=
$ok4
"
[
"
$ok1
"
==
true
]
&&
[
"
$ok2
"
==
true
]
&&
[
"
$ok3
"
==
true
]
&&
[
"
$ok4
"
==
true
]
local
rst
=
$?
echo_rst
"
$FUNCNAME
"
"
$rst
"
}
function
run_testcases
()
{
paracross_GetBlock2MainInfo
paracross_IsSync
...
...
@@ -383,6 +446,7 @@ function run_testcases() {
paracross_ListNodeStatus
paracross_Transfer_Withdraw
paracross_testTxGroup
"
$UNIT_HTTP
"
paracross_testSelfConsensStages
"
$UNIT_HTTP
"
}
function
main
()
{
...
...
plugin/dapp/paracross/commands/paracross.go
View file @
586a3ff1
...
...
@@ -498,13 +498,15 @@ func addSelfConsStageCmdFlags(cmd *cobra.Command) {
func
selfConsStage
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
height
,
_
:=
cmd
.
Flags
()
.
GetInt64
(
"height"
)
enable
,
_
:=
cmd
.
Flags
()
.
GetUint32
(
"enable"
)
paraName
,
_
:=
cmd
.
Flags
()
.
GetString
(
"paraName"
)
var
config
pt
.
ParaStageConfig
config
.
OpTy
=
pt
.
ParaOpNewApply
config
.
Op
=
&
pt
.
ParaStageConfig_Stage
{
Stage
:
&
pt
.
SelfConsensStage
{
BlockHeight
:
height
,
Enable
:
enable
}}
config
.
Title
=
paraName
config
.
Op
=
pt
.
ParaOpNewApply
config
.
Value
=
&
pt
.
ParaStageConfig_Stage
{
Stage
:
&
pt
.
SelfConsensStage
{
StartHeight
:
height
,
Enable
:
enable
}}
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
pt
.
ParaX
,
Execer
:
getRealExecName
(
paraName
,
pt
.
ParaX
)
,
ActionName
:
"selfConsStageConfig"
,
Payload
:
types
.
MustPBToJSON
(
&
config
),
}
...
...
@@ -535,13 +537,15 @@ func addVoteFlags(cmd *cobra.Command) {
func
createVoteTx
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
id
,
_
:=
cmd
.
Flags
()
.
GetString
(
"id"
)
val
,
_
:=
cmd
.
Flags
()
.
GetUint32
(
"value"
)
paraName
,
_
:=
cmd
.
Flags
()
.
GetString
(
"paraName"
)
var
config
pt
.
ParaStageConfig
config
.
OpTy
=
pt
.
ParaOpVote
config
.
Op
=
&
pt
.
ParaStageConfig_Vote
{
Vote
:
&
pt
.
ConfigVoteInfo
{
Id
:
id
,
Value
:
val
}}
config
.
Title
=
paraName
config
.
Op
=
pt
.
ParaOpVote
config
.
Value
=
&
pt
.
ParaStageConfig_Vote
{
Vote
:
&
pt
.
ConfigVoteInfo
{
Id
:
id
,
Value
:
val
}}
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
pt
.
ParaX
,
Execer
:
getRealExecName
(
paraName
,
pt
.
ParaX
)
,
ActionName
:
"selfConsStageConfig"
,
Payload
:
types
.
MustPBToJSON
(
&
config
),
}
...
...
@@ -564,13 +568,15 @@ func configVoteCmd() *cobra.Command {
func
stageCancelTx
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
id
,
_
:=
cmd
.
Flags
()
.
GetString
(
"id"
)
paraName
,
_
:=
cmd
.
Flags
()
.
GetString
(
"paraName"
)
var
config
pt
.
ParaStageConfig
config
.
OpTy
=
pt
.
ParaOpCancel
config
.
Op
=
&
pt
.
ParaStageConfig_Cancel
{
Cancel
:
&
pt
.
ConfigCancelInfo
{
Id
:
id
}}
config
.
Title
=
paraName
config
.
Op
=
pt
.
ParaOpCancel
config
.
Value
=
&
pt
.
ParaStageConfig_Cancel
{
Cancel
:
&
pt
.
ConfigCancelInfo
{
Id
:
id
}}
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
pt
.
ParaX
,
Execer
:
getRealExecName
(
paraName
,
pt
.
ParaX
)
,
ActionName
:
"selfConsStageConfig"
,
Payload
:
types
.
MustPBToJSON
(
&
config
),
}
...
...
plugin/dapp/paracross/executor/action.go
View file @
586a3ff1
...
...
@@ -732,7 +732,7 @@ func (a *action) isAllowParaConsensJump(commit *pt.ParacrossCommitAction, titleS
if
stage
==
nil
{
return
false
,
nil
}
return
stage
.
Block
Height
==
commit
.
Status
.
Height
,
nil
return
stage
.
Start
Height
==
commit
.
Status
.
Height
,
nil
}
//兼容分叉之前从1跳跃场景
...
...
plugin/dapp/paracross/executor/paracross_test.go
View file @
586a3ff1
...
...
@@ -127,7 +127,7 @@ func (suite *CommitTestSuite) SetupSuite() {
assert
.
Equal
(
suite
.
T
(),
value
,
types
.
Encode
(
nodeValue
))
stageKey
:=
calcParaSelfConsStagesKey
()
stage
:=
&
pt
.
SelfConsensStage
{
Block
Height
:
0
,
Enable
:
pt
.
ParaConfigYes
}
stage
:=
&
pt
.
SelfConsensStage
{
Start
Height
:
0
,
Enable
:
pt
.
ParaConfigYes
}
stages
:=
&
pt
.
SelfConsensStages
{
Items
:
[]
*
pt
.
SelfConsensStage
{
stage
}}
suite
.
stateDB
.
Set
(
stageKey
,
types
.
Encode
(
stages
))
value
,
err
=
suite
.
stateDB
.
Get
(
stageKey
)
...
...
@@ -486,7 +486,7 @@ func (s *VoteTestSuite) SetupSuite() {
s
.
exec
.
SetEnv
(
0
,
0
,
0
)
stageKey
:=
calcParaSelfConsStagesKey
()
stage
:=
&
pt
.
SelfConsensStage
{
Block
Height
:
0
,
Enable
:
pt
.
ParaConfigYes
}
stage
:=
&
pt
.
SelfConsensStage
{
Start
Height
:
0
,
Enable
:
pt
.
ParaConfigYes
}
stages
:=
&
pt
.
SelfConsensStages
{
Items
:
[]
*
pt
.
SelfConsensStage
{
stage
}}
s
.
stateDB
.
Set
(
stageKey
,
types
.
Encode
(
stages
))
value
,
err
:=
s
.
stateDB
.
Get
(
stageKey
)
...
...
plugin/dapp/paracross/executor/stage.go
View file @
586a3ff1
...
...
@@ -104,14 +104,14 @@ func getSelfConsensStages(db dbm.KV) (*pt.SelfConsensStages, error) {
func
getSelfConsStagesMap
(
stages
[]
*
pt
.
SelfConsensStage
)
map
[
int64
]
uint32
{
stagesMap
:=
make
(
map
[
int64
]
uint32
)
for
_
,
v
:=
range
stages
{
stagesMap
[
v
.
Block
Height
]
=
v
.
Enable
stagesMap
[
v
.
Start
Height
]
=
v
.
Enable
}
return
stagesMap
}
func
sortStages
(
stages
*
pt
.
SelfConsensStages
,
new
*
pt
.
SelfConsensStage
)
{
stages
.
Items
=
append
(
stages
.
Items
,
new
)
sort
.
Slice
(
stages
.
Items
,
func
(
i
,
j
int
)
bool
{
return
stages
.
Items
[
i
]
.
BlockHeight
<
stages
.
Items
[
j
]
.
Block
Height
})
sort
.
Slice
(
stages
.
Items
,
func
(
i
,
j
int
)
bool
{
return
stages
.
Items
[
i
]
.
StartHeight
<
stages
.
Items
[
j
]
.
Start
Height
})
}
func
updateStages
(
db
dbm
.
KV
,
stage
*
pt
.
SelfConsensStage
)
(
*
types
.
Receipt
,
error
)
{
...
...
@@ -138,7 +138,7 @@ func updateStages(db dbm.KV, stage *pt.SelfConsensStage) (*types.Receipt, error)
func
selfConsensInitStage
(
cfg
*
types
.
Chain33Config
)
*
types
.
Receipt
{
close
:=
cfg
.
IsEnable
(
pt
.
ParaConsSubConf
+
"."
+
pt
.
ParaSelfConsInitConf
)
stage
:=
&
pt
.
SelfConsensStage
{
Block
Height
:
0
,
Enable
:
pt
.
ParaConfigYes
}
stage
:=
&
pt
.
SelfConsensStage
{
Start
Height
:
0
,
Enable
:
pt
.
ParaConfigYes
}
if
close
{
stage
.
Enable
=
pt
.
ParaConfigNo
}
...
...
@@ -153,7 +153,7 @@ func getSelfConsOneStage(db dbm.KV, height int64) (*pt.SelfConsensStage, error)
}
for
i
:=
len
(
stages
.
Items
)
-
1
;
i
>=
0
;
i
--
{
if
height
>=
stages
.
Items
[
i
]
.
Block
Height
{
if
height
>=
stages
.
Items
[
i
]
.
Start
Height
{
return
stages
.
Items
[
i
],
nil
}
}
...
...
@@ -172,13 +172,13 @@ func isSelfConsOn(db dbm.KV, height int64) (bool, error) {
func
(
a
*
action
)
checkValidStage
(
config
*
pt
.
SelfConsensStage
)
error
{
cfg
:=
a
.
api
.
GetConfig
()
//0. 设置高度必须大于fork高度
if
!
cfg
.
IsDappFork
(
config
.
Block
Height
,
pt
.
ParaX
,
pt
.
ForkParaSelfConsStages
)
{
return
errors
.
Wrapf
(
types
.
ErrNotAllow
,
"checkValidStage config height:%d less than fork height"
,
config
.
Block
Height
)
if
!
cfg
.
IsDappFork
(
config
.
Start
Height
,
pt
.
ParaX
,
pt
.
ForkParaSelfConsStages
)
{
return
errors
.
Wrapf
(
types
.
ErrNotAllow
,
"checkValidStage config height:%d less than fork height"
,
config
.
Start
Height
)
}
//1. 设置高度必须大于当前区块高度
if
config
.
Block
Height
<=
a
.
height
{
return
errors
.
Wrapf
(
pt
.
ErrHeightHasPast
,
"checkValidStage config height:%d less than block height:%d"
,
config
.
Block
Height
,
a
.
height
)
if
config
.
Start
Height
<=
a
.
height
{
return
errors
.
Wrapf
(
pt
.
ErrHeightHasPast
,
"checkValidStage config height:%d less than block height:%d"
,
config
.
Start
Height
,
a
.
height
)
}
//2. 如果已经设置到stages中,简单起见,就不能更改了,应该也不会有很大影响
...
...
@@ -188,8 +188,8 @@ func (a *action) checkValidStage(config *pt.SelfConsensStage) error {
}
if
stages
!=
nil
{
stageMap
:=
getSelfConsStagesMap
(
stages
.
Items
)
if
_
,
exist
:=
stageMap
[
config
.
Block
Height
];
exist
{
return
errors
.
Wrapf
(
err
,
"checkValidStage config height:%d existed"
,
config
.
Block
Height
)
if
_
,
exist
:=
stageMap
[
config
.
Start
Height
];
exist
{
return
errors
.
Wrapf
(
err
,
"checkValidStage config height:%d existed"
,
config
.
Start
Height
)
}
}
...
...
@@ -314,13 +314,13 @@ func (a *action) stageVote(config *pt.ConfigVoteInfo) (*types.Receipt, error) {
//SelfConsensStageConfig support self consens stage config
func
(
a
*
action
)
SelfStageConfig
(
config
*
pt
.
ParaStageConfig
)
(
*
types
.
Receipt
,
error
)
{
if
config
.
Op
Ty
==
pt
.
ParaOpNewApply
{
if
config
.
Op
==
pt
.
ParaOpNewApply
{
return
a
.
stageApply
(
config
.
GetStage
())
}
else
if
config
.
Op
Ty
==
pt
.
ParaOpCancel
{
}
else
if
config
.
Op
==
pt
.
ParaOpCancel
{
return
a
.
stageCancel
(
config
.
GetCancel
())
}
else
if
config
.
Op
Ty
==
pt
.
ParaOpVote
{
}
else
if
config
.
Op
==
pt
.
ParaOpVote
{
return
a
.
stageVote
(
config
.
GetVote
())
}
...
...
plugin/dapp/paracross/executor/stage_test.go
View file @
586a3ff1
...
...
@@ -13,16 +13,16 @@ import (
func
TestSortStages
(
t
*
testing
.
T
)
{
stages
:=
&
pt
.
SelfConsensStages
{}
n1
:=
&
pt
.
SelfConsensStage
{
Block
Height
:
200
,
Enable
:
pt
.
ParaConfigYes
}
n1
:=
&
pt
.
SelfConsensStage
{
Start
Height
:
200
,
Enable
:
pt
.
ParaConfigYes
}
e1
:=
&
pt
.
SelfConsensStages
{
Items
:
[]
*
pt
.
SelfConsensStage
{
n1
}}
n2
:=
&
pt
.
SelfConsensStage
{
Block
Height
:
100
,
Enable
:
pt
.
ParaConfigNo
}
n2
:=
&
pt
.
SelfConsensStage
{
Start
Height
:
100
,
Enable
:
pt
.
ParaConfigNo
}
e2
:=
&
pt
.
SelfConsensStages
{
Items
:
[]
*
pt
.
SelfConsensStage
{
n2
,
n1
}}
n3
:=
&
pt
.
SelfConsensStage
{
Block
Height
:
700
,
Enable
:
pt
.
ParaConfigYes
}
n3
:=
&
pt
.
SelfConsensStage
{
Start
Height
:
700
,
Enable
:
pt
.
ParaConfigYes
}
e3
:=
&
pt
.
SelfConsensStages
{
Items
:
[]
*
pt
.
SelfConsensStage
{
n2
,
n1
,
n3
}}
n4
:=
&
pt
.
SelfConsensStage
{
Block
Height
:
500
,
Enable
:
pt
.
ParaConfigNo
}
n4
:=
&
pt
.
SelfConsensStage
{
Start
Height
:
500
,
Enable
:
pt
.
ParaConfigNo
}
e4
:=
&
pt
.
SelfConsensStages
{
Items
:
[]
*
pt
.
SelfConsensStage
{
n2
,
n1
,
n4
,
n3
}}
sortStages
(
stages
,
n1
)
...
...
plugin/dapp/paracross/proto/paracross.proto
View file @
586a3ff1
...
...
@@ -196,7 +196,7 @@ message SelfConsensStages {
message
SelfConsensStage
{
int64
block
Height
=
1
;
int64
start
Height
=
1
;
uint32
enable
=
2
;
}
...
...
@@ -229,10 +229,10 @@ message ConfigCancelInfo {
//广义配置类型
message
ParaStageConfig
{
string
title
=
1
;
string
title
=
1
;
// 配置类型
uint32
op
Ty
=
2
;
oneof
op
{
uint32
op
=
2
;
oneof
value
{
SelfConsensStage
stage
=
10
;
ConfigVoteInfo
vote
=
11
;
ConfigCancelInfo
cancel
=
12
;
...
...
plugin/dapp/paracross/types/type.go
View file @
586a3ff1
...
...
@@ -171,9 +171,6 @@ func (p ParacrossType) CreateTx(action string, message json.RawMessage) (*types.
}
return
CreateRawNodeGroupApplyTx
(
&
param
)
}
else
if
action
==
"selfConsStageConfig"
{
if
!
cfg
.
IsPara
()
{
return
nil
,
types
.
ErrNotSupport
}
var
param
ParaStageConfig
err
:=
types
.
JSONToPB
(
message
,
&
param
)
//err := json.Unmarshal(message, ¶m)
...
...
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