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
0fc2c2e5
Commit
0fc2c2e5
authored
May 05, 2019
by
mdj33
Committed by
vipwzw
May 05, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix para get consens height sequence
parent
33abf21a
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
43 additions
and
34 deletions
+43
-34
paracommitmsg.go
plugin/consensus/para/paracommitmsg.go
+28
-23
testcase.sh
plugin/dapp/paracross/cmd/build/testcase.sh
+1
-2
exec_del_local.go
plugin/dapp/paracross/executor/exec_del_local.go
+7
-4
exec_local.go
plugin/dapp/paracross/executor/exec_local.go
+7
-5
No files found.
plugin/consensus/para/paracommitmsg.go
View file @
0fc2c2e5
...
...
@@ -528,47 +528,52 @@ out:
client
.
paraClient
.
wg
.
Done
()
}
func
(
client
*
commitMsgClient
)
getConsensusStatus
(
block
*
types
.
Block
)
(
*
pt
.
ParacrossStatus
,
error
)
{
//获取主链共识高度
if
!
isParaSelfConsensusForked
(
block
.
MainHeight
)
{
re
ply
,
err
:=
client
.
paraClient
.
grpcClient
.
QueryChain
(
context
.
Background
(),
&
types
.
ChainExecutor
{
if
isParaSelfConsensusForked
(
block
.
MainHeight
)
{
//从本地查询共识高度
re
t
,
err
:=
client
.
paraClient
.
GetAPI
()
.
QueryChain
(
&
types
.
ChainExecutor
{
Driver
:
"paracross"
,
FuncName
:
"GetTitle
ByHash
"
,
Param
:
types
.
Encode
(
&
pt
.
ReqParacrossTitleHash
{
Title
:
types
.
GetTitle
(),
BlockHash
:
block
.
MainHash
}),
FuncName
:
"GetTitle"
,
Param
:
types
.
Encode
(
&
types
.
ReqString
{
Data
:
types
.
GetTitle
()
}),
})
if
err
!=
nil
{
plog
.
Error
(
"get
MainConsensusHeight
"
,
"err"
,
err
.
Error
())
plog
.
Error
(
"get
ConsensusHeight
"
,
"err"
,
err
.
Error
())
return
nil
,
err
}
if
!
reply
.
GetIsOk
()
{
plog
.
Info
(
"getMainConsensusHeight nok"
,
"error"
,
reply
.
GetMsg
())
resp
,
ok
:=
ret
.
(
*
pt
.
ParacrossStatus
)
if
!
ok
{
plog
.
Error
(
"getConsensusHeight ParacrossStatus nok"
)
return
nil
,
err
}
var
result
pt
.
ParacrossStatus
err
=
types
.
Decode
(
reply
.
Msg
,
&
result
)
if
err
!=
nil
{
plog
.
Error
(
"getMainConsensusHeight decode"
,
"err"
,
err
.
Error
())
return
nil
,
err
//开启自共识后也要等到自共识真正切换之后再使用,如果本地区块已经过了自共识高度,但自共识的高度还没达成,就会导致共识机制出错
if
resp
.
Height
>
-
1
{
return
resp
,
nil
}
return
&
result
,
nil
}
//
从本地查询
共识高度
re
t
,
err
:=
client
.
paraClient
.
GetAPI
()
.
QueryChain
(
&
types
.
ChainExecutor
{
//
去主链获取
共识高度
re
ply
,
err
:=
client
.
paraClient
.
grpcClient
.
QueryChain
(
context
.
Background
(),
&
types
.
ChainExecutor
{
Driver
:
"paracross"
,
FuncName
:
"GetTitle"
,
Param
:
types
.
Encode
(
&
types
.
ReqString
{
Data
:
types
.
GetTitle
()
}),
FuncName
:
"GetTitle
ByHash
"
,
Param
:
types
.
Encode
(
&
pt
.
ReqParacrossTitleHash
{
Title
:
types
.
GetTitle
(),
BlockHash
:
block
.
MainHash
}),
})
if
err
!=
nil
{
plog
.
Error
(
"get
ConsensusHeight
"
,
"err"
,
err
.
Error
())
plog
.
Error
(
"get
MainConsensusHeight
"
,
"err"
,
err
.
Error
())
return
nil
,
err
}
resp
,
ok
:=
ret
.
(
*
pt
.
ParacrossStatus
)
if
!
ok
{
plog
.
Error
(
"getConsensusHeight ParacrossStatus nok"
)
if
!
reply
.
GetIsOk
()
{
plog
.
Info
(
"getMainConsensusHeight nok"
,
"error"
,
reply
.
GetMsg
())
return
nil
,
err
}
return
resp
,
nil
var
result
pt
.
ParacrossStatus
err
=
types
.
Decode
(
reply
.
Msg
,
&
result
)
if
err
!=
nil
{
plog
.
Error
(
"getMainConsensusHeight decode"
,
"err"
,
err
.
Error
())
return
nil
,
err
}
return
&
result
,
nil
}
func
(
client
*
commitMsgClient
)
fetchPrivacyKey
(
ch
chan
crypto
.
PrivKey
)
{
...
...
plugin/dapp/paracross/cmd/build/testcase.sh
View file @
0fc2c2e5
...
...
@@ -35,8 +35,7 @@ function para_set_toml() {
sed
-i
$xsedfix
's/^emptyBlockInterval=.*/emptyBlockInterval=4/g'
"
${
1
}
"
sed
-i
$xsedfix
'/^emptyBlockInterval=.*/a MainBlockHashForkHeight=1'
"
${
1
}
"
#测试使用,主链也要替换ForkParacrossCommitTx 为300
# sed -i $xsedfix '/^emptyBlockInterval=.*/a MainParaSelfConsensusForkHeight=300' "${1}"
sed
-i
$xsedfix
'/^emptyBlockInterval=.*/a MainParaSelfConsensusForkHeight=50'
"
${
1
}
"
sed
-i
$xsedfix
's/^MainForkParacrossCommitTx=.*/MainForkParacrossCommitTx=1/g'
"
${
1
}
"
# rpc
...
...
plugin/dapp/paracross/executor/exec_del_local.go
View file @
0fc2c2e5
...
...
@@ -32,11 +32,14 @@ func (e *Paracross) ExecDelLocal_Commit(payload *pt.ParacrossCommitAction, tx *t
key
=
calcLocalHeightKey
(
g
.
Title
,
g
.
Height
)
set
.
KV
=
append
(
set
.
KV
,
&
types
.
KeyValue
{
Key
:
key
,
Value
:
nil
})
r
,
err
:=
e
.
saveLocalParaTxs
(
tx
,
true
)
if
err
!=
nil
{
return
nil
,
err
if
!
types
.
IsPara
(){
r
,
err
:=
e
.
saveLocalParaTxs
(
tx
,
true
)
if
err
!=
nil
{
return
nil
,
err
}
set
.
KV
=
append
(
set
.
KV
,
r
.
KV
...
)
}
set
.
KV
=
append
(
set
.
KV
,
r
.
KV
...
)
}
else
if
log
.
Ty
==
pt
.
TyLogParacrossCommitRecord
{
var
g
pt
.
ReceiptParacrossRecord
types
.
Decode
(
log
.
Log
,
&
g
)
...
...
plugin/dapp/paracross/executor/exec_local.go
View file @
0fc2c2e5
...
...
@@ -31,12 +31,14 @@ func (e *Paracross) ExecLocal_Commit(payload *pt.ParacrossCommitAction, tx *type
key
=
calcLocalHeightKey
(
g
.
Title
,
g
.
Height
)
set
.
KV
=
append
(
set
.
KV
,
&
types
.
KeyValue
{
Key
:
key
,
Value
:
types
.
Encode
(
&
g
)})
r
,
err
:=
e
.
saveLocalParaTxs
(
tx
,
false
)
if
err
!=
nil
{
return
nil
,
err
if
!
types
.
IsPara
(){
r
,
err
:=
e
.
saveLocalParaTxs
(
tx
,
false
)
if
err
!=
nil
{
return
nil
,
err
}
set
.
KV
=
append
(
set
.
KV
,
r
.
KV
...
)
}
set
.
KV
=
append
(
set
.
KV
,
r
.
KV
...
)
}
else
if
log
.
Ty
==
pt
.
TyLogParacrossCommitRecord
{
var
g
pt
.
ReceiptParacrossRecord
types
.
Decode
(
log
.
Log
,
&
g
)
...
...
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