[Bug] native functions are bound to a hardcoded address (0x1) in unit tests (invoked through move-cli)
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 378
- Forks
- 137
- PR merge metrics
- No merged PRs in 30d
Description
Currently when the move-cli launches, it associates the MoveStdlib native functions with address 0x1.
fn main() -> Result<()> {
let error_descriptions: ErrorMapping = bcs::from_bytes(move_stdlib::error_descriptions())?;
let cost_table = &move_vm_types::gas_schedule::INITIAL_COST_SCHEDULE;
move_cli::move_cli(
move_stdlib::natives::all_natives(AccountAddress::from_hex_literal("0x1").unwrap()),
cost_table,
&error_descriptions,
)
}
This can be problematic if a user runs unit tests against a package that sets Std to a different numerical address. Here is an example:
[package]
name = "Foo"
version = "1.0.0"
[dependencies]
MoveStdlib = { local = "../move-stdlib" }
[addresses]
A = "_"
[dev-addresses]
A = "0x2"
Std = "0x2"
This will result in the Move VM failing to load the MoveStdlib modules containing native functions:
[ FAIL ] 0x2::Foo::foo
Test failures:
Failures in 0x2::Foo:
┌── foo ──────
│ ITE: An unknown error was reported. Location:
│ VMError (if there is one): VMError {
│ major_status: UNEXPECTED_VERIFIER_ERROR,
│ sub_status: None,
│ message: Some(
│ "Unexpected verifier/deserialization error! This likely means there is code stored on chain that is unverifiable!\nError: VMError { major_status: MISSING_DEPENDENCY, sub_status: None, message: None, stacktrace: None, location: Module(ModuleId { address: 00000000000000000000000000000002, name: Identifier(\"UnitTest\") }), indices: [(FunctionHandle, 0)], offsets: [] }",
│ ),
│ stacktrace: None,
│ location: Module(
│ ModuleId {
│ address: 00000000000000000000000000000002,
│ name: Identifier(
│ "UnitTest",
│ ),
│ },
│ ),
│ indices: [
│ (
│ FunctionHandle,
│ 0,
│ ),
│ ],
│ offsets: [],
│ }
└──────────────────
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the move-cli launch path and the move_stdlib::natives::all_natives call shown in the issue. Reproduce the failure with the provided package configuration, where Std is assigned 0x2, and trace how the native-function address reaches unit-test execution. Done means the MoveStdlib native modules load when the package uses a non-0x1 Std address.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- cli, testing
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100