Skip to content
6 changes: 5 additions & 1 deletion runtime/v2/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"cosmossdk.io/core/branch"
"cosmossdk.io/core/comet"
"cosmossdk.io/core/event"
"cosmossdk.io/core/gas"
"cosmossdk.io/core/header"
"cosmossdk.io/core/registry"
"cosmossdk.io/core/router"
Expand Down Expand Up @@ -214,6 +215,7 @@ func ProvideEnvironment(
kvService store.KVStoreService,
memKvService store.MemoryStoreService,
headerService header.Service,
gasService gas.Service,
eventService event.Service,
branchService branch.Service,
routerBuilder RouterServiceBuilder,
Expand All @@ -222,7 +224,7 @@ func ProvideEnvironment(
Logger: logger,
BranchService: branchService,
EventService: eventService,
GasService: stf.NewGasMeterService(),
GasService: gasService,
HeaderService: headerService,
QueryRouterService: routerBuilder.BuildQueryRouter(),
MsgRouterService: routerBuilder.BuildMsgRouter([]byte(key.Name())),
Expand Down Expand Up @@ -296,6 +298,7 @@ func DefaultServiceBindings() depinject.Config {
eventService = services.NewGenesisEventService(stf.NewEventService())
storeBuilder = root.NewBuilder()
branchService = stf.BranchService{}
gasService = stf.NewGasMeterService()
)
return depinject.Supply(
kvServiceFactory,
Expand All @@ -305,5 +308,6 @@ func DefaultServiceBindings() depinject.Config {
eventService,
storeBuilder,
branchService,
gasService,
)
}
9 changes: 8 additions & 1 deletion tests/integration/v2/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
corebranch "cosmossdk.io/core/branch"
"cosmossdk.io/core/comet"
corecontext "cosmossdk.io/core/context"
"cosmossdk.io/core/gas"
"cosmossdk.io/core/header"
"cosmossdk.io/core/server"
corestore "cosmossdk.io/core/store"
Expand Down Expand Up @@ -99,6 +100,8 @@
RouterServiceBuilder runtime.RouterServiceBuilder
// HeaderService defines the custom header service to be used in the app.
HeaderService header.Service

GasService gas.Service
}

func DefaultStartUpConfig(t *testing.T) StartupConfig {
Expand Down Expand Up @@ -129,6 +132,7 @@
stf.NewMsgRouterService, stf.NewQueryRouterService(),
),
HeaderService: services.NewGenesisHeaderService(stf.HeaderService{}),
GasService: stf.NewGasMeterService(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add test coverage for GasService integration

While the GasService integration looks good, consider adding specific test cases to verify:

  1. Gas consumption tracking
  2. Gas limit enforcement
  3. Error handling for out-of-gas scenarios

Would you like me to help create these test cases or open a GitHub issue to track this task?

}
}

Expand Down Expand Up @@ -193,9 +197,11 @@
startupConfig.BranchService,
startupConfig.RouterServiceBuilder,
startupConfig.HeaderService,
startupConfig.GasService,
),
depinject.Invoke(
std.RegisterInterfaces,
std.RegisterLegacyAminoCodec,
),
),
append(extraOutputs, &appBuilder, &cdc, &txConfigOptions, &txConfig, &storeBuilder)...); err != nil {
Expand Down Expand Up @@ -336,10 +342,11 @@
require.NoError(t, err)
a.lastHeight++

// update block height if integration context is present
// update block height and block time if integration context is present
iCtx, ok := ctx.Value(contextKey).(*integrationContext)
if ok {
iCtx.header.Height = int64(a.lastHeight)
iCtx.header.Time = time.Now()
}
return resp, state
}
Expand Down
6 changes: 6 additions & 0 deletions tests/integration/v2/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,12 @@ type genesisTxCodec struct {
tx.ConfigOptions
}

func NewGenesisTxCodec(txConfigOptions tx.ConfigOptions) *genesisTxCodec {
return &genesisTxCodec{
txConfigOptions,
}
}

// Decode implements transaction.Codec.
func (t *genesisTxCodec) Decode(bz []byte) (stateMachineTx, error) {
var out stateMachineTx
Expand Down
Loading
Loading