Skip to content

Commit

Permalink
Make Stride a consumer chain (#811)
Browse files Browse the repository at this point in the history
Co-authored-by: stana-ethernal <[email protected]>
Co-authored-by: jstr1121 <[email protected]>
Co-authored-by: jstr1121 <[email protected]>
Co-authored-by: Aidan Salzmann <[email protected]>
Co-authored-by: Son Trinh <[email protected]>
Co-authored-by: Jacob Gadikian <[email protected]>
Co-authored-by: sampocs <[email protected]>
Co-authored-by: sampocs <[email protected]>
Co-authored-by: strbrian <[email protected]>
  • Loading branch information
10 people authored Jul 15, 2023
1 parent 4db410e commit b4abd61
Show file tree
Hide file tree
Showing 440 changed files with 2,909 additions and 1,038 deletions.
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[submodule "deps/hermes"]
# Commit: fd92eb6d17342bc83003f2067d6a9cd8261f2884
# Commit: v1.5.1
path = deps/hermes
url = https://github.com/informalsystems/ibc-rs.git
[submodule "deps/relayer"]
Expand Down
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ upgrade-build-old-binary:
@DOCKERNET_HOME=$(DOCKERNET_HOME) BUILDDIR=$(BUILDDIR) bash $(DOCKERNET_HOME)/upgrades/build_old_binary.sh

submit-upgrade-immediately:
UPGRADE_HEIGHT=100 bash $(DOCKERNET_HOME)/upgrades/submit_upgrade.sh
UPGRADE_HEIGHT=150 bash $(DOCKERNET_HOME)/upgrades/submit_upgrade.sh

submit-upgrade-after-tests:
UPGRADE_HEIGHT=400 bash $(DOCKERNET_HOME)/upgrades/submit_upgrade.sh
Expand All @@ -145,6 +145,9 @@ finish-upgrade-integration-tests:

upgrade-integration-tests-part-1: start-docker-all start-upgrade-integration-tests submit-upgrade-after-tests

setup-ics:
UPGRADE_HEIGHT=150 bash $(DOCKERNET_HOME)/upgrades/setup_ics.sh

###############################################################################
### Local to Mainnet ###
###############################################################################
Expand Down
60 changes: 60 additions & 0 deletions app/ante_handler.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package app

import (
errorsmod "cosmossdk.io/errors"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/x/auth/ante"
ibckeeper "github.com/cosmos/ibc-go/v7/modules/core/keeper"
democracyante "github.com/cosmos/interchain-security/v3/app/consumer-democracy/ante"
consumerante "github.com/cosmos/interchain-security/v3/app/consumer/ante"
ccvconsumerkeeper "github.com/cosmos/interchain-security/v3/x/ccv/consumer/keeper"
)

// HandlerOptions extend the SDK's AnteHandler options by requiring the IBC
// channel keeper.
type HandlerOptions struct {
ante.HandlerOptions

IBCKeeper *ibckeeper.Keeper
ConsumerKeeper ccvconsumerkeeper.Keeper
}

func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) {
if options.AccountKeeper == nil {
return nil, errorsmod.Wrap(sdkerrors.ErrLogic, "account keeper is required for AnteHandler")
}
if options.BankKeeper == nil {
return nil, errorsmod.Wrap(sdkerrors.ErrLogic, "bank keeper is required for AnteHandler")
}
if options.SignModeHandler == nil {
return nil, errorsmod.Wrap(sdkerrors.ErrLogic, "sign mode handler is required for ante builder")
}

var sigGasConsumer = options.SigGasConsumer
if sigGasConsumer == nil {
sigGasConsumer = ante.DefaultSigVerificationGasConsumer
}

anteDecorators := []sdk.AnteDecorator{
ante.NewSetUpContextDecorator(),
ante.NewExtensionOptionsDecorator(options.ExtensionOptionChecker),
// temporarily disabled so that chain can be tested locally without the provider chain running
consumerante.NewDisabledModulesDecorator("/cosmos.evidence", "/cosmos.slashing"),
democracyante.NewForbiddenProposalsDecorator(IsProposalWhitelisted, IsModuleWhiteList),
// ante.NewMempoolFeeDecorator(),
ante.NewValidateBasicDecorator(),
ante.NewTxTimeoutHeightDecorator(),
ante.NewValidateMemoDecorator(options.AccountKeeper),
ante.NewConsumeGasForTxSizeDecorator(options.AccountKeeper),
ante.NewDeductFeeDecorator(options.AccountKeeper, options.BankKeeper, options.FeegrantKeeper, options.TxFeeChecker),
// SetPubKeyDecorator must be called before all signature verification decorators
ante.NewSetPubKeyDecorator(options.AccountKeeper),
ante.NewValidateSigCountDecorator(options.AccountKeeper),
ante.NewSigGasConsumeDecorator(options.AccountKeeper, sigGasConsumer),
ante.NewSigVerificationDecorator(options.AccountKeeper, options.SignModeHandler),
ante.NewIncrementSequenceDecorator(options.AccountKeeper),
}

return sdk.ChainAnteDecorators(anteDecorators...), nil
}
Loading

0 comments on commit b4abd61

Please sign in to comment.