Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove unecessary SDKGasMeter impl #23503

Merged
merged 1 commit into from
Jan 24, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading