mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-14 05:41:21 +00:00
Fixes from review
This commit is contained in:
@ -419,7 +419,7 @@ func waitForAndValidateBlock(t *testing.T, n int, activeVals map[string]struct{}
|
|||||||
err := validateBlock(newBlock, activeVals)
|
err := validateBlock(newBlock, activeVals)
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
for _, tx := range txs {
|
for _, tx := range txs {
|
||||||
css[j].mempool.CheckTx(tx, nil)
|
err := css[j].mempool.CheckTx(tx, nil)
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
}
|
}
|
||||||
}, css)
|
}, css)
|
||||||
|
@ -266,13 +266,13 @@ func (h *Handshaker) ReplayBlocks(state sm.State, appHash []byte, appBlockHeight
|
|||||||
|
|
||||||
// If appBlockHeight == 0 it means that we are at genesis and hence should send InitChain.
|
// If appBlockHeight == 0 it means that we are at genesis and hence should send InitChain.
|
||||||
if appBlockHeight == 0 {
|
if appBlockHeight == 0 {
|
||||||
nvals := types.TM2PB.Validators(state.Validators) // state.Validators would work too.
|
nextVals := types.TM2PB.Validators(state.Validators) // state.Validators would work too.
|
||||||
csParams := types.TM2PB.ConsensusParams(h.genDoc.ConsensusParams)
|
csParams := types.TM2PB.ConsensusParams(h.genDoc.ConsensusParams)
|
||||||
req := abci.RequestInitChain{
|
req := abci.RequestInitChain{
|
||||||
Time: h.genDoc.GenesisTime.Unix(), // TODO
|
Time: h.genDoc.GenesisTime.Unix(), // TODO
|
||||||
ChainId: h.genDoc.ChainID,
|
ChainId: h.genDoc.ChainID,
|
||||||
ConsensusParams: csParams,
|
ConsensusParams: csParams,
|
||||||
Validators: nvals,
|
Validators: nextVals,
|
||||||
AppStateBytes: h.genDoc.AppStateJSON,
|
AppStateBytes: h.genDoc.AppStateJSON,
|
||||||
}
|
}
|
||||||
res, err := proxyApp.Consensus().InitChainSync(req)
|
res, err := proxyApp.Consensus().InitChainSync(req)
|
||||||
|
@ -53,7 +53,7 @@ func (p *provider) LatestFullCommit(chainID string, minHeight, maxHeight int64)
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if maxHeight != 0 && maxHeight < minHeight {
|
if maxHeight != 0 && maxHeight < minHeight {
|
||||||
err = fmt.Errorf("need maxHeight == 0 or minHeight <= maxHeight, got %v and %v",
|
err = fmt.Errorf("need maxHeight == 0 or minHeight <= maxHeight, got min %v and max %v",
|
||||||
minHeight, maxHeight)
|
minHeight, maxHeight)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -95,7 +95,7 @@ func (p *provider) getValidatorSet(chainID string, height int64) (valset *types.
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if height < 1 {
|
if height < 1 {
|
||||||
err = fmt.Errorf("expected height >= 1, got %v", height)
|
err = fmt.Errorf("expected height >= 1, got height %v", height)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
heightPtr := new(int64)
|
heightPtr := new(int64)
|
||||||
@ -122,11 +122,11 @@ func (p *provider) fillFullCommit(signedHeader types.SignedHeader) (fc lite.Full
|
|||||||
fc.Validators = valset
|
fc.Validators = valset
|
||||||
|
|
||||||
// Get the next validators.
|
// Get the next validators.
|
||||||
nvalset, err := p.getValidatorSet(signedHeader.ChainID, signedHeader.Height+1)
|
nextValset, err := p.getValidatorSet(signedHeader.ChainID, signedHeader.Height+1)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return lite.FullCommit{}, err
|
return lite.FullCommit{}, err
|
||||||
} else {
|
} else {
|
||||||
fc.NextValidators = nvalset
|
fc.NextValidators = nextValset
|
||||||
}
|
}
|
||||||
|
|
||||||
return fc, nil
|
return fc, nil
|
||||||
|
@ -20,11 +20,11 @@ type FullCommit struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewFullCommit returns a new FullCommit.
|
// NewFullCommit returns a new FullCommit.
|
||||||
func NewFullCommit(signedHeader types.SignedHeader, valset, nvalset *types.ValidatorSet) FullCommit {
|
func NewFullCommit(signedHeader types.SignedHeader, valset, nextValset *types.ValidatorSet) FullCommit {
|
||||||
return FullCommit{
|
return FullCommit{
|
||||||
SignedHeader: signedHeader,
|
SignedHeader: signedHeader,
|
||||||
Validators: valset,
|
Validators: valset,
|
||||||
NextValidators: nvalset,
|
NextValidators: nextValset,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,14 +148,14 @@ func (dbp *DBProvider) getValidatorSet(chainID string, height int64) (valset *ty
|
|||||||
func (dbp *DBProvider) fillFullCommit(sh types.SignedHeader) (FullCommit, error) {
|
func (dbp *DBProvider) fillFullCommit(sh types.SignedHeader) (FullCommit, error) {
|
||||||
var chainID = sh.ChainID
|
var chainID = sh.ChainID
|
||||||
var height = sh.Height
|
var height = sh.Height
|
||||||
var valset, nvalset *types.ValidatorSet
|
var valset, nextValset *types.ValidatorSet
|
||||||
// Load the validator set.
|
// Load the validator set.
|
||||||
valset, err := dbp.getValidatorSet(chainID, height)
|
valset, err := dbp.getValidatorSet(chainID, height)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return FullCommit{}, err
|
return FullCommit{}, err
|
||||||
}
|
}
|
||||||
// Load the next validator set.
|
// Load the next validator set.
|
||||||
nvalset, err = dbp.getValidatorSet(chainID, height+1)
|
nextValset, err = dbp.getValidatorSet(chainID, height+1)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return FullCommit{}, err
|
return FullCommit{}, err
|
||||||
}
|
}
|
||||||
@ -163,6 +163,6 @@ func (dbp *DBProvider) fillFullCommit(sh types.SignedHeader) (FullCommit, error)
|
|||||||
return FullCommit{
|
return FullCommit{
|
||||||
SignedHeader: sh,
|
SignedHeader: sh,
|
||||||
Validators: valset,
|
Validators: valset,
|
||||||
NextValidators: nvalset,
|
NextValidators: nextValset,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
@ -96,7 +96,7 @@ func makeVote(header *types.Header, valset *types.ValidatorSet, key crypto.PrivK
|
|||||||
}
|
}
|
||||||
|
|
||||||
func genHeader(chainID string, height int64, txs types.Txs,
|
func genHeader(chainID string, height int64, txs types.Txs,
|
||||||
valset, nvalset *types.ValidatorSet, appHash, consHash, resHash []byte) *types.Header {
|
valset, nextValset *types.ValidatorSet, appHash, consHash, resHash []byte) *types.Header {
|
||||||
|
|
||||||
return &types.Header{
|
return &types.Header{
|
||||||
ChainID: chainID,
|
ChainID: chainID,
|
||||||
@ -107,7 +107,7 @@ func genHeader(chainID string, height int64, txs types.Txs,
|
|||||||
// LastBlockID
|
// LastBlockID
|
||||||
// LastCommitHash
|
// LastCommitHash
|
||||||
ValidatorsHash: valset.Hash(),
|
ValidatorsHash: valset.Hash(),
|
||||||
NextValidatorsHash: nvalset.Hash(),
|
NextValidatorsHash: nextValset.Hash(),
|
||||||
DataHash: txs.Hash(),
|
DataHash: txs.Hash(),
|
||||||
AppHash: appHash,
|
AppHash: appHash,
|
||||||
ConsensusHash: consHash,
|
ConsensusHash: consHash,
|
||||||
@ -117,9 +117,9 @@ func genHeader(chainID string, height int64, txs types.Txs,
|
|||||||
|
|
||||||
// GenSignedHeader calls genHeader and signHeader and combines them into a SignedHeader.
|
// GenSignedHeader calls genHeader and signHeader and combines them into a SignedHeader.
|
||||||
func (pkz privKeys) GenSignedHeader(chainID string, height int64, txs types.Txs,
|
func (pkz privKeys) GenSignedHeader(chainID string, height int64, txs types.Txs,
|
||||||
valset, nvalset *types.ValidatorSet, appHash, consHash, resHash []byte, first, last int) types.SignedHeader {
|
valset, nextValset *types.ValidatorSet, appHash, consHash, resHash []byte, first, last int) types.SignedHeader {
|
||||||
|
|
||||||
header := genHeader(chainID, height, txs, valset, nvalset, appHash, consHash, resHash)
|
header := genHeader(chainID, height, txs, valset, nextValset, appHash, consHash, resHash)
|
||||||
check := types.SignedHeader{
|
check := types.SignedHeader{
|
||||||
Header: header,
|
Header: header,
|
||||||
Commit: pkz.signHeader(header, first, last),
|
Commit: pkz.signHeader(header, first, last),
|
||||||
@ -129,12 +129,12 @@ func (pkz privKeys) GenSignedHeader(chainID string, height int64, txs types.Txs,
|
|||||||
|
|
||||||
// GenFullCommit calls genHeader and signHeader and combines them into a FullCommit.
|
// GenFullCommit calls genHeader and signHeader and combines them into a FullCommit.
|
||||||
func (pkz privKeys) GenFullCommit(chainID string, height int64, txs types.Txs,
|
func (pkz privKeys) GenFullCommit(chainID string, height int64, txs types.Txs,
|
||||||
valset, nvalset *types.ValidatorSet, appHash, consHash, resHash []byte, first, last int) FullCommit {
|
valset, nextValset *types.ValidatorSet, appHash, consHash, resHash []byte, first, last int) FullCommit {
|
||||||
|
|
||||||
header := genHeader(chainID, height, txs, valset, nvalset, appHash, consHash, resHash)
|
header := genHeader(chainID, height, txs, valset, nextValset, appHash, consHash, resHash)
|
||||||
commit := types.SignedHeader{
|
commit := types.SignedHeader{
|
||||||
Header: header,
|
Header: header,
|
||||||
Commit: pkz.signHeader(header, first, last),
|
Commit: pkz.signHeader(header, first, last),
|
||||||
}
|
}
|
||||||
return NewFullCommit(commit, valset, nvalset)
|
return NewFullCommit(commit, valset, nextValset)
|
||||||
}
|
}
|
||||||
|
@ -95,7 +95,7 @@ func (ic *InquiringCertifier) Certify(shdr types.SignedHeader) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get the next validator set.
|
// Get the next validator set.
|
||||||
nvalset, err := ic.source.ValidatorSet(ic.chainID, shdr.Height+1)
|
nextValset, err := ic.source.ValidatorSet(ic.chainID, shdr.Height+1)
|
||||||
if lerr.IsErrMissingValidators(err) {
|
if lerr.IsErrMissingValidators(err) {
|
||||||
// Ignore this error.
|
// Ignore this error.
|
||||||
return nil
|
return nil
|
||||||
@ -106,7 +106,7 @@ func (ic *InquiringCertifier) Certify(shdr types.SignedHeader) error {
|
|||||||
nfc := FullCommit{
|
nfc := FullCommit{
|
||||||
SignedHeader: shdr,
|
SignedHeader: shdr,
|
||||||
Validators: tfc.NextValidators,
|
Validators: tfc.NextValidators,
|
||||||
NextValidators: nvalset,
|
NextValidators: nextValset,
|
||||||
}
|
}
|
||||||
// Validate the full commit. This checks the cryptographic
|
// Validate the full commit. This checks the cryptographic
|
||||||
// signatures of Commit against Validators.
|
// signatures of Commit against Validators.
|
||||||
|
@ -28,12 +28,12 @@ func TestInquirerValidPath(t *testing.T) {
|
|||||||
fcz := make([]FullCommit, count)
|
fcz := make([]FullCommit, count)
|
||||||
for i := 0; i < count; i++ {
|
for i := 0; i < count; i++ {
|
||||||
vals := keys.ToValidators(vote, 0)
|
vals := keys.ToValidators(vote, 0)
|
||||||
nvals := nkeys.ToValidators(vote, 0)
|
nextVals := nkeys.ToValidators(vote, 0)
|
||||||
h := int64(1 + i)
|
h := int64(1 + i)
|
||||||
appHash := []byte(fmt.Sprintf("h=%d", h))
|
appHash := []byte(fmt.Sprintf("h=%d", h))
|
||||||
fcz[i] = keys.GenFullCommit(
|
fcz[i] = keys.GenFullCommit(
|
||||||
chainID, h, nil,
|
chainID, h, nil,
|
||||||
vals, nvals,
|
vals, nextVals,
|
||||||
appHash, consHash, resHash, 0, len(keys))
|
appHash, consHash, resHash, 0, len(keys))
|
||||||
// Extend the keys by 1 each time.
|
// Extend the keys by 1 each time.
|
||||||
keys = nkeys
|
keys = nkeys
|
||||||
@ -85,13 +85,13 @@ func TestInquirerVerifyHistorical(t *testing.T) {
|
|||||||
fcz := make([]FullCommit, count)
|
fcz := make([]FullCommit, count)
|
||||||
for i := 0; i < count; i++ {
|
for i := 0; i < count; i++ {
|
||||||
vals := keys.ToValidators(vote, 0)
|
vals := keys.ToValidators(vote, 0)
|
||||||
nvals := nkeys.ToValidators(vote, 0)
|
nextVals := nkeys.ToValidators(vote, 0)
|
||||||
h := int64(1 + i)
|
h := int64(1 + i)
|
||||||
appHash := []byte(fmt.Sprintf("h=%d", h))
|
appHash := []byte(fmt.Sprintf("h=%d", h))
|
||||||
resHash := []byte(fmt.Sprintf("res=%d", h))
|
resHash := []byte(fmt.Sprintf("res=%d", h))
|
||||||
fcz[i] = keys.GenFullCommit(
|
fcz[i] = keys.GenFullCommit(
|
||||||
chainID, h, nil,
|
chainID, h, nil,
|
||||||
vals, nvals,
|
vals, nextVals,
|
||||||
appHash, consHash, resHash, 0, len(keys))
|
appHash, consHash, resHash, 0, len(keys))
|
||||||
// Extend the keys by 1 each time.
|
// Extend the keys by 1 each time.
|
||||||
keys = nkeys
|
keys = nkeys
|
||||||
|
Reference in New Issue
Block a user