Skip to content

Module uses chain extensions but chain extensions are disabled #200

@sudipghimire533

Description

@sudipghimire533

Error:

DEBUG tokio-runtime-worker runtime::contracts: New code rejected on validation: Module uses chain extensions but chain extensions are disabled  

Reproduce

runtime/src/lib.rs

// -- snip

pub mod extension;
impl pallet_contracts::Config for Runtime {
    // -- snip
    type ChainExtension = extension::Example;
}

// -- snip

runtime/src/extension.rs

#[derive(Default)]
pub struct Example;

impl ChainExtension<Runtime> for Example {
    fn call<E: Ext>(&mut self, env: Environment<E, InitState>) -> Result<RetVal, DispatchError>
    where
        E: Ext<T = Runtime>,
    {
		panic!("Hey");
	}

	fn enabled() -> bool {
		log::info!("[info] Yes it's enabled");
		true
	}
}

But when I upload a ink! contract using the chain extension, it throws error:

CodeRejected

The contract's code was found to be invalid during validation.The most likely cause of this is that an API was used which is not supported by thenode. This happens if an older node is used with a new version of ink!. Try updatingyour node to the newest available version.A more detailed error can be found on the node console if debug messages are enabledby supplying `-lruntime::contracts=debug`.

Module uses chain extensions but chain extensions are disabled

Also:

#[cfg(test)]
#[test]
fn runtime_test() {
    use pallet_contracts::chain_extension::ChainExtension;

    assert!( <Runtime as pallet_contracts::Config>::ChainExtension::enabled() );
}

Output:

running 1 test
test runtime_test ... ok

Version:

└──╼ $cargo contract --version
cargo-contract-contract 3.0.1-unknown-x86_64-unknown-linux-gnu

sp-api = { git = "https://github.com/paritytech/substrate", package = "sp-api", branch = "polkadot-v1.0.0" }
ink = { version = "4.2.0", default-features = false }
ink_env = { version = "4.2.1", default-features = false }

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