dfinance Virtual Machine for Move language
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
- install [Rust][], the easiest way to get it is to use [Rustup][]
- install [protoc][]
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 servermovec- standalone compilerstdlib-builder- standard library builder (useful for genesis creation)status-table- table of status/error-codes exporter tool
cargo uninstall dvm.
Usage
Note: Following instructions are for standalone binary executables. If you want to usecargoto build & run, just addcargo run --binat 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][].
[protobuf schemas]: https://github.com/dfinance/dvm-proto/tree/master/protos
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</code></pre>
To build your stdlib run:
<pre><code class="lang-bash">stdlib-builder /path-to-your/stdlib -po ./stdlib.json</code></pre>
Configuration actual for both
Positional arguments:
DVM require positional argument described as
. This is URI of a data source server, typically [Dnode][], local or external. This argument can be ommited because we'll read the DVMDATASOURCE [environment variable][environment variables] 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:
<pre><code class="lang-bash"># using env var: DVMDATASOURCE="http://[::1]:50052" dvm "http://[::1]:50051"
or using positional arg:
dvm "http://[::1]:50051" "http://[::1]:50052" both is same</code></pre>
But env vars used just as fallback, so args are higher prioritised. <pre><code class="lang-bash">DVMDATASOURCE="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.</code></pre>
[Dnode]: https://github.com/dfinance/dnode [UDS]: https://en.wikipedia.org/wiki/Unixdomainsocket
Environment variables:
DVMDATASOURCE - Data-source address.
Used if relevant positional argument isn't specified.
DVMLOG - Log filters. The same as standard RUSTLOG environment variable.
Possible values in verbosity ordering: error, warn, info, debug and trace.
For complex filters see documentation
DVMLOGSTYLE - Log colors. The same as standard RUSTLOGSTYLE.
Possible values in verbosity ordering: auto, always, never.
DVMSENTRYDSN - Optional key-uri, enables crash logging service integration.
If value ommited, crash logging service will not be initialized.
E.g.: DVMSENTRYDSN=https://your-dsn@uri dvm "http://[::1]:50051"
DVMSENTRYENVIRONMENT - Sets the environment code to separate events from testnet and production.
Optional. Works with Sentry integration.
E.g.: DVMSENTRYENVIR
Optional arguments:
Optional arguments have higher priority than [environment variables][], and override them when specified.
--log - same as DVM_LOG
--log-color - same as DVMLOGSTYLE
--sentry-dsn - same as DVMSENTRYDSN
--sentry-env - same as DVMSENTRYENVIRONMENT
[environment variables]: #environment-variables
For more info run dvm with
--help.
- - - - - - - - - -
Development
Just clone [this repo][] and hack some:
<pre><code class="lang-bash"># clone the repository git clone https://github.com/dfinance/dvm.git
cd dvm
build and run vm
cargo run --bin dvm -- --help</code></pre>
<!-- TODO: guide for contributors should be here -->
Check out [online documentation][dvm.docs] built on CI for latest release.
[this repo]: https://github.com/dfinance/dvm [dvm.docs]: https://dfinance.github.io/dvm/
Tests
To launch tests run:
<pre><code class="lang-bash">cargo test --all</code></pre>
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:
<pre><code class="lang-bash">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