An execution environment for blockchains.
👉 Whitepaper 👈
Grug consists of the following Rust crates:
crate | description |
---|---|
app | state machine transition logics and Tendermint ABCI implementation |
crypto | cryptography functionalities |
db/disk | an on-disk, persisted DB backend |
db/memory | an in-memory, ephemeral DB backend; used for testing |
ffi | helpers for building or interacting with FFI |
macros | procedural macros for reducing boilerplates in contract developments |
jellyfish-merkle | Jellyfish Merkle Tree (JMT) implementation |
storage | abstractions over key-value stores |
types | types, traits, and some helper functions |
vm/rust | a VM that runs native Rust codes; used for testing |
vm/wasm | a VM that runs WebAssembly byte codes |
Additionally, there are grug-testing which provides testing utilities, and grug-std, a "meta-crate", which re-exports contents from the above crates, for the convenience of contract developers.
At the heart of the project is the grug_app::App
type. Fundamentally, a blockchain is a state machine that consists of 1) the state, typically represented by a key-value database, and 2) the state transition rule, which typically involves a virtual machine that runs smart contracts. Therefore, our App
takes two generics, representing the DB and the VM, respectively:
struct App<DB, VM> {
db: DB,
vm: VM,
}
Here, DB
must implement the grug_types::Db
trait, while VM
must implement the grug_types::Vm
trait.
We will ship two Db
and two Vm
implementations, for different use cases:
use case | implementation |
---|---|
production node | App<DiskDb, WasmVm> |
testing | App<MemDb, RustVm> |
The below diagram shows the dependency relations between the crates:
Prerequisites:
Install the grug
command line software:
just install
Run tests:
just test
Lint the code:
just lint
Compile and optimize smart contracts:
just optimize
TODO
TBD