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.hashFile.sh
- prints the blake-2b hash of the input file.updateMetaData.sh
- updates the metadata of the pool.requestCommissionRateChange.sh
- requests commission rate to be updated. This is an asynchronous task that needs to be finalized.finalizeCommissionRateChange.sh
- finalizes an update commission rate request Id.
This script registers a new pool in PoolRegistry. Registration is done by passing the minimum self bond value in the transaction. Pool will be in an active state after registration is complete.
Usage:
./registerPool.sh node_address private_key signing_address commission_rate metadata_url metadata_content_hash value network_name
node_address
node address in ip:port format.
private_key
private key of the pool identity address. Private key should start with 0x
. Both 32 and 64 byte keys are accepted as an input.
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.
value
value in nAmps to pass along the transaction. This will be counted towards the self-bond value and has to be at least 1000 Aions (1000000000000000000000 nAmps).
network_name
name of the network running on the node. Network name is case insensitive. Currently only amity
and mainnet
networks are supported.
This script delegates stake to a pool.
Usage:
./delegate.sh node_address delegator_private_key pool_identity_address amount network_name
node_address
node address in ip:port format.
delegator_private_key
private key of the delegator. Private key should start with 0x
. Both 32 and 64 byte keys are accepted as an input.
pool_identity_address
pool identity address.
amount
delegation amount in nAmps.
network_name
name of the network running on the node. Network name is case insensitive. Currently only amity
and mainnet
networks are supported.
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 network_name
node_address
node address in ip:port format.
delegator_private_key
private key of the delegator. Private key should start with 0x
. Both 32 and 64 byte keys are accepted as an input.
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.
network_name
name of the network running on the node. Network name is case insensitive. Currently only amity
and mainnet
networks are supported.
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 network_name
node_address
node address in ip:port format.
delegator_private_key
private key of the delegator. Private key should start with 0x
. Both 32 and 64 byte keys are accepted as an input.
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.
network_name
name of the network running on the node. Network name is case insensitive. Currently only amity
and mainnet
networks are supported.
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 network_name
node_address
node address in ip:port format.
delegator_private_key
private key of the delegator. Private key should start with 0x
. Both 32 and 64 byte keys are accepted as an input.
pool_identity_address
pool identity address.
network_name
name of the network running on the node. Network name is case insensitive. Currently only amity
and mainnet
networks are supported.
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 network_name
node_address
node address in ip:port format.
caller_private_key
private key of the account making the transaction. Private key should start with 0x
. Both 32 and 64 byte keys are accepted as an input.
undelegate_Id
Id to finalize.
network_name
name of the network running on the node. Network name is case insensitive. Currently only amity
and mainnet
networks are supported.
This script can be used to finalize a transfer.
Usage:
./finalizeTransfer.sh node_address caller_private_key transfer_Id network_name
node_address
node address in ip:port format.
caller_private_key
private key of the account making the transaction. Private key should start with 0x
. Both 32 and 64 byte keys are accepted as an input.
transfer_Id
Id to finalize.
network_name
name of the network running on the node. Network name is case insensitive. Currently only amity
and mainnet
networks are supported.
This script prints the blake-2b hash of the input file and can be used to generate the hash of the meta-data json file.
Usage:
./hashFile.sh path_to_file
This script can be used to update the pool's metadata in the contract.
Usage:
./updateMetaData.sh node_address(ip:port) pool_private_key metadata_url metadata_content_hash network_name
node_address
node address in ip:port format.
pool_private_key
private key of pool's identity address. Private key should start with 0x
. Both 32 and 64 byte keys are accepted as an input.
metadata_url
url hosting the metadata json file.
metadata_content_hash
Blake2b hash of the json object hosted at the metadata url.
network_name
name of the network running on the node. Network name is case insensitive. Currently only amity
and mainnet
networks are supported.
This script can be used to request commission rate to be updated.
Usage:
./requestCommissionRateChange.sh node_address(ip:port) pool_private_key new_commission_rate network_name
node_address
node address in ip:port format.
pool_private_key
private key of pool's identity address. Private key should start with 0x
. Both 32 and 64 byte keys are accepted as an input.
new_commission_rate
new commission rate.
network_name
name of the network running on the node. Network name is case insensitive. Currently only amity
and mainnet
networks are supported.
This script can be used to finalize commission rate change.
Usage:
./finalizeCommissionRateChange.sh node_address(ip:port) pool_private_key request_Id network_name
node_address
node address in ip:port format.
pool_private_key
private key of pool's identity address. Private key should start with 0x
. Both 32 and 64 byte keys are accepted as an input.
request_Id
Id to finalize.
network_name
name of the network running on the node. Network name is case insensitive. Currently only amity
and mainnet
networks are supported.
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.
- Verifies that there is indeed 1 billion voted for the premined account.