The project Nulink-chain is trying to bridge the NuCypher Network from Ethereum to the Polkadot Ecosystem. The NuCypher Network is a decentralized network of nodes that perform threshold cryptography operations which are serving users with secret management and dynamic access control.
NuLink network is using a fresh FRAME-based Substrate node, ready for hacking 🚀
Instructions for setting up working environment of the Rust programming language can
be found at the
Substrate Developer Hub. Follow those
steps to install rustup
and configure the Rust toolchain to default with the
latest stable version.
This project uses a Makefile to document helpful commands and make them easier to be executed.
Get started by running these make
targets:
make init
- Run the init script to configure the Rust toolchain for WebAssembly compilation.make run
- Build and launch this project in development mode.
The init script and Makefile both specify the version of the Rust nightly compiler which this project is depending on.
The cargo run
command will perform an initial build. Use the following command to build the node
without launching it:
cargo build --release
or you can do cargo build
or cargo build --release
to build it. and you can run cargo test
to run the tests.
cargo build
or
cargo test
Once the project has been built, the following command can be used to explore all parameters and subcommands:
./target/release/nulink-chain -h
The provided cargo run
command will launch a temporary node and its state will be discarded after
you terminate the process. After the project has been built, there are other ways to launch the
node.
This command will start the single-node development chain with persistent state:
./target/release/nulink-chain --dev
Purge the development chain's state:
./target/release/nulink-chain purge-chain --dev
Start the development chain with detailed logging:
RUST_LOG=debug RUST_BACKTRACE=1 ./target/release/nulink-chain -lruntime=debug --dev
Once the nulink-node is running locally, you can connect it with Polkadot-JS Apps front-end to interact with your chain. Click here connecting the Apps to your local nulink-node.
If you want to see the multi-node consensus algorithm in action, refer to our Start a Private Network tutorial.
A simple way of using NULINK-NETWORK is to run a local node by using this command ./target/release/nulink-chain --dev --tmp --ws-external
. After you run the local node, you can use the Polkadot JS UI to connect to your local node.
After you connect to your local node , you have to paste the config types in the settings. After that you can start to register the watcher node and make all the functions work.
1. register watcher
2. synchronize the staker by watcher
3. deposit local asset for reward
4. claim reward by staker
5. create policy by user
6. revoke policy by user
Also we provide a parachain for testing. You need to connect to our test network by filling the custom endpoint. The endpoint for our test parachain is wss://testnet-pok.nulink.org. In our test network, the watcher has already been registered and it will automatically retrieve the staker information from Ethereum and update it here. The implementation of watcher node can be found here.
The first step in using this pallet is to register the watcher. If you are connecting to our test network, then you can skip this step as we have already done it.
And if you are connecting to your own local node, you can use the inherent user alice
(also you can create an new account, but you need transfer enough token to afford the extrinsic fee) and register it as the watcher by submitting an extrinsic with the nuproxy.register_watcher
function.
origin
: the owner of the watcher, in our example it'salice
.
Remark: Single watcher is supported currently in this version and the watcher can only be registered once. If you connect to our test parachain and try to register your own account as watcher, it will report failure and return a OnlyOneWatcher warning.
If you are connecting to our test network, then you can also skip this step as the watcher node would automatically sync the staker information in epoch base. The epoch is defined in the NuCypher contract in the Ethereum network(7 days currently).
If you are connecting to your own local parachain. you can now use your watcher account to synchronize the staker information from Ethereum to your parachain by submitting the extrinsic nuproxy.update_staker_infos_and_mint
. This function is used for updating the staker infos and calculating reward upon request.
origin
: the watcher account(alice
) registered bynuproxy.register_watcher
interface.infos
: the new list of stakers in the next epoch from ethereum by watcher set.(workbase is the Ethereum address of the staker, coinbase is the bonding parachain address, iswork is the flag to identify if the staker is on duty or not for the upcoming period, locked balance is the amount of the staked NuCypher token, and workcount is a metric to record the number of PRE services this staker provides)
Everyone(normally the DAO treasury) can deposit assets(Local asset[NLK
]) to the vault by submitting an extrinsic with nuproxy.reserve_to_vault
function. The asset in the vault is used for assigning basic rewards to the stakers.
origin
: the account(alice
) who reserves the asset to vault.amount
: the amount of the local asset(NLK).
The stakers can retrieve rewards any time by submitting an extrinsic with nuproxy.claim_reward_by_staker
.
origin
: the staker user account.amount
: the amount of the local asset(NLK).
The staker can check their reward balance through the state query nuproxy.rewards
.
Remark1: The rewards accumulated in the current epoch can be claimed after this epoch.
Remark2:If you are connecting to the test network, you may need to add the following staker account in order to sign this extrinsics. You can fill the raw seed when adding the staker account: 0xc8a9dda922026f8cb4619daacecaceaa04c731633cd61a358f5d8803ffe0fd76 or 0x8122683602e7c8ae75076d70c0ffcdec28ba15cd409b42e04001f2f2571391a7.
When user Alice grant access to Bob, the Nucpher client would first create a policy off-chain and then publish this policy in Polkadot parachain(please refer here for more details regarding creating a policy in Nucypher). Users Alice need to use policy.create_policy
to create policy in the Nulink Network.
origin
: the user account(alice
) who can create policy.pid
: the ID of the policy which is produced by the user off-line(Policy ID is used to identify the policy in the Ursulas network and is uniquely generated when the data owner grants access to the data receiver in the Nucypher client. It is the hash of the pubkey of the data owner, the pubkey of the data receiver and the policy label. Please check here for more infos).amount
: the amount of the local asset(NLK) for rewarding the staker.period
: the time range for the staker to process the policy. it's counted by the number of block numbers.stakers
: the address of the worker who will serve the PRE service for the user.
You can check the current stake list through the state query nuproxy.stakes
.
Users who have created a policy can use policy.revoke_policy
to revoke the policy before it expires. The remaining fees of this policy will be returned to the policy creator.
origin
: the user account(alice
) who has created the policy.pid
: the ID of the policy which is produced by the user outside.
The policy creator can claim back all his remaining balance after he revokes the policy. He can simply send thenuproxy.claim_reward_by_user
extrinsic.