OAK, or Onchain Automation Framework, is equipped with a novel smart contract virtual machine that supports an event-driven execution model, enabling developers to build fully autonomous decentralized application. By extending the current set of atomic operations, namely, opcodes of EVM, OAK introduces an innovative way for contracts to interact with each other. Contracts can emit signal events, on which other contracts can listen. Once an event is triggered, corresponding handler functions are automatically executed as a new type of transaction, signal transaction. Applications implemented with this new approach will eliminate dependency of unreliable components such as off-chain relay servers, and in return, significantly simplify execution flow and avoid security risks such as man-in-the-middle attacks.
Benefits of OAK technology,
- Secure automation
- Easy integration
- Built-in private oracle
Turing Staging
: Rococo parachain (Jan 2022)Turing Network
: Kusama parachain (April 2022)OAK Network
: Polkadot parachain (target launch Q1 2023)
- General discussion: Telegram
- Technical discussion: Discord
- Follow us on Twitter
- Subscribe to Medium Newsletter
Binaries of Turing Network can be found on Releases page of this repo.
For instructions of setting up a Turing Network collator, please refer to our documentation on docs.oak.tech.
The best way to run our blockchain and debug its code is via building from source. In this chapter we will explain the method to set up a local Rococo network with Turing and other parachains.
Ensure you have Rust and the support software (see shell.nix for the latest functional toolchain):
curl https://sh.rustup.rs -sSf | sh
# on Windows download and run rustup-init.exe
# from https://rustup.rs instead
rustup update nightly
rustup target add wasm32-unknown-unknown --toolchain nightly
# [!Important] Make sure the rustup default is compatible with your machine, for example, if you are building using Apple M1 ARM you need to run
rustup install stable-aarch64-apple-darwin
rustup default stable-aarch64-apple-darwin
You will also need to install the following dependencies:
- Linux:
sudo apt install cmake git clang libclang-dev build-essential
- Mac:
brew install cmake git llvm
- Windows: Download and install the Pre Build Windows binaries of LLVM from http://releases.llvm.org/download.html
Install additional build tools:
cargo +nightly install --git https://github.com/alexcrichton/wasm-gc
Clone OAK-blockchain code from Github:
git clone [email protected]:OAK-Foundation/OAK-blockchain.git
Then, build the code into binary:
cargo build --release --features turing-node --features dev-queue
In order to make local testing easy, use a
dev-queue
flag which will allow for putting a task directly on the task queue as opposed to waiting until the next hour to schedule a task. This works when theexecution_times
passed to schedule a task equals[0]
.
At this point, the binary of Turing Dev is built and located at ./target/release/oak-collator
.
Turing Dev is a parachain and doesn’t produce block without a relay chain, so next we will need to clone Polkadot’s code and build a local Rococo(relay chain).
First, find out a compatible version of the relay chain’s code from this repo’s polkadot-parachain
reference in ./runtime/turing/Cargo.toml, for example,
polkadot-parachain = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.29" }
release-v0.9.29 is the version of relay chain to run, so let’s build its source with the below commands.
git clone --branch release-v0.9.29 https://github.com/paritytech/polkadot
cd polkadot
cargo build --release
Here we are using a copy of Mangata’s code as an example of another parachain.
First, clone and compile the code with mangata-rococo
feature for a parachain.
git clone --branch automation-demo https://github.com/OAK-Foundation/mangata-node
cd mangata-node
cargo build --release --features mangata-rococo
The binary file is located at ./target/release/mangata-node.
We have configured a network of 2 relay chain nodes, 1 Turing node and 1 Mangata node in zombienets/turing/mangata.toml, so the easiest way to spin up a local network is through below steps.
- Clone and build source of [Zombienet]
git clone https://github.com/paritytech/zombienet.git
cd zombienet/javascript
- Make sure your node version is compatible with that in javascript/package.json, for example
"node": ">=16"
. npm install
npm run build
- After a successful build, you should be able to test run
npm run zombie
. - Create an alias to the zombie program(on MacOS). Since the actual command of
npm run zombie
isnode ./packages/cli/dist/cli.js
, we can add an alias to it by editing the~/.bash_profile
file. Simply, runvim ~/.bash_profile
add one linealias zombienet="node <your_absolute_path>/zombienet/javascript/packages/cli/dist/cli.js"
to it. - Run
source ~/.bash_profile
. This will load the new ~/.bash_profile. - Cd into OAK-blockchain folder,
cd ../../OAK-blockchain
. - Spawn zombienet with our config file,
zombienet spawn zombienets/turing/mangata.toml
.
The zombie spawn will run 2 relay chain nodes, 1 Turing node and 1 Mangata node, and set up an HRMP channel between the parachains.
In this section we will walk through the steps of manually running a local network with a Rococo relay chain, a Turing parachain and a Mangata parachain.
First, navigate to under polkadot repo’s local folder.
With the binary built in ./target/release/polkadot
, open up two terminal windows to run two nodes separately.
- Run node Alice in the first terminal window
./target/release/polkadot \ --alice \ --validator \ --tmp \ --chain ../OAK-blockchain/resources/rococo-local.json \ --port 30333 \ --ws-port 9944
- Run node Bob in the second terminal window
# Bob (In a separate terminal) ./target/release/polkadot \ --bob \ --validator \ --tmp \ --chain ../OAK-blockchain/resources/rococo-local.json \ --port 30334 \ --ws-port 9945
At this point, your local relay chain network should be running. Next, we will launch a Turing Network node and connect it to the relay chain as a parachain.
Navigate to under OAK-blockchain repo’s local folder. The binary built is located at ./target/release/oak-collator
.
Then, prepare two files, genesis-state and genesis-wasm, for parachain registration.
# Generate a genesis state file
./target/release/oak-collator export-genesis-state --chain=turing-dev > genesis-state
# Generate a genesis wasm file
./target/release/oak-collator export-genesis-wasm --chain=turing-dev > genesis-wasm
Third, run the oak-collator binary.
./target/release/oak-collator \
--alice \
--collator \
--force-authoring \
--tmp \
--chain=turing-dev \
--port 40333 \
--ws-port 9946 \
-- \
--execution wasm \
--chain ./resources/rococo-local.json \
--port 30335 \
--ws-port 9977
After this command you should be able to see the stream output of the node.
- Navigate to Local relay sudo extrinsic
- Register your local parachain on the local relay chain by calling
parasSudoWrapper.sudoScheduleParaInitialize
(see the screenshot below). - Parameters:
- Once submitted, you should be able to see the id:2114 from the Parathread tab, and after a short period on the Parachains tab.
- Once Turing is onboarded as a parachain, you should see block number start to increase on Turing explorer.
This step is optional as you can spin up another project or Turing Network as the second parachain, but for testing XCM functionality we use another parachain, Mangata, as an example here.
Navigate to under mangata-node repo’s local folder. The binary built is located at ./target/release/mangata-node
.
Second, prepare two files, genesis-state and genesis-wasm, for parachain registration.
# Generate a genesis state file
./target/release/mangata-node export-genesis-state --chain=mangata-rococo-local-testnet > genesis-state
# Generate a genesis wasm file
./target/release/mangata-node export-genesis-wasm --chain=mangata-rococo-local-testnet > genesis-wasm
Lastly, start up the build.
./target/release/mangata-node --alice --collator --force-authoring --tmp --chain=mangata-rococo-local-testnet --port 50333 --ws-port 9947 -- --execution wasm --chain ../OAK-blockchain/resources/rococo-local.json --port 30336 --ws-port 9978
Note that,
–chain=mangata-rococo-local-testnet
is necessary for the chain config.- The relay chain config is the same as that of Turing, as in from the file
../OAK-blockchain/resources/rococo-local.json
- Port numbers need to be different from those of Turing, otherwise there will be port collisions
Up to this point the Mangata node is up and running, but not producing blocks yet. We will repeat the parachain onboarding process below to connect it to Rococo.
- Navigate to Local relay sudo extrinsic
- Register Mangata on the local Rococo by calling
parasSudoWrapper.sudoScheduleParaInitialize
. - Parameters:
- id: 2110
- genesisHead: switch on "File upload" and drag in the above generated
genesis-state
file. - validationCode: switch on "File upload" and drag in the
genesis-wasm
file. - parachain: Yes.
Great, at this point you have completed all steps of setting up local networks of Rococo, Turing and Mangata! In order to test XCM functionality, next refer to our guid on docs.oak.tech.
Maintainers: OAK Development Team
If you have any questions, please ask our devs on Discord
OAK blockchain is licensed under the GPLv3.0 by the OAK Network team.