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
93bd040a
Commit
93bd040a
authored
Oct 12, 2019
by
liuyuhang
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'remotes/upstream/master' into mod_global_config
# Conflicts: # plugin/consensus/para/parasync.go
parents
aacdd6ce
91390fe4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
494 additions
and
5 deletions
+494
-5
chain33.para.toml
chain33.para.toml
+2
-2
parasync.go
plugin/consensus/para/parasync.go
+4
-3
game_test.go
plugin/dapp/game/executor/game_test.go
+485
-0
filtertxs.go
plugin/dapp/paracross/executor/filtertxs.go
+3
-0
No files found.
chain33.para.toml
View file @
93bd040a
...
...
@@ -90,8 +90,8 @@ coinDevFund=12
[consensus.sub.para]
#主链节点的grpc服务器ip,当前可以支持多ip负载均衡,如“1
01.37.227.226:8802,39.97.20.242:8802,47.107.15.126
:8802,jiedian2.bityuan.com,cloud.bityuan.com”
#ParaRemoteGrpcClient="1
83.129.226.74:8802,183.129.226.75:8802,101.37.227.226:8802,39.97.20.242:8802,47.107.15.126:8802,jiedian2.bityuan.com,cloud.bityuan.com
"
#主链节点的grpc服务器ip,当前可以支持多ip负载均衡,如“1
18.31.177.1:8802,39.97.2.127:8802,120.77.111.44
:8802,jiedian2.bityuan.com,cloud.bityuan.com”
#ParaRemoteGrpcClient="1
18.31.177.1:8802,39.97.2.127:8802,120.77.111.44:8802,jiedian2.bityuan.com,cloud.bityuan.com,183.129.226.74:8802,183.129.226.75:8802
"
ParaRemoteGrpcClient
=
"localhost:8802"
#主链指定高度的区块开始同步
startHeight
=
345850
...
...
plugin/consensus/para/parasync.go
View file @
93bd040a
...
...
@@ -362,12 +362,13 @@ func (client *blockSyncClient) addMinerTx(preStateHash []byte, block *types.Bloc
status
:=
&
pt
.
ParacrossNodeStatus
{
Title
:
cfg
.
GetTitle
(),
Height
:
block
.
Height
,
PreBlockHash
:
block
.
ParentHash
,
PreStateHash
:
preStateHash
,
MainBlockHash
:
localBlock
.
MainHash
,
MainBlockHeight
:
localBlock
.
MainHeight
,
}
if
!
pt
.
IsParaForkHeight
(
cfg
,
status
.
MainBlockHeight
,
pt
.
ForkLoopCheckCommitTxDone
)
{
status
.
PreBlockHash
=
block
.
ParentHash
status
.
PreStateHash
=
preStateHash
}
tx
,
err
:=
pt
.
CreateRawMinerTx
(
cfg
,
&
pt
.
ParacrossMinerAction
{
Status
:
status
,
IsSelfConsensus
:
client
.
paraClient
.
isParaSelfConsensusForked
(
status
.
MainBlockHeight
),
...
...
plugin/dapp/game/executor/game_test.go
0 → 100644
View file @
93bd040a
package
executor
import
(
"testing"
"github.com/33cn/chain33/account"
"github.com/33cn/chain33/common/address"
"github.com/33cn/chain33/types"
"github.com/33cn/chain33/util"
"github.com/33cn/chain33/common"
"github.com/33cn/chain33/common/crypto"
dbm
"github.com/33cn/chain33/common/db"
pty
"github.com/33cn/plugin/plugin/dapp/game/types"
"github.com/stretchr/testify/assert"
)
type
execEnv
struct
{
blockTime
int64
blockHeight
int64
difficulty
uint64
}
var
(
PrivKeyA
=
"0x6da92a632ab7deb67d38c0f6560bcfed28167998f6496db64c258d5e8393a81b"
// 1KSBd17H7ZK8iT37aJztFB22XGwsPTdwE4
PrivKeyB
=
"0x19c069234f9d3e61135fefbeb7791b149cdf6af536f26bebb310d4cd22c3fee4"
// 1JRNjdEqp4LJ5fqycUBm9ayCKSeeskgMKR
PrivKeyC
=
"0x7a80a1f75d7360c6123c32a78ecf978c1ac55636f87892df38d8b85a9aeff115"
// 1NLHPEcbTWWxxU3dGUZBhayjrCHD3psX7k
PrivKeyD
=
"0xcacb1f5d51700aea07fca2246ab43b0917d70405c65edea9b5063d72eb5c6b71"
// 1MCftFynyvG2F4ED5mdHYgziDxx6vDrScs
Nodes
=
[][]
byte
{
[]
byte
(
"1KSBd17H7ZK8iT37aJztFB22XGwsPTdwE4"
),
[]
byte
(
"1JRNjdEqp4LJ5fqycUBm9ayCKSeeskgMKR"
),
[]
byte
(
"1NLHPEcbTWWxxU3dGUZBhayjrCHD3psX7k"
),
[]
byte
(
"1MCftFynyvG2F4ED5mdHYgziDxx6vDrScs"
),
}
)
func
TestGame
(
t
*
testing
.
T
)
{
types
.
SetTitleOnlyForTest
(
"chain33"
)
total
:=
100
*
types
.
Coin
accountA
:=
types
.
Account
{
Balance
:
total
,
Frozen
:
0
,
Addr
:
string
(
Nodes
[
0
]),
}
accountB
:=
types
.
Account
{
Balance
:
total
,
Frozen
:
0
,
Addr
:
string
(
Nodes
[
1
]),
}
accountC
:=
types
.
Account
{
Balance
:
total
,
Frozen
:
0
,
Addr
:
string
(
Nodes
[
2
]),
}
accountD
:=
types
.
Account
{
Balance
:
total
,
Frozen
:
0
,
Addr
:
string
(
Nodes
[
3
]),
}
execAddr
:=
address
.
ExecAddress
(
pty
.
GameX
)
stateDB
,
_
:=
dbm
.
NewGoMemDB
(
"1"
,
"2"
,
1000
)
_
,
_
,
kvdb
:=
util
.
CreateTestDB
()
accA
,
_
:=
account
.
NewAccountDB
(
"coins"
,
"bty"
,
stateDB
)
accA
.
SaveExecAccount
(
execAddr
,
&
accountA
)
accB
,
_
:=
account
.
NewAccountDB
(
"coins"
,
"bty"
,
stateDB
)
accB
.
SaveExecAccount
(
execAddr
,
&
accountB
)
accC
,
_
:=
account
.
NewAccountDB
(
"coins"
,
"bty"
,
stateDB
)
accC
.
SaveExecAccount
(
execAddr
,
&
accountC
)
accD
,
_
:=
account
.
NewAccountDB
(
"coins"
,
"bty"
,
stateDB
)
accD
.
SaveExecAccount
(
execAddr
,
&
accountD
)
env
:=
execEnv
{
10
,
types
.
GetDappFork
(
pty
.
GameX
,
"Enable"
),
1539918074
,
}
// create game
createParam
:=
&
pty
.
GamePreCreateTx
{
Amount
:
2
*
types
.
Coin
,
HashType
:
"sha256"
,
HashValue
:
common
.
Sha256
([]
byte
(
"harrylee"
+
string
(
Rock
))),
Fee
:
100000
}
createTx
,
err
:=
pty
.
CreateRawGamePreCreateTx
(
createParam
)
if
err
!=
nil
{
t
.
Error
(
err
)
}
createTx
,
err
=
signTx
(
createTx
,
PrivKeyA
)
if
err
!=
nil
{
t
.
Error
(
err
)
}
exec
:=
newGame
()
exec
.
SetStateDB
(
stateDB
)
exec
.
SetLocalDB
(
kvdb
)
exec
.
SetEnv
(
1
,
env
.
blockTime
,
env
.
difficulty
)
receipt
,
err
:=
exec
.
Exec
(
createTx
,
int
(
1
))
if
err
!=
nil
{
t
.
Error
(
err
)
}
for
_
,
kv
:=
range
receipt
.
KV
{
stateDB
.
Set
(
kv
.
Key
,
kv
.
Value
)
}
receiptDate
:=
&
types
.
ReceiptData
{
Ty
:
receipt
.
Ty
,
Logs
:
receipt
.
Logs
}
set
,
err
:=
exec
.
ExecLocal
(
createTx
,
receiptDate
,
int
(
1
))
if
err
!=
nil
{
t
.
Error
(
err
)
}
for
_
,
kv
:=
range
set
.
KV
{
kvdb
.
Set
(
kv
.
Key
,
kv
.
Value
)
}
gameID
:=
common
.
ToHex
(
createTx
.
Hash
())
//match game
matchParam
:=
&
pty
.
GamePreMatchTx
{
GameID
:
gameID
,
Guess
:
Scissor
,
Fee
:
100000
}
matchTx
,
err
:=
pty
.
CreateRawGamePreMatchTx
(
matchParam
)
if
err
!=
nil
{
t
.
Error
(
err
)
}
matchTx
,
err
=
signTx
(
matchTx
,
PrivKeyB
)
if
err
!=
nil
{
t
.
Error
(
err
)
}
exec
.
SetStateDB
(
stateDB
)
exec
.
SetLocalDB
(
kvdb
)
exec
.
SetEnv
(
2
,
env
.
blockTime
+
20
,
env
.
difficulty
)
receipt
,
err
=
exec
.
Exec
(
matchTx
,
int
(
1
))
if
err
!=
nil
{
t
.
Error
(
err
)
}
for
_
,
kv
:=
range
receipt
.
KV
{
stateDB
.
Set
(
kv
.
Key
,
kv
.
Value
)
}
receiptDate
=
&
types
.
ReceiptData
{
Ty
:
receipt
.
Ty
,
Logs
:
receipt
.
Logs
}
set
,
err
=
exec
.
ExecLocal
(
matchTx
,
receiptDate
,
int
(
1
))
for
_
,
kv
:=
range
set
.
KV
{
kvdb
.
Set
(
kv
.
Key
,
kv
.
Value
)
}
msg
,
err
:=
exec
.
Query
(
pty
.
FuncNameQueryGameListByIds
,
types
.
Encode
(
&
pty
.
QueryGameInfos
{
GameIds
:
[]
string
{
gameID
},
}))
if
err
!=
nil
{
t
.
Error
(
err
)
}
t
.
Log
(
msg
)
msg
,
err
=
exec
.
Query
(
pty
.
FuncNameQueryGameByID
,
types
.
Encode
(
&
pty
.
QueryGameInfo
{
GameId
:
gameID
}))
if
err
!=
nil
{
t
.
Error
(
err
)
}
t
.
Log
(
msg
)
msg
,
err
=
exec
.
Query
(
pty
.
FuncNameQueryGameListByStatusAndAddr
,
types
.
Encode
(
&
pty
.
QueryGameListByStatusAndAddr
{
Status
:
pty
.
GameActionMatch
}))
if
err
!=
nil
{
t
.
Error
(
err
)
}
//close game
closeParam
:=
&
pty
.
GamePreCloseTx
{
GameID
:
gameID
,
Secret
:
"harrylee"
,
Result
:
Rock
,
Fee
:
100000
}
closeTx
,
err
:=
pty
.
CreateRawGamePreCloseTx
(
closeParam
)
if
err
!=
nil
{
t
.
Error
(
err
)
}
closeTx
,
err
=
signTx
(
closeTx
,
PrivKeyA
)
if
err
!=
nil
{
t
.
Error
(
err
)
}
exec
.
SetStateDB
(
stateDB
)
exec
.
SetLocalDB
(
kvdb
)
exec
.
SetEnv
(
2
,
env
.
blockTime
+
20
,
env
.
difficulty
)
receipt
,
err
=
exec
.
Exec
(
closeTx
,
int
(
1
))
if
err
!=
nil
{
t
.
Error
(
err
)
}
for
_
,
kv
:=
range
receipt
.
KV
{
stateDB
.
Set
(
kv
.
Key
,
kv
.
Value
)
}
receiptDate
=
&
types
.
ReceiptData
{
Ty
:
receipt
.
Ty
,
Logs
:
receipt
.
Logs
}
set
,
err
=
exec
.
ExecLocal
(
closeTx
,
receiptDate
,
int
(
1
))
for
_
,
kv
:=
range
set
.
KV
{
kvdb
.
Set
(
kv
.
Key
,
kv
.
Value
)
}
acA
:=
accA
.
LoadExecAccount
(
string
(
Nodes
[
0
]),
execAddr
)
acB
:=
accB
.
LoadExecAccount
(
string
(
Nodes
[
1
]),
execAddr
)
t
.
Log
(
acA
)
t
.
Log
(
acB
)
msg
,
err
=
exec
.
Query
(
pty
.
FuncNameQueryGameByID
,
types
.
Encode
(
&
pty
.
QueryGameInfo
{
GameId
:
gameID
}))
if
err
!=
nil
{
t
.
Error
(
err
)
}
reply
:=
msg
.
(
*
pty
.
ReplyGame
)
assert
.
Equal
(
t
,
int32
(
pty
.
GameActionClose
),
reply
.
Game
.
Status
)
assert
.
Equal
(
t
,
IsCreatorWin
,
reply
.
Game
.
Result
)
// create game
createParam
=
&
pty
.
GamePreCreateTx
{
Amount
:
2
*
types
.
Coin
,
HashType
:
"sha256"
,
HashValue
:
common
.
Sha256
([]
byte
(
"123456"
+
string
(
Rock
))),
Fee
:
100000
}
createTx
,
err
=
pty
.
CreateRawGamePreCreateTx
(
createParam
)
if
err
!=
nil
{
t
.
Error
(
err
)
}
createTx
,
err
=
signTx
(
createTx
,
PrivKeyC
)
if
err
!=
nil
{
t
.
Error
(
err
)
}
exec
.
SetStateDB
(
stateDB
)
exec
.
SetLocalDB
(
kvdb
)
exec
.
SetEnv
(
1
,
env
.
blockTime
,
env
.
difficulty
)
receipt
,
err
=
exec
.
Exec
(
createTx
,
int
(
1
))
if
err
!=
nil
{
t
.
Error
(
err
)
}
for
_
,
kv
:=
range
receipt
.
KV
{
stateDB
.
Set
(
kv
.
Key
,
kv
.
Value
)
}
receiptDate
=
&
types
.
ReceiptData
{
Ty
:
receipt
.
Ty
,
Logs
:
receipt
.
Logs
}
set
,
err
=
exec
.
ExecLocal
(
createTx
,
receiptDate
,
int
(
1
))
if
err
!=
nil
{
t
.
Error
(
err
)
}
for
_
,
kv
:=
range
set
.
KV
{
kvdb
.
Set
(
kv
.
Key
,
kv
.
Value
)
}
gameID
=
common
.
ToHex
(
createTx
.
Hash
())
//cancle game
cancleParam
:=
&
pty
.
GamePreCancelTx
{
Fee
:
1e5
,
GameID
:
gameID
}
cancelTx
,
err
:=
pty
.
CreateRawGamePreCancelTx
(
cancleParam
)
if
err
!=
nil
{
t
.
Error
(
err
)
}
createTx
,
err
=
signTx
(
cancelTx
,
PrivKeyC
)
if
err
!=
nil
{
t
.
Error
(
err
)
}
exec
.
SetStateDB
(
stateDB
)
exec
.
SetLocalDB
(
kvdb
)
exec
.
SetEnv
(
1
,
env
.
blockTime
,
env
.
difficulty
)
receipt
,
err
=
exec
.
Exec
(
cancelTx
,
int
(
1
))
if
err
!=
nil
{
t
.
Error
(
err
)
}
for
_
,
kv
:=
range
receipt
.
KV
{
stateDB
.
Set
(
kv
.
Key
,
kv
.
Value
)
}
receiptDate
=
&
types
.
ReceiptData
{
Ty
:
receipt
.
Ty
,
Logs
:
receipt
.
Logs
}
set
,
err
=
exec
.
ExecLocal
(
cancelTx
,
receiptDate
,
int
(
1
))
if
err
!=
nil
{
t
.
Error
(
err
)
}
for
_
,
kv
:=
range
set
.
KV
{
kvdb
.
Set
(
kv
.
Key
,
kv
.
Value
)
}
msg
,
err
=
exec
.
Query
(
pty
.
FuncNameQueryGameByID
,
types
.
Encode
(
&
pty
.
QueryGameInfo
{
GameId
:
gameID
}))
if
err
!=
nil
{
t
.
Error
(
err
)
}
reply
=
msg
.
(
*
pty
.
ReplyGame
)
assert
.
Equal
(
t
,
int32
(
pty
.
GameActionCancel
),
reply
.
Game
.
Status
)
//create game
createParam
=
&
pty
.
GamePreCreateTx
{
Amount
:
2
*
types
.
Coin
,
HashType
:
"sha256"
,
HashValue
:
common
.
Sha256
([]
byte
(
"123456"
+
string
(
Rock
))),
Fee
:
100000
}
createTx
,
err
=
pty
.
CreateRawGamePreCreateTx
(
createParam
)
if
err
!=
nil
{
t
.
Error
(
err
)
}
createTx
,
err
=
signTx
(
createTx
,
PrivKeyC
)
if
err
!=
nil
{
t
.
Error
(
err
)
}
exec
.
SetStateDB
(
stateDB
)
exec
.
SetLocalDB
(
kvdb
)
exec
.
SetEnv
(
1
,
env
.
blockTime
,
env
.
difficulty
)
receipt
,
err
=
exec
.
Exec
(
createTx
,
int
(
1
))
if
err
!=
nil
{
t
.
Error
(
err
)
}
for
_
,
kv
:=
range
receipt
.
KV
{
stateDB
.
Set
(
kv
.
Key
,
kv
.
Value
)
}
receiptDate
=
&
types
.
ReceiptData
{
Ty
:
receipt
.
Ty
,
Logs
:
receipt
.
Logs
}
set
,
err
=
exec
.
ExecLocal
(
createTx
,
receiptDate
,
int
(
1
))
if
err
!=
nil
{
t
.
Error
(
err
)
}
for
_
,
kv
:=
range
set
.
KV
{
kvdb
.
Set
(
kv
.
Key
,
kv
.
Value
)
}
gameID
=
common
.
ToHex
(
createTx
.
Hash
())
//match game
matchParam
=
&
pty
.
GamePreMatchTx
{
GameID
:
gameID
,
Guess
:
Rock
,
Fee
:
100000
}
matchTx
,
err
=
pty
.
CreateRawGamePreMatchTx
(
matchParam
)
if
err
!=
nil
{
t
.
Error
(
err
)
}
matchTx
,
err
=
signTx
(
matchTx
,
PrivKeyB
)
if
err
!=
nil
{
t
.
Error
(
err
)
}
exec
.
SetStateDB
(
stateDB
)
exec
.
SetLocalDB
(
kvdb
)
exec
.
SetEnv
(
2
,
env
.
blockTime
+
20
,
env
.
difficulty
)
receipt
,
err
=
exec
.
Exec
(
matchTx
,
int
(
1
))
if
err
!=
nil
{
t
.
Error
(
err
)
}
for
_
,
kv
:=
range
receipt
.
KV
{
stateDB
.
Set
(
kv
.
Key
,
kv
.
Value
)
}
receiptDate
=
&
types
.
ReceiptData
{
Ty
:
receipt
.
Ty
,
Logs
:
receipt
.
Logs
}
set
,
err
=
exec
.
ExecLocal
(
matchTx
,
receiptDate
,
int
(
1
))
for
_
,
kv
:=
range
set
.
KV
{
kvdb
.
Set
(
kv
.
Key
,
kv
.
Value
)
}
//close game
closeParam
=
&
pty
.
GamePreCloseTx
{
GameID
:
gameID
,
Secret
:
"123456"
,
Result
:
Rock
,
Fee
:
100000
}
closeTx
,
err
=
pty
.
CreateRawGamePreCloseTx
(
closeParam
)
if
err
!=
nil
{
t
.
Error
(
err
)
}
closeTx
,
err
=
signTx
(
closeTx
,
PrivKeyC
)
if
err
!=
nil
{
t
.
Error
(
err
)
}
exec
.
SetStateDB
(
stateDB
)
exec
.
SetLocalDB
(
kvdb
)
exec
.
SetEnv
(
2
,
env
.
blockTime
+
20
,
env
.
difficulty
)
receipt
,
err
=
exec
.
Exec
(
closeTx
,
int
(
1
))
if
err
!=
nil
{
t
.
Error
(
err
)
}
for
_
,
kv
:=
range
receipt
.
KV
{
stateDB
.
Set
(
kv
.
Key
,
kv
.
Value
)
}
receiptDate
=
&
types
.
ReceiptData
{
Ty
:
receipt
.
Ty
,
Logs
:
receipt
.
Logs
}
set
,
err
=
exec
.
ExecLocal
(
closeTx
,
receiptDate
,
int
(
1
))
for
_
,
kv
:=
range
set
.
KV
{
kvdb
.
Set
(
kv
.
Key
,
kv
.
Value
)
}
msg
,
err
=
exec
.
Query
(
pty
.
FuncNameQueryGameByID
,
types
.
Encode
(
&
pty
.
QueryGameInfo
{
GameId
:
gameID
}))
if
err
!=
nil
{
t
.
Error
(
err
)
}
reply
=
msg
.
(
*
pty
.
ReplyGame
)
assert
.
Equal
(
t
,
int32
(
pty
.
GameActionClose
),
reply
.
Game
.
Status
)
assert
.
Equal
(
t
,
IsDraw
,
reply
.
Game
.
Result
)
//create game
createParam
=
&
pty
.
GamePreCreateTx
{
Amount
:
2
*
types
.
Coin
,
HashType
:
"sha256"
,
HashValue
:
common
.
Sha256
([]
byte
(
"123456"
+
string
(
Rock
))),
Fee
:
100000
}
createTx
,
err
=
pty
.
CreateRawGamePreCreateTx
(
createParam
)
if
err
!=
nil
{
t
.
Error
(
err
)
}
createTx
,
err
=
signTx
(
createTx
,
PrivKeyC
)
if
err
!=
nil
{
t
.
Error
(
err
)
}
exec
.
SetStateDB
(
stateDB
)
exec
.
SetLocalDB
(
kvdb
)
exec
.
SetEnv
(
1
,
env
.
blockTime
,
env
.
difficulty
)
receipt
,
err
=
exec
.
Exec
(
createTx
,
int
(
1
))
if
err
!=
nil
{
t
.
Error
(
err
)
}
for
_
,
kv
:=
range
receipt
.
KV
{
stateDB
.
Set
(
kv
.
Key
,
kv
.
Value
)
}
receiptDate
=
&
types
.
ReceiptData
{
Ty
:
receipt
.
Ty
,
Logs
:
receipt
.
Logs
}
set
,
err
=
exec
.
ExecLocal
(
createTx
,
receiptDate
,
int
(
1
))
if
err
!=
nil
{
t
.
Error
(
err
)
}
for
_
,
kv
:=
range
set
.
KV
{
kvdb
.
Set
(
kv
.
Key
,
kv
.
Value
)
}
gameID
=
common
.
ToHex
(
createTx
.
Hash
())
//match game
matchParam
=
&
pty
.
GamePreMatchTx
{
GameID
:
gameID
,
Guess
:
Paper
,
Fee
:
100000
}
matchTx
,
err
=
pty
.
CreateRawGamePreMatchTx
(
matchParam
)
if
err
!=
nil
{
t
.
Error
(
err
)
}
matchTx
,
err
=
signTx
(
matchTx
,
PrivKeyB
)
if
err
!=
nil
{
t
.
Error
(
err
)
}
exec
.
SetStateDB
(
stateDB
)
exec
.
SetLocalDB
(
kvdb
)
exec
.
SetEnv
(
2
,
env
.
blockTime
+
20
,
env
.
difficulty
)
receipt
,
err
=
exec
.
Exec
(
matchTx
,
int
(
1
))
if
err
!=
nil
{
t
.
Error
(
err
)
}
for
_
,
kv
:=
range
receipt
.
KV
{
stateDB
.
Set
(
kv
.
Key
,
kv
.
Value
)
}
receiptDate
=
&
types
.
ReceiptData
{
Ty
:
receipt
.
Ty
,
Logs
:
receipt
.
Logs
}
set
,
err
=
exec
.
ExecLocal
(
matchTx
,
receiptDate
,
int
(
1
))
for
_
,
kv
:=
range
set
.
KV
{
kvdb
.
Set
(
kv
.
Key
,
kv
.
Value
)
}
//close game
closeParam
=
&
pty
.
GamePreCloseTx
{
GameID
:
gameID
,
Secret
:
"123456"
,
Result
:
Rock
,
Fee
:
100000
}
closeTx
,
err
=
pty
.
CreateRawGamePreCloseTx
(
closeParam
)
if
err
!=
nil
{
t
.
Error
(
err
)
}
closeTx
,
err
=
signTx
(
closeTx
,
PrivKeyC
)
if
err
!=
nil
{
t
.
Error
(
err
)
}
exec
.
SetStateDB
(
stateDB
)
exec
.
SetLocalDB
(
kvdb
)
exec
.
SetEnv
(
2
,
env
.
blockTime
+
20
,
env
.
difficulty
)
receipt
,
err
=
exec
.
Exec
(
closeTx
,
int
(
1
))
if
err
!=
nil
{
t
.
Error
(
err
)
}
for
_
,
kv
:=
range
receipt
.
KV
{
stateDB
.
Set
(
kv
.
Key
,
kv
.
Value
)
}
receiptDate
=
&
types
.
ReceiptData
{
Ty
:
receipt
.
Ty
,
Logs
:
receipt
.
Logs
}
set
,
err
=
exec
.
ExecLocal
(
closeTx
,
receiptDate
,
int
(
1
))
for
_
,
kv
:=
range
set
.
KV
{
kvdb
.
Set
(
kv
.
Key
,
kv
.
Value
)
}
msg
,
err
=
exec
.
Query
(
pty
.
FuncNameQueryGameByID
,
types
.
Encode
(
&
pty
.
QueryGameInfo
{
GameId
:
gameID
}))
if
err
!=
nil
{
t
.
Error
(
err
)
}
reply
=
msg
.
(
*
pty
.
ReplyGame
)
assert
.
Equal
(
t
,
int32
(
pty
.
GameActionClose
),
reply
.
Game
.
Status
)
assert
.
Equal
(
t
,
IsMatcherWin
,
reply
.
Game
.
Result
)
}
func
signTx
(
tx
*
types
.
Transaction
,
hexPrivKey
string
)
(
*
types
.
Transaction
,
error
)
{
signType
:=
types
.
SECP256K1
c
,
err
:=
crypto
.
New
(
types
.
GetSignName
(
""
,
signType
))
if
err
!=
nil
{
return
tx
,
err
}
bytes
,
err
:=
common
.
FromHex
(
hexPrivKey
[
:
])
if
err
!=
nil
{
return
tx
,
err
}
privKey
,
err
:=
c
.
PrivKeyFromBytes
(
bytes
)
if
err
!=
nil
{
return
tx
,
err
}
tx
.
Sign
(
int32
(
signType
),
privKey
)
return
tx
,
nil
}
plugin/dapp/paracross/executor/filtertxs.go
View file @
93bd040a
...
...
@@ -6,6 +6,7 @@ package executor
import
(
"bytes"
"encoding/hex"
"github.com/33cn/chain33/common"
"github.com/33cn/chain33/types"
...
...
@@ -65,6 +66,7 @@ func filterParaTxGroup(cfg *types.Chain33Config, tx *types.Transaction, allTxs [
}
if
!
checkReceiptExecOk
(
allTxs
[
i
]
.
Receipt
)
{
clog
.
Error
(
"filterParaTxGroup rmv tx group"
,
"txhash"
,
hex
.
EncodeToString
(
allTxs
[
i
]
.
Tx
.
Hash
()))
return
nil
,
endIdx
}
}
...
...
@@ -90,6 +92,7 @@ func FilterTxsForPara(cfg *types.Chain33Config, main *types.ParaTxDetail) []*typ
}
//单独的paracross tx 如果主链执行失败也要排除, 6.2fork原因 没有排除 非user.p.xx.paracross的平行链交易
if
main
.
Header
.
Height
>=
forkHeight
&&
bytes
.
HasSuffix
(
tx
.
Execer
,
[]
byte
(
pt
.
ParaX
))
&&
!
checkReceiptExecOk
(
main
.
TxDetails
[
i
]
.
Receipt
)
{
clog
.
Error
(
"FilterTxsForPara rmv tx"
,
"txhash"
,
hex
.
EncodeToString
(
tx
.
Hash
()))
continue
}
...
...
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