From 1b715528db47e2fccb0599d08231a0e2fe63c812 Mon Sep 17 00:00:00 2001 From: MaxMustermann2 <82761650+MaxMustermann2@users.noreply.github.com> Date: Tue, 26 Mar 2024 08:39:54 +0000 Subject: [PATCH 01/15] fix(app.go): remove incentives module The incentives module is a feature used to provide incentives to specified projects (via governance) on a chain. Since our chain does not intend to host any DeFi projects, this module is not needed. --- app/app.go | 326 ++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 238 insertions(+), 88 deletions(-) diff --git a/app/app.go b/app/app.go index 1fa133918..f832f556c 100644 --- a/app/app.go +++ b/app/app.go @@ -10,41 +10,47 @@ import ( "path/filepath" "sort" - "github.com/ExocoreNetwork/exocore/x/operator" - operatorKeeper "github.com/ExocoreNetwork/exocore/x/operator/keeper" - - exoslash "github.com/ExocoreNetwork/exocore/x/slash" - - slashKeeper "github.com/ExocoreNetwork/exocore/x/slash/keeper" - exoslashTypes "github.com/ExocoreNetwork/exocore/x/slash/types" - autocliv1 "cosmossdk.io/api/cosmos/autocli/v1" reflectionv1 "cosmossdk.io/api/cosmos/reflection/v1" authzkeeper "github.com/cosmos/cosmos-sdk/x/authz/keeper" ibctesting "github.com/cosmos/ibc-go/v7/testing" + // for EIP-1559 fee handling ethante "github.com/evmos/evmos/v14/app/ante/evm" + // for encoding and decoding of EIP-712 messages "github.com/evmos/evmos/v14/ethereum/eip712" "github.com/ExocoreNetwork/exocore/x/assets" assetsKeeper "github.com/ExocoreNetwork/exocore/x/assets/keeper" assetsTypes "github.com/ExocoreNetwork/exocore/x/assets/types" + "github.com/ExocoreNetwork/exocore/x/delegation" delegationKeeper "github.com/ExocoreNetwork/exocore/x/delegation/keeper" delegationTypes "github.com/ExocoreNetwork/exocore/x/delegation/types" + "github.com/ExocoreNetwork/exocore/x/deposit" depositKeeper "github.com/ExocoreNetwork/exocore/x/deposit/keeper" depositTypes "github.com/ExocoreNetwork/exocore/x/deposit/types" + + "github.com/ExocoreNetwork/exocore/x/operator" + operatorKeeper "github.com/ExocoreNetwork/exocore/x/operator/keeper" operatorTypes "github.com/ExocoreNetwork/exocore/x/operator/types" + "github.com/ExocoreNetwork/exocore/x/reward" rewardKeeper "github.com/ExocoreNetwork/exocore/x/reward/keeper" rewardTypes "github.com/ExocoreNetwork/exocore/x/reward/types" + + exoslash "github.com/ExocoreNetwork/exocore/x/slash" + slashKeeper "github.com/ExocoreNetwork/exocore/x/slash/keeper" + exoslashTypes "github.com/ExocoreNetwork/exocore/x/slash/types" + "github.com/ExocoreNetwork/exocore/x/withdraw" withdrawKeeper "github.com/ExocoreNetwork/exocore/x/withdraw/keeper" withdrawTypes "github.com/ExocoreNetwork/exocore/x/withdraw/types" + + // increases or decreases block gas limit based on usage "github.com/evmos/evmos/v14/x/feemarket" feemarkettypes "github.com/evmos/evmos/v14/x/feemarket/types" - "github.com/evmos/evmos/v14/x/incentives" "github.com/evmos/evmos/v14/x/inflation" "github.com/evmos/evmos/v14/x/recovery" "github.com/evmos/evmos/v14/x/revenue/v1" @@ -92,7 +98,6 @@ import ( srvflags "github.com/evmos/evmos/v14/server/flags" transfer "github.com/evmos/evmos/v14/x/ibc/transfer" transferkeeper "github.com/evmos/evmos/v14/x/ibc/transfer/keeper" - incentivestypes "github.com/evmos/evmos/v14/x/incentives/types" // NOTE: override ICS20 keeper to support IBC transfers of ERC20 tokens "cosmossdk.io/simapp" @@ -167,7 +172,6 @@ import ( icahostkeeper "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/host/keeper" - incentiveskeeper "github.com/evmos/evmos/v14/x/incentives/keeper" inflationkeeper "github.com/evmos/evmos/v14/x/inflation/keeper" inflationtypes "github.com/evmos/evmos/v14/x/inflation/types" recoverykeeper "github.com/evmos/evmos/v14/x/recovery/keeper" @@ -253,7 +257,6 @@ var ( // evmos modules inflation.AppModuleBasic{}, erc20.AppModuleBasic{}, - incentives.AppModuleBasic{}, epochs.AppModuleBasic{}, claims.AppModuleBasic{}, recovery.AppModuleBasic{}, @@ -278,17 +281,17 @@ var ( govtypes.ModuleName: {authtypes.Burner}, ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner}, icatypes.ModuleName: nil, - evmtypes.ModuleName: {authtypes.Minter, authtypes.Burner}, // used for secure addition and subtraction of balance using module account - inflationtypes.ModuleName: {authtypes.Minter}, - erc20types.ModuleName: {authtypes.Minter, authtypes.Burner}, - claimstypes.ModuleName: nil, - incentivestypes.ModuleName: {authtypes.Minter, authtypes.Burner}, + evmtypes.ModuleName: { + authtypes.Minter, + authtypes.Burner, + }, // used for secure addition and subtraction of balance using module account + inflationtypes.ModuleName: {authtypes.Minter}, + erc20types.ModuleName: {authtypes.Minter, authtypes.Burner}, + claimstypes.ModuleName: nil, } // module accounts that are allowed to receive tokens - allowedReceivingModAcc = map[string]bool{ - incentivestypes.ModuleName: true, - } + allowedReceivingModAcc = map[string]bool{} ) var ( @@ -342,14 +345,13 @@ type ExocoreApp struct { FeeMarketKeeper feemarketkeeper.Keeper // Evmos keepers - InflationKeeper inflationkeeper.Keeper - ClaimsKeeper *claimskeeper.Keeper - Erc20Keeper erc20keeper.Keeper - IncentivesKeeper incentiveskeeper.Keeper - EpochsKeeper epochskeeper.Keeper - VestingKeeper vestingkeeper.Keeper - RecoveryKeeper *recoverykeeper.Keeper - RevenueKeeper revenuekeeper.Keeper + InflationKeeper inflationkeeper.Keeper + ClaimsKeeper *claimskeeper.Keeper + Erc20Keeper erc20keeper.Keeper + EpochsKeeper epochskeeper.Keeper + VestingKeeper vestingkeeper.Keeper + RecoveryKeeper *recoverykeeper.Keeper + RevenueKeeper revenuekeeper.Keeper // exocore assets module keepers AssetsKeeper assetsKeeper.Keeper @@ -404,7 +406,8 @@ func NewExocoreApp( app.SetPrepareProposal(handler.PrepareProposalHandler()) app.SetProcessProposal(handler.ProcessProposalHandler()) }) - // NOTE we use custom transaction decoder that supports the sdk.Tx interface instead of sdk.StdTx + // NOTE we use custom transaction decoder that supports the sdk.Tx interface instead of + // sdk.StdTx bApp := baseapp.NewBaseApp( Name, logger, @@ -430,7 +433,7 @@ func NewExocoreApp( // ethermint keys evmtypes.StoreKey, feemarkettypes.StoreKey, // evmos keys - inflationtypes.StoreKey, erc20types.StoreKey, incentivestypes.StoreKey, + inflationtypes.StoreKey, erc20types.StoreKey, epochstypes.StoreKey, claimstypes.StoreKey, vestingtypes.StoreKey, revenuetypes.StoreKey, recoverytypes.StoreKey, // exoCore module keys @@ -444,7 +447,11 @@ func NewExocoreApp( ) // Add the EVM transient store key - tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey, evmtypes.TransientKey, feemarkettypes.TransientKey) + tkeys := sdk.NewTransientStoreKeys( + paramstypes.TStoreKey, + evmtypes.TransientKey, + feemarkettypes.TransientKey, + ) memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey) // load state streaming if enabled @@ -465,23 +472,37 @@ func NewExocoreApp( } // init params keeper and subspaces - app.ParamsKeeper = initParamsKeeper(appCodec, cdc, keys[paramstypes.StoreKey], tkeys[paramstypes.TStoreKey]) + app.ParamsKeeper = initParamsKeeper( + appCodec, + cdc, + keys[paramstypes.StoreKey], + tkeys[paramstypes.TStoreKey], + ) // get authority address authAddr := authtypes.NewModuleAddress(govtypes.ModuleName).String() // set the BaseApp's parameter store - app.ConsensusParamsKeeper = consensusparamkeeper.NewKeeper(appCodec, keys[consensusparamtypes.StoreKey], authAddr) + app.ConsensusParamsKeeper = consensusparamkeeper.NewKeeper( + appCodec, + keys[consensusparamtypes.StoreKey], + authAddr, + ) bApp.SetParamStore(&app.ConsensusParamsKeeper) // add capability keeper and ScopeToModule for ibc module - app.CapabilityKeeper = capabilitykeeper.NewKeeper(appCodec, keys[capabilitytypes.StoreKey], memKeys[capabilitytypes.MemStoreKey]) + app.CapabilityKeeper = capabilitykeeper.NewKeeper( + appCodec, + keys[capabilitytypes.StoreKey], + memKeys[capabilitytypes.MemStoreKey], + ) scopedIBCKeeper := app.CapabilityKeeper.ScopeToModule(ibcexported.ModuleName) scopedTransferKeeper := app.CapabilityKeeper.ScopeToModule(ibctransfertypes.ModuleName) scopedICAHostKeeper := app.CapabilityKeeper.ScopeToModule(icahosttypes.SubModuleName) - // Applications that wish to enforce statically created ScopedKeepers should call `Seal` after creating + // Applications that wish to enforce statically created ScopedKeepers should call `Seal` + // after creating // their scoped modules in `NewApp` with `ScopeToModule` app.CapabilityKeeper.Seal() // add account keepers @@ -517,7 +538,12 @@ func NewExocoreApp( app.FeeGrantKeeper = feegrantkeeper.NewKeeper(appCodec, keys[feegrant.StoreKey], accountK) app.UpgradeKeeper = *upgradekeeper.NewKeeper(skipUpgradeHeights, keys[upgradetypes.StoreKey], appCodec, homePath, app.BaseApp, authAddr) - app.AuthzKeeper = authzkeeper.NewKeeper(keys[authzkeeper.StoreKey], appCodec, app.MsgServiceRouter(), app.AccountKeeper) + app.AuthzKeeper = authzkeeper.NewKeeper( + keys[authzkeeper.StoreKey], + appCodec, + app.MsgServiceRouter(), + app.AccountKeeper, + ) tracer := cast.ToString(appOpts.Get(srvflags.EVMTracer)) @@ -530,16 +556,28 @@ func NewExocoreApp( ) evmKeeper := evmkeeper.NewKeeper( - appCodec, keys[evmtypes.StoreKey], tkeys[evmtypes.TransientKey], authtypes.NewModuleAddress(govtypes.ModuleName), - app.AccountKeeper, app.BankKeeper, stakingKeeper, app.FeeMarketKeeper, - tracer, app.GetSubspace(evmtypes.ModuleName), + appCodec, + keys[evmtypes.StoreKey], + tkeys[evmtypes.TransientKey], + authtypes.NewModuleAddress(govtypes.ModuleName), + app.AccountKeeper, + app.BankKeeper, + stakingKeeper, + app.FeeMarketKeeper, + tracer, + app.GetSubspace(evmtypes.ModuleName), ) app.EvmKeeper = evmKeeper // Create IBC Keeper app.IBCKeeper = ibckeeper.NewKeeper( - appCodec, keys[ibcexported.StoreKey], app.GetSubspace(ibcexported.ModuleName), stakingKeeper, app.UpgradeKeeper, scopedIBCKeeper, + appCodec, + keys[ibcexported.StoreKey], + app.GetSubspace(ibcexported.ModuleName), + stakingKeeper, + app.UpgradeKeeper, + scopedIBCKeeper, ) // register the proposal types @@ -549,7 +587,6 @@ func NewExocoreApp( AddRoute(upgradetypes.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(&app.UpgradeKeeper)). AddRoute(ibcclienttypes.RouterKey, ibcclient.NewClientProposalHandler(app.IBCKeeper.ClientKeeper)). AddRoute(erc20types.RouterKey, erc20.NewErc20ProposalHandler(&app.Erc20Keeper)). - AddRoute(incentivestypes.RouterKey, incentives.NewIncentivesProposalHandler(&app.IncentivesKeeper)). AddRoute(vestingtypes.RouterKey, vesting.NewVestingProposalHandler(&app.VestingKeeper)) govConfig := govtypes.DefaultConfig() @@ -567,19 +604,31 @@ func NewExocoreApp( // Evmos Keeper app.InflationKeeper = inflationkeeper.NewKeeper( - keys[inflationtypes.StoreKey], appCodec, authtypes.NewModuleAddress(govtypes.ModuleName), - app.AccountKeeper, app.BankKeeper, app.DistrKeeper, stakingKeeper, + keys[inflationtypes.StoreKey], + appCodec, + authtypes.NewModuleAddress(govtypes.ModuleName), + app.AccountKeeper, + app.BankKeeper, + app.DistrKeeper, + stakingKeeper, authtypes.FeeCollectorName, ) app.ClaimsKeeper = claimskeeper.NewKeeper( - appCodec, keys[claimstypes.StoreKey], authtypes.NewModuleAddress(govtypes.ModuleName), - app.AccountKeeper, app.BankKeeper, stakingKeeper, app.DistrKeeper, app.IBCKeeper.ChannelKeeper, + appCodec, + keys[claimstypes.StoreKey], + authtypes.NewModuleAddress(govtypes.ModuleName), + app.AccountKeeper, + app.BankKeeper, + stakingKeeper, + app.DistrKeeper, + app.IBCKeeper.ChannelKeeper, ) // register the staking hooks // NOTE: stakingKeeper above is passed by reference, so that it will contain these hooks - // NOTE: Distr, Slashing and Claim must be created before calling the Hooks method to avoid returning a Keeper without its table generated + // NOTE: Distr, Slashing and Claim must be created before calling the Hooks method to avoid + // returning a Keeper without its table generated stakingKeeper.SetHooks( stakingtypes.NewMultiStakingHooks( app.DistrKeeper.Hooks(), @@ -600,11 +649,6 @@ func NewExocoreApp( app.AccountKeeper, app.BankKeeper, app.EvmKeeper, app.StakingKeeper, app.ClaimsKeeper, ) - app.IncentivesKeeper = incentiveskeeper.NewKeeper( - keys[incentivestypes.StoreKey], appCodec, authtypes.NewModuleAddress(govtypes.ModuleName), - app.AccountKeeper, app.BankKeeper, app.InflationKeeper, app.StakingKeeper, app.EvmKeeper, - ) - app.RevenueKeeper = revenuekeeper.NewKeeper( keys[revenuetypes.StoreKey], appCodec, authtypes.NewModuleAddress(govtypes.ModuleName), app.BankKeeper, app.DistrKeeper, app.AccountKeeper, app.EvmKeeper, @@ -621,15 +665,37 @@ func NewExocoreApp( // set exoCore staking keepers app.AssetsKeeper = assetsKeeper.NewKeeper(keys[assetsTypes.StoreKey], appCodec) - app.DepositKeeper = depositKeeper.NewKeeper(keys[depositTypes.StoreKey], appCodec, app.AssetsKeeper) - app.OperatorKeeper = operatorKeeper.NewKeeper(keys[operatorTypes.StoreKey], appCodec, app.AssetsKeeper, operatorTypes.MockOracle{}, operatorTypes.MockAvs{}, delegationTypes.VirtualSlashKeeper{}) - // todo: need to replace the virtual keepers with actual keepers after they have been implemented - app.DelegationKeeper = delegationKeeper.NewKeeper(keys[depositTypes.StoreKey], appCodec, app.AssetsKeeper, delegationTypes.VirtualSlashKeeper{}, &app.OperatorKeeper) + app.DepositKeeper = depositKeeper.NewKeeper( + keys[depositTypes.StoreKey], + appCodec, + app.AssetsKeeper, + ) + app.OperatorKeeper = operatorKeeper.NewKeeper( + keys[operatorTypes.StoreKey], + appCodec, + app.AssetsKeeper, + operatorTypes.MockOracle{}, + operatorTypes.MockAvs{}, + delegationTypes.VirtualSlashKeeper{}, + ) + // todo: need to replace the virtual keepers with actual keepers after they have been + // implemented + app.DelegationKeeper = delegationKeeper.NewKeeper( + keys[depositTypes.StoreKey], + appCodec, + app.AssetsKeeper, + delegationTypes.VirtualSlashKeeper{}, + &app.OperatorKeeper, + ) app.OperatorKeeper.RegisterExpectDelegationInterface(&app.DelegationKeeper) app.WithdrawKeeper = *withdrawKeeper.NewKeeper(appCodec, keys[withdrawTypes.StoreKey], app.AssetsKeeper, app.DepositKeeper) app.RewardKeeper = *rewardKeeper.NewKeeper(appCodec, keys[rewardTypes.StoreKey], app.AssetsKeeper) - app.ExoSlashKeeper = slashKeeper.NewKeeper(appCodec, keys[exoslashTypes.StoreKey], app.AssetsKeeper) + app.ExoSlashKeeper = slashKeeper.NewKeeper( + appCodec, + keys[exoslashTypes.StoreKey], + app.AssetsKeeper, + ) // We call this after setting the hooks to ensure that the hooks are set on the keeper evmKeeper.WithPrecompiles( evmkeeper.AvailablePrecompiles( @@ -651,7 +717,6 @@ func NewExocoreApp( app.EpochsKeeper = *epochsKeeper.SetHooks( epochskeeper.NewMultiEpochHooks( // insert epoch hooks receivers here - app.IncentivesKeeper.Hooks(), app.InflationKeeper.Hooks(), ), ) @@ -665,7 +730,6 @@ func NewExocoreApp( app.EvmKeeper = app.EvmKeeper.SetHooks( evmkeeper.NewMultiEvmHooks( app.Erc20Keeper.Hooks(), - app.IncentivesKeeper.Hooks(), app.RevenueKeeper.Hooks(), app.ClaimsKeeper.Hooks(), ), @@ -759,19 +823,66 @@ func NewExocoreApp( accountK, app.StakingKeeper, app.BaseApp.DeliverTx, encodingConfig.TxConfig, ), - auth.NewAppModule(appCodec, accountK, authsims.RandomGenesisAccounts, app.GetSubspace(authtypes.ModuleName)), + auth.NewAppModule( + appCodec, + accountK, + authsims.RandomGenesisAccounts, + app.GetSubspace(authtypes.ModuleName), + ), bank.NewAppModule(appCodec, bankK, accountK, app.GetSubspace(banktypes.ModuleName)), capability.NewAppModule(appCodec, *app.CapabilityKeeper, false), - crisis.NewAppModule(&app.CrisisKeeper, skipGenesisInvariants, app.GetSubspace(crisistypes.ModuleName)), - gov.NewAppModule(appCodec, govKeeper, accountK, bankK, app.GetSubspace(govtypes.ModuleName)), - slashing.NewAppModule(appCodec, app.SlashingKeeper, accountK, bankK, app.StakingKeeper, app.GetSubspace(slashingtypes.ModuleName)), - distr.NewAppModule(appCodec, app.DistrKeeper, accountK, bankK, app.StakingKeeper, app.GetSubspace(distrtypes.ModuleName)), - staking.NewAppModule(appCodec, &app.StakingKeeper, accountK, bankK, app.GetSubspace(stakingtypes.ModuleName)), + crisis.NewAppModule( + &app.CrisisKeeper, + skipGenesisInvariants, + app.GetSubspace(crisistypes.ModuleName), + ), + gov.NewAppModule( + appCodec, + govKeeper, + accountK, + bankK, + app.GetSubspace(govtypes.ModuleName), + ), + slashing.NewAppModule( + appCodec, + app.SlashingKeeper, + accountK, + bankK, + app.StakingKeeper, + app.GetSubspace(slashingtypes.ModuleName), + ), + distr.NewAppModule( + appCodec, + app.DistrKeeper, + accountK, + bankK, + app.StakingKeeper, + app.GetSubspace(distrtypes.ModuleName), + ), + staking.NewAppModule( + appCodec, + &app.StakingKeeper, + accountK, + bankK, + app.GetSubspace(stakingtypes.ModuleName), + ), upgrade.NewAppModule(&app.UpgradeKeeper), evidence.NewAppModule(app.EvidenceKeeper), params.NewAppModule(app.ParamsKeeper), - feegrantmodule.NewAppModule(appCodec, accountK, bankK, app.FeeGrantKeeper, app.interfaceRegistry), - authzmodule.NewAppModule(appCodec, app.AuthzKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry), + feegrantmodule.NewAppModule( + appCodec, + accountK, + bankK, + app.FeeGrantKeeper, + app.interfaceRegistry, + ), + authzmodule.NewAppModule( + appCodec, + app.AuthzKeeper, + app.AccountKeeper, + app.BankKeeper, + app.interfaceRegistry, + ), consensus.NewAppModule(appCodec, app.ConsensusParamsKeeper), // ibc modules @@ -779,19 +890,26 @@ func NewExocoreApp( ica.NewAppModule(nil, &app.ICAHostKeeper), transferModule, // Ethermint app modules - evm.NewAppModule(app.EvmKeeper, app.AccountKeeper, app.GetSubspace(evmtypes.ModuleName)), + evm.NewAppModule( + app.EvmKeeper, + app.AccountKeeper, + app.GetSubspace(evmtypes.ModuleName), + ), feemarket.NewAppModule(app.FeeMarketKeeper, app.GetSubspace(feemarkettypes.ModuleName)), // Evmos app modules inflation.NewAppModule(app.InflationKeeper, app.AccountKeeper, app.StakingKeeper, app.GetSubspace(inflationtypes.ModuleName)), erc20.NewAppModule(app.Erc20Keeper, app.AccountKeeper, app.GetSubspace(erc20types.ModuleName)), - incentives.NewAppModule(app.IncentivesKeeper, app.AccountKeeper, - app.GetSubspace(incentivestypes.ModuleName)), epochs.NewAppModule(appCodec, app.EpochsKeeper), claims.NewAppModule(appCodec, *app.ClaimsKeeper, app.GetSubspace(claimstypes.ModuleName)), - vesting.NewAppModule(app.VestingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper), + vesting.NewAppModule( + app.VestingKeeper, + app.AccountKeeper, + app.BankKeeper, + app.StakingKeeper, + ), recovery.NewAppModule(*app.RecoveryKeeper, app.GetSubspace(recoverytypes.ModuleName)), revenue.NewAppModule(app.RevenueKeeper, app.AccountKeeper, @@ -811,11 +929,13 @@ func NewExocoreApp( // CanWithdrawInvariant invariant. // NOTE: upgrade module must go first to handle software upgrades. // NOTE: staking module is required if HistoricalEntries param > 0. - // NOTE: capability module's beginblocker must come before any modules using capabilities (e.g. IBC) + // NOTE: capability module's beginblocker must come before any modules using capabilities + // (e.g. IBC) app.mm.SetOrderBeginBlockers( upgradetypes.ModuleName, capabilitytypes.ModuleName, - // Note: epochs' begin should be "real" start of epochs, we keep epochs beginblock at the beginning + // Note: epochs' begin should be "real" start of epochs, we keep epochs beginblock at + // the beginning epochstypes.ModuleName, feemarkettypes.ModuleName, evmtypes.ModuleName, @@ -839,7 +959,6 @@ func NewExocoreApp( inflationtypes.ModuleName, erc20types.ModuleName, claimstypes.ModuleName, - incentivestypes.ModuleName, recoverytypes.ModuleName, revenuetypes.ModuleName, consensusparamtypes.ModuleName, @@ -860,7 +979,8 @@ func NewExocoreApp( stakingtypes.ModuleName, evmtypes.ModuleName, feemarkettypes.ModuleName, - // Note: epochs' endblock should be "real" end of epochs, we keep epochs endblock at the end + // Note: epochs' endblock should be "real" end of epochs, we keep epochs endblock at the + // end epochstypes.ModuleName, claimstypes.ModuleName, // no-op modules @@ -882,7 +1002,6 @@ func NewExocoreApp( vestingtypes.ModuleName, inflationtypes.ModuleName, erc20types.ModuleName, - incentivestypes.ModuleName, recoverytypes.ModuleName, revenuetypes.ModuleName, consensusparamtypes.ModuleName, @@ -939,7 +1058,6 @@ func NewExocoreApp( vestingtypes.ModuleName, inflationtypes.ModuleName, erc20types.ModuleName, - incentivestypes.ModuleName, epochstypes.ModuleName, recoverytypes.ModuleName, revenuetypes.ModuleName, @@ -949,22 +1067,35 @@ func NewExocoreApp( ) app.mm.RegisterInvariants(&app.CrisisKeeper) - app.configurator = module.NewConfigurator(app.appCodec, app.MsgServiceRouter(), app.GRPCQueryRouter()) + app.configurator = module.NewConfigurator( + app.appCodec, + app.MsgServiceRouter(), + app.GRPCQueryRouter(), + ) app.mm.RegisterServices(app.configurator) // add test gRPC service for testing gRPC queries in isolation // testdata.RegisterTestServiceServer(app.GRPCQueryRouter(), testdata.TestServiceImpl{}) - // create the simulation manager and define the order of the modules for deterministic simulations + // create the simulation manager and define the order of the modules for deterministic + // simulations // // NOTE: this is not required apps that don't use the simulator for fuzz testing // transactions overrideModules := map[string]module.AppModuleSimulation{ - authtypes.ModuleName: auth.NewAppModule(app.appCodec, app.AccountKeeper, authsims.RandomGenesisAccounts, app.GetSubspace(authtypes.ModuleName)), + authtypes.ModuleName: auth.NewAppModule( + app.appCodec, + app.AccountKeeper, + authsims.RandomGenesisAccounts, + app.GetSubspace(authtypes.ModuleName), + ), } app.sm = module.NewSimulationManagerFromAppModules(app.mm.Modules, overrideModules) - autocliv1.RegisterQueryServer(app.GRPCQueryRouter(), runtimeservices.NewAutoCLIQueryService(app.mm.Modules)) + autocliv1.RegisterQueryServer( + app.GRPCQueryRouter(), + runtimeservices.NewAutoCLIQueryService(app.mm.Modules), + ) reflectionSvc, err := runtimeservices.NewReflectionService() if err != nil { @@ -1049,17 +1180,24 @@ func (app *ExocoreApp) setPostHandler() { app.SetPostHandler(postHandler) } -// BeginBlocker runs the Tendermint ABCI BeginBlock logic. It executes state changes at the beginning -// of the new block for every registered module. If there is a registered fork at the current height, +// BeginBlocker runs the Tendermint ABCI BeginBlock logic. It executes state changes at the +// beginning of the new block for every registered module. If there is a registered fork at the +// current height, // BeginBlocker will schedule the upgrade plan and perform the state migration (if any). -func (app *ExocoreApp) BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) abci.ResponseBeginBlock { +func (app *ExocoreApp) BeginBlocker( + ctx sdk.Context, + req abci.RequestBeginBlock, +) abci.ResponseBeginBlock { // Perform any scheduled forks before executing the modules logic app.ScheduleForkUpgrade(ctx) return app.mm.BeginBlock(ctx, req) } // EndBlocker updates every end block -func (app *ExocoreApp) EndBlocker(ctx sdk.Context, req abci.RequestEndBlock) abci.ResponseEndBlock { +func (app *ExocoreApp) EndBlocker( + ctx sdk.Context, + req abci.RequestEndBlock, +) abci.ResponseEndBlock { return app.mm.EndBlock(ctx, req) } @@ -1078,7 +1216,10 @@ func (app *ExocoreApp) DeliverTx(req abci.RequestDeliverTx) (res abci.ResponseDe } // InitChainer updates at chain initialization -func (app *ExocoreApp) InitChainer(ctx sdk.Context, req abci.RequestInitChain) abci.ResponseInitChain { +func (app *ExocoreApp) InitChainer( + ctx sdk.Context, + req abci.RequestInitChain, +) abci.ResponseInitChain { var genesisState simapp.GenesisState if err := json.Unmarshal(req.AppStateBytes, &genesisState); err != nil { panic(err) @@ -1183,7 +1324,12 @@ func (app *ExocoreApp) RegisterAPIRoutes(apiSvr *api.Server, apiConfig config.AP } func (app *ExocoreApp) RegisterTxService(clientCtx client.Context) { - authtx.RegisterTxService(app.BaseApp.GRPCQueryRouter(), clientCtx, app.BaseApp.Simulate, app.interfaceRegistry) + authtx.RegisterTxService( + app.BaseApp.GRPCQueryRouter(), + clientCtx, + app.BaseApp.Simulate, + app.interfaceRegistry, + ) } // RegisterTendermintService implements the Application.RegisterTendermintService method. @@ -1263,13 +1409,17 @@ func initParamsKeeper( paramsKeeper.Subspace(stakingtypes.ModuleName) paramsKeeper.Subspace(distrtypes.ModuleName) paramsKeeper.Subspace(slashingtypes.ModuleName) - paramsKeeper.Subspace(govtypes.ModuleName).WithKeyTable(govv1.ParamKeyTable()) //nolint: staticcheck + paramsKeeper.Subspace(govtypes.ModuleName). + WithKeyTable(govv1.ParamKeyTable()) + //nolint: staticcheck paramsKeeper.Subspace(crisistypes.ModuleName) paramsKeeper.Subspace(ibctransfertypes.ModuleName) paramsKeeper.Subspace(ibcexported.ModuleName) paramsKeeper.Subspace(icahosttypes.SubModuleName) // ethermint subspaces - paramsKeeper.Subspace(evmtypes.ModuleName).WithKeyTable(evmtypes.ParamKeyTable()) //nolint: staticcheck + paramsKeeper.Subspace(evmtypes.ModuleName). + WithKeyTable(evmtypes.ParamKeyTable()) + //nolint: staticcheck return paramsKeeper } From 8995aeabf239d90b173bee51915b8efd00e6b55e Mon Sep 17 00:00:00 2001 From: MaxMustermann2 <82761650+MaxMustermann2@users.noreply.github.com> Date: Tue, 26 Mar 2024 08:55:14 +0000 Subject: [PATCH 02/15] fix(app): remove inflation module The inflation module is the replacement of the `mint` module from the Cosmos SDK with specific allocations to the team account. Similar to the mint module, it used the parameters like `bondedRatio`, which are not defined in our case. --- app/app.go | 97 ++++++++++++++++++++++++++---------------------------- 1 file changed, 46 insertions(+), 51 deletions(-) diff --git a/app/app.go b/app/app.go index f832f556c..5ebfa95e3 100644 --- a/app/app.go +++ b/app/app.go @@ -50,11 +50,8 @@ import ( // increases or decreases block gas limit based on usage "github.com/evmos/evmos/v14/x/feemarket" + feemarketkeeper "github.com/evmos/evmos/v14/x/feemarket/keeper" feemarkettypes "github.com/evmos/evmos/v14/x/feemarket/types" - "github.com/evmos/evmos/v14/x/inflation" - "github.com/evmos/evmos/v14/x/recovery" - "github.com/evmos/evmos/v14/x/revenue/v1" - vestingtypes "github.com/evmos/evmos/v14/x/vesting/types" runtimeservices "github.com/cosmos/cosmos-sdk/runtime/services" @@ -77,14 +74,14 @@ import ( "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/server/api" "github.com/cosmos/cosmos-sdk/server/config" - authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" + ica "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts" icahost "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/host" + icahostkeeper "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/host/keeper" 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" ibctestingtypes "github.com/cosmos/ibc-go/v7/testing/types" - // NOTE: override ICS20 keeper to support IBC transfers of ERC20 tokens ibctransfer "github.com/cosmos/ibc-go/v7/modules/apps/transfer" ibctransfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" ibc "github.com/cosmos/ibc-go/v7/modules/core" @@ -95,11 +92,12 @@ import ( ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported" ibckeeper "github.com/cosmos/ibc-go/v7/modules/core/keeper" ibctm "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint" - srvflags "github.com/evmos/evmos/v14/server/flags" + + // this module allows the transfer of ERC20 tokens over IBC. for such transfers to occur, + // they must be enabled in the ERC20 keeper. transfer "github.com/evmos/evmos/v14/x/ibc/transfer" transferkeeper "github.com/evmos/evmos/v14/x/ibc/transfer/keeper" - // NOTE: override ICS20 keeper to support IBC transfers of ERC20 tokens "cosmossdk.io/simapp" simappparams "cosmossdk.io/simapp/params" servertypes "github.com/cosmos/cosmos-sdk/server/types" @@ -109,84 +107,102 @@ import ( "github.com/cosmos/cosmos-sdk/types/mempool" "github.com/cosmos/cosmos-sdk/types/module" "github.com/cosmos/cosmos-sdk/version" + srvflags "github.com/evmos/evmos/v14/server/flags" + "github.com/cosmos/cosmos-sdk/x/auth" + authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" "github.com/cosmos/cosmos-sdk/x/auth/posthandler" authsims "github.com/cosmos/cosmos-sdk/x/auth/simulation" authtx "github.com/cosmos/cosmos-sdk/x/auth/tx" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + "github.com/cosmos/cosmos-sdk/x/authz" authzmodule "github.com/cosmos/cosmos-sdk/x/authz/module" + "github.com/cosmos/cosmos-sdk/x/bank" + bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + "github.com/cosmos/cosmos-sdk/x/capability" capabilitykeeper "github.com/cosmos/cosmos-sdk/x/capability/keeper" capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" + "github.com/cosmos/cosmos-sdk/x/consensus" + consensusparamkeeper "github.com/cosmos/cosmos-sdk/x/consensus/keeper" + consensusparamtypes "github.com/cosmos/cosmos-sdk/x/consensus/types" + "github.com/cosmos/cosmos-sdk/x/crisis" crisiskeeper "github.com/cosmos/cosmos-sdk/x/crisis/keeper" crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types" + distr "github.com/cosmos/cosmos-sdk/x/distribution" distrkeeper "github.com/cosmos/cosmos-sdk/x/distribution/keeper" distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" + "github.com/cosmos/cosmos-sdk/x/evidence" evidencekeeper "github.com/cosmos/cosmos-sdk/x/evidence/keeper" evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types" + "github.com/cosmos/cosmos-sdk/x/feegrant" feegrantkeeper "github.com/cosmos/cosmos-sdk/x/feegrant/keeper" feegrantmodule "github.com/cosmos/cosmos-sdk/x/feegrant/module" + "github.com/cosmos/cosmos-sdk/x/genutil" genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" + "github.com/cosmos/cosmos-sdk/x/gov" govclient "github.com/cosmos/cosmos-sdk/x/gov/client" govkeeper "github.com/cosmos/cosmos-sdk/x/gov/keeper" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" govv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" + "github.com/cosmos/cosmos-sdk/x/params" paramsclient "github.com/cosmos/cosmos-sdk/x/params/client" paramskeeper "github.com/cosmos/cosmos-sdk/x/params/keeper" paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" paramproposal "github.com/cosmos/cosmos-sdk/x/params/types/proposal" + "github.com/cosmos/cosmos-sdk/x/slashing" slashingkeeper "github.com/cosmos/cosmos-sdk/x/slashing/keeper" slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" + "github.com/cosmos/cosmos-sdk/x/staking" stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + "github.com/cosmos/cosmos-sdk/x/upgrade" upgradeclient "github.com/cosmos/cosmos-sdk/x/upgrade/client" upgradekeeper "github.com/cosmos/cosmos-sdk/x/upgrade/keeper" upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" "github.com/ExocoreNetwork/exocore/x/evm" - bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" - "github.com/evmos/evmos/v14/encoding" - evmostypes "github.com/evmos/evmos/v14/types" - evmtypes "github.com/evmos/evmos/v14/x/evm/types" - evmkeeper "github.com/ExocoreNetwork/exocore/x/evm/keeper" + evmtypes "github.com/evmos/evmos/v14/x/evm/types" - consensusparamkeeper "github.com/cosmos/cosmos-sdk/x/consensus/keeper" - consensusparamtypes "github.com/cosmos/cosmos-sdk/x/consensus/types" - feemarketkeeper "github.com/evmos/evmos/v14/x/feemarket/keeper" - - icahostkeeper "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/host/keeper" + "github.com/evmos/evmos/v14/encoding" + evmostypes "github.com/evmos/evmos/v14/types" - inflationkeeper "github.com/evmos/evmos/v14/x/inflation/keeper" - inflationtypes "github.com/evmos/evmos/v14/x/inflation/types" + "github.com/evmos/evmos/v14/x/recovery" recoverykeeper "github.com/evmos/evmos/v14/x/recovery/keeper" recoverytypes "github.com/evmos/evmos/v14/x/recovery/types" + + "github.com/evmos/evmos/v14/x/revenue/v1" revenuekeeper "github.com/evmos/evmos/v14/x/revenue/v1/keeper" revenuetypes "github.com/evmos/evmos/v14/x/revenue/v1/types" + "github.com/evmos/evmos/v14/x/vesting" vestingkeeper "github.com/evmos/evmos/v14/x/vesting/keeper" + vestingtypes "github.com/evmos/evmos/v14/x/vesting/types" "github.com/evmos/evmos/v14/x/claims" claimskeeper "github.com/evmos/evmos/v14/x/claims/keeper" claimstypes "github.com/evmos/evmos/v14/x/claims/types" + "github.com/evmos/evmos/v14/x/epochs" epochskeeper "github.com/evmos/evmos/v14/x/epochs/keeper" epochstypes "github.com/evmos/evmos/v14/x/epochs/types" + "github.com/evmos/evmos/v14/x/erc20" erc20keeper "github.com/evmos/evmos/v14/x/erc20/keeper" erc20types "github.com/evmos/evmos/v14/x/erc20/types" @@ -255,7 +271,6 @@ var ( evm.AppModuleBasic{}, feemarket.AppModuleBasic{}, // evmos modules - inflation.AppModuleBasic{}, erc20.AppModuleBasic{}, epochs.AppModuleBasic{}, claims.AppModuleBasic{}, @@ -285,9 +300,8 @@ var ( authtypes.Minter, authtypes.Burner, }, // used for secure addition and subtraction of balance using module account - inflationtypes.ModuleName: {authtypes.Minter}, - erc20types.ModuleName: {authtypes.Minter, authtypes.Burner}, - claimstypes.ModuleName: nil, + erc20types.ModuleName: {authtypes.Minter, authtypes.Burner}, + claimstypes.ModuleName: nil, } // module accounts that are allowed to receive tokens @@ -345,13 +359,12 @@ type ExocoreApp struct { FeeMarketKeeper feemarketkeeper.Keeper // Evmos keepers - InflationKeeper inflationkeeper.Keeper - ClaimsKeeper *claimskeeper.Keeper - Erc20Keeper erc20keeper.Keeper - EpochsKeeper epochskeeper.Keeper - VestingKeeper vestingkeeper.Keeper - RecoveryKeeper *recoverykeeper.Keeper - RevenueKeeper revenuekeeper.Keeper + ClaimsKeeper *claimskeeper.Keeper + Erc20Keeper erc20keeper.Keeper + EpochsKeeper epochskeeper.Keeper + VestingKeeper vestingkeeper.Keeper + RecoveryKeeper *recoverykeeper.Keeper + RevenueKeeper revenuekeeper.Keeper // exocore assets module keepers AssetsKeeper assetsKeeper.Keeper @@ -433,7 +446,7 @@ func NewExocoreApp( // ethermint keys evmtypes.StoreKey, feemarkettypes.StoreKey, // evmos keys - inflationtypes.StoreKey, erc20types.StoreKey, + erc20types.StoreKey, epochstypes.StoreKey, claimstypes.StoreKey, vestingtypes.StoreKey, revenuetypes.StoreKey, recoverytypes.StoreKey, // exoCore module keys @@ -602,18 +615,6 @@ func NewExocoreApp( // Set legacy router for backwards compatibility with gov v1beta1 govKeeper.SetLegacyRouter(govRouter) - // Evmos Keeper - app.InflationKeeper = inflationkeeper.NewKeeper( - keys[inflationtypes.StoreKey], - appCodec, - authtypes.NewModuleAddress(govtypes.ModuleName), - app.AccountKeeper, - app.BankKeeper, - app.DistrKeeper, - stakingKeeper, - authtypes.FeeCollectorName, - ) - app.ClaimsKeeper = claimskeeper.NewKeeper( appCodec, keys[claimstypes.StoreKey], @@ -716,8 +717,7 @@ func NewExocoreApp( epochsKeeper := epochskeeper.NewKeeper(appCodec, keys[epochstypes.StoreKey]) app.EpochsKeeper = *epochsKeeper.SetHooks( epochskeeper.NewMultiEpochHooks( - // insert epoch hooks receivers here - app.InflationKeeper.Hooks(), + // insert epoch hooks receivers here ), ) @@ -897,8 +897,6 @@ func NewExocoreApp( ), feemarket.NewAppModule(app.FeeMarketKeeper, app.GetSubspace(feemarkettypes.ModuleName)), // Evmos app modules - inflation.NewAppModule(app.InflationKeeper, app.AccountKeeper, app.StakingKeeper, - app.GetSubspace(inflationtypes.ModuleName)), erc20.NewAppModule(app.Erc20Keeper, app.AccountKeeper, app.GetSubspace(erc20types.ModuleName)), epochs.NewAppModule(appCodec, app.EpochsKeeper), @@ -956,7 +954,6 @@ func NewExocoreApp( feegrant.ModuleName, paramstypes.ModuleName, vestingtypes.ModuleName, - inflationtypes.ModuleName, erc20types.ModuleName, claimstypes.ModuleName, recoverytypes.ModuleName, @@ -1000,7 +997,6 @@ func NewExocoreApp( upgradetypes.ModuleName, // Evmos modules vestingtypes.ModuleName, - inflationtypes.ModuleName, erc20types.ModuleName, recoverytypes.ModuleName, revenuetypes.ModuleName, @@ -1056,7 +1052,6 @@ func NewExocoreApp( exoslashTypes.ModuleName, // Evmos modules vestingtypes.ModuleName, - inflationtypes.ModuleName, erc20types.ModuleName, epochstypes.ModuleName, recoverytypes.ModuleName, From eb7d9eae1cfd70207e56075011d021053ce613ee Mon Sep 17 00:00:00 2001 From: MaxMustermann2 <82761650+MaxMustermann2@users.noreply.github.com> Date: Tue, 26 Mar 2024 09:32:11 +0000 Subject: [PATCH 03/15] fix(app): clarify claims and recovery modules The pre-existing claims and recovery modules are used for airdrops and token recovery (between Cosmos and Ethereum addresses) over authorized IBC channels, respectively. This commit explicitly disables the airdrop feature while retaining to claims module to enable recovery of tokens. Note that the authorized channels for the recovery are still undecided. --- app/app.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/app.go b/app/app.go index 5ebfa95e3..419bce14e 100644 --- a/app/app.go +++ b/app/app.go @@ -183,6 +183,10 @@ import ( "github.com/evmos/evmos/v14/encoding" evmostypes "github.com/evmos/evmos/v14/types" + // The recovery module is an IBC middleware for helping users recover funds that they sent + // to the Cosmos secp256k1 address instead of the Ethereum ethsecp256k1 address. It only + // works for authorized chains. To check this, it depends on the claims module, which must + // be enabled. "github.com/evmos/evmos/v14/x/recovery" recoverykeeper "github.com/evmos/evmos/v14/x/recovery/keeper" recoverytypes "github.com/evmos/evmos/v14/x/recovery/types" @@ -195,6 +199,9 @@ import ( vestingkeeper "github.com/evmos/evmos/v14/x/vesting/keeper" vestingtypes "github.com/evmos/evmos/v14/x/vesting/types" + // The claims module is responsible for handling airdrops. We are explicitly disabling it by + // setting enable_claims to false. It is only imported because it is required by the + // recovery module. "github.com/evmos/evmos/v14/x/claims" claimskeeper "github.com/evmos/evmos/v14/x/claims/keeper" claimstypes "github.com/evmos/evmos/v14/x/claims/types" @@ -233,6 +240,11 @@ func init() { feemarkettypes.DefaultMinGasMultiplier = MainnetMinGasMultiplier // modify default min commission to 5% stakingtypes.DefaultMinCommissionRate = sdk.NewDecWithPrec(5, 2) + // explicitly disable airdrops, only token recovery over authorized channels. + claimstypes.DefaultEnableClaims = false + // disable any recovery unless explicitly enabled via governance + claimstypes.DefaultAuthorizedChannels = []string{} + claimstypes.DefaultEVMChannels = []string{} } var ( From 18850a19c213a38ebbca5f7491cb3b358fb3cdb1 Mon Sep 17 00:00:00 2001 From: MaxMustermann2 <82761650+MaxMustermann2@users.noreply.github.com> Date: Tue, 26 Mar 2024 09:34:50 +0000 Subject: [PATCH 04/15] fix(app): remove revenue module The revenue module is used for sharing the gas fees for contract interaction between the network and the contract deployer. This is not a feature that our omnichain restaking platform needs. --- app/app.go | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/app/app.go b/app/app.go index 419bce14e..9fa76cf86 100644 --- a/app/app.go +++ b/app/app.go @@ -191,10 +191,6 @@ import ( recoverykeeper "github.com/evmos/evmos/v14/x/recovery/keeper" recoverytypes "github.com/evmos/evmos/v14/x/recovery/types" - "github.com/evmos/evmos/v14/x/revenue/v1" - revenuekeeper "github.com/evmos/evmos/v14/x/revenue/v1/keeper" - revenuetypes "github.com/evmos/evmos/v14/x/revenue/v1/types" - "github.com/evmos/evmos/v14/x/vesting" vestingkeeper "github.com/evmos/evmos/v14/x/vesting/keeper" vestingtypes "github.com/evmos/evmos/v14/x/vesting/types" @@ -287,7 +283,6 @@ var ( epochs.AppModuleBasic{}, claims.AppModuleBasic{}, recovery.AppModuleBasic{}, - revenue.AppModuleBasic{}, consensus.AppModuleBasic{}, // Exocore modules assets.AppModuleBasic{}, @@ -376,7 +371,6 @@ type ExocoreApp struct { EpochsKeeper epochskeeper.Keeper VestingKeeper vestingkeeper.Keeper RecoveryKeeper *recoverykeeper.Keeper - RevenueKeeper revenuekeeper.Keeper // exocore assets module keepers AssetsKeeper assetsKeeper.Keeper @@ -460,7 +454,7 @@ func NewExocoreApp( // evmos keys erc20types.StoreKey, epochstypes.StoreKey, claimstypes.StoreKey, vestingtypes.StoreKey, - revenuetypes.StoreKey, recoverytypes.StoreKey, + recoverytypes.StoreKey, // exoCore module keys assetsTypes.StoreKey, delegationTypes.StoreKey, @@ -662,12 +656,6 @@ func NewExocoreApp( app.AccountKeeper, app.BankKeeper, app.EvmKeeper, app.StakingKeeper, app.ClaimsKeeper, ) - app.RevenueKeeper = revenuekeeper.NewKeeper( - keys[revenuetypes.StoreKey], appCodec, authtypes.NewModuleAddress(govtypes.ModuleName), - app.BankKeeper, app.DistrKeeper, app.AccountKeeper, app.EvmKeeper, - authtypes.FeeCollectorName, - ) - app.TransferKeeper = transferkeeper.NewKeeper( appCodec, keys[ibctransfertypes.StoreKey], app.GetSubspace(ibctransfertypes.ModuleName), app.ClaimsKeeper, // ICS4 Wrapper: claims IBC middleware @@ -742,7 +730,6 @@ func NewExocoreApp( app.EvmKeeper = app.EvmKeeper.SetHooks( evmkeeper.NewMultiEvmHooks( app.Erc20Keeper.Hooks(), - app.RevenueKeeper.Hooks(), app.ClaimsKeeper.Hooks(), ), ) @@ -922,8 +909,6 @@ func NewExocoreApp( ), recovery.NewAppModule(*app.RecoveryKeeper, app.GetSubspace(recoverytypes.ModuleName)), - revenue.NewAppModule(app.RevenueKeeper, app.AccountKeeper, - app.GetSubspace(revenuetypes.ModuleName)), // exoCore app modules assets.NewAppModule(appCodec, app.AssetsKeeper), deposit.NewAppModule(appCodec, app.DepositKeeper), @@ -969,7 +954,6 @@ func NewExocoreApp( erc20types.ModuleName, claimstypes.ModuleName, recoverytypes.ModuleName, - revenuetypes.ModuleName, consensusparamtypes.ModuleName, // ExoCore modules assetsTypes.ModuleName, @@ -1011,7 +995,6 @@ func NewExocoreApp( vestingtypes.ModuleName, erc20types.ModuleName, recoverytypes.ModuleName, - revenuetypes.ModuleName, consensusparamtypes.ModuleName, // ExoCore modules assetsTypes.ModuleName, @@ -1041,7 +1024,6 @@ func NewExocoreApp( govtypes.ModuleName, ibcexported.ModuleName, // Ethermint modules - // evm module denomination is used by the revenue module, in AnteHandle evmtypes.ModuleName, // NOTE: feemarket module needs to be initialized before genutil module: // gentx transactions use MinGasPriceDecorator.AnteHandle @@ -1067,7 +1049,6 @@ func NewExocoreApp( erc20types.ModuleName, epochstypes.ModuleName, recoverytypes.ModuleName, - revenuetypes.ModuleName, // NOTE: crisis module must go at the end to check for invariants on each module crisistypes.ModuleName, consensusparamtypes.ModuleName, From a85f292aeb04fe72c35e5e427002d8e4c343a074 Mon Sep 17 00:00:00 2001 From: MaxMustermann2 <82761650+MaxMustermann2@users.noreply.github.com> Date: Tue, 26 Mar 2024 09:40:44 +0000 Subject: [PATCH 05/15] fix(app): remove vesting module As the name suggests, the vesting module is responsible for token vesting. It is not critical to functioning of the platform and has been removed. If necessary, it may be added back later. --- app/app.go | 27 ++------------------ x/evm/keeper/precompiles.go | 49 +++++++++++++++++++++++++------------ 2 files changed, 35 insertions(+), 41 deletions(-) diff --git a/app/app.go b/app/app.go index 9fa76cf86..8f6c9a389 100644 --- a/app/app.go +++ b/app/app.go @@ -191,10 +191,6 @@ import ( recoverykeeper "github.com/evmos/evmos/v14/x/recovery/keeper" recoverytypes "github.com/evmos/evmos/v14/x/recovery/types" - "github.com/evmos/evmos/v14/x/vesting" - vestingkeeper "github.com/evmos/evmos/v14/x/vesting/keeper" - vestingtypes "github.com/evmos/evmos/v14/x/vesting/types" - // The claims module is responsible for handling airdrops. We are explicitly disabling it by // setting enable_claims to false. It is only imported because it is required by the // recovery module. @@ -275,7 +271,6 @@ var ( upgrade.AppModuleBasic{}, evidence.AppModuleBasic{}, transfer.AppModuleBasic{AppModuleBasic: &ibctransfer.AppModuleBasic{}}, - vesting.AppModuleBasic{}, evm.AppModuleBasic{}, feemarket.AppModuleBasic{}, // evmos modules @@ -369,7 +364,6 @@ type ExocoreApp struct { ClaimsKeeper *claimskeeper.Keeper Erc20Keeper erc20keeper.Keeper EpochsKeeper epochskeeper.Keeper - VestingKeeper vestingkeeper.Keeper RecoveryKeeper *recoverykeeper.Keeper // exocore assets module keepers @@ -453,7 +447,7 @@ func NewExocoreApp( evmtypes.StoreKey, feemarkettypes.StoreKey, // evmos keys erc20types.StoreKey, - epochstypes.StoreKey, claimstypes.StoreKey, vestingtypes.StoreKey, + epochstypes.StoreKey, claimstypes.StoreKey, recoverytypes.StoreKey, // exoCore module keys assetsTypes.StoreKey, @@ -605,9 +599,7 @@ func NewExocoreApp( AddRoute(paramproposal.RouterKey, params.NewParamChangeProposalHandler(app.ParamsKeeper)). AddRoute(upgradetypes.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(&app.UpgradeKeeper)). AddRoute(ibcclienttypes.RouterKey, ibcclient.NewClientProposalHandler(app.IBCKeeper.ClientKeeper)). - AddRoute(erc20types.RouterKey, erc20.NewErc20ProposalHandler(&app.Erc20Keeper)). - AddRoute(vestingtypes.RouterKey, vesting.NewVestingProposalHandler(&app.VestingKeeper)) - + AddRoute(erc20types.RouterKey, erc20.NewErc20ProposalHandler(&app.Erc20Keeper)) govConfig := govtypes.DefaultConfig() /* Example of setting gov params: @@ -646,11 +638,6 @@ func NewExocoreApp( app.StakingKeeper = *stakingKeeper - app.VestingKeeper = vestingkeeper.NewKeeper( - keys[vestingtypes.StoreKey], authtypes.NewModuleAddress(govtypes.ModuleName), appCodec, - app.AccountKeeper, app.BankKeeper, app.DistrKeeper, app.StakingKeeper, app.GovKeeper, - ) - app.Erc20Keeper = erc20keeper.NewKeeper( keys[erc20types.StoreKey], appCodec, authtypes.NewModuleAddress(govtypes.ModuleName), app.AccountKeeper, app.BankKeeper, app.EvmKeeper, app.StakingKeeper, app.ClaimsKeeper, @@ -702,7 +689,6 @@ func NewExocoreApp( evmkeeper.AvailablePrecompiles( *stakingKeeper, app.DistrKeeper, - app.VestingKeeper, app.AuthzKeeper, app.TransferKeeper, app.IBCKeeper.ChannelKeeper, @@ -901,12 +887,6 @@ func NewExocoreApp( epochs.NewAppModule(appCodec, app.EpochsKeeper), claims.NewAppModule(appCodec, *app.ClaimsKeeper, app.GetSubspace(claimstypes.ModuleName)), - vesting.NewAppModule( - app.VestingKeeper, - app.AccountKeeper, - app.BankKeeper, - app.StakingKeeper, - ), recovery.NewAppModule(*app.RecoveryKeeper, app.GetSubspace(recoverytypes.ModuleName)), // exoCore app modules @@ -950,7 +930,6 @@ func NewExocoreApp( authz.ModuleName, feegrant.ModuleName, paramstypes.ModuleName, - vestingtypes.ModuleName, erc20types.ModuleName, claimstypes.ModuleName, recoverytypes.ModuleName, @@ -992,7 +971,6 @@ func NewExocoreApp( paramstypes.ModuleName, upgradetypes.ModuleName, // Evmos modules - vestingtypes.ModuleName, erc20types.ModuleName, recoverytypes.ModuleName, consensusparamtypes.ModuleName, @@ -1045,7 +1023,6 @@ func NewExocoreApp( rewardTypes.ModuleName, exoslashTypes.ModuleName, // Evmos modules - vestingtypes.ModuleName, erc20types.ModuleName, epochstypes.ModuleName, recoverytypes.ModuleName, diff --git a/x/evm/keeper/precompiles.go b/x/evm/keeper/precompiles.go index a26d157bc..6d55cb8a5 100644 --- a/x/evm/keeper/precompiles.go +++ b/x/evm/keeper/precompiles.go @@ -27,9 +27,7 @@ import ( distprecompile "github.com/evmos/evmos/v14/precompiles/distribution" ics20precompile "github.com/evmos/evmos/v14/precompiles/ics20" stakingprecompile "github.com/evmos/evmos/v14/precompiles/staking" - vestingprecompile "github.com/evmos/evmos/v14/precompiles/vesting" transferkeeper "github.com/evmos/evmos/v14/x/ibc/transfer/keeper" - vestingkeeper "github.com/evmos/evmos/v14/x/vesting/keeper" ) // AvailablePrecompiles returns the list of all available precompiled contracts. @@ -37,7 +35,6 @@ import ( func AvailablePrecompiles( stakingKeeper stakingkeeper.Keeper, distributionKeeper distributionkeeper.Keeper, - vestingKeeper vestingkeeper.Keeper, authzKeeper authzkeeper.Keeper, transferKeeper transferkeeper.Keeper, channelKeeper channelkeeper.Keeper, @@ -61,34 +58,53 @@ func AvailablePrecompiles( panic(fmt.Errorf("failed to load distribution precompile: %w", err)) } - ibcTransferPrecompile, err := ics20precompile.NewPrecompile(transferKeeper, channelKeeper, authzKeeper) + ibcTransferPrecompile, err := ics20precompile.NewPrecompile( + transferKeeper, + channelKeeper, + authzKeeper, + ) if err != nil { panic(fmt.Errorf("failed to load ICS20 precompile: %w", err)) } - vestingPrecompile, err := vestingprecompile.NewPrecompile(vestingKeeper, authzKeeper) - if err != nil { - panic(fmt.Errorf("failed to load vesting precompile: %w", err)) - } - // add exoCore chain preCompiles - depositPrecompile, err := depositprecompile.NewPrecompile(stakingStateKeeper, depositKeeper, authzKeeper) + depositPrecompile, err := depositprecompile.NewPrecompile( + stakingStateKeeper, + depositKeeper, + authzKeeper, + ) if err != nil { panic(fmt.Errorf("failed to load deposit precompile: %w", err)) } - delegationPrecompile, err := delegationprecompile.NewPrecompile(stakingStateKeeper, delegationKeeper, authzKeeper) + delegationPrecompile, err := delegationprecompile.NewPrecompile( + stakingStateKeeper, + delegationKeeper, + authzKeeper, + ) if err != nil { panic(fmt.Errorf("failed to load delegation precompile: %w", err)) } - withdrawPrecompile, err := withdrawPrecompile.NewPrecompile(stakingStateKeeper, withdrawKeeper, authzKeeper) + withdrawPrecompile, err := withdrawPrecompile.NewPrecompile( + stakingStateKeeper, + withdrawKeeper, + authzKeeper, + ) if err != nil { panic(fmt.Errorf("failed to load withdraw precompile: %w", err)) } - slashPrecompile, err := slashPrecompile.NewPrecompile(stakingStateKeeper, slashKeeper, authzKeeper) + slashPrecompile, err := slashPrecompile.NewPrecompile( + stakingStateKeeper, + slashKeeper, + authzKeeper, + ) if err != nil { panic(fmt.Errorf("failed to load slash precompile: %w", err)) } - rewardPrecompile, err := rewardPrecompile.NewPrecompile(stakingStateKeeper, rewardKeeper, authzKeeper) + rewardPrecompile, err := rewardPrecompile.NewPrecompile( + stakingStateKeeper, + rewardKeeper, + authzKeeper, + ) if err != nil { panic(fmt.Errorf("failed to load reward precompile: %w", err)) } @@ -100,13 +116,14 @@ func AvailablePrecompiles( precompiles[stakingPrecompile.Address()] = stakingPrecompile precompiles[distributionPrecompile.Address()] = distributionPrecompile - precompiles[vestingPrecompile.Address()] = vestingPrecompile precompiles[ibcTransferPrecompile.Address()] = ibcTransferPrecompile return precompiles } // WithPrecompiles sets the available precompiled contracts. -func (k *Keeper) WithPrecompiles(precompiles map[common.Address]vm.PrecompiledContract) *Keeper { +func (k *Keeper) WithPrecompiles( + precompiles map[common.Address]vm.PrecompiledContract, +) *Keeper { if k.precompiles != nil { panic("available precompiles map already set") } From 82a9151c612f0bf415738b86f57cf3f476adb54c Mon Sep 17 00:00:00 2001 From: MaxMustermann2 <82761650+MaxMustermann2@users.noreply.github.com> Date: Tue, 26 Mar 2024 09:54:28 +0000 Subject: [PATCH 06/15] fix(test): remove inflation and vesting precompile --- app/export.go | 89 ++++++++++++++++++++++++------------------- x/evm/types/params.go | 1 - 2 files changed, 50 insertions(+), 40 deletions(-) diff --git a/app/export.go b/app/export.go index ed9e501c1..18b6824e7 100644 --- a/app/export.go +++ b/app/export.go @@ -19,7 +19,6 @@ import ( stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" claimstypes "github.com/evmos/evmos/v14/x/claims/types" evmtypes "github.com/evmos/evmos/v14/x/evm/types" - inflationtypes "github.com/evmos/evmos/v14/x/inflation/types" "github.com/evmos/evmos/v14/encoding" ) @@ -57,13 +56,6 @@ func NewDefaultGenesisState(cdc codec.Codec) simapp.GenesisState { evmGenesis.Params.EvmDenom = utils.BaseDenom defaultGenesis[evmtypes.ModuleName] = cdc.MustMarshalJSON(&evmGenesis) - // inflation module - inflationGenesis := inflationtypes.GenesisState{} - rawGenesis = defaultGenesis[inflationtypes.ModuleName] - cdc.MustUnmarshalJSON(rawGenesis, &inflationGenesis) - inflationGenesis.Params.MintDenom = utils.BaseDenom - defaultGenesis[inflationtypes.ModuleName] = cdc.MustMarshalJSON(&inflationGenesis) - // claims module claimsGenesis := claimstypes.GenesisState{} rawGenesis = defaultGenesis[claimstypes.ModuleName] @@ -79,7 +71,8 @@ func NewDefaultGenesisState(cdc codec.Codec) simapp.GenesisState { func (app *ExocoreApp) ExportAppStateAndValidators( forZeroHeight bool, jailAllowedAddrs []string, modulesToExport []string, ) (servertypes.ExportedApp, error) { - // Creates context with current height and checks txs for ctx to be usable by start of next block + // Creates context with current height and checks txs for ctx to be usable by start of next + // block ctx := app.NewContext(true, tmproto.Header{Height: app.LastBlockHeight()}) // We export at last height + 1, because that's the height at which @@ -116,7 +109,10 @@ func (app *ExocoreApp) ExportAppStateAndValidators( // NOTE zero height genesis is a temporary feature which will be deprecated // // in favor of export at a block height -func (app *ExocoreApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []string) error { +func (app *ExocoreApp) prepForZeroHeightGenesis( + ctx sdk.Context, + jailAllowedAddrs []string, +) error { applyAllowedAddrs := false // check if there is a allowed address list @@ -140,10 +136,13 @@ func (app *ExocoreApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddr /* Handle fee distribution state. */ // withdraw all validator commission - app.StakingKeeper.IterateValidators(ctx, func(_ int64, val stakingtypes.ValidatorI) (stop bool) { - _, _ = app.DistrKeeper.WithdrawValidatorCommission(ctx, val.GetOperator()) - return false - }) + app.StakingKeeper.IterateValidators( + ctx, + func(_ int64, val stakingtypes.ValidatorI) (stop bool) { + _, _ = app.DistrKeeper.WithdrawValidatorCommission(ctx, val.GetOperator()) + return false + }, + ) // withdraw all delegator rewards dels := app.StakingKeeper.GetAllDelegations(ctx) @@ -171,17 +170,23 @@ func (app *ExocoreApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddr ctx = ctx.WithBlockHeight(0) // reinitialize all validators - app.StakingKeeper.IterateValidators(ctx, func(_ int64, val stakingtypes.ValidatorI) (stop bool) { - // donate any unwithdrawn outstanding reward fraction tokens to the community pool - scraps := app.DistrKeeper.GetValidatorOutstandingRewardsCoins(ctx, val.GetOperator()) - feePool := app.DistrKeeper.GetFeePool(ctx) - feePool.CommunityPool = feePool.CommunityPool.Add(scraps...) - app.DistrKeeper.SetFeePool(ctx, feePool) - - err := app.DistrKeeper.Hooks().AfterValidatorCreated(ctx, val.GetOperator()) - // this lets us stop in case there's an error - return err != nil - }) + app.StakingKeeper.IterateValidators( + ctx, + func(_ int64, val stakingtypes.ValidatorI) (stop bool) { + // donate any unwithdrawn outstanding reward fraction tokens to the community pool + scraps := app.DistrKeeper.GetValidatorOutstandingRewardsCoins( + ctx, + val.GetOperator(), + ) + feePool := app.DistrKeeper.GetFeePool(ctx) + feePool.CommunityPool = feePool.CommunityPool.Add(scraps...) + app.DistrKeeper.SetFeePool(ctx, feePool) + + err := app.DistrKeeper.Hooks().AfterValidatorCreated(ctx, val.GetOperator()) + // this lets us stop in case there's an error + return err != nil + }, + ) // reinitialize all delegations for _, del := range dels { @@ -209,22 +214,28 @@ func (app *ExocoreApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddr /* Handle staking state. */ // iterate through redelegations, reset creation height - app.StakingKeeper.IterateRedelegations(ctx, func(_ int64, red stakingtypes.Redelegation) (stop bool) { - for i := range red.Entries { - red.Entries[i].CreationHeight = 0 - } - app.StakingKeeper.SetRedelegation(ctx, red) - return false - }) + app.StakingKeeper.IterateRedelegations( + ctx, + func(_ int64, red stakingtypes.Redelegation) (stop bool) { + for i := range red.Entries { + red.Entries[i].CreationHeight = 0 + } + app.StakingKeeper.SetRedelegation(ctx, red) + return false + }, + ) // iterate through unbonding delegations, reset creation height - app.StakingKeeper.IterateUnbondingDelegations(ctx, func(_ int64, ubd stakingtypes.UnbondingDelegation) (stop bool) { - for i := range ubd.Entries { - ubd.Entries[i].CreationHeight = 0 - } - app.StakingKeeper.SetUnbondingDelegation(ctx, ubd) - return false - }) + app.StakingKeeper.IterateUnbondingDelegations( + ctx, + func(_ int64, ubd stakingtypes.UnbondingDelegation) (stop bool) { + for i := range ubd.Entries { + ubd.Entries[i].CreationHeight = 0 + } + app.StakingKeeper.SetUnbondingDelegation(ctx, ubd) + return false + }, + ) // Iterate through validators by power descending, reset bond heights, and // update bond intra-tx counters. diff --git a/x/evm/types/params.go b/x/evm/types/params.go index 0dcacfceb..438f83460 100644 --- a/x/evm/types/params.go +++ b/x/evm/types/params.go @@ -13,7 +13,6 @@ var ( "0x0000000000000000000000000000000000000800", // Staking precompile "0x0000000000000000000000000000000000000801", // Distribution precompile "0x0000000000000000000000000000000000000802", // ICS20 transfer precompile - "0x0000000000000000000000000000000000000803", // Vesting precompile "0x0000000000000000000000000000000000000804", // deposit precompile "0x0000000000000000000000000000000000000805", // delegation precompile "0x0000000000000000000000000000000000000806", // reward precompile From 5dadea35055142dc2fa3fd39820d6eb36ad5cbff Mon Sep 17 00:00:00 2001 From: MaxMustermann2 <82761650+MaxMustermann2@users.noreply.github.com> Date: Tue, 26 Mar 2024 10:21:26 +0000 Subject: [PATCH 07/15] chore(lint): move nolint comment above line --- app/app.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/app.go b/app/app.go index 8f6c9a389..e85dcb5be 100644 --- a/app/app.go +++ b/app/app.go @@ -1375,16 +1375,16 @@ func initParamsKeeper( paramsKeeper.Subspace(distrtypes.ModuleName) paramsKeeper.Subspace(slashingtypes.ModuleName) paramsKeeper.Subspace(govtypes.ModuleName). + // nolint: staticcheck WithKeyTable(govv1.ParamKeyTable()) - //nolint: staticcheck paramsKeeper.Subspace(crisistypes.ModuleName) paramsKeeper.Subspace(ibctransfertypes.ModuleName) paramsKeeper.Subspace(ibcexported.ModuleName) paramsKeeper.Subspace(icahosttypes.SubModuleName) // ethermint subspaces paramsKeeper.Subspace(evmtypes.ModuleName). + // nolint: staticcheck WithKeyTable(evmtypes.ParamKeyTable()) - //nolint: staticcheck return paramsKeeper } From 1cb8618941d4d9dd033e9c60af46f8895450068e Mon Sep 17 00:00:00 2001 From: MaxMustermann2 <82761650+MaxMustermann2@users.noreply.github.com> Date: Tue, 26 Mar 2024 16:12:58 +0000 Subject: [PATCH 08/15] fix(app): adjust for claims dependency removal --- app/app.go | 23 +++++++++++------------ go.mod | 6 ++---- go.sum | 4 ++-- 3 files changed, 15 insertions(+), 18 deletions(-) diff --git a/app/app.go b/app/app.go index e85dcb5be..c375af144 100644 --- a/app/app.go +++ b/app/app.go @@ -638,9 +638,19 @@ func NewExocoreApp( app.StakingKeeper = *stakingKeeper + app.RecoveryKeeper = recoverykeeper.NewKeeper( + keys[recoverytypes.StoreKey], + appCodec, + authtypes.NewModuleAddress(govtypes.ModuleName), + app.AccountKeeper, + app.BankKeeper, + app.IBCKeeper.ChannelKeeper, + &app.TransferKeeper, + ) + app.Erc20Keeper = erc20keeper.NewKeeper( keys[erc20types.StoreKey], appCodec, authtypes.NewModuleAddress(govtypes.ModuleName), - app.AccountKeeper, app.BankKeeper, app.EvmKeeper, app.StakingKeeper, app.ClaimsKeeper, + app.AccountKeeper, app.BankKeeper, app.EvmKeeper, app.StakingKeeper, app.RecoveryKeeper, ) app.TransferKeeper = transferkeeper.NewKeeper( @@ -720,17 +730,6 @@ func NewExocoreApp( ), ) - app.RecoveryKeeper = recoverykeeper.NewKeeper( - keys[recoverytypes.StoreKey], - appCodec, - authtypes.NewModuleAddress(govtypes.ModuleName), - app.AccountKeeper, - app.BankKeeper, - app.IBCKeeper.ChannelKeeper, - app.TransferKeeper, - app.ClaimsKeeper, - ) - // NOTE: app.Erc20Keeper is already initialized elsewhere // Set the ICS4 wrappers for custom module middlewares diff --git a/go.mod b/go.mod index ff463418a..ee7f298e9 100644 --- a/go.mod +++ b/go.mod @@ -215,14 +215,12 @@ replace ( github.com/99designs/keyring => github.com/cosmos/keyring v1.2.0 // use Cosmos-SDK fork to enable Ledger functionality github.com/cosmos/cosmos-sdk => github.com/evmos/cosmos-sdk v0.47.4-evmos.2 - //github.com/cosmos/cosmos-sdk => ../cosmos-sdk //fix cosmos-sdk error github.com/cosmos/gogoproto => github.com/cosmos/gogoproto v1.4.10 // use Evmos geth fork github.com/ethereum/go-ethereum => github.com/evmos/go-ethereum v1.10.26-evmos-rc2 - // use exocore fork of evmos - github.com/evmos/evmos/v14 => github.com/ExocoreNetwork/evmos/v14 v14.1.1-0.20240205024453-5e8090e42ef4 - //github.com/evmos/evmos/v14 => ../ExocoreNetwork/evmos + // use exocore fork of evmos TODO + github.com/evmos/evmos/v14 => github.com/MaxMustermann2/evmos/v14 v14.0.0-20240326155756-4f464426e972 // Security Advisory https://github.com/advisories/GHSA-h395-qcrw-5vmq github.com/gin-gonic/gin => github.com/gin-gonic/gin v1.9.1 // replace broken goleveldb diff --git a/go.sum b/go.sum index bb081e135..20913de22 100644 --- a/go.sum +++ b/go.sum @@ -545,10 +545,10 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03 github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d h1:nalkkPQcITbvhmL4+C4cKA87NW0tfm3Kl9VXRoPywFg= github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d/go.mod h1:URdX5+vg25ts3aCh8H5IFZybJYKWhJHYMTnf+ULtoC4= github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= -github.com/ExocoreNetwork/evmos/v14 v14.1.1-0.20240205024453-5e8090e42ef4 h1:55qBGHyCOvxxu4kxh+IY6T1pElfyQey5vRKTs25Gc6s= -github.com/ExocoreNetwork/evmos/v14 v14.1.1-0.20240205024453-5e8090e42ef4/go.mod h1:Hi3CAMxAE+H7Fs7sSHsHKb4DZIURk+trop+mMrjlZqw= github.com/JohnCGriffin/overflow v0.0.0-20211019200055-46fa312c352c/go.mod h1:X0CRv0ky0k6m906ixxpzmDRLvX58TFUKS2eePweuyxk= github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= +github.com/MaxMustermann2/evmos/v14 v14.0.0-20240326155756-4f464426e972 h1:6oBb1Zhtar2hzju1Fv7cZ8mZVJoJ+K5DvbHt/nW0fyU= +github.com/MaxMustermann2/evmos/v14 v14.0.0-20240326155756-4f464426e972/go.mod h1:Hi3CAMxAE+H7Fs7sSHsHKb4DZIURk+trop+mMrjlZqw= github.com/Microsoft/go-winio v0.6.0 h1:slsWYD/zyx7lCXoZVlvQrj0hPTM1HI4+v1sIda2yDvg= github.com/Microsoft/go-winio v0.6.0/go.mod h1:cTAf44im0RAYeL23bpB+fzCyDH2MJiz2BO69KH/soAE= github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 h1:TngWCqHvy9oXAN6lEVMRuU21PR1EtLVZJmdB18Gu3Rw= From 8d709548f57a8e7ea21cd648a2c967c7304c3198 Mon Sep 17 00:00:00 2001 From: MaxMustermann2 <82761650+MaxMustermann2@users.noreply.github.com> Date: Tue, 26 Mar 2024 16:23:30 +0000 Subject: [PATCH 09/15] fix(app): remove claims module --- app/app.go | 58 +++++++++--------------------------------------------- 1 file changed, 9 insertions(+), 49 deletions(-) diff --git a/app/app.go b/app/app.go index c375af144..0dc1343da 100644 --- a/app/app.go +++ b/app/app.go @@ -185,19 +185,11 @@ import ( // The recovery module is an IBC middleware for helping users recover funds that they sent // to the Cosmos secp256k1 address instead of the Ethereum ethsecp256k1 address. It only - // works for authorized chains. To check this, it depends on the claims module, which must - // be enabled. + // works for authorized chains. "github.com/evmos/evmos/v14/x/recovery" recoverykeeper "github.com/evmos/evmos/v14/x/recovery/keeper" recoverytypes "github.com/evmos/evmos/v14/x/recovery/types" - // The claims module is responsible for handling airdrops. We are explicitly disabling it by - // setting enable_claims to false. It is only imported because it is required by the - // recovery module. - "github.com/evmos/evmos/v14/x/claims" - claimskeeper "github.com/evmos/evmos/v14/x/claims/keeper" - claimstypes "github.com/evmos/evmos/v14/x/claims/types" - "github.com/evmos/evmos/v14/x/epochs" epochskeeper "github.com/evmos/evmos/v14/x/epochs/keeper" epochstypes "github.com/evmos/evmos/v14/x/epochs/types" @@ -232,11 +224,6 @@ func init() { feemarkettypes.DefaultMinGasMultiplier = MainnetMinGasMultiplier // modify default min commission to 5% stakingtypes.DefaultMinCommissionRate = sdk.NewDecWithPrec(5, 2) - // explicitly disable airdrops, only token recovery over authorized channels. - claimstypes.DefaultEnableClaims = false - // disable any recovery unless explicitly enabled via governance - claimstypes.DefaultAuthorizedChannels = []string{} - claimstypes.DefaultEVMChannels = []string{} } var ( @@ -276,7 +263,6 @@ var ( // evmos modules erc20.AppModuleBasic{}, epochs.AppModuleBasic{}, - claims.AppModuleBasic{}, recovery.AppModuleBasic{}, consensus.AppModuleBasic{}, // Exocore modules @@ -302,8 +288,7 @@ var ( authtypes.Minter, authtypes.Burner, }, // used for secure addition and subtraction of balance using module account - erc20types.ModuleName: {authtypes.Minter, authtypes.Burner}, - claimstypes.ModuleName: nil, + erc20types.ModuleName: {authtypes.Minter, authtypes.Burner}, } // module accounts that are allowed to receive tokens @@ -361,7 +346,6 @@ type ExocoreApp struct { FeeMarketKeeper feemarketkeeper.Keeper // Evmos keepers - ClaimsKeeper *claimskeeper.Keeper Erc20Keeper erc20keeper.Keeper EpochsKeeper epochskeeper.Keeper RecoveryKeeper *recoverykeeper.Keeper @@ -447,7 +431,7 @@ func NewExocoreApp( evmtypes.StoreKey, feemarkettypes.StoreKey, // evmos keys erc20types.StoreKey, - epochstypes.StoreKey, claimstypes.StoreKey, + epochstypes.StoreKey, recoverytypes.StoreKey, // exoCore module keys assetsTypes.StoreKey, @@ -613,26 +597,14 @@ func NewExocoreApp( // Set legacy router for backwards compatibility with gov v1beta1 govKeeper.SetLegacyRouter(govRouter) - app.ClaimsKeeper = claimskeeper.NewKeeper( - appCodec, - keys[claimstypes.StoreKey], - authtypes.NewModuleAddress(govtypes.ModuleName), - app.AccountKeeper, - app.BankKeeper, - stakingKeeper, - app.DistrKeeper, - app.IBCKeeper.ChannelKeeper, - ) - // register the staking hooks // NOTE: stakingKeeper above is passed by reference, so that it will contain these hooks - // NOTE: Distr, Slashing and Claim must be created before calling the Hooks method to avoid + // NOTE: Distr and Slashing must be created before calling the Hooks method to avoid // returning a Keeper without its table generated stakingKeeper.SetHooks( stakingtypes.NewMultiStakingHooks( app.DistrKeeper.Hooks(), app.SlashingKeeper.Hooks(), - app.ClaimsKeeper.Hooks(), ), ) @@ -655,7 +627,7 @@ func NewExocoreApp( app.TransferKeeper = transferkeeper.NewKeeper( appCodec, keys[ibctransfertypes.StoreKey], app.GetSubspace(ibctransfertypes.ModuleName), - app.ClaimsKeeper, // ICS4 Wrapper: claims IBC middleware + app.RecoveryKeeper, // ICS4 Wrapper: recovery IBC middleware app.IBCKeeper.ChannelKeeper, &app.IBCKeeper.PortKeeper, app.AccountKeeper, app.BankKeeper, scopedTransferKeeper, app.Erc20Keeper, // Add ERC20 Keeper for ERC20 transfers @@ -718,15 +690,12 @@ func NewExocoreApp( ) app.GovKeeper = *govKeeper.SetHooks( - govtypes.NewMultiGovHooks( - app.ClaimsKeeper.Hooks(), - ), + govtypes.NewMultiGovHooks(), ) app.EvmKeeper = app.EvmKeeper.SetHooks( evmkeeper.NewMultiEvmHooks( app.Erc20Keeper.Hooks(), - app.ClaimsKeeper.Hooks(), ), ) @@ -734,7 +703,6 @@ func NewExocoreApp( // Set the ICS4 wrappers for custom module middlewares app.RecoveryKeeper.SetICS4Wrapper(app.IBCKeeper.ChannelKeeper) - app.ClaimsKeeper.SetICS4Wrapper(app.RecoveryKeeper) // Override the ICS20 app module transferModule := transfer.NewAppModule(app.TransferKeeper) @@ -743,7 +711,7 @@ func NewExocoreApp( app.ICAHostKeeper = icahostkeeper.NewKeeper( appCodec, app.keys[icahosttypes.StoreKey], app.GetSubspace(icahosttypes.SubModuleName), - app.ClaimsKeeper, + app.RecoveryKeeper, app.IBCKeeper.ChannelKeeper, &app.IBCKeeper.PortKeeper, app.AccountKeeper, @@ -760,21 +728,19 @@ func NewExocoreApp( transfer stack contains (from bottom to top): - ERC-20 Middleware - Recovery Middleware - - Airdrop Claims Middleware - IBC Transfer SendPacket, since it is originating from the application to core IBC: - transferKeeper.SendPacket -> claim.SendPacket -> recovery.SendPacket -> erc20.SendPacket -> channel.SendPacket + transferKeeper.SendPacket -> recovery.SendPacket -> erc20.SendPacket -> channel.SendPacket RecvPacket, message that originates from core IBC and goes down to app, the flow is the other way - channel.RecvPacket -> erc20.OnRecvPacket -> recovery.OnRecvPacket -> claim.OnRecvPacket -> transfer.OnRecvPacket + channel.RecvPacket -> erc20.OnRecvPacket -> recovery.OnRecvPacket -> transfer.OnRecvPacket */ // create IBC module from top to bottom of stack var transferStack porttypes.IBCModule transferStack = transfer.NewIBCModule(app.TransferKeeper) - transferStack = claims.NewIBCMiddleware(*app.ClaimsKeeper, transferStack) transferStack = recovery.NewIBCMiddleware(*app.RecoveryKeeper, transferStack) transferStack = erc20.NewIBCMiddleware(app.Erc20Keeper, transferStack) @@ -884,8 +850,6 @@ func NewExocoreApp( erc20.NewAppModule(app.Erc20Keeper, app.AccountKeeper, app.GetSubspace(erc20types.ModuleName)), epochs.NewAppModule(appCodec, app.EpochsKeeper), - claims.NewAppModule(appCodec, *app.ClaimsKeeper, - app.GetSubspace(claimstypes.ModuleName)), recovery.NewAppModule(*app.RecoveryKeeper, app.GetSubspace(recoverytypes.ModuleName)), // exoCore app modules @@ -930,7 +894,6 @@ func NewExocoreApp( feegrant.ModuleName, paramstypes.ModuleName, erc20types.ModuleName, - claimstypes.ModuleName, recoverytypes.ModuleName, consensusparamtypes.ModuleName, // ExoCore modules @@ -953,7 +916,6 @@ func NewExocoreApp( // Note: epochs' endblock should be "real" end of epochs, we keep epochs endblock at the // end epochstypes.ModuleName, - claimstypes.ModuleName, // no-op modules ibcexported.ModuleName, ibctransfertypes.ModuleName, @@ -994,8 +956,6 @@ func NewExocoreApp( authtypes.ModuleName, banktypes.ModuleName, distrtypes.ModuleName, - // NOTE: staking requires the claiming hook - claimstypes.ModuleName, stakingtypes.ModuleName, slashingtypes.ModuleName, govtypes.ModuleName, From fc7bd45ec87042fe9996b9d1db29fad599cc317b Mon Sep 17 00:00:00 2001 From: MaxMustermann2 <82761650+MaxMustermann2@users.noreply.github.com> Date: Tue, 26 Mar 2024 16:56:29 +0000 Subject: [PATCH 10/15] chore(lint): shfmt the protocgen script --- scripts/protocgen.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/scripts/protocgen.sh b/scripts/protocgen.sh index 06456795b..75f44a0a5 100755 --- a/scripts/protocgen.sh +++ b/scripts/protocgen.sh @@ -11,13 +11,13 @@ proto_dirs=$(find ./proto -path -prune -o -name '*.proto' -print0 | xargs -0 -n1 #proto_dirs="proto/exocore/reward/v1beta1" #echo $proto_dirs for dir in $proto_dirs; do - proto_files=$(find "${dir}" -maxdepth 3 -name '*.proto') - for file in $proto_files; do - # Check if the go_package in the file is pointing to evmos - if grep -q "option go_package.*exocore" "$file"; then - buf generate --template proto/buf.gen.gogo.yaml "$file" - fi - done + proto_files=$(find "${dir}" -maxdepth 3 -name '*.proto') + for file in $proto_files; do + # Check if the go_package in the file is pointing to evmos + if grep -q "option go_package.*exocore" "$file"; then + buf generate --template proto/buf.gen.gogo.yaml "$file" + fi + done done # move proto files to the right places From 584f6bb20514ce343d3de4b4c11b0d79ff127efd Mon Sep 17 00:00:00 2001 From: MaxMustermann2 <82761650+MaxMustermann2@users.noreply.github.com> Date: Mon, 1 Apr 2024 09:47:14 +0000 Subject: [PATCH 11/15] fix(app): remove distribution and claims modules --- app/app.go | 33 +---- app/export.go | 141 +++------------------ precompiles/delegation/delegation_test.go | 21 ++- precompiles/deposit/deposit_test.go | 12 +- testutil/staking-rewards.go | 148 ---------------------- x/dogfood/keeper/impl_sdk.go | 11 +- x/evm/keeper/precompiles.go | 9 -- x/evm/types/params.go | 3 - x/reward/keeper/claim_reward.go | 10 ++ x/reward/types/errors.go | 1 + 10 files changed, 52 insertions(+), 337 deletions(-) delete mode 100644 testutil/staking-rewards.go diff --git a/app/app.go b/app/app.go index 0dc1343da..8868d3392 100644 --- a/app/app.go +++ b/app/app.go @@ -135,10 +135,6 @@ import ( crisiskeeper "github.com/cosmos/cosmos-sdk/x/crisis/keeper" crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types" - distr "github.com/cosmos/cosmos-sdk/x/distribution" - distrkeeper "github.com/cosmos/cosmos-sdk/x/distribution/keeper" - distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" - "github.com/cosmos/cosmos-sdk/x/evidence" evidencekeeper "github.com/cosmos/cosmos-sdk/x/evidence/keeper" evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types" @@ -239,7 +235,6 @@ var ( bank.AppModuleBasic{}, capability.AppModuleBasic{}, staking.AppModuleBasic{}, - distr.AppModuleBasic{}, gov.NewAppModuleBasic( []govclient.ProposalHandler{ paramsclient.ProposalHandler, upgradeclient.LegacyProposalHandler, upgradeclient.LegacyCancelProposalHandler, @@ -278,7 +273,6 @@ var ( // module account permissions maccPerms = map[string][]string{ authtypes.FeeCollectorName: nil, - distrtypes.ModuleName: nil, stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking}, stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking}, govtypes.ModuleName: {authtypes.Burner}, @@ -324,7 +318,6 @@ type ExocoreApp struct { CapabilityKeeper *capabilitykeeper.Keeper StakingKeeper stakingkeeper.Keeper SlashingKeeper slashingkeeper.Keeper - DistrKeeper distrkeeper.Keeper GovKeeper govkeeper.Keeper CrisisKeeper crisiskeeper.Keeper UpgradeKeeper upgradekeeper.Keeper @@ -419,7 +412,7 @@ func NewExocoreApp( keys := sdk.NewKVStoreKeys( // SDK keys authtypes.StoreKey, banktypes.StoreKey, stakingtypes.StoreKey, - distrtypes.StoreKey, slashingtypes.StoreKey, + slashingtypes.StoreKey, govtypes.StoreKey, paramstypes.StoreKey, upgradetypes.StoreKey, evidencetypes.StoreKey, capabilitytypes.StoreKey, consensusparamtypes.StoreKey, feegrant.StoreKey, authzkeeper.StoreKey, crisistypes.StoreKey, @@ -522,10 +515,6 @@ func NewExocoreApp( appCodec, keys[stakingtypes.StoreKey], accountK, bankK, authAddr, ) app.StakingKeeper = *stakingKeeper - app.DistrKeeper = distrkeeper.NewKeeper( - appCodec, keys[distrtypes.StoreKey], accountK, bankK, - stakingKeeper, authtypes.FeeCollectorName, authAddr, - ) app.SlashingKeeper = slashingkeeper.NewKeeper( appCodec, app.LegacyAmino(), keys[slashingtypes.StoreKey], stakingKeeper, authAddr, ) @@ -599,11 +588,10 @@ func NewExocoreApp( // register the staking hooks // NOTE: stakingKeeper above is passed by reference, so that it will contain these hooks - // NOTE: Distr and Slashing must be created before calling the Hooks method to avoid + // NOTE: Slashing must be created before calling the Hooks method to avoid // returning a Keeper without its table generated stakingKeeper.SetHooks( stakingtypes.NewMultiStakingHooks( - app.DistrKeeper.Hooks(), app.SlashingKeeper.Hooks(), ), ) @@ -670,7 +658,6 @@ func NewExocoreApp( evmKeeper.WithPrecompiles( evmkeeper.AvailablePrecompiles( *stakingKeeper, - app.DistrKeeper, app.AuthzKeeper, app.TransferKeeper, app.IBCKeeper.ChannelKeeper, @@ -801,14 +788,6 @@ func NewExocoreApp( app.StakingKeeper, app.GetSubspace(slashingtypes.ModuleName), ), - distr.NewAppModule( - appCodec, - app.DistrKeeper, - accountK, - bankK, - app.StakingKeeper, - app.GetSubspace(distrtypes.ModuleName), - ), staking.NewAppModule( appCodec, &app.StakingKeeper, @@ -862,7 +841,7 @@ func NewExocoreApp( exoslash.NewAppModule(appCodec, app.ExoSlashKeeper), ) - // During begin block slashing happens after distr.BeginBlocker so that + // During begin block slashing happens after reward.BeginBlocker so that // there is nothing left over in the validator fee pool, to keep the // CanWithdrawInvariant invariant. // NOTE: upgrade module must go first to handle software upgrades. @@ -877,7 +856,6 @@ func NewExocoreApp( epochstypes.ModuleName, feemarkettypes.ModuleName, evmtypes.ModuleName, - distrtypes.ModuleName, slashingtypes.ModuleName, evidencetypes.ModuleName, stakingtypes.ModuleName, @@ -923,7 +901,6 @@ func NewExocoreApp( capabilitytypes.ModuleName, authtypes.ModuleName, banktypes.ModuleName, - distrtypes.ModuleName, slashingtypes.ModuleName, genutiltypes.ModuleName, evidencetypes.ModuleName, @@ -955,7 +932,6 @@ func NewExocoreApp( capabilitytypes.ModuleName, authtypes.ModuleName, banktypes.ModuleName, - distrtypes.ModuleName, stakingtypes.ModuleName, slashingtypes.ModuleName, govtypes.ModuleName, @@ -1076,7 +1052,7 @@ func (app *ExocoreApp) setAnteHandler(txConfig client.TxConfig, maxGasWanted uin ExtensionOptionChecker: evmostypes.HasDynamicFeeExtensionOption, StakingKeeper: app.StakingKeeper, FeegrantKeeper: app.FeeGrantKeeper, - DistributionKeeper: app.DistrKeeper, + DistributionKeeper: app.RewardKeeper, IBCKeeper: app.IBCKeeper, SignModeHandler: txConfig.SignModeHandler(), SigGasConsumer: ante.SigVerificationGasConsumer, @@ -1331,7 +1307,6 @@ func initParamsKeeper( paramsKeeper.Subspace(authtypes.ModuleName) paramsKeeper.Subspace(banktypes.ModuleName) paramsKeeper.Subspace(stakingtypes.ModuleName) - paramsKeeper.Subspace(distrtypes.ModuleName) paramsKeeper.Subspace(slashingtypes.ModuleName) paramsKeeper.Subspace(govtypes.ModuleName). // nolint: staticcheck diff --git a/app/export.go b/app/export.go index 18b6824e7..b71e4fd1c 100644 --- a/app/export.go +++ b/app/export.go @@ -2,7 +2,6 @@ package app import ( "encoding/json" - "fmt" "cosmossdk.io/simapp" @@ -17,7 +16,6 @@ import ( slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" "github.com/cosmos/cosmos-sdk/x/staking" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - claimstypes "github.com/evmos/evmos/v14/x/claims/types" evmtypes "github.com/evmos/evmos/v14/x/evm/types" "github.com/evmos/evmos/v14/encoding" @@ -57,11 +55,11 @@ func NewDefaultGenesisState(cdc codec.Codec) simapp.GenesisState { defaultGenesis[evmtypes.ModuleName] = cdc.MustMarshalJSON(&evmGenesis) // claims module - claimsGenesis := claimstypes.GenesisState{} - rawGenesis = defaultGenesis[claimstypes.ModuleName] - cdc.MustUnmarshalJSON(rawGenesis, &claimsGenesis) - claimsGenesis.Params.ClaimsDenom = utils.BaseDenom - defaultGenesis[claimstypes.ModuleName] = cdc.MustMarshalJSON(&claimsGenesis) + // claimsGenesis := claimstypes.GenesisState{} + // rawGenesis = defaultGenesis[claimstypes.ModuleName] + // cdc.MustUnmarshalJSON(rawGenesis, &claimsGenesis) + // claimsGenesis.Params.ClaimsDenom = utils.BaseDenom + // defaultGenesis[claimstypes.ModuleName] = cdc.MustMarshalJSON(&claimsGenesis) return defaultGenesis } @@ -111,157 +109,50 @@ func (app *ExocoreApp) ExportAppStateAndValidators( // in favor of export at a block height func (app *ExocoreApp) prepForZeroHeightGenesis( ctx sdk.Context, - jailAllowedAddrs []string, + _ []string, ) error { - applyAllowedAddrs := false + // allowedAddrsMap := make(map[string]bool) - // check if there is a allowed address list - if len(jailAllowedAddrs) > 0 { - applyAllowedAddrs = true - } - - allowedAddrsMap := make(map[string]bool) - - for _, addr := range jailAllowedAddrs { - _, err := sdk.ValAddressFromBech32(addr) - if err != nil { - return err - } - allowedAddrsMap[addr] = true - } + // for _, addr := range jailAllowedAddrs { + // _, err := sdk.ValAddressFromBech32(addr) + // if err != nil { + // return err + // } + // allowedAddrsMap[addr] = true + // } /* Just to be safe, assert the invariants on current state. */ app.CrisisKeeper.AssertInvariants(ctx) /* Handle fee distribution state. */ - // withdraw all validator commission - app.StakingKeeper.IterateValidators( - ctx, - func(_ int64, val stakingtypes.ValidatorI) (stop bool) { - _, _ = app.DistrKeeper.WithdrawValidatorCommission(ctx, val.GetOperator()) - return false - }, - ) + // TODO(mm): replace with new reward distribution keeper. // withdraw all delegator rewards - dels := app.StakingKeeper.GetAllDelegations(ctx) - for _, delegation := range dels { - valAddr, err := sdk.ValAddressFromBech32(delegation.ValidatorAddress) - if err != nil { - return err - } - - delAddr, err := sdk.AccAddressFromBech32(delegation.DelegatorAddress) - if err != nil { - return err - } - _, _ = app.DistrKeeper.WithdrawDelegationRewards(ctx, delAddr, valAddr) - } // clear validator slash events - app.DistrKeeper.DeleteAllValidatorSlashEvents(ctx) // clear validator historical rewards - app.DistrKeeper.DeleteAllValidatorHistoricalRewards(ctx) // set context height to zero height := ctx.BlockHeight() ctx = ctx.WithBlockHeight(0) // reinitialize all validators - app.StakingKeeper.IterateValidators( - ctx, - func(_ int64, val stakingtypes.ValidatorI) (stop bool) { - // donate any unwithdrawn outstanding reward fraction tokens to the community pool - scraps := app.DistrKeeper.GetValidatorOutstandingRewardsCoins( - ctx, - val.GetOperator(), - ) - feePool := app.DistrKeeper.GetFeePool(ctx) - feePool.CommunityPool = feePool.CommunityPool.Add(scraps...) - app.DistrKeeper.SetFeePool(ctx, feePool) - - err := app.DistrKeeper.Hooks().AfterValidatorCreated(ctx, val.GetOperator()) - // this lets us stop in case there's an error - return err != nil - }, - ) // reinitialize all delegations - for _, del := range dels { - valAddr, err := sdk.ValAddressFromBech32(del.ValidatorAddress) - if err != nil { - return err - } - delAddr, err := sdk.AccAddressFromBech32(del.DelegatorAddress) - if err != nil { - return err - } - err = app.DistrKeeper.Hooks().BeforeDelegationCreated(ctx, delAddr, valAddr) - if err != nil { - return err - } - err = app.DistrKeeper.Hooks().AfterDelegationModified(ctx, delAddr, valAddr) - if err != nil { - return err - } - } // reset context height ctx = ctx.WithBlockHeight(height) /* Handle staking state. */ - // iterate through redelegations, reset creation height - app.StakingKeeper.IterateRedelegations( - ctx, - func(_ int64, red stakingtypes.Redelegation) (stop bool) { - for i := range red.Entries { - red.Entries[i].CreationHeight = 0 - } - app.StakingKeeper.SetRedelegation(ctx, red) - return false - }, - ) + // not supported: iterate through redelegations, reset creation height // iterate through unbonding delegations, reset creation height - app.StakingKeeper.IterateUnbondingDelegations( - ctx, - func(_ int64, ubd stakingtypes.UnbondingDelegation) (stop bool) { - for i := range ubd.Entries { - ubd.Entries[i].CreationHeight = 0 - } - app.StakingKeeper.SetUnbondingDelegation(ctx, ubd) - return false - }, - ) // Iterate through validators by power descending, reset bond heights, and // update bond intra-tx counters. - store := ctx.KVStore(app.keys[stakingtypes.StoreKey]) - iter := sdk.KVStoreReversePrefixIterator(store, stakingtypes.ValidatorsKey) - counter := int16(0) - - for ; iter.Valid(); iter.Next() { - addr := sdk.ValAddress(iter.Key()[1:]) - validator, found := app.StakingKeeper.GetValidator(ctx, addr) - if !found { - return fmt.Errorf("expected validator %s not found", addr) - } - - validator.UnbondingHeight = 0 - if applyAllowedAddrs && !allowedAddrsMap[addr.String()] { - validator.Jailed = true - } - - app.StakingKeeper.SetValidator(ctx, validator) - counter++ - } - - if err := iter.Close(); err != nil { - return err - } if _, err := app.StakingKeeper.ApplyAndReturnValidatorSetUpdates(ctx); err != nil { return err diff --git a/precompiles/delegation/delegation_test.go b/precompiles/delegation/delegation_test.go index 430e320de..54653992c 100644 --- a/precompiles/delegation/delegation_test.go +++ b/precompiles/delegation/delegation_test.go @@ -18,7 +18,6 @@ import ( "github.com/ethereum/go-ethereum/common" ethtypes "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" - "github.com/evmos/evmos/v14/utils" "github.com/evmos/evmos/v14/x/evm/statedb" evmtypes "github.com/evmos/evmos/v14/x/evm/types" ) @@ -98,11 +97,11 @@ func (s *DelegationPrecompileSuite) TestRunDelegateToThroughClientChain() { } commonMalleate := func() (common.Address, []byte) { // prepare the call input for delegation test - valAddr, err := sdk.ValAddressFromBech32(s.Validators[0].OperatorAddress) - s.Require().NoError(err) - val, _ := s.App.StakingKeeper.GetValidator(s.Ctx, valAddr) - coins := sdk.NewCoins(sdk.NewCoin(utils.BaseDenom, sdk.NewInt(1e18))) - s.App.DistrKeeper.AllocateTokensToValidator(s.Ctx, val, sdk.NewDecCoinsFromCoins(coins...)) + // valAddr, err := sdk.ValAddressFromBech32(s.Validators[0].OperatorAddress) + // s.Require().NoError(err) + // val, _ := s.App.StakingKeeper.GetValidator(s.Ctx, valAddr) + // coins := sdk.NewCoins(sdk.NewCoin(utils.BaseDenom, sdk.NewInt(1e18))) + // s.App.DistrKeeper.AllocateTokensToValidator(s.Ctx, val, sdk.NewDecCoinsFromCoins(coins...)) input, err := s.precompile.Pack( delegation.MethodDelegateToThroughClientChain, uint16(clientChainLzID), @@ -340,11 +339,11 @@ func (s *DelegationPrecompileSuite) TestRunUnDelegateFromThroughClientChain() { } commonMalleate := func() (common.Address, []byte) { // prepare the call input for delegation test - valAddr, err := sdk.ValAddressFromBech32(s.Validators[0].OperatorAddress) - s.Require().NoError(err) - val, _ := s.App.StakingKeeper.GetValidator(s.Ctx, valAddr) - coins := sdk.NewCoins(sdk.NewCoin(utils.BaseDenom, sdk.NewInt(1e18))) - s.App.DistrKeeper.AllocateTokensToValidator(s.Ctx, val, sdk.NewDecCoinsFromCoins(coins...)) + // valAddr, err := sdk.ValAddressFromBech32(s.Validators[0].OperatorAddress) + // s.Require().NoError(err) + // val, _ := s.App.StakingKeeper.GetValidator(s.Ctx, valAddr) + // coins := sdk.NewCoins(sdk.NewCoin(utils.BaseDenom, sdk.NewInt(1e18))) + // s.App.DistrKeeper.AllocateTokensToValidator(s.Ctx, val, sdk.NewDecCoinsFromCoins(coins...)) input, err := s.precompile.Pack( delegation.MethodUndelegateFromThroughClientChain, uint16(clientChainLzID), diff --git a/precompiles/deposit/deposit_test.go b/precompiles/deposit/deposit_test.go index c806d39c8..8a27286e1 100644 --- a/precompiles/deposit/deposit_test.go +++ b/precompiles/deposit/deposit_test.go @@ -7,11 +7,9 @@ import ( "github.com/ExocoreNetwork/exocore/precompiles/deposit" assetstype "github.com/ExocoreNetwork/exocore/x/assets/types" deposittype "github.com/ExocoreNetwork/exocore/x/deposit/types" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/common" ethtypes "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" - "github.com/evmos/evmos/v14/utils" evmtypes "github.com/evmos/evmos/v14/x/evm/types" ) @@ -60,11 +58,11 @@ func (s *DepositPrecompileSuite) TestRunDepositTo() { opAmount := big.NewInt(100) assetAddr := usdtAddress commonMalleate := func() (common.Address, []byte) { - valAddr, err := sdk.ValAddressFromBech32(s.Validators[0].OperatorAddress) - s.Require().NoError(err) - val, _ := s.App.StakingKeeper.GetValidator(s.Ctx, valAddr) - coins := sdk.NewCoins(sdk.NewCoin(utils.BaseDenom, sdk.NewInt(1e18))) - s.App.DistrKeeper.AllocateTokensToValidator(s.Ctx, val, sdk.NewDecCoinsFromCoins(coins...)) + // valAddr, err := sdk.ValAddressFromBech32(s.Validators[0].OperatorAddress) + // s.Require().NoError(err) + // val, _ := s.App.StakingKeeper.GetValidator(s.Ctx, valAddr) + // coins := sdk.NewCoins(sdk.NewCoin(utils.BaseDenom, sdk.NewInt(1e18))) + // s.App.DistrKeeper.AllocateTokensToValidator(s.Ctx, val, sdk.NewDecCoinsFromCoins(coins...)) input, err := s.precompile.Pack( deposit.MethodDepositTo, uint16(clientChainLzID), diff --git a/testutil/staking-rewards.go b/testutil/staking-rewards.go deleted file mode 100644 index ac6cabefa..000000000 --- a/testutil/staking-rewards.go +++ /dev/null @@ -1,148 +0,0 @@ -package testutil - -import ( - "fmt" - "testing" - - sdkmath "cosmossdk.io/math" - "github.com/ExocoreNetwork/exocore/app" - testutiltx "github.com/ExocoreNetwork/exocore/testutil/tx" - "github.com/ExocoreNetwork/exocore/utils" - "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" - cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" - sdk "github.com/cosmos/cosmos-sdk/types" - distributionkeeper "github.com/cosmos/cosmos-sdk/x/distribution/keeper" - distributiontypes "github.com/cosmos/cosmos-sdk/x/distribution/types" - "github.com/cosmos/cosmos-sdk/x/staking" - stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" - teststaking "github.com/cosmos/cosmos-sdk/x/staking/testutil" - stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - "github.com/stretchr/testify/require" -) - -// CreateValidator creates a validator with the provided public key and stake amount -func CreateValidator(ctx sdk.Context, t *testing.T, pubKey cryptotypes.PubKey, sk stakingkeeper.Keeper, stakeAmt sdkmath.Int) { - zeroDec := sdk.ZeroDec() - stakingParams := sk.GetParams(ctx) - stakingParams.BondDenom = sk.BondDenom(ctx) - stakingParams.MinCommissionRate = zeroDec - err := sk.SetParams(ctx, stakingParams) - require.NoError(t, err) - - stakingHelper := teststaking.NewHelper(t, ctx, &sk) - stakingHelper.Commission = stakingtypes.NewCommissionRates(zeroDec, zeroDec, zeroDec) - stakingHelper.Denom = sk.BondDenom(ctx) - - valAddr := sdk.ValAddress(pubKey.Address()) - stakingHelper.CreateValidator(valAddr, pubKey, stakeAmt, true) -} - -// PrepareAccountsForDelegationRewards prepares the test suite for testing to withdraw delegation rewards. -// -// Balance is the amount of tokens that will be left in the account after the setup is done. -// For each defined reward, a validator is created and tokens are allocated to it using the distribution keeper, -// such that the given amount of tokens is outstanding as a staking reward for the account. -// -// The setup is done in the following way: -// - Fund the account with the given Address with the given balance. -// - If the given balance is zero, the account will be created with zero balance. -// -// For every reward defined in the rewards argument, the following steps are executed: -// - Set up a validator with zero commission and delegate to it -> the account delegation will be 50% of the total delegation. -// - Allocate rewards to the validator. -// -// The function returns the updated context along with a potential error. -func PrepareAccountsForDelegationRewards(t *testing.T, ctx sdk.Context, app *app.ExocoreApp, addr sdk.AccAddress, balance sdkmath.Int, rewards ...sdkmath.Int) (sdk.Context, error) { - // Calculate the necessary amount of tokens to fund the account in order for the desired residual balance to - // be left after creating Validators and delegating to them. - totalRewards := sdk.ZeroInt() - for _, reward := range rewards { - totalRewards = totalRewards.Add(reward) - } - totalNeededBalance := balance.Add(totalRewards) - - if totalNeededBalance.IsZero() { - app.AccountKeeper.SetAccount(ctx, app.AccountKeeper.NewAccountWithAddress(ctx, addr)) - } else { - // Fund account with enough tokens to stake them - err := FundAccountWithBaseDenom(ctx, app.BankKeeper, addr, totalNeededBalance.Int64()) - if err != nil { - return sdk.Context{}, fmt.Errorf("failed to fund account: %s", err.Error()) - } - } - - if totalRewards.IsZero() { - return ctx, nil - } - - // reset historical count in distribution keeper which is necessary - // for the delegation rewards to be calculated correctly - app.DistrKeeper.DeleteAllValidatorHistoricalRewards(ctx) - - // set distribution module account balance which pays out the rewards - distrAcc := app.DistrKeeper.GetDistributionAccount(ctx) - err := FundModuleAccount(ctx, app.BankKeeper, distrAcc.GetName(), sdk.NewCoins(sdk.NewCoin(utils.BaseDenom, totalRewards))) - if err != nil { - return sdk.Context{}, fmt.Errorf("failed to fund distribution module account: %s", err.Error()) - } - app.AccountKeeper.SetModuleAccount(ctx, distrAcc) - - for _, reward := range rewards { - if reward.IsZero() { - continue - } - - // Set up validator and delegate to it - privKey := ed25519.GenPrivKey() - addr2, _ := testutiltx.NewAccAddressAndKey() - err := FundAccountWithBaseDenom(ctx, app.BankKeeper, addr2, reward.Int64()) - if err != nil { - return sdk.Context{}, fmt.Errorf("failed to fund validator account: %s", err.Error()) - } - - zeroDec := sdk.ZeroDec() - stakingParams := app.StakingKeeper.GetParams(ctx) - stakingParams.BondDenom = utils.BaseDenom - stakingParams.MinCommissionRate = zeroDec - err = app.StakingKeeper.SetParams(ctx, stakingParams) - require.NoError(t, err) - - stakingHelper := teststaking.NewHelper(t, ctx, &app.StakingKeeper) - stakingHelper.Commission = stakingtypes.NewCommissionRates(zeroDec, zeroDec, zeroDec) - stakingHelper.Denom = utils.BaseDenom - - valAddr := sdk.ValAddress(addr2.Bytes()) - // self-delegate the same amount of tokens as the delegate Address also stakes - // this ensures, that the delegation rewards are 50% of the total rewards - stakingHelper.CreateValidator(valAddr, privKey.PubKey(), reward, true) - stakingHelper.Delegate(addr, valAddr, reward) - - // end block to bond validator and increase block height - // Not using Commit() here because code panics due to invalid block height - staking.EndBlocker(ctx, &app.StakingKeeper) - - // allocate rewards to validator (of these 50% will be paid out to the delegator) - validator := app.StakingKeeper.Validator(ctx, valAddr) - allocatedRewards := sdk.NewDecCoins(sdk.NewDecCoin(utils.BaseDenom, reward.Mul(sdk.NewInt(2)))) - app.DistrKeeper.AllocateTokensToValidator(ctx, validator, allocatedRewards) - } - - return ctx, nil -} - -// GetTotalDelegationRewards returns the total delegation rewards that are currently -// outstanding for the given Address. -func GetTotalDelegationRewards(ctx sdk.Context, distributionKeeper distributionkeeper.Keeper, addr sdk.AccAddress) (sdk.DecCoins, error) { - querier := distributionkeeper.NewQuerier(distributionKeeper) - resp, err := querier.DelegationTotalRewards( - ctx, - &distributiontypes.QueryDelegationTotalRewardsRequest{ - DelegatorAddress: addr.String(), - }, - ) - if err != nil { - return nil, err - } - - return resp.Total, nil -} diff --git a/x/dogfood/keeper/impl_sdk.go b/x/dogfood/keeper/impl_sdk.go index 99e30d259..78a44aafd 100644 --- a/x/dogfood/keeper/impl_sdk.go +++ b/x/dogfood/keeper/impl_sdk.go @@ -13,7 +13,11 @@ import ( // interface guards var ( + // the slashing module is responsible for downtime slashing. it tracks signing info and then + // asks the staking module (dogfood in our case) to slash the operator. _ slashingtypes.StakingKeeper = Keeper{} + // the evidence module is responsible for handling equivocation evidence. it validates the + // evidence and then asks the staking module (dogfood in our case) to slash the operator. _ evidencetypes.StakingKeeper = Keeper{} _ genutiltypes.StakingKeeper = Keeper{} _ clienttypes.StakingKeeper = Keeper{} // implemented in `validators.go` @@ -26,11 +30,8 @@ func (k Keeper) GetParams(sdk.Context) stakingtypes.Params { } // IterateValidators is an implementation of the staking interface expected by the SDK's -// slashing module. The slashing module uses it for two purposes: once at genesis to -// store a mapping of pub key to cons address (which is done by our operator module), -// and then during the invariants check to ensure that the total delegated amount -// matches that of each validator. Ideally, this invariant should be implemented -// by the delegation and/or deposit module(s) instead. +// slashing module. The slashing module uses it at genesis to store a mapping of pub key +// to cons address (which is done by our operator module), func (k Keeper) IterateValidators(sdk.Context, func(index int64, validator stakingtypes.ValidatorI) (stop bool), ) { diff --git a/x/evm/keeper/precompiles.go b/x/evm/keeper/precompiles.go index 6d55cb8a5..1246457ea 100644 --- a/x/evm/keeper/precompiles.go +++ b/x/evm/keeper/precompiles.go @@ -19,12 +19,10 @@ import ( withdrawPrecompile "github.com/ExocoreNetwork/exocore/precompiles/withdraw" exoslashKeeper "github.com/ExocoreNetwork/exocore/x/slash/keeper" authzkeeper "github.com/cosmos/cosmos-sdk/x/authz/keeper" - distributionkeeper "github.com/cosmos/cosmos-sdk/x/distribution/keeper" stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" channelkeeper "github.com/cosmos/ibc-go/v7/modules/core/04-channel/keeper" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/vm" - distprecompile "github.com/evmos/evmos/v14/precompiles/distribution" ics20precompile "github.com/evmos/evmos/v14/precompiles/ics20" stakingprecompile "github.com/evmos/evmos/v14/precompiles/staking" transferkeeper "github.com/evmos/evmos/v14/x/ibc/transfer/keeper" @@ -34,7 +32,6 @@ import ( // NOTE: this should only be used during initialization of the Keeper. func AvailablePrecompiles( stakingKeeper stakingkeeper.Keeper, - distributionKeeper distributionkeeper.Keeper, authzKeeper authzkeeper.Keeper, transferKeeper transferkeeper.Keeper, channelKeeper channelkeeper.Keeper, @@ -53,11 +50,6 @@ func AvailablePrecompiles( panic(fmt.Errorf("failed to load staking precompile: %w", err)) } - distributionPrecompile, err := distprecompile.NewPrecompile(distributionKeeper, authzKeeper) - if err != nil { - panic(fmt.Errorf("failed to load distribution precompile: %w", err)) - } - ibcTransferPrecompile, err := ics20precompile.NewPrecompile( transferKeeper, channelKeeper, @@ -115,7 +107,6 @@ func AvailablePrecompiles( precompiles[delegationPrecompile.Address()] = delegationPrecompile precompiles[stakingPrecompile.Address()] = stakingPrecompile - precompiles[distributionPrecompile.Address()] = distributionPrecompile precompiles[ibcTransferPrecompile.Address()] = ibcTransferPrecompile return precompiles } diff --git a/x/evm/types/params.go b/x/evm/types/params.go index 438f83460..6349ee5ee 100644 --- a/x/evm/types/params.go +++ b/x/evm/types/params.go @@ -11,7 +11,6 @@ var ( DefaultEVMDenom = utils.BaseDenom ExocoreAvailableEVMExtensions = []string{ "0x0000000000000000000000000000000000000800", // Staking precompile - "0x0000000000000000000000000000000000000801", // Distribution precompile "0x0000000000000000000000000000000000000802", // ICS20 transfer precompile "0x0000000000000000000000000000000000000804", // deposit precompile "0x0000000000000000000000000000000000000805", // delegation precompile @@ -23,8 +22,6 @@ var ( // ExocoreEvmDefaultParams returns default evm parameters // ExtraEIPs is empty to prevent overriding the latest hard fork instruction set -// ActivePrecompiles is empty to prevent overriding the default precompiles -// from the EVM configuration. func ExocoreEvmDefaultParams() evmtype.Params { return evmtype.Params{ EvmDenom: DefaultEVMDenom, diff --git a/x/reward/keeper/claim_reward.go b/x/reward/keeper/claim_reward.go index 182b074f8..aa7af650e 100644 --- a/x/reward/keeper/claim_reward.go +++ b/x/reward/keeper/claim_reward.go @@ -149,3 +149,13 @@ func (k Keeper) RewardForWithdraw(ctx sdk.Context, event *RewardParams) error { } return nil } + +// WithdrawDelegationRewards is an implementation of a function in the distribution interface. +// Since this module acts as the distribution module for our network, this function is here. +// When implemented, this function should find the pending (native token) rewards for the +// specified delegator and validator address combination and send them to the delegator address. +func (Keeper) WithdrawDelegationRewards( + sdk.Context, sdk.AccAddress, sdk.ValAddress, +) (sdk.Coins, error) { + return nil, rtypes.ErrNotSupportYet +} diff --git a/x/reward/types/errors.go b/x/reward/types/errors.go index 75688e4d1..320b86b51 100644 --- a/x/reward/types/errors.go +++ b/x/reward/types/errors.go @@ -14,4 +14,5 @@ var ( ErrNoParamsKey = errorsmod.Register(ModuleName, 2, "there is no stored key for params") ErrRewardAmountIsNegative = errorsmod.Register(ModuleName, 3, "the reward amount is negative") ErrRewardAssetNotExist = errorsmod.Register(ModuleName, 4, "the reward asset doesn't exist") + ErrNotSupportYet = errorsmod.Register(ModuleName, 5, "don't have supported it yet") ) From 54c91b5183c1b93564e49a97c571d9a4d22e8fc8 Mon Sep 17 00:00:00 2001 From: MaxMustermann2 <82761650+MaxMustermann2@users.noreply.github.com> Date: Mon, 8 Apr 2024 04:17:25 +0000 Subject: [PATCH 12/15] fix(go): move back to ExocoreNetwork fork --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index ee7f298e9..10244b0c1 100644 --- a/go.mod +++ b/go.mod @@ -220,7 +220,7 @@ replace ( // use Evmos geth fork github.com/ethereum/go-ethereum => github.com/evmos/go-ethereum v1.10.26-evmos-rc2 // use exocore fork of evmos TODO - github.com/evmos/evmos/v14 => github.com/MaxMustermann2/evmos/v14 v14.0.0-20240326155756-4f464426e972 + github.com/evmos/evmos/v14 => github.com/ExocoreNetwork/evmos/v14 v14.1.1-0.20240408040728-a6f685cfebb9 // Security Advisory https://github.com/advisories/GHSA-h395-qcrw-5vmq github.com/gin-gonic/gin => github.com/gin-gonic/gin v1.9.1 // replace broken goleveldb diff --git a/go.sum b/go.sum index 20913de22..3859a78f7 100644 --- a/go.sum +++ b/go.sum @@ -545,10 +545,10 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03 github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d h1:nalkkPQcITbvhmL4+C4cKA87NW0tfm3Kl9VXRoPywFg= github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d/go.mod h1:URdX5+vg25ts3aCh8H5IFZybJYKWhJHYMTnf+ULtoC4= github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= +github.com/ExocoreNetwork/evmos/v14 v14.1.1-0.20240408040728-a6f685cfebb9 h1:/jL9TiINGniPOG2bRfLmyCFSwMy/vFZ1Ta0OoE+xJaE= +github.com/ExocoreNetwork/evmos/v14 v14.1.1-0.20240408040728-a6f685cfebb9/go.mod h1:Hi3CAMxAE+H7Fs7sSHsHKb4DZIURk+trop+mMrjlZqw= github.com/JohnCGriffin/overflow v0.0.0-20211019200055-46fa312c352c/go.mod h1:X0CRv0ky0k6m906ixxpzmDRLvX58TFUKS2eePweuyxk= github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= -github.com/MaxMustermann2/evmos/v14 v14.0.0-20240326155756-4f464426e972 h1:6oBb1Zhtar2hzju1Fv7cZ8mZVJoJ+K5DvbHt/nW0fyU= -github.com/MaxMustermann2/evmos/v14 v14.0.0-20240326155756-4f464426e972/go.mod h1:Hi3CAMxAE+H7Fs7sSHsHKb4DZIURk+trop+mMrjlZqw= github.com/Microsoft/go-winio v0.6.0 h1:slsWYD/zyx7lCXoZVlvQrj0hPTM1HI4+v1sIda2yDvg= github.com/Microsoft/go-winio v0.6.0/go.mod h1:cTAf44im0RAYeL23bpB+fzCyDH2MJiz2BO69KH/soAE= github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 h1:TngWCqHvy9oXAN6lEVMRuU21PR1EtLVZJmdB18Gu3Rw= From d34998c334ba2c8e308a3a34de3ac6a2ded8a2a2 Mon Sep 17 00:00:00 2001 From: MaxMustermann2 <82761650+MaxMustermann2@users.noreply.github.com> Date: Mon, 8 Apr 2024 04:21:14 +0000 Subject: [PATCH 13/15] fix(precompiles): remove unused comments --- app/export.go | 17 +---------------- precompiles/delegation/delegation_test.go | 10 ---------- precompiles/deposit/deposit_test.go | 5 ----- 3 files changed, 1 insertion(+), 31 deletions(-) diff --git a/app/export.go b/app/export.go index b71e4fd1c..ae954fe35 100644 --- a/app/export.go +++ b/app/export.go @@ -54,13 +54,6 @@ func NewDefaultGenesisState(cdc codec.Codec) simapp.GenesisState { evmGenesis.Params.EvmDenom = utils.BaseDenom defaultGenesis[evmtypes.ModuleName] = cdc.MustMarshalJSON(&evmGenesis) - // claims module - // claimsGenesis := claimstypes.GenesisState{} - // rawGenesis = defaultGenesis[claimstypes.ModuleName] - // cdc.MustUnmarshalJSON(rawGenesis, &claimsGenesis) - // claimsGenesis.Params.ClaimsDenom = utils.BaseDenom - // defaultGenesis[claimstypes.ModuleName] = cdc.MustMarshalJSON(&claimsGenesis) - return defaultGenesis } @@ -111,15 +104,7 @@ func (app *ExocoreApp) prepForZeroHeightGenesis( ctx sdk.Context, _ []string, ) error { - // allowedAddrsMap := make(map[string]bool) - - // for _, addr := range jailAllowedAddrs { - // _, err := sdk.ValAddressFromBech32(addr) - // if err != nil { - // return err - // } - // allowedAddrsMap[addr] = true - // } + // TODO: use the []string to mark validators as jailed. /* Just to be safe, assert the invariants on current state. */ app.CrisisKeeper.AssertInvariants(ctx) diff --git a/precompiles/delegation/delegation_test.go b/precompiles/delegation/delegation_test.go index 54653992c..5de668bff 100644 --- a/precompiles/delegation/delegation_test.go +++ b/precompiles/delegation/delegation_test.go @@ -97,11 +97,6 @@ func (s *DelegationPrecompileSuite) TestRunDelegateToThroughClientChain() { } commonMalleate := func() (common.Address, []byte) { // prepare the call input for delegation test - // valAddr, err := sdk.ValAddressFromBech32(s.Validators[0].OperatorAddress) - // s.Require().NoError(err) - // val, _ := s.App.StakingKeeper.GetValidator(s.Ctx, valAddr) - // coins := sdk.NewCoins(sdk.NewCoin(utils.BaseDenom, sdk.NewInt(1e18))) - // s.App.DistrKeeper.AllocateTokensToValidator(s.Ctx, val, sdk.NewDecCoinsFromCoins(coins...)) input, err := s.precompile.Pack( delegation.MethodDelegateToThroughClientChain, uint16(clientChainLzID), @@ -339,11 +334,6 @@ func (s *DelegationPrecompileSuite) TestRunUnDelegateFromThroughClientChain() { } commonMalleate := func() (common.Address, []byte) { // prepare the call input for delegation test - // valAddr, err := sdk.ValAddressFromBech32(s.Validators[0].OperatorAddress) - // s.Require().NoError(err) - // val, _ := s.App.StakingKeeper.GetValidator(s.Ctx, valAddr) - // coins := sdk.NewCoins(sdk.NewCoin(utils.BaseDenom, sdk.NewInt(1e18))) - // s.App.DistrKeeper.AllocateTokensToValidator(s.Ctx, val, sdk.NewDecCoinsFromCoins(coins...)) input, err := s.precompile.Pack( delegation.MethodUndelegateFromThroughClientChain, uint16(clientChainLzID), diff --git a/precompiles/deposit/deposit_test.go b/precompiles/deposit/deposit_test.go index 8a27286e1..8c6296141 100644 --- a/precompiles/deposit/deposit_test.go +++ b/precompiles/deposit/deposit_test.go @@ -58,11 +58,6 @@ func (s *DepositPrecompileSuite) TestRunDepositTo() { opAmount := big.NewInt(100) assetAddr := usdtAddress commonMalleate := func() (common.Address, []byte) { - // valAddr, err := sdk.ValAddressFromBech32(s.Validators[0].OperatorAddress) - // s.Require().NoError(err) - // val, _ := s.App.StakingKeeper.GetValidator(s.Ctx, valAddr) - // coins := sdk.NewCoins(sdk.NewCoin(utils.BaseDenom, sdk.NewInt(1e18))) - // s.App.DistrKeeper.AllocateTokensToValidator(s.Ctx, val, sdk.NewDecCoinsFromCoins(coins...)) input, err := s.precompile.Pack( deposit.MethodDepositTo, uint16(clientChainLzID), From d2c932e290291ae325d4869e83d13f1e262e08da Mon Sep 17 00:00:00 2001 From: MaxMustermann2 <82761650+MaxMustermann2@users.noreply.github.com> Date: Mon, 8 Apr 2024 04:26:08 +0000 Subject: [PATCH 14/15] chore(lint): upgrade net version for vuln --- go.mod | 2 +- go.sum | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 10244b0c1..695e92f2e 100644 --- a/go.mod +++ b/go.mod @@ -52,7 +52,7 @@ require ( github.com/rs/cors v1.9.0 // indirect github.com/tyler-smith/go-bip39 v1.1.0 // indirect github.com/zondax/hid v0.9.1 // indirect - golang.org/x/net v0.22.0 // indirect + golang.org/x/net v0.23.0 // indirect ) require ( diff --git a/go.sum b/go.sum index 3859a78f7..434ff8667 100644 --- a/go.sum +++ b/go.sum @@ -1698,6 +1698,8 @@ golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns= golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= golang.org/x/net v0.22.0 h1:9sGLhx7iRIHEiX0oAJ3MRZMUCElJgy7Br1nO+AMN3Tc= golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= +golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs= +golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= From 45abf4f057cea8f03a324ea72936c779561eaf8f Mon Sep 17 00:00:00 2001 From: MaxMustermann2 <82761650+MaxMustermann2@users.noreply.github.com> Date: Mon, 8 Apr 2024 04:41:25 +0000 Subject: [PATCH 15/15] fix(assets): avoid implicity mem alias with index and do not create a copy. --- x/assets/keeper/genesis.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/x/assets/keeper/genesis.go b/x/assets/keeper/genesis.go index 38363bd4d..2ba95d226 100644 --- a/x/assets/keeper/genesis.go +++ b/x/assets/keeper/genesis.go @@ -10,16 +10,17 @@ func (k Keeper) InitGenesis(ctx sdk.Context, data *types.GenesisState) { if err := k.SetParams(ctx, &data.Params); err != nil { panic(err) } + // TODO(mm): is it possible to optimize / speed up this process? // client_chain.go - for _, infoCopy := range data.ClientChains { - info := infoCopy // prevent implicit memory aliasing + for i := range data.ClientChains { + info := data.ClientChains[i] if err := k.SetClientChainInfo(ctx, &info); err != nil { panic(err) } } // client_chain_asset.go - for _, infoCopy := range data.Tokens { - info := infoCopy // prevent implicit memory aliasing + for i := range data.Tokens { + info := data.Tokens[i] if err := k.SetStakingAssetInfo(ctx, &info); err != nil { panic(err) }