Skip to content

dfinance/dvm

Repository files navigation

DVM - Dfinance Virtual Machine

Related Repositories

  • Dnode - Dfinance Blockchain node.
  • PegZone - PegZone smart contracts.
  • OracleApp - oracle node, which fetches price feeds from exchanges.

Installation

There are two ways to install and try DVM - with Docker or with Rust-toolchain.

The Docker way

You can use this schema for your docker-compose to run everything at once:

version: '3.7'
services:
  dvm-server:
    container_name: dvm-server
    image: dfinance/dvm
    restart: always
    network_mode: host
    command: ./dvm "http://0.0.0.0:50051" "http://127.0.0.1:50052"

Or you can pull container from docker hub and run it by yourself:

# pull the latest containers
docker pull dfinance/dvm

That is how you do it:

# run virtual machine & compilation server
docker run -d --rm --network host --name dvm -p 50051:50051 registry.wings.toys/dfinance/dvm:master ./dvm "http://0.0.0.0:50051" "http://127.0.0.1:50052"
# stop the server
docker stop dvm

Check out Usage part for more info.


Installation with Rust 🦀 Cargo

Prerequisites

Build and Install

To install using cargo run the following commands:

git clone https://github.com/dfinance/dvm.git && cd dvm
# for all binaries:
cargo install --path ./cli --bins
# or for dvm only:
# cargo install --path ./cli --bin dvm

As result you will get the following executables into your .cargo/bin directory:

  • dvm - virtual machine & compilation server
  • movec - standalone compiler
  • stdlib-builder - standard library builder (useful for genesis creation)
  • status-table - table of status/error-codes exporter tool

Uninstallation: cargo uninstall dvm.

Usage

Note: Following instructions are for standalone binary executables. If you want to use cargo to build & run, just add cargo run --bin at the start of the mentioned command.

DVM server

dvm is a Move/Mvir virtual machine gRPC server. API described in protobuf schemas.

To launch the DVM server use this command:

# format: <which host:port to listen> <data-source address>
dvm "http://[::1]:50051" "http://[::1]:50052"

Compilation server

DVM has built-in Move compilation gRPC server. API described in protobuf schemas.

Stdlib Builder

stdlib-builder is a standard library builder.

To build standard library run:

# format:   <source directory> [-o output-file] [--verbose] [-p] [--help]`
# print output to stdout:
stdlib-builder stdlib/modules -p
# or write output to the file:
stdlib-builder stdlib/modules -po ./stdlib.json

To build your stdlib run:

stdlib-builder /path-to-your/stdlib -po ./stdlib.json

Configuration actual for both

Positional arguments:

DVM require positional argument described as <data-source address>. This is URI of a data source server, typically Dnode, local or external. This argument can be ommited because we'll read the DVM_DATA_SOURCE environment variable as fallback.

All of this URIs are supports following schemes:

  • http
  • ipc (using UDS), e.g.:
    • ipc://tmp/dir/file (absolute path)
    • ipc://./dir/file (relative path with . and ..)
    • ipc://~/dir/file (relative to $HOME)

Positional arguments have higher priority than environment variables, and override them when specified.

For example:

# using env var:
DVM_DATA_SOURCE="http://[::1]:50052" dvm "http://[::1]:50051"
# or using positional arg:
dvm "http://[::1]:50051" "http://[::1]:50052"
# both is same

But env vars used just as fallback, so args are higher prioritised.

DVM_DATA_SOURCE="http://[::1]:42" dvm "http://[::1]:50051" "http://[::1]:50052"
# There DVM will listen port 50051
# and connect to data source on 50052 port
# ignoring env variable.

Environment variables:

  • DVM_DATA_SOURCE - Data-source address. Used if relevant positional argument isn't specified.
  • DVM_LOG - Log filters. The same as standard RUST_LOG environment variable. Possible values in verbosity ordering: error, warn, info, debug and trace. For complex filters see documentation
  • DVM_LOG_STYLE - Log colors. The same as standard RUST_LOG_STYLE. Possible values in verbosity ordering: auto, always, never.
  • DVM_SENTRY_DSN - Optional key-uri, enables crash logging service integration. If value ommited, crash logging service will not be initialized. E.g.: DVM_SENTRY_DSN=https://your-dsn@uri dvm "http://[::1]:50051"
  • DVM_SENTRY_ENVIRONMENT - Sets the environment code to separate events from testnet and production. Optional. Works with Sentry integration. E.g.: DVM_SENTRY_ENVIRONMENT="testnet"

Optional arguments:

Optional arguments have higher priority than environment variables, and override them when specified.

  • --log - same as DVM_LOG
  • --log-color - same as DVM_LOG_STYLE
  • --sentry-dsn - same as DVM_SENTRY_DSN
  • --sentry-env - same as DVM_SENTRY_ENVIRONMENT

For more info run dvm with --help.


Development

Just clone this repo and hack some:

# clone the repository
git clone https://github.com/dfinance/dvm.git

cd dvm

# build and run vm
cargo run --bin dvm -- --help

Check out online documentation built on CI for latest release.

Tests

To launch tests run:

cargo test --all

Contributors

List of contributors is here.

To help project you always can open issue or fork, modify code in your own fork and open pull request.

Useful precommit-hook to check changes locally:

ln -s `git rev-parse --show-toplevel`/check_project.sh `git rev-parse --absolute-git-dir`/hooks/pre-commit

License

Copyright © 2020 Wings Stiftung

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.