Skip to content

Commit

Permalink
Merge branch 'main' into julien/fix-params
Browse files Browse the repository at this point in the history
  • Loading branch information
julienrbrt authored Jan 24, 2025
2 parents 011786d + e9b16a4 commit 969d34d
Showing 1 changed file with 0 additions and 49 deletions.
49 changes: 0 additions & 49 deletions runtime/gas.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package runtime

import (
"context"
"fmt"

"cosmossdk.io/core/gas"
storetypes "cosmossdk.io/store/types"
Expand Down Expand Up @@ -53,54 +52,6 @@ func (cgm CoreGasmeter) Limit() gas.Gas {
return cgm.gm.Limit()
}

// SDKGasMeter is a wrapper around the SDK's GasMeter that implements the GasMeter interface.
type SDKGasMeter struct {
gm gas.Meter
}

func (gm SDKGasMeter) GasConsumed() storetypes.Gas {
return gm.gm.Consumed()
}

func (gm SDKGasMeter) GasConsumedToLimit() storetypes.Gas {
if gm.IsPastLimit() {
return gm.gm.Limit()
}
return gm.gm.Consumed()
}

func (gm SDKGasMeter) GasRemaining() storetypes.Gas {
return gm.gm.Remaining()
}

func (gm SDKGasMeter) Limit() storetypes.Gas {
return gm.gm.Limit()
}

func (gm SDKGasMeter) ConsumeGas(amount storetypes.Gas, descriptor string) {
if err := gm.gm.Consume(amount, descriptor); err != nil {
panic(err)
}
}

func (gm SDKGasMeter) RefundGas(amount storetypes.Gas, descriptor string) {
if err := gm.gm.Refund(amount, descriptor); err != nil {
panic(err)
}
}

func (gm SDKGasMeter) IsPastLimit() bool {
return gm.gm.Remaining() <= gm.gm.Limit()
}

func (gm SDKGasMeter) IsOutOfGas() bool {
return gm.gm.Remaining() >= gm.gm.Limit()
}

func (gm SDKGasMeter) String() string {
return fmt.Sprintf("BasicGasMeter:\n limit: %d\n consumed: %d", gm.gm.Limit(), gm.gm.Remaining())
}

type GasConfig struct {
gc gas.GasConfig
}
Expand Down

0 comments on commit 969d34d

Please sign in to comment.