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
143311fe
Commit
143311fe
authored
Apr 02, 2019
by
liuyuhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modify
parent
28de2d98
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
60 additions
and
137 deletions
+60
-137
chain33.toml
chain33.toml
+1
-1
blockstore.go
vendor/github.com/33cn/chain33/blockchain/blockstore.go
+25
-0
chain_test.go
vendor/github.com/33cn/chain33/blockchain/chain_test.go
+1
-13
proc.go
vendor/github.com/33cn/chain33/blockchain/proc.go
+0
-13
process.go
vendor/github.com/33cn/chain33/blockchain/process.go
+0
-36
reindex.go
vendor/github.com/33cn/chain33/blockchain/reindex.go
+4
-4
chain33.toml
vendor/github.com/33cn/chain33/cmd/chain33/chain33.toml
+2
-0
version.go
vendor/github.com/33cn/chain33/common/version/version.go
+18
-0
client.go
vendor/github.com/33cn/chain33/rpc/client.go
+0
-20
grpchandler.go
vendor/github.com/33cn/chain33/rpc/grpchandler.go
+0
-5
jrpchandler.go
vendor/github.com/33cn/chain33/rpc/jrpchandler.go
+0
-31
base.go
vendor/github.com/33cn/chain33/system/store/base.go
+0
-3
cfg.go
vendor/github.com/33cn/chain33/types/cfg.go
+4
-0
rpc.proto
vendor/github.com/33cn/chain33/types/proto/rpc.proto
+0
-2
transaction.proto
vendor/github.com/33cn/chain33/types/proto/transaction.proto
+2
-8
rpc.pb.go
vendor/github.com/33cn/chain33/types/rpc.pb.go
+0
-0
transaction.pb.go
vendor/github.com/33cn/chain33/types/transaction.pb.go
+0
-0
chain33.go
vendor/github.com/33cn/chain33/util/cli/chain33.go
+3
-1
No files found.
chain33.toml
View file @
143311fe
...
...
@@ -131,7 +131,7 @@ returnAddr="1KcCVZLSQYRUwE5EXTsAoQs9LuJW6xwfQa"
count
=
10000
[store]
name
=
"mavl"
name
=
"
kvmvcc
mavl"
driver
=
"leveldb"
dbPath
=
"datadir/mavltree"
dbCache
=
128
...
...
vendor/github.com/33cn/chain33/blockchain/blockstore.go
View file @
143311fe
...
...
@@ -1092,6 +1092,31 @@ func (bs *BlockStore) SetUpgradeMeta(meta *types.UpgradeMeta) error {
return
bs
.
db
.
SetSync
(
version
.
LocalDBMeta
,
verByte
)
}
//SetStoreUpgradeMeta 获取存在blockchain中的Store的数据库版本号
func
(
bs
*
BlockStore
)
GetStoreUpgradeMeta
()
(
*
types
.
UpgradeMeta
,
error
)
{
ver
:=
types
.
UpgradeMeta
{}
version
,
err
:=
bs
.
db
.
Get
(
version
.
StoreDBMeta
)
if
err
!=
nil
&&
err
!=
dbm
.
ErrNotFoundInDb
{
return
nil
,
err
}
if
len
(
version
)
==
0
{
return
&
types
.
UpgradeMeta
{
Version
:
"0.0.0"
},
nil
}
err
=
types
.
Decode
(
version
,
&
ver
)
if
err
!=
nil
{
return
nil
,
err
}
storeLog
.
Info
(
"GetStoreUpgradeMeta"
,
"blockchain db version"
,
ver
)
return
&
ver
,
nil
}
//SetStoreUpgradeMeta 设置blockchain中的Store的数据库版本号
func
(
bs
*
BlockStore
)
SetStoreUpgradeMeta
(
meta
*
types
.
UpgradeMeta
)
error
{
verByte
:=
types
.
Encode
(
meta
)
storeLog
.
Info
(
"SetStoreUpgradeMeta"
,
"meta"
,
meta
)
return
bs
.
db
.
SetSync
(
version
.
StoreDBMeta
,
verByte
)
}
//isRecordBlockSequence配置的合法性检测
func
(
bs
*
BlockStore
)
isRecordBlockSequenceValid
(
chain
*
BlockChain
)
{
lastHeight
:=
bs
.
Height
()
...
...
vendor/github.com/33cn/chain33/blockchain/chain_test.go
View file @
143311fe
...
...
@@ -128,7 +128,6 @@ func TestBlockChain(t *testing.T) {
testWriteBlockToDbTemp
(
t
,
blockchain
)
testReadBlockToExec
(
t
,
blockchain
)
testReExecBlock
(
t
,
blockchain
)
testReExecBlockMsg
(
t
,
mock33
,
blockchain
)
}
func
testProcAddBlockMsg
(
t
*
testing
.
T
,
mock33
*
testnode
.
Chain33Mock
,
blockchain
*
blockchain
.
BlockChain
)
{
...
...
@@ -1115,17 +1114,6 @@ func testWriteBlockToDbTemp(t *testing.T, chain *blockchain.BlockChain) {
func
testReExecBlock
(
t
*
testing
.
T
,
chain
*
blockchain
.
BlockChain
)
{
chainlog
.
Info
(
"ReExecBlock begin ---------------------"
)
curheight
:=
chain
.
GetBlockHeight
()
chain
.
Process
ReExecBlock
(
0
,
curheight
)
chain
.
ReExecBlock
(
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/proc.go
View file @
143311fe
...
...
@@ -90,8 +90,6 @@ 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
)
}
...
...
@@ -135,17 +133,6 @@ 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
)
...
...
vendor/github.com/33cn/chain33/blockchain/process.go
View file @
143311fe
...
...
@@ -10,8 +10,6 @@ import (
"math/big"
"sync/atomic"
"fmt"
"github.com/33cn/chain33/client/api"
"github.com/33cn/chain33/common"
"github.com/33cn/chain33/common/difficulty"
...
...
@@ -601,40 +599,6 @@ 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/blockchain/reindex.go
View file @
143311fe
...
...
@@ -29,7 +29,7 @@ func (chain *BlockChain) UpgradeChain() {
}
if
chain
.
needReIndex
(
meta
)
{
//如果没有开始重建index,那么先del all keys
if
!
meta
.
Index
ing
{
if
!
meta
.
Start
ing
{
chainlog
.
Info
(
"begin del all keys"
)
chain
.
blockStore
.
delAllKeys
()
chainlog
.
Info
(
"end del all keys"
)
...
...
@@ -38,7 +38,7 @@ func (chain *BlockChain) UpgradeChain() {
//reindex 的过程中,会每个高度都去更新meta
chain
.
reIndex
(
start
,
curheight
)
meta
:=
&
types
.
UpgradeMeta
{
Index
ing
:
false
,
Start
ing
:
false
,
Version
:
version
.
GetLocalDBVersion
(),
Height
:
0
,
}
...
...
@@ -59,7 +59,7 @@ func (chain *BlockChain) reIndex(start, end int64) {
}
func
(
chain
*
BlockChain
)
needReIndex
(
meta
*
types
.
UpgradeMeta
)
bool
{
if
meta
.
Index
ing
{
//正在index
if
meta
.
Start
ing
{
//正在index
return
true
}
v1
:=
meta
.
Version
...
...
@@ -89,7 +89,7 @@ func (chain *BlockChain) reIndexOne(height int64) error {
panic
(
err
)
}
meta
:=
&
types
.
UpgradeMeta
{
Index
ing
:
true
,
Start
ing
:
true
,
Version
:
version
.
GetLocalDBVersion
(),
Height
:
height
+
1
,
}
...
...
vendor/github.com/33cn/chain33/cmd/chain33/chain33.toml
View file @
143311fe
...
...
@@ -202,6 +202,8 @@ dbPath="datadir/mavltree"
dbCache
=
128
# 数据库版本
localdbVersion
=
"1.0.0"
# 状态数据库版本
storedbVersion
=
"1.0.0"
[store.sub.mavl]
# 是否使能mavl加前缀
...
...
vendor/github.com/33cn/chain33/common/version/version.go
View file @
143311fe
...
...
@@ -12,8 +12,10 @@ var (
WalletVerKey
=
[]
byte
(
"WalletVerKey"
)
BlockChainVerKey
=
[]
byte
(
"BlockChainVerKey"
)
LocalDBMeta
=
[]
byte
(
"LocalDBMeta"
)
StoreDBMeta
=
[]
byte
(
"StoreDBMeta"
)
MavlTreeVerKey
=
[]
byte
(
"MavlTreeVerKey"
)
localversion
=
"1.0.0"
storeversion
=
"1.0.0"
appversion
=
"1.0.0"
GitCommit
string
)
...
...
@@ -49,6 +51,22 @@ func SetLocalDBVersion(version string) {
}
}
//GetStoreDBVersion 数据库版本解析
/*
格式: v1.v2.v3
如果: v1 升级了, 那么意味着localdb 需要 重新 reindex
*/
func
GetStoreDBVersion
()
string
{
return
localversion
}
//SetStoreDBVersion 通过设置版本号,强制重建数据库
func
SetStoreDBVersion
(
version
string
)
{
if
version
!=
""
{
localversion
=
version
}
}
//GetAppVersion 获取应用 app 的版本
func
GetAppVersion
()
string
{
return
appversion
...
...
vendor/github.com/33cn/chain33/rpc/client.go
View file @
143311fe
...
...
@@ -160,26 +160,6 @@ func decodeTx(hexstr string) (*types.Transaction, error) {
return
&
tx
,
nil
}
// SendRawTransaction send rawtransaction by p2p
func
(
c
*
channelClient
)
SendRawTransaction
(
param
*
types
.
SignedTx
)
(
*
types
.
Reply
,
error
)
{
if
param
==
nil
{
err
:=
types
.
ErrInvalidParam
log
.
Error
(
"SendRawTransaction"
,
"Error"
,
err
)
return
nil
,
err
}
var
tx
types
.
Transaction
err
:=
types
.
Decode
(
param
.
GetUnsign
(),
&
tx
)
if
err
==
nil
{
tx
.
Signature
=
&
types
.
Signature
{
Ty
:
param
.
GetTy
(),
Pubkey
:
param
.
GetPubkey
(),
Signature
:
param
.
GetSign
(),
}
return
c
.
SendTx
(
&
tx
)
}
return
nil
,
err
}
// GetAddrOverview get overview of address
func
(
c
*
channelClient
)
GetAddrOverview
(
parm
*
types
.
ReqAddr
)
(
*
types
.
AddrOverview
,
error
)
{
err
:=
address
.
CheckAddress
(
parm
.
Addr
)
...
...
vendor/github.com/33cn/chain33/rpc/grpchandler.go
View file @
143311fe
...
...
@@ -80,11 +80,6 @@ func (g *Grpc) CreateRawTxGroup(ctx context.Context, in *pb.CreateTransactionGro
return
&
pb
.
UnsignTx
{
Data
:
reply
},
nil
}
// SendRawTransaction send rawtransaction
func
(
g
*
Grpc
)
SendRawTransaction
(
ctx
context
.
Context
,
in
*
pb
.
SignedTx
)
(
*
pb
.
Reply
,
error
)
{
return
g
.
cli
.
SendRawTransaction
(
in
)
}
// QueryTransaction query transaction by grpc
func
(
g
*
Grpc
)
QueryTransaction
(
ctx
context
.
Context
,
in
*
pb
.
ReqHash
)
(
*
pb
.
TransactionDetail
,
error
)
{
return
g
.
cli
.
QueryTx
(
in
)
...
...
vendor/github.com/33cn/chain33/rpc/jrpchandler.go
View file @
143311fe
...
...
@@ -8,7 +8,6 @@ import (
"context"
"encoding/hex"
"encoding/json"
"fmt"
"time"
"github.com/33cn/chain33/common"
...
...
@@ -83,36 +82,6 @@ func (c *Chain33) CreateNoBalanceTransaction(in *types.NoBalanceTx, result *stri
return
nil
}
// SendRawTransaction send rawtransacion
func
(
c
*
Chain33
)
SendRawTransaction
(
in
rpctypes
.
SignedTx
,
result
*
interface
{})
error
{
var
stx
types
.
SignedTx
var
err
error
stx
.
Pubkey
,
err
=
hex
.
DecodeString
(
in
.
Pubkey
)
if
err
!=
nil
{
return
err
}
stx
.
Sign
,
err
=
hex
.
DecodeString
(
in
.
Sign
)
if
err
!=
nil
{
return
err
}
stx
.
Unsign
,
err
=
hex
.
DecodeString
(
in
.
Unsign
)
if
err
!=
nil
{
return
err
}
stx
.
Ty
=
in
.
Ty
reply
,
err
:=
c
.
cli
.
SendRawTransaction
(
&
stx
)
if
err
!=
nil
{
return
err
}
if
reply
.
IsOk
{
*
result
=
"0x"
+
hex
.
EncodeToString
(
reply
.
Msg
)
return
nil
}
return
fmt
.
Errorf
(
string
(
reply
.
Msg
))
}
// SendTransaction send transaction
func
(
c
*
Chain33
)
SendTransaction
(
in
rpctypes
.
RawParm
,
result
*
interface
{})
error
{
var
parm
types
.
Transaction
...
...
vendor/github.com/33cn/chain33/system/store/base.go
View file @
143311fe
...
...
@@ -86,9 +86,6 @@ func (store *BaseStore) SetQueueClient(c queue.Client) {
}
store
.
done
<-
struct
{}{}
}()
if
store
.
child
!=
nil
{
store
.
child
.
ProcEvent
(
nil
)
}
}
//Wait wait for basestore ready
...
...
vendor/github.com/33cn/chain33/types/cfg.go
View file @
143311fe
...
...
@@ -81,6 +81,8 @@ type Consensus struct {
Genesis
string
`protobuf:"bytes,4,opt,name=genesis" json:"genesis,omitempty"`
HotkeyAddr
string
`protobuf:"bytes,5,opt,name=hotkeyAddr" json:"hotkeyAddr,omitempty"`
ForceMining
bool
`protobuf:"varint,6,opt,name=forceMining" json:"forceMining,omitempty"`
// 配置挖矿的合约名单
MinerExecs
[]
string
`protobuf:"bytes,7,rep,name=minerExecs" json:"minerExecs,omitempty"`
}
// Wallet 配置
...
...
@@ -109,6 +111,8 @@ type Store struct {
DbCache
int32
`protobuf:"varint,4,opt,name=dbCache" json:"dbCache,omitempty"`
// 数据库版本
LocalDBVersion
string
`protobuf:"bytes,5,opt,name=localdbVersion" json:"localdbVersion,omitempty"`
// 数据库版本
StoreDBVersion
string
`protobuf:"bytes,5,opt,name=storedbVersion" json:"storedbVersion,omitempty"`
}
// BlockChain 配置
...
...
vendor/github.com/33cn/chain33/types/proto/rpc.proto
View file @
143311fe
...
...
@@ -20,8 +20,6 @@ service chain33 {
//交易接口
rpc
CreateRawTransaction
(
CreateTx
)
returns
(
UnsignTx
)
{}
rpc
CreateRawTxGroup
(
CreateTransactionGroup
)
returns
(
UnsignTx
)
{}
//发送签名后交易
rpc
SendRawTransaction
(
SignedTx
)
returns
(
Reply
)
{}
// 根据哈希查询交易
rpc
QueryTransaction
(
ReqHash
)
returns
(
TransactionDetail
)
{}
// 发送交易
...
...
vendor/github.com/33cn/chain33/types/proto/transaction.proto
View file @
143311fe
...
...
@@ -76,13 +76,6 @@ message NoBalanceTx {
string
expire
=
4
;
}
message
SignedTx
{
bytes
unsign
=
1
;
bytes
sign
=
2
;
bytes
pubkey
=
3
;
int32
ty
=
4
;
}
message
Transaction
{
bytes
execer
=
1
;
bytes
payload
=
2
;
...
...
@@ -244,7 +237,7 @@ message UserWrite {
}
message
UpgradeMeta
{
bool
index
ing
=
1
;
bool
start
ing
=
1
;
string
version
=
2
;
int64
height
=
3
;
}
\ No newline at end of file
vendor/github.com/33cn/chain33/types/rpc.pb.go
View file @
143311fe
This diff is collapsed.
Click to expand it.
vendor/github.com/33cn/chain33/types/transaction.pb.go
View file @
143311fe
This diff is collapsed.
Click to expand it.
vendor/github.com/33cn/chain33/util/cli/chain33.go
View file @
143311fe
...
...
@@ -134,6 +134,7 @@ func RunChain33(name string) {
//开始区块链模块加载
//channel, rabitmq 等
version
.
SetLocalDBVersion
(
cfg
.
Store
.
LocalDBVersion
)
version
.
SetStoreDBVersion
(
cfg
.
Store
.
StoreDBVersion
)
version
.
SetAppVersion
(
cfg
.
Version
)
log
.
Info
(
cfg
.
Title
+
"-app:"
+
version
.
GetAppVersion
()
+
" chain33:"
+
version
.
GetVersion
()
+
" localdb:"
+
version
.
GetLocalDBVersion
())
log
.
Info
(
"loading queue"
)
...
...
@@ -155,12 +156,13 @@ func RunChain33(name string) {
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
())
chain
.
Upgrade
()
log
.
Info
(
"loading consensus module"
)
cs
:=
consensus
.
New
(
cfg
.
Consensus
,
sub
.
Consensus
)
cs
.
SetQueueClient
(
q
.
Client
())
...
...
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