Giter Site home page Giter Site logo

diem / move Goto Github PK

View Code? Open in Web Editor NEW
335.0 335.0 131.0 110.38 MB

Home of the Move programming language

License: Apache License 2.0

Shell 0.62% Rust 73.74% Dockerfile 0.04% TypeScript 0.32% Boogie 0.59% TeX 2.80% Jupyter Notebook 0.02% SMT 2.95% Solidity 0.15% JavaScript 1.64% Move 17.14%
blockchain smart-contracts verification

move's Introduction

Note to readers: Silvergate Capital Corporation announced in January 2022 that it acquired intellectual property and other technology assets related to running a blockchain-based payment network from Diem, further investing in its platform and enhancing its existing stablecoin infrastructure.

Diem Logo

Diem Rust Crate Documentation (main) License grcov test history

Diem Core implements a decentralized, programmable distributed ledger which provides a financial infrastructure that can empower billions of people.

Note to Developers

  • Diem Core is a prototype.
  • The APIs are constantly evolving and designed to demonstrate types of functionality. Expect substantial changes before the release.
  • Weโ€™ve launched a testnet that is a live demonstration of an early prototype of the Diem Blockchain software.

Quick Links

Learn About Diem

Getting Started - Try Diem Core

Technical Papers

Governance

Blog

License

Diem Core is licensed as Apache 2.0.

move's People

Contributors

ankushagarwal avatar bmwill avatar bothra90 avatar davidiw avatar dependabot-preview[bot] avatar dependabot[bot] avatar dimroc avatar emmazzz avatar gregnazario avatar huitseeker avatar joshlind avatar junkil-park avatar lightmark avatar ma2bd avatar meng-xu-cs avatar metajack avatar mimoo avatar msmouse avatar phlip9 avatar rexhoffman avatar rustielin avatar sausagee avatar sblackshear avatar sunshowers avatar tnowacki avatar vgao1996 avatar wrwg avatar xli avatar zekun000 avatar zihaoccc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

move's Issues

[move-to-yul] bug in string literal

When the same string literal "error_message" is used twice in the function like:

    public fun safeTransferFrom(from: address, to: address, id: U256, amount: U256, _data: vector<u8>) acquires State {
        require(from == sender() || isApprovedForAll(from, sender()), b"error_message");
        let s = borrow_global_mut<State>(self());
        let mut_balance_from = mut_balanceOf(s, copy id, from);
        require(U256::le(copy amount, *mut_balance_from), b"error_message");

move-to-yul raises the following error.

Error: Variable name $offs_3855568786 already taken in this scope.
   --> <stdin>:943:25:
    |
943 |                         let $offs_3855568786 := add($t19, 32)
    |                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

[Feature Request] Support Windows develop

๐Ÿš€ Feature Request

Motivation

Support windows develop

Is your feature request related to a problem? Please describe.

  1. Move cli support compiles to the Windows binary.
  2. Move compiler process Windows-style line ending (CRLF)

Pitch

Describe the solution you'd like

Describe alternatives you've considered

Are you willing to open a pull request? (See CONTRIBUTING)

Additional context

starcoinorg/starcoin#3131

[Bug] Move Prover proves wrong spec for shifting operator

๐Ÿ› Bug

Move prover proves wrong spec for shifting operator.

To reproduce

Move prover can successfully find the verification error for the following module:

module 0x1234::Test {
    fun shift(x: u64): u64 { x << 8 }
    spec shift { ensures result == x * 256 + 1; }  // The +1 should cause an error
}

But it cannot find the problem for this almost identical version:

module 0x1234::Test {
    fun shift(x: u64): u64 { x << 7 }
    spec shift { ensures result == x * 128 + 1; }  // The +1 should cause an error
}

Expected Behavior

MVP should report "post-condition does not hold" for both version of the code.

Additional context

After some investigation, I found that in move-prover/boggie-backend/src/prelude/prelude.bpl, $shl and $shr are defined to support shifting by 8, 16, 32, and 64-bits only. Is that feature on purporse or a bug?

Cannot identify the number of signers in adapter layer

๐Ÿš€ Feature Request

Motivation

When trying to use the latest move, come across a problem.

We automatically add signer to the script function call if we find the function requires signers (here

fn create_signers_and_arguments(
). This checks happens at VM runtime. It has access to the loader, which can load the script or script function to read the script/script_function parameter to determine how many signers are needed. But this loader seems not exposed to adapter layer.

With the new move revision (https://github.com/diem/move/pull/175/files), to use the new execute_entry_function, it only take args, which could contains both signer and txn args. we need to determine the number of signers to add to args at adapter layer now. However, some script function requires one signer and some doesnโ€™t (eg: create_account). since loader is not exposed in the adapterโ€™s session, I currently donโ€™t find a way to calculate the number of signer in script or script function from adapter. Any suggestions or workarounds?

Pitch

Need to expose either the loader to adapter layers or functions in session to help determine the number of signers in the the script function or script

[Feature Request] TypeTable

๐Ÿš€ Feature Request

Motivation

I have mentioned the idea of TypeTable in the documentation of Table, and I describe it in more detail here.

According to the implementation of Table(#150), we get:

module Std::Table {
    native struct Table<K, V: store> has store;
    native fun create<K, V>(): Table<K, V>
    native fun destroy<K, V>(t: Table<K, V>);
    native fun insert<K, V>(t: &mut Table<K, V>, k: &K, v: V);
    native fun remove<K, V>(t: &mut Table<K, V>, k: &K): V;
    native fun contains_key<K, V>(t: &Table<K, V>, k: &K): bool;
    native fun borrow<K, V>(t: &Table<K, V>, k: &K): &V;
    native fun borrow_mut<K, V>(t: &mut Table<K, V>, k: &K): &mut V;
}

But this Table can only use type K's value as the key, not type K as the key like borrow_global.

So I suggest introducing TypeTable with the basic operations described below:

module Std::TypeTable {
   native struct TypeTable has store;
   native fun create(): TypeTable
   native fun destroy(t: TypeTable);
   native fun insert<T>(t: &mut TypeTable, v: T);
   native fun remove<T>(t: &mut TypeTable<K>): T;
   native fun contains_key<T>(t: &TypeTable<T>): bool;
   native fun borrow<T>(t: &TypeTable): &T;
   native fun borrow_mut<T>(t: &mut TypeTable<T>): &mut T;
}

Now, we can define a AccountStorage struct in Move:

module Std::Account{
   struct AccountStroage{
      resources: TypeTable,
      moudles: Table<Identifer,vector<u8>>,
   }
}

Then we bind the table when Account create, such as:

module Std::Account{
    public fun create_account(addr: address){
        let resources = TypeTable::create();
        let modules = Table::create<Identifer,vector<u8>>();
        let account_storage = AccountStorage{
            resources,
            modules,
         };
         native_save_account(addr,account_storage);
    }

    public fun borrow<T>(addr:address):&T{
      let account_storage = native_get_account_staroge(addr);
      //This expression is not available in the current Move
      //We can not return ref like this, but we can ignore it now.
      return TypeTable::borrow<T>(&account_storage.resources);
    }

    public fun move_to<T>(signer:&signer, t:T){
      //if do not want to limit signer, can use address.
      let addr = Signer:address_of(signer);
      let account_storage = native_get_account_staroge(addr);
      TypeTable::insert(&mut account_storage.resources,t);
    }
   
    //We can update or deploy code in Move now, like `create2` in ethereum.
    public fun update_module(signer:&signer, name:Identifer, code:vector<u8>){
       let account_storage = native_get_account_staroge(addr);
       account_storage.modules.insert(name, code);
    }
}
  • Now, borrow_global(address) = Account::borrow(address),
    and move_to(siger) = Account::move_to(siger), global_storage operation can been eliminate.
  • The transaction ChangeSet are all table_changes.
  • Every Move chain framework can customize their own account storage via the TypeTable and native function.

This feature can implement via an extension like Table and the backend storage is the same as Table, but TypeTable needs the same security guarantees as borrow_global.

We have two approaches to achieving this goal:

  1. Introduce TypeTable into core instead of extension, add security restrictions to TypeTable::borrow similar to borrow_global.
  2. Introduce the visibility of Struct and let the smart contract developer can control the access of Struct, see issue #157.

[Feature Request] Share Move libraries between Move blockchain projects

๐Ÿš€ Feature Request

Motivation

Now we have several Blockchain projects using Move, but it is hard to share Move libraries between different blockchains.

Perhaps the ideal way of Move project dependency like:


                                     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                                     โ”‚Move Std lib โ”‚
                                     โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜


                         โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”          โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                         โ”‚Move DeFi libโ”‚          โ”‚Move Commons lib   โ”‚
                         โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜          โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜



                                                                      โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                                                                      โ”‚ Move Chain independent lib    โ”‚
                                                                      โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜


โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ StarcoinFramework โ”‚     โ”‚ DiemFramework     โ”‚    โ”‚ 0lFramework       โ”‚   โ”‚ PontemFramework   โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜     โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜


  1. Move std lib: provide the basic modules for Move language.
  2. Move DeFi lib: provide the basic modules for DeFi, such as Token and NFT standards.
  3. Move Commons lib: provide some utils module for Move language, like java's apache-commons.
  4. Frameworks: the chain-specific modules.

However, this is not yet possible and there is an address conflict issue.

Move stdlib uses the 0x1 address and will conflict with the framework. For example, if StarcoinFramework defines a dependency on Move stdlib in Move.toml, the Move project will produce an error.

One approach to resolve this is to auto-embed Move stdlib and Move DeFi lib to the chain framework, but this also has the problem of naming conflicts.

I think this is very important for building the Move ecosystem, and this is an advantage of Move over Solidity ecosystem.

Is your feature request related to a problem? Please describe.

Pitch

Describe the solution you'd like

Describe alternatives you've considered

Are you willing to open a pull request? (See CONTRIBUTING)

Additional context

[Bug] [move] [compiler] incorrect error message when using wrong operator

๐Ÿ› Bug

I ran through a simple move tutorial and I accidentally used '=' when I meant '==' and the error message told me I was missing an end parenthesis when it is clear from the error message that I am not. See embedded screenshot below.

To reproduce

Code snippet to reproduce

// check if accessor functions return correct values
assert!(magic(&sword) == 42 && strength(&sword) = 7, 1);

Stack trace/error message
Screen Shot 2022-03-16 at 5 15 30 PM

Expected Behavior

Error should flag incorrect use of an assignment operator or something along these lines

System information

Mac OS 12.2.1

Questions on instruction gas cost

A few questions around how we chose the gas cost for some of the instructions.
In this table:

pub fn bytecode_instruction_costs() -> Vec<(Bytecode, GasCost)> {

  1. MoveTo writes new data into the storage, while MoveFrom removes data from storage. However, MoveFrom (459) is significantly more expensive than MoveTo (13). Why is MoveTo so cheap? What's the rationale behind this choice? Isn't MoveFrom considered as data deletion and should be encouraged instead of punished?
  2. Why is MoveFromGeneric (13) significantly cheaper than MoveFrom (459)?
  3. Why is ImmBorrowGlobal (23) more expensive than MutBorrowGlobal (21)? Should mutable borrows be more expensive since we expect mutations?
  4. We don't seem to distinguish the cost between global storage accesses and stack memory accesses. For instance, when we compute the cost of WriteRef, we don't really look at whether the reference is pointing to the stack or to a global storage. This makes the cost of global storage accesses (both reads and writes) way too cheap than it should be. Is this intentional?
  5. When we compute the gas cost for a native function call (
    let gas_amt = table.native_cost(native_table_idx.into());
    let memory_size = AbstractMemorySize::new(std::cmp::max(1, size) as GasCarrier);
    debug_assert!(memory_size.get() > 0);
    gas_amt.total().mul(memory_size)
    ), we are first adding the computation cost and memory cost, and then multiply the sum with the memory size. Shouldn't we only multiple the memory cost with memory size? Is this a bug?

cc @tzakian

[Feature Request] Update CONTRIBUTING.md

This was copied over from Diem and is also somewhat Diem-specific. It should be updated to reflect the smallest set of setup instructions required to start using Move.

[Feature Request] Move signature enforcement for script functions from VM -> adapter(s)

Currently, public(script) visibility is the only way to declare an entrypoint in Move. The VM/verifier enforce two things about such functions:

  1. They can only be called by other public(script) functions
  2. There are restrictions on the structure of the function signature described here

This feature suggestion proposes to keep (1) and drop (2). The reason is that every adapter has the concept of โ€œentrypointโ€ and benefits from the enforcement of (1), but the restrictions in (2) are specific to Diem-like adapters. Thus, it makes sense to move those checks thereโ€“let each adapter decide what sorts of entrypoints are valid for its clients.

This is actually eliminating a feature that limits the design space of adapters, not adding a new one. All we need to do is gate the relevant code in the verifier and source language by the relevant bytecode version.

[Bug] Serde change causing compile error in the generated RUST

๐Ÿ› Bug

This merged PR https://github.com/diem/move/pull/44/files introduced this change https://github.com/diem/move/blob/main/language/move-core/types/src/language_storage.rs#L35.
It would lead the the RUST code generated to use lower cast 'struct' as a enum variant, while the struct is a reserved keyword for RUST.

As shown in the screenshot below, the right is the RUST code generated from a move revision before PR/44 and left is the RUST code generated after PR/44. The left code won't compile
Screen Shot 2022-03-14 at 1 04 31 PM

To reproduce

Code snippet to reproduce

pub fn get_registry() -> Result<Registry> {
    let mut tracer =
        Tracer::new(TracerConfig::default().is_human_readable(bcs::is_human_readable()));
    let mut samples = Samples::new();
    // 1. Record samples for types with custom deserializers.
    trace_crypto_values(&mut tracer, &mut samples)?;
    tracer.trace_value(&mut samples, &event::EventKey::random())?;

    tracer.trace_type::<contract_event::ContractEvent>(&samples)?;
    tracer.trace_type::<language_storage::TypeTag>(&samples)?; // this line is where the problem occurs
    tracer.trace_type::<transaction::Transaction>(&samples)?;
    tracer.trace_type::<transaction::TransactionArgument>(&samples)?;
    tracer.trace_type::<transaction::VecBytes>(&samples)?;
    tracer.trace_type::<transaction::TransactionPayload>(&samples)?;
    tracer.trace_type::<transaction::WriteSetPayload>(&samples)?;
    tracer.trace_type::<transaction::authenticator::AccountAuthenticator>(&samples)?;
    tracer.trace_type::<transaction::authenticator::TransactionAuthenticator>(&samples)?;
    tracer.trace_type::<write_set::WriteOp>(&samples)?;
    tracer.registry()
}

Stack trace/error message

bos-MacBook-Pro:framework bowu$ cargo build
   Compiling aptos-types v0.1.0 (/Users/bowu/Desktop/aptos-types)
error: expected identifier, found keyword `struct`
  --> /Users/bowu/Desktop/aptos-types/src/lib.rs:90:5
   |
90 |     struct(StructTag),
   |     ^^^^^^ expected identifier, found keyword
   |
help: you can escape reserved keywords to use them as identifiers
   |
90 |     r#struct(StructTag),
   |     ~~~~~~~~

Expected Behavior

We should use capital case https://github.com/diem/move/blob/main/language/move-core/types/src/language_storage.rs#L35

[Bug]unexpected error message "Unable to find script in file sources/xxx.move" when execute command "move sandbox run sources/xxx.move"

๐Ÿ› Bug

Incorrect processing logic when execute command "move sandbox run". Current move-package implementation using the "main" function name as the file name (may add a suffix if there are more than one scripts using the same main function name) when saving the compiled script to dist other than the original script file name. and when using command "move sandbox run" it will compare the file name of saved compiled script and the file name user input, and may output error such as Error: Unable to find script in file "sources/xx.move" if the "main" function name in the script is not the same as the script file name

To reproduce

create package test

move package new test

create test script named test_script.move under directory sources/
and add the following content to test_script.move

// sources/test__script.move
script {
  use Std::Debug;

  fun test() {
    let num: u64 = 100;
    Debug::print(&num);
  }
}

run script using

move sandbox run souces/test_script.move

and you will see the following error

Stack trace/error message

Error: Unable to find script in file "sources/test_script.move"

Expected Behavior

Expected output should be
[debug] 100

Although we can change the function name of test to test_script (same as the script file name) to get the expected behavior, but it's just a suggested coding convention of using the same name of the script file name as the "main" function name in the script, it is not a must. Not event to say if there are more than one script using the same main function name, the move-compiler will append a suffix to the function name and move-package will use that name when save the compiled packages to disk.
Just using the file name to determine to compiled script is not enough, it would be better to use the FileHash to determine the compiled script to use when execute "move sandbox run"

System information

move-cli 0.1.
rustc 1.58.1 (db9d1b20b 2022-01-20)
CentOS Linux release 7.9.2009 (Core)

[move-prover] Boogie exited with compilation errors when "--trace" is set

When the prover is run against several Move modules in the DPN with the option โ€œโ€”traceโ€, output.bpl cannot pass compilation. To reproduce the error, using the following command:

move package -p diem-move/diem-framework/DPN/sources/ prove -t VASP -- โ€”trace

The output:

Error: [internal] boogie exited with compilation errors:
output.bpl(8284,62): Error: undeclared identifier: a
output.bpl(8290,66): Error: undeclared identifier: a
output.bpl(8427,62): Error: undeclared identifier: a
output.bpl(8433,66): Error: undeclared identifier: a
output.bpl(8450,70): Error: undeclared identifier: parent
output.bpl(8457,73): Error: undeclared identifier: parent
output.bpl(8463,78): Error: undeclared identifier: parent
output.bpl(8592,62): Error: undeclared identifier: a
output.bpl(8598,66): Error: undeclared identifier: a
output.bpl(8615,70): Error: undeclared identifier: parent
output.bpl(8622,73): Error: undeclared identifier: parent
output.bpl(8628,78): Error: undeclared identifier: parent
output.bpl(8950,63): Error: undeclared identifier: a
output.bpl(8956,67): Error: undeclared identifier: a
output.bpl(8973,71): Error: undeclared identifier: parent
....
37 name resolution errors detected in output.bpl

The following code in output.bpl triggers the compilation failure:

// assume Identical($t5, exists<VASP::ChildVASP>(a)) at ./sources/VASP.move:252:37+20
assume {:print "$at(46,10573,10593)"} true;
assume ($t5 == $ResourceExists($1_VASP_ChildVASP_$memory, a));

The Move code at ./sources/VASP.move:252:37+20:
ensures forall a: address : exists(a) == old(exists(a));

[Feature Request] Make VM parametric in event format

To support user-defined events emitted during execution, the VM keeps a Vec<Event> log, where Event as defined as

pub type Event = (Vec<u8>, u64, TypeTag, Vec<u8>)

here. In this representation, the event's user-defined type is in the TypeTag and the event value of this type is in the Vec<u8>.

However, there's no reason why events must have this structure--conceptually, the VM could just as easily allow the adapter to choose the structure of Event. This would be useful for an adapter we are currently working on where events look a bit different, and I expect that future adapters will find other uses of events that might not want to use this structure.

Note: the Move stdlib has an Event module and accompanying emit native function that do rely on the structure the VM assumes. We should think carefully about how we want to handle this. One option is splitting out a part of the Move stdlib that is fully generic and would be used by every conceivable adapter (e.g., Vector, Signer, Option, BitVector, ASCII, FixedPoint32). But that's a topic for another issue.

RUSTSEC in dependencies in branch main

Found RUSTSEC in dependencies in job https://github.com/diem/move/actions/runs/5230409004

    Fetching advisory database from `https://github.com/RustSec/advisory-db.git`
      Loaded 548 security advisories (from /opt/cargo/advisory-db)
    Updating crates.io index
    Scanning Cargo.lock for vulnerabilities (540 crate dependencies)
Crate:     chrono
Version:   0.4.19
Title:     Potential segfault in `localtime_r` invocations
Date:      2020-11-10
ID:        RUSTSEC-2020-0159
URL:       https://rustsec.org/advisories/RUSTSEC-2020-0159
Solution:  Upgrade to >=0.4.20
Dependency tree:
chrono 0.4.19
โ”œโ”€โ”€ x 0.1.0
โ”œโ”€โ”€ tera 1.16.0
โ”‚   โ””โ”€โ”€ move-prover-boogie-backend 0.1.0
โ”‚       โ”œโ”€โ”€ move-to-yul 0.1.0
โ”‚       โ”‚   โ”œโ”€โ”€ move-unit-test 0.1.0
โ”‚       โ”‚   โ”‚   โ”œโ”€โ”€ move-table-extension 0.1.0
โ”‚       โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ move-vm-test-utils 0.1.0
โ”‚       โ”‚   โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ test-generation 0.1.0
โ”‚       โ”‚   โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ move-vm-integration-tests 0.1.0
โ”‚       โ”‚   โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ move-unit-test 0.1.0
โ”‚       โ”‚   โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ move-transactional-test-runner 0.1.0
โ”‚       โ”‚   โ”‚   โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ move-vm-transactional-tests 0.1.0
โ”‚       โ”‚   โ”‚   โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ move-ir-compiler-transactional-tests 0.1.0
โ”‚       โ”‚   โ”‚   โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ move-compiler-transactional-tests 0.1.0
โ”‚       โ”‚   โ”‚   โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ bytecode-verifier-transactional-tests 0.1.0
โ”‚       โ”‚   โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ language-benchmarks 0.1.0
โ”‚       โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ move-vm-integration-tests 0.1.0
โ”‚       โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ move-unit-test 0.1.0
โ”‚       โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ move-cli 0.1.0
โ”‚       โ”‚   โ”‚   โ”‚       โ”œโ”€โ”€ move-transactional-test-runner 0.1.0
โ”‚       โ”‚   โ”‚   โ”‚       โ”œโ”€โ”€ move-table-extension 0.1.0
โ”‚       โ”‚   โ”‚   โ”‚       โ”œโ”€โ”€ move-stdlib 0.1.1
โ”‚       โ”‚   โ”‚   โ”‚       โ”‚   โ”œโ”€โ”€ test-generation 0.1.0
โ”‚       โ”‚   โ”‚   โ”‚       โ”‚   โ”œโ”€โ”€ move-vm-integration-tests 0.1.0
โ”‚       โ”‚   โ”‚   โ”‚       โ”‚   โ”œโ”€โ”€ move-unit-test 0.1.0
โ”‚       โ”‚   โ”‚   โ”‚       โ”‚   โ”œโ”€โ”€ move-transactional-test-runner 0.1.0
โ”‚       โ”‚   โ”‚   โ”‚       โ”‚   โ”œโ”€โ”€ move-to-yul 0.1.0
โ”‚       โ”‚   โ”‚   โ”‚       โ”‚   โ”œโ”€โ”€ move-table-extension 0.1.0
โ”‚       โ”‚   โ”‚   โ”‚       โ”‚   โ”œโ”€โ”€ move-stackless-bytecode 0.1.0
โ”‚       โ”‚   โ”‚   โ”‚       โ”‚   โ”‚   โ”œโ”€โ”€ spec-flatten 0.1.0
โ”‚       โ”‚   โ”‚   โ”‚       โ”‚   โ”‚   โ”œโ”€โ”€ read-write-set 0.1.0
โ”‚       โ”‚   โ”‚   โ”‚       โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ move-cli 0.1.0
โ”‚       โ”‚   โ”‚   โ”‚       โ”‚   โ”‚   โ”œโ”€โ”€ prover-mutation 0.1.0
โ”‚       โ”‚   โ”‚   โ”‚       โ”‚   โ”‚   โ”œโ”€โ”€ prover-lab 0.1.0
โ”‚       โ”‚   โ”‚   โ”‚       โ”‚   โ”‚   โ”œโ”€โ”€ move-to-yul 0.1.0
โ”‚       โ”‚   โ”‚   โ”‚       โ”‚   โ”‚   โ”œโ”€โ”€ move-stackless-bytecode-interpreter 0.1.0
โ”‚       โ”‚   โ”‚   โ”‚       โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ move-unit-test 0.1.0
โ”‚       โ”‚   โ”‚   โ”‚       โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ move-transactional-test-runner 0.1.0
โ”‚       โ”‚   โ”‚   โ”‚       โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ bytecode-interpreter-testsuite 0.1.0
โ”‚       โ”‚   โ”‚   โ”‚       โ”‚   โ”‚   โ”œโ”€โ”€ move-prover-boogie-backend 0.1.0
โ”‚       โ”‚   โ”‚   โ”‚       โ”‚   โ”‚   โ””โ”€โ”€ move-prover 0.1.0
โ”‚       โ”‚   โ”‚   โ”‚       โ”‚   โ”‚       โ”œโ”€โ”€ spec-flatten 0.1.0
โ”‚       โ”‚   โ”‚   โ”‚       โ”‚   โ”‚       โ”œโ”€โ”€ prover-mutation 0.1.0
โ”‚       โ”‚   โ”‚   โ”‚       โ”‚   โ”‚       โ”œโ”€โ”€ prover-lab 0.1.0
โ”‚       โ”‚   โ”‚   โ”‚       โ”‚   โ”‚       โ”œโ”€โ”€ move-stdlib 0.1.1
โ”‚       โ”‚   โ”‚   โ”‚       โ”‚   โ”‚       โ”œโ”€โ”€ move-errmapgen 0.1.0
โ”‚       โ”‚   โ”‚   โ”‚       โ”‚   โ”‚       โ”‚   โ”œโ”€โ”€ move-stdlib 0.1.1
โ”‚       โ”‚   โ”‚   โ”‚       โ”‚   โ”‚       โ”‚   โ”œโ”€โ”€ move-prover 0.1.0
โ”‚       โ”‚   โ”‚   โ”‚       โ”‚   โ”‚       โ”‚   โ””โ”€โ”€ move-cli 0.1.0
โ”‚       โ”‚   โ”‚   โ”‚       โ”‚   โ”‚       โ”œโ”€โ”€ move-docgen 0.1.0
โ”‚       โ”‚   โ”‚   โ”‚       โ”‚   โ”‚       โ”‚   โ”œโ”€โ”€ move-stdlib 0.1.1
โ”‚       โ”‚   โ”‚   โ”‚       โ”‚   โ”‚       โ”‚   โ”œโ”€โ”€ move-prover 0.1.0
โ”‚       โ”‚   โ”‚   โ”‚       โ”‚   โ”‚       โ”‚   โ””โ”€โ”€ move-package 0.1.0
โ”‚       โ”‚   โ”‚   โ”‚       โ”‚   โ”‚       โ”‚       โ”œโ”€โ”€ move-table-extension 0.1.0
โ”‚       โ”‚   โ”‚   โ”‚       โ”‚   โ”‚       โ”‚       โ”œโ”€โ”€ move-stdlib 0.1.1
โ”‚       โ”‚   โ”‚   โ”‚       โ”‚   โ”‚       โ”‚       โ”œโ”€โ”€ move-cli 0.1.0
โ”‚       โ”‚   โ”‚   โ”‚       โ”‚   โ”‚       โ”‚       โ””โ”€โ”€ move-analyzer 0.0.0
โ”‚       โ”‚   โ”‚   โ”‚       โ”‚   โ”‚       โ”œโ”€โ”€ move-cli 0.1.0
โ”‚       โ”‚   โ”‚   โ”‚       โ”‚   โ”‚       โ””โ”€โ”€ move-abigen 0.1.0
โ”‚       โ”‚   โ”‚   โ”‚       โ”‚   โ”‚           โ”œโ”€โ”€ move-prover 0.1.0
โ”‚       โ”‚   โ”‚   โ”‚       โ”‚   โ”‚           โ””โ”€โ”€ move-package 0.1.0
โ”‚       โ”‚   โ”‚   โ”‚       โ”‚   โ”œโ”€โ”€ move-compiler 0.0.1
โ”‚       โ”‚   โ”‚   โ”‚       โ”‚   โ”‚   โ”œโ”€โ”€ test-generation 0.1.0
โ”‚       โ”‚   โ”‚   โ”‚       โ”‚   โ”‚   โ”œโ”€โ”€ spec-flatten 0.1.0
โ”‚       โ”‚   โ”‚   โ”‚       โ”‚   โ”‚   โ”œโ”€โ”€ prover-mutation 0.1.0
โ”‚       โ”‚   โ”‚   โ”‚       โ”‚   โ”‚   โ”œโ”€โ”€ prover-lab 0.1.0
โ”‚       โ”‚   โ”‚   โ”‚       โ”‚   โ”‚   โ”œโ”€โ”€ move-vm-runtime 0.1.0
โ”‚       โ”‚   โ”‚   โ”‚       โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ test-generation 0.1.0
โ”‚       โ”‚   โ”‚   โ”‚       โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ move-vm-integration-tests 0.1.0
โ”‚       โ”‚   โ”‚   โ”‚       โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ move-unit-test 0.1.0
โ”‚       โ”‚   โ”‚   โ”‚       โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ move-transactional-test-runner 0.1.0
โ”‚       โ”‚   โ”‚   โ”‚       โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ move-table-extension 0.1.0
โ”‚       โ”‚   โ”‚   โ”‚       โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ move-stdlib 0.1.1
โ”‚       โ”‚   โ”‚   โ”‚       โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ move-cli 0.1.0
โ”‚       โ”‚   โ”‚   โ”‚       โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ move-async-vm 0.1.0
โ”‚       โ”‚   โ”‚   โ”‚       โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ language-benchmarks 0.1.0
โ”‚       โ”‚   โ”‚   โ”‚       โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ diem-framework-natives 0.0.0
โ”‚       โ”‚   โ”‚   โ”‚       โ”‚   โ”‚   โ”‚       โ””โ”€โ”€ df-cli 0.1.0
โ”‚       โ”‚   โ”‚   โ”‚       โ”‚   โ”‚   โ”œโ”€โ”€ move-vm-integration-tests 0.1.0
โ”‚       โ”‚   โ”‚   โ”‚       โ”‚   โ”‚   โ”œโ”€โ”€ move-unit-test 0.1.0
โ”‚       โ”‚   โ”‚   โ”‚       โ”‚   โ”‚   โ”œโ”€โ”€ move-transactional-test-runner 0.1.0
โ”‚       โ”‚   โ”‚   โ”‚       โ”‚   โ”‚   โ”œโ”€โ”€ move-to-yul 0.1.0
โ”‚       โ”‚   โ”‚   โ”‚       โ”‚   โ”‚   โ”œโ”€โ”€ move-stdlib 0.1.1
โ”‚       โ”‚   โ”‚   โ”‚       โ”‚   โ”‚   โ”œโ”€โ”€ move-stackless-bytecode 0.1.0
โ”‚       โ”‚   โ”‚   โ”‚       โ”‚   โ”‚   โ”œโ”€โ”€ move-prover 0.1.0
โ”‚       โ”‚   โ”‚   โ”‚       โ”‚   โ”‚   โ”œโ”€โ”€ move-package 0.1.0
โ”‚       โ”‚   โ”‚   โ”‚       โ”‚   โ”‚   โ”œโ”€โ”€ move-model 0.1.0

[Bug] Inconsistency between `Move.toml` and source code addresses

๐Ÿ› Bug

Addresses parsing in the Move.toml performed by the https://github.com/diem/move/blob/main/language/tools/move-package/src/source_package/manifest_parser.rs#L278 and allows addresses in the form of

A1 = "0xefff111" # with prefix
A2 = "efffefffefffefffefff" # without prefix

On the other hand, in Move source code, parsing is performed by the https://github.com/diem/move/blob/main/language/move-compiler/src/shared/mod.rs#L67 and allows for the

let a = @0xAAFFEE;  // hex with 0x prefix
let b = @111222; // decimal without any prefix

It all basically means that

// Move.toml
HelloBlockchain = "11111111111111111111111111111111"
// main.move
assert!(@HelloBlockchain == @11111111111111111111111111111111, 1);

fails with assert, as those address values are of different bases.

Is this intentional?

[Bug]cant run debug_script.move

when i run the debug_script.move. here are two issue:
1ใ€Error: Unable to find package manifest in '.' or in its parents. i have solved it through create a new package named manifest.
2ใ€error[E01001]: invalid character
โ”Œโ”€ ./sources/debug_script.move:1:9
โ”‚
1 โ”‚ script {
' found when reading file. Only ASCII printable characters, tabs (\t), and line endings (\n) are permitted.

[Documentation][IDE] Add a reference to the docs for the intellij-move IDE

There's a project called intellij-move which is Move Language Plugin for Jetbrains IDEs. It supports all of them, including the free PyCharm Community. IDE should suggest installing it when any .move file is opened, or just download it from the Marketplace in Settings -> Plugins section.
We started it in the middle of 2020, and now it's in quite good shape.

Supported features are:

  • Parsing of both Move language and MSL
  • Name resolution in Move and MSL
  • Types and type inference in Move
  • Autoformatter
  • Support for Move.toml, move-cli commands, local deps, git deps (partially)

It would be great to have some official recognition of the project, maybe add a link in the docs.

I know Diem started their own language server at https://github.com/diem/move/tree/main/language/move-analyzer, based on rust-analyzer libraries, but it has only some initial implementation. At Pontem, we tried this approach too (code at move-language-server) but it was scrapped when we realized that Diem has started move-analyzer. It has a little bit of parser implemented, I can try to finish the parser later and merge it upstream if needed.

[Feature Request] Add u256 support

๐Ÿš€ Feature Request

Support u256 primitive type.
May also consider u16, u32, and signed integer type like i8, i16, i32 , i64, i128, i256.

A similar discussion exists in diem repo diem/diem#8504

Motivation

Is your feature request related to a problem? Please describe.
u256 are common used in solidity. Lack of u256 cause many problems when bridging asset or protocol into Move contracts.

And since Move doesn't float types, we need a large integer type to simulate float calculation for u128.

Pitch

A builtin support for u256 is what I'm expecting for.

alternative is using native structs, but it's tedious.

Additional context

[Bug] 16 Bytes used in language/testing-infra when switching to 20-Byte AccountAddress

๐Ÿ› Bug

To reproduce

(1) use address20 feature in the toml dependency file as below
move-core-types = { git = "https://github.com/diem/move", rev = "90b018e5e6a14714154a2c9576325b716bc8ca0d", features = ["address20"]}

(2) and then run
cargo xclippy --all-targets

(3) notice multiple errors
https://github.com/diem/move/blob/main/language/testing-infra/transactional-test-runner/src/tasks.rs#L30 number is still hard coded as 128 bit. It would fail if the account address uses 20 bytes

https://github.com/diem/move/blob/main/language/testing-infra/transactional-test-runner/src/vm_test_harness.rs#L37 this line failed to compile when account address uses 20 bytes.

Code snippet to reproduce

Stack trace/error message

error[E0308]: mismatched types
  --> /Users/bowu/.cargo/git/checkouts/move-cd543da0a1ae83ac/90b018e/language/testing-infra/transactional-test-runner/src/tasks.rs:30:28
   |
30 |     Ok(AccountAddress::new(number.to_be_bytes()))
   |                            ^^^^^^^^^^^^^^^^^^^^ expected an array with a fixed size of 20 elements, found one with 16 elements

Expected Behavior

Expect no errors

[Bug] EVM mode silences package errors in move-cli

@vgao1996 I had an issue where the CLI silenced the output from the package manager in EVM mode.

For language/tools/move-cli/tests/move_unit_tests/assign_dev_addr_for_dep/Move.toml
If you have B = "0x2"

I would expect my new error from the package manager to show up, instead I get:

test run_all::assign_dev_addr_for_dep/args.evm.txt ... FAILED
Error: Expected output differs from actual output:
Command `package test --evm`:
BUILDING MoveStdlib
BUILDING Bar
BUILDING Foo
Running Move unit tests
[ PASS    ] 0x2::M::nop
Test result: OK. Total tests: 1; passed: 1; failed: 0
Error: Unable to resolve packages for package 'Foo'

Caused by:
    0: While resolving dependency 'Bar' in package 'Foo'
    1: Unable to resolve package dependency 'Bar'
    2: While resolving dependency 'MoveStdlib' in package 'Bar'
    3: While processing dependency 'MoveStdlib'
    4: Unable to find package manifest for 'MoveStdlib' at "Move.toml/./dep/../../../../../../move-stdlib"

[Feature Request] add eviction API's to VM's module and type caches

Problem

The Move VM keeps a cache of the modules it has previously deserialized, verified, and linked (and similar for types and scripts). However, there are no API's for removing entries from these caches, nor is there any eviction policy. This means that an instance of the VM is kept alive and continues encountering new modules, these caches will grow without bound and eventually cause memory issues.

This was not an issue in Diem because the set of modules was fixed and VM instances were ephemeral (i.e., the system starts a new VM instance for each block). But other uses of Move may want to use the VM in a different way--e.g., we are considering a system where a server keeps an instance of the VM alive indefinitely, and we expect the server to encounter many different modules.

Proposed solution

I think we should start with exposing API's that:

  1. Return the size of all three caches in bytes
  2. Clear all caches

This is rather crude, but these API's will at least allow adapters to prevent the caches from growing beyond N bytes.

In time, I can imagine VM config's that allow adapter's specifying various eviction policies (e.g., a LFU cache that drops the long tail of infrequently used modules seems like a sensible one), but I'd rather move forward with something simple for now and use experience/data to help us design something fancier.

[Feature Request] Implementing more DeFi contracts in Move

๐Ÿš€ Feature Request

Motivation

DeFi contracts are gaining lots of attention these days as they bring new innovation to the crypto and finance market. However, most of the smart contracts are written in solidity. It is important for us to see if we can implement something similar in Move and use this experience to access our gap to a wilder adoption of Move.

Pitch

Under experimental folder, we've already implemented a few interesting contracts, including a primitive token type and a simplified uniswap protocol. It would be nice if we can implement more code like this to access the usability of Move in the DeFi space.

If you would like to contribute, please refer to this [tutorial] to see how the basic-coin example is implemented and tested. This should offer you an overview of the developing flow of a Move package.

Here's a non-exhaustive list of DeFi contract that we might want to implement:

  • Compound
  • dydx
  • Uniswap
  • Oracle in Move?

Feel free to extend this list if there's any emerging new smart contracts.

[Bug] cyclic_multi_module_publish test is broken in CI

In #10 we verified that the cyclic_multi_module_publish test would fail even with an empty/dummy change. This indicates that this test is broken. #10 temporarily removed part of the test to make it pass. But we should investigate on why it's broken. Could it be due to the non-determinism of the order of modules being processed?

[evm] revert with a custom error message

We cannot write a Move contract that can pass the test language/evm/hardhat-examples/contracts/Revert.test.js

The reason is that:
Move contracts abort with error codes, and cannot abort with custom error messages (in string).
On the other hand, Solidity contracts can revert with custom error messages.

Installation fails on MacOS due to broken .NET dependency

When running the dev_setup.sh script installation of .NET on MacOS (M1) fails with the following error:

dotnet-install: Attempting to download using primary link https://dotnetcli.azureedge.net/dotnet/Sdk/5.0.404/dotnet-sdk-5.0.404-osx-arm64.tar.gz
curl: (22) The requested URL returned error: 404
dotnet-install: The resource at primary link 'https://dotnetcli.azureedge.net/dotnet/Sdk/5.0.404/dotnet-sdk-5.0.404-osx-arm64.tar.gz' is not available.
dotnet-install: Attempting to download using legacy link https://dotnetcli.azureedge.net/dotnet/Sdk/5.0.404/dotnet-dev-osx-arm64.5.0.404.tar.gz
curl: (22) The requested URL returned error: 404
dotnet-install: The resource at legacy link 'https://dotnetcli.azureedge.net/dotnet/Sdk/5.0.404/dotnet-dev-osx-arm64.5.0.404.tar.gz' is not available.
dotnet_install: Error: Could not find `.NET Core SDK` with version = 5.0.404
dotnet_install: Error: Refer to: https://aka.ms/dotnet-os-lifecycle for information on .NET Core support

It seems like the problem is related to .NET version 6 now being the default one which might have affected what's available for CI installations.

[Feature Request] Introduce Visibility to Struct

๐Ÿš€ Feature Request

Motivation

Currently, Move's structs use implicit visibility, e.g.

struct Foo{
   f1: u64,
}

is equivalent to.

public struct Foo{
   private f1: u64, 
}

Also, an implicit global storage access restriction is used to ensure that a struct can only be borrowed in the module in which it is defined.

This is actually equivalent to a conditional visibility constraint and has the same effect as adding a private visibility constraint to the struct.

private struct Foo has key{
}

So I propose to introduce the visibility of structs. This leaves it up to the smart contract developer to decide on access control for the global storage and the struct fields.

For example.

module MyModule {

   public struct Foo has key{
        public f1:u64,
   }

   private struct Bar has key{
        f1:u64,
   }
  
   public fun do_some(){
       let foo = borrow_global<Foo>();
       let bar = borrow_global<Bar>();
      // Both of these work 
   }
}

module XXX {
    use MyModule::Foo;
    public fun so_some(){
        let foo = borrow_global<Foo>();
        let f1 = foo.f1

        let bar = borrow_global<Bar>();
        // the first one will succeed, the second one will fail
    }
}

Of course, compatibility is a bigger problem, this is just an idea. If it works, I can do more work on it.

[evm] issue in emitting `Transfer` events

Emitting Transfer events causes the following errors:

1) Event (the Move contract)
       emitTransfer should emit a Transfer event:
     Error: data out-of-bounds (length=0, offset=32, code=BUFFER_OVERRUN, version=abi/5.6.0)

2) Contract: Truffle-style testing for Event (the Move contract)
       emits an Transfer event:

      No 'Transfer' events found
      + expected - actual

      -false
      +true

For more details, see Event.test.js and Event.truffle.test.js in evm/hardhat-examples/test.

[Bug] native functions are bound to a hardcoded address (0x1) in unit tests (invoked through move-cli)

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: [],
โ”‚ }
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€

[Feature Request] Support type match or other type detected syntax

๐Ÿš€ Feature Request

Motivation

Sometimes, We need to know the Generic Type variable's real type, and then do some logic dispatch by the type.

For example:

if(Type::type_of(token) == TokenA){

}else if(Type::type_of(token) == TokenB){

}

or by match:

match toke{
TokenA => {},
TokenB => {}
}

Pitch

Describe the solution you'd like

Support match syntax.

Describe alternatives you've considered

Support some reflection function

Are you willing to open a pull request? (See CONTRIBUTING)
yes

Additional context

A real use case for this feature(an ETH to STC Bridge):

https://github.com/Elements-Studio/poly-stc-contracts/blob/3ea6eb2a5c9a5572e4befe92e19d20a48ae757d0/src/modules/cross-chain/CrossChainRouter.move#L50-L61

Some related links:

  1. There was a related discussion diem/diem#4468
  2. Starcoin's Token use a native function to get token's type https://github.com/starcoinorg/starcoin-framework/blob/88061e9584e5d34f7fb4affad6f094402ca3e2dc/sources/Token.move#L487
  3. starcoinorg/starcoin#3178

[Feature Request] simplify dev_setup script

The dev_setup script installs many things (terraform, kubernetes, awscli, ...) that aren't needed to run Move. I think we should just need Rust + the .net and z3 deps for the prover.

[Feature Request] Using Move in a Layer 2 setup

๐Ÿš€ Feature Request

Motivation

Scalability of blockchain system has always been a huge concern for the community. As a result, blockchain systems usually relies on a so-called layer 2 sctructure to offload some computation to a less decentralized system in order to get greater throughput. A question then arise, if Move and MoveVM can provide any unique value to the Layer 2 scaling solution? Specifically, how we might put Move ecosystem in the famous 2x2 matrix in the Layer 2 scaling.

Pitch

There are following questions we would like to understand about Move:

  1. How easy would it be to construct a zero-knowledge based solution for Move, either via:
    a. Using existing zk based VM such as MidenVM to execute Move contracts, now that the Move team is working on a cross compiler from Move to Yul
    b. Build a VM plugin for MoveVM to support generating traces of MoveVM execution to generate zero knowledge proof of execution correctness?

Moreover, is current zk proof generation process efficient enough for executing Move codes? Can we bring Move to a Validium based roll up solution?

  1. Will the unique account structure of Move bring any unique value to the Plasma framework based solution??

Plasma based protocols are known to be more friendly to a UTXO based scheme as UTXO is naturally easier to prevent double spending on the child network. Moreover, generic smart contracts execution are usually considered not feasiable on Plasma. It would be nice if we have deeper understanding of this issue. Specifically, is it because of the limitation of EVM's state model or it's more of a generic issue that's going to plague the scale-up of Move based ecosystem as well.

Related work

StarCoin has started their optimisitc rollup proposal for a Move ecosystem.

There's also a zk based solution for Move that's been developed here.

[Bug] VS Code move-analyzer instructions refer to the old repo path

It says:

Invoke cargo install --git https://github.com/diem/diem move-analyzer to install the move-analyzer language server in your Cargo binary directory. On macOS and Linux this is usually ~/.cargo/bin. You'll want to make sure this location is in your PATH environment variable.

Might be good to just sweep the repo to see if we have other references of the old repo path.

[move-cli, evm] `move package test` fails unexpectedly

To reproduce,

in move/language/documentation/examples/experimental/basic-coin,
add a test file to tests/BasicCoinTest.move:

module BasicCoin::BasicCoinTest {
    #[test]
    fun compare_string() {
        let s1 = b"string";
        let s2 = b"string";
        assert!(s1==s2, 0);
    }
}

and then,

$ move package build
BUILDING MoveStdlib
BUILDING BasicCoin

$ move package test
BUILDING MoveStdlib
BUILDING BasicCoin
Running Move unit tests
[ PASS    ] 0xbc::BasicCoinTest::compare_string
Test result: OK. Total tests: 1; passed: 1; failed: 0

$ move package test
CACHED MoveStdlib
BUILDING BasicCoin
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: No such file or directory './build/MoveStdlib/sources/ASCIITests.move'', language/tools/move-cli/src/package/cli.rs:514:83
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

$ RUST_BACKTRACE=1 move package test
CACHED MoveStdlib
BUILDING BasicCoin
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: No such file or directory './build/MoveStdlib/sources/ASCIITests.move'', language/tools/move-cli/src/package/cli.rs:514:83
stack backtrace:
   0: _rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::result::unwrap_failed
   3: core::result::Result<T,E>::unwrap
             at /private/tmp/rust-20220304-34642-f8s218/rustc-1.59.0-src/library/core/src/result.rs:1018:23
   4: move_cli::package::cli::run_move_unit_tests::{{closure}}
             at /Users/jkpark/Work/move/language/tools/move-cli/src/package/cli.rs:514:54
   5: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
             at /private/tmp/rust-20220304-34642-f8s218/rustc-1.59.0-src/library/core/src/ops/function.rs:269:13
   6: move_package::compilation::compiled_package::CompiledPackage::build
             at /Users/jkpark/Work/move/language/tools/move-package/src/compilation/compiled_package.rs:550:42
   7: move_package::compilation::build_plan::BuildPlan::compile_with_driver
             at /Users/jkpark/Work/move/language/tools/move-package/src/compilation/build_plan.rs:75:36
   8: move_cli::package::cli::run_move_unit_tests
             at /Users/jkpark/Work/move/language/tools/move-cli/src/package/cli.rs:510:15
   9: move_cli::package::cli::handle_package_commands
             at /Users/jkpark/Work/move/language/tools/move-cli/src/package/cli.rs:424:26
  10: move_cli::run_cli
             at /Users/jkpark/Work/move/language/tools/move-cli/src/lib.rs:116:37
  11: move_cli::move_cli
             at /Users/jkpark/Work/move/language/tools/move-cli/src/lib.rs:131:5
  12: move::main
             at /Users/jkpark/Work/move/language/tools/move-cli/src/main.rs:10:5
  13: core::ops::function::FnOnce::call_once
             at /private/tmp/rust-20220304-34642-f8s218/rustc-1.59.0-src/library/core/src/ops/function.rs:227:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

This issue is there too with the flag --evm. To reproduce this, in language/evm/examples, run move package test.

error[E0432]: unresolved import `plotters_bitmap`

Hi.
I have a problem during the installation process.

error[E0432]: unresolved import plotters_bitmap
--> /home/aiv/.cargo/registry/src/github.com-1ecc6299db9ec823/plotters-0.3.3/src/evcxr.rs:4:5
|
4 | use plotters_bitmap::BitMapBackend;
| ^^^^^^^^^^^^^^^ use of undeclared crate or module plotters_bitmap

Compiling num-complex v0.4.2
Compiling num-traits v0.1.43
Compiling ordered-float v2.10.0
For more information about this error, try rustc --explain E0432.
error: could not compile plotters due to previous error
warning: build failed, waiting for other jobs to finish...
error: failed to compile move-cli v0.1.0 (https://github.com/diem/move?branch=main#08b7eae0), intermediate artifacts can be found at /tmp/cargo-install24OD2g

Screenshot from 2022-08-29 09-31-43

[Feature Request] Make VM parametric in serialization format

The VM uses BCS for serialization, but there's nothing fundamental preventing Move from supporting multiple serialization formats. Allowing the adapter to choose a serialization format for the VM would enable more efficient usage of Move in settings where the host system's data is not BCS-encoded.

[Feature Request] Improve stacktrace readability (with line numbers)

Today if we call Debug::print_stack_trace, it prints a stack with very low-level data: bytecode, stack information and etc.
This however isn't typically what a Move developer wants.
The basic thing a developer want to see would be the similar kind of stacktrace in other languages: the file and line number of each function in the stack.

[Bug] MVP proves arbitrary postconditions when unsupported operations exist

๐Ÿ› Bug

When MVP sees an unsupported operation in a function, it proves arbitrary postconditions.

To reproduce

MVP can find that this postcondition doesn't hold:

address 0x123 {
  module M {
    public fun foo(i: u64): u64 { i + 0 }
    spec foo { ensures false; } // :)
  }
}

But it falsely "proves" this one because of the bit-and operator:

address 0x123 {
  module M {
    public fun foo(i: u64): u64 { i & 0 }
    spec foo { ensures false; } // :(
  }
}

Expected Behavior

For unsupported operations, MVP currently generates an assert false in bpl.
Correct me if I am wrong, Boogie should immediately report an assertion failure upon seeing assert false.
But now seems like it sliently skipped everything.

[move-lang] Possible memory leak for droppable structs

Given

struct S has drop { x: u64 }

fun destroy(s: S) {}

... the bytecode will not contain a destroy instruction for s. However, given

fun destroy() { let _s = S{x:1}; }

... the destroy will be generated as expected.

[evm] Issues with events

  1. move-to-yul cannot compile events with string arguments. See language/evm/hardhat-examples/contracts/Event.move

  2. The Event contract in Move does not pass the hardhat test language/evm/hardhat-examples/contracts/Event.test.js

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.