aptos-labs / aptos-core

Aptos is a layer 1 blockchain built to support the widespread use of blockchain through better technology and user experience.
https://aptosfoundation.org
Other
6.18k stars 3.66k forks source link

[Bug] cannot publish modules with `public inline` and `#[view]` function #15345

Open meng-xu-cs opened 2 days ago

meng-xu-cs commented 2 days ago

🐛 Bug

Trying to publish a Move package with both public inline and #[view] attribute leads to an unexpected and hard-to-understand error code (CONSTRAINT_NOT_SATISFIED).

To reproduce

Code snippet to reproduce

Following is a minimal Move package to reproduce this issue.

module demo::demo {
    #[view]
    public inline fun zero(): u64 { 0 }
}

With an associated Move.toml

[package]
name = "Demo"
version = "1.0.0"
upgrade_policy = "compatible"
authors = []

[addresses]
demo = '_'

Compiling this Move package is fine (using either V1 or V2 compiler), e.g., with

aptos move compile --named-addresses demo=0x123

However, when publishing it on chain, e.g., to the local testnet, the following error is observed:

API error: Unknown error Transaction committed on chain, but failed execution: CONSTRAINT_NOT_SATISFIED

It is really hard to decipher what it means...

Following is one way to publish the package and observe the error:

# Launch local testnet in one terminal session
aptos node run-local-testnet --with-faucet --force-restart

# Prepare a demo account
aptos init --network local --profile demo --private-key <some-key> --skip-faucet --assume-yes
aptos account fund-with-faucet --profile demo --account demo --amount 100000

# publish the package
aptos move publish --profile demo --sender-account demo <path-to-pkg>

Expected Behavior

One of the following is expected:

System information

Please complete the following information:

brmataptos commented 1 day ago

This should be an easy addition to extended checker.