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
83f86a48
Commit
83f86a48
authored
May 29, 2019
by
张振华
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into guess-rpc-test
parents
893f8745
95f6063b
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
437 additions
and
16 deletions
+437
-16
chain33.toml
chain33.toml
+3
-2
para.go
plugin/consensus/para/para.go
+1
-1
paracommitmsg.go
plugin/consensus/para/paracommitmsg.go
+15
-1
Makefile
plugin/dapp/game/cmd/Makefile
+4
-0
build.sh
plugin/dapp/game/cmd/build.sh
+19
-0
test-rpc.sh
plugin/dapp/game/cmd/build/test-rpc.sh
+330
-0
Makefile
plugin/dapp/lottery/cmd/Makefile
+4
-0
build.sh
plugin/dapp/lottery/cmd/build.sh
+15
-0
test-rpc.sh
plugin/dapp/lottery/cmd/build/test-rpc.sh
+0
-0
chain33.para.toml
plugin/dapp/paracross/cmd/build/chain33.para.toml
+1
-0
action.go
plugin/dapp/paracross/executor/action.go
+8
-2
exec_local.go
plugin/dapp/paracross/executor/exec_local.go
+33
-7
paracross_test.go
plugin/dapp/paracross/executor/paracross_test.go
+2
-2
paracross.proto
plugin/dapp/paracross/proto/paracross.proto
+1
-0
paracross.pb.go
plugin/dapp/paracross/types/paracross.pb.go
+0
-0
kvmvcc_mavl.go
plugin/store/kvmvccmavl/kvmvcc_mavl.go
+1
-1
No files found.
chain33.toml
View file @
83f86a48
...
@@ -136,12 +136,12 @@ returnAddr="1KcCVZLSQYRUwE5EXTsAoQs9LuJW6xwfQa"
...
@@ -136,12 +136,12 @@ returnAddr="1KcCVZLSQYRUwE5EXTsAoQs9LuJW6xwfQa"
count
=
10000
count
=
10000
[store]
[store]
name
=
"mavl"
name
=
"
kvmvcc
mavl"
driver
=
"leveldb"
driver
=
"leveldb"
dbPath
=
"datadir/mavltree"
dbPath
=
"datadir/mavltree"
dbCache
=
128
dbCache
=
128
# store数据库版本
# store数据库版本
storedbVersion
=
"
1
.0.0"
storedbVersion
=
"
2
.0.0"
[store.sub.mavl]
[store.sub.mavl]
enableMavlPrefix
=
false
enableMavlPrefix
=
false
...
@@ -154,6 +154,7 @@ enableMemTree=true
...
@@ -154,6 +154,7 @@ enableMemTree=true
enableMemVal
=
true
enableMemVal
=
true
[store.sub.kvmvccmavl]
[store.sub.kvmvccmavl]
enableMVCCIter
=
true
enableMavlPrefix
=
false
enableMavlPrefix
=
false
enableMVCC
=
false
enableMVCC
=
false
enableMavlPrune
=
false
enableMavlPrune
=
false
...
...
plugin/consensus/para/para.go
View file @
83f86a48
...
@@ -34,7 +34,7 @@ const (
...
@@ -34,7 +34,7 @@ const (
addAct
int64
=
1
//add para block action
addAct
int64
=
1
//add para block action
delAct
int64
=
2
//reference blockstore.go, del para block action
delAct
int64
=
2
//reference blockstore.go, del para block action
minBlockNum
=
6
//min block number startHeight before lastHeight in mainchain
minBlockNum
=
100
//min block number startHeight before lastHeight in mainchain
)
)
var
(
var
(
...
...
plugin/consensus/para/paracommitmsg.go
View file @
83f86a48
...
@@ -19,7 +19,7 @@ import (
...
@@ -19,7 +19,7 @@ import (
var
(
var
(
consensusInterval
=
16
//about 1 new block interval
consensusInterval
=
16
//about 1 new block interval
minerInterval
=
2
minerInterval
=
5
)
)
type
commitMsgClient
struct
{
type
commitMsgClient
struct
{
...
@@ -130,6 +130,9 @@ out:
...
@@ -130,6 +130,9 @@ out:
plog
.
Error
(
"para commit msg read tick"
,
"err"
,
err
.
Error
())
plog
.
Error
(
"para commit msg read tick"
,
"err"
,
err
.
Error
())
continue
continue
}
}
if
len
(
status
)
==
0
{
continue
}
signTx
,
count
,
err
:=
client
.
calcCommitMsgTxs
(
status
)
signTx
,
count
,
err
:=
client
.
calcCommitMsgTxs
(
status
)
if
err
!=
nil
||
signTx
==
nil
{
if
err
!=
nil
||
signTx
==
nil
{
...
@@ -426,9 +429,20 @@ func (client *commitMsgClient) getNodeStatus(start, end int64) ([]*pt.ParacrossN
...
@@ -426,9 +429,20 @@ func (client *commitMsgClient) getNodeStatus(start, end int64) ([]*pt.ParacrossN
nodeList
[
block
.
Block
.
Height
]
.
StateHash
=
block
.
Block
.
StateHash
nodeList
[
block
.
Block
.
Height
]
.
StateHash
=
block
.
Block
.
StateHash
}
}
var
needSentTxs
uint32
for
i
:=
0
;
i
<
int
(
count
);
i
++
{
for
i
:=
0
;
i
<
int
(
count
);
i
++
{
ret
=
append
(
ret
,
nodeList
[
req
.
Start
+
int64
(
i
)])
ret
=
append
(
ret
,
nodeList
[
req
.
Start
+
int64
(
i
)])
needSentTxs
+=
nodeList
[
req
.
Start
+
int64
(
i
)]
.
NonCommitTxCounts
}
}
//1.如果是只有commit tx的空块,推迟发送,直到等到一个完全没有commit tx的空块或者其他tx的块
//2,如果20个块都是 commit tx的空块,20个块打包一次发送,尽量减少commit tx造成的空块
//3,如果形如xxoxx的块排列,x代表commit空块,o代表实际的块,即只要不全部是commit块,也要全部打包一起发出去
//如果=0 意味着全部是paracross commit tx,延迟发送
if
needSentTxs
==
0
&&
count
<
types
.
TxGroupMaxCount
{
plog
.
Debug
(
"para commitmsg getNodeStatus all self consensus commit tx,send delay"
,
"start"
,
start
,
"end"
,
end
)
return
nil
,
nil
}
return
ret
,
nil
return
ret
,
nil
}
}
...
...
plugin/dapp/game/cmd/Makefile
0 → 100644
View file @
83f86a48
all
:
chmod
+x ./build.sh
./build.sh
$(OUT)
$(FLAG)
\ No newline at end of file
plugin/dapp/game/cmd/build.sh
0 → 100755
View file @
83f86a48
#!/usr/bin/env bash
strpwd
=
$(
pwd
)
strcmd
=
${
strpwd
##*dapp/
}
strapp
=
${
strcmd
%/cmd*
}
OUT_DIR
=
"
${
1
}
/
$strapp
"
OUT_TESTDIR
=
"
${
1
}
/dapptest/
$strapp
"
PARACLI
=
"
${
OUT_DIR
}
/chain33-para-cli"
PARANAME
=
para
SRC_CLI
=
github.com/33cn/plugin/cli
go build
-v
-o
"
${
PARACLI
}
"
-ldflags
"-X
${
SRC_CLI
}
/buildflags.ParaName=user.p.
${
PARANAME
}
. -X
${
SRC_CLI
}
/buildflags.RPCAddr=http://localhost:8901"
"
${
SRC_CLI
}
"
# shellcheck disable=SC2086
cp
./build/
*
"
${
OUT_DIR
}
"
mkdir
-p
"
${
OUT_TESTDIR
}
"
cp
./build/
*
"
${
OUT_TESTDIR
}
"
plugin/dapp/game/cmd/build/test-rpc.sh
0 → 100755
View file @
83f86a48
This diff is collapsed.
Click to expand it.
plugin/dapp/lottery/cmd/Makefile
0 → 100644
View file @
83f86a48
all
:
chmod
+x ./build.sh
./build.sh
$(OUT)
$(FLAG)
\ No newline at end of file
plugin/dapp/lottery/cmd/build.sh
0 → 100755
View file @
83f86a48
#!/bin/sh
strpwd
=
$(
pwd
)
strcmd
=
${
strpwd
##*dapp/
}
strapp
=
${
strcmd
%/cmd*
}
OUT_DIR
=
"
${
1
}
/
$strapp
"
#FLAG=$2
mkdir
-p
"
${
OUT_DIR
}
"
cp
./build/
*
"
${
OUT_DIR
}
"
OUT_TESTDIR
=
"
${
1
}
/dapptest/
$strapp
"
mkdir
-p
"
${
OUT_TESTDIR
}
"
cp
./build/test-rpc.sh
"
${
OUT_TESTDIR
}
"
plugin/dapp/lottery/cmd/build/test-rpc.sh
0 → 100755
View file @
83f86a48
This diff is collapsed.
Click to expand it.
plugin/dapp/paracross/cmd/build/chain33.para.toml
View file @
83f86a48
...
@@ -154,6 +154,7 @@ tokenApprs = [
...
@@ -154,6 +154,7 @@ tokenApprs = [
]
]
[exec.sub.paracross]
[exec.sub.paracross]
#平行链自共识停止n个块后,超级账户可以直接参与投票
paraConsensusStopBlocks
=
100
paraConsensusStopBlocks
=
100
[pprof]
[pprof]
...
...
plugin/dapp/paracross/executor/action.go
View file @
83f86a48
...
@@ -415,7 +415,7 @@ func (a *action) Commit(commit *pt.ParacrossCommitAction) (*types.Receipt, error
...
@@ -415,7 +415,7 @@ func (a *action) Commit(commit *pt.ParacrossCommitAction) (*types.Receipt, error
saveTitle
(
a
.
db
,
calcTitleKey
(
commit
.
Status
.
Title
),
titleStatus
)
saveTitle
(
a
.
db
,
calcTitleKey
(
commit
.
Status
.
Title
),
titleStatus
)
clog
.
Info
(
"paracross.Commit commit done"
,
"height"
,
commit
.
Status
.
Height
,
clog
.
Info
(
"paracross.Commit commit done"
,
"height"
,
commit
.
Status
.
Height
,
"cross tx bitmap"
,
hex
.
EncodeToS
tring
(
commit
.
Status
.
CrossTxResult
),
"statusBlockHash"
,
hex
.
EncodeToString
(
titleStatus
.
BlockHash
))
"cross tx bitmap"
,
s
tring
(
commit
.
Status
.
CrossTxResult
),
"statusBlockHash"
,
hex
.
EncodeToString
(
titleStatus
.
BlockHash
))
//parallel chain not need to process cross commit tx here
//parallel chain not need to process cross commit tx here
if
types
.
IsPara
()
{
if
types
.
IsPara
()
{
...
@@ -491,7 +491,13 @@ func getCrossTxHashs(api client.QueueProtocolAPI, commit *pt.ParacrossCommitActi
...
@@ -491,7 +491,13 @@ func getCrossTxHashs(api client.QueueProtocolAPI, commit *pt.ParacrossCommitActi
//只获取跨链tx
//只获取跨链tx
crossTxHashs
=
paraCrossHashs
crossTxHashs
=
paraCrossHashs
crossTxResult
=
commit
.
Status
.
CrossTxResult
rst
,
err
:=
hex
.
DecodeString
(
string
(
commit
.
Status
.
CrossTxResult
))
if
err
!=
nil
{
clog
.
Error
(
"getCrossTxHashs decode string"
,
"CrossTxResult"
,
string
(
commit
.
Status
.
CrossTxResult
),
"commit.height"
,
commit
.
Status
.
Height
)
return
nil
,
nil
,
types
.
ErrInvalidParam
}
crossTxResult
=
rst
}
}
return
crossTxHashs
,
crossTxResult
,
nil
return
crossTxHashs
,
crossTxResult
,
nil
}
}
...
...
plugin/dapp/paracross/executor/exec_local.go
View file @
83f86a48
...
@@ -7,6 +7,8 @@ package executor
...
@@ -7,6 +7,8 @@ package executor
import
(
import
(
"bytes"
"bytes"
"encoding/hex"
"github.com/33cn/chain33/common"
"github.com/33cn/chain33/common"
"github.com/33cn/chain33/types"
"github.com/33cn/chain33/types"
"github.com/33cn/chain33/util"
"github.com/33cn/chain33/util"
...
@@ -164,23 +166,44 @@ func setMinerTxResult(payload *pt.ParacrossMinerAction, txs []*types.Transaction
...
@@ -164,23 +166,44 @@ func setMinerTxResult(payload *pt.ParacrossMinerAction, txs []*types.Transaction
return
nil
return
nil
}
}
func
setMinerTxResultFork
(
payload
*
pt
.
ParacrossMinerAction
,
txs
[]
*
types
.
Transaction
,
receipts
[]
*
types
.
ReceiptData
)
{
func
setMinerTxResultFork
(
status
*
pt
.
ParacrossNodeStatus
,
txs
[]
*
types
.
Transaction
,
receipts
[]
*
types
.
ReceiptData
)
error
{
isCommitTx
:=
make
(
map
[
string
]
bool
)
var
curTxHashs
[][]
byte
var
curTxHashs
[][]
byte
for
_
,
tx
:=
range
txs
{
for
_
,
tx
:=
range
txs
{
hash
:=
tx
.
Hash
()
hash
:=
tx
.
Hash
()
curTxHashs
=
append
(
curTxHashs
,
hash
)
curTxHashs
=
append
(
curTxHashs
,
hash
)
if
types
.
IsMyParaExecName
(
string
(
tx
.
Execer
))
&&
bytes
.
HasSuffix
(
tx
.
Execer
,
[]
byte
(
pt
.
ParaX
))
{
var
payload
pt
.
ParacrossAction
err
:=
types
.
Decode
(
tx
.
Payload
,
&
payload
)
if
err
!=
nil
{
clog
.
Error
(
"setMinerTxResultFork"
,
"txHash"
,
common
.
ToHex
(
hash
))
return
err
}
if
payload
.
Ty
==
pt
.
ParacrossActionCommit
{
isCommitTx
[
string
(
hash
)]
=
true
}
}
}
}
baseCrossTxHashs
:=
FilterParaCrossTxHashes
(
types
.
GetTitle
(),
txs
)
status
.
TxCounts
=
uint32
(
len
(
curTxHashs
))
//有tx且全部是user.p.x.paracross的commit tx时候设为0
status
.
NonCommitTxCounts
=
1
if
len
(
curTxHashs
)
!=
0
&&
len
(
curTxHashs
)
==
len
(
isCommitTx
)
{
status
.
NonCommitTxCounts
=
0
}
crossTxHashs
:=
FilterParaCrossTxHashes
(
types
.
GetTitle
(),
txs
)
//主链自己过滤平行链tx, 对平行链执行失败的tx主链无法识别,主链和平行链需要获取相同的最初的tx map
//主链自己过滤平行链tx, 对平行链执行失败的tx主链无法识别,主链和平行链需要获取相同的最初的tx map
//全部平行链tx结果
//全部平行链tx结果
payload
.
Status
.
TxResult
=
util
.
CalcBitMap
(
curTxHashs
,
curTxHashs
,
receipts
)
status
.
TxResult
=
[]
byte
(
hex
.
EncodeToString
(
util
.
CalcBitMap
(
curTxHashs
,
curTxHashs
,
receipts
))
)
//跨链tx结果
//跨链tx结果
payload
.
Status
.
CrossTxResult
=
util
.
CalcBitMap
(
baseCrossTxHashs
,
curTxHashs
,
receipts
)
status
.
CrossTxResult
=
[]
byte
(
hex
.
EncodeToString
(
util
.
CalcBitMap
(
crossTxHashs
,
curTxHashs
,
receipts
)))
status
.
TxHashs
=
[][]
byte
{
CalcTxHashsHash
(
curTxHashs
)}
status
.
CrossTxHashs
=
[][]
byte
{
CalcTxHashsHash
(
crossTxHashs
)}
payload
.
Status
.
TxHashs
=
[][]
byte
{
CalcTxHashsHash
(
curTxHashs
)}
return
nil
payload
.
Status
.
CrossTxHashs
=
[][]
byte
{
CalcTxHashsHash
(
baseCrossTxHashs
)}
}
}
//ExecLocal_Miner miner tx local db process
//ExecLocal_Miner miner tx local db process
...
@@ -196,7 +219,10 @@ func (e *Paracross) ExecLocal_Miner(payload *pt.ParacrossMinerAction, tx *types.
...
@@ -196,7 +219,10 @@ func (e *Paracross) ExecLocal_Miner(payload *pt.ParacrossMinerAction, tx *types.
//removed the 0 vote tx
//removed the 0 vote tx
if
payload
.
Status
.
MainBlockHeight
>=
forkHeight
{
if
payload
.
Status
.
MainBlockHeight
>=
forkHeight
{
setMinerTxResultFork
(
payload
,
txs
[
1
:
],
e
.
GetReceipt
()[
1
:
])
err
:=
setMinerTxResultFork
(
payload
.
Status
,
txs
[
1
:
],
e
.
GetReceipt
()[
1
:
])
if
err
!=
nil
{
return
nil
,
err
}
}
else
{
}
else
{
err
:=
setMinerTxResult
(
payload
,
txs
[
1
:
],
e
.
GetReceipt
()[
1
:
])
err
:=
setMinerTxResult
(
payload
,
txs
[
1
:
],
e
.
GetReceipt
()[
1
:
])
if
err
!=
nil
{
if
err
!=
nil
{
...
...
plugin/dapp/paracross/executor/paracross_test.go
View file @
83f86a48
...
@@ -620,8 +620,8 @@ func (s *VoteTestSuite) TestVoteTxFork() {
...
@@ -620,8 +620,8 @@ func (s *VoteTestSuite) TestVoteTxFork() {
if
bytes
.
Equal
(
key
,
kv
.
Key
)
{
if
bytes
.
Equal
(
key
,
kv
.
Key
)
{
var
rst
pt
.
ParacrossNodeStatus
var
rst
pt
.
ParacrossNodeStatus
types
.
Decode
(
kv
.
GetValue
(),
&
rst
)
types
.
Decode
(
kv
.
GetValue
(),
&
rst
)
s
.
Equal
([]
uint8
([]
byte
{
0x8e
}
),
rst
.
TxResult
)
s
.
Equal
([]
byte
(
"8e"
),
rst
.
TxResult
)
s
.
Equal
([]
uint8
([]
byte
{
0x22
}
),
rst
.
CrossTxResult
)
s
.
Equal
([]
byte
(
"22"
),
rst
.
CrossTxResult
)
s
.
Equal
(
1
,
len
(
rst
.
TxHashs
))
s
.
Equal
(
1
,
len
(
rst
.
TxHashs
))
s
.
Equal
(
1
,
len
(
rst
.
CrossTxHashs
))
s
.
Equal
(
1
,
len
(
rst
.
CrossTxHashs
))
...
...
plugin/dapp/paracross/proto/paracross.proto
View file @
83f86a48
...
@@ -151,6 +151,7 @@ message ParacrossNodeStatus {
...
@@ -151,6 +151,7 @@ message ParacrossNodeStatus {
repeated
bytes
txHashs
=
11
;
repeated
bytes
txHashs
=
11
;
bytes
crossTxResult
=
12
;
bytes
crossTxResult
=
12
;
repeated
bytes
crossTxHashs
=
13
;
repeated
bytes
crossTxHashs
=
13
;
uint32
nonCommitTxCounts
=
14
;
}
}
message
ParacrossCommitAction
{
message
ParacrossCommitAction
{
...
...
plugin/dapp/paracross/types/paracross.pb.go
View file @
83f86a48
This diff is collapsed.
Click to expand it.
plugin/store/kvmvccmavl/kvmvcc_mavl.go
View file @
83f86a48
...
@@ -61,7 +61,7 @@ func DisableLog() {
...
@@ -61,7 +61,7 @@ func DisableLog() {
func
init
()
{
func
init
()
{
drivers
.
Reg
(
"kvmvccmavl"
,
New
)
drivers
.
Reg
(
"kvmvccmavl"
,
New
)
types
.
RegisterDappFork
(
"store-kvmvccmavl"
,
"ForkKvmvccmavl"
,
18
6
*
10000
)
types
.
RegisterDappFork
(
"store-kvmvccmavl"
,
"ForkKvmvccmavl"
,
18
7
*
10000
)
}
}
// KVmMavlStore provide kvmvcc and mavl store interface implementation
// KVmMavlStore provide kvmvcc and mavl store interface implementation
...
...
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