Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: prepare 2.6 #184

Merged
merged 34 commits into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
bf5b8be
wip: test pob
emidev98 Oct 7, 2023
0c565a8
wip: feeshare module
emidev98 Oct 10, 2023
2af7955
wip: feeshare module
emidev98 Oct 11, 2023
41e8604
wip: feeshare module
emidev98 Oct 11, 2023
f74b838
fix: instantiate order
emidev98 Oct 11, 2023
762554b
test: feeshare
emidev98 Oct 12, 2023
2e08cd8
test: query and msg server feeshare
emidev98 Oct 12, 2023
0bd5f58
chore: prepare 2.6
emidev98 Oct 12, 2023
ec9ca88
fix: pob account to module account
emidev98 Oct 13, 2023
32630d5
fix: use the old account number
javiersuweijie Oct 13, 2023
f48f4b3
feat: add feeshare to swagger
emidev98 Oct 13, 2023
8286e01
chore: remove pob from migration
emidev98 Oct 13, 2023
9839cbd
Merge pull request #185 from terra-money/fix/pob/module/account
emidev98 Oct 13, 2023
da7bc20
fix: update pfm
javiersuweijie Oct 14, 2023
22d4172
Merge pull request #187 from terra-money/update/pfm-deps
tuky191 Oct 14, 2023
78e83c5
Merge branch 'release/v2.5' of https://github.com/terra-money/core in…
emidev98 Oct 16, 2023
f16d18f
wip: integration test pob
emidev98 Oct 16, 2023
deab81c
Merge branch 'feat/feeshare' of https://github.com/terra-money/core i…
emidev98 Oct 16, 2023
e471dcb
fix: builder genesis type
emidev98 Oct 16, 2023
3d940e9
feat: happy path pob
emidev98 Oct 16, 2023
d72a5ae
feat: new testing framework with pob module tests
emidev98 Oct 16, 2023
a5f031d
Merge branch 'prepare/2.6' of https://github.com/terra-money/core int…
emidev98 Oct 17, 2023
4a5c715
feat: feeshare, pob and auth
emidev98 Oct 17, 2023
4ee9189
feat: readme
emidev98 Oct 18, 2023
b6fc5ab
feat: vesting account testing
emidev98 Oct 18, 2023
3242156
feat: feeshare coverage
emidev98 Oct 18, 2023
5e5eae0
Merge pull request #189 from terra-money/feat/pob/test
emidev98 Oct 18, 2023
9c0eebd
tests: alliance module
emidev98 Oct 18, 2023
977cdeb
feat: gov v1 and legacy tests
emidev98 Oct 19, 2023
f7406ce
test: gov module increase coverage
emidev98 Oct 20, 2023
62957f0
Merge pull request #191 from terra-money/feat/alliance/tests
emidev98 Oct 23, 2023
6ae6822
fix: v2.6 migration
emidev98 Oct 23, 2023
ba80d87
fix: lint errorcheck
emidev98 Oct 23, 2023
3534616
Merge pull request #192 from terra-money/fix/v2.6/migration
emidev98 Oct 23, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
6 changes: 6 additions & 0 deletions app/ante/ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/x/auth/ante"
bankKeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"
ibcante "github.com/cosmos/ibc-go/v7/modules/core/ante"
ibckeeper "github.com/cosmos/ibc-go/v7/modules/core/keeper"
"github.com/skip-mev/pob/mempool"
pobante "github.com/skip-mev/pob/x/builder/ante"
pobkeeper "github.com/skip-mev/pob/x/builder/keeper"
feeshareante "github.com/terra-money/core/v2/x/feeshare/ante"
feesharekeeper "github.com/terra-money/core/v2/x/feeshare/keeper"

wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
wasmTypes "github.com/CosmWasm/wasmd/x/wasm/types"
Expand All @@ -22,6 +25,8 @@ type HandlerOptions struct {
ante.HandlerOptions

IBCkeeper *ibckeeper.Keeper
FeeShareKeeper feesharekeeper.Keeper
BankKeeper bankKeeper.Keeper
TxCounterStoreKey storetypes.StoreKey
WasmConfig wasmTypes.WasmConfig
PobBuilderKeeper pobkeeper.Keeper
Expand Down Expand Up @@ -67,6 +72,7 @@ func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) {
ante.NewValidateMemoDecorator(options.AccountKeeper),
ante.NewConsumeGasForTxSizeDecorator(options.AccountKeeper),
ante.NewDeductFeeDecorator(options.AccountKeeper, options.BankKeeper, options.FeegrantKeeper, options.TxFeeChecker),
feeshareante.NewFeeSharePayoutDecorator(options.BankKeeper, options.FeeShareKeeper),
// SetPubKeyDecorator must be called before all signature verification decorators
ante.NewSetPubKeyDecorator(options.AccountKeeper),
ante.NewValidateSigCountDecorator(options.AccountKeeper),
Expand Down
43 changes: 42 additions & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@ import (
alliancetypes "github.com/terra-money/alliance/x/alliance/types"
terracustombank "github.com/terra-money/core/v2/custom/bank"
custombankkeeper "github.com/terra-money/core/v2/custom/bank/keeper"
feeshare "github.com/terra-money/core/v2/x/feeshare"
feesharekeeper "github.com/terra-money/core/v2/x/feeshare/keeper"
feesharetypes "github.com/terra-money/core/v2/x/feeshare/types"

pobabci "github.com/skip-mev/pob/abci"
pobmempool "github.com/skip-mev/pob/mempool"
Expand All @@ -165,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 @@ -261,6 +265,7 @@ var (
wasm.AppModuleBasic{},
consensus.AppModuleBasic{},
alliance.AppModuleBasic{},
feeshare.AppModuleBasic{},
pob.AppModuleBasic{},
)

Expand Down Expand Up @@ -337,6 +342,7 @@ type TerraApp struct {
RouterKeeper routerkeeper.Keeper
TokenFactoryKeeper tokenfactorykeeper.Keeper
AllianceKeeper alliancekeeper.Keeper
FeeShareKeeper feesharekeeper.Keeper

// IBC hooks
IBCHooksKeeper *ibchookskeeper.Keeper
Expand Down Expand Up @@ -410,7 +416,7 @@ func NewTerraApp(
icahosttypes.StoreKey, icacontrollertypes.StoreKey, routertypes.StoreKey,
consensusparamtypes.StoreKey, tokenfactorytypes.StoreKey, wasmtypes.StoreKey,
ibcfeetypes.StoreKey, ibchookstypes.StoreKey, crisistypes.StoreKey,
alliancetypes.StoreKey, pobtype.StoreKey,
alliancetypes.StoreKey, feesharetypes.StoreKey, pobtype.StoreKey,
)
tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey)
memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey)
Expand Down Expand Up @@ -712,6 +718,16 @@ func NewTerraApp(
app.MsgServiceRouter(), govtypes.DefaultConfig(), authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)

app.FeeShareKeeper = feesharekeeper.NewKeeper(
appCodec,
keys[feesharetypes.StoreKey],
app.BankKeeper,
app.WasmKeeper,
app.AccountKeeper,
authtypes.FeeCollectorName,
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)

// Set legacy router for backwards compatibility with gov v1beta1
govKeeper.SetLegacyRouter(govRouter)
app.GovKeeper = *govKeeper.SetHooks(
Expand Down Expand Up @@ -769,6 +785,7 @@ func NewTerraApp(
ibchooks.NewAppModule(app.AccountKeeper),
tokenfactory.NewAppModule(app.TokenFactoryKeeper, app.AccountKeeper, app.BankKeeper, app.GetSubspace(tokenfactorytypes.ModuleName)),
alliance.NewAppModule(appCodec, app.AllianceKeeper, app.StakingKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry, app.GetSubspace(alliancetypes.ModuleName)),
feeshare.NewAppModule(app.FeeShareKeeper, app.AccountKeeper, app.GetSubspace(feesharetypes.ModuleName)),
pob.NewAppModule(appCodec, app.BuilderKeeper),
)

Expand Down Expand Up @@ -803,6 +820,7 @@ func NewTerraApp(
wasmtypes.ModuleName,
tokenfactorytypes.ModuleName,
alliancetypes.ModuleName,
feesharetypes.ModuleName,
consensusparamtypes.ModuleName,
pobtype.ModuleName,
)
Expand Down Expand Up @@ -834,6 +852,7 @@ func NewTerraApp(
wasmtypes.ModuleName,
tokenfactorytypes.ModuleName,
alliancetypes.ModuleName,
feesharetypes.ModuleName,
consensusparamtypes.ModuleName,
pobtype.ModuleName,
)
Expand Down Expand Up @@ -869,6 +888,7 @@ func NewTerraApp(
ibchookstypes.ModuleName,
wasmtypes.ModuleName,
alliancetypes.ModuleName,
feesharetypes.ModuleName,
consensusparamtypes.ModuleName,
pobtype.ModuleName,
)
Expand Down Expand Up @@ -897,6 +917,8 @@ func NewTerraApp(
SignModeHandler: encodingConfig.TxConfig.SignModeHandler(),
SigGasConsumer: cosmosante.DefaultSigVerificationGasConsumer,
},
BankKeeper: app.BankKeeper,
FeeShareKeeper: app.FeeShareKeeper,
IBCkeeper: app.IBCKeeper,
TxCounterStoreKey: keys[wasmtypes.StoreKey],
WasmConfig: wasmConfig.ToWasmConfig(),
Expand Down Expand Up @@ -970,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 @@ -1165,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 Expand Up @@ -1206,6 +1245,7 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
paramsKeeper.Subspace(tokenfactorytypes.ModuleName).WithKeyTable(tokenfactorytypes.ParamKeyTable())
paramsKeeper.Subspace(icacontrollertypes.SubModuleName)
paramsKeeper.Subspace(alliancetypes.ModuleName).WithKeyTable(alliancetypes.ParamKeyTable())
paramsKeeper.Subspace(feesharetypes.ModuleName).WithKeyTable(feesharetypes.ParamKeyTable())

paramsKeeper.Subspace(wasmtypes.ModuleName).WithKeyTable(wasmtypes.ParamKeyTable())

Expand Down Expand Up @@ -1310,6 +1350,7 @@ func (app *TerraApp) SimulationManager() *module.SimulationManager {
router.NewAppModule(&app.RouterKeeper),
wasm.NewAppModule(appCodec, &app.WasmKeeper, app.StakingKeeper, app.AccountKeeper, app.BankKeeper, app.MsgServiceRouter(), app.GetSubspace(wasmtypes.ModuleName)),
alliance.NewAppModule(appCodec, app.AllianceKeeper, app.StakingKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry, app.GetSubspace(alliancetypes.ModuleName)),
feeshare.NewAppModule(app.FeeShareKeeper, app.AccountKeeper, app.GetSubspace(feesharetypes.ModuleName)),
)

sm.RegisterStoreDecoders()
Expand Down
3 changes: 3 additions & 0 deletions app/app_test/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/stretchr/testify/require"
"github.com/terra-money/alliance/x/alliance"
"github.com/terra-money/core/v2/app/wasmconfig"
"github.com/terra-money/core/v2/x/feeshare"
"github.com/terra-money/core/v2/x/tokenfactory"

tmtypes "github.com/cometbft/cometbft/types"
Expand Down Expand Up @@ -150,6 +151,7 @@ func TestInitGenesisOnMigration(t *testing.T) {
"distribution": distribution.AppModule{}.ConsensusVersion(),
"evidence": evidence.AppModule{}.ConsensusVersion(),
"feegrant": feegrantmodule.AppModule{}.ConsensusVersion(),
"feeshare": feeshare.AppModule{}.ConsensusVersion(),
"feeibc": ibcfee.AppModule{}.ConsensusVersion(),
"genutil": genutil.AppModule{}.ConsensusVersion(),
"gov": gov.AppModule{}.ConsensusVersion(),
Expand Down Expand Up @@ -181,6 +183,7 @@ func TestInitGenesisOnMigration(t *testing.T) {
"distribution": 3,
"evidence": 1,
"feegrant": 2,
"feeshare": 2,
"feeibc": 1,
"genutil": 1,
"gov": 4,
Expand Down
23 changes: 17 additions & 6 deletions app/app_test/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ import (
"github.com/stretchr/testify/suite"
"github.com/terra-money/core/v2/app"
terra_app "github.com/terra-money/core/v2/app"
"github.com/terra-money/core/v2/app/config"
appparams "github.com/terra-money/core/v2/app/params"
terrraParams "github.com/terra-money/core/v2/app/params"
"github.com/terra-money/core/v2/app/wasmconfig"
feesharetypes "github.com/terra-money/core/v2/x/feeshare/types"
tokenfactorytypes "github.com/terra-money/core/v2/x/tokenfactory/types"
)

Expand All @@ -44,8 +45,10 @@ type AppTestSuite struct {
// Setup sets up basic environment for suite (App, Ctx, and test accounts)
func (s *AppTestSuite) Setup() {
appparams.RegisterAddressesConfig()
baseTestAccts := CreateRandomAccounts(3)
encCfg := terra_app.MakeEncodingConfig()
genesisState := app.NewDefaultGenesisState(encCfg.Marshaler)
genesisState.ConfigureBondDenom(encCfg.Marshaler, config.BondDenom)
genesisState.ConfigureICA(encCfg.Marshaler)

db := dbm.NewMemDB()
s.App = terra_app.NewTerraApp(
Expand All @@ -61,21 +64,26 @@ func (s *AppTestSuite) Setup() {
wasmconfig.DefaultConfig(),
)

s.TestAccs = []sdk.AccAddress{}
s.TestAccs = append(s.TestAccs, baseTestAccts...)
s.Ctx = s.App.NewContext(true, tmproto.Header{Height: 1, Time: time.Now()})
s.QueryHelper = &baseapp.QueryServiceTestHelper{
GRPCQueryRouter: s.App.GRPCQueryRouter(),
Ctx: s.Ctx,
}
err := s.App.BankKeeper.SetParams(s.Ctx, banktypes.NewParams(true))
s.Require().NoError(err)

err = s.App.WasmKeeper.SetParams(s.Ctx, wasmtypes.DefaultParams())
s.Require().NoError(err)

err = s.App.FeeShareKeeper.SetParams(s.Ctx, feesharetypes.DefaultParams())
s.Require().NoError(err)

err = s.App.TokenFactoryKeeper.SetParams(s.Ctx, tokenfactorytypes.DefaultParams())
s.Require().NoError(err)

s.App.DistrKeeper.SetFeePool(s.Ctx, distrtypes.InitialFeePool())

s.TestAccs = s.CreateRandomAccounts(3)
}

func (s *AppTestSuite) AssertEventEmitted(ctx sdk.Context, eventTypeExpected string, numEventsExpected int) {
Expand All @@ -91,11 +99,14 @@ func (s *AppTestSuite) AssertEventEmitted(ctx sdk.Context, eventTypeExpected str
}

// CreateRandomAccounts is a function return a list of randomly generated AccAddresses
func CreateRandomAccounts(numAccts int) []sdk.AccAddress {
func (s *AppTestSuite) CreateRandomAccounts(numAccts int) []sdk.AccAddress {
testAddrs := make([]sdk.AccAddress, numAccts)
for i := 0; i < numAccts; i++ {
pk := ed25519.GenPrivKey().PubKey()
testAddrs[i] = sdk.AccAddress(pk.Address())

err := s.FundAcc(testAddrs[i], sdk.NewCoins(sdk.NewInt64Coin("uluna", 100000000)))
s.Require().NoError(err)
}

return testAddrs
Expand All @@ -116,7 +127,7 @@ func SetupGenesisValSet(
genAccs []authtypes.GenesisAccount,
opts []wasm.Option,
app *terra_app.TerraApp,
encCfg terrraParams.EncodingConfig,
encCfg appparams.EncodingConfig,
balances ...banktypes.Balance,
) terra_app.GenesisState {
genesisState := terra_app.NewDefaultGenesisState(encCfg.Marshaler)
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
Loading
Loading