mirror of
https://github.com/0glabs/0g-chain.git
synced 2024-12-26 00:05:18 +00:00
remove shutdown module
This commit is contained in:
parent
4298564096
commit
98a044d7af
18
app/app.go
18
app/app.go
@ -337,7 +337,6 @@ func NewApp(logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest bool,
|
|||||||
// initialize the app
|
// initialize the app
|
||||||
app.SetInitChainer(app.InitChainer)
|
app.SetInitChainer(app.InitChainer)
|
||||||
app.SetBeginBlocker(app.BeginBlocker)
|
app.SetBeginBlocker(app.BeginBlocker)
|
||||||
// TODO app.SetAnteHandler(NewAnteHandler(app.accountKeeper, app.supplyKeeper, app.shutdownKeeper, auth.DefaultSigVerificationGasConsumer))
|
|
||||||
app.SetAnteHandler(auth.NewAnteHandler(app.accountKeeper, app.supplyKeeper, auth.DefaultSigVerificationGasConsumer))
|
app.SetAnteHandler(auth.NewAnteHandler(app.accountKeeper, app.supplyKeeper, auth.DefaultSigVerificationGasConsumer))
|
||||||
app.SetEndBlocker(app.EndBlocker)
|
app.SetEndBlocker(app.EndBlocker)
|
||||||
|
|
||||||
@ -352,23 +351,6 @@ func NewApp(logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest bool,
|
|||||||
return app
|
return app
|
||||||
}
|
}
|
||||||
|
|
||||||
// func NewAnteHandler(ak auth.AccountKeeper, supplyKeeper supply.Keeper, shutdownKeeper shutdown.Keeper, sigGasConsumer SignatureVerificationGasConsumer) sdk.AnteHandler {
|
|
||||||
// return sdk.ChainAnteDecorators(
|
|
||||||
// auth.NewSetUpContextDecorator(), // outermost AnteDecorator. SetUpContext must be called first
|
|
||||||
// shutdownAnte.NewDisableMsgDecorator(shutdownKeeper),
|
|
||||||
// auth.NewMempoolFeeDecorator(),
|
|
||||||
// auth.NewValidateBasicDecorator(),
|
|
||||||
// auth.NewValidateMemoDecorator(ak),
|
|
||||||
// auth.NewConsumeGasForTxSizeDecorator(ak),
|
|
||||||
// auth.NewSetPubKeyDecorator(ak), // SetPubKeyDecorator must be called before all signature verification decorators
|
|
||||||
// auth.NewValidateSigCountDecorator(ak),
|
|
||||||
// auth.NewDeductFeeDecorator(ak, supplyKeeper),
|
|
||||||
// auth.NewSigGasConsumeDecorator(ak, sigGasConsumer),
|
|
||||||
// auth.NewSigVerificationDecorator(ak),
|
|
||||||
// auth.NewIncrementSequenceDecorator(ak), // innermost AnteDecorator
|
|
||||||
// )
|
|
||||||
// }
|
|
||||||
|
|
||||||
// custom tx codec
|
// custom tx codec
|
||||||
func MakeCodec() *codec.Codec {
|
func MakeCodec() *codec.Codec {
|
||||||
var cdc = codec.New()
|
var cdc = codec.New()
|
||||||
|
@ -1,35 +0,0 @@
|
|||||||
package ante
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"github.com/kava-labs/kava/x/shutdown/keeper"
|
|
||||||
|
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
||||||
)
|
|
||||||
|
|
||||||
// DisableMsgDecorator errors if a tx contains a disallowed msg type and calls the next AnteHandler if all msgs are allowed
|
|
||||||
type DisableMsgDecorator struct {
|
|
||||||
shutdownKeeper keeper.Keeper
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewDisableMsgDecorator(shutdownKeeper keeper.Keeper) DisableMsgDecorator {
|
|
||||||
return DisableMsgDecorator{
|
|
||||||
shutdownKeeper: shutdownKeeper,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (dmd DisableMsgDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err error) {
|
|
||||||
|
|
||||||
// get msg route, error if not allowed
|
|
||||||
disallowedRoutes := dmd.shutdownKeeper.GetMsgRoutes(ctx)
|
|
||||||
for _, m := range tx.GetMsgs() {
|
|
||||||
for _, r := range disallowedRoutes {
|
|
||||||
if r.Route == m.Route() && r.Msg == m.Type() {
|
|
||||||
return ctx, fmt.Errorf("route %s has been disabled, tx rejected", r)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// otherwise continue to next antehandler decorator
|
|
||||||
return next(ctx, tx, simulate)
|
|
||||||
}
|
|
@ -1,19 +0,0 @@
|
|||||||
package keeper
|
|
||||||
|
|
||||||
import (
|
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
||||||
"github.com/kava-labs/kava/x/shutdown/types"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Keeper stores routes that have been "broken"
|
|
||||||
type Keeper struct {
|
|
||||||
}
|
|
||||||
|
|
||||||
func (k Keeper) GetMsgRoutes(ctx sdk.Context) []types.MsgRoute {
|
|
||||||
// TODO
|
|
||||||
return []types.MsgRoute{}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (k Keeper) SetMsgRoutes(ctx sdk.Context, routes []types.MsgRoute) {
|
|
||||||
// TODO
|
|
||||||
}
|
|
@ -1,30 +0,0 @@
|
|||||||
package shutdown
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
||||||
"github.com/cosmos/cosmos-sdk/x/gov"
|
|
||||||
|
|
||||||
"github.com/kava-labs/kava/x/shutdown/keeper"
|
|
||||||
"github.com/kava-labs/kava/x/shutdown/types"
|
|
||||||
)
|
|
||||||
|
|
||||||
func NewShutdownProposalHandler(k keeper.Keeper) gov.Handler {
|
|
||||||
return func(ctx sdk.Context, content gov.Content) sdk.Error {
|
|
||||||
switch c := content.(type) {
|
|
||||||
case types.ShutdownProposal:
|
|
||||||
return handleShutdownProposal(ctx, k, c)
|
|
||||||
|
|
||||||
default:
|
|
||||||
errMsg := fmt.Sprintf("unrecognized %s proposal content type: %T", types.ModuleName, c)
|
|
||||||
return sdk.ErrUnknownRequest(errMsg)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func handleShutdownProposal(ctx sdk.Context, k keeper.Keeper, c types.ShutdownProposal) sdk.Error {
|
|
||||||
// TODO validate proposal
|
|
||||||
k.SetMsgRoutes(ctx, c.MsgRoutes)
|
|
||||||
return nil
|
|
||||||
}
|
|
@ -1,18 +0,0 @@
|
|||||||
|
|
||||||
# `shutdown`
|
|
||||||
|
|
||||||
## Table of Contents
|
|
||||||
|
|
||||||
## Overview
|
|
||||||
|
|
||||||
The `x/shutdown` module allows certain message types to be disabled based on governance votes.
|
|
||||||
|
|
||||||
Msgs and routes are disabled via an antehandler decorator. The decorator checks incoming all txs and rejects them if they contain a disallowed msg type.
|
|
||||||
Disallowed msg types are stored in a circuit breaker keeper.
|
|
||||||
|
|
||||||
The list of disallowed msg types is updated via a custom governance proposal and handler.
|
|
||||||
|
|
||||||
Design Alternatives:
|
|
||||||
|
|
||||||
- store list of disallowed msg types in params, then we don't need the custom gov proposal
|
|
||||||
- replace the app Router with a custom one to avoid using the antehandler - can't be done with current baseapp, but v0.38.x enables this. (https://github.com/cosmos/cosmos-sdk/issues/5455)
|
|
@ -1,62 +0,0 @@
|
|||||||
package types
|
|
||||||
|
|
||||||
import (
|
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
||||||
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
|
|
||||||
)
|
|
||||||
|
|
||||||
type MsgRoute struct {
|
|
||||||
Route string
|
|
||||||
Msg string // how best to store a Msg type?
|
|
||||||
}
|
|
||||||
|
|
||||||
const (
|
|
||||||
ProposalTypeShutdown = "Shutdown"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Assert ShutdownProposal implements govtypes.Content at compile-time
|
|
||||||
var _ govtypes.Content = ShutdownProposal{}
|
|
||||||
|
|
||||||
type ShutdownProposal struct {
|
|
||||||
Title string
|
|
||||||
Description string
|
|
||||||
MsgRoutes []MsgRoute
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetTitle returns the title of a community pool spend proposal.
|
|
||||||
func (sp ShutdownProposal) GetTitle() string { return sp.Title }
|
|
||||||
|
|
||||||
// GetDescription returns the description of a community pool spend proposal.
|
|
||||||
func (sp ShutdownProposal) GetDescription() string { return sp.Description }
|
|
||||||
|
|
||||||
// GetDescription returns the routing key of a community pool spend proposal.
|
|
||||||
func (sp ShutdownProposal) ProposalRoute() string { return RouterKey }
|
|
||||||
|
|
||||||
// ProposalType returns the type of a community pool spend proposal.
|
|
||||||
func (sp ShutdownProposal) ProposalType() string { return ProposalTypeShutdown }
|
|
||||||
|
|
||||||
// ValidateBasic runs basic stateless validity checks
|
|
||||||
func (sp ShutdownProposal) ValidateBasic() sdk.Error {
|
|
||||||
err := govtypes.ValidateAbstract(DefaultCodespace, sp)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
// TODO
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// String implements the Stringer interface.
|
|
||||||
func (sp ShutdownProposal) String() string {
|
|
||||||
// TODO
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
const (
|
|
||||||
DefaultCodespace sdk.CodespaceType = ModuleName
|
|
||||||
|
|
||||||
// ModuleName is the module name constant used in many places
|
|
||||||
ModuleName = "shutdown"
|
|
||||||
|
|
||||||
// RouterKey is the message route for distribution
|
|
||||||
RouterKey = ModuleName
|
|
||||||
)
|
|
Loading…
Reference in New Issue
Block a user