Skip to content

Commit

Permalink
chore: Call only MigrateWithInfo and move arity check to cw-vm
Browse files Browse the repository at this point in the history
  • Loading branch information
kulikthebird committed Aug 28, 2024
1 parent 797cfa0 commit ef8f438
Show file tree
Hide file tree
Showing 3 changed files with 284 additions and 275 deletions.
19 changes: 1 addition & 18 deletions x/wasm/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -572,24 +572,7 @@ func (k Keeper) callMigrateEntrypoint(
Sender: senderAddress.String(),
OldMigrateVersion: OldMigrateVersion,
}
var res *wasmvmtypes.ContractResult
var gasUsed uint64
var err error
if OldMigrateVersion == nil {
res, gasUsed, err = k.wasmVM.Migrate(newChecksum, env, msg, vmStore, cosmwasmAPI, &querier, k.gasMeter(sdkCtx), gasLeft, costJSONDeserialization)
if err != nil {
if strings.Contains(err.Error(), "The called function args arity does not match") {
res, gasUsed, err = k.wasmVM.MigrateWithInfo(newChecksum, env, msg, migrateInfo, vmStore, cosmwasmAPI, &querier, k.gasMeter(sdkCtx), gasLeft, costJSONDeserialization)
}
}
} else {
res, gasUsed, err = k.wasmVM.MigrateWithInfo(newChecksum, env, msg, migrateInfo, vmStore, cosmwasmAPI, &querier, k.gasMeter(sdkCtx), gasLeft, costJSONDeserialization)
if err != nil {
if strings.Contains(err.Error(), "The called function args arity does not match") {
res, gasUsed, err = k.wasmVM.Migrate(newChecksum, env, msg, vmStore, cosmwasmAPI, &querier, k.gasMeter(sdkCtx), gasLeft, costJSONDeserialization)
}
}
}
res, gasUsed, err := k.wasmVM.MigrateWithInfo(newChecksum, env, msg, migrateInfo, vmStore, cosmwasmAPI, &querier, k.gasMeter(sdkCtx), gasLeft, costJSONDeserialization)

k.consumeRuntimeGas(sdkCtx, gasUsed)
if err != nil {
Expand Down
Loading

0 comments on commit ef8f438

Please sign in to comment.