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
bb3a9784
Commit
bb3a9784
authored
Mar 14, 2019
by
mdj33
Committed by
33cn
Mar 27, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add config to para self consensus fork
parent
28f8d396
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
25 deletions
+31
-25
para.go
plugin/consensus/para/para.go
+22
-22
paracommitmsg.go
plugin/consensus/para/paracommitmsg.go
+1
-1
testcase.sh
plugin/dapp/paracross/cmd/build/testcase.sh
+2
-0
paracross.go
plugin/dapp/paracross/executor/paracross.go
+6
-2
No files found.
plugin/consensus/para/para.go
View file @
bb3a9784
...
@@ -47,11 +47,11 @@ var (
...
@@ -47,11 +47,11 @@ var (
emptyBlockInterval
int64
=
4
//write empty block every interval blocks in mainchain
emptyBlockInterval
int64
=
4
//write empty block every interval blocks in mainchain
zeroHash
[
32
]
byte
zeroHash
[
32
]
byte
//current miner tx take any privatekey for unify all nodes sign purpose, and para chain is free
//current miner tx take any privatekey for unify all nodes sign purpose, and para chain is free
minerPrivateKey
=
"6da92a632ab7deb67d38c0f6560bcfed28167998f6496db64c258d5e8393a81b"
minerPrivateKey
=
"6da92a632ab7deb67d38c0f6560bcfed28167998f6496db64c258d5e8393a81b"
searchHashMatchDepth
int32
=
100
searchHashMatchDepth
int32
=
100
mainBlockHashForkHeight
int64
=
types
.
MaxHeight
//calc block hash fork height in main chain
mainBlockHashForkHeight
int64
=
209186
//calc block hash fork height in main chain
mainPara
CommitTx
ForkHeight
int64
=
types
.
MaxHeight
//support paracross commit tx fork height in main chain
mainPara
SelfConsensus
ForkHeight
int64
=
types
.
MaxHeight
//support paracross commit tx fork height in main chain
curMainChainHeight
int64
curMainChainHeight
int64
//当前实时的主链高度
)
)
func
init
()
{
func
init
()
{
...
@@ -72,14 +72,16 @@ type client struct {
...
@@ -72,14 +72,16 @@ type client 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"`
EmptyBlockInterval
int64
`json:"emptyBlockInterval,omitempty"`
EmptyBlockInterval
int64
`json:"emptyBlockInterval,omitempty"`
AuthAccount
string
`json:"authAccount,omitempty"`
AuthAccount
string
`json:"authAccount,omitempty"`
WaitBlocks4CommitMsg
int32
`json:"waitBlocks4CommitMsg,omitempty"`
WaitBlocks4CommitMsg
int32
`json:"waitBlocks4CommitMsg,omitempty"`
SearchHashMatchedBlockDepth
int32
`json:"searchHashMatchedBlockDepth,omitempty"`
SearchHashMatchedBlockDepth
int32
`json:"searchHashMatchedBlockDepth,omitempty"`
GenesisAmount
int64
`json:"genesisAmount,omitempty"`
GenesisAmount
int64
`json:"genesisAmount,omitempty"`
MainBlockHashForkHeight
int64
`json:"mainBlockHashForkHeight,omitempty"`
MainParaSelfConsensusForkHeight
int64
`json:"mainParaSelfConsensusForkHeight,omitempty"`
}
}
// New function to init paracross env
// New function to init paracross env
...
@@ -107,6 +109,13 @@ func New(cfg *types.Consensus, sub []byte) queue.Module {
...
@@ -107,6 +109,13 @@ func New(cfg *types.Consensus, sub []byte) queue.Module {
if
subcfg
.
SearchHashMatchedBlockDepth
>
0
{
if
subcfg
.
SearchHashMatchedBlockDepth
>
0
{
searchHashMatchDepth
=
subcfg
.
SearchHashMatchedBlockDepth
searchHashMatchDepth
=
subcfg
.
SearchHashMatchedBlockDepth
}
}
if
subcfg
.
MainBlockHashForkHeight
>
0
{
mainBlockHashForkHeight
=
subcfg
.
MainBlockHashForkHeight
}
if
subcfg
.
MainParaSelfConsensusForkHeight
>
0
{
mainParaSelfConsensusForkHeight
=
subcfg
.
MainParaSelfConsensusForkHeight
}
pk
,
err
:=
hex
.
DecodeString
(
minerPrivateKey
)
pk
,
err
:=
hex
.
DecodeString
(
minerPrivateKey
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -198,15 +207,6 @@ func (client *client) InitBlock() {
...
@@ -198,15 +207,6 @@ func (client *client) InitBlock() {
}
else
{
}
else
{
client
.
SetCurrentBlock
(
block
)
client
.
SetCurrentBlock
(
block
)
}
}
// get main chain calc block hash fork height
mainBlockHashForkHeight
,
err
=
client
.
GetForkHeightOnMainChain
(
"ForkBlockHash"
)
if
err
!=
nil
{
panic
(
err
)
}
mainParaCommitTxForkHeight
,
err
=
client
.
GetForkHeightOnMainChain
(
pt
.
ParaX
+
"-"
+
pt
.
ForkCommitTx
)
if
err
!=
nil
{
panic
(
err
)
}
}
}
...
...
plugin/consensus/para/paracommitmsg.go
View file @
bb3a9784
...
@@ -350,7 +350,7 @@ func checkTxInMainBlock(targetTx *types.Transaction, detail *types.BlockDetail)
...
@@ -350,7 +350,7 @@ func checkTxInMainBlock(targetTx *types.Transaction, detail *types.BlockDetail)
}
}
func
isMainCommitHeightForked
()
bool
{
func
isMainCommitHeightForked
()
bool
{
return
curMainChainHeight
>
mainPara
CommitTx
ForkHeight
+
100
return
curMainChainHeight
>
mainPara
SelfConsensus
ForkHeight
+
100
}
}
//当前未考虑获取key非常多失败的场景, 如果获取height非常多,block模块会比较大,但是使用完了就释放了
//当前未考虑获取key非常多失败的场景, 如果获取height非常多,block模块会比较大,但是使用完了就释放了
...
...
plugin/dapp/paracross/cmd/build/testcase.sh
View file @
bb3a9784
...
@@ -32,6 +32,8 @@ function para_set_toml() {
...
@@ -32,6 +32,8 @@ function para_set_toml() {
sed
-i
$xsedfix
's/^# TestNet=.*/TestNet=true/g'
"
${
1
}
"
sed
-i
$xsedfix
's/^# TestNet=.*/TestNet=true/g'
"
${
1
}
"
sed
-i
$xsedfix
's/^startHeight=.*/startHeight=0/g'
"
${
1
}
"
sed
-i
$xsedfix
's/^startHeight=.*/startHeight=0/g'
"
${
1
}
"
sed
-i
$xsedfix
's/^emptyBlockInterval=.*/emptyBlockInterval=4/g'
"
${
1
}
"
sed
-i
$xsedfix
's/^emptyBlockInterval=.*/emptyBlockInterval=4/g'
"
${
1
}
"
sed
-i
$xsedfix
'/^emptyBlockInterval=.*/a MainBlockHashForkHeight=1'
"
${
1
}
"
sed
-i
$xsedfix
'/^emptyBlockInterval=.*/a MainParaSelfConsensusForkHeight=300'
"
${
1
}
"
# rpc
# rpc
sed
-i
$xsedfix
's/^jrpcBindAddr=.*/jrpcBindAddr="0.0.0.0:8901"/g'
"
${
1
}
"
sed
-i
$xsedfix
's/^jrpcBindAddr=.*/jrpcBindAddr="0.0.0.0:8901"/g'
"
${
1
}
"
...
...
plugin/dapp/paracross/executor/paracross.go
View file @
bb3a9784
...
@@ -318,10 +318,14 @@ func (c *Paracross) allow(tx *types.Transaction, index int) error {
...
@@ -318,10 +318,14 @@ func (c *Paracross) allow(tx *types.Transaction, index int) error {
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
if
payload
.
Ty
==
pt
.
ParacrossActionAssetTransfer
||
payload
.
Ty
==
pt
.
ParacrossActionAssetWithdraw
||
if
payload
.
Ty
==
pt
.
ParacrossActionAssetTransfer
||
payload
.
Ty
==
pt
.
ParacrossActionAssetWithdraw
{
payload
.
Ty
==
pt
.
ParacrossActionCommit
{
return
nil
return
nil
}
}
if
c
.
GetHeight
()
>
types
.
GetDappFork
(
pt
.
ParaX
,
pt
.
ForkCommitTx
)
{
if
payload
.
Ty
==
pt
.
ParacrossActionCommit
{
return
nil
}
}
}
}
return
types
.
ErrNotAllow
return
types
.
ErrNotAllow
}
}
...
...
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