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
4be69878
Commit
4be69878
authored
Jan 12, 2019
by
vipwzw
Committed by
33cn
Jan 14, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixbug para consensus
parent
f6103da0
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
43 additions
and
34 deletions
+43
-34
para.go
plugin/consensus/para/para.go
+3
-3
paracommitmsg_test.go
plugin/consensus/para/paracommitmsg_test.go
+6
-3
paratxrequest_test.go
plugin/consensus/para/paratxrequest_test.go
+6
-3
chain33.para.test.toml
plugin/dapp/paracross/cmd/build/chain33.para.test.toml
+13
-11
chain33.para.toml
plugin/dapp/paracross/cmd/build/chain33.para.toml
+14
-13
api.go
vendor/github.com/33cn/chain33/client/api/api.go
+1
-1
No files found.
plugin/consensus/para/para.go
View file @
4be69878
...
@@ -130,7 +130,7 @@ func New(cfg *types.Consensus, sub []byte) queue.Module {
...
@@ -130,7 +130,7 @@ func New(cfg *types.Consensus, sub []byte) queue.Module {
conn
:
conn
,
conn
:
conn
,
grpcClient
:
grpcClient
,
grpcClient
:
grpcClient
,
paraClient
:
paraCli
,
paraClient
:
paraCli
,
authAccount
:
cfg
.
AuthAccount
,
authAccount
:
sub
cfg
.
AuthAccount
,
privateKey
:
priKey
,
privateKey
:
priKey
,
isCaughtUp
:
false
,
isCaughtUp
:
false
,
}
}
...
@@ -690,8 +690,8 @@ func (client *client) createBlock(lastBlock *types.Block, txs []*types.Transacti
...
@@ -690,8 +690,8 @@ func (client *client) createBlock(lastBlock *types.Block, txs []*types.Transacti
//挖矿固定难度
//挖矿固定难度
newblock
.
Difficulty
=
types
.
GetP
(
0
)
.
PowLimitBits
newblock
.
Difficulty
=
types
.
GetP
(
0
)
.
PowLimitBits
newblock
.
TxHash
=
merkle
.
CalcMerkleRoot
(
newblock
.
Txs
)
newblock
.
TxHash
=
merkle
.
CalcMerkleRoot
(
newblock
.
Txs
)
newblock
.
BlockTime
=
mainBlock
.
BlockTime
newblock
.
BlockTime
=
mainBlock
.
Detail
.
Block
.
BlockTime
newblock
.
MainHash
=
mainBlock
.
Hash
()
newblock
.
MainHash
=
mainBlock
.
Detail
.
Block
.
Hash
()
err
:=
client
.
addMinerTx
(
lastBlock
.
StateHash
,
&
newblock
,
mainBlock
)
err
:=
client
.
addMinerTx
(
lastBlock
.
StateHash
,
&
newblock
,
mainBlock
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
...
...
plugin/consensus/para/paracommitmsg_test.go
View file @
4be69878
...
@@ -60,7 +60,10 @@ func (s *suiteParaCommitMsg) initEnv(cfg *types.Config, sub *types.ConfigSubModu
...
@@ -60,7 +60,10 @@ func (s *suiteParaCommitMsg) initEnv(cfg *types.Config, sub *types.ConfigSubModu
q
:=
queue
.
New
(
"channel"
)
q
:=
queue
.
New
(
"channel"
)
s
.
q
=
q
s
.
q
=
q
//api, _ = client.New(q.Client(), nil)
//api, _ = client.New(q.Client(), nil)
var
subcfg
subConfig
if
sub
!=
nil
{
types
.
MustDecode
(
sub
.
Consensus
[
"para"
],
&
subcfg
)
}
s
.
block
=
blockchain
.
New
(
cfg
.
BlockChain
)
s
.
block
=
blockchain
.
New
(
cfg
.
BlockChain
)
s
.
block
.
SetQueueClient
(
q
.
Client
())
s
.
block
.
SetQueueClient
(
q
.
Client
())
...
@@ -83,9 +86,9 @@ func (s *suiteParaCommitMsg) initEnv(cfg *types.Config, sub *types.ConfigSubModu
...
@@ -83,9 +86,9 @@ func (s *suiteParaCommitMsg) initEnv(cfg *types.Config, sub *types.ConfigSubModu
ret
:=
&
types
.
Reply
{
IsOk
:
true
,
Msg
:
data
}
ret
:=
&
types
.
Reply
{
IsOk
:
true
,
Msg
:
data
}
s
.
grpcCli
.
On
(
"QueryChain"
,
mock
.
Anything
,
mock
.
Anything
)
.
Return
(
ret
,
nil
)
.
Maybe
()
s
.
grpcCli
.
On
(
"QueryChain"
,
mock
.
Anything
,
mock
.
Anything
)
.
Return
(
ret
,
nil
)
.
Maybe
()
s
.
grpcCli
.
On
(
"SendTransaction"
,
mock
.
Anything
,
mock
.
Anything
)
.
Return
(
reply
,
nil
)
.
Maybe
()
s
.
grpcCli
.
On
(
"SendTransaction"
,
mock
.
Anything
,
mock
.
Anything
)
.
Return
(
reply
,
nil
)
.
Maybe
()
s
.
grpcCli
.
On
(
"GetLastHeader"
,
mock
.
Anything
,
mock
.
Anything
)
.
Return
(
&
types
.
Header
{
Height
:
cfg
.
Consensus
.
StartHeight
+
minBlockNum
},
nil
)
.
Maybe
()
s
.
grpcCli
.
On
(
"GetLastHeader"
,
mock
.
Anything
,
mock
.
Anything
)
.
Return
(
&
types
.
Header
{
Height
:
subcfg
.
StartHeight
+
minBlockNum
},
nil
)
.
Maybe
()
s
.
grpcCli
.
On
(
"GetBlockHash"
,
mock
.
Anything
,
mock
.
Anything
)
.
Return
(
&
types
.
ReplyHash
{
Hash
:
[]
byte
(
"1"
)},
nil
)
.
Maybe
()
s
.
grpcCli
.
On
(
"GetBlockHash"
,
mock
.
Anything
,
mock
.
Anything
)
.
Return
(
&
types
.
ReplyHash
{
Hash
:
[]
byte
(
"1"
)},
nil
)
.
Maybe
()
s
.
grpcCli
.
On
(
"GetSequenceByHash"
,
mock
.
Anything
,
mock
.
Anything
)
.
Return
(
&
types
.
Int64
{
Data
:
cfg
.
Consensus
.
StartHeight
},
nil
)
.
Maybe
()
s
.
grpcCli
.
On
(
"GetSequenceByHash"
,
mock
.
Anything
,
mock
.
Anything
)
.
Return
(
&
types
.
Int64
{
Data
:
subcfg
.
StartHeight
},
nil
)
.
Maybe
()
s
.
para
.
grpcClient
=
s
.
grpcCli
s
.
para
.
grpcClient
=
s
.
grpcCli
s
.
para
.
SetQueueClient
(
q
.
Client
())
s
.
para
.
SetQueueClient
(
q
.
Client
())
...
...
plugin/consensus/para/paratxrequest_test.go
View file @
4be69878
...
@@ -46,7 +46,10 @@ func (s *suiteParaClient) initEnv(cfg *types.Config, sub *types.ConfigSubModule)
...
@@ -46,7 +46,10 @@ func (s *suiteParaClient) initEnv(cfg *types.Config, sub *types.ConfigSubModule)
q
:=
queue
.
New
(
"channel"
)
q
:=
queue
.
New
(
"channel"
)
s
.
q
=
q
s
.
q
=
q
//api, _ = client.New(q.Client(), nil)
//api, _ = client.New(q.Client(), nil)
var
subcfg
subConfig
if
sub
!=
nil
{
types
.
MustDecode
(
sub
.
Consensus
[
"para"
],
&
subcfg
)
}
s
.
block
=
blockchain
.
New
(
cfg
.
BlockChain
)
s
.
block
=
blockchain
.
New
(
cfg
.
BlockChain
)
s
.
block
.
SetQueueClient
(
q
.
Client
())
s
.
block
.
SetQueueClient
(
q
.
Client
())
...
@@ -58,7 +61,7 @@ func (s *suiteParaClient) initEnv(cfg *types.Config, sub *types.ConfigSubModule)
...
@@ -58,7 +61,7 @@ func (s *suiteParaClient) initEnv(cfg *types.Config, sub *types.ConfigSubModule)
//cfg.Consensus.StartHeight = 0
//cfg.Consensus.StartHeight = 0
//add block by UT below
//add block by UT below
cfg
.
Consensus
.
EmptyBlockInterval
=
100
subcfg
.
EmptyBlockInterval
=
100
s
.
para
=
New
(
cfg
.
Consensus
,
sub
.
Consensus
[
"para"
])
.
(
*
client
)
s
.
para
=
New
(
cfg
.
Consensus
,
sub
.
Consensus
[
"para"
])
.
(
*
client
)
s
.
grpcCli
=
&
typesmocks
.
Chain33Client
{}
s
.
grpcCli
=
&
typesmocks
.
Chain33Client
{}
...
@@ -72,7 +75,7 @@ func (s *suiteParaClient) initEnv(cfg *types.Config, sub *types.ConfigSubModule)
...
@@ -72,7 +75,7 @@ func (s *suiteParaClient) initEnv(cfg *types.Config, sub *types.ConfigSubModule)
ret
:=
&
types
.
Reply
{
IsOk
:
true
,
Msg
:
data
}
ret
:=
&
types
.
Reply
{
IsOk
:
true
,
Msg
:
data
}
s
.
grpcCli
.
On
(
"QueryChain"
,
mock
.
Anything
,
mock
.
Anything
)
.
Return
(
ret
,
nil
)
.
Maybe
()
s
.
grpcCli
.
On
(
"QueryChain"
,
mock
.
Anything
,
mock
.
Anything
)
.
Return
(
ret
,
nil
)
.
Maybe
()
s
.
grpcCli
.
On
(
"SendTransaction"
,
mock
.
Anything
,
mock
.
Anything
)
.
Return
(
reply
,
nil
)
.
Maybe
()
s
.
grpcCli
.
On
(
"SendTransaction"
,
mock
.
Anything
,
mock
.
Anything
)
.
Return
(
reply
,
nil
)
.
Maybe
()
s
.
grpcCli
.
On
(
"GetLastHeader"
,
mock
.
Anything
,
mock
.
Anything
)
.
Return
(
&
types
.
Header
{
Height
:
cfg
.
Consensus
.
StartHeight
+
minBlockNum
},
nil
)
.
Maybe
()
s
.
grpcCli
.
On
(
"GetLastHeader"
,
mock
.
Anything
,
mock
.
Anything
)
.
Return
(
&
types
.
Header
{
Height
:
subcfg
.
StartHeight
+
minBlockNum
},
nil
)
.
Maybe
()
s
.
grpcCli
.
On
(
"GetBlockHash"
,
mock
.
Anything
,
mock
.
Anything
)
.
Return
(
&
types
.
ReplyHash
{
Hash
:
[]
byte
(
"1"
)},
nil
)
.
Maybe
()
s
.
grpcCli
.
On
(
"GetBlockHash"
,
mock
.
Anything
,
mock
.
Anything
)
.
Return
(
&
types
.
ReplyHash
{
Hash
:
[]
byte
(
"1"
)},
nil
)
.
Maybe
()
s
.
para
.
grpcClient
=
s
.
grpcCli
s
.
para
.
grpcClient
=
s
.
grpcCli
s
.
para
.
SetQueueClient
(
q
.
Client
())
s
.
para
.
SetQueueClient
(
q
.
Client
())
...
...
plugin/dapp/paracross/cmd/build/chain33.para.test.toml
View file @
4be69878
...
@@ -71,17 +71,6 @@ maxTxNumPerAccount=10000
...
@@ -71,17 +71,6 @@ maxTxNumPerAccount=10000
name
=
"para"
name
=
"para"
genesisBlockTime
=
1514533394
genesisBlockTime
=
1514533394
genesis
=
"14KEKbYtKKQm4wMthSK9J4La4nAiidGozt"
genesis
=
"14KEKbYtKKQm4wMthSK9J4La4nAiidGozt"
ParaRemoteGrpcClient
=
"localhost:8802"
#主链指定高度的区块开始同步
startHeight
=
20
#打包时间间隔,单位秒
writeBlockSeconds
=
2
#主链每隔几个没有相关交易的区块,平行链上打包空区块
emptyBlockInterval
=
4
#验证账户,验证节点需要配置自己的账户,并且钱包导入对应种子,非验证节点留空
authAccount
=
"1KSBd17H7ZK8iT37aJztFB22XGwsPTdwE4"
#等待平行链共识消息在主链上链并成功的块数,超出会重发共识消息,最小是2
waitBlocks4CommitMsg
=
2
[mver.consensus]
[mver.consensus]
fundKeyAddr
=
"1BQXS6TxaYYG5mADaWij4AxhZZUTpw95a5"
fundKeyAddr
=
"1BQXS6TxaYYG5mADaWij4AxhZZUTpw95a5"
...
@@ -98,6 +87,19 @@ maxTxNumber = 1600 #160
...
@@ -98,6 +87,19 @@ maxTxNumber = 1600 #160
targetTimespan
=
2304
targetTimespan
=
2304
targetTimePerBlock
=
16
targetTimePerBlock
=
16
[consensus.sub.para]
ParaRemoteGrpcClient
=
"localhost:8802"
#主链指定高度的区块开始同步
startHeight
=
20
#打包时间间隔,单位秒
writeBlockSeconds
=
2
#主链每隔几个没有相关交易的区块,平行链上打包空区块
emptyBlockInterval
=
4
#验证账户,验证节点需要配置自己的账户,并且钱包导入对应种子,非验证节点留空
authAccount
=
"1KSBd17H7ZK8iT37aJztFB22XGwsPTdwE4"
#等待平行链共识消息在主链上链并成功的块数,超出会重发共识消息,最小是2
waitBlocks4CommitMsg
=
2
[store]
[store]
name
=
"mavl"
name
=
"mavl"
driver
=
"memdb"
driver
=
"memdb"
...
...
plugin/dapp/paracross/cmd/build/chain33.para.toml
View file @
4be69878
...
@@ -72,19 +72,6 @@ maxTxNumPerAccount=10000
...
@@ -72,19 +72,6 @@ maxTxNumPerAccount=10000
name
=
"para"
name
=
"para"
genesisBlockTime
=
1514533394
genesisBlockTime
=
1514533394
genesis
=
"14KEKbYtKKQm4wMthSK9J4La4nAiidGozt"
genesis
=
"14KEKbYtKKQm4wMthSK9J4La4nAiidGozt"
ParaRemoteGrpcClient
=
"localhost:8802"
#主链指定高度的区块开始同步
startHeight
=
345850
#打包时间间隔,单位秒
writeBlockSeconds
=
2
#主链每隔几个没有相关交易的区块,平行链上打包空区块
emptyBlockInterval
=
50
#验证账户,验证节点需要配置自己的账户,并且钱包导入对应种子,非验证节点留空
authAccount
=
""
#等待平行链共识消息在主链上链并成功的块数,超出会重发共识消息,最小是2
waitBlocks4CommitMsg
=
2
searchHashMatchedBlockDepth
=
100
[mver.consensus]
[mver.consensus]
fundKeyAddr
=
"1BQXS6TxaYYG5mADaWij4AxhZZUTpw95a5"
fundKeyAddr
=
"1BQXS6TxaYYG5mADaWij4AxhZZUTpw95a5"
...
@@ -101,6 +88,20 @@ maxTxNumber = 1600 #160
...
@@ -101,6 +88,20 @@ maxTxNumber = 1600 #160
targetTimespan
=
2304
targetTimespan
=
2304
targetTimePerBlock
=
16
targetTimePerBlock
=
16
[consensus.sub.para]
ParaRemoteGrpcClient
=
"localhost:8802"
#主链指定高度的区块开始同步
startHeight
=
345850
#打包时间间隔,单位秒
writeBlockSeconds
=
2
#主链每隔几个没有相关交易的区块,平行链上打包空区块
emptyBlockInterval
=
50
#验证账户,验证节点需要配置自己的账户,并且钱包导入对应种子,非验证节点留空
authAccount
=
""
#等待平行链共识消息在主链上链并成功的块数,超出会重发共识消息,最小是2
waitBlocks4CommitMsg
=
2
searchHashMatchedBlockDepth
=
100
[store]
[store]
name
=
"mavl"
name
=
"mavl"
driver
=
"leveldb"
driver
=
"leveldb"
...
...
vendor/github.com/33cn/chain33/client/api/api.go
View file @
4be69878
...
@@ -80,7 +80,7 @@ type paraChainAPI struct {
...
@@ -80,7 +80,7 @@ type paraChainAPI struct {
}
}
func
newParaChainAPI
(
api
client
.
QueueProtocolAPI
,
grpcaddr
string
)
ExecutorAPI
{
func
newParaChainAPI
(
api
client
.
QueueProtocolAPI
,
grpcaddr
string
)
ExecutorAPI
{
paraRemoteGrpcClient
:=
types
.
Conf
(
"config.consensus"
)
.
GStr
(
"ParaRemoteGrpcClient"
)
paraRemoteGrpcClient
:=
types
.
Conf
(
"config.consensus
.sub.para
"
)
.
GStr
(
"ParaRemoteGrpcClient"
)
if
grpcaddr
!=
""
{
if
grpcaddr
!=
""
{
paraRemoteGrpcClient
=
grpcaddr
paraRemoteGrpcClient
=
grpcaddr
}
}
...
...
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