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
957a16f0
Commit
957a16f0
authored
Dec 05, 2019
by
mdj33
Committed by
vipwzw
Dec 17, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cmd improve
parent
55589cbe
Show whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
157 additions
and
59 deletions
+157
-59
para.go
plugin/consensus/para/para.go
+3
-4
para_test.go
plugin/consensus/para/para_test.go
+1
-1
paracommitmsg.go
plugin/consensus/para/paracommitmsg.go
+8
-7
paracreate.go
plugin/consensus/para/paracreate.go
+1
-1
parasync.go
plugin/consensus/para/parasync.go
+3
-3
parasync_test.go
plugin/consensus/para/parasync_test.go
+1
-1
testcase.sh
plugin/dapp/paracross/cmd/build/testcase.sh
+4
-4
Makefile
plugin/dapp/paracross/cmd/scripts/autodeploy/Makefile
+2
-0
autodeploy.md
plugin/dapp/paracross/cmd/scripts/autodeploy/autodeploy.md
+19
-0
config
plugin/dapp/paracross/cmd/scripts/autodeploy/config
+15
-21
docker-compose.sh
...n/dapp/paracross/cmd/scripts/autodeploy/docker-compose.sh
+12
-0
paracross.go
plugin/dapp/paracross/commands/paracross.go
+70
-17
exec_local.go
plugin/dapp/paracross/executor/exec_local.go
+1
-0
query.go
plugin/dapp/paracross/executor/query.go
+1
-0
paracross.proto
plugin/dapp/paracross/proto/paracross.proto
+3
-0
rpc.go
plugin/dapp/paracross/rpc/rpc.go
+13
-0
No files found.
plugin/consensus/para/para.go
View file @
957a16f0
...
...
@@ -58,8 +58,7 @@ type client struct {
commitMsgClient
*
commitMsgClient
blockSyncClient
*
blockSyncClient
multiDldCli
*
multiDldClient
authAccount
string
privateKey
crypto
.
PrivKey
minerPrivateKey
crypto
.
PrivKey
wg
sync
.
WaitGroup
subCfg
*
subConfig
isClosed
int32
...
...
@@ -139,14 +138,14 @@ func New(cfg *types.Consensus, sub []byte) queue.Module {
para
:=
&
client
{
BaseClient
:
c
,
authAccount
:
subcfg
.
AuthAccount
,
privateKey
:
priKey
,
minerPrivateKey
:
priKey
,
subCfg
:
&
subcfg
,
quitCreate
:
make
(
chan
struct
{}),
}
para
.
commitMsgClient
=
&
commitMsgClient
{
paraClient
:
para
,
authAccount
:
subcfg
.
AuthAccount
,
waitMainBlocks
:
waitBlocks4CommitMsg
,
waitConsensStopTimes
:
waitConsensStopTimes
,
consensHeight
:
-
2
,
...
...
plugin/consensus/para/para_test.go
View file @
957a16f0
...
...
@@ -175,7 +175,7 @@ func TestAddMinerTx(t *testing.T) {
para
:=
&
client
{
BaseClient
:
&
drivers
.
BaseClient
{}}
para
.
SetAPI
(
api
)
para
.
subCfg
=
new
(
subConfig
)
para
.
p
rivateKey
=
priKey
para
.
minerP
rivateKey
=
priKey
para
.
commitMsgClient
=
new
(
commitMsgClient
)
para
.
commitMsgClient
.
paraClient
=
para
...
...
plugin/consensus/para/paracommitmsg.go
View file @
957a16f0
...
...
@@ -53,6 +53,7 @@ type commitMsgClient struct {
consensHeight
int64
consensDoneHeight
int64
selfConsensError
int32
//自共识比主链共识更高的异常场景,需要等待自共识<=主链共识再发送
authAccount
string
authAccountIn
bool
isRollBack
int32
checkTxCommitTimes
int32
...
...
@@ -76,7 +77,7 @@ func (client *commitMsgClient) handler() {
client
.
paraClient
.
wg
.
Add
(
1
)
go
client
.
getMainConsensusInfo
()
if
client
.
paraClient
.
authAccount
!=
""
{
if
client
.
authAccount
!=
""
{
client
.
paraClient
.
wg
.
Add
(
1
)
client
.
sendMsgCh
=
make
(
chan
*
types
.
Transaction
,
1
)
go
client
.
sendCommitMsg
()
...
...
@@ -275,7 +276,7 @@ func (client *commitMsgClient) checkAuthAccountIn() {
if
err
!=
nil
{
return
}
authExist
:=
strings
.
Contains
(
nodes
,
client
.
paraClient
.
authAccount
)
authExist
:=
strings
.
Contains
(
nodes
,
client
.
authAccount
)
//如果授权节点重新加入,需要从当前共识高度重新发送
if
!
client
.
authAccountIn
&&
authExist
{
...
...
@@ -361,7 +362,7 @@ func (client *commitMsgClient) getSendingTx(startHeight, endHeight int64) (*type
for
i
,
msg
:=
range
sendingMsgs
{
plog
.
Debug
(
"paracommitmsg sending"
,
"idx"
,
i
,
"height"
,
msg
.
Height
,
"mainheight"
,
msg
.
MainBlockHeight
,
"blockhash"
,
common
.
HashHex
(
msg
.
BlockHash
),
"mainHash"
,
common
.
HashHex
(
msg
.
MainBlockHash
),
"from"
,
client
.
paraClient
.
authAccount
)
"from"
,
client
.
authAccount
)
}
return
signTx
,
count
...
...
@@ -678,7 +679,7 @@ out:
isSync
=
true
}
if
client
.
paraClient
.
authAccount
!=
""
{
if
client
.
authAccount
!=
""
{
client
.
GetProperFeeRate
()
}
...
...
@@ -836,7 +837,7 @@ func (client *commitMsgClient) getNodeGroupAddrs() (string, error) {
}
func
(
client
*
commitMsgClient
)
onWalletStatus
(
status
*
types
.
WalletStatus
)
{
if
status
==
nil
||
client
.
paraClient
.
authAccount
==
""
{
if
status
==
nil
||
client
.
authAccount
==
""
{
return
}
if
!
status
.
IsWalletLock
&&
client
.
privateKey
==
nil
{
...
...
@@ -858,7 +859,7 @@ func (client *commitMsgClient) onWalletStatus(status *types.WalletStatus) {
}
func
(
client
*
commitMsgClient
)
onWalletAccount
(
acc
*
types
.
Account
)
{
if
acc
==
nil
||
client
.
paraClient
.
authAccount
==
""
||
client
.
paraC
lient
.
authAccount
!=
acc
.
Addr
||
client
.
privateKey
!=
nil
{
if
acc
==
nil
||
client
.
authAccount
==
""
||
c
lient
.
authAccount
!=
acc
.
Addr
||
client
.
privateKey
!=
nil
{
return
}
err
:=
client
.
fetchPriKey
()
...
...
@@ -872,7 +873,7 @@ func (client *commitMsgClient) onWalletAccount(acc *types.Account) {
}
func
(
client
*
commitMsgClient
)
fetchPriKey
()
error
{
req
:=
&
types
.
ReqString
{
Data
:
client
.
paraClient
.
authAccount
}
req
:=
&
types
.
ReqString
{
Data
:
client
.
authAccount
}
msg
:=
client
.
paraClient
.
GetQueueClient
()
.
NewMessage
(
"wallet"
,
types
.
EventDumpPrivkey
,
req
)
err
:=
client
.
paraClient
.
GetQueueClient
()
.
Send
(
msg
,
true
)
...
...
plugin/consensus/para/paracreate.go
View file @
957a16f0
...
...
@@ -561,7 +561,7 @@ out:
count
=
int64
(
len
(
paraTxs
.
Items
))
}
//如果超过1个block,则认为当前正在追赶,暂不处理
if
client
.
authAccount
!=
""
&&
len
(
paraTxs
.
Items
)
==
1
{
if
client
.
commitMsgClient
.
authAccount
!=
""
&&
len
(
paraTxs
.
Items
)
==
1
{
client
.
commitMsgClient
.
commitTxCheckNotify
(
paraTxs
.
Items
[
0
]
.
TxDetails
)
}
...
...
plugin/consensus/para/parasync.go
View file @
957a16f0
...
...
@@ -231,7 +231,7 @@ func (client *blockSyncClient) syncBlocksIfNeed() (bool, error) {
if
err
==
nil
{
isSyncCaughtUp
:=
lastBlock
.
Height
+
1
==
lastLocalHeight
client
.
setSyncCaughtUp
(
isSyncCaughtUp
)
if
client
.
paraClient
.
authAccount
!=
""
{
if
client
.
paraClient
.
commitMsgClient
.
authAccount
!=
""
{
client
.
printDebugInfo
(
"Para sync - add block commit"
,
"isSyncCaughtUp"
,
isSyncCaughtUp
)
client
.
paraClient
.
commitMsgClient
.
updateChainHeightNotify
(
lastBlock
.
Height
+
1
,
false
)
}
...
...
@@ -250,7 +250,7 @@ func (client *blockSyncClient) syncBlocksIfNeed() (bool, error) {
//通知发送层
if
err
==
nil
{
client
.
setSyncCaughtUp
(
false
)
if
client
.
paraClient
.
authAccount
!=
""
{
if
client
.
paraClient
.
commitMsgClient
.
authAccount
!=
""
{
client
.
printDebugInfo
(
"Para sync - rollback block commit"
,
"isSyncCaughtUp"
,
false
)
client
.
paraClient
.
commitMsgClient
.
updateChainHeightNotify
(
lastBlock
.
Height
-
1
,
true
)
}
...
...
@@ -384,7 +384,7 @@ func (client *blockSyncClient) addMinerTx(preStateHash []byte, block *types.Bloc
return
err
}
tx
.
Sign
(
types
.
SECP256K1
,
client
.
paraClient
.
p
rivateKey
)
tx
.
Sign
(
types
.
SECP256K1
,
client
.
paraClient
.
minerP
rivateKey
)
block
.
Txs
=
append
([]
*
types
.
Transaction
{
tx
},
block
.
Txs
...
)
return
nil
...
...
plugin/consensus/para/parasync_test.go
View file @
957a16f0
...
...
@@ -66,7 +66,7 @@ func createParaTestInstance(t *testing.T, q queue.Queue) *client {
assert
.
Nil
(
t
,
err
)
priKey
,
err
:=
secp
.
PrivKeyFromBytes
(
pk
)
assert
.
Nil
(
t
,
err
)
para
.
p
rivateKey
=
priKey
para
.
minerP
rivateKey
=
priKey
//实例化BlockSyncClient
para
.
blockSyncClient
=
&
blockSyncClient
{
...
...
plugin/dapp/paracross/cmd/build/testcase.sh
View file @
957a16f0
...
...
@@ -336,11 +336,11 @@ function para_cross_transfer_withdraw() {
echo
"
${
hash
}
"
query_tx
"
${
CLI
}
"
"
${
hash
}
"
hash
=
$(${
CLI
}
send para asset_transfer
--p
titl
e
user.p.para.
-a
1.4
-n
test
-t
12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
-k
4257D8692EF7FE13C68B65D6A52F03933DB2FA5CE8FAF210B5B8B80C721CED01
)
hash
=
$(${
CLI
}
send para asset_transfer
--p
araNam
e
user.p.para.
-a
1.4
-n
test
-t
12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
-k
4257D8692EF7FE13C68B65D6A52F03933DB2FA5CE8FAF210B5B8B80C721CED01
)
echo
"
${
hash
}
"
query_tx
"
${
PARA_CLI
}
"
"
${
hash
}
"
hash2
=
$(${
CLI
}
send para asset_withdraw
--p
titl
e
user.p.para.
-a
0.7
-n
test
-t
12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
-k
4257D8692EF7FE13C68B65D6A52F03933DB2FA5CE8FAF210B5B8B80C721CED01
)
hash2
=
$(${
CLI
}
send para asset_withdraw
--p
araNam
e
user.p.para.
-a
0.7
-n
test
-t
12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
-k
4257D8692EF7FE13C68B65D6A52F03933DB2FA5CE8FAF210B5B8B80C721CED01
)
local times
=
200
while
true
;
do
...
...
@@ -426,12 +426,12 @@ function para_cross_transfer_withdraw_for_token() {
query_tx
"
${
MAIN_CLI
}
"
"
${
hash
}
"
echo
"=========== # 2.transfer asset to para chain ============="
hash
=
$(${
CLI
}
send para asset_transfer
--p
titl
e
user.p.para.
-s
FZM
-a
220
-n
test
-t
12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
-k
12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
)
hash
=
$(${
CLI
}
send para asset_transfer
--p
araNam
e
user.p.para.
-s
FZM
-a
220
-n
test
-t
12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
-k
12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
)
echo
"
${
hash
}
"
query_tx
"
${
MAIN_CLI
}
"
"
${
hash
}
"
echo
"=========== # 3.asset_withdraw from parachain ============="
${
CLI
}
send para asset_withdraw
--p
titl
e
user.p.para.
-a
111
-s
FZM
-n
test
-t
12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
-k
12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
${
CLI
}
send para asset_withdraw
--p
araNam
e
user.p.para.
-a
111
-s
FZM
-n
test
-t
12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
-k
12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
local times
=
100
while
true
;
do
...
...
plugin/dapp/paracross/cmd/scripts/autodeploy/Makefile
View file @
957a16f0
...
...
@@ -14,3 +14,4 @@ help: ## Display this help screen
@
printf
"[command]
\n
"
@
printf
"[nodegroup]: create super node group if not create
\n
"
@
printf
"[wallet]: set node wallet private key if not set
\n
"
@
printf
"[miner]: unlock wallet to miner
\n
"
\ No newline at end of file
plugin/dapp/paracross/cmd/scripts/autodeploy/autodeploy.md
0 → 100644
View file @
957a16f0
# 平行链授权节点一键式部署
## 需求
平行链申请超级节点步骤比较多,需要设置的地方也比较多,容易遗漏
## 使用
1.
把编译好的chain33,chain33-cli,chain33.toml,和chain33.para.toml和本脚本目录放到一起
1.
修改config文件配置项,每个配置项都有说明
1.
make docker-compose 缺省启动
1.
make docker-compose op=nodegroup 配置超级账户组
1.
make docker-compose op=wallet 配置钱包开启共识
1.
系统缺省会把区块链数据从docker重映射到本地storage目录,以后默认启动历史数据不会丢失
1.
make docker-compose down 停止当前平行链
## 系统重启
1.
系统重启使用 make docker-compose即可, 起来后 make docker-compose op=miner开启挖矿
\ No newline at end of file
plugin/dapp/paracross/cmd/scripts/autodeploy/config
View file @
957a16f0
paraName="test"
#genesisAccount=""
#genesisAmount=100000000
#mainStartHeight=4800000
#authAccount=()
#authPrikey=()
##docker8901端口暴露到宿主机的端口
#authPort=("18901" "18902" "18903" "18904")
#
##需要和chain33 主链保持一致
#superManager="['1JmFaA6unrCFYEWPGRi7uuXY1KthTJxJEP']"
#
##nodegroup create
##申请超级账户需要在主链冻结币数量
#authFrozenCoins=0
#nodeGroupApplier=""
#applierPrikey=""
#superManagerPrikey=""
#平行链名字,这里不需要加user.p.前缀
paraName="test"
#### 测试链配置,主链配置需要把如下测试链配置屏蔽 ##########
#### 测试链配置四个节点例子,主链配置需要把如下测试链配置屏蔽 ##########
#创世账户
genesisAccount="14KEKbYtKKQm4wMthSK9J4La4nAiidGozt"
#创世数量
genesisAmount=100000000
#从主链哪个高度开始同步区块
mainStartHeight=4000000
#平行链授权账户,这里的数量要和下面的authPrikey和authPort保持一致
authAccount=( "1KSBd17H7ZK8iT37aJztFB22XGwsPTdwE4" "1JRNjdEqp4LJ5fqycUBm9ayCKSeeskgMKR" "1NLHPEcbTWWxxU3dGUZBhayjrCHD3psX7k" "1MCftFynyvG2F4ED5mdHYgziDxx6vDrScs")
#授权账户的私钥,为了导入钱包,自动开启共识挖矿
authPrikey=("0x6da92a632ab7deb67d38c0f6560bcfed28167998f6496db64c258d5e8393a81b" "0x19c069234f9d3e61135fefbeb7791b149cdf6af536f26bebb310d4cd22c3fee4" "0x7a80a1f75d7360c6123c32a78ecf978c1ac55636f87892df38d8b85a9aeff115" "0xcacb1f5d51700aea07fca2246ab43b0917d70405c65edea9b5063d72eb5c6b71")
#授权节点的宿主机端口
authPort=("18901" "18902" "18903" "18904")
#需要和chain33 主链保持一致
...
...
@@ -32,8 +22,12 @@ superManager="['12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv']"
tokenApprs="['12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv']"
#nodegroup create
#超级账户创建
#授权账户申请需要在主链上冻结的BTY数量,申请之前需要chain33项目方沟通,需要chain33超级管理员审批通过
authFrozenCoins=0
#超级账户组申请者,需要事先在paracross合约转移必须的BTY,数量=申请的授权账户数量*authFrozenCoins
nodeGroupApplier="1KSBd17H7ZK8iT37aJztFB22XGwsPTdwE4"
#超级账户组申请者私钥 签名交易使用
applierPrikey="0x6da92a632ab7deb67d38c0f6560bcfed28167998f6496db64c258d5e8393a81b"
#超级管理员私钥,在主链上申请不需要填
superManagerPrikey="4257D8692EF7FE13C68B65D6A52F03933DB2FA5CE8FAF210B5B8B80C721CED01"
plugin/dapp/paracross/cmd/scripts/autodeploy/docker-compose.sh
View file @
957a16f0
...
...
@@ -87,6 +87,13 @@ function para_import_wallet() {
./
$CHAIN33_CLI
--rpc_laddr
"http://localhost:
$port
"
wallet status
}
function
para_unlock_wallet
()
{
for
((
i
=
0
;
i <
${#
authPort
[@]
}
;
i++
))
;
do
echo
"=========== # para unlock wallet
${
authPort
[
$i
]
}
============="
./
$CHAIN33_CLI
--rpc_laddr
"http://localhost:
${
authPort
[
$i
]
}
"
wallet unlock
-p
1314fuzamei
-t
0
done
}
function
start
()
{
echo
"=========== # docker-compose ps ============="
docker-compose ps
...
...
@@ -175,6 +182,7 @@ EOF
volumes:
- "../storage/parachain
$i
/paradatadir:/root/paradatadir"
- "../storage/parachain
$i
/logs:/root/logs"
- "../storage/parachain
$i
/parawallet:/root/parawallet"
EOF
done
...
...
@@ -260,6 +268,10 @@ function main() {
para_set_wallet
fi
if
[
"
$1
"
==
"miner"
]
;
then
para_unlock_wallet
fi
echo
"===============================parachain startup end========================================================="
}
...
...
plugin/dapp/paracross/commands/paracross.go
View file @
957a16f0
...
...
@@ -42,6 +42,7 @@ func ParcCmd() *cobra.Command {
GetHeightCmd
(),
GetBlockInfoCmd
(),
GetLocalBlockInfoCmd
(),
GetConsensDoneInfoCmd
(),
)
return
cmd
}
...
...
@@ -66,9 +67,6 @@ func addCreateAssetTransferFlags(cmd *cobra.Command) {
cmd
.
Flags
()
.
StringP
(
"note"
,
"n"
,
""
,
"transaction note info"
)
cmd
.
Flags
()
.
StringP
(
"ptitle"
,
""
,
""
,
"the title of para chain, like `user.p.guodun.`"
)
cmd
.
MarkFlagRequired
(
"ptitle"
)
cmd
.
Flags
()
.
StringP
(
"symbol"
,
"s"
,
""
,
"default for bty, symbol for token"
)
}
...
...
@@ -98,9 +96,6 @@ func addCreateAssetWithdrawFlags(cmd *cobra.Command) {
cmd
.
Flags
()
.
StringP
(
"note"
,
"n"
,
""
,
"transaction note info"
)
cmd
.
Flags
()
.
StringP
(
"ptitle"
,
""
,
""
,
"the title of para chain, like `user.p.guodun.`"
)
cmd
.
MarkFlagRequired
(
"ptitle"
)
cmd
.
Flags
()
.
StringP
(
"to"
,
"t"
,
""
,
"receiver account address"
)
cmd
.
MarkFlagRequired
(
"to"
)
...
...
@@ -117,7 +112,7 @@ func createAssetWithdraw(cmd *cobra.Command, args []string) {
}
func
createAssetTx
(
cmd
*
cobra
.
Command
,
isWithdraw
bool
)
(
string
,
error
)
{
title
,
_
:=
cmd
.
Flags
()
.
GetString
(
"
titl
e"
)
title
,
_
:=
cmd
.
Flags
()
.
GetString
(
"
paraNam
e"
)
cfg
:=
types
.
GetCliSysParam
(
title
)
amount
,
_
:=
cmd
.
Flags
()
.
GetFloat64
(
"amount"
)
...
...
@@ -130,12 +125,11 @@ func createAssetTx(cmd *cobra.Command, isWithdraw bool) (string, error) {
note
,
_
:=
cmd
.
Flags
()
.
GetString
(
"note"
)
symbol
,
_
:=
cmd
.
Flags
()
.
GetString
(
"symbol"
)
ptitle
,
_
:=
cmd
.
Flags
()
.
GetString
(
"ptitle"
)
if
!
strings
.
HasPrefix
(
ptitle
,
"user.p"
)
{
fmt
.
Fprintln
(
os
.
Stderr
,
"ptitle is not right, title format like `user.p.guodun.`"
)
if
!
strings
.
HasPrefix
(
title
,
"user.p"
)
{
fmt
.
Fprintln
(
os
.
Stderr
,
"title is not right, title format like `user.p.guodun.`"
)
return
""
,
types
.
ErrInvalidParam
}
execName
:=
p
title
+
pt
.
ParaX
execName
:=
title
+
pt
.
ParaX
param
:=
types
.
CreateTx
{
To
:
toAddr
,
...
...
@@ -269,7 +263,10 @@ func createNodeJoinTx(cmd *cobra.Command, args []string) {
opAddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"addr"
)
coins
,
_
:=
cmd
.
Flags
()
.
GetFloat64
(
"coins"
)
paraName
,
_
:=
cmd
.
Flags
()
.
GetString
(
"paraName"
)
if
!
strings
.
HasPrefix
(
paraName
,
"user.p"
)
{
fmt
.
Fprintln
(
os
.
Stderr
,
"paraName is not right, paraName format like `user.p.guodun.`"
)
return
}
payload
:=
&
pt
.
ParaNodeAddrConfig
{
Title
:
paraName
,
Op
:
1
,
Addr
:
opAddr
,
CoinsFrozen
:
int64
(
math
.
Trunc
((
coins
+
0.0000001
)
*
1e4
))
*
1e4
}
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
getRealExecName
(
paraName
,
pt
.
ParaX
),
...
...
@@ -304,7 +301,10 @@ func createNodeVoteTx(cmd *cobra.Command, args []string) {
paraName
,
_
:=
cmd
.
Flags
()
.
GetString
(
"paraName"
)
id
,
_
:=
cmd
.
Flags
()
.
GetString
(
"id"
)
val
,
_
:=
cmd
.
Flags
()
.
GetUint32
(
"value"
)
if
!
strings
.
HasPrefix
(
paraName
,
"user.p"
)
{
fmt
.
Fprintln
(
os
.
Stderr
,
"paraName is not right, paraName format like `user.p.guodun.`"
)
return
}
payload
:=
&
pt
.
ParaNodeAddrConfig
{
Title
:
paraName
,
Op
:
2
,
Id
:
id
,
Value
:
val
}
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
getRealExecName
(
paraName
,
pt
.
ParaX
),
...
...
@@ -337,7 +337,10 @@ func addNodeQuitFlags(cmd *cobra.Command) {
func
createNodeQuitTx
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
paraName
,
_
:=
cmd
.
Flags
()
.
GetString
(
"paraName"
)
opAddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"addr"
)
if
!
strings
.
HasPrefix
(
paraName
,
"user.p"
)
{
fmt
.
Fprintln
(
os
.
Stderr
,
"paraName is not right, paraName format like `user.p.guodun.`"
)
return
}
payload
:=
&
pt
.
ParaNodeAddrConfig
{
Title
:
paraName
,
Op
:
3
,
Addr
:
opAddr
}
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
getRealExecName
(
paraName
,
pt
.
ParaX
),
...
...
@@ -370,7 +373,10 @@ func addNodeCancelFlags(cmd *cobra.Command) {
func
createNodeCancelTx
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
paraName
,
_
:=
cmd
.
Flags
()
.
GetString
(
"paraName"
)
id
,
_
:=
cmd
.
Flags
()
.
GetString
(
"id"
)
if
!
strings
.
HasPrefix
(
paraName
,
"user.p"
)
{
fmt
.
Fprintln
(
os
.
Stderr
,
"paraName is not right, paraName format like `user.p.guodun.`"
)
return
}
payload
:=
&
pt
.
ParaNodeAddrConfig
{
Title
:
paraName
,
Op
:
4
,
Id
:
id
}
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
getRealExecName
(
paraName
,
pt
.
ParaX
),
...
...
@@ -655,6 +661,11 @@ func nodeGroupApply(cmd *cobra.Command, args []string) {
addrs
,
_
:=
cmd
.
Flags
()
.
GetString
(
"addrs"
)
coins
,
_
:=
cmd
.
Flags
()
.
GetFloat64
(
"coins"
)
if
!
strings
.
HasPrefix
(
paraName
,
"user.p"
)
{
fmt
.
Fprintln
(
os
.
Stderr
,
"paraName is not right, paraName format like `user.p.guodun.`"
)
return
}
payload
:=
&
pt
.
ParaNodeGroupConfig
{
Title
:
paraName
,
Op
:
1
,
Addrs
:
addrs
,
CoinsFrozen
:
int64
(
math
.
Trunc
((
coins
+
0.0000001
)
*
1e4
))
*
1e4
}
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
getRealExecName
(
paraName
,
pt
.
ParaX
),
...
...
@@ -691,6 +702,11 @@ func nodeGroupApprove(cmd *cobra.Command, args []string) {
id
,
_
:=
cmd
.
Flags
()
.
GetString
(
"id"
)
coins
,
_
:=
cmd
.
Flags
()
.
GetFloat64
(
"coins"
)
if
!
strings
.
HasPrefix
(
paraName
,
"user.p"
)
{
fmt
.
Fprintln
(
os
.
Stderr
,
"paraName is not right, paraName format like `user.p.guodun.`"
)
return
}
payload
:=
&
pt
.
ParaNodeGroupConfig
{
Title
:
paraName
,
Op
:
2
,
Id
:
id
,
CoinsFrozen
:
int64
(
math
.
Trunc
((
coins
+
0.0000001
)
*
1e4
))
*
1e4
}
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
getRealExecName
(
paraName
,
pt
.
ParaX
),
...
...
@@ -722,7 +738,10 @@ func addNodeGroupQuitCmdFlags(cmd *cobra.Command) {
func
nodeGroupQuit
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
paraName
,
_
:=
cmd
.
Flags
()
.
GetString
(
"paraName"
)
id
,
_
:=
cmd
.
Flags
()
.
GetString
(
"id"
)
if
!
strings
.
HasPrefix
(
paraName
,
"user.p"
)
{
fmt
.
Fprintln
(
os
.
Stderr
,
"paraName is not right, paraName format like `user.p.guodun.`"
)
return
}
payload
:=
&
pt
.
ParaNodeGroupConfig
{
Title
:
paraName
,
Op
:
3
,
Id
:
id
}
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
getRealExecName
(
paraName
,
pt
.
ParaX
),
...
...
@@ -754,7 +773,10 @@ func addNodeGroupModifyCmdFlags(cmd *cobra.Command) {
func
nodeGroupModify
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
paraName
,
_
:=
cmd
.
Flags
()
.
GetString
(
"paraName"
)
coins
,
_
:=
cmd
.
Flags
()
.
GetFloat64
(
"coins"
)
if
!
strings
.
HasPrefix
(
paraName
,
"user.p"
)
{
fmt
.
Fprintln
(
os
.
Stderr
,
"paraName is not right, paraName format like `user.p.guodun.`"
)
return
}
payload
:=
&
pt
.
ParaNodeGroupConfig
{
Title
:
paraName
,
Op
:
4
,
CoinsFrozen
:
int64
(
math
.
Trunc
((
coins
+
0.0000001
)
*
1e4
))
*
1e4
}
params
:=
&
rpctypes
.
CreateTxIn
{
Execer
:
getRealExecName
(
paraName
,
pt
.
ParaX
),
...
...
@@ -1110,3 +1132,34 @@ func showSelfStages(cmd *cobra.Command, args []string) {
ctx
:=
jsonclient
.
NewRPCCtx
(
rpcLaddr
,
"paracross.ListSelfStages"
,
params
,
&
res
)
ctx
.
Run
()
}
func
addConsensDoneCmdFlags
(
cmd
*
cobra
.
Command
)
{
cmd
.
Flags
()
.
Int64P
(
"height"
,
"g"
,
0
,
"height to para chain"
)
cmd
.
MarkFlagRequired
(
"height"
)
}
func
consensDoneInfo
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
paraName
,
_
:=
cmd
.
Flags
()
.
GetString
(
"paraName"
)
height
,
_
:=
cmd
.
Flags
()
.
GetInt64
(
"height"
)
params
:=
pt
.
ReqParacrossTitleHeight
{
Title
:
paraName
,
Height
:
height
,
}
var
res
pt
.
RespParacrossDone
ctx
:=
jsonclient
.
NewRPCCtx
(
rpcLaddr
,
"paracross.GetDoneTitleHeight"
,
params
,
&
res
)
ctx
.
Run
()
}
// GetConsensDoneInfoCmd get para chain done height consens info
func
GetConsensDoneInfoCmd
()
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"consens_done"
,
Short
:
"Get para chain done height consensus info"
,
Run
:
consensDoneInfo
,
}
addConsensDoneCmdFlags
(
cmd
)
return
cmd
}
plugin/dapp/paracross/executor/exec_local.go
View file @
957a16f0
...
...
@@ -30,6 +30,7 @@ func (e *Paracross) ExecLocal_Commit(payload *pt.ParacrossCommitAction, tx *type
}
else
if
log
.
Ty
==
pt
.
TyLogParacrossCommitDone
{
var
g
pt
.
ReceiptParacrossDone
types
.
Decode
(
log
.
Log
,
&
g
)
g
.
ChainExecHeight
=
e
.
GetHeight
()
key
:=
calcLocalTitleKey
(
g
.
Title
)
set
.
KV
=
append
(
set
.
KV
,
&
types
.
KeyValue
{
Key
:
key
,
Value
:
types
.
Encode
(
&
g
)})
...
...
plugin/dapp/paracross/executor/query.go
View file @
957a16f0
...
...
@@ -385,6 +385,7 @@ func loadLocalTitle(db dbm.KV, title string, height int64) (types.Message, error
MostSameCommit
:
st
.
MostSameCommit
,
Title
:
st
.
Title
,
Height
:
st
.
Height
,
ChainExecHeight
:
st
.
ChainExecHeight
,
TxResult
:
hex
.
EncodeToString
(
st
.
TxResult
),
},
nil
}
...
...
plugin/dapp/paracross/proto/paracross.proto
View file @
957a16f0
...
...
@@ -328,6 +328,7 @@ message ReceiptParacrossDone {
repeated
bytes
crossTxHashs
=
12
;
bytes
mainBlockHash
=
13
;
int64
mainBlockHeight
=
14
;
int64
chainExecHeight
=
15
;
}
message
ReceiptParacrossRecord
{
...
...
@@ -356,6 +357,8 @@ message RespParacrossDone {
string
stateHash
=
6
;
uint32
txCounts
=
7
;
string
txResult
=
8
;
//commitDone chainHeight
int64
chainExecHeight
=
9
;
}
message
RespParacrossTitles
{
...
...
plugin/dapp/paracross/rpc/rpc.go
View file @
957a16f0
...
...
@@ -118,6 +118,19 @@ func (c *channelClient) GetDoneTitleHeight(ctx context.Context, req *pt.ReqParac
return
nil
,
types
.
ErrDecode
}
// GetAssetTxResult get asset tx result
func
(
c
*
Jrpc
)
GetDoneTitleHeight
(
req
*
pt
.
ReqParacrossTitleHeight
,
result
*
interface
{})
error
{
if
req
==
nil
{
return
types
.
ErrInvalidParam
}
data
,
err
:=
c
.
cli
.
GetDoneTitleHeight
(
context
.
Background
(),
req
)
if
err
!=
nil
{
return
err
}
*
result
=
data
return
err
}
func
(
c
*
channelClient
)
GetAssetTxResult
(
ctx
context
.
Context
,
req
*
types
.
ReqString
)
(
*
pt
.
ParacrossAssetRsp
,
error
)
{
cfg
:=
c
.
GetConfig
()
data
,
err
:=
c
.
Query
(
pt
.
GetExecName
(
cfg
),
"GetAssetTxResult"
,
req
)
...
...
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