Skip to content

Commit

Permalink
masterchef + e-staking module implementation (#435)
Browse files Browse the repository at this point in the history
* scaffold masterchef module

* scaffold estaking module

* bootstrap required proto/msgs/queries

* hook functions for masterchef

* ClaimRewards, token transfer on AddExternalIncentive, PendingRewards query

* masterchef reward distribution update

* external reward distribution

* Integrate distribution module on app.go and add TODOs for estaking

* Add whitelist feature for external incentive tokens & minimum amount configuration per external incentive & Add more query functions for frontend (e.g. queries on incentives - APR)

* update on commitment hook management for Eden and EdenB

* add update on wasmbinding and cli commands

* add GetTokenPrice

* update reward claim process for eden and edenB

* add unit test for user reward info and abci todo

* Resolve chain start issue on estaking module

* cleanup eden validator pubkey variables

* add update on external incentive APR, unit tests

* update on masterchef unit test

* implement estaking msgserver, queries, disable reward distribution in incentive module

* implement missing hooks for estaking

* add further test and fixes on masterchef

* reward distribution logic on estaking

* add TODO unit tesT

* Refactor queries to fit into new estaking + masterchef data structure

* fix issues after testing through cli command

* removal of duplications in incentive and masterchef

* add update for edenB rewards

* Resolve single node start issue

* update for EdenBoostApr field

* Implement query for AllProgramRewards on incentive module & disable invariant

* update on estaking+masterchef+commitment

* add missing wasmbinding on estaking

* add basic upgrade handler for commitment, incentive, masterchef, distribution

* resolve issues in single node start

* Resolve stablestake reward claim issue on masterchef

* add incentive refactoring upgrade test script

* add missing wasmbindings for estaking+masterchef

* add unit test for estaking msgServer

* update unit test for UpdateStakersRewards

* Add unit test for estaking QueryRewards

* prevent panics on hooks

* Add unit test for Estaking ExtendedFunctions

* Add unit test for masterchef abci

* Move elys staked snapshot related codebase from incentive to estaking & resolve tests

* fix hooks execution on incentive v11 migration

* fix issue in v11 migration script

* add query command for all rewards for a delegator

* resolve unit tests

* ci: software upgrade test fix

* ci: fix upgrade-assure

* ci: increase timeout to 10min

* test: improve test scripts

* ci: add flags to avoid port conflicts between nodes

* fix cli command example text

* remove max_eden_per_allocation on masterchef incentive info

---------

Co-authored-by: Cosmic Vagabond <121588426+cosmic-vagabond@users.noreply.github.com>
  • Loading branch information
jelysn and cosmic-vagabond authored Apr 26, 2024
1 parent adada7c commit a4aecf0
Show file tree
Hide file tree
Showing 272 changed files with 29,313 additions and 12,610 deletions.
9 changes: 4 additions & 5 deletions .github/workflows/software-upgrade-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
jobs:
software-upgrade-test:
runs-on: ubuntu-latest
timeout-minutes: 60

steps:
- name: Checkout repository
Expand Down Expand Up @@ -52,14 +53,12 @@ jobs:

- name: Chain initialization
run: |
# disabled this line temporarily as v0.29.31 types.go commitment vesting info structure is different
# TODO: restore this line before v0.29.32 is released
# cp -a scripts/upgrade-assure/types.go scripts/upgrade-assure-skip/types.go
go run ./scripts/upgrade-assure-skip/... $SNAPSHOT_PATH $OLD_BINARY_PATH $NEW_BINARY_PATH --skip-node-start
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: |
go run ./scripts/upgrade-assure/... $SNAPSHOT_PATH $OLD_BINARY_PATH $NEW_BINARY_PATH --skip-snapshot --skip-chain-init
GOMEMLIMIT=16GiB go run ./scripts/upgrade-assure/... $SNAPSHOT_PATH $OLD_BINARY_PATH $NEW_BINARY_PATH --skip-snapshot --skip-chain-init
11 changes: 1 addition & 10 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 @@ -29,4 +20,4 @@ jobs:
- name: Run unit tests
run: |
go test ./...
make ci-test-unit
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -95,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
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 a4aecf0

Please sign in to comment.