mirror of
https://github.com/tendermint/tendermint.git
synced 2026-02-06 12:00:44 +00:00
Merge branch 'master' into marko/int64-
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
"github.com/tendermint/tendermint/crypto"
|
||||
"github.com/tendermint/tendermint/crypto/ed25519"
|
||||
cryptoenc "github.com/tendermint/tendermint/crypto/encoding"
|
||||
tmrand "github.com/tendermint/tendermint/libs/rand"
|
||||
tmstate "github.com/tendermint/tendermint/proto/tendermint/state"
|
||||
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
|
||||
@@ -163,10 +164,18 @@ func makeHeaderPartsResponsesValPubKeyChange(
|
||||
// If the pubkey is new, remove the old and add the new.
|
||||
_, val := state.NextValidators.GetByIndex(0)
|
||||
if !bytes.Equal(pubkey.Bytes(), val.PubKey.Bytes()) {
|
||||
vPbPk, err := cryptoenc.PubKeyToProto(val.PubKey)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
pbPk, err := cryptoenc.PubKeyToProto(pubkey)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
abciResponses.EndBlock = &abci.ResponseEndBlock{
|
||||
ValidatorUpdates: []abci.ValidatorUpdate{
|
||||
types.TM2PB.NewValidatorUpdate(val.PubKey, 0),
|
||||
types.TM2PB.NewValidatorUpdate(pubkey, 10),
|
||||
{PubKey: vPbPk, Power: 0},
|
||||
{PubKey: pbPk, Power: 10},
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -188,9 +197,13 @@ func makeHeaderPartsResponsesValPowerChange(
|
||||
// If the pubkey is new, remove the old and add the new.
|
||||
_, val := state.NextValidators.GetByIndex(0)
|
||||
if val.VotingPower != power {
|
||||
vPbPk, err := cryptoenc.PubKeyToProto(val.PubKey)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
abciResponses.EndBlock = &abci.ResponseEndBlock{
|
||||
ValidatorUpdates: []abci.ValidatorUpdate{
|
||||
types.TM2PB.NewValidatorUpdate(val.PubKey, power),
|
||||
{PubKey: vPbPk, Power: power},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,11 +108,11 @@ func TestABCIResponsesSaveLoad1(t *testing.T) {
|
||||
|
||||
abciResponses.DeliverTxs[0] = &abci.ResponseDeliverTx{Data: []byte("foo"), Events: nil}
|
||||
abciResponses.DeliverTxs[1] = &abci.ResponseDeliverTx{Data: []byte("bar"), Log: "ok", Events: nil}
|
||||
abciResponses.EndBlock = &abci.ResponseEndBlock{ValidatorUpdates: []abci.ValidatorUpdate{
|
||||
types.TM2PB.NewValidatorUpdate(ed25519.GenPrivKey().PubKey(), 10),
|
||||
}}
|
||||
pbpk, err := cryptoenc.PubKeyToProto(ed25519.GenPrivKey().PubKey())
|
||||
require.NoError(t, err)
|
||||
abciResponses.EndBlock = &abci.ResponseEndBlock{ValidatorUpdates: []abci.ValidatorUpdate{{PubKey: pbpk, Power: 10}}}
|
||||
|
||||
err := stateStore.SaveABCIResponses(block.Height, abciResponses)
|
||||
err = stateStore.SaveABCIResponses(block.Height, abciResponses)
|
||||
require.NoError(t, err)
|
||||
loadedABCIResponses, err := stateStore.LoadABCIResponses(block.Height)
|
||||
assert.Nil(err)
|
||||
|
||||
Reference in New Issue
Block a user