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][move-compiler-v2] compiler-v2 fails vm_test_harness/example.move test #13255

Open brmataptos opened 6 months ago

brmataptos commented 6 months ago

See

third_party/move/testing-infra/transactional-test-runner/tests/vm_test_harness/example.v2_exp

in #13216 .

There might be some problem with the test harness, but task 4 of the test case fails compilation with MOVE_COMPILER_V2=true.

brmataptos commented 5 months ago

This is related to #13392. Namely, the problem is that the transactional tests just simulate publishing code, but don't really publish it anywhere. This means we have to treat the previous code as a "to be compiled" source, but if there is a conflict with the later source we have a problem.

rahxephon89 commented 5 months ago

@wrwg @brmataptos, this error happens because when running expansion phase in V2, all modules lib_definitions are moved to source_definitions. If a module in lib_definitions has the same address and same name as an existing module in source_definitions, the error Duplicate definition for module will be raised.

brmataptos commented 5 months ago

We need to test this case when building a new module when there is an existing module of the same name and address on-chain already. Maybe this just works due to the package builder, but we need to test module upgrade cases as would be done by real users.