diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index f55a90ad..3e3e4a0c 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1,3 +1,3 @@ # https://help.github.com/articles/about-codeowners -* @johnletey @mbreithecker @troykessler +* @mbreithecker @troykessler @shifty11 diff --git a/.github/workflows/all.yml b/.github/workflows/all.yml new file mode 100644 index 00000000..c126f513 --- /dev/null +++ b/.github/workflows/all.yml @@ -0,0 +1,9 @@ +name: run all jobs +on: push + +jobs: + lint: + uses: ./.github/workflows/lint.yml + + test: + uses: ./.github/workflows/test.yml \ No newline at end of file diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index accc8d20..5ec1f46f 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,29 +1,39 @@ -on: push +name: lint +on: + workflow_call: jobs: buf: runs-on: ubuntu-latest steps: - # Run `git checkout` - - uses: actions/checkout@v3 + # Checkout the repository + - name: Checkout the repository + uses: actions/checkout@v4 # Install `buf` - - uses: bufbuild/buf-setup-action@v1 + - name: Install `buf` + uses: bufbuild/buf-setup-action@v1 with: github_token: ${{ github.token }} # Lint Protobuf files - - uses: bufbuild/buf-lint-action@v1 + - name: Lint Protobuf files + uses: bufbuild/buf-lint-action@v1 with: buf_token: ${{ secrets.BUF_TOKEN }} -# TODO(@john): Figure out why linting passes locally but not here. -# golangci: -# runs-on: ubuntu-latest -# steps: -# # Run `git checkout` -# - uses: actions/checkout@v3 -# # Install `go` -# - uses: actions/setup-go@v3 -# # Lint Go files -# - uses: golangci/golangci-lint-action@v3 -# with: -# args: --timeout=10m + golangci: + runs-on: ubuntu-latest + steps: + # Checkout the repository + - name: Checkout the repository + uses: actions/checkout@v4 + # Setup Golang + - name: 🐿 Setup Golang + uses: actions/setup-go@v4 + with: + go-version-file: 'go.mod' + # Lint go files with golangci-lint + - name: Lint go files with golangci-lint + uses: golangci/golangci-lint-action@v3 + with: + version: latest + args: --timeout=10m diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 00000000..d069d018 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,19 @@ +name: test +on: + workflow_call: + +jobs: + test: + runs-on: ubuntu-latest + steps: + # Checkout the repository + - name: Check out repository code + uses: actions/checkout@v4 + # Setup Golang + - name: 🐿 Setup Golang + uses: actions/setup-go@v4 + with: + go-version-file: 'go.mod' + # Test & coverage report creation + - name: Test & coverage report creation + run: go test -cover -mod=readonly ./x/... \ No newline at end of file diff --git a/Makefile b/Makefile index 9fe45bf7..50784932 100644 --- a/Makefile +++ b/Makefile @@ -123,7 +123,6 @@ endif ### Development ### ############################################################################### -# TODO(@john): Switch to the Docker image? dev: @ignite chain serve --reset-once --skip-proto --verbose @@ -144,12 +143,6 @@ lint: @go run $(golangci_lint_cmd) run --skip-dirs scripts --timeout=10m @echo "✅ Completed linting!" -# TODO(@john): Can we remove this since we use GolangCI? -vet: - @echo "🤖 Running vet..." - @go vet ./... - @echo "✅ Completed vet!" - ############################################################################### ### Protobuf ### ############################################################################### diff --git a/app/app.go b/app/app.go index 2e9027f5..9f31b949 100644 --- a/app/app.go +++ b/app/app.go @@ -98,7 +98,7 @@ import ( group "github.com/cosmos/cosmos-sdk/x/group/module" // IBC Core ibc "github.com/cosmos/ibc-go/v7/modules/core" - ibcClientHandler "github.com/cosmos/ibc-go/v7/modules/core/02-client" // TODO + ibcClientHandler "github.com/cosmos/ibc-go/v7/modules/core/02-client" ibcClientTypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" ibcPortTypes "github.com/cosmos/ibc-go/v7/modules/core/05-port/types" ibcExported "github.com/cosmos/ibc-go/v7/modules/core/exported" @@ -345,7 +345,7 @@ func NewKYVEApp( scopedICAControllerKeeper := app.CapabilityKeeper.ScopeToModule(icaControllerTypes.SubModuleName) scopedICAHostKeeper := app.CapabilityKeeper.ScopeToModule(icaHostTypes.SubModuleName) - // TODO(@john): Seal x/capability keeper. + app.CapabilityKeeper.Seal() // add keepers app.AccountKeeper = authKeeper.NewAccountKeeper( @@ -384,7 +384,7 @@ func NewKYVEApp( appCodec, keys[mintTypes.StoreKey], app.StakingKeeper, - &app.StakersKeeper, // TODO(@john) + &app.StakersKeeper, // This is a pointer because the stakers keeper is not initialized yet. app.AccountKeeper, app.BankKeeper, authTypes.FeeCollectorName, diff --git a/app/upgrades/v1_4/upgrade.go b/app/upgrades/v1_4/upgrade.go index 25014a7d..78d3bdbd 100644 --- a/app/upgrades/v1_4/upgrade.go +++ b/app/upgrades/v1_4/upgrade.go @@ -32,6 +32,8 @@ import ( upgradeTypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" ) +//nolint:all +//goland:noinspection GoDeprecation func CreateUpgradeHandler( mm *module.Manager, configurator module.Configurator, diff --git a/cmd/kyved/root.go b/cmd/kyved/root.go index 57d3c0d5..f3bbac67 100644 --- a/cmd/kyved/root.go +++ b/cmd/kyved/root.go @@ -103,7 +103,7 @@ func NewRootCmd(encodingConfig kyveApp.EncodingConfig) *cobra.Command { tmCli.NewCompletionCmd(rootCmd, true), debug.Cmd(), config.Cmd(), - pruning.PruningCmd(ac.createApp), + pruning.Cmd(ac.createApp, kyveApp.DefaultNodeHome), rpc.StatusCommand(), queryCommand(), diff --git a/testutil/integration/checks.go b/testutil/integration/checks.go index e84c8c36..446fcf29 100644 --- a/testutil/integration/checks.go +++ b/testutil/integration/checks.go @@ -8,7 +8,7 @@ import ( "github.com/KYVENetwork/chain/x/delegation" delegationtypes "github.com/KYVENetwork/chain/x/delegation/types" globalTypes "github.com/KYVENetwork/chain/x/global/types" - "github.com/KYVENetwork/chain/x/pool" + poolmodule "github.com/KYVENetwork/chain/x/pool" querytypes "github.com/KYVENetwork/chain/x/query/types" "github.com/KYVENetwork/chain/x/stakers" stakertypes "github.com/KYVENetwork/chain/x/stakers/types" @@ -24,10 +24,7 @@ func (suite *KeeperTestSuite) PerformValidityChecks() { // verify pool module suite.VerifyPoolModuleAssetsIntegrity() suite.VerifyPoolTotalFunds() - - // TODO(@troy,@max): Figure out a better way to check this when disabling pools. - // suite.VerifyPoolQueries() - + suite.VerifyPoolQueries() suite.VerifyPoolGenesisImportExport() // verify stakers module @@ -98,6 +95,15 @@ func (suite *KeeperTestSuite) VerifyPoolQueries() { poolsQuery = append(poolsQuery, activePoolsQuery.Pools...) poolsQuery = append(poolsQuery, disabledPoolsQuery.Pools...) + // sort pools by id + for i := range poolsQuery { + for j := range poolsQuery { + if poolsQuery[i].Id < poolsQuery[j].Id { + poolsQuery[i], poolsQuery[j] = poolsQuery[j], poolsQuery[i] + } + } + } + Expect(activePoolsQueryErr).To(BeNil()) Expect(disabledPoolsQueryErr).To(BeNil()) @@ -155,7 +161,7 @@ func (suite *KeeperTestSuite) VerifyPoolQueries() { } func (suite *KeeperTestSuite) VerifyPoolGenesisImportExport() { - genState := pool.ExportGenesis(suite.Ctx(), suite.App().PoolKeeper) + genState := poolmodule.ExportGenesis(suite.Ctx(), suite.App().PoolKeeper) // Delete all entries in Pool Store store := suite.Ctx().KVStore(suite.App().PoolKeeper.StoreKey()) @@ -163,7 +169,7 @@ func (suite *KeeperTestSuite) VerifyPoolGenesisImportExport() { err := genState.Validate() Expect(err).To(BeNil()) - pool.InitGenesis(suite.Ctx(), suite.App().PoolKeeper, *genState) + poolmodule.InitGenesis(suite.Ctx(), suite.App().PoolKeeper, *genState) } // ===================== diff --git a/x/delegation/keeper/msg_server_delegate_test.go b/x/delegation/keeper/msg_server_delegate_test.go index 9160f14d..991df2a9 100644 --- a/x/delegation/keeper/msg_server_delegate_test.go +++ b/x/delegation/keeper/msg_server_delegate_test.go @@ -21,7 +21,7 @@ TEST CASES - msg_server_delegate.go * Payout delegators * Don't pay out rewards twice * Delegate to validator with 0 $KYVE -* TODO(@max): Delegate to multiple validators +* Delegate to multiple validators */ @@ -276,6 +276,16 @@ var _ = Describe("msg_server_delegate.go", Ordered, func() { }) // ACT + s.RunTxDelegatorSuccess(&types.MsgDelegate{ + Creator: i.DUMMY[1], + Staker: i.ALICE, + Amount: 200 * i.KYVE, + }) + s.RunTxDelegatorSuccess(&types.MsgDelegate{ + Creator: i.DUMMY[1], + Staker: i.BOB, + Amount: 200 * i.KYVE, + }) s.RunTxDelegatorSuccess(&types.MsgDelegate{ Creator: i.DUMMY[1], Staker: i.CHARLIE, @@ -286,8 +296,14 @@ var _ = Describe("msg_server_delegate.go", Ordered, func() { s.PerformValidityChecks() poolModuleBalance := s.GetBalanceFromModule(types.ModuleName) - Expect(poolModuleBalance).To(Equal(200*i.KYVE + aliceSelfDelegation + bobSelfDelegation)) - Expect(s.GetBalanceFromAddress(i.DUMMY[1])).To(Equal(800 * i.KYVE)) + Expect(poolModuleBalance).To(Equal(600*i.KYVE + aliceSelfDelegation + bobSelfDelegation)) + Expect(s.GetBalanceFromAddress(i.DUMMY[1])).To(Equal(400 * i.KYVE)) + + aliceDelegation := s.App().DelegationKeeper.GetDelegationAmount(s.Ctx(), i.ALICE) + Expect(aliceDelegation).To(Equal(200*i.KYVE + aliceSelfDelegation)) + + bobDelegation := s.App().DelegationKeeper.GetDelegationAmount(s.Ctx(), i.BOB) + Expect(bobDelegation).To(Equal(200*i.KYVE + bobSelfDelegation)) charlieDelegation := s.App().DelegationKeeper.GetDelegationAmount(s.Ctx(), i.CHARLIE) Expect(charlieDelegation).To(Equal(200 * i.KYVE)) diff --git a/x/delegation/keeper/msg_server_undelegate_test.go b/x/delegation/keeper/msg_server_undelegate_test.go index 7c2225c1..f6565711 100644 --- a/x/delegation/keeper/msg_server_undelegate_test.go +++ b/x/delegation/keeper/msg_server_undelegate_test.go @@ -26,9 +26,6 @@ TEST CASES - msg_server_undelegate.go * JoinA, Slash, JoinB, PayoutReward * Slash twice * Start unbonding, slash twice, payout, await undelegation - -TODO(@max): joinA slash joinB slash -> remaining delegation - */ var _ = Describe("msg_server_undelegate.go", Ordered, func() { @@ -493,6 +490,11 @@ var _ = Describe("msg_server_undelegate.go", Ordered, func() { // ASSERT Expect(s.App().DelegationKeeper.GetOutstandingRewards(s.Ctx(), i.ALICE, i.DUMMY[0])).To(Equal(uint64(666_666_666))) Expect(s.App().DelegationKeeper.GetOutstandingRewards(s.Ctx(), i.ALICE, i.DUMMY[1])).To(Equal(uint64(2_666_666_666))) + + // must be the same as before + Expect(s.App().DelegationKeeper.GetDelegationAmount(s.Ctx(), i.ALICE)).To(Equal((50 + 25) * i.KYVE)) + Expect(s.App().DelegationKeeper.GetDelegationAmountOfDelegator(s.Ctx(), i.ALICE, i.DUMMY[0])).To(Equal(5 * i.KYVE)) + Expect(s.App().DelegationKeeper.GetDelegationAmountOfDelegator(s.Ctx(), i.ALICE, i.DUMMY[1])).To(Equal(20 * i.KYVE)) }) It("Slash twice", func() { diff --git a/x/delegation/keeper/msg_server_withdraw_rewards_test.go b/x/delegation/keeper/msg_server_withdraw_rewards_test.go index 331eaadb..357ad1b5 100644 --- a/x/delegation/keeper/msg_server_withdraw_rewards_test.go +++ b/x/delegation/keeper/msg_server_withdraw_rewards_test.go @@ -3,6 +3,7 @@ package keeper_test import ( pooltypes "github.com/KYVENetwork/chain/x/pool/types" stakerstypes "github.com/KYVENetwork/chain/x/stakers/types" + sdk "github.com/cosmos/cosmos-sdk/types" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" @@ -17,10 +18,8 @@ TEST CASES - msg_server_withdraw_rewards.go * Payout rewards which cause rounding issues and withdraw * Withdraw from a non-existing delegator * Test invalid payouts to delegators - -* TODO(@max): Test withdrawal of rewards which are zero -* TODO(@max): Test withdrawal of rewards with multiple slashes - +* Withdraw rewards which are zero +* Withdraw rewards with multiple slashes */ var _ = Describe("msg_server_withdraw_rewards.go", Ordered, func() { @@ -171,4 +170,61 @@ var _ = Describe("msg_server_withdraw_rewards.go", Ordered, func() { Expect(err1).To(HaveOccurred()) Expect(err2).To(HaveOccurred()) }) + + It("Withdraw rewards which are zero", func() { + // ARRANGE + s.RunTxDelegatorSuccess(&types.MsgDelegate{ + Creator: i.DUMMY[0], + Staker: i.ALICE, + Amount: 1, + }) + startBalance := s.GetBalanceFromAddress(i.DUMMY[0]) + + // ACT + Expect(s.App().DelegationKeeper.GetOutstandingRewards(s.Ctx(), i.ALICE, i.DUMMY[0])).To(Equal(uint64(0))) + + s.RunTxDelegatorSuccess(&types.MsgWithdrawRewards{ + Creator: i.DUMMY[0], + Staker: i.ALICE, + }) + + // ASSERT + Expect(s.GetBalanceFromAddress(i.DUMMY[0])).To(Equal(startBalance)) + Expect(s.App().DelegationKeeper.GetOutstandingRewards(s.Ctx(), i.ALICE, i.DUMMY[0])).To(Equal(uint64(0))) + }) + + It("Withdraw rewards with multiple slashes", func() { + // ARRANGE + s.RunTxDelegatorSuccess(&types.MsgDelegate{ + Creator: i.DUMMY[0], + Staker: i.ALICE, + Amount: 10 * i.KYVE, + }) + startBalance := s.GetBalanceFromAddress(i.DUMMY[0]) + + // ACT + params := s.App().DelegationKeeper.GetParams(s.Ctx()) + params.UploadSlash = sdk.MustNewDecFromStr("0.5") + s.App().DelegationKeeper.SetParams(s.Ctx(), params) + + // Slash 50% + s.App().DelegationKeeper.SlashDelegators(s.Ctx(), 0, i.ALICE, types.SLASH_TYPE_UPLOAD) + PayoutRewards(s, i.ALICE, 5*i.KYVE) + + // Slash 50% again + s.App().DelegationKeeper.SlashDelegators(s.Ctx(), 0, i.ALICE, types.SLASH_TYPE_UPLOAD) + PayoutRewards(s, i.ALICE, 5*i.KYVE) + + s.PerformValidityChecks() + + // ASSERT + Expect(s.App().DelegationKeeper.GetOutstandingRewards(s.Ctx(), i.ALICE, i.DUMMY[0])).To(Equal(10 * i.KYVE)) + + s.RunTxDelegatorSuccess(&types.MsgWithdrawRewards{ + Creator: i.DUMMY[0], + Staker: i.ALICE, + }) + Expect(s.App().DelegationKeeper.GetOutstandingRewards(s.Ctx(), i.ALICE, i.DUMMY[0])).To(Equal(uint64(0))) + Expect(s.GetBalanceFromAddress(i.DUMMY[0])).To(Equal(startBalance + 10*i.KYVE)) + }) }) diff --git a/x/team/types/types.go b/x/team/types/types.go index 2ff5a778..62ad3767 100644 --- a/x/team/types/types.go +++ b/x/team/types/types.go @@ -43,8 +43,8 @@ type VestingStatus struct { var ( TEAM_FOUNDATION_STRING = "kyve1u7ukf2nv6v5j5y2yqprm8yqruue2rlmrkx4xgq" TEAM_BCP_STRING = "kyve1ruxaec07ca3dh0amkzxjap7av3xjt5vjgnd424" - TEAM_ALLOCATION_STRING = "165000000000000" - TGE_STRING = "2023-03-14T14:03:14" + TEAM_ALLOCATION_STRING = "165000000000000000" + TGE_STRING = "2023-02-01T10:34:15" ) // Convert passed build variables (string) to the corresponding int values