-
Notifications
You must be signed in to change notification settings - Fork 279
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[feature] #1902: Bare metal 4-peer setup script.
Signed-off-by: Aleksandr <a-p-petrosyan@yandex.ru>
- Loading branch information
1 parent
e0eda1e
commit 2785207
Showing
13 changed files
with
180 additions
and
178 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,5 +43,5 @@ cmake-build* | |
|
||
*.deb | ||
\#* | ||
/test_docker | ||
/cargo-timing*.html | ||
/test/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/bin/bash | ||
|
||
case $1 in | ||
setup) | ||
git clone https://github.com/hyperledger/iroha-java.git | ||
cd iroha-java || exit | ||
git checkout iroha2-dev # TODO: chagnge this to main after release. | ||
;; | ||
run) | ||
cd iroha-java || exit | ||
./gradlew build | ||
;; | ||
cleanup) | ||
rm -rf iroha_api_test | ||
;; | ||
esac |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
#!/bin/bash | ||
|
||
# Un-comment for debugging | ||
set -ex | ||
|
||
TEST=${TEST:-"./test"} | ||
HOST=${HOST:-"127.0.0.1"} | ||
IROHA2_CONFIG_PATH="$TEST/peers/config.json" | ||
IROHA2_GENESIS_PATH="$TEST/peers/genesis.json" | ||
|
||
# TODO: don't hard-code these, instead, generate them. | ||
declare -A public_keys | ||
public_keys[iroha0]='ed01207233bfc89dcbd68c19fde6ce6158225298ec1131b6a130d1aeb454c1ab5183c0' | ||
public_keys[iroha1]='ed0120cc25624d62896d3a0bfd8940f928dc2abf27cc57cefeb442aa96d9081aae58a1' | ||
public_keys[iroha2]='ed0120faca9e8aa83225cb4d16d67f27dd4f93fc30ffa11adc1f5c88fd5495ecc91020' | ||
public_keys[iroha3]='ed01208e351a70b6a603ed285d666b8d689b680865913ba03ce29fb7d13a166c4e7f1f' | ||
|
||
declare -A private_keys | ||
private_keys[iroha0]='9ac47abf59b356e0bd7dcbbbb4dec080e302156a48ca907e47cb6aea1d32719e7233bfc89dcbd68c19fde6ce6158225298ec1131b6a130d1aeb454c1ab5183c0' | ||
private_keys[iroha1]='3bac34cda9e3763fa069c1198312d1ec73b53023b8180c822ac355435edc4a24cc25624d62896d3a0bfd8940f928dc2abf27cc57cefeb442aa96d9081aae58a1' | ||
private_keys[iroha2]='1261a436d36779223d7d6cf20e8b644510e488e6a50bafd77a7485264d27197dfaca9e8aa83225cb4d16d67f27dd4f93fc30ffa11adc1f5c88fd5495ecc91020' | ||
private_keys[iroha3]='a70dab95c7482eb9f159111b65947e482108cfe67df877bd8d3b9441a781c7c98e351a70b6a603ed285d666b8d689b680865913ba03ce29fb7d13a166c4e7f1f' | ||
|
||
declare -A p2p_ports | ||
p2p_ports[iroha0]='1337' | ||
p2p_ports[iroha1]='1338' | ||
p2p_ports[iroha2]='1339' | ||
p2p_ports[iroha3]='1340' | ||
|
||
declare -A api_ports | ||
api_ports[iroha0]='8080' | ||
api_ports[iroha1]='8081' | ||
api_ports[iroha2]='8082' | ||
api_ports[iroha3]='8083' | ||
|
||
declare -A telemetry_ports | ||
telemetry_ports[iroha0]='8180' | ||
telemetry_ports[iroha1]='8181' | ||
telemetry_ports[iroha2]='8182' | ||
telemetry_ports[iroha3]='8183' | ||
|
||
function trusted_peer_entry { | ||
# This way it's easier to read when debugging the script | ||
echo "{" | ||
echo "\"address\": \"$HOST:${p2p_ports[$1]}\"," | ||
echo -n "\"public_key\": \"${public_keys[$1]}\"" | ||
echo -n "}" | ||
} | ||
|
||
function generate_trusted_peers { | ||
echo -n "[" | ||
for iter in {0..2} | ||
do | ||
trusted_peer_entry "iroha$iter" | ||
echo -n "," | ||
done | ||
trusted_peer_entry iroha3 | ||
echo "]" | ||
} | ||
|
||
SUMERAGI_TRUSTED_PEERS="$(generate_trusted_peers)" | ||
|
||
function set_up_peers_common { | ||
PEERS="$TEST/peers" | ||
mkdir -p "$PEERS" | ||
cp ./configs/peer/{config.json,genesis.json} "$PEERS" | ||
cp ./target/debug/iroha "$PEERS" || { | ||
# TODO this can fail for other reasons as well. | ||
echo 'Please build the `iroha` binary, by running:' | ||
echo '`cargo build --bin iroha`' | ||
exit 1 | ||
} | ||
} | ||
|
||
function bulk_export { | ||
export TORII_P2P_ADDR | ||
export TORII_API_URL | ||
export TORII_TELEMETRY_URL | ||
export IROHA_PUBLIC_KEY | ||
export IROHA_PRIVATE_KEY | ||
export SUMERAGI_TRUSTED_PEERS | ||
export IROHA2_CONFIG_PATH | ||
export IROHA2_GENESIS_PATH | ||
} | ||
|
||
function run_peer () { | ||
TORII_P2P_ADDR="$HOST:${p2p_ports[$1]}" | ||
TORII_API_URL="$HOST:${api_ports[$1]}" | ||
TORII_TELEMETRY_URL="$HOST:${telemetry_ports[$1]}" | ||
IROHA_PUBLIC_KEY=${public_keys[$1]} | ||
IROHA_PRIVATE_KEY="{ \"digest_function\": \"ed25519\", \"payload\": \"${private_keys[$1]}\" }" | ||
exec -a "$1" "$TEST/peers/iroha" "$2" > "$TEST/peers/$1.log" & disown | ||
} | ||
|
||
function run_4_peers { | ||
run_peer iroha1 | ||
run_peer iroha2 | ||
run_peer iroha3 | ||
run_peer iroha0 --submit-genesis | ||
} | ||
|
||
function clean_up_peers { | ||
# Note: We want an exact match, hence '^' in the beginning and '$' | ||
# at the end. If any of the peers has stopped working we want to | ||
# signal a failure, but kill all the remaining peers. | ||
pkill '^iroha' | ||
} | ||
|
||
case $1 in | ||
|
||
setup) | ||
## Set client up to communicate with the first peer. | ||
mkdir "$TEST" || echo "$TEST Already exists" | ||
cp ./target/debug/iroha_client_cli "$TEST" || { | ||
echo 'Please build `iroha_client_cli` by running' | ||
echo '`cargo build --bin iroha_client_cli`' | ||
exit | ||
} | ||
echo '{"comment":{"String": "Hello Meta!"}}' >"$TEST/metadata.json" | ||
cp ./configs/client_cli/config.json "$TEST" | ||
case $2 in | ||
docker) | ||
docker compose up --force-recreate;; | ||
*) | ||
set_up_peers_common | ||
bulk_export | ||
run_4_peers | ||
esac | ||
;; | ||
|
||
cleanup) | ||
case $2 in | ||
docker) | ||
docker-compose rm -s -f;; | ||
*) | ||
clean_up_peers | ||
esac | ||
rm "$TEST" -r -f | ||
;; | ||
|
||
*) | ||
echo 'Specify either `setup` or `cleanup`' | ||
exit 1 | ||
esac |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/bash | ||
set -ex | ||
TEST=${TEST:-"./test"} | ||
CMD="$TEST/iroha_client_cli --config $TEST/config.json" | ||
$CMD asset get --account alice@wonderland --asset 'rose#wonderland' | grep -q 'Quantity(13)' | ||
sleep ${SLEEP:-10} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/bash | ||
set -ex | ||
TEST=${TEST:-"./test"} | ||
CMD="$TEST/iroha_client_cli --config $TEST/config.json" | ||
$CMD domain register --id="Soramitsu" --metadata="$TEST/metadata.json" | ||
sleep 2 | ||
$CMD account register --id="Alice@Soramitsu" --key="ed0120a753146e75b910ae5e2994dc8adea9e7d87e5d53024cfa310ce992f17106f92c" | ||
sleep 2 | ||
$CMD asset register --id="XOR#Soramitsu" --value-type=Quantity | ||
sleep 2 | ||
$CMD asset mint --account="Alice@Soramitsu" --asset="XOR#Soramitsu" --quantity="100" | ||
sleep 2 | ||
$CMD asset get --account="Alice@Soramitsu" --asset="XOR#Soramitsu" | grep -q 'Quantity(100)' |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.