Skip to content

Commit fd41204

Browse files
committed
added igor's scripts
1 parent e0870b3 commit fd41204

File tree

7 files changed

+159
-2
lines changed

7 files changed

+159
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ release/
77
*.dot
88
*.log
99
*.ign
10+
pchaind

Makefile

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,4 +106,20 @@ govulncheck:
106106
@go install golang.org/x/vuln/cmd/govulncheck@latest
107107
@govulncheck ./...
108108

109-
.PHONY: govet govulncheck
109+
.PHONY: govet govulncheck
110+
111+
TARGET ?= darwin:arm64
112+
113+
build-release:
114+
@echo "Building for darwin:arm64"
115+
rm -rf release
116+
rm pchaind || echo "Error: Failed to remove pchaind"
117+
ignite chain init
118+
ignite chain build \
119+
--release.targets $(TARGET) \
120+
--output ./release \
121+
--release
122+
123+
unzip-build:
124+
@echo "Unzipping build"
125+
tar xzf ./release/pchain_$(subst :,_,$(TARGET)).tar.gz

build-testnet-config.sh

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# RUN THIS LINE BY LINE; COMMENTING OUT EVERYTHING ELSE !!!
2+
3+
# OPTIONAL STEP: create keys (write down the memo words)(you need this only once per environment)
4+
pchaind keys add user1
5+
pchaind keys add user2
6+
7+
## make 3 folders with all configs and genesis files and validator keys for
8+
# a testnetwork (tn) of 3 nodes: pushnode1(.tn/pn1), .tn/pn2, .tn/pn3
9+
pchaind init pn1 --home ~/.tn/pn1 --chain-id test-push-chain
10+
pchaind init pn2 --home ~/.tn/pn2 --chain-id test-push-chain
11+
pchaind init pn3 --home ~/.tn/pn3 --chain-id test-push-chain
12+
13+
# build config/genesis.json
14+
### register 2 genesis accounts with 500k push each
15+
# user1 would own nodes pn1,pn2,pn3
16+
export user1=$(pchaind keys show user1 -a)
17+
pchaind genesis add-genesis-account $user1 500000000000npush --home ~/.tn/pn1
18+
# user2 would own nothing
19+
export user2=$(pchaind keys show user2 -a)
20+
pchaind genesis add-genesis-account $user2 500000000000npush --home ~/.tn/pn1
21+
22+
# replace all tokens with npush; npush is nano push; it is 1/1 000 000 of push
23+
sed -i '' 's/stake/npush/g' ~/.tn/pn1/config/genesis.json
24+
25+
26+
# I cannot register more no matter how hord I try
27+
# this is the command we have in 0.50:
28+
# pchaind genesis gentx <key_name> <amount> [flags]
29+
# this is the command which I need in 0.52:
30+
# pchaind genesis gentx <key_name> 10000000000stake --chain-id push-test-chain --moniker="pn1" --commission-rate="0.10" --commission-max-rate="0.20" --commission-max-change-rate="0.01" --min-self-delegation="1" --ip "192.168.88.114" --node-id <your_node_id> --home ~/.tn/pn2
31+
# register 1 founder validator in genesis.json ;
32+
pchaind genesis gentx user1 10000000000npush --chain-id test-push-chain --home ~/.tn/pn1
33+
# put all txs into genesis.json
34+
pchaind genesis collect-gentxs --home ~/.tn/pn1
35+
# copy genesis to other nodes
36+
cp ~/.tn/pn1/config/genesis.json ~/.tn/pn2/config/genesis.json
37+
cp ~/.tn/pn1/config/genesis.json ~/.tn/pn3/config/genesis.json
38+
39+
## configs
40+
41+
# build config/app.toml
42+
sed -i '' 's/minimum-gas-prices = ""/minimum-gas-prices = "0.25npush"/g' ~/.tn/pn1/config/app.toml
43+
cp ~/.tn/pn1/config/app.toml ~/.tn/pn2/config/app.toml
44+
cp ~/.tn/pn1/config/app.toml ~/.tn/pn3/config/app.toml
45+
46+
47+
# build config/config.toml
48+
export pn1_id=$(pchaind tendermint show-node-id --home ~/.tn/pn1)
49+
export pn1_url="$pn1_id@pn1.dev.push.org:26656"
50+
51+
export pn2_id=$(pchaind tendermint show-node-id --home ~/.tn/pn2)
52+
export pn2_url="$pn2_id@pn2.dev.push.org:26656"
53+
54+
export pn3_id=$(pchaind tendermint show-node-id --home ~/.tn/pn3)
55+
export pn3_url="$pn3_id@pn3.dev.push.org:26656"
56+
57+
export pn1_peers="\"$pn2_url, $pn3_url\""
58+
sed -i '' "s/persistent_peers = \"\"/persistent_peers = $pn1_peers/g" ~/.tn/pn1/config/config.toml
59+
grep -i persistent_peers ~/.tn/pn1/config/config.toml
60+
61+
export pn2_peers="\"$pn1_url, $pn3_url\""
62+
sed -i '' "s/persistent_peers = \"\"/persistent_peers = $pn2_peers/g" ~/.tn/pn2/config/config.toml
63+
grep -i persistent_peers ~/.tn/pn2/config/config.toml
64+
65+
export pn3_peers="\"$pn1_url, $pn2_url\""
66+
sed -i '' "s/persistent_peers = \"\"/persistent_peers = $pn3_peers/g" ~/.tn/pn3/config/config.toml
67+
grep -i "persistent_peers =" ~/.tn/pn3/config/config.toml

config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
version: 1
22
validation: sovereign
33
genesis:
4-
chain_id: "pcv-1"
4+
chain_id: "test-push-chain"
55
app_state:
66
staking:
77
params:

deploy-code.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/bash
2+
FILE="release/push_linux_amd64.tar.gz"
3+
REMOTE_HOST="pn2.dev.push.org"
4+
DEST_EXEC_DIR="/home/igx/app"
5+
6+
7+
# DO NOT EDIT THIS UNLESS NEEDED
8+
9+
echo "Building sources for linux:amd64 into release/"
10+
ignite chain build --release.targets linux:amd64 --output ./release --release
11+
12+
REMOTE_TMP="/tmp/$(basename "$FILE")"
13+
echo "Transferring $FILE to $REMOTE_HOST:$REMOTE_TMP..."
14+
scp "$FILE" "$REMOTE_HOST:$REMOTE_TMP"
15+
if [ $? -ne 0 ]; then
16+
echo "Error: SCP failed."
17+
exit 1
18+
fi
19+
echo "Extracting the tarball on $REMOTE_HOST into $DEST_EXEC_DIR..."
20+
ssh "$REMOTE_HOST" "mkdir -p '$DEST_EXEC_DIR' && tar -xzvf '$REMOTE_TMP' -C '$DEST_EXEC_DIR' && chmod u+x ~/app/pchaind"
21+
if [ $? -ne 0 ]; then
22+
echo "Error: Extraction failed."
23+
exit 1
24+
fi
25+
26+
echo "Deployment complete."

deploy-config.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/bash
2+
SRC_HOME_DIR="/Users/igx/.tn/pn2"
3+
REMOTE_HOST="pn2.dev.push.org"
4+
5+
# DO NOT EDIT THIS UNLESS NEEDED
6+
DEST_HOME_DIR="/home/igx/.pchain"
7+
ARCHIVE_FILE="config.tar.gz"
8+
REMOTE_ARCHIVE="/tmp/${ARCHIVE_FILE}"
9+
10+
echo "Creating archive $ARCHIVE_FILE from $SRC_HOME_DIR..."
11+
COPYFILE_DISABLE=1 tar -czvf "$ARCHIVE_FILE" -C "$SRC_HOME_DIR" .
12+
if [ $? -ne 0 ]; then
13+
echo "Error: Archiving $SRC_HOME_DIR failed."
14+
exit 1
15+
fi
16+
echo "Uploading $ARCHIVE_FILE to $REMOTE_HOST:$REMOTE_ARCHIVE..."
17+
scp "$ARCHIVE_FILE" "$REMOTE_HOST:$REMOTE_ARCHIVE"
18+
if [ $? -ne 0 ]; then
19+
echo "Error: SCP of $ARCHIVE_FILE failed."
20+
exit 1
21+
fi
22+
23+
echo "Extracting $ARCHIVE_FILE on $REMOTE_HOST into $DEST_HOME_DIR..."
24+
ssh "$REMOTE_HOST" "mkdir -p '$DEST_HOME_DIR' && tar -xzvf '$REMOTE_ARCHIVE' -C '$DEST_HOME_DIR'"
25+
if [ $? -ne 0 ]; then
26+
echo "Error: Extraction of $ARCHIVE_FILE failed."
27+
exit 1
28+
fi
29+
30+
echo "Deployment complete."

deploy-user-key.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
SRC_HOME_DIR="/Users/igx/.tn/pn2"
3+
REMOTE_HOST="pn2.dev.push.org"
4+
REMOTE_DIR="/home/igx/.push/"
5+
KEY_FILE="user2_key.json"
6+
7+
# DO NOT EDIT THIS UNLESS NEEDED
8+
9+
echo "Exporting key..."
10+
pchaind keys export user2 --output json > $KEY_FILE
11+
12+
echo "Uploading $KEY_FILE to $REMOTE_HOST:$REMOTE_DIR..."
13+
scp "$KEY_FILE" "$REMOTE_HOST:$REMOTE_DIR$KEY_FILE"
14+
if [ $? -ne 0 ]; then
15+
echo "Error: SCP of $KEY_FILE failed."
16+
exit 1
17+
fi

0 commit comments

Comments
 (0)