Skip to content
Branch: master
Find file History
Darion Cassel and calibra-opensource Fix wrong table used in gas_schedule
The gas cost for each instruction is stored in a `CostTable` which is split into a `compute_table` and `memory_table`. Together these two costs (compute and memory) are used to calculate a total cost for an instruction during execution. There are two helper functions that get the cost from each table; `memory_gas` and `comp_gas`.

While I using MIRAI to verifying the safety of the `unwrap()` calls in each function, I came across the following copy and paste bug: the `comp_gas` function was using the `memory_table` rather than the `compute_table`. As a result, the compute cost being returned for each instruction is just 1.

A consequence of this fix is that the default maximum gas bound had to be raised and several tests that had to be modified to increase account balances.
Latest commit 4d4ca63 Jul 15, 2019

README.md

id title custom_edit_url
move-language
Move Language

Move

Move is a new programming language developed to provide a safe and programmable foundation for the Libra Blockchain.

Organization

The Move language directory consists of five parts:

  • The virtual machine (VM), which contains the bytecode format, a bytecode interpreter, and infrastructure for executing a block of transactions. This directory also contains the infrastructure to generate the genesis block.

  • The bytecode verifier, which contains a static analysis tool for rejecting invalid Move bytecode. The virtual machine runs the bytecode verifier on any new Move code it encounters before executing it. The compiler runs the bytecode verifier on its output and surfaces the errors to the programmer.

  • The Move intermediate representation (IR) compiler, which compiles human-readable program text into Move bytecode. Warning: the IR compiler is a testing tool. It can generate invalid bytecode that will be rejected by the Move bytecode verifier. The IR syntax is a work in progress that will undergo significant changes.

  • The standard library, which contains the Move IR code for the core system modules such as LibraAccount and LibraCoin.

  • The tests for the virtual machine, bytecode verifier, and compiler. These tests are written in Move IR and run by a testing framework that parses the expected result of running a test from special directives encoded in comments.

How the Move Language Fits Into Libra Core

Libra Core components interact with the language component through the VM. Specifically, the admission control component uses a limited, read-only subset of the VM functionality to discard invalid transactions before they are admitted to the mempool and consensus. The execution component uses the VM to execute a block of transactions.

Exploring Move IR

  • You can find many small Move IR examples in the tests. The easiest way to experiment with Move IR is to create a new test in this directory and follow the instructions for running the tests.
  • Some more substantial examples can be found in the standard library. The two most notable ones are LibraAccount.mvir, which implements accounts on the Libra blockchain, and LibraCoin.mvir, which implements Libra coin.
  • The four transaction scripts supported in the Libra testnet are also in the standard library directiory. They are peer-to-peer transfer, account creation, minting new Libra (will only work for an account with proper privileges), and key rotation.
  • The most complete documentation of the Move IR syntax is the grammar. You can also take a look at the parser for the Move IR.
  • Check out the IR compiler README for more details on writing Move IR code.

Directory Organization

├── README.md          # This README
├── bytecode_verifier  # The bytecode verifier
├── e2e_tests          # infrastructure and tests for the end-to-end flow
├── functional_tests   # Testing framework for the Move language
├── compiler           # The IR to Move bytecode compiler
├── stdlib             # Core Move modules and transaction scripts
├── test.sh            # Script for running all the language tests
└── vm
    ├── cost_synthesis # Cost synthesis for bytecode instructions
    ├── src            # Bytecode language definitions, serializer, and deserializer
    ├── tests          # VM tests
    ├── vm_genesis     # The genesis state creation, and blockchain genesis writeset
    └── vm_runtime     # The bytecode interpreter
You can’t perform that action at this time.