The purpose of this tooling is to run through the initial deployment and configuration of the staker and pool registry contracts.
Note that this is really quick-and-dirty so just setup as an Eclipse project. In order to avoid requiring the building being done by everyone, I uploaded the built Tools.jar
which includes the functionality here. If this becomes long-lived, we can generalize the build to make it a basic ant
task so everyone can easily build and package it after making changes.
Tools.jar
- as mentioned, this includes the functionality of note which these scripts depend on. The main entry-points arecli.PackageJarAsHex
which takes the JAR given as a path argument and returns it as a hex string andcli.SignTransaction
which takes a private key and other data to produce the hex string containing the entire raw transaction.stakerRegistry.jar
- the StakerRegistry smart contract. This is just the resource built from that project, committed here for convenience.poolRegistry.jar
- the PoolRegistry smart contract. This is just the resource built from that project, committed here for convenience.rpc.sh
- adapted from the pre-node_test_harness functional test demonstration, this provides some of the lower-level logic around interacting with the JCON-RPC on the server as well as functionality fromTools.jar
.bootstrap.sh
- the top-level script which takes no arguments and will synchronously perform all operations required to bootstrap PoS block production on a running PoW Unity cluster.deploy.sh
- deploys StakerRegistry and PoolRegistry contracts.registerPool.sh
- registers a pool and does a self-bond.delegate.sh
- delegates stake to a pool.undelegate.sh
- undelegates the amount specified from pool.transferDelegation.sh
- transfers stake from one pool to another.withdrawRewards.sh
- withdraws the block rewards of a delegator.finalizeUndelegate.sh
- finalizes an undelegate Id.finalizeTransfer.sh
- finalizes a transfer Id.
This script registers a pool and does a self bond to put the pool in an active state.
Usage:
./registerPool.sh node_address private_key signing_address commission_rate metadata_url metadata_content_hash
node_address
node address in ip:port format.
private_key
private key of the pool identity address (32 bytes).
signing_address
signing address of the pool.
commission_rate
the pool commission rate with 4 decimal places of granularity (between [0, 1000000]).
metadata_url
url hosting the metadata json file.
metadata_content_hash
Blake2b hash of the json object hosted at the metadata url.
This script delegates stake to a pool.
Usage:
./delegate.sh node_address delegator_private_key pool_identity_address amount
node_address
node address in ip:port format.
delegator_private_key
private key of the delegator (32 bytes).
pool_identity_address
pool identity address.
amount
delegation amount in nAmps.
It outputs the current stake of the delegator in the pool.
This script undelegates stake from a pool.
Usage:
./undelegate.sh node_address delegator_private_key pool_identity_address amount fee
node_address
node address in ip:port format.
delegator_private_key
private key of the delegator (32 bytes).
pool_identity_address
pool identity address.
amount
undelegation amount in nAmps.
fee
the amount of stake that will be transferred to the account that invokes finalizeUndelegate.
It outputs the current stake of the delegator in the pool, followed by the undelegate Id.
This script can be used to transfer stake from one pool to another pool.
Usage:
./transferDelegation.sh node_address delegator_private_key from_pool_identity_address to_pool_identity_address amount fee
node_address
node address in ip:port format.
delegator_private_key
private key of the delegator (32 bytes).
from_pool_identity_address
the pool address where the stake is removed from.
to_pool_identity_address
the pool address where the stake is transferred to.
amount
transfer amount in nAmps.
fee
the amount of stake that will be transferred to the account that invokes finalizeTransfer.
It outputs the current stake of the delegator in the from pool, followed by the transfer Id.
This script can be used to withdraw block rewards.
Usage:
./withdrawRewards.sh node_address delegator_private_key pool_identity_address
node_address
node address in ip:port format.
delegator_private_key
private key of the delegator (32 bytes).
pool_identity_address
pool identity address.
It outputs the total amount of rewards withdrawn (in nAmps).
This script can be used to finalize an undelegation.
Usage:
./finalizeUndelegate.sh node_address caller_private_key undelegate_Id
node_address
node address in ip:port format.
caller_private_key
private key of the account making the transaction (32 bytes).
undelegate_Id
Id to finalize.
This script can be used to finalize a transfer.
Usage:
./finalizeTransfer.sh node_address caller_private_key transfer_Id
node_address
node address in ip:port format.
caller_private_key
private key of the account making the transaction (32 bytes).
transfer_Id
Id to finalize.
In order to run this
- Ensure that the cluster is in a clean state (we depend on this being the first transaction that the premined account has sent).
- Ensure that a node attached to the cluster is running, with JSON-RPC port open, on 127.0.0.1 (NOTE: The IP/host and port can be changed in
rpc.sh
). - Run
./bootstrap.sh
and wait for it to complete (takes a minute since it requires at least 3 blocks to be mined). - Cluster is now bootstrapped and the premined account is now a valid staker.
What this does:
- Deploys the StakingRegistry contract as the premined account.
- Registers the premined account as a staker.
- Votes 1 billion Wei (whatever we call the base unit on Aion) for the premined account, from the premined account.
- Verifies that there is indeed 1 billion voted for the premined account.