Skip to content

Commit

Permalink
Merge pull request #5 from initia-labs/feat/cosmos-50
Browse files Browse the repository at this point in the history
feat: cosmos-50
  • Loading branch information
beer-1 authored Jan 18, 2024
2 parents 4f64dd3 + 08ac91c commit da7cac5
Show file tree
Hide file tree
Showing 30 changed files with 2,623 additions and 1,081 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
steps:
- uses: actions/[email protected]
with:
go-version: 1.19
go-version: 1.21
- uses: technote-space/get-diff-action@v5
id: git_diff
with:
Expand Down Expand Up @@ -64,7 +64,7 @@ jobs:
- name: Setup go
uses: actions/setup-go@v3
with:
go-version: 1.19
go-version: 1.21
# for private repo access
- run: git config --global url.https://${GITHUB_ACCESS_TOKEN}:[email protected]/.insteadOf https://github.com/
- run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
steps:
- uses: actions/setup-go@v3
with:
go-version: 1.19
go-version: 1.21
- name: Install openssl
run: sudo apt-get install libssl-dev
- uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.19.1-alpine3.16 AS go-builder
FROM golang:1.21-alpine AS go-builder
#ARG arch=x86_64

# See https://github.com/CosmWasm/wasmvm/releases
Expand Down
36 changes: 20 additions & 16 deletions app/ante/ante.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package ante

import (
"cosmossdk.io/errors"
corestoretypes "cosmossdk.io/core/store"
errorsmod "cosmossdk.io/errors"
"github.com/cosmos/cosmos-sdk/codec"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/x/auth/ante"
ibcante "github.com/cosmos/ibc-go/v7/modules/core/ante"
ibckeeper "github.com/cosmos/ibc-go/v7/modules/core/keeper"
ibcante "github.com/cosmos/ibc-go/v8/modules/core/ante"
ibckeeper "github.com/cosmos/ibc-go/v8/modules/core/keeper"

opchildante "github.com/initia-labs/OPinit/x/opchild/ante"
opchildtypes "github.com/initia-labs/OPinit/x/opchild/types"
Expand All @@ -27,40 +27,44 @@ type HandlerOptions struct {
ante.HandlerOptions
Codec codec.BinaryCodec
IBCkeeper *ibckeeper.Keeper
RollupKeeper opchildtypes.AnteKeeper
OPChildKeeper opchildtypes.AnteKeeper
AuctionKeeper auctionkeeper.Keeper
TxEncoder sdk.TxEncoder
MevLane auctionante.MEVLane
FreeLane block.Lane

// wasm ante options
WasmKeeper *wasmkeeper.Keeper
WasmConfig *wasmtypes.WasmConfig
TXCounterStoreKey storetypes.StoreKey
WasmKeeper *wasmkeeper.Keeper
WasmConfig *wasmtypes.WasmConfig
TXCounterStoreService corestoretypes.KVStoreService
}

// NewAnteHandler returns an AnteHandler that checks and increments sequence
// numbers, checks signatures & account numbers, and deducts fees from the first
// signer.
func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) {
if options.AccountKeeper == nil {
return nil, errors.Wrap(sdkerrors.ErrLogic, "account keeper is required for ante builder")
return nil, errorsmod.Wrap(sdkerrors.ErrLogic, "account keeper is required for ante builder")
}

if options.BankKeeper == nil {
return nil, errors.Wrap(sdkerrors.ErrLogic, "bank keeper is required for ante builder")
return nil, errorsmod.Wrap(sdkerrors.ErrLogic, "bank keeper is required for ante builder")
}

if options.SignModeHandler == nil {
return nil, errors.Wrap(sdkerrors.ErrLogic, "sign mode handler is required for ante builder")
return nil, errorsmod.Wrap(sdkerrors.ErrLogic, "sign mode handler is required for ante builder")
}

if options.WasmConfig == nil {
return nil, errors.Wrap(sdkerrors.ErrLogic, "wasm config is required for ante builder")
return nil, errorsmod.Wrap(sdkerrors.ErrLogic, "wasm config is required for ante builder")
}

if options.WasmKeeper == nil {
return nil, errors.Wrap(sdkerrors.ErrLogic, "wasm keeper is required for ante builder")
return nil, errorsmod.Wrap(sdkerrors.ErrLogic, "wasm keeper is required for ante builder")
}

if options.TXCounterStoreService == nil {
return nil, errorsmod.Wrap(sdkerrors.ErrLogic, "wasm store service is required for ante builder")
}

sigGasConsumer := options.SigGasConsumer
Expand All @@ -70,7 +74,7 @@ func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) {

txFeeChecker := options.TxFeeChecker
if txFeeChecker == nil {
txFeeChecker = opchildante.NewMempoolFeeChecker(options.RollupKeeper).CheckTxFeeWithMinGasPrices
txFeeChecker = opchildante.NewMempoolFeeChecker(options.OPChildKeeper).CheckTxFeeWithMinGasPrices
}

freeLaneFeeChecker := func(ctx sdk.Context, tx sdk.Tx) (sdk.Coins, int64, error) {
Expand All @@ -82,7 +86,7 @@ func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) {
// return fee without fee check
feeTx, ok := tx.(sdk.FeeTx)
if !ok {
return nil, 0, errors.Wrap(sdkerrors.ErrTxDecode, "Tx must be a FeeTx")
return nil, 0, errorsmod.Wrap(sdkerrors.ErrTxDecode, "Tx must be a FeeTx")
}

return feeTx.GetFee(), 1 /* FIFO */, nil
Expand All @@ -93,7 +97,7 @@ func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) {
ante.NewExtensionOptionsDecorator(options.ExtensionOptionChecker),
// NOTE - WASM simulation gas limit can affect other module messages.
wasmkeeper.NewLimitSimulationGasDecorator(options.WasmConfig.SimulationGasLimit),
wasmkeeper.NewCountTXDecorator(options.TXCounterStoreKey),
wasmkeeper.NewCountTXDecorator(options.TXCounterStoreService),
wasmkeeper.NewGasRegisterDecorator(options.WasmKeeper.GetGasRegister()),
ante.NewValidateBasicDecorator(),
ante.NewTxTimeoutHeightDecorator(),
Expand Down
Loading

0 comments on commit da7cac5

Please sign in to comment.