Skip to content

Commit

Permalink
Merge pull request #184 from terra-money/prepare/2.6
Browse files Browse the repository at this point in the history
chore: prepare 2.6
  • Loading branch information
tuky191 authored Oct 23, 2023
2 parents e35e22d + 3534616 commit 327f85d
Show file tree
Hide file tree
Showing 29 changed files with 11,500 additions and 214 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,5 @@ dependency-graph.png

# Tests
scripts/tests/ibc-hooks/counter/target
scripts/tests/vesting-accounts/.vesting-periods.json
scripts/tests/vesting-accounts/.vesting-periods.json
node_modules
12 changes: 1 addition & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,6 @@ integration-test-all: init-test-framework \
test-relayer \
test-ica \
test-ibc-hooks \
test-vesting-accounts \
test-alliance \
test-tokenfactory

init-test-framework: clean-testing-data install
Expand All @@ -225,14 +223,6 @@ test-ibc-hooks:
@echo "Testing ibc hooks..."
./scripts/tests/ibc-hooks/increment.sh

test-alliance:
@echo "Testing alliance module..."
./scripts/tests/alliance/delegate.sh

test-vesting-accounts:
@echo "Testing vesting accounts..."
./scripts/tests/vesting-accounts/validate-vesting.sh

test-tokenfactory:
@echo "Testing tokenfactory..."
./scripts/tests/tokenfactory/tokenfactory.sh
Expand All @@ -251,7 +241,7 @@ clean-testing-data:
-@rm -rf ./_build


.PHONY: integration-test-all init-test-framework test-relayer test-ica test-ibc-hooks test-vesting-accounts test-tokenfactory clean-testing-data
.PHONY: integration-test-all init-test-framework test-relayer test-ica test-ibc-hooks test-tokenfactory clean-testing-data

###############################################################################
### Protobuf ###
Expand Down
18 changes: 18 additions & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ import (
v2_3_0 "github.com/terra-money/core/v2/app/upgrades/v2.3.0"
v2_4 "github.com/terra-money/core/v2/app/upgrades/v2.4"
v2_5 "github.com/terra-money/core/v2/app/upgrades/v2.5"
v2_6 "github.com/terra-money/core/v2/app/upgrades/v2.6"

// unnamed import of statik for swagger UI support
_ "github.com/terra-money/core/v2/client/docs/statik"
Expand Down Expand Up @@ -991,6 +992,13 @@ func NewTerraApp(
},
}
app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &storeUpgrades))
} else if upgradeInfo.Name == terraappconfig.Upgrade2_6 && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) {
storeUpgrades := storetypes.StoreUpgrades{
Added: []string{
feesharetypes.StoreKey,
},
}
app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &storeUpgrades))
}

if loadLatest {
Expand Down Expand Up @@ -1186,6 +1194,16 @@ func (app *TerraApp) RegisterUpgradeHandlers(cfg module.Configurator) {
app.AccountKeeper,
),
)
app.UpgradeKeeper.SetUpgradeHandler(
terraappconfig.Upgrade2_6,
v2_6.CreateUpgradeHandler(app.mm,
app.configurator,
app.appCodec,
app.IBCKeeper.ClientKeeper,
app.AccountKeeper,
app.FeeShareKeeper,
),
)
}

// RegisterSwaggerAPI registers swagger route with API Server
Expand Down
1 change: 1 addition & 0 deletions app/config/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,5 @@ const (
Upgrade2_4_rc = "2.4.0-rc4" // This is pisco only since an incorrect plan name was used for the upgrade
Upgrade2_4 = "v2.4"
Upgrade2_5 = "v2.5"
Upgrade2_6 = "v2.6"
)
7 changes: 7 additions & 0 deletions app/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
icagenesistypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/genesis/types"
icahosttypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/host/types"
icatypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/types"
buildertypes "github.com/skip-mev/pob/x/builder/types"
"github.com/terra-money/core/v2/app/config"
tokenfactorytypes "github.com/terra-money/core/v2/x/tokenfactory/types"
)
Expand Down Expand Up @@ -60,6 +61,12 @@ func (genState GenesisState) ConfigureBondDenom(cdc codec.JSONCodec, bondDenom s
tokenFactoryGenState.Params.DenomCreationFee = sdk.NewCoins(sdk.NewCoin(bondDenom, sdk.NewInt(10000000)))
genState[tokenfactorytypes.ModuleName] = cdc.MustMarshalJSON(&tokenFactoryGenState)

var builderGenState buildertypes.GenesisState
cdc.MustUnmarshalJSON(genState[buildertypes.ModuleName], &builderGenState)
builderGenState.Params.ReserveFee = sdk.NewCoin(bondDenom, sdk.NewInt(1))
builderGenState.Params.MinBidIncrement = sdk.NewCoin(bondDenom, sdk.NewInt(1))
genState[buildertypes.ModuleName] = cdc.MustMarshalJSON(&builderGenState)

return genState
}

Expand Down
4 changes: 2 additions & 2 deletions app/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ func TestGenesis(t *testing.T) {
"max_bundle_size": 2,
"escrow_account_address": "32sHF2qbF8xMmvwle9QEcy59Cbc=",
"reserve_fee": {
"denom": "stake",
"denom": "uluna",
"amount": "1"
},
"min_bid_increment": {
"denom": "stake",
"denom": "uluna",
"amount": "1"
},
"front_running_protection": true,
Expand Down
102 changes: 102 additions & 0 deletions app/upgrades/v2.6/upgrade.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
package v2_6

import (
"time"

sdkerrors "cosmossdk.io/errors"
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
clientkeeper "github.com/cosmos/ibc-go/v7/modules/core/02-client/keeper"
ibcclienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types"
ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported"
ibctm "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint"
pobtypes "github.com/skip-mev/pob/x/builder/types"
feesharekeeper "github.com/terra-money/core/v2/x/feeshare/keeper"
feesharetypes "github.com/terra-money/core/v2/x/feeshare/types"
)

func CreateUpgradeHandler(
mm *module.Manager,
cfg module.Configurator,
cdc codec.Codec,
clientKeeper clientkeeper.Keeper,
authKeeper authkeeper.AccountKeeper,
feesharekeeper feesharekeeper.Keeper,
) upgradetypes.UpgradeHandler {
return func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
// feeshare module is a new module added in v2.6,
// we need to set the default params
err := feesharekeeper.SetParams(ctx, feesharetypes.DefaultParams())
if err != nil {
return nil, err
}
// overwrite pob account to a module account for pisco-1
overwritePobModuleAccount(ctx, authKeeper)

// Increase the unbonding period for atlantic-2
err = increaseUnbondingPeriod(ctx, cdc, clientKeeper)
if err != nil {
return nil, err
}
return mm.RunMigrations(ctx, cfg, fromVM)
}
}

// Overwrite the module account for pisco-1
func overwritePobModuleAccount(ctx sdk.Context, authKeeper authkeeper.AccountKeeper) {
if ctx.ChainID() == "pisco-1" {
macc := authtypes.NewEmptyModuleAccount(pobtypes.ModuleName)
pobaccount := authKeeper.GetAccount(ctx, macc.GetAddress())
// if pob account exists, overwrite it
// if not, create a new one
if pobaccount != nil {
macc.AccountNumber = pobaccount.GetAccountNumber()
maccI := (authKeeper.NewAccount(ctx, macc)).(authtypes.ModuleAccountI)
authKeeper.SetModuleAccount(ctx, maccI)
} else {
maccI := (authKeeper.NewAccount(ctx, macc)).(authtypes.ModuleAccountI)
authKeeper.SetModuleAccount(ctx, maccI)
}
}
}

// Iterate all IBC clients and increase unbonding period for all atlantic-2 clients
func increaseUnbondingPeriod(ctx sdk.Context, cdc codec.BinaryCodec, clientKeeper clientkeeper.Keeper) error {
var clientIDs []string
clientKeeper.IterateClientStates(ctx, []byte(ibcexported.Tendermint), func(clientID string, _ ibcexported.ClientState) bool {
clientIDs = append(clientIDs, clientID)
return false
})

var totalUpdated int

for _, clientID := range clientIDs {
clientState, ok := clientKeeper.GetClientState(ctx, clientID)
if !ok {
return sdkerrors.Wrapf(ibcclienttypes.ErrClientNotFound, "clientID %s", clientID)
}

tmClientState, ok := clientState.(*ibctm.ClientState)
if !ok {
return sdkerrors.Wrap(ibcclienttypes.ErrInvalidClient, "client state is not tendermint even though client id contains 07-tendermint")
}

// ATLANTIC 2 blockchain changed the unbonding period on their side,
// we take advantage of having to upgrade the chain to also increase
// the unbonding priod on our side.
if tmClientState.GetChainID() == "atlantic-2" {
tmClientState.UnbondingPeriod = time.Hour * 24 * 21

clientKeeper.SetClientState(ctx, clientID, tmClientState)
}
}

clientLogger := clientKeeper.Logger(ctx)
clientLogger.Info("total ibc clients updated: ", totalUpdated)

return nil
}
4 changes: 2 additions & 2 deletions client/docs/config.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"swagger": "2.0",
"info": {
"description": "Source code for <a target='_blank' href='https://github.com/terra-money/core'>Terra Core v2.5</a><br/>UI to interact with the blockchain <a target='_blank' href='https://station.terra.money/'>Station</a><br/>Create a DAO on Terra using <a target='_blank' href='https://enterprise.money/'>Enterprise</a><br/>Run on-chain automted jobs <a target='_blank' href='https://warp.money/'>Wrap</a><br/>Explore the network using <a target='_blank' href='https://terrasco.pe/'>TerraScope</a><br/>Anything you need to know about shared security on <a target='_blank' href='https://alliance.terra.money/'>Alliance Docs</a><br/>More info about the protocol on <a target='_blank' href='https://docs.terra.money/'>Terra Docs</a>",
"version": "2.5"
"description": "Source code for <a target='_blank' href='https://github.com/terra-money/core'>Terra Core v2.6</a><br/>UI to interact with the blockchain <a target='_blank' href='https://station.terra.money/'>Station</a><br/>Create a DAO on Terra using <a target='_blank' href='https://enterprise.money/'>Enterprise</a><br/>Run on-chain automted jobs <a target='_blank' href='https://warp.money/'>Wrap</a><br/>Explore the network using <a target='_blank' href='https://terrasco.pe/'>TerraScope</a><br/>Anything you need to know about shared security on <a target='_blank' href='https://alliance.terra.money/'>Alliance Docs</a><br/>More info about the protocol on <a target='_blank' href='https://docs.terra.money/'>Terra Docs</a>",
"version": "2.6"
},
"apis": [
{
Expand Down
2 changes: 1 addition & 1 deletion client/docs/statik/statik.go

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions client/docs/swagger-ui/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ swagger: '2.0'
info:
description: >-
Source code for <a target='_blank'
href='https://github.com/terra-money/core'>Terra Core v2.5</a><br/>UI to
href='https://github.com/terra-money/core'>Terra Core v2.6</a><br/>UI to
interact with the blockchain <a target='_blank'
href='https://station.terra.money/'>Station</a><br/>Create a DAO on Terra
using <a target='_blank'
Expand All @@ -14,7 +14,7 @@ info:
href='https://alliance.terra.money/'>Alliance Docs</a><br/>More info about
the protocol on <a target='_blank' href='https://docs.terra.money/'>Terra
Docs</a>
version: '2.5'
version: '2.6'
paths:
/terra/alliances:
get:
Expand Down
32 changes: 32 additions & 0 deletions integration-tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Terra Core Integration Tests

This project is meant to increase the success ratio for new core releases, improve reliability and features for [@terra-money/feather.js](https://github.com/terra-money/feather.js). This tests are written using TypeScript with [jest](https://jestjs.io/) and executed in parallel to improve time execution.


### Development

Keep in mind that tests are executed in paralel when using the same account with two different tests it can misslead test results with errors like "account missmatch sequence" when submitting two transactions with the same nonce, missmatching balances, etc...

Another good practice with this framework is to isolate and assert values within a test considering that the data is not wiped out each time a new test is executed.


Folders structure:
```sh
├── jest.config.js
├── tsconfig.json
├── package.json
├── package-lock.json
├── README.md
└── src
├── contracts # WASM Contracts to be used in the tests.
│ └── reflect.wasm
├── helpers # Functions to improve code readability and avoid duplications.
│ ├── const.ts
│ ├── lcd.connection.ts
│ └── mnemonics.ts
└── modules # Tests splited by module that intent to test.
├── auth.test.ts
├── feeshare.test.ts
└── pob.test.ts

```
8 changes: 8 additions & 0 deletions integration-tests/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
testMatch: ['**/*.test.ts'],
verbose: true,
testTimeout: 30000,
};
Loading

0 comments on commit 327f85d

Please sign in to comment.