Crates.io | firewood |
lib.rs | firewood |
version | 0.0.2 |
source | src |
created_at | 2023-04-14 15:43:53.332121 |
updated_at | 2023-04-21 21:50:09.108549 |
description | Firewood is an embedded key-value store, optimized to store blockchain state. |
homepage | https://avalabs.org |
repository | |
max_upload_size | |
id | 839250 |
size | 389,883 |
:warning: firewood is alpha-level software and is not ready for production use. Do not use firewood to store production data. See the license for more information regarding firewood usage.
Firewood is an embedded key-value store, optimized to store blockchain state. It prioritizes access to latest state, by providing extremely fast reads, but also provides a limited view into past state. It does not copy-on-write the state trie to generate an ever growing forest of tries like other databases, but instead keeps one latest version of the trie index on disk and apply in-place updates to it. This ensures that the database size is small and stable during the course of running firewood. Firewood was first conceived to provide a very fast storage layer for the EVM but could be used on any blockchain that requires authenticated state.
Firewood is a robust database implemented from the ground up to directly store trie nodes and user data. Unlike most (if not all) of the solutions in the field, it is not built on top of a generic KV store such as LevelDB/RocksDB. Like a B+-tree based store, firewood directly uses the tree structure as the index on disk. Thus, there is no additional “emulation” of the logical trie to flatten out the data structure to feed into the underlying DB that is unaware of the data being stored.
Firewood provides OS-level crash recovery via a write-ahead log (WAL). The WAL guarantees atomicity and durability in the database, but also offers “reversibility”: some portion of the old WAL can be optionally kept around to allow a fast in-memory rollback to recover some past versions of the entire store back in memory. While running the store, new changes will also contribute to the configured window of changes (at batch granularity) to access any past versions with no additional cost at all.
Firewood provides two isolated storage spaces which can be both or selectively used the user. The account model portion of the storage offers something very similar to StateDB in geth, which captures the address-“state key” style of two-level access for an account’s (smart contract’s) state. Therefore, it takes minimal effort to delegate all state storage from an EVM implementation to firewood. The other portion of the storage supports generic trie storage for arbitrary keys and values. When unused, there is no additional cost.
firewood is licensed by the Ecosystem License. For more information, see the LICENSE file.
The following crates are vendored in this repository to allow for making modifications without requiring upstream approval:
These crates will either be heavily modified or removed prior to the production launch of firewood. If they are retained, all changes made will be shared upstream.
This milestone will focus on additional code cleanup, including supporting concurrent access to a specific revision, as well as cleaning up the basic reader and writer interfaces to have consistent read/write semantics.
This milestone will add support for proposals, including proposed future branches, with a cache to make committing these branches efficiently.
The focus of this milestone will be to support synchronization to other instances to replicate the state. A synchronization library should also be developed for this milestone.
Firewood currently is Linux-only, as it has a dependency on the asynchronous
I/O provided by the Linux kernel (see libaio
). Unfortunately, Docker is not
able to successfully emulate the syscalls libaio
relies on, so Linux or a
Linux VM must be used to run firewood. It is encouraged to enhance the project
with I/O supports for other OSes, such as OSX (where kqueue
needs to be used
for async I/O) and Windows. Please contact us if you're interested in such contribution.
There are several examples, in the examples directory, that simulate real world
use-cases. Try running them via the command-line, via cargo run --release --example simple
.
To integrate firewood into a custom VM or other project, see the firewood-connection for a straightforward way to use firewood via custom message-passing.
See the release documentation for detailed information on how to release firewood.
Firewood comes with a CLI tool called fwdctl
that enables one to create and interact with a local instance of a firewood database. For more information, see the fwdctl README.
cargo test --release