Skip to content

Commit 266f811

Browse files
committed
Init
1 parent 72bbc38 commit 266f811

File tree

10 files changed

+2529
-853
lines changed

10 files changed

+2529
-853
lines changed

app/ante.go

Lines changed: 34 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
package app
22

33
import (
4+
"errors"
5+
6+
ibcante "github.com/cosmos/ibc-go/v10/modules/core/ante"
7+
"github.com/cosmos/ibc-go/v10/modules/core/keeper"
8+
9+
corestoretypes "cosmossdk.io/core/store"
10+
circuitante "cosmossdk.io/x/circuit/ante"
11+
circuitkeeper "cosmossdk.io/x/circuit/keeper"
12+
413
sdk "github.com/cosmos/cosmos-sdk/types"
5-
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
614
"github.com/cosmos/cosmos-sdk/x/auth/ante"
7-
ibcante "github.com/cosmos/ibc-go/v3/modules/core/ante"
8-
ibckeeper "github.com/cosmos/ibc-go/v3/modules/core/keeper"
915

1016
wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
1117
wasmTypes "github.com/CosmWasm/wasmd/x/wasm/types"
@@ -16,51 +22,53 @@ import (
1622
type HandlerOptions struct {
1723
ante.HandlerOptions
1824

19-
IBCKeeper *ibckeeper.Keeper
20-
WasmConfig *wasmTypes.WasmConfig
21-
TXCounterStoreKey sdk.StoreKey
25+
IBCKeeper *keeper.Keeper
26+
NodeConfig *wasmTypes.NodeConfig
27+
WasmKeeper *wasmkeeper.Keeper
28+
TXCounterStoreService corestoretypes.KVStoreService
29+
CircuitKeeper *circuitkeeper.Keeper
2230
}
2331

32+
// NewAnteHandler constructor
2433
func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) {
2534
if options.AccountKeeper == nil {
26-
return nil, sdkerrors.Wrap(sdkerrors.ErrLogic, "account keeper is required for AnteHandler")
35+
return nil, errors.New("account keeper is required for ante builder")
2736
}
2837
if options.BankKeeper == nil {
29-
return nil, sdkerrors.Wrap(sdkerrors.ErrLogic, "bank keeper is required for AnteHandler")
38+
return nil, errors.New("bank keeper is required for ante builder")
3039
}
3140
if options.SignModeHandler == nil {
32-
return nil, sdkerrors.Wrap(sdkerrors.ErrLogic, "sign mode handler is required for ante builder")
41+
return nil, errors.New("sign mode handler is required for ante builder")
3342
}
34-
if options.WasmConfig == nil {
35-
return nil, sdkerrors.Wrap(sdkerrors.ErrLogic, "wasm config is required for ante builder")
43+
if options.NodeConfig == nil {
44+
return nil, errors.New("wasm config is required for ante builder")
3645
}
37-
if options.TXCounterStoreKey == nil {
38-
return nil, sdkerrors.Wrap(sdkerrors.ErrLogic, "tx counter key is required for ante builder")
46+
if options.TXCounterStoreService == nil {
47+
return nil, errors.New("wasm store service is required for ante builder")
3948
}
40-
41-
var sigGasConsumer = options.SigGasConsumer
42-
if sigGasConsumer == nil {
43-
sigGasConsumer = ante.DefaultSigVerificationGasConsumer
49+
if options.CircuitKeeper == nil {
50+
return nil, errors.New("circuit keeper is required for ante builder")
4451
}
4552

4653
anteDecorators := []sdk.AnteDecorator{
4754
ante.NewSetUpContextDecorator(), // outermost AnteDecorator. SetUpContext must be called first
48-
wasmkeeper.NewLimitSimulationGasDecorator(options.WasmConfig.SimulationGasLimit), // after setup context to enforce limits early
49-
wasmkeeper.NewCountTXDecorator(options.TXCounterStoreKey),
50-
ante.NewRejectExtensionOptionsDecorator(),
51-
ante.NewMempoolFeeDecorator(),
55+
wasmkeeper.NewLimitSimulationGasDecorator(options.NodeConfig.SimulationGasLimit), // after setup context to enforce limits early
56+
wasmkeeper.NewCountTXDecorator(options.TXCounterStoreService),
57+
wasmkeeper.NewGasRegisterDecorator(options.WasmKeeper.GetGasRegister()),
58+
wasmkeeper.NewTxContractsDecorator(),
59+
circuitante.NewCircuitBreakerDecorator(options.CircuitKeeper),
60+
ante.NewExtensionOptionsDecorator(options.ExtensionOptionChecker),
5261
ante.NewValidateBasicDecorator(),
5362
ante.NewTxTimeoutHeightDecorator(),
5463
ante.NewValidateMemoDecorator(options.AccountKeeper),
5564
ante.NewConsumeGasForTxSizeDecorator(options.AccountKeeper),
56-
ante.NewDeductFeeDecorator(options.AccountKeeper, options.BankKeeper, options.FeegrantKeeper),
57-
// SetPubKeyDecorator must be called before all signature verification decorators
58-
ante.NewSetPubKeyDecorator(options.AccountKeeper),
65+
ante.NewDeductFeeDecorator(options.AccountKeeper, options.BankKeeper, options.FeegrantKeeper, options.TxFeeChecker),
66+
ante.NewSetPubKeyDecorator(options.AccountKeeper), // SetPubKeyDecorator must be called before all signature verification decorators
5967
ante.NewValidateSigCountDecorator(options.AccountKeeper),
60-
ante.NewSigGasConsumeDecorator(options.AccountKeeper, sigGasConsumer),
68+
ante.NewSigGasConsumeDecorator(options.AccountKeeper, options.SigGasConsumer),
6169
ante.NewSigVerificationDecorator(options.AccountKeeper, options.SignModeHandler),
6270
ante.NewIncrementSequenceDecorator(options.AccountKeeper),
63-
ibcante.NewAnteDecorator(options.IBCKeeper),
71+
ibcante.NewRedundantRelayDecorator(options.IBCKeeper),
6472
}
6573

6674
return sdk.ChainAnteDecorators(anteDecorators...), nil

0 commit comments

Comments
 (0)