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
721cfedf
Commit
721cfedf
authored
Jul 05, 2019
by
mdj33
Committed by
vipwzw
Jul 11, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cut commit status parameter
parent
5be6fba4
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
146 additions
and
104 deletions
+146
-104
para.go
plugin/consensus/para/para.go
+5
-2
paracommitmsg.go
plugin/consensus/para/paracommitmsg.go
+6
-4
action.go
plugin/dapp/paracross/executor/action.go
+85
-76
exec_local.go
plugin/dapp/paracross/executor/exec_local.go
+10
-8
filtertxs.go
plugin/dapp/paracross/executor/filtertxs.go
+1
-1
paracross.go
plugin/dapp/paracross/executor/paracross.go
+0
-3
query.go
plugin/dapp/paracross/executor/query.go
+0
-4
superaccount.go
plugin/dapp/paracross/executor/superaccount.go
+1
-1
paracross.proto
plugin/dapp/paracross/proto/paracross.proto
+3
-5
paracross.go
plugin/dapp/paracross/types/paracross.go
+35
-0
No files found.
plugin/consensus/para/para.go
View file @
721cfedf
...
@@ -687,12 +687,15 @@ func (client *client) addMinerTx(preStateHash []byte, block *types.Block, main *
...
@@ -687,12 +687,15 @@ func (client *client) addMinerTx(preStateHash []byte, block *types.Block, main *
status
:=
&
pt
.
ParacrossNodeStatus
{
status
:=
&
pt
.
ParacrossNodeStatus
{
Title
:
types
.
GetTitle
(),
Title
:
types
.
GetTitle
(),
Height
:
block
.
Height
,
Height
:
block
.
Height
,
PreBlockHash
:
block
.
ParentHash
,
PreStateHash
:
preStateHash
,
MainBlockHash
:
main
.
Seq
.
Hash
,
MainBlockHash
:
main
.
Seq
.
Hash
,
MainBlockHeight
:
main
.
Detail
.
Block
.
Height
,
MainBlockHeight
:
main
.
Detail
.
Block
.
Height
,
}
}
if
!
paracross
.
IsParaForkHeight
(
status
.
MainBlockHeight
,
pt
.
ForkLoopCheckCommitTxDone
)
{
status
.
PreBlockHash
=
block
.
ParentHash
status
.
PreStateHash
=
preStateHash
}
tx
,
err
:=
pt
.
CreateRawMinerTx
(
&
pt
.
ParacrossMinerAction
{
tx
,
err
:=
pt
.
CreateRawMinerTx
(
&
pt
.
ParacrossMinerAction
{
Status
:
status
,
Status
:
status
,
IsSelfConsensus
:
isParaSelfConsensusForked
(
status
.
MainBlockHeight
),
IsSelfConsensus
:
isParaSelfConsensusForked
(
status
.
MainBlockHeight
),
...
...
plugin/consensus/para/paracommitmsg.go
View file @
721cfedf
...
@@ -445,7 +445,6 @@ func (client *commitMsgClient) getNodeStatus(start, end int64) ([]*pt.ParacrossN
...
@@ -445,7 +445,6 @@ func (client *commitMsgClient) getNodeStatus(start, end int64) ([]*pt.ParacrossN
return
nil
,
errors
.
New
(
"paracommitmsg wrong block result"
)
return
nil
,
errors
.
New
(
"paracommitmsg wrong block result"
)
}
}
nodeList
[
block
.
Block
.
Height
]
.
BlockHash
=
block
.
Block
.
Hash
()
nodeList
[
block
.
Block
.
Height
]
.
BlockHash
=
block
.
Block
.
Hash
()
nodeList
[
block
.
Block
.
Height
]
.
StateHash
=
block
.
Block
.
StateHash
}
}
var
needSentTxs
uint32
var
needSentTxs
uint32
...
@@ -462,6 +461,11 @@ func (client *commitMsgClient) getNodeStatus(start, end int64) ([]*pt.ParacrossN
...
@@ -462,6 +461,11 @@ func (client *commitMsgClient) getNodeStatus(start, end int64) ([]*pt.ParacrossN
return
nil
,
nil
return
nil
,
nil
}
}
//clear flag
for
_
,
v
:=
range
ret
{
v
.
NonCommitTxCounts
=
0
}
return
ret
,
nil
return
ret
,
nil
}
}
...
@@ -479,10 +483,8 @@ func (client *commitMsgClient) getGenesisNodeStatus() (*pt.ParacrossNodeStatus,
...
@@ -479,10 +483,8 @@ func (client *commitMsgClient) getGenesisNodeStatus() (*pt.ParacrossNodeStatus,
}
}
status
.
Title
=
types
.
GetTitle
()
status
.
Title
=
types
.
GetTitle
()
status
.
Height
=
block
.
Height
status
.
Height
=
block
.
Height
status
.
PreBlockHash
=
zeroHash
[
:
]
status
.
BlockHash
=
block
.
Hash
()
status
.
BlockHash
=
block
.
Hash
()
status
.
PreStateHash
=
zeroHash
[
:
]
status
.
StateHash
=
block
.
StateHash
return
&
status
,
nil
return
&
status
,
nil
}
}
...
...
plugin/dapp/paracross/executor/action.go
View file @
721cfedf
...
@@ -100,8 +100,22 @@ func checkCommitInfo(commit *pt.ParacrossCommitAction) error {
...
@@ -100,8 +100,22 @@ func checkCommitInfo(commit *pt.ParacrossCommitAction) error {
return
types
.
ErrInvalidParam
return
types
.
ErrInvalidParam
}
}
clog
.
Debug
(
"paracross.Commit check input"
,
"height"
,
commit
.
Status
.
Height
,
"mainHeight"
,
commit
.
Status
.
MainBlockHeight
,
clog
.
Debug
(
"paracross.Commit check input"
,
"height"
,
commit
.
Status
.
Height
,
"mainHeight"
,
commit
.
Status
.
MainBlockHeight
,
"mainHash"
,
hex
.
EncodeToString
(
commit
.
Status
.
MainBlockHash
),
"blockHash"
,
hex
.
EncodeToString
(
commit
.
Status
.
BlockHash
),
"mainHash"
,
hex
.
EncodeToString
(
commit
.
Status
.
MainBlockHash
),
"blockHash"
,
hex
.
EncodeToString
(
commit
.
Status
.
BlockHash
))
"preBlockHash"
,
hex
.
EncodeToString
(
commit
.
Status
.
PreBlockHash
))
if
!
pt
.
IsParaForkHeight
(
commit
.
Status
.
MainBlockHeight
,
pt
.
ForkLoopCheckCommitTxDone
)
{
if
commit
.
Status
.
Height
==
0
{
if
len
(
commit
.
Status
.
Title
)
==
0
||
len
(
commit
.
Status
.
BlockHash
)
==
0
{
return
types
.
ErrInvalidParam
}
return
nil
}
if
len
(
commit
.
Status
.
MainBlockHash
)
==
0
||
len
(
commit
.
Status
.
Title
)
==
0
||
commit
.
Status
.
Height
<
0
||
len
(
commit
.
Status
.
PreBlockHash
)
==
0
||
len
(
commit
.
Status
.
BlockHash
)
==
0
||
len
(
commit
.
Status
.
StateHash
)
==
0
||
len
(
commit
.
Status
.
PreStateHash
)
==
0
{
return
types
.
ErrInvalidParam
}
return
nil
}
if
commit
.
Status
.
Height
==
0
{
if
commit
.
Status
.
Height
==
0
{
if
len
(
commit
.
Status
.
Title
)
==
0
||
len
(
commit
.
Status
.
BlockHash
)
==
0
{
if
len
(
commit
.
Status
.
Title
)
==
0
||
len
(
commit
.
Status
.
BlockHash
)
==
0
{
...
@@ -109,9 +123,7 @@ func checkCommitInfo(commit *pt.ParacrossCommitAction) error {
...
@@ -109,9 +123,7 @@ func checkCommitInfo(commit *pt.ParacrossCommitAction) error {
}
}
return
nil
return
nil
}
}
if
len
(
commit
.
Status
.
MainBlockHash
)
==
0
||
len
(
commit
.
Status
.
Title
)
==
0
||
commit
.
Status
.
Height
<
0
||
if
len
(
commit
.
Status
.
MainBlockHash
)
==
0
||
commit
.
Status
.
Height
<
0
||
len
(
commit
.
Status
.
BlockHash
)
==
0
{
len
(
commit
.
Status
.
PreBlockHash
)
==
0
||
len
(
commit
.
Status
.
BlockHash
)
==
0
||
len
(
commit
.
Status
.
StateHash
)
==
0
||
len
(
commit
.
Status
.
PreStateHash
)
==
0
{
return
types
.
ErrInvalidParam
return
types
.
ErrInvalidParam
}
}
...
@@ -182,13 +194,8 @@ func makeDoneReceipt(execMainHeight int64, commit *pt.ParacrossNodeStatus,
...
@@ -182,13 +194,8 @@ func makeDoneReceipt(execMainHeight int64, commit *pt.ParacrossNodeStatus,
MostSameCommit
:
most
,
MostSameCommit
:
most
,
Title
:
commit
.
Title
,
Title
:
commit
.
Title
,
Height
:
commit
.
Height
,
Height
:
commit
.
Height
,
StateHash
:
commit
.
StateHash
,
BlockHash
:
commit
.
BlockHash
,
BlockHash
:
commit
.
BlockHash
,
TxCounts
:
commit
.
TxCounts
,
TxResult
:
commit
.
TxResult
,
TxResult
:
commit
.
TxResult
,
TxHashs
:
commit
.
TxHashs
,
CrossTxHashs
:
commit
.
CrossTxHashs
,
CrossTxResult
:
commit
.
CrossTxResult
,
MainBlockHeight
:
commit
.
MainBlockHeight
,
MainBlockHeight
:
commit
.
MainBlockHeight
,
MainBlockHash
:
commit
.
MainBlockHash
,
MainBlockHash
:
commit
.
MainBlockHash
,
}
}
...
@@ -198,7 +205,7 @@ func makeDoneReceipt(execMainHeight int64, commit *pt.ParacrossNodeStatus,
...
@@ -198,7 +205,7 @@ func makeDoneReceipt(execMainHeight int64, commit *pt.ParacrossNodeStatus,
Height
:
commit
.
Height
,
Height
:
commit
.
Height
,
BlockHash
:
commit
.
BlockHash
,
BlockHash
:
commit
.
BlockHash
,
}
}
if
execMainHeight
>=
g
etDappForkHeight
(
pt
.
ForkLoopCheckCommitTxDone
)
{
if
execMainHeight
>=
pt
.
G
etDappForkHeight
(
pt
.
ForkLoopCheckCommitTxDone
)
{
status
.
MainHeight
=
commit
.
MainBlockHeight
status
.
MainHeight
=
commit
.
MainBlockHeight
status
.
MainHash
=
commit
.
MainBlockHash
status
.
MainHash
=
commit
.
MainBlockHash
}
}
...
@@ -238,13 +245,13 @@ func getMostCommit(stat *pt.ParacrossHeightStatus) (int, string) {
...
@@ -238,13 +245,13 @@ func getMostCommit(stat *pt.ParacrossHeightStatus) (int, string) {
}
}
//需要在ForkLoopCheckCommitTxDone后使用
//需要在ForkLoopCheckCommitTxDone后使用
func
getMostResults
(
mostHash
[]
byte
,
stat
*
pt
.
ParacrossHeightStatus
)
([]
byte
,
[]
byte
,
[]
byte
,
[]
byte
,
[]
byte
)
{
func
getMostResults
(
mostHash
[]
byte
,
stat
*
pt
.
ParacrossHeightStatus
)
[]
byte
{
for
i
,
hash
:=
range
stat
.
BlockDetails
.
BlockHashs
{
for
i
,
hash
:=
range
stat
.
BlockDetails
.
BlockHashs
{
if
bytes
.
Equal
(
mostHash
,
hash
)
{
if
bytes
.
Equal
(
mostHash
,
hash
)
{
return
stat
.
BlockDetails
.
StateHashs
[
i
],
stat
.
BlockDetails
.
TxResults
[
i
],
stat
.
BlockDetails
.
TxHashs
[
i
],
stat
.
BlockDetails
.
CrossTxResults
[
i
],
stat
.
BlockDetails
.
CrossTxHash
s
[
i
]
return
stat
.
BlockDetails
.
TxResult
s
[
i
]
}
}
}
}
return
nil
,
nil
,
nil
,
nil
,
nil
return
nil
}
}
func
hasCommited
(
addrs
[]
string
,
addr
string
)
(
bool
,
int
)
{
func
hasCommited
(
addrs
[]
string
,
addr
string
)
(
bool
,
int
)
{
...
@@ -256,41 +263,6 @@ func hasCommited(addrs []string, addr string) (bool, int) {
...
@@ -256,41 +263,6 @@ func hasCommited(addrs []string, addr string) (bool, int) {
return
false
,
0
return
false
,
0
}
}
func
getDappForkHeight
(
forkKey
string
)
int64
{
var
forkHeight
int64
if
types
.
IsPara
()
{
key
:=
forkKey
switch
forkKey
{
case
pt
.
ForkCommitTx
:
key
=
pt
.
MainForkParacrossCommitTx
case
pt
.
ForkLoopCheckCommitTxDone
:
key
=
pt
.
MainLoopCheckCommitTxDoneForkHeight
}
forkHeight
=
types
.
Conf
(
"config.consensus.sub.para"
)
.
GInt
(
key
)
if
forkHeight
<=
0
{
forkHeight
=
types
.
MaxHeight
}
}
else
{
forkHeight
=
types
.
GetDappFork
(
pt
.
ParaX
,
forkKey
)
// CI特殊处理,主链是local,fork都是0,平行链有些配置项需要设置为非0,不然获取到的高度为MaxHeight
if
types
.
IsLocal
()
{
switch
forkKey
{
case
pt
.
ForkCommitTx
:
forkHeight
=
10
case
pt
.
ForkLoopCheckCommitTxDone
:
forkHeight
=
60
}
}
}
return
forkHeight
}
func
isParaForkHeight
(
height
int64
,
forkKey
string
)
bool
{
return
height
>=
getDappForkHeight
(
forkKey
)
}
func
getConfigNodes
(
db
dbm
.
KV
,
title
string
)
(
map
[
string
]
struct
{},
[]
byte
,
error
)
{
func
getConfigNodes
(
db
dbm
.
KV
,
title
string
)
(
map
[
string
]
struct
{},
[]
byte
,
error
)
{
key
:=
calcParaNodeGroupAddrsKey
(
title
)
key
:=
calcParaNodeGroupAddrsKey
(
title
)
nodes
,
_
,
err
:=
getNodes
(
db
,
key
)
nodes
,
_
,
err
:=
getNodes
(
db
,
key
)
...
@@ -309,7 +281,7 @@ func getConfigNodes(db dbm.KV, title string) (map[string]struct{}, []byte, error
...
@@ -309,7 +281,7 @@ func getConfigNodes(db dbm.KV, title string) (map[string]struct{}, []byte, error
}
}
func
(
a
*
action
)
getNodesGroup
(
title
string
)
(
map
[
string
]
struct
{},
error
)
{
func
(
a
*
action
)
getNodesGroup
(
title
string
)
(
map
[
string
]
struct
{},
error
)
{
if
a
.
exec
.
GetMainHeight
()
<
g
etDappForkHeight
(
pt
.
ForkCommitTx
)
{
if
a
.
exec
.
GetMainHeight
()
<
pt
.
G
etDappForkHeight
(
pt
.
ForkCommitTx
)
{
nodes
,
_
,
err
:=
getConfigManageNodes
(
a
.
db
,
title
)
nodes
,
_
,
err
:=
getConfigManageNodes
(
a
.
db
,
title
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
errors
.
Wrapf
(
err
,
"getNodes for title:%s"
,
title
)
return
nil
,
errors
.
Wrapf
(
err
,
"getNodes for title:%s"
,
title
)
...
@@ -330,11 +302,8 @@ func updateCommitBlockHashs(stat *pt.ParacrossHeightStatus, commit *pt.Paracross
...
@@ -330,11 +302,8 @@ func updateCommitBlockHashs(stat *pt.ParacrossHeightStatus, commit *pt.Paracross
}
}
}
}
stat
.
BlockDetails
.
BlockHashs
=
append
(
stat
.
BlockDetails
.
BlockHashs
,
commit
.
BlockHash
)
stat
.
BlockDetails
.
BlockHashs
=
append
(
stat
.
BlockDetails
.
BlockHashs
,
commit
.
BlockHash
)
stat
.
BlockDetails
.
StateHashs
=
append
(
stat
.
BlockDetails
.
StateHashs
,
commit
.
StateHash
)
stat
.
BlockDetails
.
TxResults
=
append
(
stat
.
BlockDetails
.
TxResults
,
commit
.
TxResult
)
stat
.
BlockDetails
.
TxResults
=
append
(
stat
.
BlockDetails
.
TxResults
,
commit
.
TxResult
)
stat
.
BlockDetails
.
TxHashs
=
append
(
stat
.
BlockDetails
.
TxHashs
,
commit
.
TxHashs
[
0
])
stat
.
BlockDetails
.
CrossTxResults
=
append
(
stat
.
BlockDetails
.
CrossTxResults
,
commit
.
CrossTxResult
)
stat
.
BlockDetails
.
CrossTxHashs
=
append
(
stat
.
BlockDetails
.
CrossTxHashs
,
commit
.
CrossTxHashs
[
0
])
}
}
//根据nodes过滤掉可能退出了的addrs
//根据nodes过滤掉可能退出了的addrs
...
@@ -374,7 +343,7 @@ func (a *action) Commit(commit *pt.ParacrossCommitAction) (*types.Receipt, error
...
@@ -374,7 +343,7 @@ func (a *action) Commit(commit *pt.ParacrossCommitAction) (*types.Receipt, error
return
nil
,
errors
.
Wrapf
(
err
,
"getTitle:%s"
,
a
.
fromaddr
)
return
nil
,
errors
.
Wrapf
(
err
,
"getTitle:%s"
,
a
.
fromaddr
)
}
}
if
titleStatus
.
Height
+
1
==
commit
.
Status
.
Height
&&
commit
.
Status
.
Height
>
0
{
if
titleStatus
.
Height
+
1
==
commit
.
Status
.
Height
&&
commit
.
Status
.
Height
>
0
&&
!
pt
.
IsParaForkHeight
(
commit
.
Status
.
MainBlockHeight
,
pt
.
ForkLoopCheckCommitTxDone
)
{
if
!
bytes
.
Equal
(
titleStatus
.
BlockHash
,
commit
.
Status
.
PreBlockHash
)
{
if
!
bytes
.
Equal
(
titleStatus
.
BlockHash
,
commit
.
Status
.
PreBlockHash
)
{
clog
.
Error
(
"paracross.Commit"
,
"check PreBlockHash"
,
hex
.
EncodeToString
(
titleStatus
.
BlockHash
),
clog
.
Error
(
"paracross.Commit"
,
"check PreBlockHash"
,
hex
.
EncodeToString
(
titleStatus
.
BlockHash
),
"commit tx"
,
hex
.
EncodeToString
(
commit
.
Status
.
PreBlockHash
),
"commitheit"
,
commit
.
Status
.
Height
,
"commit tx"
,
hex
.
EncodeToString
(
commit
.
Status
.
PreBlockHash
),
"commitheit"
,
commit
.
Status
.
Height
,
...
@@ -431,13 +400,13 @@ func (a *action) Commit(commit *pt.ParacrossCommitAction) (*types.Receipt, error
...
@@ -431,13 +400,13 @@ func (a *action) Commit(commit *pt.ParacrossCommitAction) (*types.Receipt, error
BlockHash
:
[][]
byte
{
commit
.
Status
.
BlockHash
},
BlockHash
:
[][]
byte
{
commit
.
Status
.
BlockHash
},
},
},
}
}
if
i
sParaForkHeight
(
a
.
exec
.
GetMainHeight
(),
pt
.
ForkCommitTx
)
{
if
pt
.
I
sParaForkHeight
(
a
.
exec
.
GetMainHeight
(),
pt
.
ForkCommitTx
)
{
stat
.
MainHeight
=
commit
.
Status
.
MainBlockHeight
stat
.
MainHeight
=
commit
.
Status
.
MainBlockHeight
stat
.
MainHash
=
commit
.
Status
.
MainBlockHash
stat
.
MainHash
=
commit
.
Status
.
MainBlockHash
}
}
//用commit.MainBlockHeight 判断更准确,如果用a.exec.MainHeight也可以,但是可能收到MainHeight之前的高度共识tx,
//用commit.MainBlockHeight 判断更准确,如果用a.exec.MainHeight也可以,但是可能收到MainHeight之前的高度共识tx,
// 后面loopCommitTxDone时候也是用当前共识高度大于分叉高度判断
// 后面loopCommitTxDone时候也是用当前共识高度大于分叉高度判断
if
i
sParaForkHeight
(
commit
.
Status
.
MainBlockHeight
,
pt
.
ForkLoopCheckCommitTxDone
)
{
if
pt
.
I
sParaForkHeight
(
commit
.
Status
.
MainBlockHeight
,
pt
.
ForkLoopCheckCommitTxDone
)
{
stat
.
BlockDetails
=
&
pt
.
ParacrossStatusBlockDetails
{}
stat
.
BlockDetails
=
&
pt
.
ParacrossStatusBlockDetails
{}
updateCommitBlockHashs
(
stat
,
commit
.
Status
)
updateCommitBlockHashs
(
stat
,
commit
.
Status
)
}
}
...
@@ -454,13 +423,13 @@ func (a *action) Commit(commit *pt.ParacrossCommitAction) (*types.Receipt, error
...
@@ -454,13 +423,13 @@ func (a *action) Commit(commit *pt.ParacrossCommitAction) (*types.Receipt, error
found
,
index
:=
hasCommited
(
stat
.
Details
.
Addrs
,
a
.
fromaddr
)
found
,
index
:=
hasCommited
(
stat
.
Details
.
Addrs
,
a
.
fromaddr
)
if
found
{
if
found
{
stat
.
Details
.
BlockHash
[
index
]
=
commit
.
Status
.
BlockHash
stat
.
Details
.
BlockHash
[
index
]
=
commit
.
Status
.
BlockHash
if
i
sParaForkHeight
(
commit
.
Status
.
MainBlockHeight
,
pt
.
ForkLoopCheckCommitTxDone
)
{
if
pt
.
I
sParaForkHeight
(
commit
.
Status
.
MainBlockHeight
,
pt
.
ForkLoopCheckCommitTxDone
)
{
updateCommitBlockHashs
(
stat
,
commit
.
Status
)
updateCommitBlockHashs
(
stat
,
commit
.
Status
)
}
}
}
else
{
}
else
{
stat
.
Details
.
Addrs
=
append
(
stat
.
Details
.
Addrs
,
a
.
fromaddr
)
stat
.
Details
.
Addrs
=
append
(
stat
.
Details
.
Addrs
,
a
.
fromaddr
)
stat
.
Details
.
BlockHash
=
append
(
stat
.
Details
.
BlockHash
,
commit
.
Status
.
BlockHash
)
stat
.
Details
.
BlockHash
=
append
(
stat
.
Details
.
BlockHash
,
commit
.
Status
.
BlockHash
)
if
i
sParaForkHeight
(
commit
.
Status
.
MainBlockHeight
,
pt
.
ForkLoopCheckCommitTxDone
)
{
if
pt
.
I
sParaForkHeight
(
commit
.
Status
.
MainBlockHeight
,
pt
.
ForkLoopCheckCommitTxDone
)
{
updateCommitBlockHashs
(
stat
,
commit
.
Status
)
updateCommitBlockHashs
(
stat
,
commit
.
Status
)
}
}
}
}
...
@@ -473,7 +442,7 @@ func (a *action) Commit(commit *pt.ParacrossCommitAction) (*types.Receipt, error
...
@@ -473,7 +442,7 @@ func (a *action) Commit(commit *pt.ParacrossCommitAction) (*types.Receipt, error
}
}
saveTitleHeight
(
a
.
db
,
calcTitleHeightKey
(
stat
.
Title
,
stat
.
Height
),
stat
)
saveTitleHeight
(
a
.
db
,
calcTitleHeightKey
(
stat
.
Title
,
stat
.
Height
),
stat
)
//fork之前记录的stat 没有根据nodes更新而更新
//fork之前记录的stat 没有根据nodes更新而更新
if
i
sParaForkHeight
(
stat
.
MainHeight
,
pt
.
ForkLoopCheckCommitTxDone
)
{
if
pt
.
I
sParaForkHeight
(
stat
.
MainHeight
,
pt
.
ForkLoopCheckCommitTxDone
)
{
r
:=
makeCommitStatReceipt
(
stat
)
r
:=
makeCommitStatReceipt
(
stat
)
receipt
=
mergeReceipt
(
receipt
,
r
)
receipt
=
mergeReceipt
(
receipt
,
r
)
}
}
...
@@ -517,7 +486,7 @@ func (a *action) commitTxDone(nodeStatus *pt.ParacrossNodeStatus, stat *pt.Parac
...
@@ -517,7 +486,7 @@ func (a *action) commitTxDone(nodeStatus *pt.ParacrossNodeStatus, stat *pt.Parac
saveTitleHeight
(
a
.
db
,
calcTitleHeightKey
(
stat
.
Title
,
stat
.
Height
),
stat
)
saveTitleHeight
(
a
.
db
,
calcTitleHeightKey
(
stat
.
Title
,
stat
.
Height
),
stat
)
//之前记录的stat 状态没更新
//之前记录的stat 状态没更新
if
i
sParaForkHeight
(
stat
.
MainHeight
,
pt
.
ForkLoopCheckCommitTxDone
)
{
if
pt
.
I
sParaForkHeight
(
stat
.
MainHeight
,
pt
.
ForkLoopCheckCommitTxDone
)
{
r
:=
makeCommitStatReceipt
(
stat
)
r
:=
makeCommitStatReceipt
(
stat
)
receipt
=
mergeReceipt
(
receipt
,
r
)
receipt
=
mergeReceipt
(
receipt
,
r
)
}
}
...
@@ -540,7 +509,7 @@ func (a *action) commitTxDoneStep2(nodeStatus *pt.ParacrossNodeStatus, stat *pt.
...
@@ -540,7 +509,7 @@ func (a *action) commitTxDoneStep2(nodeStatus *pt.ParacrossNodeStatus, stat *pt.
titleStatus
.
Title
=
nodeStatus
.
Title
titleStatus
.
Title
=
nodeStatus
.
Title
titleStatus
.
Height
=
nodeStatus
.
Height
titleStatus
.
Height
=
nodeStatus
.
Height
titleStatus
.
BlockHash
=
nodeStatus
.
BlockHash
titleStatus
.
BlockHash
=
nodeStatus
.
BlockHash
if
i
sParaForkHeight
(
a
.
exec
.
GetMainHeight
(),
pt
.
ForkLoopCheckCommitTxDone
)
{
if
pt
.
I
sParaForkHeight
(
a
.
exec
.
GetMainHeight
(),
pt
.
ForkLoopCheckCommitTxDone
)
{
titleStatus
.
MainHeight
=
nodeStatus
.
MainBlockHeight
titleStatus
.
MainHeight
=
nodeStatus
.
MainBlockHeight
titleStatus
.
MainHash
=
nodeStatus
.
MainBlockHash
titleStatus
.
MainHash
=
nodeStatus
.
MainBlockHash
}
}
...
@@ -571,14 +540,24 @@ func (a *action) commitTxDoneStep2(nodeStatus *pt.ParacrossNodeStatus, stat *pt.
...
@@ -571,14 +540,24 @@ func (a *action) commitTxDoneStep2(nodeStatus *pt.ParacrossNodeStatus, stat *pt.
return
receipt
,
nil
return
receipt
,
nil
}
}
func
(
a
*
action
)
procCrossTxs
(
status
*
pt
.
ParacrossNodeStatus
)
(
*
types
.
Receipt
,
error
)
{
func
isHaveCrossTxs
(
status
*
pt
.
ParacrossNodeStatus
)
bool
{
//ForkLoopCheckCommitTxDone分叉后只返回全部txResult的结果,要实际过滤出来后才能确定有没有跨链tx
if
pt
.
IsParaForkHeight
(
status
.
MainBlockHeight
,
pt
.
ForkLoopCheckCommitTxDone
)
{
return
true
}
haveCrossTxs
:=
len
(
status
.
CrossTxHashs
)
>
0
haveCrossTxs
:=
len
(
status
.
CrossTxHashs
)
>
0
if
status
.
Height
>
0
&&
isParaForkHeight
(
status
.
MainBlockHeight
,
pt
.
ForkCommitTx
)
&&
len
(
status
.
CrossTxHashs
[
0
])
==
0
{
//ForkCommitTx后,CrossTxHashs[][] 所有跨链交易做成一个校验hash,如果没有则[0]为nil
if
status
.
Height
>
0
&&
pt
.
IsParaForkHeight
(
status
.
MainBlockHeight
,
pt
.
ForkCommitTx
)
&&
len
(
status
.
CrossTxHashs
[
0
])
==
0
{
haveCrossTxs
=
false
haveCrossTxs
=
false
}
}
return
haveCrossTxs
}
if
enableParacrossTransfer
&&
status
.
Height
>
0
&&
haveCrossTxs
{
func
(
a
*
action
)
procCrossTxs
(
status
*
pt
.
ParacrossNodeStatus
)
(
*
types
.
Receipt
,
error
)
{
clog
.
Debug
(
"paracross.Commit commitDone do cross"
,
"height"
,
status
.
Height
,
"havecross"
,
haveCrossTxs
)
if
enableParacrossTransfer
&&
status
.
Height
>
0
&&
isHaveCrossTxs
(
status
)
{
clog
.
Debug
(
"paracross.Commit commitDone do cross"
,
"height"
,
status
.
Height
)
crossTxReceipt
,
err
:=
a
.
execCrossTxs
(
status
)
crossTxReceipt
,
err
:=
a
.
execCrossTxs
(
status
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
...
@@ -602,9 +581,9 @@ func (a *action) loopCommitTxDone(title string) (*types.Receipt, error) {
...
@@ -602,9 +581,9 @@ func (a *action) loopCommitTxDone(title string) (*types.Receipt, error) {
return
nil
,
errors
.
Wrapf
(
err
,
"getTitle:%s"
,
title
)
return
nil
,
errors
.
Wrapf
(
err
,
"getTitle:%s"
,
title
)
}
}
//当前共识高度还未到分叉高度,则不处理
//当前共识高度还未到分叉高度,则不处理
if
!
i
sParaForkHeight
(
titleStatus
.
GetMainHeight
(),
pt
.
ForkLoopCheckCommitTxDone
)
{
if
!
pt
.
I
sParaForkHeight
(
titleStatus
.
GetMainHeight
(),
pt
.
ForkLoopCheckCommitTxDone
)
{
return
nil
,
errors
.
Wrapf
(
pt
.
ErrForkHeightNotReach
,
return
nil
,
errors
.
Wrapf
(
pt
.
ErrForkHeightNotReach
,
"titleHeight:%d,forkHeight:%d"
,
titleStatus
.
MainHeight
,
g
etDappForkHeight
(
pt
.
ForkLoopCheckCommitTxDone
))
"titleHeight:%d,forkHeight:%d"
,
titleStatus
.
MainHeight
,
pt
.
G
etDappForkHeight
(
pt
.
ForkLoopCheckCommitTxDone
))
}
}
loopHeight
:=
titleStatus
.
Height
loopHeight
:=
titleStatus
.
Height
...
@@ -670,18 +649,14 @@ func (a *action) commitTxDoneByStat(stat *pt.ParacrossHeightStatus, titleStatus
...
@@ -670,18 +649,14 @@ func (a *action) commitTxDoneByStat(stat *pt.ParacrossHeightStatus, titleStatus
r
:=
makeCommitStatReceipt
(
stat
)
r
:=
makeCommitStatReceipt
(
stat
)
receipt
=
mergeReceipt
(
receipt
,
r
)
receipt
=
mergeReceipt
(
receipt
,
r
)
stateHash
,
txRst
,
txHash
,
crossTxRst
,
crossTxHash
:=
getMostResults
([]
byte
(
mostHash
),
stat
)
txRst
:=
getMostResults
([]
byte
(
mostHash
),
stat
)
mostStatus
:=
&
pt
.
ParacrossNodeStatus
{
mostStatus
:=
&
pt
.
ParacrossNodeStatus
{
MainBlockHash
:
stat
.
MainHash
,
MainBlockHash
:
stat
.
MainHash
,
MainBlockHeight
:
stat
.
MainHeight
,
MainBlockHeight
:
stat
.
MainHeight
,
Title
:
stat
.
Title
,
Title
:
stat
.
Title
,
Height
:
stat
.
Height
,
Height
:
stat
.
Height
,
BlockHash
:
[]
byte
(
mostHash
),
BlockHash
:
[]
byte
(
mostHash
),
StateHash
:
stateHash
,
TxResult
:
txRst
,
TxResult
:
txRst
,
TxHashs
:
[][]
byte
{
txHash
},
CrossTxResult
:
crossTxRst
,
CrossTxHashs
:
[][]
byte
{
crossTxHash
},
}
}
//add commit done receipt
//add commit done receipt
...
@@ -707,7 +682,7 @@ func (a *action) isParaSelfConsensSwitch(commit *pt.ParacrossHeightStatus, title
...
@@ -707,7 +682,7 @@ func (a *action) isParaSelfConsensSwitch(commit *pt.ParacrossHeightStatus, title
return
true
,
nil
return
true
,
nil
}
}
selfConsensForkHeight
:=
g
etDappForkHeight
(
pt
.
ParaSelfConsensForkHeight
)
selfConsensForkHeight
:=
pt
.
G
etDappForkHeight
(
pt
.
ParaSelfConsensForkHeight
)
lastStatusMainHeight
:=
int64
(
-
1
)
lastStatusMainHeight
:=
int64
(
-
1
)
if
titleStatus
.
Height
>
-
1
{
if
titleStatus
.
Height
>
-
1
{
s
,
err
:=
getTitleHeight
(
a
.
db
,
calcTitleHeightKey
(
commit
.
Title
,
titleStatus
.
Height
))
s
,
err
:=
getTitleHeight
(
a
.
db
,
calcTitleHeightKey
(
commit
.
Title
,
titleStatus
.
Height
))
...
@@ -747,8 +722,42 @@ func (a *action) execCrossTx(tx *types.TransactionDetail, crossTxHash []byte) (*
...
@@ -747,8 +722,42 @@ func (a *action) execCrossTx(tx *types.TransactionDetail, crossTxHash []byte) (*
}
}
func
getCrossTxHashsByRst
(
api
client
.
QueueProtocolAPI
,
status
*
pt
.
ParacrossNodeStatus
)
([][]
byte
,
[]
byte
,
error
)
{
//只获取跨链tx
rst
,
err
:=
hex
.
DecodeString
(
string
(
status
.
TxResult
))
if
err
!=
nil
{
clog
.
Error
(
"getCrossTxHashs decode rst"
,
"CrossTxResult"
,
string
(
status
.
TxResult
),
"paraHeight"
,
status
.
Height
)
return
nil
,
nil
,
types
.
ErrInvalidParam
}
//空块
if
len
(
rst
)
==
0
{
return
nil
,
nil
,
nil
}
blockDetail
,
err
:=
GetBlock
(
api
,
status
.
MainBlockHash
)
if
err
!=
nil
{
return
nil
,
nil
,
err
}
//抽取平行链交易和跨链交易
paraAllTxs
:=
FilterTxsForPara
(
status
.
Title
,
blockDetail
)
var
baseHashs
[][]
byte
for
_
,
tx
:=
range
paraAllTxs
{
baseHashs
=
append
(
baseHashs
,
tx
.
Hash
())
}
paraCrossHashs
:=
FilterParaCrossTxHashes
(
status
.
Title
,
paraAllTxs
)
crossRst
:=
util
.
CalcBitMapByBitMap
(
paraCrossHashs
,
baseHashs
,
rst
)
return
paraCrossHashs
,
crossRst
,
nil
}
func
getCrossTxHashs
(
api
client
.
QueueProtocolAPI
,
status
*
pt
.
ParacrossNodeStatus
)
([][]
byte
,
[]
byte
,
error
)
{
func
getCrossTxHashs
(
api
client
.
QueueProtocolAPI
,
status
*
pt
.
ParacrossNodeStatus
)
([][]
byte
,
[]
byte
,
error
)
{
if
!
isParaForkHeight
(
status
.
MainBlockHeight
,
pt
.
ForkCommitTx
)
{
if
pt
.
IsParaForkHeight
(
status
.
MainBlockHeight
,
pt
.
ForkLoopCheckCommitTxDone
)
{
return
getCrossTxHashsByRst
(
api
,
status
)
}
if
!
pt
.
IsParaForkHeight
(
status
.
MainBlockHeight
,
pt
.
ForkCommitTx
)
{
return
status
.
CrossTxHashs
,
status
.
CrossTxResult
,
nil
return
status
.
CrossTxHashs
,
status
.
CrossTxResult
,
nil
}
}
...
@@ -879,7 +888,7 @@ func (a *action) AssetWithdraw(withdraw *types.AssetsWithdraw) (*types.Receipt,
...
@@ -879,7 +888,7 @@ func (a *action) AssetWithdraw(withdraw *types.AssetsWithdraw) (*types.Receipt,
//当前miner tx不需要校验上一个区块的衔接性,因为tx就是本节点发出,高度,preHash等都在本区块里面的blockchain做了校验
//当前miner tx不需要校验上一个区块的衔接性,因为tx就是本节点发出,高度,preHash等都在本区块里面的blockchain做了校验
func
(
a
*
action
)
Miner
(
miner
*
pt
.
ParacrossMinerAction
)
(
*
types
.
Receipt
,
error
)
{
func
(
a
*
action
)
Miner
(
miner
*
pt
.
ParacrossMinerAction
)
(
*
types
.
Receipt
,
error
)
{
if
miner
.
Status
.
Title
!=
types
.
GetTitle
()
||
miner
.
Status
.
PreBlockHash
==
nil
||
miner
.
Status
.
MainBlockHash
==
nil
{
if
miner
.
Status
.
Title
!=
types
.
GetTitle
()
||
miner
.
Status
.
MainBlockHash
==
nil
{
return
nil
,
pt
.
ErrParaMinerExecErr
return
nil
,
pt
.
ErrParaMinerExecErr
}
}
...
...
plugin/dapp/paracross/executor/exec_local.go
View file @
721cfedf
...
@@ -217,7 +217,6 @@ func setMinerTxResultFork(status *pt.ParacrossNodeStatus, txs []*types.Transacti
...
@@ -217,7 +217,6 @@ func setMinerTxResultFork(status *pt.ParacrossNodeStatus, txs []*types.Transacti
}
}
}
}
status
.
TxCounts
=
uint32
(
len
(
curTxHashs
))
//有tx且全部是user.p.x.paracross的commit tx时候设为0
//有tx且全部是user.p.x.paracross的commit tx时候设为0
status
.
NonCommitTxCounts
=
1
status
.
NonCommitTxCounts
=
1
if
len
(
curTxHashs
)
!=
0
&&
len
(
curTxHashs
)
==
len
(
isCommitTx
)
{
if
len
(
curTxHashs
)
!=
0
&&
len
(
curTxHashs
)
==
len
(
isCommitTx
)
{
...
@@ -227,12 +226,15 @@ func setMinerTxResultFork(status *pt.ParacrossNodeStatus, txs []*types.Transacti
...
@@ -227,12 +226,15 @@ func setMinerTxResultFork(status *pt.ParacrossNodeStatus, txs []*types.Transacti
//主链自己过滤平行链tx, 对平行链执行失败的tx主链无法识别,主链和平行链需要获取相同的最初的tx map
//主链自己过滤平行链tx, 对平行链执行失败的tx主链无法识别,主链和平行链需要获取相同的最初的tx map
//全部平行链tx结果
//全部平行链tx结果
status
.
TxResult
=
[]
byte
(
hex
.
EncodeToString
(
util
.
CalcBitMap
(
curTxHashs
,
curTxHashs
,
receipts
)))
status
.
TxResult
=
[]
byte
(
hex
.
EncodeToString
(
util
.
CalcSingleBitMap
(
curTxHashs
,
receipts
)))
//跨链tx结果
status
.
CrossTxResult
=
[]
byte
(
hex
.
EncodeToString
(
util
.
CalcBitMap
(
crossTxHashs
,
curTxHashs
,
receipts
)))
//ForkLoopCheckCommitTxDone 后只保留全部txreseult 结果
if
!
pt
.
IsParaForkHeight
(
status
.
MainBlockHeight
,
pt
.
ForkLoopCheckCommitTxDone
)
{
status
.
TxHashs
=
[][]
byte
{
CalcTxHashsHash
(
curTxHashs
)}
//跨链tx结果
status
.
CrossTxHashs
=
[][]
byte
{
CalcTxHashsHash
(
crossTxHashs
)}
status
.
CrossTxResult
=
[]
byte
(
hex
.
EncodeToString
(
util
.
CalcBitMap
(
crossTxHashs
,
curTxHashs
,
receipts
)))
status
.
TxHashs
=
[][]
byte
{
CalcTxHashsHash
(
curTxHashs
)}
status
.
CrossTxHashs
=
[][]
byte
{
CalcTxHashsHash
(
crossTxHashs
)}
}
return
nil
return
nil
}
}
...
@@ -246,7 +248,7 @@ func (e *Paracross) ExecLocal_Miner(payload *pt.ParacrossMinerAction, tx *types.
...
@@ -246,7 +248,7 @@ func (e *Paracross) ExecLocal_Miner(payload *pt.ParacrossMinerAction, tx *types.
var
set
types
.
LocalDBSet
var
set
types
.
LocalDBSet
txs
:=
e
.
GetTxs
()
txs
:=
e
.
GetTxs
()
forkHeight
:=
g
etDappForkHeight
(
pt
.
ForkCommitTx
)
forkHeight
:=
pt
.
G
etDappForkHeight
(
pt
.
ForkCommitTx
)
//removed the 0 vote tx
//removed the 0 vote tx
if
payload
.
Status
.
MainBlockHeight
>=
forkHeight
{
if
payload
.
Status
.
MainBlockHeight
>=
forkHeight
{
...
...
plugin/dapp/paracross/executor/filtertxs.go
View file @
721cfedf
...
@@ -75,7 +75,7 @@ func filterParaTxGroup(title string, tx *types.Transaction, main *types.BlockDet
...
@@ -75,7 +75,7 @@ func filterParaTxGroup(title string, tx *types.Transaction, main *types.BlockDet
//FilterTxsForPara include some main tx in tx group before ForkParacrossCommitTx
//FilterTxsForPara include some main tx in tx group before ForkParacrossCommitTx
func
FilterTxsForPara
(
title
string
,
main
*
types
.
BlockDetail
)
[]
*
types
.
Transaction
{
func
FilterTxsForPara
(
title
string
,
main
*
types
.
BlockDetail
)
[]
*
types
.
Transaction
{
var
txs
[]
*
types
.
Transaction
var
txs
[]
*
types
.
Transaction
forkHeight
:=
g
etDappForkHeight
(
pt
.
ForkCommitTx
)
forkHeight
:=
pt
.
G
etDappForkHeight
(
pt
.
ForkCommitTx
)
for
i
:=
0
;
i
<
len
(
main
.
Block
.
Txs
);
i
++
{
for
i
:=
0
;
i
<
len
(
main
.
Block
.
Txs
);
i
++
{
tx
:=
main
.
Block
.
Txs
[
i
]
tx
:=
main
.
Block
.
Txs
[
i
]
if
types
.
IsSpecificParaExecName
(
title
,
string
(
tx
.
Execer
))
{
if
types
.
IsSpecificParaExecName
(
title
,
string
(
tx
.
Execer
))
{
...
...
plugin/dapp/paracross/executor/paracross.go
View file @
721cfedf
...
@@ -97,9 +97,6 @@ func (c *Paracross) saveLocalParaTxsFork(commitDone *pt.ReceiptParacrossDone, is
...
@@ -97,9 +97,6 @@ func (c *Paracross) saveLocalParaTxsFork(commitDone *pt.ReceiptParacrossDone, is
Height
:
commitDone
.
Height
,
Height
:
commitDone
.
Height
,
BlockHash
:
commitDone
.
BlockHash
,
BlockHash
:
commitDone
.
BlockHash
,
TxResult
:
commitDone
.
TxResult
,
TxResult
:
commitDone
.
TxResult
,
TxHashs
:
commitDone
.
TxHashs
,
CrossTxResult
:
commitDone
.
CrossTxResult
,
CrossTxHashs
:
commitDone
.
CrossTxHashs
,
}
}
crossTxHashs
,
crossTxResult
,
err
:=
getCrossTxHashs
(
c
.
GetAPI
(),
status
)
crossTxHashs
,
crossTxResult
,
err
:=
getCrossTxHashs
(
c
.
GetAPI
(),
status
)
...
...
plugin/dapp/paracross/executor/query.go
View file @
721cfedf
...
@@ -226,8 +226,6 @@ func listLocalTitles(db dbm.KVDB) (types.Message, error) {
...
@@ -226,8 +226,6 @@ func listLocalTitles(db dbm.KVDB) (types.Message, error) {
MostSameCommit
:
st
.
MostSameCommit
,
MostSameCommit
:
st
.
MostSameCommit
,
Title
:
st
.
Title
,
Title
:
st
.
Title
,
Height
:
st
.
Height
,
Height
:
st
.
Height
,
StateHash
:
common
.
ToHex
(
st
.
StateHash
),
TxCounts
:
st
.
TxCounts
,
TxResult
:
hex
.
EncodeToString
(
st
.
TxResult
),
TxResult
:
hex
.
EncodeToString
(
st
.
TxResult
),
}
}
...
@@ -313,8 +311,6 @@ func loadLocalTitle(db dbm.KV, title string, height int64) (types.Message, error
...
@@ -313,8 +311,6 @@ func loadLocalTitle(db dbm.KV, title string, height int64) (types.Message, error
MostSameCommit
:
st
.
MostSameCommit
,
MostSameCommit
:
st
.
MostSameCommit
,
Title
:
st
.
Title
,
Title
:
st
.
Title
,
Height
:
st
.
Height
,
Height
:
st
.
Height
,
StateHash
:
common
.
ToHex
(
st
.
StateHash
),
TxCounts
:
st
.
TxCounts
,
TxResult
:
hex
.
EncodeToString
(
st
.
TxResult
),
TxResult
:
hex
.
EncodeToString
(
st
.
TxResult
),
},
nil
},
nil
}
}
...
...
plugin/dapp/paracross/executor/superaccount.go
View file @
721cfedf
...
@@ -612,7 +612,7 @@ func (a *action) nodeVote(config *pt.ParaNodeAddrConfig) (*types.Receipt, error)
...
@@ -612,7 +612,7 @@ func (a *action) nodeVote(config *pt.ParaNodeAddrConfig) (*types.Receipt, error)
}
}
receipt
=
mergeReceipt
(
receipt
,
r
)
receipt
=
mergeReceipt
(
receipt
,
r
)
if
a
.
exec
.
GetMainHeight
()
>
g
etDappForkHeight
(
pt
.
ForkLoopCheckCommitTxDone
)
{
if
a
.
exec
.
GetMainHeight
()
>
pt
.
G
etDappForkHeight
(
pt
.
ForkLoopCheckCommitTxDone
)
{
//node quit后,如果committx满足2/3目标,自动触发commitDone
//node quit后,如果committx满足2/3目标,自动触发commitDone
r
,
err
=
a
.
loopCommitTxDone
(
config
.
Title
)
r
,
err
=
a
.
loopCommitTxDone
(
config
.
Title
)
if
err
!=
nil
{
if
err
!=
nil
{
...
...
plugin/dapp/paracross/proto/paracross.proto
View file @
721cfedf
...
@@ -16,11 +16,9 @@ message ParacrossStatusDetails {
...
@@ -16,11 +16,9 @@ message ParacrossStatusDetails {
//记录不同blockHash的详细数据
//记录不同blockHash的详细数据
message
ParacrossStatusBlockDetails
{
message
ParacrossStatusBlockDetails
{
repeated
bytes
blockHashs
=
1
;
repeated
bytes
blockHashs
=
1
;
repeated
bytes
stateHashs
=
2
;
repeated
bytes
txResults
=
2
;
repeated
bytes
txResults
=
3
;
repeated
bytes
txHashs
=
4
;
repeated
bytes
crossTxResults
=
5
;
repeated
bytes
crossTxHashs
=
6
;
}
}
message
ParacrossHeightStatus
{
message
ParacrossHeightStatus
{
...
...
plugin/dapp/paracross/types/paracross.go
View file @
721cfedf
...
@@ -308,3 +308,38 @@ func (p ParacrossType) CreateRawTransferTx(action string, param json.RawMessage)
...
@@ -308,3 +308,38 @@ func (p ParacrossType) CreateRawTransferTx(action string, param json.RawMessage)
return
tx
,
nil
return
tx
,
nil
}
}
func
GetDappForkHeight
(
forkKey
string
)
int64
{
var
forkHeight
int64
if
types
.
IsPara
()
{
key
:=
forkKey
switch
forkKey
{
case
ForkCommitTx
:
key
=
MainForkParacrossCommitTx
case
ForkLoopCheckCommitTxDone
:
key
=
MainLoopCheckCommitTxDoneForkHeight
}
forkHeight
=
types
.
Conf
(
"config.consensus.sub.para"
)
.
GInt
(
key
)
if
forkHeight
<=
0
{
forkHeight
=
types
.
MaxHeight
}
}
else
{
forkHeight
=
types
.
GetDappFork
(
ParaX
,
forkKey
)
// CI特殊处理,主链是local,fork都是0,平行链有些配置项需要设置为非0,不然获取到的高度为MaxHeight
if
types
.
IsLocal
()
{
switch
forkKey
{
case
ForkCommitTx
:
forkHeight
=
10
case
ForkLoopCheckCommitTxDone
:
forkHeight
=
60
}
}
}
return
forkHeight
}
func
IsParaForkHeight
(
height
int64
,
forkKey
string
)
bool
{
return
height
>=
GetDappForkHeight
(
forkKey
)
}
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