Skip to content

Commit

Permalink
code updates to work with system contracts
Browse files Browse the repository at this point in the history
  • Loading branch information
ericpassmore committed May 9, 2024
1 parent ca16464 commit 05d5b9c
Show file tree
Hide file tree
Showing 10 changed files with 204 additions and 51 deletions.
3 changes: 3 additions & 0 deletions AntelopeDocker
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 10 additions & 7 deletions bin/activate_savanna.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
16 changes: 0 additions & 16 deletions bin/block_producer_schedule.sh

This file was deleted.

41 changes: 41 additions & 0 deletions bin/block_producer_setup.sh
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions bin/boot_actions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion bin/build_antelope_software.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
38 changes: 38 additions & 0 deletions bin/create_accounts.sh
Original file line number Diff line number Diff line change
@@ -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
42 changes: 42 additions & 0 deletions bin/do_snapshot.sh
Original file line number Diff line number Diff line change
@@ -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
Loading

0 comments on commit 05d5b9c

Please sign in to comment.