From ece82611c7d3a516c17b2f9c2e1a4d754d764cc8 Mon Sep 17 00:00:00 2001 From: nuco-shidokht Date: Tue, 15 Oct 2019 14:03:19 -0400 Subject: [PATCH] Made initial self bond value an input parameter to the script --- ReadMe.md | 3 ++- Tools.jar | Bin 173776 -> 174861 bytes registerPool.sh | 12 +++++++----- src/cli/EncodeType.java | 27 +++++++++++++++++++++++++++ 4 files changed, 36 insertions(+), 6 deletions(-) create mode 100644 src/cli/EncodeType.java diff --git a/ReadMe.md b/ReadMe.md index 461cf9d..d0f6392 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -32,7 +32,7 @@ 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``` +```./registerPool.sh node_address private_key signing_address commission_rate metadata_url metadata_content_hash value``` `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.
@@ -40,6 +40,7 @@ Pool will be in an active state after registration is complete. `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).
### delegate.sh diff --git a/Tools.jar b/Tools.jar index 80299a1f9a17bc5283f77c383b3be3aae5552861..7cec734f8ba7887c6fe82c24a91ce5aaf39daa0c 100644 GIT binary patch delta 3362 zcmZuydpMQp7XS9z+a+z+luO&Kl1qs#QYyoQie#pw7@?tN#-&IdsodFYmtt=$A%u)c zsfodqE=KVeVSa~u5Pzm8TdLOa>YeTY zahyHdjorN@%03lT~K2#QM~Ukh*=h=D3`F z*j@ii)7Iawt=#TrdA!BU`-DfA*Uy2f=Whk4@;p4f?r^^|kIwF5UuGgxv zZab}KOAO5|FJCu%{8C4*|Lo4Ns~Q61h)XKNufFDne6h*Bq4s=xAIn&N#ByEWn`ArF z};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jdwcM|j!IMC`LsESk%gK9k7n!av zr#I5cAQ^;LKqTlw7zoA%;ovSiRP=(@vtu_D^z^D(Y1~QfA(!f(sg}U?9XyYhe_4r;5tCw4jAi qw;93sZ4_}%N{fx&t=m8kJ6E=0o@|4T?kl(z+^udL*RYB{WZb{Dydi!7 diff --git a/registerPool.sh b/registerPool.sh index 49efb74..151170a 100755 --- a/registerPool.sh +++ b/registerPool.sh @@ -2,7 +2,7 @@ # ----------------------------------------------------------------------------- # This script can be used to register a pool and do self bond. # -# Usage: ./registerPool.sh node_address private_key signing_address commission_rate metadata_url metadata_content_hash +# Usage: ./registerPool.sh node_address private_key signing_address commission_rate metadata_url metadata_content_hash value # ----------------------------------------------------------------------------- POOL_REGISTRY_ADDRESS="0xa01b68fa4f947ea4829bebdac148d1f7f8a0be9a8fd5ce33e1696932bef05356" @@ -73,10 +73,10 @@ function get_coinbase(){ fi } -if [ $# -ne 6 ] +if [ $# -ne 7 ] then echo "Invalid number of parameters." - echo "Usage: ./registerPool.sh node_address(ip:port) private_key signing_address commission_rate metadata_url metadata_content_hash" + echo "Usage: ./registerPool.sh node_address(ip:port) private_key signing_address commission_rate metadata_url metadata_content_hash value" exit 1 fi node_address="$1" @@ -85,6 +85,7 @@ signing_address="$3" commission="$4" metadata_url="$5" metadata_content_hash="$6" +amount="$7" if [ ${#private_key} == 130 ] then @@ -107,7 +108,7 @@ echo "Using nonce $NONCE" echo "Sending registration call..." # registerStaker(Address signingAddress, int commissionRate, byte[] metaDataUrl, byte[] metaDataContentHash) callPayload="$(java -cp $TOOLS_JAR cli.ComposeCallPayload "registerPool" "$signing_address" "$commission" "$metadata_url" "$metadata_content_hash")" -receipt=`./rpc.sh --call "$private_key" "$NONCE" "$POOL_REGISTRY_ADDRESS" "$callPayload" "1000000000000000000000"` +receipt=`./rpc.sh --call "$private_key" "$NONCE" "$POOL_REGISTRY_ADDRESS" "$callPayload" "$amount"` require_success $? echo "Transaction hash: \"$receipt\". Waiting for transaction to complete..." @@ -117,8 +118,9 @@ echo "Transaction completed" echo "Verifying that pool was registered and is active..." # getStake(Address pool, Address staker) callPayload="$(java -cp $TOOLS_JAR cli.ComposeCallPayload "getStake" "$identity_address" "$identity_address")" +amount_hex="$(java -cp $TOOLS_JAR cli.EncodeType "BigInteger" "$amount")" # This result in a BigInteger: 0x23 (byte), length (byte), value (big-endian length bytes) -verify_state "$POOL_REGISTRY_ADDRESS" "$callPayload" "0x23093635c9adc5dea00000" +verify_state "$POOL_REGISTRY_ADDRESS" "$callPayload" "$amount_hex" echo "Current stake = 1000 Aions" callPayload="$(java -cp $TOOLS_JAR cli.ComposeCallPayload "isActive" "$identity_address")" diff --git a/src/cli/EncodeType.java b/src/cli/EncodeType.java new file mode 100644 index 0000000..488803a --- /dev/null +++ b/src/cli/EncodeType.java @@ -0,0 +1,27 @@ +package cli; + +import net.i2p.crypto.eddsa.Utils; +import org.aion.avm.userlib.abi.ABIEncoder; + +import java.math.BigInteger; + +public class EncodeType { + public static void main(String[] args) { + if (0 == args.length) { + System.err.println("Usage: cli.EncodeType Type"); + System.exit(1); + } + + byte[] rawCallData = null; + String type = args[0]; + switch (type) { + case "BigInteger": + rawCallData = ABIEncoder.encodeOneBigInteger(new BigInteger(args[1])); + break; + default: + System.err.println("Type " + type + " is not defined."); + System.exit(1); + } + System.out.println("0x" + Utils.bytesToHex(rawCallData)); + } +}