Skip to content

Commit

Permalink
update the wasm module
Browse files Browse the repository at this point in the history
  • Loading branch information
thr2240 committed May 6, 2024
1 parent 1a3bcce commit c250750
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
2 changes: 1 addition & 1 deletion running_script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ MONIKER="ollo_testnet"
# otherwise your balance will be wiped quickly
# The keyring test does not require private key to steal tokens from you
KEYRING="test"
LOGLEVEL="info"
LOGLEVEL="debug"
# Set dedicated home directory for the ollod instance
HOMEDIR="$HOME/.ollo"
# to trace evm
Expand Down
31 changes: 16 additions & 15 deletions x/wasm/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
"github.com/tendermint/tendermint/libs/log"

// "github.com/ollo-station/ollo/x/wasm/ioutils"
"github.com/ollo-station/ollo/x/wasm/ioutils"
"github.com/ollo-station/ollo/x/wasm/types"
)

Expand Down Expand Up @@ -202,13 +202,14 @@ func (k Keeper) create(ctx sdk.Context, creator sdk.AccAddress, wasmCode []byte,
return 0, checksum, sdkerrors.Wrap(sdkerrors.ErrUnauthorized, "can not create code")
}

// if ioutils.IsGzip(wasmCode) {
// ctx.GasMeter().ConsumeGas(k.gasRegister.UncompressCosts(len(wasmCode)), "Uncompress gzip bytecode")
// wasmCode, err = ioutils.Uncompress(wasmCode, uint64(types.MaxWasmSize))
// if err != nil {
// return 0, checksum, sdkerrors.Wrap(types.ErrCreateFailed, err.Error())
// }
// }

if ioutils.IsGzip(wasmCode) {
ctx.GasMeter().ConsumeGas(k.gasRegister.UncompressCosts(len(wasmCode)), "Uncompress gzip bytecode")
wasmCode, err = ioutils.Uncompress(wasmCode, uint64(types.MaxWasmSize))
if err != nil {
return 0, checksum, sdkerrors.Wrap(types.ErrCreateFailed, err.Error())
}
}

ctx.GasMeter().ConsumeGas(k.gasRegister.CompileCosts(len(wasmCode)), "Compiling wasm bytecode")
checksum, err = k.wasmVM.Create(wasmCode)
Expand Down Expand Up @@ -244,13 +245,13 @@ func (k Keeper) storeCodeInfo(ctx sdk.Context, codeID uint64, codeInfo types.Cod
}

func (k Keeper) importCode(ctx sdk.Context, codeID uint64, codeInfo types.CodeInfo, wasmCode []byte) error {
// if ioutils.IsGzip(wasmCode) {
// var err error
// wasmCode, err = ioutils.Uncompress(wasmCode, uint64(types.MaxWasmSize))
// if err != nil {
// return sdkerrors.Wrap(types.ErrCreateFailed, err.Error())
// }
// }
if ioutils.IsGzip(wasmCode) {
var err error
wasmCode, err = ioutils.Uncompress(wasmCode, uint64(types.MaxWasmSize))
if err != nil {
return sdkerrors.Wrap(types.ErrCreateFailed, err.Error())
}
}
newCodeHash, err := k.wasmVM.Create(wasmCode)
if err != nil {
return sdkerrors.Wrap(types.ErrCreateFailed, err.Error())
Expand Down

0 comments on commit c250750

Please sign in to comment.