mirror of
https://github.com/0glabs/0g-chain.git
synced 2024-11-13 03:25:20 +00:00
address some TODOs
This commit is contained in:
parent
5911e648b7
commit
029842168a
@ -19,12 +19,10 @@ type Keeper struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewKeeper(cdc *codec.Codec, storeKey sdk.StoreKey, router govtypes.Router) Keeper {
|
func NewKeeper(cdc *codec.Codec, storeKey sdk.StoreKey, router govtypes.Router) Keeper {
|
||||||
// It is vital to seal the governance proposal router here as to not allow
|
// Logic in the keeper methods assume the set of gov handlers is fixed.
|
||||||
// further handlers to be registered after the keeper is created since this
|
// So the gov router must be sealed so no handlers can be added or removed after the keeper is created.
|
||||||
// could create invalid or non-deterministic behavior.
|
// Note: for some reason the gov router panics if it has already been sealed, so a helper func is used to make sealing idempotent.
|
||||||
// TODO why?
|
sealGovRouterIdempotently(router)
|
||||||
// Not sealing the router because for some reason the function panics if it has already been sealed and there is no way to tell if has already been called.
|
|
||||||
// router.Seal()
|
|
||||||
|
|
||||||
return Keeper{
|
return Keeper{
|
||||||
cdc: cdc,
|
cdc: cdc,
|
||||||
@ -33,6 +31,13 @@ func NewKeeper(cdc *codec.Codec, storeKey sdk.StoreKey, router govtypes.Router)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func sealGovRouterIdempotently(router govtypes.Router) {
|
||||||
|
defer func() {
|
||||||
|
recover()
|
||||||
|
}()
|
||||||
|
router.Seal()
|
||||||
|
}
|
||||||
|
|
||||||
// ---------- Committees ----------
|
// ---------- Committees ----------
|
||||||
|
|
||||||
// GetCommittee gets a committee from the store.
|
// GetCommittee gets a committee from the store.
|
||||||
|
@ -22,8 +22,6 @@ func (k Keeper) SubmitProposal(ctx sdk.Context, proposer sdk.AccAddress, committ
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check proposal is valid
|
// Check proposal is valid
|
||||||
// TODO what if it's not valid now but will be in the future?
|
|
||||||
// TODO does this need to be before permission check?
|
|
||||||
if err := k.ValidatePubProposal(ctx, pubProposal); err != nil {
|
if err := k.ValidatePubProposal(ctx, pubProposal); err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
@ -92,7 +90,6 @@ func (k Keeper) CloseOutProposal(ctx sdk.Context, proposalID uint64) sdk.Error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (k Keeper) ValidatePubProposal(ctx sdk.Context, pubProposal types.PubProposal) sdk.Error {
|
func (k Keeper) ValidatePubProposal(ctx sdk.Context, pubProposal types.PubProposal) sdk.Error {
|
||||||
// TODO not sure if the basic validation is required - should be run in msg.ValidateBasic
|
|
||||||
if pubProposal == nil {
|
if pubProposal == nil {
|
||||||
return sdk.ErrInternal("proposal is empty")
|
return sdk.ErrInternal("proposal is empty")
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
package types
|
package types
|
||||||
|
|
||||||
// These msg types should be basically the same as for gov, but without deposits.
|
|
||||||
|
|
||||||
// MsgSubmitProposal is used by committee members to create a new proposal that they can vote on.
|
// MsgSubmitProposal is used by committee members to create a new proposal that they can vote on.
|
||||||
type MsgSubmitProposal struct {
|
type MsgSubmitProposal struct {
|
||||||
// TODO
|
// TODO
|
||||||
|
Loading…
Reference in New Issue
Block a user