ink icon indicating copy to clipboard operation
ink copied to clipboard

Issue Deploying Contract with Events on Westend AssetHub (hash_blake2_256 syscall missing)

Open AlexD10S opened this issue 7 months ago • 3 comments

During the recent hackathon, some users reported an issue when deploying smart contracts to Westend AssetHub using ink! v6. The following error:

▲  Pre-submission dry-run failed: ModuleError: Revive::CodeRejected: 
["The contract failed to compile or is missing the correct entry points.", 
"", 
"A more detailed error can be found on the node console if debug messages are enabled", 
"by supplying `-lruntime::revive=debug`."]

It appears the issue is related to contract events. Contracts like flipper, or versions of ERC20 where events are commented out, deploy successfully. However, when events are included, the deployment fails. Note: I also tried removing the #[ink(topic)] attribute from the events as suggested in some comments, but the error persists.

Running the Westend AssetHub node locally with the debug flag (-lruntime::revive=debug), I observed this error:

DEBUG tokio-runtime-worker runtime::revive: Program references unknown syscall: 'hash_blake2_256'

Steps to Reproduce:

  1. Clone the ERC20 example from https://github.com/use-ink/ink-examples/blob/v6.x/erc20/lib.rs
  2. Attempt to deploy it to Westend AssetHub, a quick way: https://inkv6alpha.netlify.app/. and you will see how it fails.
  3. If you comment out all Self::env().emit_event(...) lines (here,here and here), tebuild and redeploy -> deployment will now succeed without the events.

Set up Westend AssetHub locally

To run Westend AssetHub locally with debugging enabled, add this line:

args = ["-lruntime::revive=debug"]

at the end of the config file: https://github.com/r0gue-io/pop-cli/blob/main/tests/networks/westend%2Basset-hub.toml Run:

pop up network -f ./tests/networks/westend+asset-hub.toml -r stable2503-1

AlexD10S avatar May 08 '25 13:05 AlexD10S

The reason why ink-node works while Westend AssetHub does not is due to the configuration of the pallet_revive.

In Westend AssetHub, the following line disables the unstable interface: https://github.com/paritytech/polkadot-sdk/blob/master/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs#L1085

type UnsafeUnstableInterface = ConstBool<false>;

Whereas in ink-node, it is explicitly enabled: https://github.com/use-ink/ink-node/blob/main/runtime/src/revive_config.rs#L55:

type UnsafeUnstableInterface = ConstBool<true>;

Because of this difference, smart contracts using the unstable-hostfn feature (https://github.com/use-ink/ink-examples/blob/v6.x/erc20/Cargo.toml#L9) will fail on Westend AssetHub but work on ink-node. This feature was introduced in https://github.com/use-ink/ink/pull/2427

AlexD10S avatar May 09 '25 14:05 AlexD10S

PR enabling these in pop's devnet and testnet runtimes - https://github.com/r0gue-io/pop-node/pull/564

al3mart avatar May 09 '25 15:05 al3mart

The function is unstable on pallet-revive side. My understanding is that it will be moved to a pre-compile and then stabilized again.

Here's the tracking issue: https://github.com/paritytech/polkadot-sdk/issues/8570.

For now, users of ink! unfortunately can't use events on chains that don't have unstable functions enabled (like Westend).

cmichi avatar Jun 10 '25 12:06 cmichi

I'm closing the issue, the precompile for Blake2_256 was implemented in ink! by now.

I'm not sure in which stable the precompile was released, but I think latest stable2509 must contain it.

cmichi avatar Oct 29 '25 15:10 cmichi