More TM 0.24 updates
This commit is contained in:
parent
73292e08b4
commit
14d5e686d9
|
@ -420,7 +420,7 @@ func (app *BaseApp) BeginBlock(req abci.RequestBeginBlock) (res abci.ResponseBeg
|
||||||
|
|
||||||
// set the signed validators for addition to context in deliverTx
|
// set the signed validators for addition to context in deliverTx
|
||||||
// TODO: communicate this result to the address to pubkey map in slashing
|
// TODO: communicate this result to the address to pubkey map in slashing
|
||||||
app.signedValidators = req.LastCommitInfo.GetValidators()
|
app.voteInfos = req.LastCommitInfo.GetVotes()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@ import (
|
||||||
tcmd "github.com/tendermint/tendermint/cmd/tendermint/commands"
|
tcmd "github.com/tendermint/tendermint/cmd/tendermint/commands"
|
||||||
cmn "github.com/tendermint/tendermint/libs/common"
|
cmn "github.com/tendermint/tendermint/libs/common"
|
||||||
"github.com/tendermint/tendermint/node"
|
"github.com/tendermint/tendermint/node"
|
||||||
|
"github.com/tendermint/tendermint/p2p"
|
||||||
pvm "github.com/tendermint/tendermint/privval"
|
pvm "github.com/tendermint/tendermint/privval"
|
||||||
"github.com/tendermint/tendermint/proxy"
|
"github.com/tendermint/tendermint/proxy"
|
||||||
)
|
)
|
||||||
|
@ -94,10 +95,16 @@ func startInProcess(ctx *Context, appCreator AppCreator) (*node.Node, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nodeKey, err := p2p.LoadOrGenNodeKey(cfg.NodeKeyFile())
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
// create & start tendermint node
|
// create & start tendermint node
|
||||||
tmNode, err := node.NewNode(
|
tmNode, err := node.NewNode(
|
||||||
cfg,
|
cfg,
|
||||||
pvm.LoadOrGenFilePV(cfg.PrivValidatorFile()),
|
pvm.LoadOrGenFilePV(cfg.PrivValidatorFile()),
|
||||||
|
nodeKey,
|
||||||
proxy.NewLocalClientCreator(app),
|
proxy.NewLocalClientCreator(app),
|
||||||
node.DefaultGenesisDocProviderFunc(cfg),
|
node.DefaultGenesisDocProviderFunc(cfg),
|
||||||
node.DefaultDBProvider,
|
node.DefaultDBProvider,
|
||||||
|
|
|
@ -14,7 +14,7 @@ func First(st KVStore, start, end []byte) (kv cmn.KVPair, ok bool) {
|
||||||
}
|
}
|
||||||
defer iter.Close()
|
defer iter.Close()
|
||||||
|
|
||||||
return cmn.KVPair{iter.Key(), iter.Value()}, true
|
return cmn.KVPair{Key: iter.Key(), Value: iter.Value()}, true
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gets the last item. `end` is exclusive.
|
// Gets the last item. `end` is exclusive.
|
||||||
|
@ -22,7 +22,7 @@ func Last(st KVStore, start, end []byte) (kv cmn.KVPair, ok bool) {
|
||||||
iter := st.ReverseIterator(end, start)
|
iter := st.ReverseIterator(end, start)
|
||||||
if !iter.Valid() {
|
if !iter.Valid() {
|
||||||
if v := st.Get(start); v != nil {
|
if v := st.Get(start); v != nil {
|
||||||
return cmn.KVPair{cp(start), cp(v)}, true
|
return cmn.KVPair{Key: cp(start), Value: cp(v)}, true
|
||||||
}
|
}
|
||||||
return kv, false
|
return kv, false
|
||||||
}
|
}
|
||||||
|
@ -36,5 +36,5 @@ func Last(st KVStore, start, end []byte) (kv cmn.KVPair, ok bool) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return cmn.KVPair{iter.Key(), iter.Value()}, true
|
return cmn.KVPair{Key: iter.Key(), Value: iter.Value()}, true
|
||||||
}
|
}
|
||||||
|
|
|
@ -239,7 +239,7 @@ func (st *iavlStore) Query(req abci.RequestQuery) (res abci.ResponseQuery) {
|
||||||
var KVs []KVPair
|
var KVs []KVPair
|
||||||
iterator := sdk.KVStorePrefixIterator(st, subspace)
|
iterator := sdk.KVStorePrefixIterator(st, subspace)
|
||||||
for ; iterator.Valid(); iterator.Next() {
|
for ; iterator.Valid(); iterator.Next() {
|
||||||
KVs = append(KVs, KVPair{iterator.Key(), iterator.Value()})
|
KVs = append(KVs, KVPair{Key: iterator.Key(), Value: iterator.Value()})
|
||||||
}
|
}
|
||||||
iterator.Close()
|
iterator.Close()
|
||||||
res.Value = cdc.MustMarshalBinary(KVs)
|
res.Value = cdc.MustMarshalBinary(KVs)
|
||||||
|
@ -309,7 +309,7 @@ func (iter *iavlIterator) iterateRoutine() {
|
||||||
select {
|
select {
|
||||||
case <-iter.quitCh:
|
case <-iter.quitCh:
|
||||||
return true // done with iteration.
|
return true // done with iteration.
|
||||||
case iter.iterCh <- cmn.KVPair{key, value}:
|
case iter.iterCh <- cmn.KVPair{Key: key, Value: value}:
|
||||||
return false // yay.
|
return false // yay.
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -3,6 +3,7 @@ package types
|
||||||
import (
|
import (
|
||||||
abci "github.com/tendermint/tendermint/abci/types"
|
abci "github.com/tendermint/tendermint/abci/types"
|
||||||
"github.com/tendermint/tendermint/crypto"
|
"github.com/tendermint/tendermint/crypto"
|
||||||
|
tmtypes "github.com/tendermint/tendermint/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
// status of a validator
|
// status of a validator
|
||||||
|
@ -55,6 +56,14 @@ func ABCIValidator(v Validator) abci.Validator {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// validator which fulfills abci validator update interface for use in Tendermint
|
||||||
|
func ABCIValidatorUpdate(v Validator) abci.ValidatorUpdate {
|
||||||
|
return abci.ValidatorUpdate{
|
||||||
|
PubKey: tmtypes.TM2PB.PubKey(v.GetPubKey()),
|
||||||
|
Power: v.GetPower().RoundInt64(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// properties for the set of all validators
|
// properties for the set of all validators
|
||||||
type ValidatorSet interface {
|
type ValidatorSet interface {
|
||||||
// iterate through validator by owner-AccAddress, execute func for each validator
|
// iterate through validator by owner-AccAddress, execute func for each validator
|
||||||
|
|
|
@ -138,7 +138,7 @@ func (k Keeper) handleValidatorSignature(ctx sdk.Context, addr crypto.Address, p
|
||||||
}
|
}
|
||||||
|
|
||||||
// AddValidators adds the validators to the keepers validator addr to pubkey mapping.
|
// AddValidators adds the validators to the keepers validator addr to pubkey mapping.
|
||||||
func (k Keeper) AddValidators(ctx sdk.Context, vals []abci.Validator) {
|
func (k Keeper) AddValidators(ctx sdk.Context, vals []abci.ValidatorUpdate) {
|
||||||
for i := 0; i < len(vals); i++ {
|
for i := 0; i < len(vals); i++ {
|
||||||
val := vals[i]
|
val := vals[i]
|
||||||
pubkey, err := tmtypes.PB2TM.PubKey(val.PubKey)
|
pubkey, err := tmtypes.PB2TM.PubKey(val.PubKey)
|
||||||
|
|
|
@ -20,7 +20,7 @@ func BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock, sk Keeper) (tags
|
||||||
// Iterate over all the validators which *should* have signed this block
|
// Iterate over all the validators which *should* have signed this block
|
||||||
// Store whether or not they have actually signed it and slash/unbond any
|
// Store whether or not they have actually signed it and slash/unbond any
|
||||||
// which have missed too many blocks in a row (downtime slashing)
|
// which have missed too many blocks in a row (downtime slashing)
|
||||||
for _, voteInfo := range req.LastCommitInfo.GetVoteInfos() {
|
for _, voteInfo := range req.LastCommitInfo.GetVotes() {
|
||||||
sk.handleValidatorSignature(ctx, voteInfo.Validator.Address, voteInfo.Validator.Power, voteInfo.SignedLastBlock)
|
sk.handleValidatorSignature(ctx, voteInfo.Validator.Address, voteInfo.Validator.Power, voteInfo.SignedLastBlock)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ import (
|
||||||
// addition, it also sets any delegations found in data. Finally, it updates
|
// addition, it also sets any delegations found in data. Finally, it updates
|
||||||
// the bonded validators.
|
// the bonded validators.
|
||||||
// Returns final validator set after applying all declaration and delegations
|
// Returns final validator set after applying all declaration and delegations
|
||||||
func InitGenesis(ctx sdk.Context, keeper Keeper, data types.GenesisState) (res []abci.Validator, err error) {
|
func InitGenesis(ctx sdk.Context, keeper Keeper, data types.GenesisState) (res []abci.ValidatorUpdate, err error) {
|
||||||
keeper.SetPool(ctx, data.Pool)
|
keeper.SetPool(ctx, data.Pool)
|
||||||
keeper.SetNewParams(ctx, data.Params)
|
keeper.SetNewParams(ctx, data.Params)
|
||||||
keeper.InitIntraTxCounter(ctx)
|
keeper.InitIntraTxCounter(ctx)
|
||||||
|
@ -47,9 +47,9 @@ func InitGenesis(ctx sdk.Context, keeper Keeper, data types.GenesisState) (res [
|
||||||
keeper.UpdateBondedValidatorsFull(ctx)
|
keeper.UpdateBondedValidatorsFull(ctx)
|
||||||
|
|
||||||
vals := keeper.GetValidatorsBonded(ctx)
|
vals := keeper.GetValidatorsBonded(ctx)
|
||||||
res = make([]abci.Validator, len(vals))
|
res = make([]abci.ValidatorUpdate, len(vals))
|
||||||
for i, val := range vals {
|
for i, val := range vals {
|
||||||
res[i] = sdk.ABCIValidator(val)
|
res[i] = sdk.ABCIValidatorUpdate(val)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ func NewHandler(k keeper.Keeper) sdk.Handler {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called every block, process inflation, update validator set
|
// Called every block, process inflation, update validator set
|
||||||
func EndBlocker(ctx sdk.Context, k keeper.Keeper) (ValidatorUpdates []abci.Validator) {
|
func EndBlocker(ctx sdk.Context, k keeper.Keeper) (ValidatorUpdates []abci.ValidatorUpdate) {
|
||||||
pool := k.GetPool(ctx)
|
pool := k.GetPool(ctx)
|
||||||
|
|
||||||
// Process provision inflation
|
// Process provision inflation
|
||||||
|
|
|
@ -201,13 +201,13 @@ func (k Keeper) GetValidatorsByPower(ctx sdk.Context) []types.Validator {
|
||||||
// Accumulated updates to the active/bonded validator set for tendermint
|
// Accumulated updates to the active/bonded validator set for tendermint
|
||||||
|
|
||||||
// get the most recently updated validators
|
// get the most recently updated validators
|
||||||
func (k Keeper) GetTendermintUpdates(ctx sdk.Context) (updates []abci.Validator) {
|
func (k Keeper) GetTendermintUpdates(ctx sdk.Context) (updates []abci.ValidatorUpdate) {
|
||||||
store := ctx.KVStore(k.storeKey)
|
store := ctx.KVStore(k.storeKey)
|
||||||
|
|
||||||
iterator := sdk.KVStorePrefixIterator(store, TendermintUpdatesKey) //smallest to largest
|
iterator := sdk.KVStorePrefixIterator(store, TendermintUpdatesKey) //smallest to largest
|
||||||
for ; iterator.Valid(); iterator.Next() {
|
for ; iterator.Valid(); iterator.Next() {
|
||||||
valBytes := iterator.Value()
|
valBytes := iterator.Value()
|
||||||
var val abci.Validator
|
var val abci.ValidatorUpdate
|
||||||
k.cdc.MustUnmarshalBinary(valBytes, &val)
|
k.cdc.MustUnmarshalBinary(valBytes, &val)
|
||||||
updates = append(updates, val)
|
updates = append(updates, val)
|
||||||
}
|
}
|
||||||
|
@ -256,7 +256,7 @@ func (k Keeper) UpdateValidator(ctx sdk.Context, validator types.Validator) type
|
||||||
case powerIncreasing && !validator.Jailed &&
|
case powerIncreasing && !validator.Jailed &&
|
||||||
(oldFound && oldValidator.Status == sdk.Bonded):
|
(oldFound && oldValidator.Status == sdk.Bonded):
|
||||||
|
|
||||||
bz := k.cdc.MustMarshalBinary(validator.ABCIValidator())
|
bz := k.cdc.MustMarshalBinary(sdk.ABCIValidatorUpdate(validator))
|
||||||
store.Set(GetTendermintUpdatesKey(validator.Operator), bz)
|
store.Set(GetTendermintUpdatesKey(validator.Operator), bz)
|
||||||
|
|
||||||
if cliffPower != nil {
|
if cliffPower != nil {
|
||||||
|
@ -292,7 +292,7 @@ func (k Keeper) UpdateValidator(ctx sdk.Context, validator types.Validator) type
|
||||||
|
|
||||||
// if decreased in power but still bonded, update Tendermint validator
|
// if decreased in power but still bonded, update Tendermint validator
|
||||||
if oldFound && oldValidator.BondedTokens().GT(validator.BondedTokens()) {
|
if oldFound && oldValidator.BondedTokens().GT(validator.BondedTokens()) {
|
||||||
bz := k.cdc.MustMarshalBinary(validator.ABCIValidator())
|
bz := k.cdc.MustMarshalBinary(sdk.ABCIValidatorUpdate(validator))
|
||||||
store.Set(GetTendermintUpdatesKey(validator.Operator), bz)
|
store.Set(GetTendermintUpdatesKey(validator.Operator), bz)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -634,7 +634,7 @@ func (k Keeper) beginUnbondingValidator(ctx sdk.Context, validator types.Validat
|
||||||
k.SetValidator(ctx, validator)
|
k.SetValidator(ctx, validator)
|
||||||
|
|
||||||
// add to accumulated changes for tendermint
|
// add to accumulated changes for tendermint
|
||||||
bzABCI := k.cdc.MustMarshalBinary(validator.ABCIValidatorZero())
|
bzABCI := k.cdc.MustMarshalBinary(validator.ABCIValidatorUpdateZero())
|
||||||
store.Set(GetTendermintUpdatesKey(validator.Operator), bzABCI)
|
store.Set(GetTendermintUpdatesKey(validator.Operator), bzABCI)
|
||||||
|
|
||||||
// also remove from the Bonded types.Validators Store
|
// also remove from the Bonded types.Validators Store
|
||||||
|
@ -669,7 +669,7 @@ func (k Keeper) bondValidator(ctx sdk.Context, validator types.Validator) types.
|
||||||
store.Set(GetValidatorsBondedIndexKey(validator.Operator), []byte{})
|
store.Set(GetValidatorsBondedIndexKey(validator.Operator), []byte{})
|
||||||
|
|
||||||
// add to accumulated changes for tendermint
|
// add to accumulated changes for tendermint
|
||||||
bzABCI := k.cdc.MustMarshalBinary(validator.ABCIValidator())
|
bzABCI := k.cdc.MustMarshalBinary(sdk.ABCIValidatorUpdate(validator))
|
||||||
store.Set(GetTendermintUpdatesKey(validator.Operator), bzABCI)
|
store.Set(GetTendermintUpdatesKey(validator.Operator), bzABCI)
|
||||||
|
|
||||||
// call the bond hook if present
|
// call the bond hook if present
|
||||||
|
@ -704,7 +704,7 @@ func (k Keeper) RemoveValidator(ctx sdk.Context, address sdk.ValAddress) {
|
||||||
}
|
}
|
||||||
store.Delete(GetValidatorsBondedIndexKey(validator.Operator))
|
store.Delete(GetValidatorsBondedIndexKey(validator.Operator))
|
||||||
|
|
||||||
bz := k.cdc.MustMarshalBinary(validator.ABCIValidatorZero())
|
bz := k.cdc.MustMarshalBinary(validator.ABCIValidatorUpdateZero())
|
||||||
store.Set(GetTendermintUpdatesKey(address), bz)
|
store.Set(GetTendermintUpdatesKey(address), bz)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -317,12 +317,12 @@ func (v Validator) ABCIValidator() abci.Validator {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ABCIValidatorZero returns an abci.Validator from a staked validator type
|
// ABCIValidatorUpdateZero returns an abci.ValidatorUpdate from a staked validator type
|
||||||
// with with zero power used for validator updates.
|
// with with zero power used for validator updates.
|
||||||
func (v Validator) ABCIValidatorZero() abci.Validator {
|
func (v Validator) ABCIValidatorUpdateZero() abci.ValidatorUpdate {
|
||||||
return abci.Validator{
|
return abci.ValidatorUpdate{
|
||||||
Address: v.PubKey.Address(),
|
PubKey: tmtypes.TM2PB.PubKey(v.PubKey),
|
||||||
Power: 0,
|
Power: 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue