diff --git a/x/oracle/keeper/owasm.go b/x/oracle/keeper/owasm.go index 0cd595011..a853c1c2b 100644 --- a/x/oracle/keeper/owasm.go +++ b/x/oracle/keeper/owasm.go @@ -21,10 +21,11 @@ func ConvertToOwasmGas(cosmos uint64) uint64 { // GetSpanSize return maximum value between MaxReportDataSize and MaxCallDataSize func (k Keeper) GetSpanSize(ctx sdk.Context) uint64 { - if k.GetParams(ctx).MaxReportDataSize > k.GetParams(ctx).MaxCalldataSize { - return k.GetParams(ctx).MaxReportDataSize + params := k.GetParams(ctx) + if params.MaxReportDataSize > params.MaxCalldataSize { + return params.MaxReportDataSize } - return k.GetParams(ctx).MaxCalldataSize + return params.MaxCalldataSize } // GetRandomValidators returns a pseudorandom subset of active validators. Each validator has @@ -71,12 +72,13 @@ func (k Keeper) PrepareRequest( } askCount := r.GetAskCount() - if askCount > k.GetParams(ctx).MaxAskCount { - return 0, types.WrapMaxError(types.ErrInvalidAskCount, int(askCount), int(k.GetParams(ctx).MaxAskCount)) + params := k.GetParams(ctx) + if askCount > params.MaxAskCount { + return 0, types.WrapMaxError(types.ErrInvalidAskCount, int(askCount), int(params.MaxAskCount)) } // Consume gas for data requests. - ctx.GasMeter().ConsumeGas(askCount*k.GetParams(ctx).PerValidatorRequestGas, "PER_VALIDATOR_REQUEST_FEE") + ctx.GasMeter().ConsumeGas(askCount*params.PerValidatorRequestGas, "PER_VALIDATOR_REQUEST_FEE") // Get a random validator set to perform this request. validators, err := k.GetRandomValidators(ctx, int(askCount), k.GetRequestCount(ctx)+1) @@ -93,8 +95,8 @@ func (k Keeper) PrepareRequest( // Create an execution environment and call Owasm prepare function. env := types.NewPrepareEnv( req, - int64(k.GetParams(ctx).MaxCalldataSize), - int64(k.GetParams(ctx).MaxRawRequestCount), + int64(params.MaxCalldataSize), + int64(params.MaxRawRequestCount), int64(k.GetSpanSize(ctx)), ) script, err := k.GetOracleScript(ctx, req.OracleScriptID) @@ -103,7 +105,7 @@ func (k Keeper) PrepareRequest( } // Consume fee and execute owasm code - ctx.GasMeter().ConsumeGas(k.GetParams(ctx).BaseOwasmGas, "BASE_OWASM_FEE") + ctx.GasMeter().ConsumeGas(params.BaseOwasmGas, "BASE_OWASM_FEE") ctx.GasMeter().ConsumeGas(r.GetPrepareGas(), "OWASM_PREPARE_FEE") code := k.GetFile(script.Filename) output, err := k.owasmVM.Prepare(code, ConvertToOwasmGas(r.GetPrepareGas()), env) @@ -142,7 +144,7 @@ func (k Keeper) PrepareRequest( ctx.EventManager().EmitEvent(event) // Subtract execute fee - ctx.GasMeter().ConsumeGas(k.GetParams(ctx).BaseOwasmGas, "BASE_OWASM_FEE") + ctx.GasMeter().ConsumeGas(params.BaseOwasmGas, "BASE_OWASM_FEE") ctx.GasMeter().ConsumeGas(r.GetExecuteGas(), "OWASM_EXECUTE_FEE") // Emit an event for each of the raw data requests. diff --git a/x/oracle/types/expected_keepers.go b/x/oracle/types/expected_keepers.go index b3e5a10fc..a78335cf9 100644 --- a/x/oracle/types/expected_keepers.go +++ b/x/oracle/types/expected_keepers.go @@ -11,7 +11,6 @@ import ( distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" ibcclienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" - ibcchanneltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" ) // AccountKeeper defines the expected account keeper. @@ -47,8 +46,6 @@ type DistrKeeper interface { // ChannelKeeper defines the expected IBC channel keeper type ChannelKeeper interface { - GetChannel(ctx sdk.Context, srcPort, srcChan string) (channel ibcchanneltypes.Channel, found bool) - GetNextSequenceSend(ctx sdk.Context, portID, channelID string) (uint64, bool) SendPacket( ctx sdk.Context, chanCap *capabilitytypes.Capability,