0.3.2 Aug 23, 2022
0.3.1 Aug 13, 2022
0.2.1 Jul 22, 2022
0.1.6 Jul 5, 2022
0.1.4 May 23, 2022

#114 in #bytecode

Download history 3/week @ 2023-12-14 7/week @ 2023-12-21 12/week @ 2023-12-28 2/week @ 2024-01-04 4/week @ 2024-01-11 5/week @ 2024-02-01 10/week @ 2024-02-08 68/week @ 2024-02-15 38/week @ 2024-02-22 22/week @ 2024-02-29 18/week @ 2024-03-07 13/week @ 2024-03-14 33/week @ 2024-03-21 52/week @ 2024-03-28

116 downloads per month
Used in 166 crates (44 directly)

Apache-2.0

580KB
13K SLoC


id: vm title: Virtual Machine custom_edit_url: https://github.com/move-language/move/edit/main/language/move-binary-format/README.md

The MoveVM executes transactions expressed in the Move bytecode. There are two main crates: the core VM and the VM runtime. The VM core contains the low-level data type for the VM - mostly the file format and abstraction over it. A gas metering logical abstraction is also defined there.

Overview

The MoveVM is a stack machine with a static type system. The MoveVM honors the specification of the Move language through a mix of file format, verification (for reference bytecode verifier README) and runtime constraints. The structure of the file format allows the definition of modules, types (resources and unrestricted types), and functions. Code is expressed via bytecode instructions, which may have references to external functions and types. The file format also imposes certain invariants of the language such as opaque types and private fields. From the file format definition it should be clear that modules define a scope/namespace for functions and types. Types are opaque given all fields are private, and types carry no functions or methods.

Implementation Details

The MoveVM core crate provides the definition of the file format and all utilities related to the file format:

  • A simple Rust abstraction over the file format (diem/language/move-binary-format/src/file_format.rs) and the bytecodes. These Rust structures are widely used in the code base.
  • Serialization and deserialization of the file format. These define the on-chain binary representation of the code.
  • Some pretty printing functionalities.
  • A proptest infrastructure for the file format.

The CompiledModule and CompiledScript definitions in diem/language/move-binary-format/src/file_format.rs are the top-level structs for a Move Module or Transaction Script, respectively. These structs provide a simple abstraction over the file format. Additionally, a set of Views are defined to easily navigate and inspect CompiledModules and CompiledScripts.

Folder Structure

.
├── src             # VM core files
├── tests           # Proptests
└── vm-runtime      # Interpreter and runtime data types (see README in that folder)

Dependencies

~1–2MB
~42K SLoC