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
c6e251dc
Commit
c6e251dc
authored
Feb 26, 2020
by
mdj33
Committed by
vipwzw
Feb 28, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
parachain improve
parent
404beadc
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
66 additions
and
30 deletions
+66
-30
chain33.para.toml
chain33.para.toml
+2
-2
para.go
plugin/consensus/para/para.go
+1
-1
paracreate.go
plugin/consensus/para/paracreate.go
+1
-1
paracross.go
plugin/dapp/paracross/commands/paracross.go
+0
-1
action.go
plugin/dapp/paracross/executor/action.go
+58
-23
exec.go
plugin/dapp/paracross/executor/exec.go
+2
-2
paracross.go
plugin/dapp/paracross/executor/paracross.go
+2
-0
No files found.
chain33.para.toml
View file @
c6e251dc
...
@@ -211,7 +211,7 @@ ForkEnableParaRegExec=0
...
@@ -211,7 +211,7 @@ ForkEnableParaRegExec=0
ForkCacheDriver
=
0
ForkCacheDriver
=
0
ForkTicketFundAddrV1
=
-1
#fork6.3
ForkTicketFundAddrV1
=
-1
#fork6.3
#主链和平行链都使用同一个fork高度
#主链和平行链都使用同一个fork高度
ForkRootHash
=
45
00000
ForkRootHash
=
70
00000
[fork.sub.coins]
[fork.sub.coins]
Enable
=
0
Enable
=
0
...
@@ -254,7 +254,7 @@ Enable=0
...
@@ -254,7 +254,7 @@ Enable=0
ForkParacrossWithdrawFromParachain
=
0
ForkParacrossWithdrawFromParachain
=
0
ForkParacrossCommitTx
=
0
ForkParacrossCommitTx
=
0
ForkLoopCheckCommitTxDone
=
0
ForkLoopCheckCommitTxDone
=
0
#
平行链分阶段自共识支持合约配置,缺省是0
#
仅平行链适用,自共识分阶段开启,缺省是0,若对应主链高度7000000之前开启过自共识,需要重新配置此分叉,并为之前自共识设置selfConsensEnablePreContract配置项
ForkParaSelfConsStages
=
0
ForkParaSelfConsStages
=
0
ForkParaAssetTransferRbk
=
0
ForkParaAssetTransferRbk
=
0
...
...
plugin/consensus/para/para.go
View file @
c6e251dc
...
@@ -91,7 +91,7 @@ type subConfig struct {
...
@@ -91,7 +91,7 @@ type subConfig struct {
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"`
JumpDownload
Open
bool
`json:"jumpDownloadOpen
,omitempty"`
JumpDownload
Close
bool
`json:"jumpDownloadClose
,omitempty"`
}
}
// New function to init paracross env
// New function to init paracross env
...
...
plugin/consensus/para/paracreate.go
View file @
c6e251dc
...
@@ -497,7 +497,7 @@ func (client *client) procLocalAddBlocks(mainBlocks *types.ParaTxDetails) error
...
@@ -497,7 +497,7 @@ func (client *client) procLocalAddBlocks(mainBlocks *types.ParaTxDetails) error
func
(
client
*
client
)
CreateBlock
()
{
func
(
client
*
client
)
CreateBlock
()
{
defer
client
.
wg
.
Done
()
defer
client
.
wg
.
Done
()
if
client
.
subCfg
.
JumpDownload
Open
{
if
client
.
subCfg
.
JumpDownload
Close
{
client
.
jumpDldCli
.
tryJumpDownload
()
client
.
jumpDldCli
.
tryJumpDownload
()
}
}
...
...
plugin/dapp/paracross/commands/paracross.go
View file @
c6e251dc
...
@@ -256,7 +256,6 @@ func addCreateCrossAssetTransferFlags(cmd *cobra.Command) {
...
@@ -256,7 +256,6 @@ func addCreateCrossAssetTransferFlags(cmd *cobra.Command) {
cmd
.
MarkFlagRequired
(
"symbol"
)
cmd
.
MarkFlagRequired
(
"symbol"
)
cmd
.
Flags
()
.
StringP
(
"to"
,
"t"
,
""
,
"transfer to account"
)
cmd
.
Flags
()
.
StringP
(
"to"
,
"t"
,
""
,
"transfer to account"
)
cmd
.
MarkFlagRequired
(
"to"
)
cmd
.
Flags
()
.
Float64P
(
"amount"
,
"a"
,
0
,
"transaction amount"
)
cmd
.
Flags
()
.
Float64P
(
"amount"
,
"a"
,
0
,
"transaction amount"
)
cmd
.
MarkFlagRequired
(
"amount"
)
cmd
.
MarkFlagRequired
(
"amount"
)
...
...
plugin/dapp/paracross/executor/action.go
View file @
c6e251dc
...
@@ -1007,30 +1007,38 @@ func (a *action) execCrossTxs(status *pt.ParacrossNodeStatus) (*types.Receipt, e
...
@@ -1007,30 +1007,38 @@ func (a *action) execCrossTxs(status *pt.ParacrossNodeStatus) (*types.Receipt, e
return
&
receipt
,
nil
return
&
receipt
,
nil
}
}
func
(
a
*
action
)
assetTransferMainCheck
(
cfg
*
types
.
Chain33Config
)
error
{
//主链如果没有nodegroup配置,也不允许跨链,直接返回错误,平行链也不会执行
if
cfg
.
IsDappFork
(
a
.
height
,
pt
.
ParaX
,
pt
.
ForkParaAssetTransferRbk
)
{
return
a
.
isAllowTransfer
()
}
return
nil
}
func
(
a
*
action
)
AssetTransfer
(
transfer
*
types
.
AssetsTransfer
)
(
*
types
.
Receipt
,
error
)
{
func
(
a
*
action
)
AssetTransfer
(
transfer
*
types
.
AssetsTransfer
)
(
*
types
.
Receipt
,
error
)
{
clog
.
Debug
(
"Paracross.Exec"
,
"AssetTransfer"
,
transfer
.
Cointoken
,
"transfer"
,
""
)
clog
.
Debug
(
"Paracross.Exec"
,
"AssetTransfer"
,
transfer
.
Cointoken
,
"transfer"
,
""
)
cfg
:=
a
.
api
.
GetConfig
()
isPara
:=
cfg
.
IsPara
()
//
rbk fork后 如果没有nodegroup conf,也不允许跨链
//
主链如果没有nodegroup配置,也不允许跨链,直接返回错误,平行链也不会执行
if
a
.
api
.
GetConfig
()
.
IsDappFork
(
a
.
height
,
pt
.
ParaX
,
pt
.
ForkParaAssetTransferRbk
)
{
if
!
isPara
{
err
:=
a
.
isAllowTransfer
(
)
err
:=
a
.
assetTransferMainCheck
(
cfg
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
errors
.
Wrap
(
err
,
"AssetTransfer
not allow
"
)
return
nil
,
errors
.
Wrap
(
err
,
"AssetTransfer
check
"
)
}
}
}
}
receipt
,
err
:=
a
.
assetTransfer
(
transfer
)
receipt
,
err
:=
a
.
assetTransfer
(
transfer
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
errors
.
Wrap
(
err
,
"AssetTransfer
failed
"
)
return
nil
,
errors
.
Wrap
(
err
,
"AssetTransfer"
)
}
}
return
receipt
,
nil
return
receipt
,
nil
}
}
func
(
a
*
action
)
AssetWithdraw
(
withdraw
*
types
.
AssetsWithdraw
)
(
*
types
.
Receipt
,
error
)
{
func
(
a
*
action
)
assetWithdrawMainCheck
(
cfg
*
types
.
Chain33Config
,
withdraw
*
types
.
AssetsWithdraw
)
error
{
//分叉高度之后,支持从平行链提取资产
cfg
:=
a
.
api
.
GetConfig
()
if
!
cfg
.
IsDappFork
(
a
.
height
,
pt
.
ParaX
,
"ForkParacrossWithdrawFromParachain"
)
{
if
!
cfg
.
IsDappFork
(
a
.
height
,
pt
.
ParaX
,
"ForkParacrossWithdrawFromParachain"
)
{
if
withdraw
.
Cointoken
!=
""
{
if
withdraw
.
Cointoken
!=
""
{
return
nil
,
types
.
ErrNotSupport
return
errors
.
Wrapf
(
types
.
ErrNotSupport
,
"not support,token=%s"
,
withdraw
.
Cointoken
)
}
}
}
}
...
@@ -1038,12 +1046,24 @@ func (a *action) AssetWithdraw(withdraw *types.AssetsWithdraw) (*types.Receipt,
...
@@ -1038,12 +1046,24 @@ func (a *action) AssetWithdraw(withdraw *types.AssetsWithdraw) (*types.Receipt,
if
cfg
.
IsDappFork
(
a
.
height
,
pt
.
ParaX
,
pt
.
ForkParaAssetTransferRbk
)
{
if
cfg
.
IsDappFork
(
a
.
height
,
pt
.
ParaX
,
pt
.
ForkParaAssetTransferRbk
)
{
err
:=
a
.
isAllowTransfer
()
err
:=
a
.
isAllowTransfer
()
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
errors
.
Wrap
(
err
,
"AssetTransfer
not allow"
)
return
errors
.
Wrap
(
err
,
"AssetWithdraw
not allow"
)
}
}
}
}
return
nil
}
func
(
a
*
action
)
AssetWithdraw
(
withdraw
*
types
.
AssetsWithdraw
)
(
*
types
.
Receipt
,
error
)
{
//分叉高度之后,支持从平行链提取资产
cfg
:=
a
.
api
.
GetConfig
()
isPara
:=
cfg
.
IsPara
()
isPara
:=
cfg
.
IsPara
()
if
!
isPara
{
if
!
isPara
{
err
:=
a
.
assetWithdrawMainCheck
(
cfg
,
withdraw
)
if
err
!=
nil
{
return
nil
,
err
}
}
if
!
isPara
{
// 需要平行链先执行, 达成共识时,继续执行
// 需要平行链先执行, 达成共识时,继续执行
return
nil
,
nil
return
nil
,
nil
}
}
...
@@ -1056,27 +1076,42 @@ func (a *action) AssetWithdraw(withdraw *types.AssetsWithdraw) (*types.Receipt,
...
@@ -1056,27 +1076,42 @@ func (a *action) AssetWithdraw(withdraw *types.AssetsWithdraw) (*types.Receipt,
return
receipt
,
nil
return
receipt
,
nil
}
}
func
(
a
*
action
)
CrossAssetTransfer
(
transfer
*
pt
.
CrossAssetTransfer
)
(
*
types
.
Receipt
,
error
)
{
func
(
a
*
action
)
crossAssetTransferMainCheck
(
transfer
*
pt
.
CrossAssetTransfer
)
error
{
clog
.
Debug
(
"Paracross.CrossAssetTransfer"
,
"exec"
,
transfer
.
AssetExec
,
"symbol"
,
transfer
.
AssetSymbol
)
cfg
:=
a
.
api
.
GetConfig
()
isPara
:=
cfg
.
IsPara
()
err
:=
a
.
isAllowTransfer
()
err
:=
a
.
isAllowTransfer
()
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
errors
.
Wrap
(
err
,
"CrossAssetTransfer
not Allow"
)
return
errors
.
Wrap
(
err
,
"
not Allow"
)
}
}
if
len
(
transfer
.
AssetExec
)
==
0
||
len
(
transfer
.
AssetSymbol
)
==
0
||
transfer
.
Amount
==
0
{
if
len
(
transfer
.
AssetExec
)
==
0
||
len
(
transfer
.
AssetSymbol
)
==
0
||
transfer
.
Amount
==
0
{
return
nil
,
errors
.
Wrapf
(
types
.
ErrInvalidParam
,
"CrossAssetTransfer
exec=%s, symbol=%s, amount=%d should not be null"
,
return
errors
.
Wrapf
(
types
.
ErrInvalidParam
,
"
exec=%s, symbol=%s, amount=%d should not be null"
,
transfer
.
AssetExec
,
transfer
.
AssetSymbol
,
transfer
.
Amount
)
transfer
.
AssetExec
,
transfer
.
AssetSymbol
,
transfer
.
Amount
)
}
}
return
nil
}
func
(
a
*
action
)
CrossAssetTransfer
(
transfer
*
pt
.
CrossAssetTransfer
)
(
*
types
.
Receipt
,
error
)
{
cfg
:=
a
.
api
.
GetConfig
()
isPara
:=
cfg
.
IsPara
()
//主链检查参数
if
!
isPara
{
err
:=
a
.
crossAssetTransferMainCheck
(
transfer
)
if
err
!=
nil
{
return
nil
,
err
}
}
//平行链在ForkRootHash之前不支持crossAssetTransfer
if
isPara
&&
!
cfg
.
IsFork
(
a
.
exec
.
GetMainHeight
(),
"ForkRootHash"
)
{
return
nil
,
errors
.
Wrap
(
types
.
ErrNotSupport
,
"not Allow before ForkRootHash"
)
}
if
len
(
transfer
.
ToAddr
)
==
0
{
if
len
(
transfer
.
ToAddr
)
==
0
{
transfer
.
ToAddr
=
a
.
tx
.
From
()
transfer
.
ToAddr
=
a
.
tx
.
From
()
}
}
act
,
err
:=
getCrossAction
(
transfer
,
string
(
a
.
tx
.
Execer
))
act
,
err
:=
getCrossAction
(
transfer
,
string
(
a
.
tx
.
Execer
))
if
act
==
pt
.
ParacrossNoneTransfer
{
if
act
==
pt
.
ParacrossNoneTransfer
{
return
nil
,
errors
.
Wrap
(
err
,
"
CrossAssetTransfer
non action"
)
return
nil
,
errors
.
Wrap
(
err
,
"non action"
)
}
}
// 需要平行链先执行, 达成共识时,继续执行
// 需要平行链先执行, 达成共识时,继续执行
if
!
isPara
&&
(
act
==
pt
.
ParacrossMainAssetWithdraw
||
act
==
pt
.
ParacrossParaAssetTransfer
)
{
if
!
isPara
&&
(
act
==
pt
.
ParacrossMainAssetWithdraw
||
act
==
pt
.
ParacrossParaAssetTransfer
)
{
...
@@ -1158,16 +1193,16 @@ func getTitleFrom(exec []byte) ([]byte, error) {
...
@@ -1158,16 +1193,16 @@ func getTitleFrom(exec []byte) ([]byte, error) {
func
(
a
*
action
)
isAllowTransfer
()
error
{
func
(
a
*
action
)
isAllowTransfer
()
error
{
//1. 没有配置nodegroup 不允许
//1. 没有配置nodegroup 不允许
t
it
,
err
:=
getTitleFrom
(
a
.
tx
.
Execer
)
t
empTitle
,
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
,
"not para chain exec=%s"
,
string
(
a
.
tx
.
Execer
))
}
}
nodes
,
err
:=
a
.
getNodesGroup
(
string
(
t
it
))
nodes
,
err
:=
a
.
getNodesGroup
(
string
(
t
empTitle
))
if
err
!=
nil
{
if
err
!=
nil
{
return
errors
.
Wrapf
(
err
,
"
CrossAssetTransfer get nodegroup err,title=%s"
,
tit
)
return
errors
.
Wrapf
(
err
,
"
nodegroup not config,title=%s"
,
tempTitle
)
}
}
if
len
(
nodes
)
==
0
{
if
len
(
nodes
)
==
0
{
return
errors
.
Wrapf
(
err
,
"CrossAssetTransfer nodegroup not create,title=%s"
,
tit
)
return
errors
.
Wrapf
(
types
.
ErrNotSupport
,
"nodegroup not create,title=%s"
,
tempTitle
)
}
}
//2. 非跨链执行器不允许
//2. 非跨链执行器不允许
if
!
types
.
IsParaExecName
(
string
(
a
.
tx
.
Execer
))
{
if
!
types
.
IsParaExecName
(
string
(
a
.
tx
.
Execer
))
{
...
...
plugin/dapp/paracross/executor/exec.go
View file @
c6e251dc
...
@@ -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/paracross.go
View file @
c6e251dc
...
@@ -328,6 +328,8 @@ func (c *Paracross) allow(tx *types.Transaction, index int) error {
...
@@ -328,6 +328,8 @@ func (c *Paracross) allow(tx *types.Transaction, index int) error {
if
payload
.
Ty
==
pt
.
ParacrossActionAssetTransfer
||
payload
.
Ty
==
pt
.
ParacrossActionAssetWithdraw
{
if
payload
.
Ty
==
pt
.
ParacrossActionAssetTransfer
||
payload
.
Ty
==
pt
.
ParacrossActionAssetWithdraw
{
return
nil
return
nil
}
}
//对一些跨链的新feature,主链分叉之前不允许执行,但会走none执行器,因为分叉之前的版本就是走none执行器
//然后会被过滤到平行链,最好在分叉前控制主链不发送相关交易,要么设置系统统一的fork比如ForkRootHash,主链和平行链都可以阻止执行,
if
cfg
.
IsDappFork
(
c
.
GetHeight
(),
pt
.
ParaX
,
pt
.
ForkCommitTx
)
{
if
cfg
.
IsDappFork
(
c
.
GetHeight
(),
pt
.
ParaX
,
pt
.
ForkCommitTx
)
{
if
payload
.
Ty
==
pt
.
ParacrossActionCommit
||
payload
.
Ty
==
pt
.
ParacrossActionNodeConfig
||
if
payload
.
Ty
==
pt
.
ParacrossActionCommit
||
payload
.
Ty
==
pt
.
ParacrossActionNodeConfig
||
payload
.
Ty
==
pt
.
ParacrossActionNodeGroupApply
{
payload
.
Ty
==
pt
.
ParacrossActionNodeGroupApply
{
...
...
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