Use any as validator pubkey (#7597)
* protobuf pubkey type update * wip2 * wip3 * solving types.NewValidator issues * remove bech32 from validator type assignment * update Validator interface * Changelog update * wip4 * update genutil * fix simapp & x/ibc/testing tests * update staking * changelog update * fix import cycle in tests * fix amino panic on TestValidatorMarshalUnmarshalJSON * fix TestValidatorMarshalUnmarshalJSON consensus_pubkey check * Add UnpackInterfaces to HistoricalInfo * fix TestHistoricalInfo * update todos * fix: Expecting ed25519.PubKey to implement proto.Message * fix linter issues * Fix migrate test * Update CHANGELOG.md Co-authored-by: Marie Gauthier <marie.gauthier63@gmail.com> * review comments * cosmetic changes * add UnpackInterfaces got GenesisRandomized test * Validator.Equal reuses Validator.MinEqual * fix test * use Validator.Equal in tests * Fix staking simulation TestRandomizedGenState * Remove TODO * use HistoricalInfo.Equal * use proto.Equal * rename Validator.GetConsPubKey to TmConsPubKey * prefer require.Equal over reflect.DeepEqual * SetHistoricalInfo using a pointer * Fix TestQueryDelegation test * Fix TestQueryValidators test * Fix TestSimulateMsgUnjail test * experiement with LegacyAmino instances * Register codecs in all simapp tests * Fix cli_test compilation problems * fix typo sdk -> std * fix typo * fix TestPlanStringer * Rename to MakeEncodingConfig * Remove RegisterCodecsTests * Use gRPC in GetCmdQueryValidators * Empty status * fix info log check * linter fixes * rename simapparams to simappparams * Update simapp/test_helpers.go Co-authored-by: Marie Gauthier <marie.gauthier63@gmail.com> * comments updates * use valAddr1 instead of sdk.ValAddress(pk1.Address().Bytes()) Co-authored-by: Cory Levinson <cjlevinson@gmail.com> Co-authored-by: Amaury Martiny <amaury.martiny@protonmail.com> Co-authored-by: Marie Gauthier <marie.gauthier63@gmail.com>
This commit is contained in:
co-authored by
Marie Gauthier
Cory Levinson
Amaury Martiny
parent
5bebf2bd39
commit
6bc8ff2dfe
@@ -9,7 +9,7 @@ import (
|
||||
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
|
||||
"github.com/tendermint/tendermint/types"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/simapp/params"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/types/simulation"
|
||||
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
|
||||
)
|
||||
@@ -153,19 +153,15 @@ func (w WeightedProposalContent) ContentSimulatorFn() simulation.ContentSimulato
|
||||
//-----------------------------------------------------------------------------
|
||||
// Param change proposals
|
||||
|
||||
// RandomParams returns random simulation consensus parameters, it extracts the Evidence from the Staking genesis state.
|
||||
func RandomConsensusParams(r *rand.Rand, appState json.RawMessage) *abci.ConsensusParams {
|
||||
cdc := params.MakeEncodingConfig().Marshaler
|
||||
|
||||
// randomConsensusParams returns random simulation consensus parameters, it extracts the Evidence from the Staking genesis state.
|
||||
func randomConsensusParams(r *rand.Rand, appState json.RawMessage, cdc codec.JSONMarshaler) *abci.ConsensusParams {
|
||||
var genesisState map[string]json.RawMessage
|
||||
|
||||
err := json.Unmarshal(appState, &genesisState)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
stakingGenesisState := stakingtypes.GetGenesisStateFromAppState(cdc, genesisState)
|
||||
|
||||
consensusParams := &abci.ConsensusParams{
|
||||
Block: &abci.BlockParams{
|
||||
MaxBytes: int64(simulation.RandIntBetween(r, 20000000, 30000000)),
|
||||
|
||||
@@ -14,6 +14,7 @@ import (
|
||||
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/baseapp"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/simulation"
|
||||
)
|
||||
@@ -23,11 +24,11 @@ const AverageBlockTime = 6 * time.Second
|
||||
// initialize the chain for the simulation
|
||||
func initChain(
|
||||
r *rand.Rand, params Params, accounts []simulation.Account, app *baseapp.BaseApp,
|
||||
appStateFn simulation.AppStateFn, config simulation.Config,
|
||||
appStateFn simulation.AppStateFn, config simulation.Config, cdc codec.JSONMarshaler,
|
||||
) (mockValidators, time.Time, []simulation.Account, string) {
|
||||
appState, accounts, chainID, genesisTimestamp := appStateFn(r, accounts, config)
|
||||
|
||||
consensusParams := RandomConsensusParams(r, appState)
|
||||
consensusParams := randomConsensusParams(r, appState, cdc)
|
||||
|
||||
req := abci.RequestInitChain{
|
||||
AppStateBytes: appState,
|
||||
@@ -52,6 +53,7 @@ func SimulateFromSeed(
|
||||
ops WeightedOperations,
|
||||
blockedAddrs map[string]bool,
|
||||
config simulation.Config,
|
||||
cdc codec.JSONMarshaler,
|
||||
) (stopEarly bool, exportedParams Params, err error) {
|
||||
// in case we have to end early, don't os.Exit so that we can run cleanup code.
|
||||
testingMode, _, b := getTestingMode(tb)
|
||||
@@ -67,7 +69,7 @@ func SimulateFromSeed(
|
||||
|
||||
// Second variable to keep pending validator set (delayed one block since
|
||||
// TM 0.24) Initially this is the same as the initial validator set
|
||||
validators, genesisTimestamp, accs, chainID := initChain(r, params, accs, app, appStateFn, config)
|
||||
validators, genesisTimestamp, accs, chainID := initChain(r, params, accs, app, appStateFn, config, cdc)
|
||||
if len(accs) == 0 {
|
||||
return true, params, fmt.Errorf("must have greater than zero genesis accounts")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user