Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3c2038c
commit 9b7ba69
Showing
7 changed files
with
185 additions
and
106 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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
tendermint-cas-demo | ||
tendermint_* | ||
*.json | ||
|
||
|
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,33 @@ | ||
os = $(shell uname | tr '[A-Z]' '[a-z]') | ||
arch = $(shell uname -m | sed 's/x86_64/amd64/') | ||
tendermint_version = 0.25.0 | ||
tendermint_binary = tendermint_${tendermint_version}_${os}_${arch} | ||
tendermint_archive = ${tendermint_binary}.zip | ||
|
||
tendermint-cas-demo: | ||
@go build ./cmd/tendermint-cas-demo | ||
|
||
${tendermint_binary}: ${tendermint_archive} | ||
@unzip -o $< | ||
@mv tendermint $@ | ||
@touch $@ | ||
|
||
${tendermint_archive}: | ||
@echo downloading ${tendermint_archive}... | ||
@curl -o $@ -Ss -L https://github.com/tendermint/tendermint/releases/download/v${tendermint_version}/${tendermint_archive} | ||
@touch $@ | ||
|
||
.PHONY: bootstrap_1 | ||
bootstrap_1: ${tendermint_binary} tendermint-cas-demo | ||
@./bootstrap_1.sh ./${tendermint_binary} | ||
|
||
.PHONY: bootstrap_3 | ||
bootstrap_3: ${tendermint_binary} tendermint-cas-demo | ||
@./bootstrap_3.sh ./${tendermint_binary} | ||
|
||
.PHONY: clean | ||
clean: | ||
@rm -rf tendermint-cas-demo | ||
@rm -rf ${tendermint_binary} ${tendermint_archive} | ||
@rm -rf tendermint_zero/ tendermint_{a,b,c}/ | ||
@rm -rf zero.json {a,b,c}.json |
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
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
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,68 @@ | ||
#!/usr/bin/env sh | ||
|
||
set -e | ||
|
||
if [ $# -ne 1 ] | ||
then | ||
echo "usage: $0 <tendermint binary>" | ||
exit | ||
fi | ||
|
||
tendermint_binary=$1 | ||
|
||
echo clearing any old state... | ||
rm -rf tendermint_{a,b,c}/ | ||
rm -rf {a,b,c}.json | ||
|
||
echo initializing three nodes... | ||
${tendermint_binary} init --home tendermint_a >/dev/null | ||
${tendermint_binary} init --home tendermint_b >/dev/null | ||
${tendermint_binary} init --home tendermint_c >/dev/null | ||
|
||
echo capturing validators... | ||
a_validator=$(cat tendermint_a/config/genesis.json | jq .validators[0]) | ||
b_validator=$(cat tendermint_b/config/genesis.json | jq .validators[0]) | ||
c_validator=$(cat tendermint_c/config/genesis.json | jq .validators[0]) | ||
|
||
echo capturing peer addresses... | ||
a_address=$(echo $a_validator | jq .address | tr -d '"') | ||
b_address=$(echo $b_validator | jq .address | tr -d '"') | ||
c_address=$(echo $c_validator | jq .address | tr -d '"') | ||
persistent_peers="${a_address}@127.0.0.1:10001, ${b_address}@127.0.0.1:10002, ${c_address}@127.0.0.1:10003" | ||
|
||
echo building a common genesis file... | ||
common_genesis=$(cat tendermint_a/config/genesis.json | jq "(.validators) = [${a_validator}, ${b_validator}, ${c_validator}]") | ||
|
||
echo writing common genesis file... | ||
echo $common_genesis | jq . > tendermint_a/config/genesis.json | ||
echo $common_genesis | jq . > tendermint_b/config/genesis.json | ||
echo $common_genesis | jq . > tendermint_c/config/genesis.json | ||
|
||
echo producing config files... | ||
echo 'moniker = "a"' | tee tendermint_a/config/config.toml >/dev/null | ||
echo 'moniker = "b"' | tee tendermint_b/config/config.toml >/dev/null | ||
echo 'moniker = "c"' | tee tendermint_c/config/config.toml >/dev/null | ||
echo 'proxy_app = ""' | tee -a tendermint_?/config/config.toml >/dev/null | ||
echo '' | tee -a tendermint_?/config/config.toml >/dev/null | ||
echo '[rpc]' | tee -a tendermint_?/config/config.toml >/dev/null | ||
echo 'laddr = ""' | tee -a tendermint_?/config/config.toml >/dev/null | ||
echo '' | tee -a tendermint_?/config/config.toml >/dev/null | ||
echo '[p2p]' | tee -a tendermint_?/config/config.toml >/dev/null | ||
echo 'laddr = "tcp://127.0.0.1:10001"' | tee -a tendermint_a/config/config.toml >/dev/null | ||
echo 'laddr = "tcp://127.0.0.1:10002"' | tee -a tendermint_b/config/config.toml >/dev/null | ||
echo 'laddr = "tcp://127.0.0.1:10003"' | tee -a tendermint_c/config/config.toml >/dev/null | ||
echo "persistent_peers = \"${persistent_peers}\"" | tee -a tendermint_?/config/config.toml >/dev/null | ||
|
||
echo now you can run three nodes | ||
echo | ||
echo " ./tendermint-cas-demo -api-addr 127.0.0.1:8081 -app-file a.json -tendermint-dir tendermint_a" | ||
echo " ./tendermint-cas-demo -api-addr 127.0.0.1:8082 -app-file b.json -tendermint-dir tendermint_b" | ||
echo " ./tendermint-cas-demo -api-addr 127.0.0.1:8083 -app-file c.json -tendermint-dir tendermint_c" | ||
echo | ||
echo other fun things to try | ||
echo | ||
echo " watch -n1 -- cat ?.json # watch state being updated" | ||
echo " curl -Ss -XPOST 'localhost:8081/x?new=one' # set x=one" | ||
echo " curl -Ss -XPOST 'localhost:8082/x?old=one&new=two' # set x=two" | ||
echo " curl -Ss -XGET 'localhost:8083/x' # get x" | ||
echo |
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