Ethereum Experts Share Their Facebook Libra Insights

Developers on Facebook’s Libra blockchain, the white paper, and how to get testnet Libra coins.

Consensys
ConsenSys Media
7 min readJun 28, 2019

--

Kauri is a decentralized knowledge base and support network where contributors share tutorials, examples, developer tools, application protocols, and other Ethereum content. Taking its name from the oldest and largest tree on earth, Kauri symbolizes a community-grown tree of knowledge that stands to support further innovation, adoption, and collaboration in the developer ecosystem.

Shortly after Facebook’s Libra hit the main waves, Kauri contributors dove right into the pool of complex technology and communicated their findings step by step. This article highlights three thorough investigative pieces around the Libra technical white paper, Libra’s new programming language Move, and the Calibra Wallet.

Building and Working with Facebook’s Cryptocurrency Libra

Setup

We followed the setup instructions in the documentation on macOS, which worked without any issues and downloaded any dependencies missing from our local system.

We noticed that Libra is using rocksdb for storage, which is unsurprising as it’s a popular option and also created by Facebook. There are other dependencies, mostly used for cryptography and storage, you can see the full list in the various Cargo.toml files in the repository. Which also shows that most of Libra is written in Rust. Interestingly, we noticed that Libra uses the Rust Bitcoin hashes project for hashing, plus a handful of Parity labs modules.

Build and connect

After setup, you can build the CLI client and connect to the testnet. This takes some time and uses a reasonable amount of your computer resources, but again completed with no issues. At the end of the build process, your local machine connects to a validator node and provides you with an interface to the node.

Next, we tried creating accounts, which worked fine. There are three main functions: account, query, transfer; all of which are relatively self-explanatory. In this step of the tutorial, we create two accounts, each of which has their own index and hex address. You can use the index value instead of the address in other CLI commands to reference the account you want to interact with.

Add coins

Next, we add Libra coins using a time-honored faucet. We noticed that the testnet faucet has a limit of 5 requests per minute, which is not realistic for a real-world payment option. Hopefully, this is just testnet rate limiting.

At this point, we also noticed that using the query account_state 0 command returned a couple of interesting field values, including a Blockchain versionvalue, a “sequence number” (kind of like a nonce). The account also had a state before we have yet pushed the account values to the blockchain. This is different from Ethereum or Bitcoin and means that either account generation must also have an event which pings testnet or that if it’s a valid account number, Libra returns its balance as “none”, but validates it’s a compliant address.

Visit Kauri to access the rest of the tutorial, where Coogan from ConsenSys Academy submits a transaction and shares his conclusion.

Whitepaper Deep Dive — Move: Facebook Libra Blockchain’s New Programming Language

Ethereum developer and a blockchain community enthusiast, Lee Ting Ting walks us through the 26-page technical whitepaper of Move, Libra’s new programming language.

Abstract

Move is an executable bytecode language used to implement custom transactions and smart contracts.

Key findings:

  • While Move is a bytecode language which can be directly executed in Move’s VM, Solidity (Ethereum’s smart contract language) is a higher level language that needs to be compiled down to bytecode before executing in EVM (Ethereum’s Virtual Machine).
  • Move can not only be used to implement smart contracts but also custom transactions (explained later in the article), while Solidity is a language for smart contracts on Ethereum only.
  • The key feature of Move is the ability to define custom resource types with semantics inspired by linear logic: a resource can never be copied or implicitly discarded, only moved between program storage locations.
  • Move shares a few certain similar features to Rust.

Flexibility and Safety:

  • Move adds flexibility to Libra via transaction scripts. Each Libra transaction includes a transaction script that is effectively the main procedure of the transaction.
  • The scripts can perform either expressive one-off behaviors (such as paying a specific set of recipients) or reusable behaviors (by invoking a single procedure that encapsulates the reusable logic)

Peer-to-Peer Payment Transaction Script

Lee annotates several new symbols with red text in the payment transcript:

The amount of coins will be transferred from the transaction sender to payee
  • 0x0: the account address where the module is stored
  • Currency: the name of the module
  • Coin: the resource type
  • The value coin returned by the procedure is a resource value whose type is 0x0.Currency.Coin
  • move(): the value can not be used again
  • copy(): the value can be used later

Currency Move Execution model:

Read the rest of her findings, which include a code breakdown, a comparison of current problems facing existing blockchain languages, (all of which have been solved in Move), implementing a deposit, and further details regarding the programming language and the design principles behind it.

Quick Dive into the Move Programming Language

Kauri Software Engineer Wil Barnes shared his thoughts on the Libra Move’s technical white paper.

Two Different Types of Programs: Transaction Scripts & Modules

  • Transaction scripts are more single-use and can invoke modules
  • Modules are long-term pieces of code stored in Libra’s global state

Move Global State

  • Libra’s global state is a mapping of account addresses => accounts.
  • Think 0x0, 0x1, 0x2 in succession, with each of these account addresses able to hold zero or more modules and at least one resource values.
  • Say at account address 0x1337 I have a module deployed named ‘Multisig’ and a resource type called ‘Wallet.’
  • 0x1337 would consist of our ‘module/Multisig’ module and our ‘0x1337.Multisig.Wallet’ resource type.
  • More modules and resource types can still be added to our 0x1337 address.
  • “Accounts can contain at most one resource value of a given type and at most one module with a given name” [4.1, 1st sentence]
  • Move is designed so that malicious actors outside the module cannot affect the resource types within the module.

Read Wil’s comparisons between Libra and Ethereum 1:

Libra & Ethereum 1 transactions are nearly identical

  • Both include gas price & gas supply mechanisms.
  • Libra’s ‘sequence’ == Ethereum’s ‘nonce.’
  • Both implement ‘all-or-nothing’ transactions; out-of-gas, failed require/assert, result in reversion of the whole transaction.

Libra ‘Modules’ & Ethereum ‘Smart Contracts’

  • Fairly similar, with nuances
  • Modules enforce strong data abstraction: “Critical operations on a resource type T may only be performed inside a module that defines T.” [Section 3.1, last sentence]
  • A struct, or presumably any resource type, within a module can only be changed by that module.

Move VM & Ethereum Virtual Machine (EVM)

  • “Move bytecode instructions are executed by a stack-based interpreter similar to the Common Language Runtime and Java Virtual Machine.” [5.1 1st paragraph, 1st sentence]
  • “Execution of Move programs is metered in a manner similar to the EVM. Each bytecode instructed has an associated gas unit cost, and any transaction to be executed must include a gas unit budget. The interpreter track sthe gas units remaining during execution and halts with an error if the amount remaining reaches zero.” [5.1 4th paragraph, 1st sentence]

A Note on Transaction Scripts

  • A rough parallel for a transaction script would be the ‘main.rs’ in Rust or ‘main.py’ in Python.
  • “[…] scripts can perform either expressive one-off behaviors (such as paying a specific set of recipients) or reusable behaviors (by invoking a single procedure that encapsulates the reusable logic)_” [3.2, 1st paragraph, 5th sentence]

Read the rest of Wil’s deep dive, which includes Move VM nuances and Move’s global state.

Kauri’s collaborative and ever-growing body of knowledge gives Web2 and Web3 developers the tools and documentation to learn and build faster. These posts demonstrate that Kauri contributors don’t shy away from expanding their expert opinions outside of Ethereum to the entire blockchain space.

Learn more by reading the Kauri Libra collection.

Disclaimer. The views, information, and opinions expressed are solely those by the author above do not necessarily represent the views of Consensys AG. They are meant for informational purposes only, are not intended to serve as a recommendation or investment advice to buy or sell any securities, cryptoassets, or other financial products.

--

--

Consensys
ConsenSys Media

A complete suite of products to create and participate in web3.