diff --git a/AntelopeDocker b/AntelopeDocker index d99daa7..fdd1c60 100644 --- a/AntelopeDocker +++ b/AntelopeDocker @@ -41,6 +41,9 @@ RUN git clone -b release/4.1 --single-branch https://github.com/AntelopeIO/cdt.g RUN git clone https://github.com/AntelopeIO/reference-contracts.git RUN git clone -b april_leap --single-branch https://github.com/eosnetworkfoundation/bootstrap-private-network.git WORKDIR /local/eosnetworkfoundation/repos/bootstrap-private-network +# Build uses the following +# SPRING_GIT_COMMIT_TAG=${1:-release/1.0-beta1} +# CDT_GIT_COMMIT_TAG=${2:-release/4.1} RUN /local/eosnetworkfoundation/repos/bootstrap-private-network/bin/build_antelope_software.sh USER root RUN /local/eosnetworkfoundation/repos/bootstrap-private-network/bin/install_antelope_software.sh diff --git a/bin/activate_savanna.sh b/bin/activate_savanna.sh index bd938bc..0b9a989 100755 --- a/bin/activate_savanna.sh +++ b/bin/activate_savanna.sh @@ -9,24 +9,27 @@ ENDPOINT=$1 # First array starts from the second argument to the 22st argument -PUBLIC_KEY=("${@:2:22}") +PUBLIC_KEY=("${@:2:4}") # Second array starts from the 23rd argument to the 43rd argument -PROOF_POSSESION=("${@:23:43}") +PROOF_POSSESION=("${@:5:7}") # unwindw our producer finalizer keys and make activating call # New System Contracts Replace with actions regfinkey, and switchtosvnn # regfinkey [producer name] [public key] [proof of possession] counter=0 -for producer_name in bpa bpb bpc bpd bpe bpf bpg bph bpi bpj bpk bpl bpm bpn bpo bpp bpq bpr bps bpt bpu +for producer_name in bpa bpb bpc do - let counter+=1 - # Execute the cleos command error if vars not set - cleos --url $ENDPOINT push action eosio regfinkey "${producer_name:?}" "${PUBLIC_KEY[$counter]:?}" "${PROOF_POSSESION[$counter]:?}" + # void system_contract::regfinkey( const name& finalizer_name, const std::string& finalizer_key, const std::string& proof_of_possession) + cleos --url $ENDPOINT push action eosio regfinkey "{\"finalizer_name\":\"${producer_name:?}\", \ + \"finalizer_key\":\"${PUBLIC_KEY[$counter]:?}\", \ + \"proof_of_possession\":\"${PROOF_POSSESION[$counter]:?}\"}" -p ${producer_name:?} + let counter+=1 done sleep 1 # switchtosvnn -cleos --url $ENDPOINT push action eosio switchtosvnn +# void system_contract::switchtosvnn() +cleos --url $ENDPOINT push action eosio switchtosvnn '{}' -p eosio diff --git a/bin/block_producer_schedule.sh b/bin/block_producer_schedule.sh deleted file mode 100755 index 94b78f8..0000000 --- a/bin/block_producer_schedule.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env bash - -ENDPOINT=$1 -PUBLIC_KEY=$2 - -# create 21 producers error out if vars not set -for producer_name in bpa bpb bpc bpd bpe bpf bpg bph bpi bpj bpk bpl bpm bpn bpo bpp bpq bpr bps bpt bpu -do - cleos system newaccount eosio ${producer_name:?} ${PUBLIC_KEY:?} --stake-net "50 EOS" --stake-cpu "50 EOS" --buy-ram "500 EOS" - # get some spending money - cleos --url $ENDPOINT transfer eosio ${producer_name} "10000 EOS" "init funding" - # register producer - cleos --url $ENDPOINT system regproducer ${producer_name} ${PUBLIC_KEY} -done - -# cleos --url $ENDPOINT system voteproducer prods eosio bpa bpb bpc diff --git a/bin/block_producer_setup.sh b/bin/block_producer_setup.sh new file mode 100755 index 0000000..e6046f1 --- /dev/null +++ b/bin/block_producer_setup.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env bash + +ENDPOINT_ONE=$1 +WALLET_DIR=$2 + +# create 21 producers error out if vars not set +for producer_name in bpa bpb bpc +do + [ ! -s "$WALLET_DIR/${producer_name}.keys" ] && cleos create key --to-console > "$WALLET_DIR/${producer_name}.keys" + # head because we want the first match; they may be multiple keys + PRIVATE_KEY=$(grep Private "$WALLET_DIR/${producer_name}.keys" | head -1 | cut -d: -f2 | sed 's/ //g') + PUBLIC_KEY=$(grep Public "$WALLET_DIR/${producer_name}.keys" | head -1 | cut -d: -f2 | sed 's/ //g') + cleos wallet import --name finality-test-network-wallet --private-key $PRIVATE_KEY + + # register producer + cleos --url $ENDPOINT_ONE system regproducer ${producer_name} ${PUBLIC_KEY} +done + +# create user keys +[ ! -s "$WALLET_DIR/user.keys" ] && cleos create key --to-console > "$WALLET_DIR/user.keys" +# head because we want the first match; they may be multiple keys +USER_PRIVATE_KEY=$(grep Private "$WALLET_DIR/user.keys" | head -1 | cut -d: -f2 | sed 's/ //g') +cleos wallet import --name finality-test-network-wallet --private-key $USER_PRIVATE_KEY + +for user_name in usera userb userc userd usere userf userg userh useri userj +do + # vote + cleos --url $ENDPOINT_ONE system voteproducer prods ${user_name} bpa bpb bpc +done + +for user_name in userk userl userm usern usero userp userq userr users usert useru +do + # vote + cleos --url $ENDPOINT_ONE system voteproducer prods ${user_name} bpa bpb bpc +done + +for user_name in userv userw userx usery userz +do + # vote + cleos --url $ENDPOINT_ONE system voteproducer prods ${user_name} bpa bpb bpc +done diff --git a/bin/boot_actions.sh b/bin/boot_actions.sh index 525dcf6..3ea240a 100755 --- a/bin/boot_actions.sh +++ b/bin/boot_actions.sh @@ -24,8 +24,8 @@ cleos --url $ENDPOINT create account eosio eosio.vpay $PUBLIC_KEY cleos --url $ENDPOINT create account eosio eosio.rex $PUBLIC_KEY cleos --url $ENDPOINT set contract eosio.token "$CONTRACT_DIR"/eosio.token/ -cleos --url $ENDPOINT push action eosio.token create '[ "eosio", "10000000000.0000 EOS" ]' -p eosio.token@active -cleos --url $ENDPOINT push action eosio.token issue '[ "eosio", "1000000000.0000 EOS", "initial issuance" ]' -p eosio +cleos --url $ENDPOINT push action eosio.token create '[ "eosio", "380000000.0000 EOS" ]' -p eosio.token@active +cleos --url $ENDPOINT push action eosio.token issue '[ "eosio", "380000000.0000 EOS", "initial issuance" ]' -p eosio cleos --url $ENDPOINT set contract eosio "$CONTRACT_DIR"/eosio.msig cleos --url $ENDPOINT set contract eosio "$CONTRACT_DIR"/eosio.wrap diff --git a/bin/build_antelope_software.sh b/bin/build_antelope_software.sh index e9ef278..afb6f19 100755 --- a/bin/build_antelope_software.sh +++ b/bin/build_antelope_software.sh @@ -6,7 +6,7 @@ # called from Docker Build ### -SPRING_GIT_COMMIT_TAG=${1:-main} +SPRING_GIT_COMMIT_TAG=${1:-release/1.0-beta1} CDT_GIT_COMMIT_TAG=${2:-release/4.1} NPROC=${3:-$(nproc)} TUID=$(id -ur) diff --git a/bin/create_accounts.sh b/bin/create_accounts.sh new file mode 100755 index 0000000..b550ed6 --- /dev/null +++ b/bin/create_accounts.sh @@ -0,0 +1,38 @@ +#!/usr/bin/env bash + +ENDPOINT_ONE=$1 +WALLET_DIR=$2 + +# create 21 producers error out if vars not set +for producer_name in bpa bpb bpc bpd bpe bpf bpg bph bpi bpj bpk bpl bpm bpn bpo bpp bpq bpr bps bpt bpu +do + [ ! -s "$WALLET_DIR/${producer_name}.keys" ] && cleos create key --to-console > "$WALLET_DIR/${producer_name}.keys" + # head because we want the first match; they may be multiple keys + PRIVATE_KEY=$(grep Private "$WALLET_DIR/${producer_name}.keys" | head -1 | cut -d: -f2 | sed 's/ //g') + PUBLIC_KEY=$(grep Public "$WALLET_DIR/${producer_name}.keys" | head -1 | cut -d: -f2 | sed 's/ //g') + cleos wallet import --name finality-test-network-wallet --private-key $PRIVATE_KEY + + # 400 staked per producer x21 = 8400 EOS staked total + cleos --url $ENDPOINT_ONE system newaccount eosio ${producer_name:?} ${PUBLIC_KEY:?} --stake-net "500 EOS" --stake-cpu "500 EOS" --buy-ram "1000 EOS" + # get some spending money + cleos --url $ENDPOINT_ONE transfer eosio ${producer_name} "10000 EOS" "init funding" + # self stake some net and cpu + cleos --url $ENDPOINT_ONE system delegatebw ${producer_name} ${producer_name} "4000.0 EOS" "4000.0 EOS" +done + +# create user keys +[ ! -s "$WALLET_DIR/user.keys" ] && cleos create key --to-console > "$WALLET_DIR/user.keys" +# head because we want the first match; they may be multiple keys +USER_PRIVATE_KEY=$(grep Private "$WALLET_DIR/user.keys" | head -1 | cut -d: -f2 | sed 's/ //g') +USER_PUBLIC_KEY=$(grep Public "$WALLET_DIR/user.keys" | head -1 | cut -d: -f2 | sed 's/ //g') +cleos wallet import --name finality-test-network-wallet --private-key $USER_PRIVATE_KEY + +for user_name in usera userb userc userd usere userf userg userh useri userj userk userl userm usern usero userp userq userr users usert useru userv userw userx usery userz +do + # create user account + cleos --url $ENDPOINT_ONE system newaccount eosio ${user_name:?} ${USER_PUBLIC_KEY:?} --stake-net "50 EOS" --stake-cpu "50 EOS" --buy-ram "100 EOS" + # get some spending money + cleos --url $ENDPOINT_ONE transfer eosio ${user_name} "11540000 EOS" "init funding" + # stake 1154K EOS x26 accounts = 300,004,000 EOS Total Staked + cleos --url $ENDPOINT_ONE system delegatebw ${user_name} ${user_name} "5770000.000 EOS" "5770000.0000 EOS" +done diff --git a/bin/do_snapshot.sh b/bin/do_snapshot.sh new file mode 100755 index 0000000..0134cf0 --- /dev/null +++ b/bin/do_snapshot.sh @@ -0,0 +1,42 @@ +#!/usr/bin/env bash + +ENDPOINT=${1:-http://127.0.0.1:8888} + +SNAPSHOT_DIR="/bigata1/savanna" +curl -X POST "${ENDPOINT}/v1/producer/create_snapshot" > ${SNAPSHOT_DIR}/snapshot.json +SNAP_PATH=$(cat "${SNAPSHOT_DIR}/snapshot.json" | \ + python3 -c "import sys +import json +print (json.load(sys.stdin)['snapshot_name'])") +SNAP_HEAD_BLOCK=$(cat "${SNAPSHOT_DIR}/snapshot.json" | \ + python3 -c "import sys +import json +print (json.load(sys.stdin)['head_block_num'])") +VERSION=$(cat "${SNAPSHOT_DIR}/snapshot.json" | \ + python3 -c "import sys +import json +print (json.load(sys.stdin)['version'])") +HEAD_BLOCK_TIME=$(cat "${SNAPSHOT_DIR}/snapshot.json" | \ + python3 -c "import sys +import json +print (json.load(sys.stdin)['head_block_time'])") + +DATE=${HEAD_BLOCK_TIME%T*} +TIME=${HEAD_BLOCK_TIME#*T} +HOUR=${TIME%%:*} +DATE="${DATE}-${HOUR}" +if type zstd >/dev/null 2>&1; then + # rename to our format snapshot-2019-08-11-16-eos-v6-0073487941.bin.zst + NEW_PATH="${SNAP_PATH%/*}/snapshot-${DATE}-eos-v${VERSION}-${SNAP_HEAD_BLOCK}.bin.zst" + zstd < "$SNAP_PATH" > "$NEW_PATH" + if [ $? -eq 0 ]; then + rm "$SNAP_PATH" + fi +else + NEW_PATH="${SNAP_PATH%/*}/snapshot-${DATE}-eos-v${VERSION}-${SNAP_HEAD_BLOCK}.bin.gzip" + gzip < "$SNAP_PATH" > "$NEW_PATH" + if [ $? -eq 0 ]; then + rm "$SNAP_PATH" + fi +fi +rm ${SNAPSHOT_DIR}/snapshot.json diff --git a/bin/finality_test_network.sh b/bin/finality_test_network.sh index db324c3..f5979b7 100755 --- a/bin/finality_test_network.sh +++ b/bin/finality_test_network.sh @@ -7,8 +7,15 @@ # CLEAN out data from previous network # STOP all nodes on network # START 3 node network +# BACKUP take snapshots on each running nodeos #### +# config information +NODEOS_ONE_PORT=8888 +NODEOS_TWO_PORT=6888 +NODEOS_THREE_PORT=7888 +ENDPOINT="http://127.0.0.1:${NODEOS_ONE_PORT}" + COMMAND=${1:-"NA"} ROOT_DIR="/bigata1/savanna" LOG_DIR="/bigata1/log" @@ -27,7 +34,7 @@ stop_func() { echo $p && kill -15 $p done echo "waiting for production network to quiesce..." - sleep 60 + sleep 5 } ### END STOP Command @@ -60,16 +67,17 @@ start_func() { exit 127 fi - # get config information - NODEOS_ONE_PORT=8888 - ENDPOINT="http://127.0.0.1:${NODEOS_ONE_PORT}" - # create private key [ ! -d "$WALLET_DIR" ] && mkdir -p "$WALLET_DIR" - [ ! -f "$WALLET_DIR"/finality-test-network.keys ] && cleos create key --to-console > "$WALLET_DIR"/finality-test-network.keys + [ ! -s "$WALLET_DIR"/finality-test-network.keys ] && cleos create key --to-console > "$WALLET_DIR"/finality-test-network.keys # head because we want the first match; they may be multiple keys EOS_ROOT_PRIVATE_KEY=$(grep Private "${WALLET_DIR}"/finality-test-network.keys | head -1 | cut -d: -f2 | sed 's/ //g') EOS_ROOT_PUBLIC_KEY=$(grep Public "${WALLET_DIR}"/finality-test-network.keys | head -1 | cut -d: -f2 | sed 's/ //g') + # create keys for first three producers + for producer_name in bpa bpb bpc + do + [ ! -s "$WALLET_DIR/${producer_name}.keys" ] && cleos create key --to-console > "$WALLET_DIR/${producer_name}.keys" + done # create initialize genesis file; create directories; copy cofigs into place if [ "$COMMAND" == "CREATE" ]; then @@ -104,24 +112,31 @@ start_func() { # create accounts, activate protocols, create tokens, set system contracts sleep 1 "$SCRIPT_DIR"/boot_actions.sh "$ENDPOINT" "$CONTRACT_DIR" "$EOS_ROOT_PUBLIC_KEY" - "$SCRIPT_DIR"/block_producer_schedule.sh "$ENDPOINT" "$EOS_ROOT_PUBLIC_KEY" + sleep 1 + # create producer and user accounts, stake EOS + "$SCRIPT_DIR"/create_accounts.sh "$ENDPOINT" "$CONTRACT_DIR" + sleep 1 + # register producers and users vote for producers + "$SCRIPT_DIR"/block_producer_setup.sh "$ENDPOINT" "$WALLET_DIR" # need a long sleep here to allow time for new production schedule to settle - echo "please wait 60 seconds while we wait for new producer schedule to settle" - sleep 60 + echo "please wait 5 seconds while we wait for new producer schedule to settle" + sleep 5 kill -15 $NODEOS_ONE_PID # wait for shutdown - sleep 15 + sleep 5 fi # if CREATE we bootstraped the node and killed it # if START we have no node running # either way we need to start Node One + BPA_PRIVATE_KEY=$(grep Private "$WALLET_DIR/bpa.keys" | head -1 | cut -d: -f2 | sed 's/ //g') + BPA_PUBLIC_KEY=$(grep Public "$WALLET_DIR/bpa.keys" | head -1 | cut -d: -f2 | sed 's/ //g') nodeos --agent-name "Finality Test Node One" \ --http-server-address 0.0.0.0:${NODEOS_ONE_PORT} \ --p2p-listen-endpoint 0.0.0.0:1444 \ --enable-stale-production \ --producer-name bpa \ - --signature-provider ${EOS_ROOT_PUBLIC_KEY}=KEY:${EOS_ROOT_PRIVATE_KEY} \ + --signature-provider ${BPA_PUBLIC_KEY}=KEY:${BPA_PRIVATE_KEY} \ --config "$ROOT_DIR"/config.ini \ --data-dir "$ROOT_DIR"/nodeos-one/data \ --p2p-peer-address 127.0.0.1:2444 \ @@ -129,47 +144,56 @@ start_func() { # start nodeos two echo "please wait while we fire up the second node" - sleep 5 + sleep 2 + + BPB_PRIVATE_KEY=$(grep Private "$WALLET_DIR/bpb.keys" | head -1 | cut -d: -f2 | sed 's/ //g') + BPB_PUBLIC_KEY=$(grep Public "$WALLET_DIR/bpb.keys" | head -1 | cut -d: -f2 | sed 's/ //g') if [ "$COMMAND" == "CREATE" ]; then nodeos --genesis-json ${ROOT_DIR}/genesis.json --agent-name "Finality Test Node Two" \ - --http-server-address 0.0.0.0:6888 \ + --http-server-address 0.0.0.0:${NODEOS_TWO_PORT} \ --p2p-listen-endpoint 0.0.0.0:2444 \ + --enable-stale-production \ --producer-name bpb \ - --signature-provider ${EOS_ROOT_PUBLIC_KEY}=KEY:${EOS_ROOT_PRIVATE_KEY} \ + --signature-provider ${BPB_PUBLIC_KEY}=KEY:${BPB_PRIVATE_KEY} \ --config "$ROOT_DIR"/config.ini \ --data-dir "$ROOT_DIR"/nodeos-two/data \ --p2p-peer-address 127.0.0.1:1444 \ --p2p-peer-address 127.0.0.1:3444 > $LOG_DIR/nodeos-two.log 2>&1 & else nodeos --agent-name "Finality Test Node Two" \ - --http-server-address 0.0.0.0:6888 \ + --http-server-address 0.0.0.0:${NODEOS_TWO_PORT} \ --p2p-listen-endpoint 0.0.0.0:2444 \ + --enable-stale-production \ --producer-name bpb \ - --signature-provider ${EOS_ROOT_PUBLIC_KEY}=KEY:${EOS_ROOT_PRIVATE_KEY} \ + --signature-provider ${BPB_PUBLIC_KEY}=KEY:${BPB_PRIVATE_KEY} \ --config "$ROOT_DIR"/config.ini \ --data-dir "$ROOT_DIR"/nodeos-two/data \ --p2p-peer-address 127.0.0.1:1444 \ --p2p-peer-address 127.0.0.1:3444 > $LOG_DIR/nodeos-two.log 2>&1 & fi echo "please wait while we fire up the third node" - sleep 10 + sleep 5 + BPC_PRIVATE_KEY=$(grep Private "$WALLET_DIR/bpc.keys" | head -1 | cut -d: -f2 | sed 's/ //g') + BPC_PUBLIC_KEY=$(grep Public "$WALLET_DIR/bpc.keys" | head -1 | cut -d: -f2 | sed 's/ //g') if [ "$COMMAND" == "CREATE" ]; then nodeos --genesis-json ${ROOT_DIR}/genesis.json --agent-name "Finality Test Node Three" \ - --http-server-address 0.0.0.0:7888 \ + --http-server-address 0.0.0.0:${NODEOS_THREE_PORT} \ --p2p-listen-endpoint 0.0.0.0:3444 \ + --enable-stale-production \ --producer-name bpc \ - --signature-provider ${EOS_ROOT_PUBLIC_KEY}=KEY:${EOS_ROOT_PRIVATE_KEY} \ + --signature-provider ${BPC_PUBLIC_KEY}=KEY:${BPC_PRIVATE_KEY} \ --config "$ROOT_DIR"/config.ini \ --data-dir "$ROOT_DIR"/nodeos-three/data \ --p2p-peer-address 127.0.0.1:1444 \ --p2p-peer-address 127.0.0.1:2444 > $LOG_DIR/nodeos-three.log 2>&1 & else nodeos --agent-name "Finality Test Node Three" \ - --http-server-address 0.0.0.0:7888 \ + --http-server-address 0.0.0.0:${NODEOS_THREE_PORT} \ --p2p-listen-endpoint 0.0.0.0:3444 \ + --enable-stale-production \ --producer-name bpc \ - --signature-provider ${EOS_ROOT_PUBLIC_KEY}=KEY:${EOS_ROOT_PRIVATE_KEY} \ + --signature-provider ${BPC_PUBLIC_KEY}=KEY:${BPC_PRIVATE_KEY} \ --config "$ROOT_DIR"/config.ini \ --data-dir "$ROOT_DIR"/nodeos-three/data \ --p2p-peer-address 127.0.0.1:1444 \ @@ -177,7 +201,7 @@ start_func() { fi echo "waiting for production network to sync up..." - sleep 60 + sleep 20 } ## end START/CREATE COMMAND @@ -215,7 +239,7 @@ if [ "$COMMAND" == "SAVANNA" ]; then PUBLIC_KEY=() PROOF_POSSESION=() # producers - for producer_name in bpa bpb bpc bpd bpe bpf bpg bph bpi bpj bpk bpl bpm bpn bpo bpp bpq bpr bps bpt bpu + for producer_name in bpa bpb bpc do spring-util bls create key --to-console > "${WALLET_DIR:?}"/"${producer_name}.finalizer.key" PUBLIC_KEY+=( $(grep Public "${WALLET_DIR}"/"${producer_name}.finalizer.key" | cut -d: -f2 | sed 's/ //g') ) \ @@ -230,7 +254,7 @@ if [ "$COMMAND" == "SAVANNA" ]; then echo "need to reload config: please wait shutting down node" stop_func - echo "need to reload config: please wait startu up nodes" + echo "need to reload config: please wait while we startup up nodes" start_func "START" echo "running final command to activate finality" @@ -238,6 +262,17 @@ if [ "$COMMAND" == "SAVANNA" ]; then "$SCRIPT_DIR"/open_wallet.sh "$WALLET_DIR" # array will expand to multiple arguments on receiving side "$SCRIPT_DIR"/activate_savanna.sh "$ENDPOINT" "${PUBLIC_KEY[@]}" "${PROOF_POSSESION[@]}" + echo "please wait for transition to Savanna consensus" + sleep 30 + grep 'Transitioning to savanna' "$LOG_DIR"/nodeos-one.log + grep 'Transition to instant finality' "$LOG_DIR"/nodeos-one.log +fi + +if [ "$COMMAND" == "BACKUP" ]; then + for loc in "http://127.0.0.1:${NODEOS_ONE_PORT}" "http://127.0.0.1:${NODEOS_TWO_PORT}" "http://127.0.0.1:${NODEOS_THREE_PORT}" + do + $SCRIPT_DIR/do_snapshot.sh $loc + done fi echo "COMPLETED COMMAND ${COMMAND}" diff --git a/bin/install_antelope_software.sh b/bin/install_antelope_software.sh index e5e30d4..6c2e8f1 100755 --- a/bin/install_antelope_software.sh +++ b/bin/install_antelope_software.sh @@ -18,7 +18,14 @@ if [ "$TUID" -eq 0 ]; then CDT_BUILD_DIR="${ROOT_DIR}"/repos/cdt/build cd "${SPRING_BUILD_DIR:?}" || exit - dpkg -i ./spring_[1-9].[0-9].[0-9]*-ubuntu22.04_amd64.deb + PRIME_LOC='./spring_[1-9].[0-9].[0-9]*-ubuntu22.04_amd64.deb' + SECOND_LOC='./_CPack_Packages/Linux/DEB/spring_[1-9].[0-9].[0-9]*-ubuntu22.04_amd64.deb' + if [ -e $PRIME_LOC ]; then + dpkg -i $PRIME_LOC + else + dpkg -i $SECOND_LOC + fi + cd "${CDT_BUILD_DIR:?}" || exit make install