laconicd/utils/context.go
Prathamesh Musale e63f51cacd
All checks were successful
Integration Tests / test-integration (push) Successful in 2m13s
E2E Tests / test-e2e (push) Successful in 3m21s
Lint / Run golangci-lint (push) Successful in 5m5s
SDK Tests / sdk_tests_nameservice_expiry (push) Successful in 6m51s
Unit Tests / test-unit (push) Successful in 1m45s
SDK Tests / sdk_tests (push) Successful in 7m43s
SDK Tests / sdk_tests_auctions (push) Successful in 12m18s
Use custom KV store config to handle progressively increasing gas usage (#30)
Part of [Create an external fixturenet-laconicd stack](https://www.notion.so/Create-an-external-fixturenet-laconicd-stack-3b33cc2317444f4da209c4472f4244ed)

Reviewed-on: cerc-io/laconic2d#30
Co-authored-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
Co-committed-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
2024-06-25 06:33:41 +00:00

30 lines
654 B
Go

package utils
import (
"fmt"
"cosmossdk.io/log"
storetypes "cosmossdk.io/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
)
func CtxWithCustomKVGasConfig(ctx *sdk.Context) *sdk.Context {
updatedCtx := ctx.WithKVGasConfig(storetypes.GasConfig{
HasCost: 0,
DeleteCost: 0,
ReadCostFlat: 0,
ReadCostPerByte: 0,
WriteCostFlat: 0,
WriteCostPerByte: 0,
IterNextCostFlat: 0,
})
return &updatedCtx
}
func LogTxGasConsumed(ctx sdk.Context, logger log.Logger, tx string) {
gasConsumed := ctx.GasMeter().GasConsumed()
logger.Info("tx executed", "method", tx, "gas_consumed", fmt.Sprintf("%d", gasConsumed))
}