Skip to content

Commit

Permalink
Initial commit of eosdac-testnet scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeljyeates committed Oct 3, 2018
1 parent 3f59af0 commit f499172
Show file tree
Hide file tree
Showing 13 changed files with 382 additions and 0 deletions.
25 changes: 25 additions & 0 deletions eosdac-testnet/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# eosDAC testnet

These scripts will install and configure eosDAC contracts on a freshly started chain.

## Configuration

Copy the configuration files conf.example.sh, conf_private.example.sh and conf_dac.example.sh to conf.sh, conf_private.sh and conf_dac.sh

You will need to modify all of the files to your needs, make sure that the public key in conf_private.sh matches your genesis.json file

## boot.sh

This script will boot the base eosio chain and install the system contracts.

## populate.sh

This will populate all of the eosDAC contracts as well as developer, test custodian and test voter accounts.

## build.sh

Will compile and install the eosDAC contrats, run this if you modify the contracts after booting for the first time.

## permissions.sh

All the DAC accounts will be resigned and permissions set up to allow the dac to operate.
90 changes: 90 additions & 0 deletions eosdac-testnet/boot.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
#!/bin/bash

green=`tput setaf 2`
reset=`tput sgr0`

source ./conf_private.sh
source ./conf.sh



echo -e "\n\n----------------- BOOT SEQUENCE -------------------\n\n";

run_cmd() {
cmd="$1";
echo -e "\n\n >> ${green} Next command: $1 \n\n ${reset}";
#wait;
#read -p "Press enter to continue ${reset}";
eval "cleos -u $API_URL $1";
}

create_act() {
act="$1"
key="$2"
eval "cleos -u $API_URL system newaccount --stake-cpu \"10.0000 EOS\" --stake-net \"10.0000 EOS\" --transfer --buy-ram-kbytes 1024 eosio $act $key"
}


run_cmd "set contract eosio "$CONTRACTS/eosio.bios" -p eosio";

run_cmd "create account eosio eosio.msig $EOSIO_PUB"
sleep 1;
cleos -u $API_URL get account eosio.msig;

run_cmd "create account eosio eosio.token $EOSIO_PUB"
sleep 1;
cleos -u $API_URL get account eosio.token;

run_cmd "create account eosio eosio.ram $EOSIO_PUB"
sleep 1;
cleos -u $API_URL get account eosio.ram;

run_cmd "create account eosio eosio.ramfee $EOSIO_PUB"
sleep 1;
cleos -u $API_URL get account eosio.ramfee;

run_cmd "create account eosio eosio.names $EOSIO_PUB"
sleep 1;
cleos -u $API_URL get account eosio.names;

run_cmd "create account eosio eosio.stake $EOSIO_PUB"
sleep 1;
cleos -u $API_URL get account eosio.stake;

run_cmd "create account eosio eosio.saving $EOSIO_PUB"
sleep 1;
cleos -u $API_URL get account eosio.saving;

run_cmd "create account eosio eosio.bpay $EOSIO_PUB"
sleep 1;
cleos -u $API_URL get account eosio.bpay;

run_cmd "create account eosio eosio.vpay $EOSIO_PUB"
sleep 1;
cleos -u $API_URL get account eosio.vpay;

run_cmd "push action eosio setpriv "'["eosio.msig",1]'" -p eosio"
sleep 1;
cleos -u $API_URL get account -j eosio.msig | jq

run_cmd "set contract eosio.msig "$CONTRACTS/eosio.msig" -p eosio.msig"
run_cmd "get code eosio.msig"

run_cmd "set contract eosio.token "$CONTRACTS/eosio.token" -p eosio.token"
run_cmd "get code eosio.token"

cleos -u $API_URL push action eosio.token create '["eosio","10000000000.0000 EOS"]' -p eosio.token

cleos -u $API_URL get currency stats eosio.token EOS

cleos -u $API_URL push action eosio.token issue '["eosio", "1000000000.0000 EOS", "initial issuance"]' -p eosio

cleos -u $API_URL get currency stats eosio.token EOS




# Install system contract
run_cmd "set contract eosio "$CONTRACTS/eosio.system" -p eosio"

run_cmd "get code eosio"
35 changes: 35 additions & 0 deletions eosdac-testnet/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash

green=`tput setaf 2`
reset=`tput sgr0`

source ./conf_private.sh
source ./conf_dac.sh
source ./conf.sh

run_cmd() {
cmd="$1";
echo -e "\n\n >> ${green} Next command: $1 \n\n ${reset}";
#wait;
#read -p "Press enter to continue ${reset}";
eval "cleos -u $API_URL $1";
}

echo -e "\n\n----------------- BUILDING CONTRACTS -------------------\n\n";

PWD=`pwd`

cd $DACCONTRACTS/daccustodian/
git pull
$EOSIOCPP -o daccustodian.wast daccustodian.cpp

cd $DACCONTRACTS/eosdactoken/
git pull
cd eosdactoken/
$EOSIOCPP -o eosdactoken.wast eosdactoken.cpp

cd $PWD

run_cmd "set contract "$dactokens" "$DACCONTRACTS/eosdactoken/eosdactoken" -p eosdactokens"

run_cmd "set contract "$daccustodian" "$DACCONTRACTS/daccustodian" -p daccustodian"
4 changes: 4 additions & 0 deletions eosdac-testnet/conf.example.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
API_URL="http://127.0.0.1:8888"
CONTRACTS="/path/to/eos/build/contracts"
DACCONTRACTS="/path/to/eosdac/contracts"
EOSIOCPP="eosio-cpp"
12 changes: 12 additions & 0 deletions eosdac-testnet/conf_dac.example.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# eosDAC specific accounts and contracts
# The account holding the custodian (voting) contract
daccustodian="daccustodian"
# An empty account used to represent various permission levels
# All other DAC accounts will eventually point back to this
dacauthority="dacauthority"
# The token contract account
dactokens="eosdactokens"
# The money owning account. It is assumed that all tokens owned will be kept here
dacowner="eosdacthedac"
# An extra account used by eosDAC
dacextra="eosdacserver"
5 changes: 5 additions & 0 deletions eosdac-testnet/conf_private.example.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Enter public and private key for eosio, this should match the public key in
# the genesis.json file. This key will also be used to create all system and
# DAC accounts
EOSIO_PUB="EOS...";
EOSIO_PVT="5...";
1 change: 1 addition & 0 deletions eosdac-testnet/dac_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
["10.0000 EOSDAC", 5, 12, 600, "dacauthority", "eosdacthedac", 15, 3, 11, 9, 7, 360, "50.0000 EOS"]
54 changes: 54 additions & 0 deletions eosdac-testnet/permissions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/bin/bash

green=`tput setaf 2`
reset=`tput sgr0`

source ./conf_private.sh
source ./conf_dac.sh
source ./conf.sh



echo -e "\n\n----------------- PERMISSIONS -------------------\n\n";

run_cmd() {
cmd="$1";
echo -e "\n\n >> ${green} Next command: $1 \n\n ${reset}";
#wait;
#read -p "Press enter to continue ${reset}";
eval "cleos -u $API_URL $1";
}




dacaccounts="$dacextra $dacowner $dactokens $dacauthority $daccustodian"

# resign extra account to dacauthority@active
run_cmd "set account permission $dacextra active ./perms/resign.json owner -p $dacextra@owner"
run_cmd "set account permission $dacextra owner ./perms/resign.json '' -p $dacextra@owner"
# resign dactokens account to dacauthority@active
run_cmd "set account permission $dactokens active ./perms/resign.json owner -p $dactokens@owner"
run_cmd "set account permission $dactokens owner ./perms/resign.json '' -p $dactokens@owner"
# resign daccustodian account to dacauthority@active
run_cmd "set account permission $daccustodian active ./perms/resign.json owner -p $daccustodian@owner"
run_cmd "set account permission $daccustodian owner ./perms/resign.json '' -p $daccustodian@owner"
# resign dacowner account to dacauthority@active, must allow timelocked transfers from [email protected]
run_cmd "set account permission $dacowner xfer ./perms/daccustodian_transfer.json active -p $dacowner@owner"
run_cmd "set action permission $dacowner eosio.token transfer xfer -p $dacowner@owner"
run_cmd "set account permission $dacowner active ./perms/resign.json owner -p $dacowner@owner"
run_cmd "set account permission $dacowner owner ./perms/resign.json '' -p $dacowner@owner"
# [email protected] has to be able to updateauth on dacauthority
run_cmd "set account permission $dacauthority owner ./perms/daccustodian_updateauth.json '' -p $dacauthority@owner"
run_cmd "set action permission $dacauthority eosio updateauth owner -p $dacauthority@owner"


dacaccounts="$dacextra $dacowner $dactokens $dacauthority $daccustodian"

for act in $dacaccounts
do
echo "------------- $act ---------------"
cleos -u $API_URL get account -j $act | jq '.permissions'
done

#run_cmd "set account permission $dacauthority owner ./dac_auth_perms.json '' -p dacauthority@owner"
8 changes: 8 additions & 0 deletions eosdac-testnet/perms/daccustodian_transfer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"threshold": 2,
"keys": [],
"accounts": [
{"permission":{"actor":"daccustodian", "permission":"eosio.code"}, "weight":1}
],
"waits": [{"wait_sec":30, "weight":1}]
}
8 changes: 8 additions & 0 deletions eosdac-testnet/perms/daccustodian_updateauth.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"threshold": 1,
"keys": [],
"accounts": [
{"permission":{"actor":"daccustodian", "permission":"eosio.code"}, "weight":1}
],
"waits": []
}
6 changes: 6 additions & 0 deletions eosdac-testnet/perms/resign.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"threshold" : 1,
"keys" : [],
"accounts": [{"permission":{"actor":"dacauthority", "permission":"active"}, "weight":1}],
"waits": []
}
133 changes: 133 additions & 0 deletions eosdac-testnet/populate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
#!/bin/bash

green=`tput setaf 2`
reset=`tput sgr0`

source ./conf_private.sh
source ./conf_dac.sh
source ./conf.sh



echo -e "\n\n----------------- POPULATE SEQUENCE -------------------\n\n";

run_cmd() {
cmd="$1";
echo -e "\n\n >> ${green} Next command: $1 \n\n ${reset}";
#wait;
#read -p "Press enter to continue ${reset}";
eval "cleos -u $API_URL $1";
}

create_act() {
act="$1"
key="$2"
eval "cleos -u $API_URL system newaccount --stake-cpu \"10.0000 EOS\" --stake-net \"10.0000 EOS\" --transfer --buy-ram-kbytes 1024 eosio $act $key"
}


dacaccounts="$dacextra $dacowner $dactokens $dacauthority $daccustodian"

for act in $dacaccounts
do
create_act $act $EOSIO_PUB
#run_cmd "system newaccount --stake-cpu \"10.0000 EOS\" --stake-net \"10.0000 EOS\" --transfer --buy-ram-kbytes 1024 eosio $act $EOSIO_PUB"
#sleep 1;
#cleos -u $API_URL get account $act;
done

run_cmd "transfer eosio $dacowner \"100000.0000 EOS\""

run_cmd "set contract "$dactokens" "$DACCONTRACTS/eosdactoken/eosdactoken" -p eosdactokens"
run_cmd "get code $dactokens"

cleos -u $API_URL push action $dactokens create '["eosdactokens", "10000000000.0000 EOSDAC", 0]' -p $dactokens
cleos -u $API_URL push action $dactokens issue '["eosdactokens", "1000000000.0000 EOSDAC", "Issue"]' -p $dactokens

run_cmd "set contract daccustodian "$DACCONTRACTS/daccustodian" -p daccustodian"
run_cmd "get code daccustodian"


run_cmd "push action daccustodian updateconfig dac_config.json -p daccustodian"
sleep 1;
run_cmd "get table daccustodian daccustodian config"

run_cmd "push action eosdactokens newmemterms terms.json -p eosdactokens"


# Developer accounts
create_devs() {
create_act evilmikehere EOS54NkNpEt9aotyBvEZVfj54NuFAebaDLnyg2GtJ6pyvBoxxg9Aw
run_cmd "transfer eosio evilmikehere \"10000000.0000 EOS\""
run_cmd "transfer -c eosdactokens eosdactokens evilmikehere \"100000000.0000 EOSDAC\""

create_act kasperkasper EOS5JLKQDsJwqh6vVTbqVnHsHDk6He1Xo6nsQSy3536B1gx3FGzZJ
run_cmd "transfer eosio kasperkasper \"10000000.0000 EOS\""
run_cmd "transfer -c eosdactokens eosdactokens kasperkasper \"10000000.0000 EOSDAC\""

create_act dallasdallas EOS5kt3N8qEwwRYYvWWZaJvsoz9iuVurLRhw36vckmSesHdm8A9su
run_cmd "transfer eosio dallasdallas \"10000000.0000 EOS\""
run_cmd "transfer -c eosdactokens eosdactokens dallasdallas \"10000000.0000 EOSDAC\""

create_act lukedactest1 EOS8YE3xbMVSiDxrJCK3qRsxT8e7ThfvpxdmwaXgeMAn5VYJxE26G
run_cmd "transfer eosio lukedactest1 \"5000000.0000 EOS\""
run_cmd "transfer -c eosdactokens eosdactokens lukedactest1 \"5000000.0000 EOSDAC\""

create_act lukedactest2 EOS5qhoS2McrhC6mkW2gN4eDPZZJhf3EQEvUf1gZoRxJTJXoNrFVk
run_cmd "transfer eosio lukedactest2 \"5000000.0000 EOS\""
run_cmd "transfer -c eosdactokens eosdactokens lukedactest2 \"5000000.0000 EOSDAC\""

create_act tiktiktiktik EOS5yMoSRtLecubsQmTVSmdurCAnh6etwRsVDNoXx697Jr193GRKp
run_cmd "transfer eosio tiktiktiktik \"10000000.0000 EOS\""
run_cmd "transfer -c eosdactokens eosdactokens tiktiktiktik \"10000000.0000 EOSDAC\""
}
create_devs


# Get the terms to hash it for registration
CONSTITUTION=$(cleos -u $API_URL get table eosdactokens eosdactokens memberterms | jq '.rows[0].terms' | tr -d '"')
wget -O constitution.md $CONSTITUTION
CON_MD5=$(md5sum constitution.md | cut -d' ' -f1)
rm -f constitution.md


# Build this array for random voting later
CUST_ACCTS=()


# Custodian accounts
for x in {a..z}
do
CUST="eosdaccusta$x"
CUST_ACTS+=($CUST)
create_act $CUST $EOSIO_PUB
run_cmd "transfer -c eosdactokens eosdactokens $CUST \"100000.0000 EOSDAC\""
run_cmd "push action eosdactokens memberreg '[\"$CUST\", \"$CON_MD5\"]' -p $CUST"
run_cmd "transfer -c eosdactokens $CUST daccustodian \"10.0000 EOSDAC\" \"daccustodian\""
run_cmd "push action daccustodian nominatecand '[\"$CUST\", \"10.0000 EOS\"]' -p $CUST"
done

# Voter accounts
for x in {a..z}
do
for y in {a..z}
do
VOT="eosdacvote$x$y"
create_act $VOT $EOSIO_PUB
run_cmd "transfer -c eosdactokens eosdactokens $VOT \"100000.0000 EOSDAC\""
run_cmd "push action eosdactokens memberreg '[\"$VOT\", \"$CON_MD5\"]' -p $VOT"
# random votes
numbers=$(jot -r 5 0 26)
votes=()
while read -r number; do
vote=${CUST_ACTS[$number]}
echo $vote
votes+=($vote)
done <<< "$numbers"

votes_arr=($(tr ' ' '\n' <<< "${votes[@]}" | sort -u | tr '\n' ' '))
json=$(jq -n --arg va "${votes_arr}" --arg v "${VOT}" '[$v, ($va | split(" ")) ]')
echo $json > vote_data.json
run_cmd "push action daccustodian votecust ./vote_data.json -p $VOT"
done
done
1 change: 1 addition & 0 deletions eosdac-testnet/terms.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
["https://raw.githubusercontent.com/eosdac/constitution/14d8d6d0262707f7c72183cff505d19e321f1cb3/constitution.md", "6d2cc6201302b3f485e2a939881ae451"]

0 comments on commit f499172

Please sign in to comment.