fury02 / bigmap-poc

Proof of concept of an infinitely scalable data storage for the Internet Computer application, written in Rust

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Proof of concept demo of BigMap

The idea of BigMap is to enable infinitely scalable key-value storage on the Internet Computer. This repository contains a proof of concept of this idea that the DFINITY foundation worked on in the past. It is currently broken and it is also not supported. The repository is open-sourced to serve as an inspiration for developers.

Prerequisites

Dependencies

  • Rust compiler 1.45+ (and cargo)
  • cmake (optional but recommended)
  • IC SDK (DFX) 0.6.9+

IC SDK

To integrate BigMap with the Internet Computer applications, it's necessary to have the DFX version 0.6.9 or higher

DFX_VERSION=0.6.9 sh -ci "$(curl -fsSL https://sdk.dfinity.org/install.sh)"

Rust CDK is included with Big Map through git subtree, so it does not have to be separately downloaded and installed.

Rust

Tested with Rust 1.45+. Please make sure you install the latest version.

Make sure you're running the latest version of Rust, with wasm32 target

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
rustup toolchain install stable
rustup override set stable
rustup target add wasm32-unknown-unknown

Build and install canisters

Simply run ./bootstrap.sh, or

git clone git@github.com:dfinity/big-map-rs.git
cd big-map-rs

npm install
dfx build
dfx canister create bigmap
dfx canister install bigmap
./bigmap-cli --set-data-bucket-wasm-binary target/wasm32-unknown-unknown/release/bigmap_data.wasm
./bigmap-cli --set-search-wasm-binary target/wasm32-unknown-unknown/release/bigmap_search.wasm

Test

You can either take a look at test.sh for a complete set of test steps, or you can selectively run the below commands:

dfx canister call bigmap get '(vec { 97; 98; 99; })'
# (null)
dfx canister call bigmap put '(vec { 97; 98; 99; }, vec { 100; 101; 102; })'
# ()
dfx canister call bigmap get '(vec { 97; 98; 99; })'
# (opt vec { 4; 5; 6; })

It is also possible to talk directly to the data bucket canisters, but this is likely only useful during development or debugging. In this case it's necessary to know the CanisterId, which is printed in the replica debug logs during creation.

For example:

dfx canister call tup4c-ks6aa-aaaaa-aaaaa-aaaaa-aaaaa-aaaaa-q get '(vec { 97; 98; 99; })'
# (null)
dfx canister call tup4c-ks6aa-aaaaa-aaaaa-aaaaa-aaaaa-aaaaa-q put '(vec { 97; 98; 99; }, vec { 100; 101; 102; })'
# ()
dfx canister call tup4c-ks6aa-aaaaa-aaaaa-aaaaa-aaaaa-aaaaa-q get '(vec { 97; 98; 99; })'
# (opt vec { 4; 5; 6; })

About

Proof of concept of an infinitely scalable data storage for the Internet Computer application, written in Rust

License:Apache License 2.0


Languages

Language:Rust 74.7%Language:JavaScript 14.4%Language:TypeScript 7.0%Language:Shell 2.4%Language:HTML 0.9%Language:CSS 0.5%