Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Module uses chain extensions but chain extensions are disabled #200

Closed
sudipghimire533 opened this issue Aug 5, 2023 · 3 comments · Fixed by #201
Closed

Module uses chain extensions but chain extensions are disabled #200

sudipghimire533 opened this issue Aug 5, 2023 · 3 comments · Fixed by #201

Comments

@sudipghimire533
Copy link

sudipghimire533 commented Aug 5, 2023

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 }
@athei
Copy link
Member

athei commented Aug 6, 2023

Was fixed upstream by paritytech/substrate#14642. It was backported to the polkadot-v1.0.0 branch. If you are compiling from source you can just cargo update.

@athei athei mentioned this issue Aug 6, 2023
@athei athei closed this as completed in #201 Aug 6, 2023
athei added a commit that referenced this issue Aug 6, 2023
Sync with `polkadot-v1.0.0` in order to include
paritytech/substrate#14642.

Fixes #200
@deep-ink-ventures
Copy link

Would've saved me a few hours if this would have been merged into release-v1.0.0-cumulus :-)

@athei
Copy link
Member

athei commented Aug 14, 2023

😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants