-
Notifications
You must be signed in to change notification settings - Fork 14
/
local-node.sh
executable file
·70 lines (61 loc) · 2.8 KB
/
local-node.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/env bash
set -eo pipefail
export FX_HOME=${FX_HOME:-"/tmp/fxcore"}
genesis_tmp="$FX_HOME/config/genesis.json.tmp"
if [[ "$1" == "init" ]]; then
if [ -d "$FX_HOME" ]; then
echo "node home '$FX_HOME' already exists"
read -rp "Are you sure you want to delete all the data and start over? [y/N] " input
[[ "$input" != "y" && "$input" != "Y" ]] && exit 1
rm -r "$FX_HOME"
fi
# Initialize private validator, p2p, genesis, and application configuration files
fxcored init local --chain-id fxcore --default-denom FX
# update consensus params
jq '.consensus.params.block.max_gas = "30000000"' "$FX_HOME/config/genesis.json" >"$genesis_tmp" &&
mv "$genesis_tmp" "$FX_HOME/config/genesis.json"
jq '.consensus.params.block.max_bytes = "1048576"' "$FX_HOME/config/genesis.json" >"$genesis_tmp" &&
mv "$genesis_tmp" "$FX_HOME/config/genesis.json"
fxcored config config.toml rpc.cors_allowed_origins "*"
# open prometheus
fxcored config config.toml instrumentation.prometheus true
# consensus
fxcored config config.toml consensus.timeout_commit 1s
# open rest and swagger
fxcored config app.toml api.enable true
fxcored config app.toml api.enabled-unsafe-cors true
fxcored config app.toml api.swagger true
# open telemetry
fxcored config app.toml telemetry.enabled true
fxcored config app.toml telemetry.enable-service-label true
fxcored config app.toml telemetry.prometheus-retention-time 60
# web3 api
fxcored config app.toml json-rpc.api "eth,txpool,personal,net,debug,web3"
# update fxcore client config
fxcored config set client chain-id "fxcore"
fxcored config set client keyring-backend "test"
fxcored config set client output "json"
fxcored config set client broadcast-mode "sync"
echo "test test test test test test test test test test test junk" | fxcored keys add fx1 --recover
if [ -n "${2:-""}" ]; then
fxcored genesis add-genesis-account fx1 10004000000000000000000000FX
# update genesis total supply
jq '.app_state.bank.supply[0].amount = "388604525462891000000000000"' "$FX_HOME/config/genesis.json" >"$genesis_tmp" &&
mv "$genesis_tmp" "$FX_HOME/config/genesis.json"
jq '.app_state.gov.voting_params.voting_period = "15s"' "$FX_HOME/config/genesis.json" >"$genesis_tmp" &&
mv "$genesis_tmp" "$FX_HOME/config/genesis.json"
else
fxcored genesis add-genesis-account fx1 4000000000000000000000FX
fi
fxcored genesis gentx fx1 100000000000000000000FX --chain-id=fxcore \
--gas="200000" \
--moniker="fx-validator" \
--commission-max-change-rate="0.01" \
--commission-max-rate="0.2" \
--commission-rate="0.01" \
--details="Details A Function X foundation self-hosted validator." \
--security-contact="contact@functionx.io" \
--website="functionx.io"
fxcored genesis collect-gentxs
fi
fxcored start