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
6904435a
Commit
6904435a
authored
Oct 10, 2019
by
caopingcp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tendermint save local state
parent
91390fe4
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
152 additions
and
37 deletions
+152
-37
consensus_state.go
plugin/consensus/tendermint/consensus_state.go
+0
-0
peer_set.go
plugin/consensus/tendermint/peer_set.go
+0
-0
state.go
plugin/consensus/tendermint/state.go
+11
-11
store.go
plugin/consensus/tendermint/store.go
+84
-0
tendermint.go
plugin/consensus/tendermint/tendermint.go
+0
-0
tendermint_test.go
plugin/consensus/tendermint/tendermint_test.go
+2
-2
block.go
plugin/consensus/tendermint/types/block.go
+8
-11
errors.go
plugin/consensus/tendermint/types/errors.go
+18
-0
priv_validator.go
plugin/consensus/tendermint/types/priv_validator.go
+1
-1
round_state.go
plugin/consensus/tendermint/types/round_state.go
+12
-1
signable.go
plugin/consensus/tendermint/types/signable.go
+2
-2
validator_set.go
plugin/consensus/tendermint/types/validator_set.go
+1
-1
tendermint.proto
plugin/dapp/valnode/proto/tendermint.proto
+13
-8
tendermint.pb.go
plugin/dapp/valnode/types/tendermint.pb.go
+0
-0
valnode.pb.go
plugin/dapp/valnode/types/valnode.pb.go
+0
-0
No files found.
plugin/consensus/tendermint/consensus_state.go
View file @
6904435a
This diff is collapsed.
Click to expand it.
plugin/consensus/tendermint/peer_set.go
View file @
6904435a
This diff is collapsed.
Click to expand it.
plugin/consensus/tendermint/state.go
View file @
6904435a
...
@@ -118,9 +118,9 @@ func (s State) GetValidators() (last *ttypes.ValidatorSet, current *ttypes.Valid
...
@@ -118,9 +118,9 @@ func (s State) GetValidators() (last *ttypes.ValidatorSet, current *ttypes.Valid
// Create a block from the latest state
// Create a block from the latest state
// MakeBlock builds a block with the given txs and commit from the current state.
// MakeBlock builds a block with the given txs and commit from the current state.
func
(
s
State
)
MakeBlock
(
height
int64
,
round
int64
,
Txs
[]
*
types
.
Transaction
,
commit
*
tmtypes
.
TendermintCommit
)
*
ttypes
.
TendermintBlock
{
func
(
s
State
)
MakeBlock
(
height
int64
,
round
int64
,
pblock
*
types
.
Block
,
commit
*
tmtypes
.
TendermintCommit
,
proposerAddr
[]
byte
)
*
ttypes
.
TendermintBlock
{
// build base block
// build base block
block
:=
ttypes
.
MakeBlock
(
height
,
round
,
Txs
,
commit
)
block
:=
ttypes
.
MakeBlock
(
height
,
round
,
pblock
,
commit
)
// fill header with state data
// fill header with state data
block
.
Header
.
ChainID
=
s
.
ChainID
block
.
Header
.
ChainID
=
s
.
ChainID
...
@@ -130,6 +130,7 @@ func (s State) MakeBlock(height int64, round int64, Txs []*types.Transaction, co
...
@@ -130,6 +130,7 @@ func (s State) MakeBlock(height int64, round int64, Txs []*types.Transaction, co
block
.
Header
.
AppHash
=
s
.
AppHash
block
.
Header
.
AppHash
=
s
.
AppHash
block
.
Header
.
ConsensusHash
=
s
.
ConsensusParams
.
Hash
()
block
.
Header
.
ConsensusHash
=
s
.
ConsensusParams
.
Hash
()
block
.
Header
.
LastResultsHash
=
s
.
LastResultsHash
block
.
Header
.
LastResultsHash
=
s
.
LastResultsHash
block
.
Header
.
ProposerAddr
=
proposerAddr
return
block
return
block
}
}
...
@@ -226,6 +227,7 @@ func LoadState(state *tmtypes.State) State {
...
@@ -226,6 +227,7 @@ func LoadState(state *tmtypes.State) State {
ChainID
:
state
.
GetChainID
(),
ChainID
:
state
.
GetChainID
(),
LastBlockHeight
:
state
.
GetLastBlockHeight
(),
LastBlockHeight
:
state
.
GetLastBlockHeight
(),
LastBlockTotalTx
:
state
.
GetLastBlockTotalTx
(),
LastBlockTotalTx
:
state
.
GetLastBlockTotalTx
(),
LastBlockID
:
ttypes
.
BlockID
{
BlockID
:
*
state
.
LastBlockID
},
LastBlockTime
:
state
.
LastBlockTime
,
LastBlockTime
:
state
.
LastBlockTime
,
Validators
:
nil
,
Validators
:
nil
,
LastValidators
:
nil
,
LastValidators
:
nil
,
...
@@ -307,7 +309,7 @@ func (csdb *CSStateDB) LoadValidators(height int64) (*ttypes.ValidatorSet, error
...
@@ -307,7 +309,7 @@ func (csdb *CSStateDB) LoadValidators(height int64) (*ttypes.ValidatorSet, error
if
height
==
0
{
if
height
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
if
csdb
.
state
.
LastBlockHeight
+
1
==
height
{
if
csdb
.
state
.
LastBlockHeight
==
height
{
return
csdb
.
state
.
Validators
,
nil
return
csdb
.
state
.
Validators
,
nil
}
}
...
@@ -374,6 +376,7 @@ func SaveState(state State) *tmtypes.State {
...
@@ -374,6 +376,7 @@ func SaveState(state State) *tmtypes.State {
ChainID
:
state
.
ChainID
,
ChainID
:
state
.
ChainID
,
LastBlockHeight
:
state
.
LastBlockHeight
,
LastBlockHeight
:
state
.
LastBlockHeight
,
LastBlockTotalTx
:
state
.
LastBlockTotalTx
,
LastBlockTotalTx
:
state
.
LastBlockTotalTx
,
LastBlockID
:
&
state
.
LastBlockID
.
BlockID
,
LastBlockTime
:
state
.
LastBlockTime
,
LastBlockTime
:
state
.
LastBlockTime
,
Validators
:
&
tmtypes
.
ValidatorSet
{
Validators
:
make
([]
*
tmtypes
.
Validator
,
0
),
Proposer
:
&
tmtypes
.
Validator
{}},
Validators
:
&
tmtypes
.
ValidatorSet
{
Validators
:
make
([]
*
tmtypes
.
Validator
,
0
),
Proposer
:
&
tmtypes
.
Validator
{}},
LastValidators
:
&
tmtypes
.
ValidatorSet
{
Validators
:
make
([]
*
tmtypes
.
Validator
,
0
),
Proposer
:
&
tmtypes
.
Validator
{}},
LastValidators
:
&
tmtypes
.
ValidatorSet
{
Validators
:
make
([]
*
tmtypes
.
Validator
,
0
),
Proposer
:
&
tmtypes
.
Validator
{}},
...
@@ -458,17 +461,14 @@ func LoadProposer(source *tmtypes.Validator) (*ttypes.Validator, error) {
...
@@ -458,17 +461,14 @@ func LoadProposer(source *tmtypes.Validator) (*ttypes.Validator, error) {
}
}
// CreateBlockInfoTx make blockInfo to the first transaction of the block and execer is valnode
// CreateBlockInfoTx make blockInfo to the first transaction of the block and execer is valnode
func
CreateBlockInfoTx
(
pubkey
string
,
lastCommit
*
tmtypes
.
TendermintCommit
,
seenCommit
*
tmtypes
.
TendermintCommit
,
state
*
tmtypes
.
State
,
proposal
*
tmtypes
.
Proposal
,
block
*
tmtypes
.
TendermintBlock
)
*
types
.
Transaction
{
func
CreateBlockInfoTx
(
pubkey
string
,
state
*
tmtypes
.
State
,
block
*
tmtypes
.
TendermintBlock
)
*
types
.
Transaction
{
block
NoTxs
:=
*
block
block
Save
:=
*
block
block
NoTxs
.
Txs
=
make
([]
*
types
.
Transaction
,
0
)
block
Save
.
Data
=
nil
blockInfo
:=
&
tmtypes
.
TendermintBlockInfo
{
blockInfo
:=
&
tmtypes
.
TendermintBlockInfo
{
SeenCommit
:
seenCommit
,
LastCommit
:
lastCommit
,
State
:
state
,
State
:
state
,
Proposal
:
proposal
,
Block
:
&
blockSave
,
Block
:
&
blockNoTxs
,
}
}
tendermintlog
.
Debug
(
"CreateBlockInfoTx"
,
"
validators"
,
blockInfo
.
State
.
Validators
.
Validators
,
"block"
,
block
,
"block-notxs"
,
blockNoTxs
)
tendermintlog
.
Debug
(
"CreateBlockInfoTx"
,
"
blockInfo"
,
blockInfo
)
nput
:=
&
tmtypes
.
ValNodeAction_BlockInfo
{
BlockInfo
:
blockInfo
}
nput
:=
&
tmtypes
.
ValNodeAction_BlockInfo
{
BlockInfo
:
blockInfo
}
action
:=
&
tmtypes
.
ValNodeAction
{
Value
:
nput
,
Ty
:
tmtypes
.
ValNodeActionBlockInfo
}
action
:=
&
tmtypes
.
ValNodeAction
{
Value
:
nput
,
Ty
:
tmtypes
.
ValNodeActionBlockInfo
}
...
...
plugin/consensus/tendermint/store.go
0 → 100644
View file @
6904435a
package
tendermint
import
(
"fmt"
dbm
"github.com/33cn/chain33/common/db"
"github.com/33cn/chain33/types"
tmtypes
"github.com/33cn/plugin/plugin/dapp/valnode/types"
)
var
(
stateKey
=
[]
byte
(
"stateKey"
)
)
type
ConsensusStore
struct
{
db
dbm
.
DB
}
// NewConsensusStore returns a new ConsensusStore with the given DB
func
NewConsensusStore
()
*
ConsensusStore
{
db
:=
DefaultDBProvider
(
"state"
)
db
.
SetCacheSize
(
100
)
return
&
ConsensusStore
{
db
:
db
,
}
}
// LoadStateFromStore
func
(
cs
*
ConsensusStore
)
LoadStateFromStore
()
*
tmtypes
.
State
{
buf
,
err
:=
cs
.
db
.
Get
(
stateKey
)
if
err
!=
nil
{
tendermintlog
.
Error
(
"LoadStateFromStore"
,
"err"
,
err
)
return
nil
}
state
:=
&
tmtypes
.
State
{}
err
=
types
.
Decode
(
buf
,
state
)
if
err
!=
nil
{
panic
(
err
)
}
return
state
}
// LoadStateHeight
func
(
cs
*
ConsensusStore
)
LoadStateHeight
()
int64
{
state
:=
cs
.
LoadStateFromStore
()
if
state
==
nil
{
return
int64
(
0
)
}
return
state
.
LastBlockHeight
}
// LoadSeenCommit by height
func
(
cs
*
ConsensusStore
)
LoadSeenCommit
(
height
int64
)
*
tmtypes
.
TendermintCommit
{
buf
,
err
:=
cs
.
db
.
Get
(
calcSeenCommitKey
(
height
))
if
err
!=
nil
{
tendermintlog
.
Error
(
"LoadSeenCommit"
,
"err"
,
err
)
return
nil
}
commit
:=
&
tmtypes
.
TendermintCommit
{}
err
=
types
.
Decode
(
buf
,
commit
)
if
err
!=
nil
{
panic
(
err
)
}
return
commit
}
// SaveConsensusState save state and seenCommit
func
(
cs
*
ConsensusStore
)
SaveConsensusState
(
height
int64
,
state
*
tmtypes
.
State
,
sc
*
tmtypes
.
TendermintCommit
)
error
{
seenCommitBytes
:=
types
.
Encode
(
sc
)
stateBytes
:=
types
.
Encode
(
state
)
batch
:=
cs
.
db
.
NewBatch
(
true
)
batch
.
Set
(
calcSeenCommitKey
(
height
),
seenCommitBytes
)
batch
.
Set
(
stateKey
,
stateBytes
)
err
:=
batch
.
Write
()
if
err
!=
nil
{
tendermintlog
.
Error
(
"SaveConsensusState batch.Write"
,
"err"
,
err
)
return
err
}
return
nil
}
func
calcSeenCommitKey
(
height
int64
)
[]
byte
{
return
[]
byte
(
fmt
.
Sprintf
(
"SC:%v"
,
height
))
}
plugin/consensus/tendermint/tendermint.go
View file @
6904435a
This diff is collapsed.
Click to expand it.
plugin/consensus/tendermint/tendermint_test.go
View file @
6904435a
...
@@ -68,12 +68,12 @@ func TendermintPerf() {
...
@@ -68,12 +68,12 @@ func TendermintPerf() {
for
err
!=
nil
{
for
err
!=
nil
{
err
=
createConn
()
err
=
createConn
()
}
}
time
.
Sleep
(
10
*
time
.
Second
)
time
.
Sleep
(
2
*
time
.
Second
)
for
i
:=
0
;
i
<
loopCount
;
i
++
{
for
i
:=
0
;
i
<
loopCount
;
i
++
{
NormPut
()
NormPut
()
time
.
Sleep
(
time
.
Second
)
time
.
Sleep
(
time
.
Second
)
}
}
time
.
Sleep
(
10
*
time
.
Second
)
time
.
Sleep
(
2
*
time
.
Second
)
}
}
func
initEnvTendermint
()
(
queue
.
Queue
,
*
blockchain
.
BlockChain
,
queue
.
Module
,
queue
.
Module
,
*
executor
.
Executor
,
queue
.
Module
,
queue
.
Module
)
{
func
initEnvTendermint
()
(
queue
.
Queue
,
*
blockchain
.
BlockChain
,
queue
.
Module
,
queue
.
Module
,
*
executor
.
Executor
,
queue
.
Module
,
queue
.
Module
)
{
...
...
plugin/consensus/tendermint/types/block.go
View file @
6904435a
...
@@ -58,15 +58,16 @@ type TendermintBlock struct {
...
@@ -58,15 +58,16 @@ type TendermintBlock struct {
// MakeBlock returns a new block with an empty header, except what can be computed from itself.
// MakeBlock returns a new block with an empty header, except what can be computed from itself.
// It populates the same set of fields validated by ValidateBasic
// It populates the same set of fields validated by ValidateBasic
func
MakeBlock
(
height
int64
,
round
int64
,
Txs
[]
*
types
.
Transaction
,
commit
*
tmtypes
.
TendermintCommit
)
*
TendermintBlock
{
func
MakeBlock
(
height
int64
,
round
int64
,
pblock
*
types
.
Block
,
commit
*
tmtypes
.
TendermintCommit
)
*
TendermintBlock
{
block
:=
&
TendermintBlock
{
&
tmtypes
.
TendermintBlock
{
block
:=
&
TendermintBlock
{
&
tmtypes
.
TendermintBlock
{
Header
:
&
tmtypes
.
TendermintBlockHeader
{
Header
:
&
tmtypes
.
TendermintBlockHeader
{
Height
:
height
,
Height
:
height
,
Round
:
round
,
Round
:
round
,
Time
:
time
.
Now
()
.
UnixNano
()
,
Time
:
pblock
.
BlockTime
,
NumTxs
:
int64
(
len
(
Txs
)),
NumTxs
:
int64
(
len
(
pblock
.
Txs
)),
},
},
Txs
:
Txs
,
Data
:
pblock
,
LastCommit
:
commit
,
LastCommit
:
commit
,
Evidence
:
&
tmtypes
.
EvidenceData
{
Evidence
:
make
([]
*
tmtypes
.
EvidenceEnvelope
,
0
)},
Evidence
:
&
tmtypes
.
EvidenceData
{
Evidence
:
make
([]
*
tmtypes
.
EvidenceEnvelope
,
0
)},
},
},
...
@@ -97,7 +98,7 @@ func (b *TendermintBlock) AddEvidence(evidence []Evidence) {
...
@@ -97,7 +98,7 @@ func (b *TendermintBlock) AddEvidence(evidence []Evidence) {
// ValidateBasic performs basic validation that doesn't involve state data.
// ValidateBasic performs basic validation that doesn't involve state data.
// It checks the internal consistency of the block.
// It checks the internal consistency of the block.
func
(
b
*
TendermintBlock
)
ValidateBasic
()
(
int64
,
error
)
{
func
(
b
*
TendermintBlock
)
ValidateBasic
()
(
int64
,
error
)
{
newTxs
:=
int64
(
len
(
b
.
Txs
))
newTxs
:=
int64
(
len
(
b
.
Data
.
Txs
))
if
b
.
Header
.
NumTxs
!=
newTxs
{
if
b
.
Header
.
NumTxs
!=
newTxs
{
return
0
,
fmt
.
Errorf
(
"Wrong Block.Header.NumTxs. Expected %v, got %v"
,
newTxs
,
b
.
Header
.
NumTxs
)
return
0
,
fmt
.
Errorf
(
"Wrong Block.Header.NumTxs. Expected %v, got %v"
,
newTxs
,
b
.
Header
.
NumTxs
)
...
@@ -247,17 +248,13 @@ func (h *Header) StringIndented(indent string) string {
...
@@ -247,17 +248,13 @@ func (h *Header) StringIndented(indent string) string {
// Commit struct
// Commit struct
type
Commit
struct
{
type
Commit
struct
{
*
tmtypes
.
TendermintCommit
*
tmtypes
.
TendermintCommit
firstPrecommit
*
tmtypes
.
Vote
hash
[]
byte
hash
[]
byte
bitArray
*
BitArray
bitArray
*
BitArray
firstPrecommit
*
tmtypes
.
Vote
}
}
// FirstPrecommit returns the first non-nil precommit in the commit
// FirstPrecommit returns the first non-nil precommit in the commit
func
(
commit
*
Commit
)
FirstPrecommit
()
*
tmtypes
.
Vote
{
func
(
commit
*
Commit
)
FirstPrecommit
()
*
tmtypes
.
Vote
{
if
len
(
commit
.
Precommits
)
==
0
{
return
nil
}
if
commit
.
firstPrecommit
!=
nil
{
if
commit
.
firstPrecommit
!=
nil
{
return
commit
.
firstPrecommit
return
commit
.
firstPrecommit
}
}
...
...
plugin/consensus/tendermint/types/errors.go
0 → 100644
View file @
6904435a
// Copyright Fuzamei Corp. 2018 All Rights Reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package
types
import
"errors"
var
(
// ErrBaseTxType error type
ErrBaseTxType
=
errors
.
New
(
"ErrBaseTxType"
)
// ErrBlockInfoTx error type
ErrBlockInfoTx
=
errors
.
New
(
"ErrBlockInfoTx"
)
// ErrBaseExecErr error type
ErrBaseExecErr
=
errors
.
New
(
"ErrBaseExecErr"
)
// ErrLastBlockID error type
ErrLastBlockID
=
errors
.
New
(
"ErrLastBlockID"
)
)
plugin/consensus/tendermint/types/priv_validator.go
View file @
6904435a
...
@@ -440,7 +440,7 @@ func (pv *PrivValidatorImp) SignHeartbeat(chainID string, heartbeat *Heartbeat)
...
@@ -440,7 +440,7 @@ func (pv *PrivValidatorImp) SignHeartbeat(chainID string, heartbeat *Heartbeat)
// String returns a string representation of the PrivValidatorImp.
// String returns a string representation of the PrivValidatorImp.
func
(
pv
*
PrivValidatorImp
)
String
()
string
{
func
(
pv
*
PrivValidatorImp
)
String
()
string
{
return
Fmt
(
"PrivValidator{%
v
LH:%v, LR:%v, LS:%v}"
,
pv
.
GetAddress
(),
pv
.
LastHeight
,
pv
.
LastRound
,
pv
.
LastStep
)
return
Fmt
(
"PrivValidator{%
X
LH:%v, LR:%v, LS:%v}"
,
pv
.
GetAddress
(),
pv
.
LastHeight
,
pv
.
LastRound
,
pv
.
LastStep
)
}
}
// GetLastHeight ...
// GetLastHeight ...
...
...
plugin/consensus/tendermint/types/round_state.go
View file @
6904435a
...
@@ -39,10 +39,11 @@ const (
...
@@ -39,10 +39,11 @@ const (
ProposalPOLID
=
byte
(
0x05
)
ProposalPOLID
=
byte
(
0x05
)
VoteID
=
byte
(
0x06
)
VoteID
=
byte
(
0x06
)
HasVoteID
=
byte
(
0x07
)
HasVoteID
=
byte
(
0x07
)
VoteSetMaj23ID
=
byte
(
0
X
08
)
VoteSetMaj23ID
=
byte
(
0
x
08
)
VoteSetBitsID
=
byte
(
0x09
)
VoteSetBitsID
=
byte
(
0x09
)
ProposalHeartbeatID
=
byte
(
0x0a
)
ProposalHeartbeatID
=
byte
(
0x0a
)
ProposalBlockID
=
byte
(
0x0b
)
ProposalBlockID
=
byte
(
0x0b
)
ValidBlockID
=
byte
(
0x0c
)
PacketTypePing
=
byte
(
0xff
)
PacketTypePing
=
byte
(
0xff
)
PacketTypePong
=
byte
(
0xfe
)
PacketTypePong
=
byte
(
0xfe
)
...
@@ -62,6 +63,7 @@ func InitMessageMap() {
...
@@ -62,6 +63,7 @@ func InitMessageMap() {
VoteSetBitsID
:
reflect
.
TypeOf
(
tmtypes
.
VoteSetBitsMsg
{}),
VoteSetBitsID
:
reflect
.
TypeOf
(
tmtypes
.
VoteSetBitsMsg
{}),
ProposalHeartbeatID
:
reflect
.
TypeOf
(
tmtypes
.
Heartbeat
{}),
ProposalHeartbeatID
:
reflect
.
TypeOf
(
tmtypes
.
Heartbeat
{}),
ProposalBlockID
:
reflect
.
TypeOf
(
tmtypes
.
TendermintBlock
{}),
ProposalBlockID
:
reflect
.
TypeOf
(
tmtypes
.
TendermintBlock
{}),
ValidBlockID
:
reflect
.
TypeOf
(
tmtypes
.
ValidBlockMsg
{}),
}
}
}
}
...
@@ -108,6 +110,8 @@ type RoundState struct {
...
@@ -108,6 +110,8 @@ type RoundState struct {
ProposalBlock
*
TendermintBlock
ProposalBlock
*
TendermintBlock
LockedRound
int
LockedRound
int
LockedBlock
*
TendermintBlock
LockedBlock
*
TendermintBlock
ValidRound
int
// Last known round with POL for non-nil valid block.
ValidBlock
*
TendermintBlock
// Last known block of POL mentioned above.
Votes
*
HeightVoteSet
Votes
*
HeightVoteSet
CommitRound
int
CommitRound
int
LastCommit
*
VoteSet
// Last precommits at Height-1
LastCommit
*
VoteSet
// Last precommits at Height-1
...
@@ -141,6 +145,8 @@ func (rs *RoundState) StringIndented(indent string) string {
...
@@ -141,6 +145,8 @@ func (rs *RoundState) StringIndented(indent string) string {
%s ProposalBlock: %v
%s ProposalBlock: %v
%s LockedRound: %v
%s LockedRound: %v
%s LockedBlock: %v
%s LockedBlock: %v
%s ValidRound: %v
%s ValidBlock: %v
%s Votes: %v
%s Votes: %v
%s LastCommit: %v
%s LastCommit: %v
%s LastValidators:%v
%s LastValidators:%v
...
@@ -153,6 +159,8 @@ func (rs *RoundState) StringIndented(indent string) string {
...
@@ -153,6 +159,8 @@ func (rs *RoundState) StringIndented(indent string) string {
indent
,
rs
.
ProposalBlock
.
StringShort
(),
indent
,
rs
.
ProposalBlock
.
StringShort
(),
indent
,
rs
.
LockedRound
,
indent
,
rs
.
LockedRound
,
indent
,
rs
.
LockedBlock
.
StringShort
(),
indent
,
rs
.
LockedBlock
.
StringShort
(),
indent
,
rs
.
ValidRound
,
indent
,
rs
.
ValidBlock
.
StringShort
(),
indent
,
rs
.
Votes
.
StringIndented
(
indent
+
" "
),
indent
,
rs
.
Votes
.
StringIndented
(
indent
+
" "
),
indent
,
rs
.
LastCommit
.
StringShort
(),
indent
,
rs
.
LastCommit
.
StringShort
(),
indent
,
rs
.
LastValidators
.
StringIndented
(
indent
+
" "
),
indent
,
rs
.
LastValidators
.
StringIndented
(
indent
+
" "
),
...
@@ -173,6 +181,7 @@ type PeerRoundState struct {
...
@@ -173,6 +181,7 @@ type PeerRoundState struct {
StartTime
time
.
Time
// Estimated start of round 0 at this height
StartTime
time
.
Time
// Estimated start of round 0 at this height
Proposal
bool
// True if peer has proposal for this round
Proposal
bool
// True if peer has proposal for this round
ProposalBlock
bool
// True if peer has proposal block for this round
ProposalBlock
bool
// True if peer has proposal block for this round
ProposalBlockHash
[]
byte
ProposalPOLRound
int
// Proposal's POL round. -1 if none.
ProposalPOLRound
int
// Proposal's POL round. -1 if none.
ProposalPOL
*
BitArray
// nil until ProposalPOLMessage received.
ProposalPOL
*
BitArray
// nil until ProposalPOLMessage received.
Prevotes
*
BitArray
// All votes peer has for this round
Prevotes
*
BitArray
// All votes peer has for this round
...
@@ -194,6 +203,7 @@ func (prs PeerRoundState) StringIndented(indent string) string {
...
@@ -194,6 +203,7 @@ func (prs PeerRoundState) StringIndented(indent string) string {
%s %v/%v/%v @%v
%s %v/%v/%v @%v
%s Proposal %v
%s Proposal %v
%s ProposalBlock %v
%s ProposalBlock %v
%s ProposalBlockHash %X
%s POL %v (round %v)
%s POL %v (round %v)
%s Prevotes %v
%s Prevotes %v
%s Precommits %v
%s Precommits %v
...
@@ -203,6 +213,7 @@ func (prs PeerRoundState) StringIndented(indent string) string {
...
@@ -203,6 +213,7 @@ func (prs PeerRoundState) StringIndented(indent string) string {
indent
,
prs
.
Height
,
prs
.
Round
,
prs
.
Step
,
prs
.
StartTime
,
indent
,
prs
.
Height
,
prs
.
Round
,
prs
.
Step
,
prs
.
StartTime
,
indent
,
prs
.
Proposal
,
indent
,
prs
.
Proposal
,
indent
,
prs
.
ProposalBlock
,
indent
,
prs
.
ProposalBlock
,
indent
,
prs
.
ProposalBlock
,
indent
,
prs
.
ProposalPOL
,
prs
.
ProposalPOLRound
,
indent
,
prs
.
ProposalPOL
,
prs
.
ProposalPOLRound
,
indent
,
prs
.
Prevotes
,
indent
,
prs
.
Prevotes
,
indent
,
prs
.
Precommits
,
indent
,
prs
.
Precommits
,
...
...
plugin/consensus/tendermint/types/signable.go
View file @
6904435a
...
@@ -70,7 +70,7 @@ func NewProposal(height int64, round int, blockhash []byte, polRound int, polBlo
...
@@ -70,7 +70,7 @@ func NewProposal(height int64, round int, blockhash []byte, polRound int, polBlo
// String returns a string representation of the Proposal.
// String returns a string representation of the Proposal.
func
(
p
*
Proposal
)
String
()
string
{
func
(
p
*
Proposal
)
String
()
string
{
return
fmt
.
Sprintf
(
"Proposal{%v/%v (%v,
%v) %X %v
@ %s}"
,
return
fmt
.
Sprintf
(
"Proposal{%v/%v (%v,
%X) %X %X
@ %s}"
,
p
.
Height
,
p
.
Round
,
p
.
POLRound
,
p
.
POLBlockID
,
p
.
Height
,
p
.
Round
,
p
.
POLRound
,
p
.
POLBlockID
,
p
.
Blockhash
,
p
.
Signature
,
CanonicalTime
(
time
.
Unix
(
0
,
p
.
Timestamp
)))
p
.
Blockhash
,
p
.
Signature
,
CanonicalTime
(
time
.
Unix
(
0
,
p
.
Timestamp
)))
}
}
...
@@ -211,7 +211,7 @@ func (vote *Vote) String() string {
...
@@ -211,7 +211,7 @@ func (vote *Vote) String() string {
PanicSanity
(
"Unknown vote type"
)
PanicSanity
(
"Unknown vote type"
)
}
}
return
fmt
.
Sprintf
(
"Vote{%v:%X %v/%02d/%v(%v) %X %
v
@ %s}"
,
return
fmt
.
Sprintf
(
"Vote{%v:%X %v/%02d/%v(%v) %X %
X
@ %s}"
,
vote
.
ValidatorIndex
,
Fingerprint
(
vote
.
ValidatorAddress
),
vote
.
ValidatorIndex
,
Fingerprint
(
vote
.
ValidatorAddress
),
vote
.
Height
,
vote
.
Round
,
vote
.
Type
,
typeString
,
vote
.
Height
,
vote
.
Round
,
vote
.
Type
,
typeString
,
Fingerprint
(
vote
.
BlockID
.
Hash
),
vote
.
Signature
,
Fingerprint
(
vote
.
BlockID
.
Hash
),
vote
.
Signature
,
...
...
plugin/consensus/tendermint/types/validator_set.go
View file @
6904435a
...
@@ -70,7 +70,7 @@ func (v *Validator) String() string {
...
@@ -70,7 +70,7 @@ func (v *Validator) String() string {
if
v
==
nil
{
if
v
==
nil
{
return
"nil-Validator"
return
"nil-Validator"
}
}
return
Fmt
(
"Validator{
%v %v
VP:%v A:%v}"
,
return
Fmt
(
"Validator{
ADDR:%X PUB:%X
VP:%v A:%v}"
,
v
.
Address
,
v
.
Address
,
v
.
PubKey
,
v
.
PubKey
,
v
.
VotingPower
,
v
.
VotingPower
,
...
...
plugin/dapp/valnode/proto/tendermint.proto
View file @
6904435a
syntax
=
"proto3"
;
syntax
=
"proto3"
;
import
"
transactio
n.proto"
;
import
"
blockchai
n.proto"
;
package
types
;
package
types
;
...
@@ -30,11 +30,9 @@ message TendermintCommit {
...
@@ -30,11 +30,9 @@ message TendermintCommit {
}
}
message
TendermintBlockInfo
{
message
TendermintBlockInfo
{
TendermintCommit
SeenCommit
=
1
;
State
State
=
2
;
TendermintCommit
LastCommit
=
2
;
Proposal
Proposal
=
3
;
State
State
=
3
;
TendermintBlock
block
=
4
;
Proposal
Proposal
=
4
;
TendermintBlock
block
=
5
;
}
}
message
BlockSize
{
message
BlockSize
{
...
@@ -118,14 +116,14 @@ message TendermintBlockHeader {
...
@@ -118,14 +116,14 @@ message TendermintBlockHeader {
bytes
appHash
=
11
;
bytes
appHash
=
11
;
bytes
lastResultsHash
=
12
;
bytes
lastResultsHash
=
12
;
bytes
evidenceHash
=
13
;
bytes
evidenceHash
=
13
;
bytes
proposerAddr
=
14
;
}
}
message
TendermintBlock
{
message
TendermintBlock
{
TendermintBlockHeader
header
=
1
;
TendermintBlockHeader
header
=
1
;
repeated
Transaction
txs
=
2
;
Block
data
=
2
;
EvidenceData
evidence
=
3
;
EvidenceData
evidence
=
3
;
TendermintCommit
lastCommit
=
4
;
TendermintCommit
lastCommit
=
4
;
bytes
proposerAddr
=
5
;
}
}
message
Proposal
{
message
Proposal
{
...
@@ -146,6 +144,13 @@ message NewRoundStepMsg {
...
@@ -146,6 +144,13 @@ message NewRoundStepMsg {
int32
lastCommitRound
=
5
;
int32
lastCommitRound
=
5
;
}
}
message
ValidBlockMsg
{
int64
height
=
1
;
int32
round
=
2
;
bytes
blockhash
=
3
;
bool
isCommit
=
4
;
}
message
CommitStepMsg
{
message
CommitStepMsg
{
int64
height
=
1
;
int64
height
=
1
;
}
}
...
...
plugin/dapp/valnode/types/tendermint.pb.go
View file @
6904435a
This diff is collapsed.
Click to expand it.
plugin/dapp/valnode/types/valnode.pb.go
View file @
6904435a
This diff is collapsed.
Click to expand it.
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