Skip to content

Commit 0ab1ecc

Browse files
committed
bump contracts and use local ante handler
1 parent 8131df7 commit 0ab1ecc

File tree

21 files changed

+341
-247
lines changed

21 files changed

+341
-247
lines changed

app/ante/account_number.go

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package ante
2+
3+
import (
4+
storetypes "cosmossdk.io/store/types"
5+
6+
sdk "github.com/cosmos/cosmos-sdk/types"
7+
cosmosante "github.com/cosmos/cosmos-sdk/x/auth/ante"
8+
authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
9+
)
10+
11+
// AccountNumberDecorator is a custom ante handler that increments the account number depending on
12+
// the execution mode (Simulate, CheckTx, Finalize).
13+
//
14+
// This is to avoid account number conflicts when running concurrent Simulate, CheckTx, and Finalize.
15+
type AccountNumberDecorator struct {
16+
ak cosmosante.AccountKeeper
17+
}
18+
19+
// NewAccountNumberDecorator creates a new instance of AccountNumberDecorator.
20+
func NewAccountNumberDecorator(ak cosmosante.AccountKeeper) AccountNumberDecorator {
21+
return AccountNumberDecorator{ak}
22+
}
23+
24+
// AnteHandle is the AnteHandler implementation for AccountNumberDecorator.
25+
func (and AccountNumberDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (sdk.Context, error) {
26+
if !ctx.IsCheckTx() && !ctx.IsReCheckTx() && !simulate {
27+
return next(ctx, tx, simulate)
28+
}
29+
30+
ak := and.ak.(*authkeeper.AccountKeeper)
31+
32+
gasFreeCtx := ctx.WithGasMeter(storetypes.NewInfiniteGasMeter())
33+
num, err := ak.AccountNumber.Peek(gasFreeCtx)
34+
if err != nil {
35+
return ctx, err
36+
}
37+
38+
accountNumAddition := uint64(1_000_000)
39+
if simulate {
40+
accountNumAddition += 1_000_000
41+
}
42+
43+
if err := ak.AccountNumber.Set(gasFreeCtx, num+accountNumAddition); err != nil {
44+
return ctx, err
45+
}
46+
47+
return next(ctx, tx, simulate)
48+
}

app/ante/ante.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import (
1212

1313
opchildante "github.com/initia-labs/OPinit/x/opchild/ante"
1414
opchildtypes "github.com/initia-labs/OPinit/x/opchild/types"
15-
initiaante "github.com/initia-labs/initia/app/ante"
1615

1716
"github.com/skip-mev/block-sdk/v2/block"
1817
auctionante "github.com/skip-mev/block-sdk/v2/x/auction/ante"
@@ -94,7 +93,7 @@ func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) {
9493
}
9594

9695
anteDecorators := []sdk.AnteDecorator{
97-
initiaante.NewAccountNumberDecorator(options.AccountKeeper),
96+
NewAccountNumberDecorator(options.AccountKeeper),
9897
ante.NewSetUpContextDecorator(), // outermost AnteDecorator. SetUpContext must be called first
9998
ante.NewExtensionOptionsDecorator(options.ExtensionOptionChecker),
10099
// NOTE - WASM simulation gas limit can affect other module messages.

app/app.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -785,7 +785,7 @@ func NewMinitiaApp(
785785
consensus.NewAppModule(appCodec, *app.ConsensusParamsKeeper),
786786
wasm.NewAppModule(appCodec, app.WasmKeeper, nil /* unused */, app.AccountKeeper, app.BankKeeper, app.MsgServiceRouter(), nil),
787787
auction.NewAppModule(app.appCodec, *app.AuctionKeeper),
788-
tokenfactory.NewAppModule(appCodec, *app.TokenFactoryKeeper, *app.AccountKeeper, *app.BankKeeper),
788+
tokenfactory.NewAppModule(appCodec, app.TokenFactoryKeeper, *app.AccountKeeper, *app.BankKeeper),
789789
// ibc modules
790790
ibc.NewAppModule(app.IBCKeeper),
791791
ibctransfer.NewAppModule(*app.TransferKeeper),

app/ibc-hooks/contracts/Cargo.lock

Lines changed: 54 additions & 55 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/ibc-hooks/contracts/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ overflow-checks = true
2828

2929

3030
[dependencies]
31-
cosmwasm-std = "1.1.0"
32-
cosmwasm-schema = "1.1.0"
33-
cw-storage-plus = "0.13.4"
31+
cosmwasm-std = "2.0.4"
32+
cosmwasm-schema = "2.0.4"
33+
cw-storage-plus = "2.0.0"
3434

3535
[dev-dependencies]
3636

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
c132532b9641facc9afe6c4ad81bebd1237292c26f50ec782426b51cee4cdc90 counter-aarch64.wasm
2+
c7ef9d37456ef0e7754f0e7df70f6f2488a185ea2a1acdee464daf65428d66c3 counter.wasm
182 KB
Binary file not shown.

0 commit comments

Comments
 (0)