diff --git a/.gitignore b/.gitignore index 63a4dc6dcc..450d9952d0 100644 --- a/.gitignore +++ b/.gitignore @@ -26,4 +26,6 @@ genesis/pylonsd artifacts cmd/pylonsd/__debug_bin -proto/dart/* \ No newline at end of file +proto/dart/* + +debug \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index acaaef5d67..df6086d47d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,38 @@ -FROM starport/cli -COPY . /app -USER root -EXPOSE $PORT -ENTRYPOINT [ "starport", "chain", "serve", "-p", "/app" ] \ No newline at end of file +FROM golang:1.18-alpine3.16 AS go-builder + +RUN set -eux + +RUN apk add --no-cache ca-certificates git build-base linux-headers + +WORKDIR /code + +# Install babyd binary +RUN echo "Installing pylonsd binary" +ADD https://github.com/Pylons-tech/pylons/archive/refs/tags/v0.4.2.tar.gz /code/ +RUN tar -xf v0.4.2.tar.gz -C /code/ --strip-components=1 +RUN go build -o bin/pylonsd -mod=readonly ./cmd/pylonsd + +#------------------------------------------- +FROM golang:1.18-alpine3.16 + +RUN apk add --no-cache bash py3-pip jq curl +RUN pip install toml-cli + +WORKDIR / + +COPY --from=go-builder /code/bin/pylonsd /usr/bin/pylonsd +COPY --from=go-builder /code/bin/pylonsd / +COPY scripts/* / +RUN chmod +x /*.sh + +# rest server +EXPOSE 1317 +# tendermint rpc +EXPOSE 26657 +# p2p address +EXPOSE 26656 +# gRPC address +EXPOSE 9090 + +# wrong ENTRYPOINT can lead to executable not running +ENTRYPOINT ["/bin/bash", "test_node_deploy.sh"] \ No newline at end of file diff --git a/Makefile b/Makefile index b338e41fe0..9d86fd8a2d 100644 --- a/Makefile +++ b/Makefile @@ -17,30 +17,30 @@ export GO111MODULE = on build_tags = netgo ifeq ($(LEDGER_ENABLED),true) - ifeq ($(OS),Windows_NT) - GCCEXE = $(shell where gcc.exe 2> NUL) - ifeq ($(GCCEXE),) - $(error gcc.exe not installed for ledger support, please install or set LEDGER_ENABLED=false) - else - build_tags += ledger - endif - else - UNAME_S = $(shell uname -s) - ifeq ($(UNAME_S),OpenBSD) - $(warning OpenBSD detected, disabling ledger support (https://github.com/cosmos/cosmos-sdk/issues/1988)) - else - GCC = $(shell command -v gcc 2> /dev/null) - ifeq ($(GCC),) - $(error gcc not installed for ledger support, please install or set LEDGER_ENABLED=false) - else - build_tags += ledger - endif - endif - endif + ifeq ($(OS),Windows_NT) + GCCEXE = $(shell where gcc.exe 2> NUL) + ifeq ($(GCCEXE),) + $(error gcc.exe not installed for ledger support, please install or set LEDGER_ENABLED=false) + else + build_tags += ledger + endif + else + UNAME_S = $(shell uname -s) + ifeq ($(UNAME_S),OpenBSD) + $(warning OpenBSD detected, disabling ledger support (https://github.com/cosmos/cosmos-sdk/issues/1988)) + else + GCC = $(shell command -v gcc 2> /dev/null) + ifeq ($(GCC),) + $(error gcc not installed for ledger support, please install or set LEDGER_ENABLED=false) + else + build_tags += ledger + endif + endif + endif endif ifeq (cleveldb,$(findstring cleveldb,$(PYLONS_BUILD_OPTIONS))) - build_tags += gcc + build_tags += gcc endif build_tags += $(BUILD_TAGS) build_tags := $(strip $(build_tags)) @@ -59,10 +59,10 @@ ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=pylons \ ifeq (cleveldb,$(findstring cleveldb,$(PYLONS_BUILD_OPTIONS))) - ldflags += -X github.com/cosmos/cosmos-sdk/types.DBBackend=cleveldb + ldflags += -X github.com/cosmos/cosmos-sdk/types.DBBackend=cleveldb endif ifeq (,$(findstring nostrip,$(PYLONS_BUILD_OPTIONS))) - ldflags += -w -s + ldflags += -w -s endif ldflags += $(LDFLAGS) ldflags := $(strip $(ldflags)) @@ -70,7 +70,7 @@ ldflags := $(strip $(ldflags)) BUILD_FLAGS := -tags "$(build_tags)" -ldflags '$(ldflags)' # check for nostrip option ifeq (,$(findstring nostrip,$(PYLONS_BUILD_OPTIONS))) - BUILD_FLAGS += -trimpath + BUILD_FLAGS += -trimpath endif # The below include contains the tools target. @@ -96,12 +96,12 @@ build-linux: go.sum build-reproducible: go.sum $(DOCKER) rm latest-build || true $(DOCKER) run --volume=$(CURDIR):/sources:ro \ - --env TARGET_PLATFORMS='linux/amd64 darwin/amd64 linux/arm6' \ - --env APP=pylonsd \ - --env VERSION=$(VERSION) \ - --env COMMIT=$(COMMIT) \ - --env LEDGER_ENABLED=$(LEDGER_ENABLED) \ - --name latest-build cosmossdk/rbuilder:latest + --env TARGET_PLATFORMS='linux/amd64 darwin/amd64 linux/arm6' \ + --env APP=pylonsd \ + --env VERSION=$(VERSION) \ + --env COMMIT=$(COMMIT) \ + --env LEDGER_ENABLED=$(LEDGER_ENABLED) \ + --name latest-build cosmossdk/rbuilder:latest $(DOCKER) cp -a latest-build:/home/builder/artifacts/ $(CURDIR)/ clean: @@ -249,3 +249,12 @@ proto-lint: .PHONY: lint format proto-lint + + +############################################################################### +### Localnet ### +############################################################################### + +# Build image for a local testnet +localnet-build: + docker build -f Dockerfile -t pylons-node . \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000000..5e3a65501e --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,11 @@ +version: '3' + +services: + node0: + container_name: pylonsnode0 + image: "pylons-node" + ports: + - "26657:26657" + - "1317:1317" + volumes: + - ./debug:/debug \ No newline at end of file diff --git a/scripts/test_node_deploy.sh b/scripts/test_node_deploy.sh index 89198f1eb5..653535951d 100644 --- a/scripts/test_node_deploy.sh +++ b/scripts/test_node_deploy.sh @@ -9,6 +9,7 @@ LOGLEVEL="info" rm -rf ~/.pylon* # retrieve all args +WILL_START_FRESH=0 WILL_RECOVER=0 WILL_INSTALL=0 WILL_CONTINUE=0 @@ -18,6 +19,10 @@ then # $@ is for getting list of arguments for arg in "$@"; do case $arg in + --fresh) + WILL_START_FRESH=1 + shift + ;; --recover) WILL_RECOVER=1 shift @@ -48,6 +53,11 @@ fi # validate dependencies are installed command -v jq > /dev/null 2>&1 || { echo >&2 "jq not installed. More info: https://stedolan.github.io/jq/download/"; exit 1; } +if [ $WILL_START_FRESH -eq 1 ]; +then + rm -rf $HOME/.pylons* +fi + # install pylonsd if not exist if [ $WILL_INSTALL -eq 0 ]; then @@ -62,11 +72,15 @@ pylonsd config keyring-backend $KEYRING pylonsd config chain-id $CHAINID # determine if user wants to recorver or create new +rm debug/keys.txt + if [ $WILL_RECOVER -eq 0 ]; then - pylonsd keys add $KEY --keyring-backend $KEYRING --algo $KEYALGO + KEY_INFO=$(pylonsd keys add $KEY --keyring-backend $KEYRING --algo $KEYALGO) + echo $KEY_INFO >> debug/keys.txt else - pylonsd keys add $KEY --keyring-backend $KEYRING --algo $KEYALGO --recover + KEY_INFO=$(pylonsd keys add $KEY --keyring-backend $KEYRING --algo $KEYALGO --recover) + echo $KEY_INFO >> debug/keys.txt fi echo >&1 "\n" @@ -83,6 +97,10 @@ cat $HOME/.pylons/config/genesis.json | jq '.app_state["mint"]["params"]["mint_d # Set gas limit in genesis # cat $HOME/.pylons/config/genesis.json | jq '.consensus_params["block"]["max_gas"]="10000000"' > $HOME/.pylons/config/tmp_genesis.json && mv $HOME/.pylons/config/tmp_genesis.json $HOME/.pylons/config/genesis.json +# enable rest server and swagger +toml set --toml-path $HOME/.pylons/config/app.toml api.swagger true +toml set --toml-path $HOME/.pylons/config/app.toml api.enable true + # Allocate genesis accounts (cosmos formatted addresses) pylonsd add-genesis-account $KEY 1000000000000upylon --keyring-backend $KEYRING @@ -96,4 +114,4 @@ pylonsd collect-gentxs pylonsd validate-genesis # Start the node (remove the --pruning=nothing flag if historical queries are not needed) -pylonsd start --pruning=nothing --log_level $LOGLEVEL --minimum-gas-prices=0.0001upylon +pylonsd start --pruning=nothing --log_level $LOGLEVEL --minimum-gas-prices=0.0001upylon --rpc.laddr tcp://0.0.0.0:26657