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
7b771cd2
Commit
7b771cd2
authored
Jan 17, 2020
by
mdj33
Committed by
vipwzw
Feb 18, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add UT
parent
cced1c38
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
173 additions
and
101 deletions
+173
-101
chain33.para.toml
chain33.para.toml
+0
-2
para.go
plugin/consensus/para/para.go
+20
-25
parajumpdownload.go
plugin/consensus/para/parajumpdownload.go
+1
-1
paracross.toml
plugin/dapp/paracross/autotest/paracross.toml
+1
-22
config
plugin/dapp/paracross/cmd/scripts/autodeploy/config
+4
-0
docker-compose.sh
...n/dapp/paracross/cmd/scripts/autodeploy/docker-compose.sh
+2
-0
asset-transfer.md
plugin/dapp/paracross/executor/asset-transfer.md
+23
-3
assettransfer_test.go
plugin/dapp/paracross/executor/assettransfer_test.go
+80
-0
exec.go
plugin/dapp/paracross/executor/exec.go
+2
-2
superaccount_test.go
plugin/dapp/paracross/executor/superaccount_test.go
+40
-7
paracross.go
plugin/dapp/paracross/types/paracross.go
+0
-39
No files found.
chain33.para.toml
View file @
7b771cd2
...
@@ -110,8 +110,6 @@ mainBlockHashForkHeight=209186
...
@@ -110,8 +110,6 @@ mainBlockHashForkHeight=209186
mainForkParacrossCommitTx
=
2270000
mainForkParacrossCommitTx
=
2270000
#主链开启循环检查共识交易done的fork高度,需要和主链保持严格一致,不可修改,4320000是bityuan主链对应高度, ycc或其他按实际修改
#主链开启循环检查共识交易done的fork高度,需要和主链保持严格一致,不可修改,4320000是bityuan主链对应高度, ycc或其他按实际修改
mainLoopCheckCommitTxDoneForkHeight
=
4320000
mainLoopCheckCommitTxDoneForkHeight
=
4320000
#主链交易验证merkelRoot主链分叉高度,需和主链保持一致,不可修改
mainVerifyMerkleRootForkHeight
=
-1
#主链每隔几个没有相关平行链交易的区块,平行链上打包空区块,缺省从平行链blockHeight=0开始,依次增长,空块间隔不能为0
#主链每隔几个没有相关平行链交易的区块,平行链上打包空区块,缺省从平行链blockHeight=0开始,依次增长,空块间隔不能为0
[[consensus.sub.para.emptyBlockInterval]]
[[consensus.sub.para.emptyBlockInterval]]
blockHeight
=
0
blockHeight
=
0
...
...
plugin/consensus/para/para.go
View file @
7b771cd2
...
@@ -72,27 +72,26 @@ type emptyBlockInterval struct {
...
@@ -72,27 +72,26 @@ type emptyBlockInterval struct {
}
}
type
subConfig
struct
{
type
subConfig
struct
{
WriteBlockSeconds
int64
`json:"writeBlockSeconds,omitempty"`
WriteBlockSeconds
int64
`json:"writeBlockSeconds,omitempty"`
ParaRemoteGrpcClient
string
`json:"paraRemoteGrpcClient,omitempty"`
ParaRemoteGrpcClient
string
`json:"paraRemoteGrpcClient,omitempty"`
StartHeight
int64
`json:"startHeight,omitempty"`
StartHeight
int64
`json:"startHeight,omitempty"`
GenesisStartHeightSame
bool
`json:"genesisStartHeightSame,omitempty"`
GenesisStartHeightSame
bool
`json:"genesisStartHeightSame,omitempty"`
EmptyBlockInterval
[]
*
emptyBlockInterval
`json:"emptyBlockInterval,omitempty"`
EmptyBlockInterval
[]
*
emptyBlockInterval
`json:"emptyBlockInterval,omitempty"`
AuthAccount
string
`json:"authAccount,omitempty"`
AuthAccount
string
`json:"authAccount,omitempty"`
WaitBlocks4CommitMsg
int32
`json:"waitBlocks4CommitMsg,omitempty"`
WaitBlocks4CommitMsg
int32
`json:"waitBlocks4CommitMsg,omitempty"`
GenesisAmount
int64
`json:"genesisAmount,omitempty"`
GenesisAmount
int64
`json:"genesisAmount,omitempty"`
MainBlockHashForkHeight
int64
`json:"mainBlockHashForkHeight,omitempty"`
MainBlockHashForkHeight
int64
`json:"mainBlockHashForkHeight,omitempty"`
MainVrfMerkleRootForkHeight
int64
`json:"mainVrfMerkleRootForkHeight,omitempty"`
WaitConsensStopTimes
uint32
`json:"waitConsensStopTimes,omitempty"`
WaitConsensStopTimes
uint32
`json:"waitConsensStopTimes,omitempty"`
MaxCacheCount
int64
`json:"maxCacheCount,omitempty"`
MaxCacheCount
int64
`json:"maxCacheCount,omitempty"`
MaxSyncErrCount
int32
`json:"maxSyncErrCount,omitempty"`
MaxSyncErrCount
int32
`json:"maxSyncErrCount,omitempty"`
BatchFetchBlockCount
int64
`json:"batchFetchBlockCount,omitempty"`
BatchFetchBlockCount
int64
`json:"batchFetchBlockCount,omitempty"`
ParaConsensStartHeight
int64
`json:"paraConsensStartHeight,omitempty"`
ParaConsensStartHeight
int64
`json:"paraConsensStartHeight,omitempty"`
MultiDownloadOpen
bool
`json:"multiDownloadOpen,omitempty"`
MultiDownloadOpen
bool
`json:"multiDownloadOpen,omitempty"`
MultiDownInvNumPerJob
int64
`json:"multiDownInvNumPerJob,omitempty"`
MultiDownInvNumPerJob
int64
`json:"multiDownInvNumPerJob,omitempty"`
MultiDownJobBuffNum
uint32
`json:"multiDownJobBuffNum,omitempty"`
MultiDownJobBuffNum
uint32
`json:"multiDownJobBuffNum,omitempty"`
MultiDownServerRspTime
uint32
`json:"multiDownServerRspTime,omitempty"`
MultiDownServerRspTime
uint32
`json:"multiDownServerRspTime,omitempty"`
RmCommitParamMainHeight
int64
`json:"rmCommitParamMainHeight,omitempty"`
RmCommitParamMainHeight
int64
`json:"rmCommitParamMainHeight,omitempty"`
JumpDownloadOpen
bool
`json:"jumpDownloadOpen,omitempty"`
JumpDownloadOpen
bool
`json:"jumpDownloadOpen,omitempty"`
}
}
// New function to init paracross env
// New function to init paracross env
...
@@ -203,10 +202,6 @@ func New(cfg *types.Consensus, sub []byte) queue.Module {
...
@@ -203,10 +202,6 @@ func New(cfg *types.Consensus, sub []byte) queue.Module {
para
.
jumpDldCli
=
&
jumpDldClient
{
paraClient
:
para
}
para
.
jumpDldCli
=
&
jumpDldClient
{
paraClient
:
para
}
if
subcfg
.
MainVrfMerkleRootForkHeight
<=
0
{
subcfg
.
MainVrfMerkleRootForkHeight
=
types
.
MaxHeight
}
c
.
SetChild
(
para
)
c
.
SetChild
(
para
)
return
para
return
para
}
}
...
...
plugin/consensus/para/parajumpdownload.go
View file @
7b771cd2
...
@@ -153,7 +153,7 @@ func (j *jumpDldClient) process(job *paraTxBlocksJob) {
...
@@ -153,7 +153,7 @@ func (j *jumpDldClient) process(job *paraTxBlocksJob) {
return
return
}
}
// 2. 校验交易merkle根和之前读的主链头的交易rootHash
// 2. 校验交易merkle根和之前读的主链头的交易rootHash
if
tx
.
Header
.
Height
>=
j
.
paraClient
.
subCfg
.
MainVrfMerkleRootForkHeight
{
if
j
.
paraClient
.
GetAPI
()
.
GetConfig
()
.
IsFork
(
tx
.
Header
.
Height
,
"ForkRootHash"
)
{
err
:=
j
.
verifyTxMerkleRoot
(
tx
,
headMap
)
err
:=
j
.
verifyTxMerkleRoot
(
tx
,
headMap
)
if
err
!=
nil
{
if
err
!=
nil
{
atomic
.
StoreInt32
(
&
j
.
downFail
,
1
)
atomic
.
StoreInt32
(
&
j
.
downFail
,
1
)
...
...
plugin/dapp/paracross/autotest/paracross.toml
View file @
7b771cd2
...
@@ -30,17 +30,6 @@ to = "1HPkPopVe3ERfvaAgedDtJQ792taZFEHCe"
...
@@ -30,17 +30,6 @@ to = "1HPkPopVe3ERfvaAgedDtJQ792taZFEHCe"
amount
=
"1"
amount
=
"1"
checkItem
=
["balance"]
checkItem
=
["balance"]
#send para asset bty
[[TransferCase]]
id
=
"btyParaTrans"
command
=
"send para asset_transfer --paraName user.p.test. -a 0.1 -t 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv -k 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
from
=
"12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
#复用coins的transfer用例,此处to地址比较特殊,为平行链paracross合约的地址
to
=
"16zsMh7mvNDKPG6E9NVrPhw6zL93gWsTpR"
amount
=
"0.1"
checkItem
=
["balance"]
dep
=
["btyToExec"]
repeat
=
10
#send token to paracross
#send token to paracross
[[TransferCase]]
[[TransferCase]]
...
@@ -52,17 +41,7 @@ amount = "10"
...
@@ -52,17 +41,7 @@ amount = "10"
checkItem
=
["balance"]
checkItem
=
["balance"]
dep
=
["tokenFinish"]
dep
=
["tokenFinish"]
#send para asset token PT
[[TransferCase]]
id
=
"tokenParaTrans"
command
=
"send para asset_transfer --paraName user.p.test. -s PT -a 1 -t 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv -k 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
from
=
"12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
#复用coins的transfer用例,此处to地址比较特殊,为平行链paracross合约的地址
to
=
"16zsMh7mvNDKPG6E9NVrPhw6zL93gWsTpR"
amount
=
"1"
checkItem
=
["balance"]
dep
=
["tokenToExec"]
repeat
=
10
plugin/dapp/paracross/cmd/scripts/autodeploy/config
View file @
7b771cd2
...
@@ -8,8 +8,12 @@ genesisAccount="14KEKbYtKKQm4wMthSK9J4La4nAiidGozt"
...
@@ -8,8 +8,12 @@ genesisAccount="14KEKbYtKKQm4wMthSK9J4La4nAiidGozt"
#创世数量
#创世数量
genesisAmount=100000000
genesisAmount=100000000
#主链节点的ip
ParaRemoteGrpcClient="114.55.11.139:1197"
#从主链哪个高度开始同步区块
#从主链哪个高度开始同步区块
mainStartHeight=4000000
mainStartHeight=4000000
#fork config
mainLoopCheckCommitTxDoneForkHeight=3120000
#平行链授权账户,这里的数量要和下面的authPrikey和authPort保持一致
#平行链授权账户,这里的数量要和下面的authPrikey和authPort保持一致
authAccount=( "1KSBd17H7ZK8iT37aJztFB22XGwsPTdwE4" "1JRNjdEqp4LJ5fqycUBm9ayCKSeeskgMKR" "1NLHPEcbTWWxxU3dGUZBhayjrCHD3psX7k" "1MCftFynyvG2F4ED5mdHYgziDxx6vDrScs")
authAccount=( "1KSBd17H7ZK8iT37aJztFB22XGwsPTdwE4" "1JRNjdEqp4LJ5fqycUBm9ayCKSeeskgMKR" "1NLHPEcbTWWxxU3dGUZBhayjrCHD3psX7k" "1MCftFynyvG2F4ED5mdHYgziDxx6vDrScs")
#授权账户的私钥,为了导入钱包,自动开启共识挖矿
#授权账户的私钥,为了导入钱包,自动开启共识挖矿
...
...
plugin/dapp/paracross/cmd/scripts/autodeploy/docker-compose.sh
View file @
7b771cd2
...
@@ -43,6 +43,8 @@ function para_set_toml() {
...
@@ -43,6 +43,8 @@ function para_set_toml() {
sed
-i
$sedfix
's/^Title.*/Title="user.p.'''
"
$paraName
"
'''."/g'
"
${
1
}
"
sed
-i
$sedfix
's/^Title.*/Title="user.p.'''
"
$paraName
"
'''."/g'
"
${
1
}
"
sed
-i
$sedfix
's/^startHeight=.*/startHeight='''
"
$mainStartHeight
"
'''/g'
"
${
1
}
"
sed
-i
$sedfix
's/^startHeight=.*/startHeight='''
"
$mainStartHeight
"
'''/g'
"
${
1
}
"
sed
-i
$sedfix
's/^ParaRemoteGrpcClient=.*/ParaRemoteGrpcClient='''
"
$ParaRemoteGrpcClient
"
'''/g'
"
${
1
}
"
sed
-i
$sedfix
's/^mainLoopCheckCommitTxDoneForkHeight=.*/mainLoopCheckCommitTxDoneForkHeight='''
"
$mainLoopCheckCommitTxDoneForkHeight
"
'''/g'
"
${
1
}
"
# rpc
# rpc
sed
-i
$sedfix
's/^jrpcBindAddr=.*/jrpcBindAddr="0.0.0.0:8901"/g'
"
${
1
}
"
sed
-i
$sedfix
's/^jrpcBindAddr=.*/jrpcBindAddr="0.0.0.0:8901"/g'
"
${
1
}
"
...
...
plugin/dapp/paracross/executor/asset-transfer.md
View file @
7b771cd2
...
@@ -22,9 +22,8 @@
...
@@ -22,9 +22,8 @@
1.
为了容易认出, 暂定方案 执行器名字带上另行链title:如 user.p.guodun.paracross, 也就是说需要在主链上能执行这样的交易
1.
为了容易认出, 暂定方案 执行器名字带上另行链title:如 user.p.guodun.paracross, 也就是说需要在主链上能执行这样的交易
关于交易序号的说明
关于交易序号的说明
1.
由于平行链上加了挖矿交易, 交易列表不再是全部从主链区块中过滤, 原来设计表示平行链区块交易列表执行情况的bitmap, 改为 txHash 对应结果的数组
1.
由于平行链上加了挖矿交易, 交易列表不再是全部从主链区块中过滤
1.
避免对平行链后续变动,主链数平行链的交易序号也要跟着变化
1.
挖矿交易记录的交易结果的bitmap, 再主链根据主链区块高度,重新获取交易,然后找到对应bit 获取执行结果
1.
但交易大小会变大, 如果接受不了, 再做其他的方案
## 交易
## 交易
...
@@ -46,6 +45,27 @@ asset-transfer 分两种, 主链转出, 主链转入
...
@@ -46,6 +45,27 @@ asset-transfer 分两种, 主链转出, 主链转入
1.
某平行链paracross合约帐号, balance -
1.
某平行链paracross合约帐号, balance -
1.
用户主链paracross合约帐号, balance +
1.
用户主链paracross合约帐号, balance +
cross-transfer 把transfer和withdraw统一为transfer, 通过统一地址符号,内部判断是transfer和withdraw
统一地址符号:title+执行器+符号
1.
主链title缺省为空,类似:coins.bty, token.FZM
1.
平行链符号为: user.p.test.coins.para 或user.p.game.token.FZM
主链转移资产场景: type=0, tx.exec=user.p.test.
1.
主链本币转移: symbol:{coins/token}.bty/cny or bty/cny,
平行链资产: paracross-coins.bty
2.
主链外币转移: symbol: user.p.para.coins.ccny,
平行链资产: paracross-paracross.user.p.para.coins.ccny
3.
平行链本币提回: symbol: user.p.test.coins.ccny
平行链资产: paracross账户coins.ccny资产释放
平行链转移资产场景:type=1,tx.exec=user.p.test.
1.
平行链本币转移: symbol:user.p.test.{coins/token}.ccny
主链产生资产: paracross-user.p.test.{coins}.ccny
2.
主链外币提取: symbol: user.p.para.coins.ccny
主链恢复外币资产:user.p.test.paracross地址释放user.p.para.coins.ccny
3.
主链本币提取: symbol: coins.bty
主链恢复本币资产:user.p.test.paracross地址释放coin.bty
交易执行代码分为 三个部分
交易执行代码分为 三个部分
1.
主链
1.
主链
1.
平行链
1.
平行链
...
...
plugin/dapp/paracross/executor/assettransfer_test.go
View file @
7b771cd2
...
@@ -16,9 +16,11 @@ import (
...
@@ -16,9 +16,11 @@ import (
"github.com/33cn/chain33/common/address"
"github.com/33cn/chain33/common/address"
dbm
"github.com/33cn/chain33/common/db"
dbm
"github.com/33cn/chain33/common/db"
dbmock
"github.com/33cn/chain33/common/db/mocks"
dbmock
"github.com/33cn/chain33/common/db/mocks"
coins
"github.com/33cn/chain33/system/dapp/coins/types"
"github.com/33cn/chain33/types"
"github.com/33cn/chain33/types"
"github.com/33cn/plugin/plugin/dapp/paracross/testnode"
"github.com/33cn/plugin/plugin/dapp/paracross/testnode"
pt
"github.com/33cn/plugin/plugin/dapp/paracross/types"
pt
"github.com/33cn/plugin/plugin/dapp/paracross/types"
token
"github.com/33cn/plugin/plugin/dapp/token/types"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/mock"
)
)
...
@@ -336,3 +338,81 @@ func createAssetTransferTokenTx(s suite.Suite, privFrom string, to []byte) (*typ
...
@@ -336,3 +338,81 @@ func createAssetTransferTokenTx(s suite.Suite, privFrom string, to []byte) (*typ
return
tx
,
nil
return
tx
,
nil
}
}
func
TestGetCrossAction
(
t
*
testing
.
T
)
{
txExec
:=
"paracross"
transfer
:=
&
pt
.
CrossAssetTransfer
{
Type
:
0
,
AssetSymbol
:
"coin.bty"
}
action
,
err
:=
getCrossAction
(
transfer
,
txExec
)
assert
.
NotNil
(
t
,
err
)
assert
.
Equal
(
t
,
int64
(
pt
.
ParacrossNoneTransfer
),
action
)
txExec
=
"user.p.para.paracross"
action
,
err
=
getCrossAction
(
transfer
,
txExec
)
assert
.
Nil
(
t
,
err
)
assert
.
Equal
(
t
,
int64
(
pt
.
ParacrossMainTransfer
),
action
)
transfer
=
&
pt
.
CrossAssetTransfer
{
Type
:
0
,
AssetSymbol
:
"user.p.para.coin.bty"
}
action
,
err
=
getCrossAction
(
transfer
,
txExec
)
assert
.
Nil
(
t
,
err
)
assert
.
Equal
(
t
,
int64
(
pt
.
ParacrossParaWithdraw
),
action
)
transfer
=
&
pt
.
CrossAssetTransfer
{
Type
:
0
,
AssetSymbol
:
"user.p.test.coin.bty"
}
action
,
err
=
getCrossAction
(
transfer
,
txExec
)
assert
.
Nil
(
t
,
err
)
assert
.
Equal
(
t
,
int64
(
pt
.
ParacrossMainTransfer
),
action
)
transfer
=
&
pt
.
CrossAssetTransfer
{
Type
:
1
,
AssetSymbol
:
"coin.bty"
}
action
,
err
=
getCrossAction
(
transfer
,
txExec
)
assert
.
Nil
(
t
,
err
)
assert
.
Equal
(
t
,
int64
(
pt
.
ParacrossMainWithdraw
),
action
)
transfer
=
&
pt
.
CrossAssetTransfer
{
Type
:
1
,
AssetSymbol
:
"user.p.para.coin.bty"
}
action
,
err
=
getCrossAction
(
transfer
,
txExec
)
assert
.
Nil
(
t
,
err
)
assert
.
Equal
(
t
,
int64
(
pt
.
ParacrossParaTransfer
),
action
)
transfer
=
&
pt
.
CrossAssetTransfer
{
Type
:
1
,
AssetSymbol
:
"user.p.test.coin.bty"
}
action
,
err
=
getCrossAction
(
transfer
,
txExec
)
assert
.
Nil
(
t
,
err
)
assert
.
Equal
(
t
,
int64
(
pt
.
ParacrossMainWithdraw
),
action
)
}
func
TestFormatTransfer
(
t
*
testing
.
T
)
{
act
:=
int64
(
pt
.
ParacrossMainTransfer
)
transfer
:=
&
pt
.
CrossAssetTransfer
{
Type
:
0
,
AssetSymbol
:
"user.p.coins.bty"
}
rst
:=
formatTransfer
(
transfer
,
act
)
assert
.
Equal
(
t
,
pt
.
ParaX
,
rst
.
AssetExec
)
act
=
pt
.
ParacrossMainWithdraw
transfer
=
&
pt
.
CrossAssetTransfer
{
Type
:
0
,
AssetSymbol
:
"user.p.coins.bty"
}
rst
=
formatTransfer
(
transfer
,
act
)
assert
.
Equal
(
t
,
pt
.
ParaX
,
rst
.
AssetExec
)
act
=
pt
.
ParacrossMainTransfer
transfer
=
&
pt
.
CrossAssetTransfer
{
Type
:
0
,
AssetSymbol
:
"coins.bty"
}
rst
=
formatTransfer
(
transfer
,
act
)
assert
.
Equal
(
t
,
coins
.
CoinsX
,
rst
.
AssetExec
)
act
=
pt
.
ParacrossMainWithdraw
transfer
=
&
pt
.
CrossAssetTransfer
{
Type
:
0
,
AssetSymbol
:
"coins.bty"
}
rst
=
formatTransfer
(
transfer
,
act
)
assert
.
Equal
(
t
,
coins
.
CoinsX
,
rst
.
AssetExec
)
act
=
pt
.
ParacrossMainTransfer
transfer
=
&
pt
.
CrossAssetTransfer
{
Type
:
0
,
AssetSymbol
:
"fzm"
}
rst
=
formatTransfer
(
transfer
,
act
)
assert
.
Equal
(
t
,
token
.
TokenX
,
rst
.
AssetExec
)
act
=
pt
.
ParacrossMainTransfer
transfer
=
&
pt
.
CrossAssetTransfer
{
Type
:
0
,
AssetSymbol
:
""
}
rst
=
formatTransfer
(
transfer
,
act
)
assert
.
Equal
(
t
,
coins
.
CoinsX
,
rst
.
AssetExec
)
assert
.
Equal
(
t
,
"bty"
,
rst
.
AssetSymbol
)
act
=
pt
.
ParacrossParaTransfer
transfer
=
&
pt
.
CrossAssetTransfer
{
Type
:
0
,
AssetSymbol
:
"user.p.coins.para"
}
rst
=
formatTransfer
(
transfer
,
act
)
assert
.
Equal
(
t
,
coins
.
CoinsX
,
rst
.
AssetExec
)
assert
.
Equal
(
t
,
"para"
,
rst
.
AssetSymbol
)
}
plugin/dapp/paracross/executor/exec.go
View file @
7b771cd2
...
@@ -35,7 +35,7 @@ func (e *Paracross) Exec_AssetTransfer(payload *types.AssetsTransfer, tx *types.
...
@@ -35,7 +35,7 @@ func (e *Paracross) Exec_AssetTransfer(payload *types.AssetsTransfer, tx *types.
receipt
,
err
:=
a
.
AssetTransfer
(
payload
)
receipt
,
err
:=
a
.
AssetTransfer
(
payload
)
if
err
!=
nil
{
if
err
!=
nil
{
clog
.
Error
(
"Paracross AssetTransfer failed"
,
"error"
,
err
,
"hash"
,
hex
.
EncodeToString
(
tx
.
Hash
()))
clog
.
Error
(
"Paracross AssetTransfer failed"
,
"error"
,
err
,
"hash"
,
hex
.
EncodeToString
(
tx
.
Hash
()))
return
nil
,
err
ors
.
Cause
(
err
)
return
nil
,
err
}
}
return
receipt
,
nil
return
receipt
,
nil
}
}
...
@@ -51,7 +51,7 @@ func (e *Paracross) Exec_AssetWithdraw(payload *types.AssetsWithdraw, tx *types.
...
@@ -51,7 +51,7 @@ func (e *Paracross) Exec_AssetWithdraw(payload *types.AssetsWithdraw, tx *types.
receipt
,
err
:=
a
.
AssetWithdraw
(
payload
)
receipt
,
err
:=
a
.
AssetWithdraw
(
payload
)
if
err
!=
nil
{
if
err
!=
nil
{
clog
.
Error
(
"ParacrossActionAssetWithdraw failed"
,
"error"
,
err
,
"hash"
,
hex
.
EncodeToString
(
tx
.
Hash
()))
clog
.
Error
(
"ParacrossActionAssetWithdraw failed"
,
"error"
,
err
,
"hash"
,
hex
.
EncodeToString
(
tx
.
Hash
()))
return
nil
,
err
ors
.
Cause
(
err
)
return
nil
,
err
}
}
return
receipt
,
nil
return
receipt
,
nil
}
}
...
...
plugin/dapp/paracross/executor/superaccount_test.go
View file @
7b771cd2
...
@@ -16,6 +16,8 @@ import (
...
@@ -16,6 +16,8 @@ import (
dbmock
"github.com/33cn/chain33/common/db/mocks"
dbmock
"github.com/33cn/chain33/common/db/mocks"
"github.com/33cn/chain33/types"
"github.com/33cn/chain33/types"
"strings"
pt
"github.com/33cn/plugin/plugin/dapp/paracross/types"
pt
"github.com/33cn/plugin/plugin/dapp/paracross/types"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/mock"
)
)
...
@@ -30,6 +32,37 @@ var (
...
@@ -30,6 +32,37 @@ var (
PrivKey12Q
=
"4257D8692EF7FE13C68B65D6A52F03933DB2FA5CE8FAF210B5B8B80C721CED01"
PrivKey12Q
=
"4257D8692EF7FE13C68B65D6A52F03933DB2FA5CE8FAF210B5B8B80C721CED01"
)
)
// createRawNodeConfigTx create raw tx for node config
func
createRawNodeConfigTx
(
config
*
pt
.
ParaNodeAddrConfig
)
(
*
types
.
Transaction
,
error
)
{
action
:=
&
pt
.
ParacrossAction
{
Ty
:
pt
.
ParacrossActionNodeConfig
,
Value
:
&
pt
.
ParacrossAction_NodeConfig
{
NodeConfig
:
config
},
}
tx
:=
&
types
.
Transaction
{
Payload
:
types
.
Encode
(
action
),
Execer
:
[]
byte
(
config
.
Title
+
pt
.
ParaX
),
}
return
tx
,
nil
}
//createRawNodeGroupApplyTx create raw tx for node group
func
createRawNodeGroupApplyTx
(
apply
*
pt
.
ParaNodeGroupConfig
)
(
*
types
.
Transaction
,
error
)
{
apply
.
Id
=
strings
.
Trim
(
apply
.
Id
,
" "
)
action
:=
&
pt
.
ParacrossAction
{
Ty
:
pt
.
ParacrossActionNodeGroupApply
,
Value
:
&
pt
.
ParacrossAction_NodeGroupConfig
{
NodeGroupConfig
:
apply
},
}
tx
:=
&
types
.
Transaction
{
Payload
:
types
.
Encode
(
action
),
Execer
:
[]
byte
(
apply
.
Title
+
pt
.
ParaX
),
}
return
tx
,
nil
}
type
NodeManageTestSuite
struct
{
type
NodeManageTestSuite
struct
{
suite
.
Suite
suite
.
Suite
stateDB
dbm
.
KV
stateDB
dbm
.
KV
...
@@ -182,7 +215,7 @@ func voteTest(suite *NodeManageTestSuite, id string, join bool) {
...
@@ -182,7 +215,7 @@ func voteTest(suite *NodeManageTestSuite, id string, join bool) {
Id
:
id
,
Id
:
id
,
Value
:
pt
.
ParaVoteYes
,
Value
:
pt
.
ParaVoteYes
,
}
}
tx
,
err
:=
pt
.
C
reateRawNodeConfigTx
(
config
)
tx
,
err
:=
c
reateRawNodeConfigTx
(
config
)
suite
.
Nil
(
err
)
suite
.
Nil
(
err
)
count
++
count
++
...
@@ -210,7 +243,7 @@ func (suite *NodeManageTestSuite) testNodeGroupConfigQuit() {
...
@@ -210,7 +243,7 @@ func (suite *NodeManageTestSuite) testNodeGroupConfigQuit() {
Addrs
:
applyAddrs
,
Addrs
:
applyAddrs
,
Op
:
pt
.
ParacrossNodeGroupApply
,
Op
:
pt
.
ParacrossNodeGroupApply
,
}
}
tx
,
err
:=
pt
.
C
reateRawNodeGroupApplyTx
(
config
)
tx
,
err
:=
c
reateRawNodeGroupApplyTx
(
config
)
suite
.
Nil
(
err
)
suite
.
Nil
(
err
)
receipt
:=
nodeCommit
(
suite
,
PrivKeyB
,
tx
)
receipt
:=
nodeCommit
(
suite
,
PrivKeyB
,
tx
)
...
@@ -226,7 +259,7 @@ func (suite *NodeManageTestSuite) testNodeGroupConfigQuit() {
...
@@ -226,7 +259,7 @@ func (suite *NodeManageTestSuite) testNodeGroupConfigQuit() {
Id
:
g
.
Current
.
Id
,
Id
:
g
.
Current
.
Id
,
Op
:
pt
.
ParacrossNodeGroupQuit
,
Op
:
pt
.
ParacrossNodeGroupQuit
,
}
}
tx
,
err
=
pt
.
C
reateRawNodeGroupApplyTx
(
config
)
tx
,
err
=
c
reateRawNodeGroupApplyTx
(
config
)
suite
.
Nil
(
err
)
suite
.
Nil
(
err
)
nodeCommit
(
suite
,
PrivKeyB
,
tx
)
nodeCommit
(
suite
,
PrivKeyB
,
tx
)
...
@@ -242,7 +275,7 @@ func (suite *NodeManageTestSuite) testNodeGroupConfig() {
...
@@ -242,7 +275,7 @@ func (suite *NodeManageTestSuite) testNodeGroupConfig() {
Addrs
:
applyAddrs
,
Addrs
:
applyAddrs
,
Op
:
pt
.
ParacrossNodeGroupApply
,
Op
:
pt
.
ParacrossNodeGroupApply
,
}
}
tx
,
err
:=
pt
.
C
reateRawNodeGroupApplyTx
(
config
)
tx
,
err
:=
c
reateRawNodeGroupApplyTx
(
config
)
suite
.
Nil
(
err
)
suite
.
Nil
(
err
)
receipt
:=
nodeCommit
(
suite
,
PrivKeyB
,
tx
)
receipt
:=
nodeCommit
(
suite
,
PrivKeyB
,
tx
)
...
@@ -258,7 +291,7 @@ func (suite *NodeManageTestSuite) testNodeGroupConfig() {
...
@@ -258,7 +291,7 @@ func (suite *NodeManageTestSuite) testNodeGroupConfig() {
Id
:
g
.
Current
.
Id
,
Id
:
g
.
Current
.
Id
,
Op
:
pt
.
ParacrossNodeGroupApprove
,
Op
:
pt
.
ParacrossNodeGroupApprove
,
}
}
tx
,
err
=
pt
.
C
reateRawNodeGroupApplyTx
(
config
)
tx
,
err
=
c
reateRawNodeGroupApplyTx
(
config
)
suite
.
Nil
(
err
)
suite
.
Nil
(
err
)
receipt
=
nodeCommit
(
suite
,
PrivKey12Q
,
tx
)
receipt
=
nodeCommit
(
suite
,
PrivKey12Q
,
tx
)
...
@@ -273,7 +306,7 @@ func (suite *NodeManageTestSuite) testNodeConfig() {
...
@@ -273,7 +306,7 @@ func (suite *NodeManageTestSuite) testNodeConfig() {
Op
:
pt
.
ParaOpNewApply
,
Op
:
pt
.
ParaOpNewApply
,
Addr
:
Account14K
,
Addr
:
Account14K
,
}
}
tx
,
err
:=
pt
.
C
reateRawNodeConfigTx
(
config
)
tx
,
err
:=
c
reateRawNodeConfigTx
(
config
)
suite
.
Nil
(
err
)
suite
.
Nil
(
err
)
receipt
:=
nodeCommit
(
suite
,
PrivKey14K
,
tx
)
receipt
:=
nodeCommit
(
suite
,
PrivKey14K
,
tx
)
...
@@ -293,7 +326,7 @@ func (suite *NodeManageTestSuite) testNodeConfig() {
...
@@ -293,7 +326,7 @@ func (suite *NodeManageTestSuite) testNodeConfig() {
Op
:
pt
.
ParaOpQuit
,
Op
:
pt
.
ParaOpQuit
,
Addr
:
Account14K
,
Addr
:
Account14K
,
}
}
tx
,
err
=
pt
.
C
reateRawNodeConfigTx
(
config
)
tx
,
err
=
c
reateRawNodeConfigTx
(
config
)
suite
.
Nil
(
err
)
suite
.
Nil
(
err
)
receipt
=
nodeCommit
(
suite
,
PrivKeyD
,
tx
)
receipt
=
nodeCommit
(
suite
,
PrivKeyD
,
tx
)
checkQuitReceipt
(
suite
,
receipt
)
checkQuitReceipt
(
suite
,
receipt
)
...
...
plugin/dapp/paracross/types/paracross.go
View file @
7b771cd2
...
@@ -7,7 +7,6 @@ package types
...
@@ -7,7 +7,6 @@ package types
import
(
import
(
"encoding/json"
"encoding/json"
"fmt"
"fmt"
"strings"
"github.com/33cn/chain33/common/address"
"github.com/33cn/chain33/common/address"
"github.com/33cn/chain33/common/log/log15"
"github.com/33cn/chain33/common/log/log15"
...
@@ -50,11 +49,6 @@ const (
...
@@ -50,11 +49,6 @@ const (
TyLogParaCrossAssetTransfer
=
670
TyLogParaCrossAssetTransfer
=
670
)
)
type
paracrossCommitTx
struct
{
Fee
int64
`json:"fee"`
Status
ParacrossNodeStatus
`json:"status"`
}
// action type
// action type
const
(
const
(
// ParacrossActionCommit paracross consensus commit action
// ParacrossActionCommit paracross consensus commit action
...
@@ -217,39 +211,6 @@ func createRawCommitTx(cfg *types.Chain33Config, status *ParacrossNodeStatus, na
...
@@ -217,39 +211,6 @@ func createRawCommitTx(cfg *types.Chain33Config, status *ParacrossNodeStatus, na
return
tx
,
nil
return
tx
,
nil
}
}
// CreateRawNodeConfigTx create raw tx for node config
func
CreateRawNodeConfigTx
(
config
*
ParaNodeAddrConfig
)
(
*
types
.
Transaction
,
error
)
{
config
.
Addr
=
strings
.
Trim
(
config
.
Addr
,
" "
)
config
.
Id
=
strings
.
Trim
(
config
.
Id
,
" "
)
action
:=
&
ParacrossAction
{
Ty
:
ParacrossActionNodeConfig
,
Value
:
&
ParacrossAction_NodeConfig
{
config
},
}
tx
:=
&
types
.
Transaction
{
Payload
:
types
.
Encode
(
action
),
}
return
tx
,
nil
}
//CreateRawNodeGroupApplyTx create raw tx for node group
func
CreateRawNodeGroupApplyTx
(
apply
*
ParaNodeGroupConfig
)
(
*
types
.
Transaction
,
error
)
{
apply
.
Id
=
strings
.
Trim
(
apply
.
Id
,
" "
)
action
:=
&
ParacrossAction
{
Ty
:
ParacrossActionNodeGroupApply
,
Value
:
&
ParacrossAction_NodeGroupConfig
{
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
)
{
// 跨链交易需要在主链和平行链上执行, 所以应该可以在主链和平行链上构建
// 跨链交易需要在主链和平行链上执行, 所以应该可以在主链和平行链上构建
...
...
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