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
20472856
Commit
20472856
authored
Mar 29, 2019
by
liuyuhang
Committed by
vipwzw
Apr 01, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
将本地更新的chain33部分合并到plugin里面
parent
54ea2ad8
Show whitespace changes
Inline
Side-by-side
Showing
30 changed files
with
539 additions
and
105 deletions
+539
-105
chain33.toml
chain33.toml
+12
-0
round_state.go
plugin/consensus/tendermint/types/round_state.go
+0
-0
certutils.go
...rt/authority/tools/cryptogen/generator/utils/certutils.go
+0
-0
kvdb.go
plugin/store/kvdb/kvdb.go
+15
-0
kvmvccdb.go
plugin/store/kvmvcc/kvmvccdb.go
+15
-0
kvmvcc_mavl.go
plugin/store/kvmvccmavl/kvmvcc_mavl.go
+87
-2
kvmvccdb.go
plugin/store/kvmvccmavl/kvmvccdb.go
+5
-0
mavl.go
plugin/store/kvmvccmavl/mavl.go
+27
-0
mpt.go
plugin/store/mpt/mpt.go
+15
-0
chain.go
vendor/github.com/33cn/chain33/blockchain/chain.go
+0
-1
chain_test.go
vendor/github.com/33cn/chain33/blockchain/chain_test.go
+20
-0
exec.go
vendor/github.com/33cn/chain33/blockchain/exec.go
+5
-0
proc.go
vendor/github.com/33cn/chain33/blockchain/proc.go
+17
-4
process.go
vendor/github.com/33cn/chain33/blockchain/process.go
+36
-0
base.go
vendor/github.com/33cn/chain33/system/store/base.go
+21
-2
base_test.go
vendor/github.com/33cn/chain33/system/store/base_test.go
+8
-0
node.go
vendor/github.com/33cn/chain33/system/store/mavl/db/node.go
+3
-0
tree.go
vendor/github.com/33cn/chain33/system/store/mavl/db/tree.go
+10
-15
mavl.go
vendor/github.com/33cn/chain33/system/store/mavl/mavl.go
+32
-0
mavl_test.go
...or/github.com/33cn/chain33/system/store/mavl/mavl_test.go
+55
-0
common.pb.go
vendor/github.com/33cn/chain33/types/common.pb.go
+38
-29
db.pb.go
vendor/github.com/33cn/chain33/types/db.pb.go
+48
-40
event.go
vendor/github.com/33cn/chain33/types/event.go
+2
-0
common.proto
vendor/github.com/33cn/chain33/types/proto/common.proto
+1
-0
db.proto
vendor/github.com/33cn/chain33/types/proto/db.proto
+1
-0
chain33.go
vendor/github.com/33cn/chain33/util/cli/chain33.go
+4
-4
exec.go
vendor/github.com/33cn/chain33/util/exec.go
+4
-4
util.go
vendor/github.com/33cn/chain33/util/util.go
+44
-2
util_test.go
vendor/github.com/33cn/chain33/util/util_test.go
+12
-0
wallet_test.go
vendor/github.com/33cn/chain33/wallet/wallet_test.go
+2
-2
No files found.
chain33.toml
View file @
20472856
...
...
@@ -146,6 +146,18 @@ enableMemTree=true
# 是否使能mavl叶子节点数据载入内存
enableMemVal
=
true
[store.sub.kvmvccmavl]
enableMavlPrefix
=
false
enableMVCC
=
false
enableMavlPrune
=
false
pruneHeight
=
10000
# 是否使能mavl数据载入内存
enableMemTree
=
true
# 是否使能mavl叶子节点数据载入内存
enableMemVal
=
true
# 是否使能升级kvmvcc(在mavl数据上)
enableUpdateKvmvcc
=
false
[wallet]
minFee
=
100000
driver
=
"leveldb"
...
...
plugin/consensus/tendermint/types/round_state.go
View file @
20472856
plugin/dapp/cert/authority/tools/cryptogen/generator/utils/certutils.go
View file @
20472856
plugin/store/kvdb/kvdb.go
View file @
20472856
...
...
@@ -121,6 +121,18 @@ func (kvs *KVStore) Commit(req *types.ReqHash) ([]byte, error) {
return
req
.
Hash
,
nil
}
// MemSetUpgrade set kvs to the mem of KVStore
func
(
kvs
*
KVStore
)
MemSetUpgrade
(
datas
*
types
.
StoreSet
,
sync
bool
)
([]
byte
,
error
)
{
//not support
return
nil
,
nil
}
// CommitUpgrade kvs in the mem of KVStore
func
(
kvs
*
KVStore
)
CommitUpgrade
(
req
*
types
.
ReqHash
)
([]
byte
,
error
)
{
//not support
return
nil
,
nil
}
// Rollback kvs in the mem of KVStore
func
(
kvs
*
KVStore
)
Rollback
(
req
*
types
.
ReqHash
)
([]
byte
,
error
)
{
_
,
ok
:=
kvs
.
cache
[
string
(
req
.
Hash
)]
...
...
@@ -141,6 +153,9 @@ func (kvs *KVStore) IterateRangeByStateHash(statehash []byte, start []byte, end
// ProcEvent handles supported events
func
(
kvs
*
KVStore
)
ProcEvent
(
msg
*
queue
.
Message
)
{
if
msg
==
nil
{
return
}
msg
.
ReplyErr
(
"KVStore"
,
types
.
ErrActionNotSupport
)
}
...
...
plugin/store/kvmvcc/kvmvccdb.go
View file @
20472856
...
...
@@ -131,6 +131,18 @@ func (mvccs *KVMVCCStore) Commit(req *types.ReqHash) ([]byte, error) {
return
req
.
Hash
,
nil
}
// MemSetUpgrade set kvs to the mem of KVMVCCStore module and return the StateHash
func
(
mvccs
*
KVMVCCStore
)
MemSetUpgrade
(
datas
*
types
.
StoreSet
,
sync
bool
)
([]
byte
,
error
)
{
//not support
return
nil
,
nil
}
// CommitUpgrade kvs in the mem of KVMVCCStore module to state db and return the StateHash
func
(
mvccs
*
KVMVCCStore
)
CommitUpgrade
(
req
*
types
.
ReqHash
)
([]
byte
,
error
)
{
//not support
return
nil
,
nil
}
// Rollback kvs in the mem of KVMVCCStore module and return the StateHash
func
(
mvccs
*
KVMVCCStore
)
Rollback
(
req
*
types
.
ReqHash
)
([]
byte
,
error
)
{
_
,
ok
:=
mvccs
.
kvsetmap
[
string
(
req
.
Hash
)]
...
...
@@ -175,6 +187,9 @@ func (mvccs *KVMVCCStore) IterateRangeByStateHash(statehash []byte, start []byte
// ProcEvent handles supported events
func
(
mvccs
*
KVMVCCStore
)
ProcEvent
(
msg
*
queue
.
Message
)
{
if
msg
==
nil
{
return
}
msg
.
ReplyErr
(
"KVStore"
,
types
.
ErrActionNotSupport
)
}
...
...
plugin/store/kvmvccmavl/kvmvcc_mavl.go
View file @
20472856
...
...
@@ -33,6 +33,11 @@ var (
delMavlDataState
int32
wg
sync
.
WaitGroup
quit
bool
// 用来阻塞查看当前是否需要升级数据库
done
chan
struct
{}
// 使能mavl在当前区块基础上升级kvmvcc
enableUpdateKvmvcc
bool
)
const
(
...
...
@@ -54,6 +59,7 @@ func DisableLog() {
func
init
()
{
drivers
.
Reg
(
"kvmvccmavl"
,
New
)
done
=
make
(
chan
struct
{},
1
)
}
// KVmMavlStore provide kvmvcc and mavl store interface implementation
...
...
@@ -75,6 +81,10 @@ type subMavlConfig struct {
EnableMVCC
bool
`json:"enableMVCC"`
EnableMavlPrune
bool
`json:"enableMavlPrune"`
PruneHeight
int32
`json:"pruneHeight"`
// 是否使能内存树
EnableMemTree
bool
`json:"enableMemTree"`
// 是否使能内存树中叶子节点
EnableMemVal
bool
`json:"enableMemVal"`
}
type
subConfig
struct
{
...
...
@@ -83,11 +93,15 @@ type subConfig struct {
EnableMVCC
bool
`json:"enableMVCC"`
EnableMavlPrune
bool
`json:"enableMavlPrune"`
PruneHeight
int32
`json:"pruneHeight"`
// 是否使能内存树
EnableMemTree
bool
`json:"enableMemTree"`
// 是否使能内存树中叶子节点
EnableMemVal
bool
`json:"enableMemVal"`
EnableUpdateKvmvcc
bool
`json:"enableUpdateKvmvcc"`
}
// New construct KVMVCCStore module
func
New
(
cfg
*
types
.
Store
,
sub
[]
byte
)
queue
.
Module
{
bs
:=
drivers
.
NewBaseStore
(
cfg
)
var
kvms
*
KVmMavlStore
var
subcfg
subConfig
var
subKVMVCCcfg
subKVMVCCConfig
...
...
@@ -102,7 +116,15 @@ func New(cfg *types.Store, sub []byte) queue.Module {
subMavlcfg
.
EnableMVCC
=
subcfg
.
EnableMVCC
subMavlcfg
.
EnableMavlPrune
=
subcfg
.
EnableMavlPrune
subMavlcfg
.
PruneHeight
=
subcfg
.
PruneHeight
subMavlcfg
.
EnableMemTree
=
subcfg
.
EnableMemTree
subMavlcfg
.
EnableMemVal
=
subcfg
.
EnableMemVal
}
if
subcfg
.
EnableUpdateKvmvcc
{
enableUpdateKvmvcc
=
true
}
bs
:=
drivers
.
NewBaseStore
(
cfg
)
cache
,
err
:=
lru
.
New
(
cacheSize
)
if
err
!=
nil
{
panic
(
"new KVmMavlStore fail"
)
...
...
@@ -239,7 +261,70 @@ func (kvmMavls *KVmMavlStore) IterateRangeByStateHash(statehash []byte, start []
// ProcEvent handles supported events
func
(
kvmMavls
*
KVmMavlStore
)
ProcEvent
(
msg
*
queue
.
Message
)
{
msg
.
ReplyErr
(
"KVmMavlStore"
,
types
.
ErrActionNotSupport
)
//msg.ReplyErr("KVmMavlStore", types.ErrActionNotSupport)
client
:=
kvmMavls
.
GetQueueClient
()
if
msg
!=
nil
&&
msg
.
Ty
==
types
.
EventReExecBlock
{
reData
:=
msg
.
GetData
()
.
(
*
types
.
ReplyString
)
if
reData
.
Data
==
"over"
{
kmlog
.
Info
(
"ProcEvent update store over"
)
msg
.
ReplyErr
(
"KVmMavlStore"
,
nil
)
done
<-
struct
{}{}
return
}
}
else
if
msg
==
nil
{
if
!
enableUpdateKvmvcc
{
return
}
height
,
err
:=
kvmMavls
.
KVMVCCStore
.
GetMaxVersion
()
if
err
!=
nil
{
height
=
0
}
else
{
height
++
}
msg1
:=
client
.
NewMessage
(
"blockchain"
,
types
.
EventReExecBlock
,
&
types
.
ReqInt
{
Height
:
height
})
err
=
client
.
Send
(
msg1
,
true
)
if
err
!=
nil
{
return
}
resp
,
err
:=
client
.
Wait
(
msg1
)
if
err
!=
nil
{
return
}
data
:=
resp
.
GetData
()
.
(
*
types
.
ReplyString
)
if
data
.
Data
==
"need"
{
//进程阻塞
<-
done
}
}
}
// MemSetUpgrade set kvs to the mem of KVmMavlStore module not cache the tree and return the StateHash
func
(
kvmMavls
*
KVmMavlStore
)
MemSetUpgrade
(
datas
*
types
.
StoreSet
,
sync
bool
)
([]
byte
,
error
)
{
if
datas
.
Height
<
kvmvccMavlFork
{
hash
,
err
:=
kvmMavls
.
MavlStore
.
MemSetUpgrade
(
datas
,
sync
)
if
err
!=
nil
{
return
hash
,
err
}
_
,
err
=
kvmMavls
.
KVMVCCStore
.
MemSet
(
datas
,
hash
,
sync
)
if
err
!=
nil
{
return
hash
,
err
}
if
err
==
nil
{
kvmMavls
.
cache
.
Add
(
string
(
hash
),
datas
.
Height
)
}
return
hash
,
err
}
// 仅仅做kvmvcc
hash
,
err
:=
kvmMavls
.
KVMVCCStore
.
MemSet
(
datas
,
nil
,
sync
)
if
err
==
nil
{
kvmMavls
.
cache
.
Add
(
string
(
hash
),
datas
.
Height
)
}
return
hash
,
err
}
// CommitUpgrade kvs in the mem of KVmMavlStore module to state db and return the StateHash
func
(
kvmMavls
*
KVmMavlStore
)
CommitUpgrade
(
req
*
types
.
ReqHash
)
([]
byte
,
error
)
{
return
kvmMavls
.
KVMVCCStore
.
Commit
(
req
)
}
// Del set kvs to nil with StateHash
...
...
plugin/store/kvmvccmavl/kvmvccdb.go
View file @
20472856
...
...
@@ -229,6 +229,11 @@ func (mvccs *KVMVCCStore) saveKVSets(kvset []*types.KeyValue) {
storeBatch
.
Write
()
}
// GetMaxVersion 获取当前最大高度
func
(
mvccs
*
KVMVCCStore
)
GetMaxVersion
()
(
int64
,
error
)
{
return
mvccs
.
mvcc
.
GetMaxVersion
()
}
func
(
mvccs
*
KVMVCCStore
)
checkVersion
(
height
int64
)
([]
*
types
.
KeyValue
,
error
)
{
//检查新加入区块的height和现有的version的关系,来判断是否要回滚数据
maxVersion
,
err
:=
mvccs
.
mvcc
.
GetMaxVersion
()
...
...
plugin/store/kvmvccmavl/mavl.go
View file @
20472856
...
...
@@ -32,12 +32,16 @@ func NewMavl(sub *subMavlConfig, db dbm.DB) *MavlStore {
subcfg
.
EnableMVCC
=
sub
.
EnableMVCC
subcfg
.
EnableMavlPrune
=
sub
.
EnableMavlPrune
subcfg
.
PruneHeight
=
sub
.
PruneHeight
subcfg
.
EnableMemTree
=
sub
.
EnableMemTree
subcfg
.
EnableMemVal
=
sub
.
EnableMemVal
}
mavls
:=
&
MavlStore
{
db
,
&
sync
.
Map
{},
subcfg
.
EnableMavlPrefix
,
subcfg
.
EnableMVCC
,
subcfg
.
EnableMavlPrune
,
subcfg
.
PruneHeight
}
mavl
.
EnableMavlPrefix
(
subcfg
.
EnableMavlPrefix
)
mavl
.
EnableMVCC
(
subcfg
.
EnableMVCC
)
mavl
.
EnablePrune
(
subcfg
.
EnableMavlPrune
)
mavl
.
SetPruneHeight
(
int
(
subcfg
.
PruneHeight
))
mavl
.
EnableMemTree
(
subcfg
.
EnableMemTree
)
mavl
.
EnableMemVal
(
subcfg
.
EnableMemVal
)
return
mavls
}
...
...
@@ -103,6 +107,29 @@ func (mavls *MavlStore) MemSet(datas *types.StoreSet, sync bool) ([]byte, error)
return
hash
,
nil
}
// MemSetUpgrade 计算hash之后不在内存中存储树
func
(
mavls
*
MavlStore
)
MemSetUpgrade
(
datas
*
types
.
StoreSet
,
sync
bool
)
([]
byte
,
error
)
{
beg
:=
types
.
Now
()
defer
func
()
{
kmlog
.
Info
(
"MemSet"
,
"cost"
,
types
.
Since
(
beg
))
}()
if
len
(
datas
.
KV
)
==
0
{
kmlog
.
Info
(
"store mavl memset,use preStateHash as stateHash for kvset is null"
)
return
datas
.
StateHash
,
nil
}
tree
:=
mavl
.
NewTree
(
mavls
.
db
,
sync
)
tree
.
SetBlockHeight
(
datas
.
Height
)
err
:=
tree
.
Load
(
datas
.
StateHash
)
if
err
!=
nil
{
return
nil
,
err
}
for
i
:=
0
;
i
<
len
(
datas
.
KV
);
i
++
{
tree
.
Set
(
datas
.
KV
[
i
]
.
Key
,
datas
.
KV
[
i
]
.
Value
)
}
hash
:=
tree
.
Hash
()
return
hash
,
nil
}
// Commit convert memcory mavl to storage db
func
(
mavls
*
MavlStore
)
Commit
(
req
*
types
.
ReqHash
)
([]
byte
,
error
)
{
beg
:=
types
.
Now
()
...
...
plugin/store/mpt/mpt.go
View file @
20472856
...
...
@@ -135,6 +135,18 @@ func (mpts *Store) Commit(req *types.ReqHash) ([]byte, error) {
return
req
.
Hash
,
nil
}
// MemSetUpgrade set keys values to memcory mpt, return root hash and error
func
(
mpts
*
Store
)
MemSetUpgrade
(
datas
*
types
.
StoreSet
,
sync
bool
)
([]
byte
,
error
)
{
//not support
return
nil
,
nil
}
// CommitUpgrade convert memcory mpt to storage db
func
(
mpts
*
Store
)
CommitUpgrade
(
req
*
types
.
ReqHash
)
([]
byte
,
error
)
{
//not support
return
nil
,
nil
}
// Rollback 回退将缓存的mpt树删除掉
func
(
mpts
*
Store
)
Rollback
(
req
*
types
.
ReqHash
)
([]
byte
,
error
)
{
_
,
ok
:=
mpts
.
trees
[
string
(
req
.
Hash
)]
...
...
@@ -159,5 +171,8 @@ func (mpts *Store) IterateRangeByStateHash(statehash []byte, start []byte, end [
// ProcEvent not support message
func
(
mpts
*
Store
)
ProcEvent
(
msg
*
queue
.
Message
)
{
if
msg
==
nil
{
return
}
msg
.
ReplyErr
(
"Store"
,
types
.
ErrActionNotSupport
)
}
vendor/github.com/33cn/chain33/blockchain/chain.go
View file @
20472856
...
...
@@ -100,7 +100,6 @@ type BlockChain struct {
isParaChain
bool
//是否是平行链。平行链需要记录Sequence信息
isStrongConsistency
bool
//lock
cachelock
sync
.
Mutex
synBlocklock
sync
.
Mutex
peerMaxBlklock
sync
.
Mutex
castlock
sync
.
Mutex
...
...
vendor/github.com/33cn/chain33/blockchain/chain_test.go
View file @
20472856
...
...
@@ -127,6 +127,8 @@ func TestBlockChain(t *testing.T) {
testCheckBlock
(
t
,
blockchain
)
testWriteBlockToDbTemp
(
t
,
blockchain
)
testReadBlockToExec
(
t
,
blockchain
)
testReExecBlock
(
t
,
blockchain
)
testReExecBlockMsg
(
t
,
mock33
,
blockchain
)
}
func
testProcAddBlockMsg
(
t
*
testing
.
T
,
mock33
*
testnode
.
Chain33Mock
,
blockchain
*
blockchain
.
BlockChain
)
{
...
...
@@ -1109,3 +1111,21 @@ func testWriteBlockToDbTemp(t *testing.T, chain *blockchain.BlockChain) {
}
chainlog
.
Info
(
"WriteBlockToDbTemp end ---------------------"
)
}
func
testReExecBlock
(
t
*
testing
.
T
,
chain
*
blockchain
.
BlockChain
)
{
chainlog
.
Info
(
"ReExecBlock begin ---------------------"
)
curheight
:=
chain
.
GetBlockHeight
()
chain
.
ProcessReExecBlock
(
0
,
curheight
)
chainlog
.
Info
(
"ReExecBlock end ---------------------"
)
}
func
testReExecBlockMsg
(
t
*
testing
.
T
,
mock33
*
testnode
.
Chain33Mock
,
chain
*
blockchain
.
BlockChain
)
{
var
err
error
client
:=
mock33
.
GetClient
()
msg1
:=
client
.
NewMessage
(
"blockchain"
,
types
.
EventReExecBlock
,
&
types
.
ReqInt
{
Height
:
8
})
err
=
client
.
Send
(
msg1
,
true
)
require
.
NoError
(
t
,
err
)
_
,
err
=
client
.
Wait
(
msg1
)
require
.
NoError
(
t
,
err
)
time
.
Sleep
(
time
.
Millisecond
*
20
)
}
vendor/github.com/33cn/chain33/blockchain/exec.go
View file @
20472856
...
...
@@ -14,3 +14,8 @@ import (
func
execBlock
(
client
queue
.
Client
,
prevStateRoot
[]
byte
,
block
*
types
.
Block
,
errReturn
bool
,
sync
bool
)
(
*
types
.
BlockDetail
,
[]
*
types
.
Transaction
,
error
)
{
return
util
.
ExecBlock
(
client
,
prevStateRoot
,
block
,
errReturn
,
sync
,
true
)
}
//从本地执行区块
func
execBlockUpgrade
(
client
queue
.
Client
,
prevStateRoot
[]
byte
,
block
*
types
.
Block
,
sync
bool
)
error
{
return
util
.
ExecBlockUpgrade
(
client
,
prevStateRoot
,
block
,
sync
)
}
vendor/github.com/33cn/chain33/blockchain/proc.go
View file @
20472856
...
...
@@ -90,6 +90,8 @@ func (chain *BlockChain) ProcRecvMsg() {
case
types
.
EventGetSeqCBLastNum
:
go
chain
.
processMsg
(
msg
,
reqnum
,
chain
.
getSeqCBLastNum
)
case
types
.
EventReExecBlock
:
go
chain
.
processMsg
(
msg
,
reqnum
,
chain
.
reExecBlock
)
default
:
go
chain
.
processMsg
(
msg
,
reqnum
,
chain
.
unknowMsg
)
}
...
...
@@ -133,6 +135,17 @@ func (chain *BlockChain) getSeqCBLastNum(msg *queue.Message) {
msg
.
Reply
(
chain
.
client
.
NewMessage
(
"rpc"
,
types
.
EventGetSeqCBLastNum
,
lastNum
))
}
func
(
chain
*
BlockChain
)
reExecBlock
(
msg
*
queue
.
Message
)
{
data
:=
(
msg
.
Data
)
.
(
*
types
.
ReqInt
)
curHeight
:=
chain
.
GetBlockHeight
()
if
curHeight
<
data
.
Height
{
msg
.
Reply
(
chain
.
client
.
NewMessage
(
"store"
,
types
.
EventReExecBlock
,
&
types
.
ReplyString
{
Data
:
"none"
}))
return
}
msg
.
Reply
(
chain
.
client
.
NewMessage
(
"store"
,
types
.
EventReExecBlock
,
&
types
.
ReplyString
{
Data
:
"need"
}))
chain
.
ProcessReExecBlock
(
data
.
Height
,
curHeight
)
}
func
(
chain
*
BlockChain
)
queryTx
(
msg
*
queue
.
Message
)
{
txhash
:=
(
msg
.
Data
)
.
(
*
types
.
ReqHash
)
TransactionDetail
,
err
:=
chain
.
ProcQueryTxMsg
(
txhash
.
Hash
)
...
...
@@ -162,16 +175,16 @@ func (chain *BlockChain) addBlock(msg *queue.Message) {
blockpid
:=
msg
.
Data
.
(
*
types
.
BlockPid
)
//chainlog.Error("addBlock", "height", blockpid.Block.Height, "pid", blockpid.Pid)
if
chain
.
GetDownloadSyncStatus
()
{
//downLoadTask 运行时设置对应的blockdone
if
chain
.
downLoadTask
.
InProgress
()
{
chain
.
downLoadTask
.
Done
(
blockpid
.
Block
.
GetHeight
())
}
err
:=
chain
.
WriteBlockToDbTemp
(
blockpid
.
Block
)
if
err
!=
nil
{
chainlog
.
Error
(
"WriteBlockToDbTemp"
,
"height"
,
blockpid
.
Block
.
Height
,
"err"
,
err
.
Error
())
reply
.
IsOk
=
false
reply
.
Msg
=
[]
byte
(
err
.
Error
())
}
//downLoadTask 运行时设置对应的blockdone
if
chain
.
downLoadTask
.
InProgress
()
{
chain
.
downLoadTask
.
Done
(
blockpid
.
Block
.
GetHeight
())
}
}
else
{
_
,
err
:=
chain
.
ProcAddBlockMsg
(
false
,
&
types
.
BlockDetail
{
Block
:
blockpid
.
Block
},
blockpid
.
Pid
)
if
err
!=
nil
{
...
...
vendor/github.com/33cn/chain33/blockchain/process.go
View file @
20472856
...
...
@@ -10,6 +10,8 @@ import (
"math/big"
"sync/atomic"
"fmt"
"github.com/33cn/chain33/client/api"
"github.com/33cn/chain33/common"
"github.com/33cn/chain33/common/difficulty"
...
...
@@ -599,6 +601,40 @@ func (b *BlockChain) ProcessDelParaChainBlock(broadcast bool, blockdetail *types
return
nil
,
true
,
false
,
nil
}
// ProcessReExecBlock 从对应高度本地重新执行区块
func
(
b
*
BlockChain
)
ProcessReExecBlock
(
startHeight
,
curHeight
int64
)
{
var
prevStateHash
[]
byte
if
startHeight
>
0
{
blockdetail
,
err
:=
b
.
GetBlock
(
startHeight
-
1
)
if
err
!=
nil
{
panic
(
fmt
.
Sprintf
(
"get height=%d err, this not allow fail"
,
startHeight
-
1
))
}
prevStateHash
=
blockdetail
.
Block
.
StateHash
}
for
i
:=
startHeight
;
i
<=
curHeight
;
i
++
{
blockdetail
,
err
:=
b
.
GetBlock
(
i
)
if
err
!=
nil
{
panic
(
fmt
.
Sprintf
(
"get height=%d err, this not allow fail"
,
i
))
}
block
:=
blockdetail
.
Block
err
=
execBlockUpgrade
(
b
.
client
,
prevStateHash
,
block
,
false
)
if
err
!=
nil
{
panic
(
fmt
.
Sprintf
(
"execBlockEx height=%d err=%s, this not allow fail"
,
i
,
err
.
Error
()))
}
prevStateHash
=
block
.
StateHash
}
// 通知执行结束
msg
:=
b
.
client
.
NewMessage
(
"store"
,
types
.
EventReExecBlock
,
&
types
.
ReplyString
{
Data
:
"over"
})
err
:=
b
.
client
.
Send
(
msg
,
true
)
if
err
!=
nil
{
return
}
_
,
err
=
b
.
client
.
Wait
(
msg
)
if
err
!=
nil
{
return
}
}
// IsRecordFaultErr 检测此错误是否要记录到故障错误中
func
IsRecordFaultErr
(
err
error
)
bool
{
return
err
!=
types
.
ErrFutureBlock
&&
!
api
.
IsGrpcError
(
err
)
&&
!
api
.
IsQueueError
(
err
)
...
...
vendor/github.com/33cn/chain33/system/store/base.go
View file @
20472856
...
...
@@ -49,6 +49,10 @@ type SubStore interface {
Del
(
req
*
types
.
StoreDel
)
([]
byte
,
error
)
IterateRangeByStateHash
(
statehash
[]
byte
,
start
[]
byte
,
end
[]
byte
,
ascending
bool
,
fn
func
(
key
,
value
[]
byte
)
bool
)
ProcEvent
(
msg
*
queue
.
Message
)
//用升级本地交易构建store
MemSetUpgrade
(
datas
*
types
.
StoreSet
,
sync
bool
)
([]
byte
,
error
)
CommitUpgrade
(
hash
*
types
.
ReqHash
)
([]
byte
,
error
)
}
// BaseStore 基础的store结构体
...
...
@@ -82,6 +86,9 @@ func (store *BaseStore) SetQueueClient(c queue.Client) {
}
store
.
done
<-
struct
{}{}
}()
if
store
.
child
!=
nil
{
store
.
child
.
ProcEvent
(
nil
)
}
}
//Wait wait for basestore ready
...
...
@@ -108,7 +115,13 @@ func (store *BaseStore) processMessage(msg *queue.Message) {
}
else
if
msg
.
Ty
==
types
.
EventStoreMemSet
{
//只是在内存中set 一下,并不改变状态
go
func
()
{
datas
:=
msg
.
GetData
()
.
(
*
types
.
StoreSetWithSync
)
hash
,
err
:=
store
.
child
.
MemSet
(
datas
.
Storeset
,
datas
.
Sync
)
var
hash
[]
byte
var
err
error
if
datas
.
Upgrade
{
hash
,
err
=
store
.
child
.
MemSetUpgrade
(
datas
.
Storeset
,
datas
.
Sync
)
}
else
{
hash
,
err
=
store
.
child
.
MemSet
(
datas
.
Storeset
,
datas
.
Sync
)
}
if
err
!=
nil
{
msg
.
Reply
(
client
.
NewMessage
(
""
,
types
.
EventStoreSetReply
,
err
))
return
...
...
@@ -118,7 +131,13 @@ func (store *BaseStore) processMessage(msg *queue.Message) {
}
else
if
msg
.
Ty
==
types
.
EventStoreCommit
{
//把内存中set 的交易 commit
go
func
()
{
req
:=
msg
.
GetData
()
.
(
*
types
.
ReqHash
)
hash
,
err
:=
store
.
child
.
Commit
(
req
)
var
hash
[]
byte
var
err
error
if
req
.
Upgrade
{
hash
,
err
=
store
.
child
.
CommitUpgrade
(
req
)
}
else
{
hash
,
err
=
store
.
child
.
Commit
(
req
)
}
if
hash
==
nil
{
msg
.
Reply
(
client
.
NewMessage
(
""
,
types
.
EventStoreCommit
,
types
.
ErrHashNotFound
))
if
err
==
types
.
ErrDataBaseDamage
{
//如果是数据库写失败,需要上报给用户
...
...
vendor/github.com/33cn/chain33/system/store/base_test.go
View file @
20472856
...
...
@@ -36,6 +36,14 @@ func (s *storeChild) Commit(hash *types.ReqHash) ([]byte, error) {
return
[]
byte
{},
nil
}
func
(
s
*
storeChild
)
MemSetUpgrade
(
datas
*
types
.
StoreSet
,
sync
bool
)
([]
byte
,
error
)
{
return
[]
byte
{},
nil
}
func
(
s
*
storeChild
)
CommitUpgrade
(
req
*
types
.
ReqHash
)
([]
byte
,
error
)
{
return
[]
byte
{},
nil
}
func
(
s
*
storeChild
)
Rollback
(
req
*
types
.
ReqHash
)
([]
byte
,
error
)
{
return
[]
byte
{},
nil
}
...
...
vendor/github.com/33cn/chain33/system/store/mavl/db/node.go
View file @
20472856
...
...
@@ -218,6 +218,9 @@ func (node *Node) Hash(t *Tree) []byte {
}
}
if
enableMemTree
{
updateLocalMemTree
(
t
,
node
)
}
return
node
.
hash
}
...
...
vendor/github.com/33cn/chain33/system/store/mavl/db/tree.go
View file @
20472856
...
...
@@ -168,6 +168,16 @@ func (t *Tree) Hash() []byte {
return
nil
}
hash
:=
t
.
root
.
Hash
(
t
)
// 更新memTree
if
enableMemTree
&&
memTree
!=
nil
{
for
k
:=
range
t
.
obsoleteNode
{
memTree
.
Delete
(
k
)
}
for
k
,
v
:=
range
t
.
updateNode
{
memTree
.
Add
(
k
,
v
)
}
treelog
.
Debug
(
"Tree.Hash"
,
"memTree len"
,
memTree
.
Len
(),
"tree height"
,
t
.
blockHeight
)
}
return
hash
}
...
...
@@ -193,16 +203,6 @@ func (t *Tree) Save() []byte {
treelog
.
Error
(
"Tree.Save"
,
"saveRootHash err"
,
err
)
}
}
// 更新memTree
if
enableMemTree
&&
memTree
!=
nil
{
for
k
:=
range
t
.
obsoleteNode
{
memTree
.
Delete
(
k
)
}
for
k
,
v
:=
range
t
.
updateNode
{
memTree
.
Add
(
k
,
v
)
}
treelog
.
Debug
(
"Tree.Save"
,
"memTree len"
,
memTree
.
Len
(),
"tree height"
,
t
.
blockHeight
)
}
beg
:=
types
.
Now
()
err
:=
t
.
ndb
.
Commit
()
...
...
@@ -530,11 +530,6 @@ func (ndb *nodeDB) SaveNode(t *Tree, node *Node) {
node
.
persisted
=
true
ndb
.
cacheNode
(
node
)
delete
(
ndb
.
orphans
,
string
(
node
.
hash
))
//treelog.Debug("SaveNode", "hash", node.hash, "height", node.height, "value", node.value)
// Save node hashInt64 to localmem
if
enableMemTree
{
updateLocalMemTree
(
t
,
node
)
}
}
func
getNode4MemTree
(
hash
[]
byte
)
(
*
Node
,
error
)
{
...
...
vendor/github.com/33cn/chain33/system/store/mavl/mavl.go
View file @
20472856
...
...
@@ -172,6 +172,35 @@ func (mavls *Store) Commit(req *types.ReqHash) ([]byte, error) {
return
req
.
Hash
,
nil
}
// MemSetUpgrade cacl mavl, but not store tree, return root hash and error
func
(
mavls
*
Store
)
MemSetUpgrade
(
datas
*
types
.
StoreSet
,
sync
bool
)
([]
byte
,
error
)
{
beg
:=
types
.
Now
()
defer
func
()
{
mlog
.
Info
(
"MemSet"
,
"cost"
,
types
.
Since
(
beg
))
}()
if
len
(
datas
.
KV
)
==
0
{
mlog
.
Info
(
"store mavl memset,use preStateHash as stateHash for kvset is null"
)
mavls
.
trees
.
Store
(
string
(
datas
.
StateHash
),
nil
)
return
datas
.
StateHash
,
nil
}
tree
:=
mavl
.
NewTree
(
mavls
.
GetDB
(),
sync
)
tree
.
SetBlockHeight
(
datas
.
Height
)
err
:=
tree
.
Load
(
datas
.
StateHash
)
if
err
!=
nil
{
return
nil
,
err
}
for
i
:=
0
;
i
<
len
(
datas
.
KV
);
i
++
{
tree
.
Set
(
datas
.
KV
[
i
]
.
Key
,
datas
.
KV
[
i
]
.
Value
)
}
hash
:=
tree
.
Hash
()
return
hash
,
nil
}
// CommitUpgrade convert memcory mavl to storage db
func
(
mavls
*
Store
)
CommitUpgrade
(
req
*
types
.
ReqHash
)
([]
byte
,
error
)
{
return
req
.
Hash
,
nil
}
// Rollback 回退将缓存的mavl树删除掉
func
(
mavls
*
Store
)
Rollback
(
req
*
types
.
ReqHash
)
([]
byte
,
error
)
{
beg
:=
types
.
Now
()
...
...
@@ -194,6 +223,9 @@ func (mavls *Store) IterateRangeByStateHash(statehash []byte, start []byte, end
// ProcEvent not support message
func
(
mavls
*
Store
)
ProcEvent
(
msg
*
queue
.
Message
)
{
if
msg
==
nil
{
return
}
msg
.
ReplyErr
(
"Store"
,
types
.
ErrActionNotSupport
)
}
...
...
vendor/github.com/33cn/chain33/system/store/mavl/mavl_test.go
View file @
20472856
...
...
@@ -14,6 +14,7 @@ import (
"github.com/33cn/chain33/account"
"github.com/33cn/chain33/common"
"github.com/33cn/chain33/queue"
drivers
"github.com/33cn/chain33/system/store"
mavldb
"github.com/33cn/chain33/system/store/mavl/db"
"github.com/33cn/chain33/types"
...
...
@@ -116,6 +117,35 @@ func TestKvdbMemSet(t *testing.T) {
assert
.
Nil
(
t
,
notExistHash
)
}
func
TestKvdbMemSetUpgrade
(
t
*
testing
.
T
)
{
dir
,
err
:=
ioutil
.
TempDir
(
""
,
"example"
)
assert
.
Nil
(
t
,
err
)
defer
os
.
RemoveAll
(
dir
)
// clean up
os
.
RemoveAll
(
dir
)
//删除已存在目录
var
storeCfg
=
newStoreCfg
(
dir
)
store
:=
New
(
storeCfg
,
nil
)
.
(
*
Store
)
assert
.
NotNil
(
t
,
store
)
var
kv
[]
*
types
.
KeyValue
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
[]
byte
(
"mk1"
),
Value
:
[]
byte
(
"v1"
)})
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
[]
byte
(
"mk2"
),
Value
:
[]
byte
(
"v2"
)})
datas
:=
&
types
.
StoreSet
{
StateHash
:
drivers
.
EmptyRoot
[
:
],
KV
:
kv
,
}
hash
,
err
:=
store
.
MemSetUpgrade
(
datas
,
true
)
assert
.
Nil
(
t
,
err
)
keys
:=
[][]
byte
{[]
byte
(
"mk1"
),
[]
byte
(
"mk2"
)}
get1
:=
&
types
.
StoreGet
{
StateHash
:
hash
,
Keys
:
keys
}
values
:=
store
.
Get
(
get1
)
assert
.
Len
(
t
,
values
,
2
)
hash1
,
err
:=
store
.
CommitUpgrade
(
&
types
.
ReqHash
{
Hash
:
hash
})
assert
.
Nil
(
t
,
err
)
assert
.
Equal
(
t
,
hash
,
hash1
)
}
func
TestKvdbRollback
(
t
*
testing
.
T
)
{
dir
,
err
:=
ioutil
.
TempDir
(
""
,
"example"
)
assert
.
Nil
(
t
,
err
)
...
...
@@ -146,6 +176,31 @@ func TestKvdbRollback(t *testing.T) {
assert
.
Nil
(
t
,
notExistHash
)
}
func
TestProcEvent
(
t
*
testing
.
T
)
{
dir
,
err
:=
ioutil
.
TempDir
(
""
,
"example"
)
assert
.
Nil
(
t
,
err
)
defer
os
.
RemoveAll
(
dir
)
// clean up
os
.
RemoveAll
(
dir
)
//删除已存在目录
var
storeCfg
=
newStoreCfg
(
dir
)
store
:=
New
(
storeCfg
,
nil
)
.
(
*
Store
)
assert
.
NotNil
(
t
,
store
)
store
.
ProcEvent
(
nil
)
store
.
ProcEvent
(
&
queue
.
Message
{})
}
func
TestDel
(
t
*
testing
.
T
)
{
dir
,
err
:=
ioutil
.
TempDir
(
""
,
"example"
)
assert
.
Nil
(
t
,
err
)
defer
os
.
RemoveAll
(
dir
)
// clean up
os
.
RemoveAll
(
dir
)
//删除已存在目录
var
storeCfg
=
newStoreCfg
(
dir
)
store
:=
New
(
storeCfg
,
nil
)
.
(
*
Store
)
assert
.
NotNil
(
t
,
store
)
store
.
Del
(
nil
)
}
var
checkKVResult
[]
*
types
.
KeyValue
func
checkKV
(
k
,
v
[]
byte
)
bool
{
...
...
vendor/github.com/33cn/chain33/types/common.pb.go
View file @
20472856
...
...
@@ -265,6 +265,7 @@ func (m *Int64) GetData() int64 {
type
ReqHash
struct
{
Hash
[]
byte
`protobuf:"bytes,1,opt,name=hash,proto3" json:"hash,omitempty"`
Upgrade
bool
`protobuf:"varint,2,opt,name=upgrade,proto3" json:"upgrade,omitempty"`
XXX_NoUnkeyedLiteral
struct
{}
`json:"-"`
XXX_unrecognized
[]
byte
`json:"-"`
XXX_sizecache
int32
`json:"-"`
...
...
@@ -302,6 +303,13 @@ func (m *ReqHash) GetHash() []byte {
return
nil
}
func
(
m
*
ReqHash
)
GetUpgrade
()
bool
{
if
m
!=
nil
{
return
m
.
Upgrade
}
return
false
}
type
ReplyHash
struct
{
Hash
[]
byte
`protobuf:"bytes,1,opt,name=hash,proto3" json:"hash,omitempty"`
XXX_NoUnkeyedLiteral
struct
{}
`json:"-"`
...
...
@@ -781,33 +789,34 @@ func init() {
func
init
()
{
proto
.
RegisterFile
(
"common.proto"
,
fileDescriptor_555bd8c177793206
)
}
var
fileDescriptor_555bd8c177793206
=
[]
byte
{
// 445 bytes of a gzipped FileDescriptorProto
0x1f
,
0x8b
,
0x08
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x02
,
0xff
,
0x84
,
0x53
,
0x51
,
0x6b
,
0xdb
,
0x30
,
0x10
,
0x26
,
0x71
,
0x93
,
0xc6
,
0x57
,
0x3f
,
0x0c
,
0x33
,
0x86
,
0xe9
,
0x5a
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,
0x2a
,
0x47
,
0x7b
,
0xc0
,
0x07
,
0xa3
,
0x67
,
0x47
,
0x07
,
0x51
,
0x70
,
0xf1
,
0x20
,
0x77
,
0x46
,
0xd5
,
0x7a
,
0xa9
,
0xb3
,
0x1a
,
0xb3
,
0xb2
,
0xca
,
0x96
,
0x03
,
0xdf
,
0x1e
,
0xa0
,
0x52
,
0xd1
,
0x34
,
0xce
,
0x1f
,
0x96
,
0x98
,
0x48
,
0x5a
,
0x08
,
0xa5
,
0x93
,
0x84
,
0x58
,
0x02
,
0x3e
,
0x40
,
0xec
,
0x50
,
0x00
,
0x5f
,
0xd7
,
0xc4
,
0x13
,
0xf0
,
0x01
,
0x7e
,
0xb9
,
0xfe
,
0xf9
,
0x2a
,
0x57
,
0xb6
,
0xe8
,
0xd6
,
0x37
,
0x69
,
0x5d
,
0x2d
,
0x92
,
0x24
,
0xd5
,
0x0b
,
0xb7
,
0xb4
,
0xa0
,
0xdf
,
0x69
,
0x3d
,
0xa5
,
0x9f
,
0x2b
,
0xf9
,
0x1d
,
0x00
,
0x00
,
0xff
,
0xff
,
0x05
,
0xe6
,
0x9f
,
0x5b
,
0x6c
,
0x03
,
0x00
,
0x00
,
}
vendor/github.com/33cn/chain33/types/db.pb.go
View file @
20472856
...
...
@@ -591,6 +591,7 @@ func (m *StoreDel) GetHeight() int64 {
type
StoreSetWithSync
struct
{
Storeset
*
StoreSet
`protobuf:"bytes,1,opt,name=storeset,proto3" json:"storeset,omitempty"`
Sync
bool
`protobuf:"varint,2,opt,name=sync,proto3" json:"sync,omitempty"`
Upgrade
bool
`protobuf:"varint,3,opt,name=upgrade,proto3" json:"upgrade,omitempty"`
XXX_NoUnkeyedLiteral
struct
{}
`json:"-"`
XXX_unrecognized
[]
byte
`json:"-"`
XXX_sizecache
int32
`json:"-"`
...
...
@@ -635,6 +636,13 @@ func (m *StoreSetWithSync) GetSync() bool {
return
false
}
func
(
m
*
StoreSetWithSync
)
GetUpgrade
()
bool
{
if
m
!=
nil
{
return
m
.
Upgrade
}
return
false
}
type
StoreGet
struct
{
StateHash
[]
byte
`protobuf:"bytes,1,opt,name=stateHash,proto3" json:"stateHash,omitempty"`
Keys
[][]
byte
`protobuf:"bytes,2,rep,name=keys,proto3" json:"keys,omitempty"`
...
...
@@ -1006,46 +1014,46 @@ func init() {
func
init
()
{
proto
.
RegisterFile
(
"db.proto"
,
fileDescriptor_8817812184a13374
)
}
var
fileDescriptor_8817812184a13374
=
[]
byte
{
// 6
42
bytes of a gzipped FileDescriptorProto
// 6
54
bytes of a gzipped FileDescriptorProto
0x1f
,
0x8b
,
0x08
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x02
,
0xff
,
0x94
,
0x55
,
0xc1
,
0x6a
,
0xdb
,
0x40
,
0x10
,
0x45
,
0x92
,
0x9d
,
0x48
,
0x93
,
0xd0
,
0x18
,
0x11
,
0x8a
,
0x08
,
0x29
,
0x49
,
0x75
,
0x72
,
0x29
,
0x38
,
0xa5
,
0xee
,
0xb1
,
0x87
,
0x26
,
0x04
,
0xd2
,
0x62
,
0xb7
,
0x04
,
0x
19
,
0x5c
,
0xe8
,
0xa1
,
0xa
0
,
0x
c8
,
0xe3
,
0x48
,
0xc4
,
0xde
,
0x75
,
0xb5
,
0xab
,
0x12
,
0xf5
,
0xd2
,
0x8f
,
0xe8
,
0xa9
,
0xbf
,
0xd5
,
0x2f
,
0x2a
,
0x3b
,
0xbb
,
0xb2
,
0x64
,
0x50
,
0x
e3
,
0xe6
,
0x36
,
0x6f
,
0xbc
,
0x7a
,
0xef
,
0xcd
,
0xd
b
,
0x59
,
0x0c
,
0x
ee
,
0xec
,
0x66
,
0xb0
,
0xca
,
0xb9
,
0xe4
,
0x7e
,
0x57
,
0x96
,
0x2b
,
0x14
,
0x47
,
0xf
b
,
0x
09
,
0x5f
,
0x2e
,
0x39
,
0xd3
,
0xcd
,
0xf0
,
0x2b
,
0xb8
,
0x63
,
0x8c
,
0xe7
,
0x9f
,
0xf8
,
0x0c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x32
,
0x2f
,
0x39
,
0x9e
,
0x33
,
0xc9
,
0x94
,
0x9d
,
0x94
,
0x15
,
0x69
,
0x11
,
0x
58
,
0x74
,
0x47
,
0x83
,
0x70
,
0x68
,
0xda
,
0xa6
,
0x99
,
0x5d
,
0x0a
,
0xb1
,
0x68
,
0x91
,
0x59
,
0x6d
,
0x
b2
,
0xb3
,
0xa3
,
0x2f
,
0xcf
,
0x6e
,
0x32
,
0x99
,
0x96
,
0xd7
,
0xa3
,
0x58
,
0x2c
,
0x4f
,
0xc6
,
0xe3
,
0x
98
,
0x9f
,
0xc4
,
0x29
,
0xcb
,
0xf8
,
0x78
,
0x7c
,
0x42
,
0x2b
,
0x78
,
0xbd
,
0x45
,
0xff
,
0x33
,
0xe3
,
0x
bf
,
0x01
,
0x00
,
0x00
,
0xff
,
0xff
,
0xb7
,
0xe6
,
0x2e
,
0x76
,
0x88
,
0x06
,
0x
00
,
0x00
,
}
vendor/github.com/33cn/chain33/types/event.go
View file @
20472856
...
...
@@ -151,6 +151,8 @@ const (
EventGetProperFee
=
140
EventReplyProperFee
=
141
EventReExecBlock
=
142
//exec
EventBlockChainQuery
=
212
EventConsensusQuery
=
213
...
...
vendor/github.com/33cn/chain33/types/proto/common.proto
View file @
20472856
...
...
@@ -30,6 +30,7 @@ message Int64 {
message
ReqHash
{
bytes
hash
=
1
;
bool
upgrade
=
2
;
}
message
ReplyHash
{
...
...
vendor/github.com/33cn/chain33/types/proto/db.proto
View file @
20472856
...
...
@@ -71,6 +71,7 @@ message StoreDel {
message
StoreSetWithSync
{
StoreSet
storeset
=
1
;
bool
sync
=
2
;
bool
upgrade
=
3
;
}
message
StoreGet
{
...
...
vendor/github.com/33cn/chain33/util/cli/chain33.go
View file @
20472856
...
...
@@ -152,15 +152,15 @@ func RunChain33(name string) {
exec
:=
executor
.
New
(
cfg
.
Exec
,
sub
.
Exec
)
exec
.
SetQueueClient
(
q
.
Client
())
log
.
Info
(
"loading store module"
)
s
:=
store
.
New
(
cfg
.
Store
,
sub
.
Store
)
s
.
SetQueueClient
(
q
.
Client
())
log
.
Info
(
"loading blockchain module"
)
chain
:=
blockchain
.
New
(
cfg
.
BlockChain
)
chain
.
SetQueueClient
(
q
.
Client
())
chain
.
UpgradeChain
()
log
.
Info
(
"loading store module"
)
s
:=
store
.
New
(
cfg
.
Store
,
sub
.
Store
)
s
.
SetQueueClient
(
q
.
Client
())
log
.
Info
(
"loading consensus module"
)
cs
:=
consensus
.
New
(
cfg
.
Consensus
,
sub
.
Consensus
)
cs
.
SetQueueClient
(
q
.
Client
())
...
...
vendor/github.com/33cn/chain33/util/exec.go
View file @
20472856
...
...
@@ -59,9 +59,9 @@ func ExecTx(client queue.Client, prevStateRoot []byte, block *types.Block) (*typ
}
//ExecKVMemSet : send kv values to memory store and set it in db
func
ExecKVMemSet
(
client
queue
.
Client
,
prevStateRoot
[]
byte
,
height
int64
,
kvset
[]
*
types
.
KeyValue
,
sync
bool
)
([]
byte
,
error
)
{
func
ExecKVMemSet
(
client
queue
.
Client
,
prevStateRoot
[]
byte
,
height
int64
,
kvset
[]
*
types
.
KeyValue
,
sync
bool
,
upgrade
bool
)
([]
byte
,
error
)
{
set
:=
&
types
.
StoreSet
{
StateHash
:
prevStateRoot
,
KV
:
kvset
,
Height
:
height
}
setwithsync
:=
&
types
.
StoreSetWithSync
{
Storeset
:
set
,
Sync
:
sync
}
setwithsync
:=
&
types
.
StoreSetWithSync
{
Storeset
:
set
,
Sync
:
sync
,
Upgrade
:
upgrade
}
msg
:=
client
.
NewMessage
(
"store"
,
types
.
EventStoreMemSet
,
setwithsync
)
err
:=
client
.
Send
(
msg
,
true
)
...
...
@@ -77,8 +77,8 @@ func ExecKVMemSet(client queue.Client, prevStateRoot []byte, height int64, kvset
}
//ExecKVSetCommit : commit the data set opetation to db
func
ExecKVSetCommit
(
client
queue
.
Client
,
hash
[]
byte
)
error
{
req
:=
&
types
.
ReqHash
{
Hash
:
hash
}
func
ExecKVSetCommit
(
client
queue
.
Client
,
hash
[]
byte
,
upgrade
bool
)
error
{
req
:=
&
types
.
ReqHash
{
Hash
:
hash
,
Upgrade
:
upgrade
}
msg
:=
client
.
NewMessage
(
"store"
,
types
.
EventStoreCommit
,
req
)
err
:=
client
.
Send
(
msg
,
true
)
if
err
!=
nil
{
...
...
vendor/github.com/33cn/chain33/util/util.go
View file @
20472856
...
...
@@ -312,7 +312,7 @@ func ExecBlock(client queue.Client, prevStateRoot []byte, block *types.Block, er
beg
=
types
.
Now
()
block
.
TxHash
=
calcHash
var
detail
types
.
BlockDetail
calcHash
,
err
=
ExecKVMemSet
(
client
,
prevStateRoot
,
block
.
Height
,
kvset
,
sync
)
calcHash
,
err
=
ExecKVMemSet
(
client
,
prevStateRoot
,
block
.
Height
,
kvset
,
sync
,
false
)
if
err
!=
nil
{
return
nil
,
nil
,
err
}
...
...
@@ -341,7 +341,7 @@ func ExecBlock(client queue.Client, prevStateRoot []byte, block *types.Block, er
}
ulog
.
Info
(
"ExecBlock"
,
"CheckBlock"
,
types
.
Since
(
beg
))
// 写数据库失败时需要及时返回错误,防止错误数据被写入localdb中CHAIN33-567
err
=
ExecKVSetCommit
(
client
,
block
.
StateHash
)
err
=
ExecKVSetCommit
(
client
,
block
.
StateHash
,
false
)
if
err
!=
nil
{
return
nil
,
nil
,
err
}
...
...
@@ -350,6 +350,48 @@ func ExecBlock(client queue.Client, prevStateRoot []byte, block *types.Block, er
return
&
detail
,
deltx
,
nil
}
// ExecBlockUpgrade : just exec block
func
ExecBlockUpgrade
(
client
queue
.
Client
,
prevStateRoot
[]
byte
,
block
*
types
.
Block
,
sync
bool
)
error
{
//发送执行交易给execs模块
//通过consensus module 再次检查
ulog
.
Debug
(
"ExecBlockUpgrade"
,
"height------->"
,
block
.
Height
,
"ntx"
,
len
(
block
.
Txs
))
beg
:=
types
.
Now
()
beg1
:=
beg
defer
func
()
{
ulog
.
Info
(
"ExecBlockUpgrade"
,
"height"
,
block
.
Height
,
"ntx"
,
len
(
block
.
Txs
),
"writebatchsync"
,
sync
,
"cost"
,
types
.
Since
(
beg1
))
}()
//tx交易去重处理, 这个地方要查询数据库,需要一个更快的办法
cacheTxs
:=
types
.
TxsToCache
(
block
.
Txs
)
var
err
error
block
.
Txs
=
types
.
CacheToTxs
(
cacheTxs
)
//println("1")
receipts
,
err
:=
ExecTx
(
client
,
prevStateRoot
,
block
)
if
err
!=
nil
{
return
err
}
ulog
.
Info
(
"ExecBlockUpgrade"
,
"ExecTx"
,
types
.
Since
(
beg
))
beg
=
types
.
Now
()
var
kvset
[]
*
types
.
KeyValue
for
i
:=
0
;
i
<
len
(
receipts
.
Receipts
);
i
++
{
receipt
:=
receipts
.
Receipts
[
i
]
kvset
=
append
(
kvset
,
receipt
.
KV
...
)
}
kvset
=
DelDupKey
(
kvset
)
calcHash
,
err
:=
ExecKVMemSet
(
client
,
prevStateRoot
,
block
.
Height
,
kvset
,
sync
,
true
)
if
err
!=
nil
{
return
err
}
//println("2")
if
!
bytes
.
Equal
(
block
.
StateHash
,
calcHash
)
{
return
types
.
ErrCheckStateHash
}
ulog
.
Info
(
"ExecBlockUpgrade"
,
"CheckBlock"
,
types
.
Since
(
beg
))
// 写数据库失败时需要及时返回错误,防止错误数据被写入localdb中CHAIN33-567
err
=
ExecKVSetCommit
(
client
,
calcHash
,
true
)
return
err
}
//CreateNewBlock : Create a New Block
func
CreateNewBlock
(
parent
*
types
.
Block
,
txs
[]
*
types
.
Transaction
)
*
types
.
Block
{
newblock
:=
&
types
.
Block
{}
...
...
vendor/github.com/33cn/chain33/util/util_test.go
View file @
20472856
...
...
@@ -278,6 +278,18 @@ func TestExecBlock(t *testing.T) {
assert
.
NoError
(
t
,
err
)
}
func
TestExecBlockUpgrade
(
t
*
testing
.
T
)
{
client
:=
&
testClient
{}
client
.
On
(
"Send"
,
mock
.
Anything
,
mock
.
Anything
)
.
Return
(
nil
)
var
txs
[]
*
types
.
Transaction
addr
,
priv
:=
Genaddress
()
tx
:=
CreateCoinsTx
(
priv
,
addr
,
types
.
Coin
)
tx
.
Sign
(
types
.
SECP256K1
,
priv
)
txs
=
append
(
txs
,
tx
)
err
:=
ExecBlockUpgrade
(
client
,
nil
,
&
types
.
Block
{
Txs
:
txs
},
false
)
assert
.
NoError
(
t
,
err
)
}
func
TestExecAndCheckBlock
(
t
*
testing
.
T
)
{
client
:=
&
testClient
{}
client
.
On
(
"Send"
,
mock
.
Anything
,
mock
.
Anything
)
.
Return
(
nil
)
...
...
vendor/github.com/33cn/chain33/wallet/wallet_test.go
View file @
20472856
...
...
@@ -143,12 +143,12 @@ func SaveAccountTomavl(client queue.Client, prevStateRoot []byte, accs []*types.
kvs
:=
accountdb
.
GetKVSet
(
acc
)
kvset
=
append
(
kvset
,
kvs
...
)
}
hash
,
err
:=
util
.
ExecKVMemSet
(
client
,
prevStateRoot
,
0
,
kvset
,
true
)
hash
,
err
:=
util
.
ExecKVMemSet
(
client
,
prevStateRoot
,
0
,
kvset
,
true
,
false
)
if
err
!=
nil
{
panic
(
err
)
}
Statehash
=
hash
util
.
ExecKVSetCommit
(
client
,
Statehash
)
util
.
ExecKVSetCommit
(
client
,
Statehash
,
false
)
return
hash
}
...
...
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