Skip to content

Commit

Permalink
Merge branch 'main' into launchpad_module
Browse files Browse the repository at this point in the history
  • Loading branch information
cosmic-vagabond committed Apr 26, 2024
2 parents 273ec04 + 2127d74 commit e48a2a4
Show file tree
Hide file tree
Showing 407 changed files with 36,172 additions and 12,186 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.inputs.release_tag }}
Expand All @@ -31,7 +31,7 @@ jobs:
# helper functions
extract_txhash() { awk -F 'txhash: ' '/txhash:/{print $2; exit}'; }
extract_proposal_id() { awk -F 'key: proposal_id|value: ' '/key: proposal_id/ { getline; gsub(/"/, "", $2); print $2; exit }'; }
extract_and_calc_upgrade_height() { awk -F'"latest_block_height":"' '{ split($2,a,"\""); print a[1]+8000; exit }'; }
extract_and_calc_upgrade_height() { awk -F'"latest_block_height":"' '{ split($2,a,"\""); print a[1]+21600; exit }'; }
extract_checksum() { awk "/elysd-${{ github.ref_name }}-linux-amd64.tar.gz/ {print \$1; exit}"; }
# environment variables
Expand Down
64 changes: 64 additions & 0 deletions .github/workflows/software-upgrade-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Test Software Upgrade

on:
pull_request:

jobs:
software-upgrade-test:
runs-on: ubuntu-latest
timeout-minutes: 60

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: "1.21"

- name: Retrieve latest snapshot
run: |
DOWNLOAD_URL=https://snapshots-testnet.stake-town.com/elys/elystestnet-1_latest.tar.lz4
SNAPSHOT_PATH=/tmp/snapshot.tar.lz4
curl -L $DOWNLOAD_URL -o $SNAPSHOT_PATH
echo "SNAPSHOT_PATH=$SNAPSHOT_PATH" >> $GITHUB_ENV
- name: Retrieve latest binary
run: |
LATEST_TAG=$(git describe --tags `git rev-list --tags --max-count=1`)
DOWNLOAD_URL=https://github.com/elys-network/elys/releases/download/$LATEST_TAG/elysd-$LATEST_TAG-linux-amd64
OLD_BINARY_PATH=/tmp/elysd-$LATEST_TAG
curl -L $DOWNLOAD_URL -o $OLD_BINARY_PATH && chmod +x $OLD_BINARY_PATH
echo "LATEST_TAG=$LATEST_TAG" >> $GITHUB_ENV
echo "OLD_BINARY_PATH=$OLD_BINARY_PATH" >> $GITHUB_ENV
- name: Create git tag
run: git tag v999.999.999

- name: Run make build
run: |
make build
NEW_BINARY_PATH=./build/elysd
echo "NEW_BINARY_PATH=$NEW_BINARY_PATH" >> $GITHUB_ENV
- name: Copy upgrade-assure scripts
run: cp -a scripts/upgrade-assure scripts/upgrade-assure-skip

- name: Check out latest tag
run: git checkout $LATEST_TAG

- name: Chain initialization
run: |
cp -a scripts/upgrade-assure/types.go scripts/upgrade-assure-skip/types.go
GOMEMLIMIT=16GiB go run ./scripts/upgrade-assure-skip/... $SNAPSHOT_PATH $OLD_BINARY_PATH $NEW_BINARY_PATH --skip-node-start
- name: Check out new branch
run: git checkout ${{ github.head_ref }}

- name: Software upgrade
run: |
GOMEMLIMIT=16GiB go run ./scripts/upgrade-assure/... $SNAPSHOT_PATH $OLD_BINARY_PATH $NEW_BINARY_PATH --skip-snapshot --skip-chain-init
15 changes: 3 additions & 12 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
# This workflow file defines a job named test that runs on Ubuntu and is triggered
# on push and pull request events.
#
# The job checks out the repository code, sets up Go with version 1.20, installs
# the project dependencies, and runs the unit tests using `go test`.
#
# The purpose of this workflow file is to automate the process of running unit tests
# for the Elys codebase whenever code changes are pushed or a pull request is opened.

name: Run unit tests
on: push

Expand All @@ -16,17 +7,17 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: "1.20"
go-version: "1.21"

- name: Install dependencies
run: |
go mod tidy
- name: Run unit tests
run: |
go test ./...
make ci-test-unit
12 changes: 8 additions & 4 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,14 @@ builds:
- -X github.com/cosmos/cosmos-sdk/version.AppName=elysd
- -X github.com/cosmos/cosmos-sdk/version.Version=v{{ .Version }}
- -X github.com/cosmos/cosmos-sdk/version.Commit={{ .Commit }}
- -X github.com/cosmos/cosmos-sdk/version.BuildTags=netgo,ledger,static_wasm
- -X github.com/cosmos/cosmos-sdk/version.BuildTags=netgo,ledger,static_wasm,pebbledb
- -w -s
- -linkmode=external
tags:
- netgo
- ledger
- static_wasm
- pebbledb
- id: elysd-darwin-arm64
main: ./cmd/elysd/main.go
binary: elysd
Expand All @@ -51,13 +52,14 @@ builds:
- -X github.com/cosmos/cosmos-sdk/version.AppName=elysd
- -X github.com/cosmos/cosmos-sdk/version.Version=v{{ .Version }}
- -X github.com/cosmos/cosmos-sdk/version.Commit={{ .Commit }}
- -X github.com/cosmos/cosmos-sdk/version.BuildTags=netgo,ledger,static_wasm
- -X github.com/cosmos/cosmos-sdk/version.BuildTags=netgo,ledger,static_wasm,pebbledb
- -w -s
- -linkmode=external
tags:
- netgo
- ledger
- static_wasm
- pebbledb
- id: elysd-linux-amd64
main: ./cmd/elysd
binary: elysd
Expand All @@ -78,7 +80,7 @@ builds:
- -X github.com/cosmos/cosmos-sdk/version.AppName=elysd
- -X github.com/cosmos/cosmos-sdk/version.Version=v{{ .Version }}
- -X github.com/cosmos/cosmos-sdk/version.Commit={{ .Commit }}
- -X github.com/cosmos/cosmos-sdk/version.BuildTags=netgo,ledger,muslc,osusergo
- -X github.com/cosmos/cosmos-sdk/version.BuildTags=netgo,ledger,muslc,osusergo,pebbledb
- -w -s
- -linkmode=external
- -extldflags '-Wl,-z,muldefs -static -lm'
Expand All @@ -87,6 +89,7 @@ builds:
- ledger
- muslc
- osusergo
- pebbledb
- id: elysd-linux-arm64
main: ./cmd/elysd
binary: elysd
Expand All @@ -107,7 +110,7 @@ builds:
- -X github.com/cosmos/cosmos-sdk/version.AppName=elysd
- -X github.com/cosmos/cosmos-sdk/version.Version=v{{ .Version }}
- -X github.com/cosmos/cosmos-sdk/version.Commit={{ .Commit }}
- -X github.com/cosmos/cosmos-sdk/version.BuildTags=netgo,ledger,muslc,osusergo
- -X github.com/cosmos/cosmos-sdk/version.BuildTags=netgo,ledger,muslc,osusergo,pebbledb
- -w -s
- -linkmode=external
- -extldflags '-Wl,-z,muldefs -static -lm'
Expand All @@ -116,6 +119,7 @@ builds:
- ledger
- muslc
- osusergo
- pebbledb
universal_binaries:
- id: elysd-darwin-universal
ids:
Expand Down
23 changes: 20 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,16 @@ BINARY?=$(NAME)d
COMMIT:=$(shell git log -1 --format='%H')
VERSION:=$(shell git describe --tags --match 'v*' --abbrev=8 | sed 's/-g/-/' | sed 's/-[0-9]*-/-/')
GOFLAGS:=""
GOTAGS:=ledger

# if rocksdb env variable is set, add the tag
ifdef ROCKSDB
DBENGINE=rocksdb
else
DBENGINE=pebbledb
endif

GOTAGS:=ledger,$(DBENGINE)

SHELL := /bin/bash # Use bash syntax

# currently installed Go version
Expand Down Expand Up @@ -37,7 +46,9 @@ ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=$(NAME) \
-X github.com/cosmos/cosmos-sdk/version.ServerName=$(BINARY) \
-X github.com/cosmos/cosmos-sdk/version.ClientName=$(BINARY) \
-X github.com/cosmos/cosmos-sdk/version.Version=$(VERSION) \
-X github.com/cosmos/cosmos-sdk/version.Commit=$(COMMIT)
-X github.com/cosmos/cosmos-sdk/version.Commit=$(COMMIT) \
-X github.com/cosmos/cosmos-sdk/types.DBBackend=$(DBENGINE) \
-X github.com/cosmos/cosmos-sdk/version.BuildTags=netgo,ledger,muslc,osusergo,$(DBENGINE)
BUILD_FLAGS := -ldflags '$(ldflags)' -tags '$(GOTAGS)'
BUILD_FOLDER = ./build

Expand Down Expand Up @@ -84,13 +95,18 @@ test-unit:
@echo Running unit tests...
@GOFLAGS=$(GOFLAGS) go test -race -failfast -v ./...

## ci-test-unit: Run unit tests
ci-test-unit:
@echo Running unit tests via CI...
@GOFLAGS=$(GOFLAGS) GOMEMLIMIT=16GiB go test -race -cpu=4 -failfast -v ./...

## clean: Clean build files. Runs `go clean` internally.
clean:
@echo Cleaning build cache...
@rm -rf $(BUILD_FOLDER) 2> /dev/null
@go clean ./...

.PHONY: mocks test-unit clean
.PHONY: mocks test-unit ci-test-unit clean

## go-mod-cache: Retrieve the go modules and store them in the local cache
go-mod-cache: go.sum
Expand Down Expand Up @@ -152,6 +168,7 @@ stop-docker:

GORELEASER_IMAGE := ghcr.io/goreleaser/goreleaser-cross:v$(GO_VERSION)
COSMWASM_VERSION := $(shell go list -m github.com/CosmWasm/wasmvm | sed 's/.* //')
ROCKSDB_VERSION := 8.9.1

## release: Build binaries for all platforms and generate checksums
ifdef GITHUB_TOKEN
Expand Down
6 changes: 3 additions & 3 deletions app/ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ func (min MinCommissionDecorator) AnteHandle(
return errorsmod.Wrap(sdkerrors.ErrUnauthorized, "commission can't be lower than 5%")
}
projectedVotingPower := min.CalculateValidatorProjectedVotingPower(ctx, sdk.NewDecFromInt(msg.Value.Amount))
if projectedVotingPower.GTE(maxVotingPower) {
if projectedVotingPower.GT(maxVotingPower) {
return errorsmod.Wrapf(
sdkerrors.ErrInvalidRequest,
"This validator has a voting power of %s%%. Delegations not allowed to a validator whose post-delegation voting power is more than %s%%. Please delegate to a validator with less bonded tokens", projectedVotingPower.Mul(sdk.NewDec(100)), maxVotingPower.Mul(sdk.NewDec(100)))
Expand All @@ -160,7 +160,7 @@ func (min MinCommissionDecorator) AnteHandle(
}

projectedVotingPower := min.CalculateDelegateProjectedVotingPower(ctx, val, sdk.NewDecFromInt(msg.Amount.Amount))
if projectedVotingPower.GTE(maxVotingPower) {
if projectedVotingPower.GT(maxVotingPower) {
return errorsmod.Wrapf(
sdkerrors.ErrInvalidRequest,
"This validator has a voting power of %s%%. Delegations not allowed to a validator whose post-delegation voting power is more than %s%%. Please delegate to a validator with less bonded tokens", projectedVotingPower.Mul(sdk.NewDec(100)), maxVotingPower.Mul(sdk.NewDec(100)))
Expand All @@ -181,7 +181,7 @@ func (min MinCommissionDecorator) AnteHandle(
}

projectedVotingPower := min.CalculateRedelegateProjectedVotingPower(ctx, dstVal, delegateAmount)
if projectedVotingPower.GTE(maxVotingPower) {
if projectedVotingPower.GT(maxVotingPower) {
return errorsmod.Wrapf(
sdkerrors.ErrInvalidRequest,
"This validator has a voting power of %s%%. Delegations not allowed to a validator whose post-delegation voting power is more than %s%%. Please redelegate to a validator with less bonded tokens", projectedVotingPower.Mul(sdk.NewDec(100)), maxVotingPower.Mul(sdk.NewDec(100)))
Expand Down
Loading

0 comments on commit e48a2a4

Please sign in to comment.