Skip to content

Commit

Permalink
Swap simulate and simulate special
Browse files Browse the repository at this point in the history
  • Loading branch information
phamminh0811 committed Sep 18, 2024
1 parent 7f404ee commit bc944e1
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 9 deletions.
8 changes: 5 additions & 3 deletions custom/auth/client/utils/feeutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ func ComputeFeesWithCmd(
gasStr, _ := flagSet.GetString(flags.FlagGas)
switch gasStr {
case flags.GasFlagAuto:
// skip
txf = txf.WithGas(0)
txf = txf.WithSimulateAndExecute(true)
case "":
txf = txf.WithGas(0)
txf = txf.WithSimulateAndExecute(true)
Expand Down Expand Up @@ -123,8 +124,9 @@ func CalculateGas(
return nil, 0, err
}

taxGas := simSpecialRes.GasInfo.GasUsed - simRes.GasInfo.GasUsed
actualGas := uint64(txf.GasAdjustment() * float64(simRes.GasInfo.GasUsed))
taxGas := simRes.GasInfo.GasUsed - simSpecialRes.GasInfo.GasUsed
actualGas := uint64(txf.GasAdjustment() * float64(simSpecialRes.GasInfo.GasUsed))
simRes.GasInfo = simSpecialRes.GasInfo
return simRes, actualGas + taxGas, nil
}

Expand Down
2 changes: 1 addition & 1 deletion custom/wasm/keeper/handler_plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func (h SDKMessageHandler) DispatchMsg(ctx sdk.Context, contractAddr sdk.AccAddr
return nil, nil, err
}
ctx.TaxGasMeter().ConsumeGas(taxGas, "tax gas")
if ctx.IsSpecialSimulate() {
if ctx.IsSimulate() {
ctx.CacheTaxGasMeter().ConsumeGas(taxGas, "tax gas")
}

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ replace (
// use cometbft
github.com/cometbft/cometbft => github.com/classic-terra/cometbft v0.37.4-terra1
github.com/cometbft/cometbft-db => github.com/cometbft/cometbft-db v0.8.0
github.com/cosmos/cosmos-sdk => github.com/classic-terra/cosmos-sdk v0.47.10-terra.2
github.com/cosmos/cosmos-sdk => ../Upgrade/cosmos-sdk
github.com/cosmos/ibc-go/v7 => github.com/classic-terra/ibc-go/v7 v7.4.0-terra.1
github.com/cosmos/ledger-cosmos-go => github.com/terra-money/ledger-terra-go v0.11.2
// replace goleveldb to optimized one
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -350,8 +350,6 @@ github.com/circonus-labs/circonus-gometrics v2.3.1+incompatible/go.mod h1:nmEj6D
github.com/circonus-labs/circonusllhist v0.1.3/go.mod h1:kMXHVDlOchFAehlya5ePtbp5jckzBHf4XRpQvBOLI+I=
github.com/classic-terra/cometbft v0.37.4-terra1 h1:eT5B2n5KKi5WVW+3ZNOVTmtfKKaZrXOLX9G80m9mhZo=
github.com/classic-terra/cometbft v0.37.4-terra1/go.mod h1:vFqj7Qe3uFFJvHZleTJPQDmJ/WscXHi4rKWqiCAaNZk=
github.com/classic-terra/cosmos-sdk v0.47.10-terra.2 h1:f54DHwGuOcyrWToTYKpFLy1i5qUz9GAtc6DOg7rF6zI=
github.com/classic-terra/cosmos-sdk v0.47.10-terra.2/go.mod h1:Qgm2WbKtqHgE1v9eAra7Fos/zAcB7F4ikwwbDm9SV+o=
github.com/classic-terra/goleveldb v0.0.0-20230914223247-2b28f6655121 h1:fjpWDB0hm225wYg9vunyDyTH8ftd5xEUgINJKidj+Tw=
github.com/classic-terra/goleveldb v0.0.0-20230914223247-2b28f6655121/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc=
github.com/classic-terra/ibc-go/v7 v7.4.0-terra.1 h1:xPT04cguu/Tt//x8eOKQVZP3RfYh/JDaBS4jPexK/OM=
Expand Down
2 changes: 1 addition & 1 deletion x/tax2gas/ante/ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func (fd FeeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, nex
WithValue(types.FinalGasPrices, gasPrices)
if !taxGas.IsZero() {
newCtx.TaxGasMeter().ConsumeGas(taxGas, "ante handler taxGas")
if ctx.IsSpecialSimulate() {
if ctx.IsSimulate() {
ctx.CacheTaxGasMeter().ConsumeGas(taxGas, "tax gas")
}
}
Expand Down
2 changes: 1 addition & 1 deletion x/tax2gas/post/post.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func (tgd Tax2gasPostDecorator) PostHandle(ctx sdk.Context, tx sdk.Tx, simulate
taxGasUint64 := taxGas.Uint64()
// Check if gas not overflow
if totalGasConsumed+taxGasUint64 >= totalGasConsumed && totalGasConsumed+taxGasUint64 >= taxGasUint64 {
if ctx.IsSpecialSimulate() {
if ctx.IsSimulate() {
if taxGasUint64+totalGasConsumed > ctx.GasMeter().Limit() {
ctx.GasMeter().ExtendGasLimit()
}
Expand Down

0 comments on commit bc944e1

Please sign in to comment.