From 48b44e2966902c2e26284f4f51ddcae4adf02db6 Mon Sep 17 00:00:00 2001 From: beer-1 <147697694+beer-1@users.noreply.github.com> Date: Thu, 18 Jul 2024 13:52:35 +0900 Subject: [PATCH] use initia ante (#54) --- README.md | 1 - app/ante/account_number.go | 48 -------------------------------------- app/ante/ante.go | 3 ++- go.mod | 2 +- go.sum | 4 ++-- 5 files changed, 5 insertions(+), 53 deletions(-) delete mode 100644 app/ante/account_number.go diff --git a/README.md b/README.md index b6975bc..c040a3a 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,6 @@ To get started with L2, please visit the [documentation](https://initia.gitbook. - Integrates seamlessly with the OPinit stack, enhancing security. - Provides immediate access to the full suite of Initia ecosystem tools right from the start. - ## Contributing Contributions are welcome! If you have any ideas, suggestions, or bug reports, please open an issue or submit a pull request. diff --git a/app/ante/account_number.go b/app/ante/account_number.go deleted file mode 100644 index bcd355a..0000000 --- a/app/ante/account_number.go +++ /dev/null @@ -1,48 +0,0 @@ -package ante - -import ( - storetypes "cosmossdk.io/store/types" - - sdk "github.com/cosmos/cosmos-sdk/types" - cosmosante "github.com/cosmos/cosmos-sdk/x/auth/ante" - authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" -) - -// AccountNumberDecorator is a custom ante handler that increments the account number depending on -// the execution mode (Simulate, CheckTx, Finalize). -// -// This is to avoid account number conflicts when running concurrent Simulate, CheckTx, and Finalize. -type AccountNumberDecorator struct { - ak cosmosante.AccountKeeper -} - -// NewAccountNumberDecorator creates a new instance of AccountNumberDecorator. -func NewAccountNumberDecorator(ak cosmosante.AccountKeeper) AccountNumberDecorator { - return AccountNumberDecorator{ak} -} - -// AnteHandle is the AnteHandler implementation for AccountNumberDecorator. -func (and AccountNumberDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (sdk.Context, error) { - if !ctx.IsCheckTx() && !ctx.IsReCheckTx() && !simulate { - return next(ctx, tx, simulate) - } - - ak := and.ak.(*authkeeper.AccountKeeper) - - gasFreeCtx := ctx.WithGasMeter(storetypes.NewInfiniteGasMeter()) - num, err := ak.AccountNumber.Peek(gasFreeCtx) - if err != nil { - return ctx, err - } - - accountNumAddition := uint64(1_000_000) - if simulate { - accountNumAddition += 1_000_000 - } - - if err := ak.AccountNumber.Set(gasFreeCtx, num+accountNumAddition); err != nil { - return ctx, err - } - - return next(ctx, tx, simulate) -} diff --git a/app/ante/ante.go b/app/ante/ante.go index e850b40..4b146a7 100644 --- a/app/ante/ante.go +++ b/app/ante/ante.go @@ -12,6 +12,7 @@ import ( opchildante "github.com/initia-labs/OPinit/x/opchild/ante" opchildtypes "github.com/initia-labs/OPinit/x/opchild/types" + "github.com/initia-labs/initia/app/ante/accnum" "github.com/skip-mev/block-sdk/v2/block" auctionante "github.com/skip-mev/block-sdk/v2/x/auction/ante" @@ -93,7 +94,7 @@ func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) { } anteDecorators := []sdk.AnteDecorator{ - NewAccountNumberDecorator(options.AccountKeeper), + accnum.NewAccountNumberDecorator(options.AccountKeeper), ante.NewSetUpContextDecorator(), // outermost AnteDecorator. SetUpContext must be called first ante.NewExtensionOptionsDecorator(options.ExtensionOptionChecker), // NOTE - WASM simulation gas limit can affect other module messages. diff --git a/go.mod b/go.mod index bf736ae..aec9373 100644 --- a/go.mod +++ b/go.mod @@ -35,7 +35,7 @@ require ( github.com/grpc-ecosystem/grpc-gateway v1.16.0 github.com/hashicorp/go-metrics v0.5.3 github.com/initia-labs/OPinit v0.3.2 - github.com/initia-labs/initia v0.3.4 + github.com/initia-labs/initia v0.3.5 github.com/initia-labs/kvindexer v0.1.5 github.com/initia-labs/kvindexer/submodules/block v0.1.0 github.com/initia-labs/kvindexer/submodules/tx v0.1.0 diff --git a/go.sum b/go.sum index dcf553d..49d89f7 100644 --- a/go.sum +++ b/go.sum @@ -806,8 +806,8 @@ github.com/initia-labs/cometbft v0.0.0-20240704071917-6c77a401128c h1:+icq583vNt github.com/initia-labs/cometbft v0.0.0-20240704071917-6c77a401128c/go.mod h1:qGaJePRWAc2OL3OGNd//8fqgypCaFjmwZcy/cNner84= github.com/initia-labs/ibc-go/v8 v8.0.0-20240419124350-4275a05abe2c h1:FDwh5zZbm9v7C37ni4FytQQ9Os5XxYp1px5U7Nqdu2Y= github.com/initia-labs/ibc-go/v8 v8.0.0-20240419124350-4275a05abe2c/go.mod h1:wj3qx75iC/XNnsMqbPDCIGs0G6Y3E/lo3bdqCyoCy+8= -github.com/initia-labs/initia v0.3.4 h1:i2fwTx9WDwGp2nyX64r6jtdtgfJmRqKAXGdxbHBRg9s= -github.com/initia-labs/initia v0.3.4/go.mod h1:nwtnVe3obacErGb7w6tq8Ych3U0d2f59rsgpVUeMnmM= +github.com/initia-labs/initia v0.3.5 h1:JsO0OZ+ZRQjzFusXSA2f7U1LNO6nApaCr+U6idJ+Pko= +github.com/initia-labs/initia v0.3.5/go.mod h1:nwtnVe3obacErGb7w6tq8Ych3U0d2f59rsgpVUeMnmM= github.com/initia-labs/kvindexer v0.1.5 h1:YLR4d237dNkGR8pe2zRGxx3CFB2CU6hhUmeJsshUw/0= github.com/initia-labs/kvindexer v0.1.5/go.mod h1:OV85HaQ9KVrg+zGPUlxT9RF9nAaM3Yq4/3MoHqGqhWk= github.com/initia-labs/kvindexer/submodules/block v0.1.0 h1:y+EXnksd/I2F96mzIoQA64nZUZON2P+99YrSzeLCLoY=