Skip to content

Commit

Permalink
Fix StoreCode simulation
Browse files Browse the repository at this point in the history
  • Loading branch information
chipshort committed Dec 10, 2024
1 parent 8dd94c1 commit 5f9f00d
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions x/wasm/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,8 @@ func (k Keeper) create(ctx context.Context, creator sdk.AccAddress, wasmCode []b

gasLeft := k.runtimeGasForContract(sdkCtx)
var gasUsed uint64
if sdkCtx.ExecMode() == sdk.ExecModeSimulate {
isSimulation := sdkCtx.ExecMode() == sdk.ExecModeSimulate
if isSimulation {
// only simulate storing the code, no files are written
checksum, gasUsed, err = k.wasmVM.SimulateStoreCode(wasmCode, gasLeft)
} else {
Expand All @@ -182,7 +183,11 @@ func (k Keeper) create(ctx context.Context, creator sdk.AccAddress, wasmCode []b
if err != nil {
return 0, checksum, errorsmod.Wrap(types.ErrCreateFailed, err.Error())
}
report, err := k.wasmVM.AnalyzeCode(checksum)
// simulation gets default value for report
var report *wasmvmtypes.AnalysisReport = &wasmvmtypes.AnalysisReport{}
if !isSimulation {
report, err = k.wasmVM.AnalyzeCode(checksum)
}
if err != nil {
return 0, checksum, errorsmod.Wrap(types.ErrCreateFailed, err.Error())
}
Expand Down

0 comments on commit 5f9f00d

Please sign in to comment.