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

[dev branch] mpm spectest can not compile use module #3732

Closed
nkysg opened this issue Sep 13, 2022 · 4 comments
Closed

[dev branch] mpm spectest can not compile use module #3732

nkysg opened this issue Sep 13, 2022 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@nkysg
Copy link
Collaborator

nkysg commented Sep 13, 2022

Bug Report

Starcoin version:
使用 https://github.com/starcoinorg/starcoin.git dev分支编译mpm

git clone https://github.com/Elements-Studio/starswap-core.git
cd starswap-core
mpm spectest test -v

报错

Error: error[E03002]: unbound module
   ┌─ /var/folders/yw/g0zm8vb56ls0j8nk2vzjw1br0000gn/T/.tmp980qYe:18:9
   │
18 │     use StarcoinFramework::Math;
   │         ^^^^^^^^^^^^^^^^^^^^^^^ Invalid 'use'. Unbound module: '(StarcoinFramework=0x1)::Math'

查看starswap-core下面math_test.move

//# run --signers alice
script {
    use StarcoinFramework::Math;
    use StarcoinFramework::Debug;
    use SwapAdmin::SafeMath;

    // case : x*y/z overflow
    fun math_overflow(_: signer) {
        let precision: u8 = 18;
        let scaling_factor = Math::pow(10, (precision as u64));
        let amount_x: u128 = 110000 * scaling_factor;
        let reserve_y: u128 = 8000000 * scaling_factor;
        let reserve_x: u128 = 2000000 * scaling_factor;

        let amount_y_1 = SafeMath::safe_mul_div_u128(amount_x, reserve_y, reserve_x);
        let amount_y_2 = SafeMath::safe_mul_div_u128(amount_x, reserve_x, reserve_y);
        Debug::print<u128>(&amount_y_1);
        Debug::print<u128>(&amount_y_2);
        assert!(amount_y_1 == 440000 * scaling_factor, 3003);
        assert!(amount_y_2 == 27500 * scaling_factor, 3004);
    }
}
// check: EXECUTED

这么写有问题
改成下面的可以编译

//# run --signers alice
script {
  //  use StarcoinFramework::Math;
   // use StarcoinFramework::Debug;
    //use SwapAdmin::SafeMath;

    // case : x*y/z overflow
    fun math_overflow(_: signer) {
        let precision: u8 = 18;
        let scaling_factor = StarcoinFramework::Math::pow(10, (precision as u64));
        let amount_x: u128 = 110000 * scaling_factor;
        let reserve_y: u128 = 8000000 * scaling_factor;
        let reserve_x: u128 = 2000000 * scaling_factor;

        let amount_y_1 = SwapAdmin::SafeMath::safe_mul_div_u128(amount_x, reserve_y, reserve_x);
        let amount_y_2 = SwapAdmin::SafeMath::safe_mul_div_u128(amount_x, reserve_x, reserve_y);
        Debug::print<u128>(&amount_y_1);
        Debug::print<u128>(&amount_y_2);
        assert!(amount_y_1 == 440000 * scaling_factor, 3003);
        assert!(amount_y_2 == 27500 * scaling_factor, 3004);
    }
}
// check: EXECUTED

Current behavior:

Expected behavior:

Steps to reproduce:

Related code:

insert short code snippets here

Other information:

@nkysg nkysg added the bug Something isn't working label Sep 13, 2022
@nkysg nkysg changed the title [dev branch] mpm spectest can not compile [dev branch] mpm spectest can not compile use module Sep 13, 2022
@LemonHX LemonHX self-assigned this Sep 13, 2022
@LemonHX
Copy link
Member

LemonHX commented Sep 13, 2022

图片
windows starcoin dev branch even debug is not correct

@LemonHX
Copy link
Member

LemonHX commented Sep 13, 2022

[C:\Users\lemonhx\.cargo\git\checkouts\move-ae0d26a86327ae96\1eb08bd\language\move-compiler\src\expansion\translate.rs:886] &context.module_members = UniqueMap(
    {
        ModuleIdent_ {
            address: (alice=0x15D0B101053497F9A2354D63F744D5D0),
            module: ModuleName(
                "TestHelper",
            ),
        }: (
            Loc {
                file_hash: "b15b4c0cb75b74d0044b3653c301b8e4ea0198923b2b277c08553a33b1fe70ae",
                start: 20,
                end: 30,
            },
            {
                "EXP_SCALE": Constant,
                "U128_MAX": Constant,
                "U64_MAX": Constant,
            },
        ),
    },
)

it's the problem of path switching

@LemonHX
Copy link
Member

LemonHX commented Sep 13, 2022

as we see there isn't a single module in
language\move-compiler\src\expansion\translate.rs
dbg is added in https://github.com/starcoinorg/move/tree/dev3732 at language\move-compiler\src\expansion\translate.rs:887

@LemonHX
Copy link
Member

LemonHX commented Sep 14, 2022

done

@LemonHX LemonHX closed this as completed Sep 14, 2022
LemonHX added a commit that referenced this issue Sep 14, 2022
nanne007 added a commit to nanne007/starcoin that referenced this issue Oct 10, 2022
* [compiler] update move
[compiler] Upgrade Move and fix compiler error
[clippy] Fix clippy error

* Merge branch 'master' into update_move

* gen new stdlib

* fix warning: add phantom for merkle distributor

* update move version
fix merkle tree test

* fix Identifier merge

* Update module_upgrade_test.rs

* update script
update move

* check commit

* 1.add table native functions
2.gen new stdlib
3.add table native function gas cost in vmconfig

* 1.add StateKey,MoveExt, SessionId,MoveResolveExt
2.add session finish_with_extension
3.change WriteSet , TransactionOutput, StateKeyView

* add contract_api.json

* 1.add halley genesis

* gen new stdlib

* Merge branch 'master' into update_move

* fix lock

* update move repo

* add move table extension flush

* add statedb support move table extension with commit and flush

* remove WriteAccessPathSet and refactor code

* remove unused code

* add halley genesis

* add halley genesis

* remove file

* fix bug

* add halley genesis

* add table item test code

* fix  warnings

* update move repo

* fix fmt

* reset proxima

* add proxima genesis_config.json

* branch update_move add docker build

* add table_info storage

* update starcoin-framework repo

* fix clippy warnings

* reset proxima genesis

* update docker build

* update starcoin_framework

* gen new stdlib, reset proxima genesis

* gen new stdlib, reset proxima genesis

* gen new stdlib, reset proxima genesis

* gen new stdlib, reset proxima genesis

* add TableItemProof

* add TableItemProof

* fmt Cargo.toml

* add TableItemProof unit_test

* change StateKeyView serde Field attributes

* fix pre_lib

* [Feature]Add string module (starcoinorg#3626)

* add string

* fix string

* add string in stdlib

* fix stdlib

* new stdlib

* Fix String module native

* Fix cargo move

* update move commit

* add manual dispatch to workflow build and test

* add pr build_test

* fix execute script (starcoinorg#3705)

* add config

* fix run script

* fix mpm package table test (starcoinorg#3715)

* [dev branch]table extension compatible dry run (starcoinorg#3706)

* change dry_out return value

* add DryRunOutputViewV2 for StateKey

* add dry_run_table_item, dry_run_state_key

* remove dry_run_table_item, dry_run_state_key

* reset proxima

* reset proxima

* close starcoinorg#3732

* mpm: remove tmp code

Co-authored-by: LemonHX <[email protected]>
Co-authored-by: nk_ysg <[email protected]>
Co-authored-by: WGB5445 <[email protected]>
nkysg added a commit that referenced this issue Feb 10, 2023
* [compiler] update move
[compiler] Upgrade Move and fix compiler error
[clippy] Fix clippy error

* Merge branch 'master' into update_move

* gen new stdlib

* fix warning: add phantom for merkle distributor

* update move version
fix merkle tree test

* fix Identifier merge

* Update module_upgrade_test.rs

* update script
update move

* check commit

* 1.add table native functions
2.gen new stdlib
3.add table native function gas cost in vmconfig

* 1.add StateKey,MoveExt, SessionId,MoveResolveExt
2.add session finish_with_extension
3.change WriteSet , TransactionOutput, StateKeyView

* add contract_api.json

* 1.add halley genesis

* gen new stdlib

* Merge branch 'master' into update_move

* add move table extension flush

* add statedb support move table extension with commit and flush

* add table item test code

* fix  warnings

* update move repo

* fix fmt

* reset proxima

* add proxima genesis_config.json

* branch update_move add docker build

* add table_info storage

* update starcoin-framework repo

* fix clippy warnings

* gen new stdlib, reset proxima genesis

* add TableItemProof

* add TableItemProof

* fmt Cargo.toml

* add TableItemProof unit_test

* change StateKeyView serde Field attributes

* [Feature]Add string module (#3626)

* add string

* fix string

* add string in stdlib

* new stdlib

* Fix String module native

* Fix cargo move

* add pr build_test

* fix execute script (#3705)

* add config

* fix run script

* fix mpm package table test (#3715)

* [dev branch]table extension compatible dry run (#3706)

* change dry_out return value

* reset proxima

* close #3732

* mpm: remove tmp code

* [dev]Update docker_build.yml docker/setup-buildx-action to 2,  Dockerfile rustup version to 1.25.1 (#3771)

* Update docker_build.yml

* Update Dockerfile

* [dev] remove starcoin-x package,update script and config (#3772)

* [dev] remove starcoin-x package

* remove in toml

* update mold flag

* remove starcoin-x alias

* add back test scripts

* fix powershell

* use BAD_TRANSACTION_FEE_CURRENCY for test

gas_schedule: change max gas unit of test env to 400_000_000

[dev branch] move update use new  gas meter imp (#3795)

* use GasParameter replace costTable

* compat GasCost and GasConstants

* ErrorContext change to ErrorDescription

* update GasConstants member function

* ErrorContext change to ErrorDescription

* update move TableHandle def

* 1.refactor gas-algebra-ext
2.add gas_params for starcoin_vm

* 1.add move stdlib nursery GasParam

* update starcoin_natives gas_params

* update VmConfig to gas_params

* add vmconfig to gas_schedule test

* add gas meter calc function

* update starcoin_vm get gas_params

* temp remove table_info column

* update starcoin-framework

* add test stdlib precompiled

* update move_stdlib params

* Package transaction publish bundle logic

* Update move dep for fixing transactional test harness

* comment StarcoinFramework checkpoint

* compatible legacy AccountDataCache

* move bytecode v6

* update starcoin-framework

Co-authored-by: jolestar <[email protected]>
Co-authored-by: fikgol <[email protected]>
Co-authored-by: WGB5445 <[email protected]>

* abi support u16, u32, u256

* update rpc schema

---------

Co-authored-by: LemonHX <[email protected]>
Co-authored-by: WGB5445 <[email protected]>
Co-authored-by: caojiafeng <[email protected]>
Co-authored-by: jiangying <[email protected]>
Co-authored-by: jolestar <[email protected]>
Co-authored-by: fikgol <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants