Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Gate-keeping validator set from validators without required public keys #431

Merged
merged 7 commits into from
Dec 9, 2024
23 changes: 14 additions & 9 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ import (
"github.com/sedaprotocol/seda-chain/app/utils"
// Used in cosmos-sdk when registering the route for swagger docs.
_ "github.com/sedaprotocol/seda-chain/client/docs/statik"
"github.com/sedaprotocol/seda-chain/cmd/sedad/gentx"
"github.com/sedaprotocol/seda-chain/x/batching"
batchingkeeper "github.com/sedaprotocol/seda-chain/x/batching/keeper"
batchingtypes "github.com/sedaprotocol/seda-chain/x/batching/types"
Expand Down Expand Up @@ -170,7 +171,7 @@ var (
// non-dependant module elements, such as codec registration
// and genesis verification.
ModuleBasics = module.NewBasicManager(
genutil.NewAppModuleBasic(genutiltypes.DefaultMessageValidator),
genutil.NewAppModuleBasic(gentx.GenTxValidator),
auth.AppModuleBasic{},
authzmodule.AppModuleBasic{},
vesting.AppModuleBasic{},
Expand Down Expand Up @@ -259,7 +260,7 @@ type App struct {
WasmStorageKeeper wasmstoragekeeper.Keeper
TallyKeeper tallykeeper.Keeper
DataProxyKeeper dataproxykeeper.Keeper
PubKeyKeeper pubkeykeeper.Keeper
PubKeyKeeper *pubkeykeeper.Keeper
BatchingKeeper batchingkeeper.Keeper

// App-level pre-blocker (Note this cannot change consensus parameters)
Expand Down Expand Up @@ -425,7 +426,10 @@ func NewApp(
authcodec.NewBech32Codec(sdk.GetConfig().GetBech32ValidatorAddrPrefix()),
authcodec.NewBech32Codec(sdk.GetConfig().GetBech32ConsensusAddrPrefix()),
)
app.StakingKeeper = stakingkeeper.NewKeeper(sdkStakingKeeper)
app.StakingKeeper = stakingkeeper.NewKeeper(
sdkStakingKeeper,
authcodec.NewBech32Codec(sdk.GetConfig().GetBech32ValidatorAddrPrefix()),
)

app.FeeGrantKeeper = feegrantkeeper.NewKeeper(
appCodec,
Expand Down Expand Up @@ -647,14 +651,15 @@ func NewApp(
app.WasmKeeper,
)

app.PubKeyKeeper = *pubkeykeeper.NewKeeper(
app.PubKeyKeeper = pubkeykeeper.NewKeeper(
appCodec,
runtime.NewKVStoreService(keys[pubkeytypes.StoreKey]),
app.StakingKeeper,
app.SlashingKeeper,
authcodec.NewBech32Codec(sdk.GetConfig().GetBech32ValidatorAddrPrefix()),
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)
app.StakingKeeper.SetPubKeyKeeper(app.PubKeyKeeper)

app.DataProxyKeeper = *dataproxykeeper.NewKeeper(
appCodec,
Expand Down Expand Up @@ -781,7 +786,7 @@ func NewApp(
mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper, nil, nil),
slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper, nil, app.interfaceRegistry),
distr.NewAppModule(appCodec, app.DistrKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper, nil),
staking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper, nil),
staking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper, app.PubKeyKeeper),
upgrade.NewAppModule(app.UpgradeKeeper, app.AccountKeeper.AddressCodec()),
evidence.NewAppModule(app.EvidenceKeeper),
consensus.NewAppModule(appCodec, app.ConsensusParamsKeeper),
Expand Down Expand Up @@ -809,7 +814,7 @@ func NewApp(
app.bmm = module.NewBasicManagerFromManager(
app.mm,
map[string]module.AppModuleBasic{
genutiltypes.ModuleName: genutil.NewAppModuleBasic(genutiltypes.DefaultMessageValidator),
genutiltypes.ModuleName: genutil.NewAppModuleBasic(gentx.GenTxValidator),
govtypes.ModuleName: gov.NewAppModuleBasic(
[]govclient.ProposalHandler{
// paramsclient.ProposalHandler,
Expand Down Expand Up @@ -907,8 +912,9 @@ func NewApp(
slashingtypes.ModuleName,
govtypes.ModuleName,
minttypes.ModuleName,
crisistypes.ModuleName,
pubkeytypes.ModuleName, // pubkey before genutil
genutiltypes.ModuleName,
crisistypes.ModuleName,
evidencetypes.ModuleName,
authz.ModuleName,
feegrant.ModuleName,
Expand All @@ -924,11 +930,10 @@ func NewApp(
ibcfeetypes.ModuleName,
wasmtypes.ModuleName, // wasm after ibc transfer
packetforwardtypes.ModuleName,
// custom modules
// custom modules (except pubkey)
wasmstoragetypes.ModuleName,
tallytypes.ModuleName,
dataproxytypes.ModuleName,
pubkeytypes.ModuleName,
batchingtypes.ModuleName,
}
app.mm.SetOrderInitGenesis(genesisModuleOrder...)
Expand Down
5 changes: 3 additions & 2 deletions cmd/sedad/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ import (
"github.com/sedaprotocol/seda-chain/app"
appparams "github.com/sedaprotocol/seda-chain/app/params"
_ "github.com/sedaprotocol/seda-chain/client/docs/statik" // for swagger docs
"github.com/sedaprotocol/seda-chain/cmd/sedad/gentx"
)

// NewRootCmd creates a new root command for a Cosmos SDK application
Expand Down Expand Up @@ -187,13 +188,13 @@ func initRootCmd(rootCmd *cobra.Command, encodingConfig app.EncodingConfig, basi
rootCmd.AddCommand(
genutilcli.InitCmd(basicManager, app.DefaultNodeHome),
JoinNetworkCommand(basicManager, app.DefaultNodeHome),
genutilcli.CollectGenTxsCmd(
gentx.CollectGenTxsCmd(
banktypes.GenesisBalancesIterator{},
app.DefaultNodeHome,
gentxModule.GenTxValidator,
encodingConfig.InterfaceRegistry.SigningContext().ValidatorAddressCodec(),
),
genutilcli.GenTxCmd(
gentx.GenTxCmd(
basicManager,
encodingConfig.TxConfig,
banktypes.GenesisBalancesIterator{},
Expand Down
4 changes: 2 additions & 2 deletions cmd/sedad/gentx/collect_gentxs.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ func GenAppStateFromConfig(cdc codec.JSONCodec, txEncodingConfig client.TxEncodi
}

// CollectTxs processes and validates application's genesis Txs of type
// MsgCreateValidatorWithVRF and returns the list of appGenTxs and
// MsgCreateSEDAValidator and returns the list of appGenTxs and
// persistent peers required to generate genesis.json.
func CollectTxs(cdc codec.JSONCodec, txJSONDecoder sdk.TxDecoder, moniker, genTxsDir string,
genesis *types.AppGenesis, genBalIterator types.GenesisBalancesIterator,
Expand Down Expand Up @@ -188,7 +188,7 @@ func CollectTxs(cdc codec.JSONCodec, txJSONDecoder sdk.TxDecoder, moniker, genTx

// genesis transactions must be single-message
msgs := genTx.GetMsgs()
msg := msgs[0].(*stakingtypes.MsgCreateValidatorWithVRF)
msg := msgs[0].(*stakingtypes.MsgCreateSEDAValidator)

// validate validator addresses and funds against the accounts in the state
valAddr, err := valAddrCodec.StringToBytes(msg.ValidatorAddress)
Expand Down
Loading
Loading