From 5c38698d1aacd8a1330b904dc2cd8b9f73495f30 Mon Sep 17 00:00:00 2001 From: Toshihito Kikuchi Date: Mon, 3 Apr 2023 18:07:26 -0700 Subject: [PATCH] Various fixes to make V0 LocalNet work on WSL2 - Remove go.mod.local and use the latest go.mod in the pocket-core branch - Update the tendermint path in go.mod before `go build` - docker/pokt-net/dev-tm/Dockerfile for scaffold - docker/pokt-net/dev-tm/prepare-tendermint.sh for playground nodes - Clean up pocket-core/vendor before creating a container - Simplify data directory creation because `paths=($(echo $nodes | tr " " "\n"))` causes a syntax error somehow - Update some critical parameters in genesis.json with the same values as mainnet --- bin/pokt-net/utils.sh | 2 +- docker/pokt-net/dev-tm/Dockerfile | 11 ++- docker/pokt-net/dev-tm/go.mod.local | 83 -------------------- docker/pokt-net/dev-tm/prepare-tendermint.sh | 8 +- docker/pokt-net/dev-tm/watch.sh | 4 +- stacks/pokt-net/scaffold/cleanup.sh | 2 +- stacks/pokt-net/scaffold/up.sh | 22 ++---- stacks/pokt-net/shared/genesis.json | 6 +- 8 files changed, 25 insertions(+), 113 deletions(-) delete mode 100644 docker/pokt-net/dev-tm/go.mod.local diff --git a/bin/pokt-net/utils.sh b/bin/pokt-net/utils.sh index 251363d..cf36752 100755 --- a/bin/pokt-net/utils.sh +++ b/bin/pokt-net/utils.sh @@ -46,7 +46,7 @@ function update_chains_json() { if [[ ! -z ${ETH_ALTRUIST} && ! -z ${POLY_ALTRUIST} ]]; then echo "ETH_ALTRUIST and POLY_ALTRUIST are set so we are going update chains.json" sed "s#http://user:pass@eth.altruist.com#${ETH_ALTRUIST}#g" stacks/pokt-net/shared/chains.template.json > stacks/pokt-net/shared/chains.local.json - sed -i '' "s#http://user:pass@poly.altruist.com#${POLY_ALTRUIST}#g" stacks/pokt-net/shared/chains.local.json + sed -i "s#http://user:pass@poly.altruist.com#${POLY_ALTRUIST}#g" stacks/pokt-net/shared/chains.local.json else echo "ETH_ALTRUIST and POLY_ALTRUIST are not set so we are not going update chains.json" cp stacks/pokt-net/shared/chains.template.json > stacks/pokt-net/shared/chains.local.json diff --git a/docker/pokt-net/dev-tm/Dockerfile b/docker/pokt-net/dev-tm/Dockerfile index 1eaa0f7..fc2345a 100644 --- a/docker/pokt-net/dev-tm/Dockerfile +++ b/docker/pokt-net/dev-tm/Dockerfile @@ -58,14 +58,17 @@ RUN mkdir -p /home/app/.pocket/config RUN chown -R app /home/app/.pocket RUN chown -R app /go +# Overwrite go.mod files for local development +RUN sed -i 's|^replace github.com/tendermint/tendermint => .*$|replace github.com/tendermint/tendermint => '$TENDERMINT_PATH'|' $POCKET_PATH/go.mod +RUN cp $POCKET_PATH/go.mod $POCKET_ROOT/go.mod.core + +# Clear vendor directory to reset the previous run +RUN rm -rf $POCKET_PATH/vendor + # Build the pocket main binary using the mainline dependencies RUN cd ${POCKET_PATH} \ && go build -tags cleveldb -o ${GOPATH}/bin/pocket app/cmd/pocket_core/main.go -# Overwrite go.mod files for local development -COPY ${POCKET_E2E_STACK_RELATIVE_PATH}/go.mod.local $POCKET_ROOT/go.mod.core -RUN chmod 654 $POCKET_ROOT/go.mod.core - # Overwrite go.mod files for local development COPY ${POCKET_E2E_STACK_RELATIVE_PATH}/go.mod.tendermint $POCKET_ROOT/go.mod.tendermint RUN chmod 654 $POCKET_ROOT/go.mod.tendermint diff --git a/docker/pokt-net/dev-tm/go.mod.local b/docker/pokt-net/dev-tm/go.mod.local deleted file mode 100644 index 1891112..0000000 --- a/docker/pokt-net/dev-tm/go.mod.local +++ /dev/null @@ -1,83 +0,0 @@ -module github.com/pokt-network/pocket-core - -go 1.18 - -replace github.com/tendermint/tendermint => /go/src/github.com/pokt-network/tendermint - -replace github.com/tendermint/tm-db => github.com/pokt-network/tm-db v0.5.2-0.20220118210553-9b2300f289ba - -require ( - github.com/cucumber/godog v0.12.5 - github.com/go-kit/kit v0.12.0 - github.com/gogo/protobuf v1.3.2 - github.com/golang/protobuf v1.5.2 - github.com/hashicorp/golang-lru v0.5.4 - github.com/jordanorelli/lexnum v0.0.0-20141216151731-460eeb125754 - github.com/julienschmidt/httprouter v1.3.0 - github.com/pkg/errors v0.9.1 - github.com/prometheus/client_golang v1.11.0 - github.com/regen-network/cosmos-proto v0.3.0 - github.com/spf13/cobra v1.4.0 - github.com/stretchr/testify v1.7.0 - github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 - github.com/tendermint/go-amino v0.15.1 - github.com/tendermint/tendermint v0.33.7 - github.com/tendermint/tm-db v0.5.1 - github.com/willf/bloom v2.0.3+incompatible - golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 - google.golang.org/protobuf v1.27.1 - gopkg.in/h2non/gock.v1 v1.1.2 - gopkg.in/yaml.v2 v2.4.0 -) - -require ( - github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d // indirect - github.com/Workiva/go-datastructures v1.0.52 // indirect - github.com/beorn7/perks v1.0.1 // indirect - github.com/btcsuite/btcd v0.20.1-beta // indirect - github.com/cespare/xxhash/v2 v2.1.2 // indirect - github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d // indirect - github.com/cucumber/gherkin-go/v19 v19.0.3 // indirect - github.com/cucumber/messages-go/v16 v16.0.1 // indirect - github.com/davecgh/go-spew v1.1.1 // indirect - github.com/go-kit/log v0.2.0 // indirect - github.com/go-logfmt/logfmt v0.5.1 // indirect - github.com/gofrs/uuid v4.0.0+incompatible // indirect - github.com/golang/snappy v0.0.4 // indirect - github.com/google/btree v1.0.0 // indirect - github.com/google/go-cmp v0.5.6 // indirect - github.com/gorilla/websocket v1.4.2 // indirect - github.com/gtank/merlin v0.1.1 // indirect - github.com/gtank/ristretto255 v0.1.2 // indirect - github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542 // indirect - github.com/hashicorp/go-immutable-radix v1.3.1 // indirect - github.com/hashicorp/go-memdb v1.3.0 // indirect - github.com/inconshreveable/mousetrap v1.0.0 // indirect - github.com/jmhodges/levigo v1.0.0 // indirect - github.com/kr/text v0.2.0 // indirect - github.com/libp2p/go-buffer-pool v0.0.2 // indirect - github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect - github.com/mimoo/StrobeGo v0.0.0-20181016162300-f8f6d4d2b643 // indirect - github.com/minio/highwayhash v1.0.2 // indirect - github.com/onsi/ginkgo v1.16.2 // indirect - github.com/onsi/gomega v1.13.0 // indirect - github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/prometheus/client_model v0.2.0 // indirect - github.com/prometheus/common v0.30.0 // indirect - github.com/prometheus/procfs v0.7.3 // indirect - github.com/rcrowley/go-metrics v0.0.0-20200313005456-10cdbea86bc0 // indirect - github.com/rs/cors v1.7.0 // indirect - github.com/spaolacci/murmur3 v1.1.0 // indirect - github.com/spf13/pflag v1.0.5 // indirect - github.com/stretchr/objx v0.1.1 // indirect - github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c // indirect - github.com/willf/bitset v1.1.10 // indirect - go.etcd.io/bbolt v1.3.3 // indirect - golang.org/x/net v0.1.0 // indirect - golang.org/x/sys v0.1.0 // indirect - golang.org/x/term v0.1.0 // indirect - golang.org/x/text v0.4.0 // indirect - google.golang.org/genproto v0.0.0-20210917145530-b395a37504d4 // indirect - google.golang.org/grpc v1.40.0 // indirect - gopkg.in/yaml.v3 v3.0.1 // indirect -) diff --git a/docker/pokt-net/dev-tm/prepare-tendermint.sh b/docker/pokt-net/dev-tm/prepare-tendermint.sh index 08610b0..50fc343 100755 --- a/docker/pokt-net/dev-tm/prepare-tendermint.sh +++ b/docker/pokt-net/dev-tm/prepare-tendermint.sh @@ -13,15 +13,15 @@ if [[ -f "/dev/tendermint.built" ]]; then go mod tidy && go mod vendor # Need to get the dependencies in the docker container go mod download + go build cmd/tendermint/main.go fi -cd $TENDERMINT_PATH -go build cmd/tendermint/main.go + +# Doing a `mv` here errors; can't preserve ownership +cp -f $POCKET_ROOT/go.mod.core $POCKET_PATH/go.mod if [[ -f "/dev/core.built" ]]; then touch "/dev/core.built" echo "Installing dependencies for core..." - # Doing a `mv` here errors; can't preserve ownershi - cp -f $POCKET_ROOT/go.mod.core $POCKET_PATH/go.mod cd $POCKET_PATH # Need to update vendor/module.txt to the local dev paths go mod tidy && go mod vendor diff --git a/docker/pokt-net/dev-tm/watch.sh b/docker/pokt-net/dev-tm/watch.sh index 51a709b..4513628 100755 --- a/docker/pokt-net/dev-tm/watch.sh +++ b/docker/pokt-net/dev-tm/watch.sh @@ -5,9 +5,9 @@ echo "Starting watch.sh..." echo "POCKET_CORE_SEEDS: $POCKET_CORE_SEEDS"; echo "POCKET_ADDRESS: $POCKET_ADDRESS"; -if [ -z $EXECOMMAND ] +if [ -z "$EXECCOMMAND" ] then - echo "Expecting EXECOMMAND env var, none was exported."; + echo "Expecting EXECCOMMAND env var, none was exported."; export EXECCOMMAND="start --seeds $POCKET_CORE_SEEDS --keybase=false --datadir=/home/app/.pocket" echo "Exported $EXECCOMMAND as EXECCOMMAND"; fi; diff --git a/stacks/pokt-net/scaffold/cleanup.sh b/stacks/pokt-net/scaffold/cleanup.sh index 2b2b15c..7f681aa 100644 --- a/stacks/pokt-net/scaffold/cleanup.sh +++ b/stacks/pokt-net/scaffold/cleanup.sh @@ -1,3 +1,3 @@ #!/usr/bin/env bash -rm -rf $CWD/stacks/pokt-playground \ No newline at end of file +sudo rm -rf $CWD/stacks/pokt-playground diff --git a/stacks/pokt-net/scaffold/up.sh b/stacks/pokt-net/scaffold/up.sh index f819e81..f9389cf 100644 --- a/stacks/pokt-net/scaffold/up.sh +++ b/stacks/pokt-net/scaffold/up.sh @@ -1,17 +1,5 @@ #!/usr/bin/bash -create_data_folder() { - mkdir -p $1/data/ -} - -create_data_folders_for_nodes() { - paths=$1 - for i in "${!paths[@]}" - do - create_data_folder $CWD/stacks/pokt-playground/${paths[i]} - done -} - export POCKET_CORE_REPOS_PATH=$POCKET_CORE_REPOS_PATH export POCKET_E2E_STACK_RELATIVE_PATH=$(basename -a $POCKET_E2E_STACK_PATH) @@ -30,8 +18,12 @@ docker-compose \ --force-recreate echo "Creating data folders for the generated nodes..." -nodes=$(ls $CWD/stacks/pokt-playground | grep node | awk '{print $1}') -paths=($(echo $nodes | tr " " "\n")) -create_data_folders_for_nodes $paths + +NODES=$CWD/stacks/pokt-playground/node* +for NODE in $NODES +do + echo "Creating $NODE/data" + sudo mkdir $NODE/data +done echo 'Done'; diff --git a/stacks/pokt-net/shared/genesis.json b/stacks/pokt-net/shared/genesis.json index c028c2d..a9fd0a5 100755 --- a/stacks/pokt-net/shared/genesis.json +++ b/stacks/pokt-net/shared/genesis.json @@ -21,9 +21,9 @@ "session_node_count": "4", "proof_waiting_period": "3", "supported_blockchains": ["0021", "0009"], - "claim_expiration": "100", + "claim_expiration": "24", "replay_attack_burn_multiplier": "3", - "minimum_number_of_proofs": "1" + "minimum_number_of_proofs": "10" }, "receipts": null, "claims": null @@ -168,7 +168,7 @@ "max_validators": "5", "stake_denom": "upokt", "stake_minimum": "1000000", - "session_block_frequency": "2", + "session_block_frequency": "4", "dao_allocation": "10", "proposer_allocation": "1", "maximum_chains": "15",