Skip to content

Commit

Permalink
chore: v0.45.x bump min go version to 1.17 (#11686)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderbez committed Apr 19, 2022
1 parent e73b7ee commit ffef0ba
Show file tree
Hide file tree
Showing 16 changed files with 254 additions and 90 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
steps:
- uses: actions/setup-go@v2.1.4
with:
go-version: 1.16
go-version: 1.17
- uses: technote-space/get-diff-action@v5
id: git_diff
with:
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/sims.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2.1.3
with:
go-version: 1.16
go-version: 1.17
- name: Display go version
run: go version
- run: make build
Expand All @@ -26,7 +26,7 @@ jobs:
steps:
- uses: actions/setup-go@v2.1.3
with:
go-version: 1.16
go-version: 1.17
- name: Display go version
run: go version
- name: Install runsim
Expand All @@ -43,7 +43,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2.1.3
with:
go-version: 1.16
go-version: 1.17
- name: Display go version
run: go version
- uses: technote-space/get-diff-action@v4
Expand All @@ -69,7 +69,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2.1.3
with:
go-version: 1.16
go-version: 1.17
- name: Display go version
run: go version
- uses: technote-space/get-diff-action@v4
Expand Down Expand Up @@ -97,7 +97,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2.1.3
with:
go-version: 1.16
go-version: 1.17
- name: Display go version
run: go version
- uses: technote-space/get-diff-action@v4
Expand Down Expand Up @@ -125,7 +125,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2.1.3
with:
go-version: 1.16
go-version: 1.17
- name: Display go version
run: go version
- uses: technote-space/get-diff-action@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v2.1.3
with:
go-version: 1.16
go-version: 1.17
- name: Unshallow
run: git fetch --prune --unshallow
- name: Create release
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
steps:
- uses: actions/setup-go@v2.1.3
with:
go-version: 1.16
go-version: 1.17
- name: Display go version
run: go version
- name: install tparse
Expand All @@ -32,7 +32,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2.1.3
with:
go-version: 1.16
go-version: 1.17
- uses: technote-space/get-diff-action@v4
id: git_diff
with:
Expand All @@ -49,7 +49,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2.1.3
with:
go-version: 1.16
go-version: 1.17
- name: Display go version
run: go version
- uses: technote-space/get-diff-action@v4
Expand Down Expand Up @@ -102,7 +102,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2.1.3
with:
go-version: 1.16
go-version: 1.17
- uses: technote-space/get-diff-action@v4
with:
PATTERNS: |
Expand Down Expand Up @@ -180,7 +180,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2.1.3
with:
go-version: 1.16
go-version: 1.17
- uses: technote-space/get-diff-action@v4
with:
PATTERNS: |
Expand Down Expand Up @@ -224,7 +224,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2.1.3
with:
go-version: 1.16
go-version: 1.17
- uses: technote-space/get-diff-action@v4
id: git_diff
with:
Expand All @@ -234,7 +234,7 @@ jobs:
go.sum
- name: start localnet
run: |
make clean build-simd-linux localnet-start
make clean localnet-start
if: env.GIT_DIFF
- name: test liveness
run: |
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ Ref: https://keepachangelog.com/en/1.0.0/

### Improvements

* [\#11686](https://github.com/cosmos/cosmos-sdk/pull/11686) Update the min required Golang version to `1.17`.
* (x/auth/vesting) [\#11652](https://github.com/cosmos/cosmos-sdk/pull/11652) Add util functions for `Period(s)`

## [v0.45.3](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.45.3) - 2022-04-12
Expand Down
55 changes: 23 additions & 32 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -112,41 +112,18 @@ BUILD_TARGETS := build install

build: BUILD_ARGS=-o $(BUILDDIR)/
build-linux:
GOOS=linux GOARCH=amd64 LEDGER_ENABLED=false $(MAKE) build
GOOS=linux GOARCH=$(if $(findstring aarch64,$(shell uname -m)) || $(findstring arm64,$(shell uname -m)),arm64,amd64) LEDGER_ENABLED=false $(MAKE) build

$(BUILD_TARGETS): go.sum $(BUILDDIR)/
go $@ -mod=readonly $(BUILD_FLAGS) $(BUILD_ARGS) ./...

$(BUILDDIR)/:
mkdir -p $(BUILDDIR)/

build-simd-all: go.sum
$(DOCKER) rm latest-build || true
$(DOCKER) run --volume=$(CURDIR):/sources:ro \
--env TARGET_PLATFORMS='linux/amd64 darwin/amd64 linux/arm64 windows/amd64' \
--env APP=simd \
--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)/

build-simd-linux: go.sum $(BUILDDIR)/
$(DOCKER) rm latest-build || true
$(DOCKER) run --volume=$(CURDIR):/sources:ro \
--env TARGET_PLATFORMS='linux/amd64' \
--env APP=simd \
--env VERSION=$(VERSION) \
--env COMMIT=$(COMMIT) \
--env LEDGER_ENABLED=false \
--name latest-build cosmossdk/rbuilder:latest
$(DOCKER) cp -a latest-build:/home/builder/artifacts/ $(CURDIR)/
cp artifacts/simd-*-linux-amd64 $(BUILDDIR)/simd

cosmovisor:
$(MAKE) -C cosmovisor cosmovisor

.PHONY: build build-linux build-simd-all build-simd-linux cosmovisor
.PHONY: build build-linux cosmovisor

mockgen_cmd=go run github.com/golang/mock/mockgen

Expand Down Expand Up @@ -484,26 +461,40 @@ proto-update-deps:
### Localnet ###
###############################################################################

# Run a 4-node testnet locally
localnet-start: build-linux localnet-stop
$(if $(shell $(DOCKER) inspect -f '{{ .Id }}' cosmossdk/simd-env 2>/dev/null),$(info found image cosmossdk/simd-env),$(MAKE) -C contrib/images simd-env)
$(DOCKER) run --rm -v $(CURDIR)/localnet:/data cosmossdk/simd-env \
testnet init-files --v 4 -o /data --starting-ip-address 192.168.10.2 --keyring-backend=test
localnet-build-env:
$(MAKE) -C contrib/images simd-env

localnet-build-dlv:
$(MAKE) -C contrib/images simd-dlv

localnet-build-nodes:
$(DOCKER) run --rm -v $(CURDIR)/.testnets:/data cosmossdk/simd \
testnet init-files --v 4 -o /data --starting-ip-address 192.168.10.2 --keyring-backend=test
docker-compose up -d

localnet-stop:
docker-compose down

.PHONY: localnet-start localnet-stop
# localnet-start will run a 4-node testnet locally. The nodes are
# based off the docker images in: ./contrib/images/simd-env
localnet-start: localnet-stop localnet-build-env localnet-build-nodes

# localnet-debug will run a 4-node testnet locally in debug mode
# you can read more about the debug mode here: ./contrib/images/simd-dlv/README.md
localnet-debug: localnet-stop localnet-build-dlv localnet-build-nodes

.PHONY: localnet-start localnet-stop localnet-debug localnet-build-env \
localnet-build-dlv localnet-build-nodes

###############################################################################
### rosetta ###
###############################################################################
# builds rosetta test data dir

rosetta-data:
-docker container rm data_dir_build
docker build -t rosetta-ci:latest -f contrib/rosetta/node/Dockerfile .
docker run --name data_dir_build -t rosetta-ci:latest sh /rosetta/data.sh
docker cp data_dir_build:/tmp/data.tar.gz "$(CURDIR)/contrib/rosetta/node/data.tar.gz"
docker container rm data_dir_build

.PHONY: rosetta-data
15 changes: 11 additions & 4 deletions contrib/images/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
all: simd-env

simd-env:
docker build --tag cosmossdk/simd-env -f simd-env/Dockerfile \
$(shell git rev-parse --show-toplevel)
simd-env: simd-rmi
docker build --tag cosmossdk/simd -f simd-env/Dockerfile \
$(shell git rev-parse --show-toplevel)

.PHONY: all simd-env
simd-dlv: simd-rmi
docker build --tag cosmossdk/simd -f simd-dlv/Dockerfile \
$(shell git rev-parse --show-toplevel)

simd-rmi:
docker rmi cosmossdk/simd 2>/dev/null; true

.PHONY: all simd-env simd-dlv simd-rmi
22 changes: 22 additions & 0 deletions contrib/images/simd-dlv/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
FROM golang:1.17-alpine AS build
RUN apk add build-base git linux-headers libc-dev
RUN go install github.com/go-delve/delve/cmd/dlv@latest
WORKDIR /work
COPY go.mod go.sum /work/
RUN go mod download
COPY ./ /work
RUN LEDGER_ENABLED=false make COSMOS_BUILD_OPTIONS="debug,nostrip" clean build

FROM alpine:3.14 AS run
RUN apk add bash curl jq
COPY contrib/images/simd-dlv/wrapper.sh /usr/bin/wrapper.sh

VOLUME /simd
COPY --from=build /work/build/simd /simd/
COPY --from=build /go/bin/dlv /usr/local/bin
WORKDIR /simd

EXPOSE 26656 26657 2345
ENTRYPOINT ["/usr/bin/wrapper.sh"]
CMD ["start", "--log_format", "plain"]
STOPSIGNAL SIGTERM
37 changes: 37 additions & 0 deletions contrib/images/simd-dlv/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Remote Debugging with go-delve

[Delve](https://github.com/go-delve/delve) is a debugger for the Go programming language. The goal of the project is to provide a simple, full featured debugging tool for Go. Delve should be easy to invoke and easy to use. Chances are if you're using a debugger, things aren't going your way. With that in mind, Delve should stay out of your way as much as possible.

## Use-case

Cosmos-SDK provides you with a local network to bootstrap a chain in your machine, but how does one debug a node or module?

If we start a single node, we won't be able to debug transactions as the machine will be in bootstrapping phase trying to find peers to connect too, thats why we need to start a local network.

But the current `localnet-start` does not provide us with debugging tools so that's why there is a different image for debugging a local network, that is to avoid any issues in the future were debugging won't be needed.

Both `simd-env` and `simd-dlv` work and run the same, except that `simd-dlv` uses `go-delve` to run the binaries.

## How to use

The command to start a local network in debug mode is:

```shell
# make localnet-debug
```

The command to stop the local network and destroy its containers is:

```shell
# make localnet-stop
```

__note: this works the same for both `localnet-start` and `localnet-debug`__

Now, by default only `simdnode0` is run in debug mode, but you can run any of the other nodes in debug mode by changing the `DEBUG` environment variable to `1` in `docker-compose.yml`.

## How to connect

Delve will open a port on `2345` for `simdnode0` and it will increment for each of the other nodes that have `DEBUG` set to `1`.

You can connect to the debugging server either through [GoLand IDE](https://www.jetbrains.com/help/go/attach-to-running-go-processes-with-debugger.html) or you can use [delve cli](https://github.com/go-delve/delve/blob/master/Documentation/usage/dlv_connect.md) command.
25 changes: 25 additions & 0 deletions contrib/images/simd-dlv/wrapper.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env sh
set -euo pipefail
set -x

DEBUG=${DEBUG:-0}
BINARY=/simd/${BINARY:-simd}
ID=${ID:-0}
LOG=${LOG:-simd.log}

if ! [ -f "${BINARY}" ]; then
echo "The binary $(basename "${BINARY}") cannot be found. Please add the binary to the shared folder. Please use the BINARY environment variable if the name of the binary is not 'simd'"
exit 1
fi

export SIMDHOME="/data/node${ID}/simd"

if [ "$DEBUG" -eq 1 ]; then
dlv --listen=:2345 --continue --headless=true --api-version=2 --accept-multiclient exec "${BINARY}" -- --home "${SIMDHOME}" "$@"
elif [ "$DEBUG" -eq 1 ] && [ -d "$(dirname "${SIMDHOME}"/"${LOG}")" ]; then
dlv --listen=:2345 --continue --headless=true --api-version=2 --accept-multiclient exec "${BINARY}" -- --home "${SIMDHOME}" "$@" | tee "${SIMDHOME}/${LOG}"
elif [ -d "$(dirname "${SIMDHOME}"/"${LOG}")" ]; then
"${BINARY}" --home "${SIMDHOME}" "$@" | tee "${SIMDHOME}/${LOG}"
else
"${BINARY}" --home "${SIMDHOME}" "$@"
fi
2 changes: 1 addition & 1 deletion contrib/images/simd-env/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FROM golang:1.17-alpine AS build
RUN apk add build-base git linux-headers
WORKDIR /work
COPY go.mod go.sum /work/
COPY db/go.mod db/go.sum /work/db/

RUN go mod download
COPY ./ /work
RUN LEDGER_ENABLED=false make clean build
Expand Down
3 changes: 1 addition & 2 deletions contrib/rosetta/node/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.15-alpine as build
FROM golang:1.17-alpine as build

RUN apk add --no-cache tar

Expand Down Expand Up @@ -29,4 +29,3 @@ COPY --from=build /node/root /root/
WORKDIR /root/.simapp

RUN chmod -R 0777 ./

2 changes: 1 addition & 1 deletion contrib/rosetta/rosetta-cli/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.15-alpine as build
FROM golang:1.17-alpine as build

RUN apk add git gcc libc-dev --no-cache

Expand Down
Loading

0 comments on commit ffef0ba

Please sign in to comment.