Skip to content

CodeRejected: module imports a non-existent function #243

@ashutoshvarma

Description

@ashutoshvarma

Problem: -

Error while deploying contracts that contains methods that deletes storage states. That includes operation like Mapping.delete() that call env().clearContractStroage().

Temporary Fix: -

Commented out the new seal_clear_storage from __unstable__.ts, that overshadows the old seal_clear_storage from seal0.ts

@external("__unstable__", "seal_clear_storage")
export declare function seal_clear_storage(keyPtr: Ptr): Size;

Substrate Contracts Node Log

v0.22

 DEBUG tokio-runtime-worker runtime::contracts: CodeRejected: module imports a non-existent function

v0.23

 DEBUG tokio-runtime-worker runtime::contracts: failed to instantiate code: cannot find definition for import __unstable__::seal_clear_storage: Func(DedupFuncType(GuardedEntity { guard_idx: EngineIdx(2), entity_idx: DedupFuncTypeIdx(0) }))

Steps to reproduce: -

Build and deploy any contract that has delete() method. Below is the minimal reproduction contract.

import { HashKeccak256, AccountId, Mapping } from "ask-lang";

@contract()
export class Contract {
    _map: Mapping<AccountId, u32, HashKeccak256> = new Mapping();

    @constructor()
    default(): void {}

    @message({ mutates: true })
    remove(k: AccountId): void {
        return this._map.delete(k);
    }
}

Notes (Not related to this issue) :-

Cannot deploy any contract build with ark-lang v0.4.0 on latest substrate-contracts-node v0.23.
Always fails with below error.

DEBUG tokio-runtime-worker runtime::contracts: failed to instantiate code: found an unexpected start function with index 58

Maybe related to paritytech/substrate#207

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions