Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

fix(inflation): remove todos #248

Merged
merged 2 commits into from
Oct 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions client/x/evmengine/keeper/abci_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,6 @@ func TestKeeper_PrepareProposal(t *testing.T) {
ak := moduletestutil.NewMockAccountKeeper(ctrl)
esk := moduletestutil.NewMockEvmStakingKeeper(ctrl)
uk := moduletestutil.NewMockUpgradeKeeper(ctrl)
mk := moduletestutil.NewMockMintKeeper(ctrl)
dk := moduletestutil.NewMockDistrKeeper(ctrl)

if tt.setupMocks != nil {
Expand All @@ -232,7 +231,7 @@ func TestKeeper_PrepareProposal(t *testing.T) {
tt.mockEngine.EngineClient, err = ethclient.NewEngineMock(storeKey)
require.NoError(t, err)

k, err := NewKeeper(cdc, storeService, &tt.mockEngine, &tt.mockClient, txConfig, ak, esk, uk, mk, dk)
k, err := NewKeeper(cdc, storeService, &tt.mockEngine, &tt.mockClient, txConfig, ak, esk, uk, dk)
require.NoError(t, err)
k.SetValidatorAddress(common.BytesToAddress([]byte("test")))
populateGenesisHead(ctx, t, k)
Expand Down Expand Up @@ -263,12 +262,11 @@ func TestKeeper_PrepareProposal(t *testing.T) {
ak := moduletestutil.NewMockAccountKeeper(ctrl)
esk := moduletestutil.NewMockEvmStakingKeeper(ctrl)
uk := moduletestutil.NewMockUpgradeKeeper(ctrl)
mk := moduletestutil.NewMockMintKeeper(ctrl)
dk := moduletestutil.NewMockDistrKeeper(ctrl)
// Expected call for PeekEligibleWithdrawals
esk.EXPECT().PeekEligibleWithdrawals(gomock.Any()).Return(nil, nil).AnyTimes()

keeper, err := NewKeeper(cdc, storeService, &mockEngine, mockClient, txConfig, ak, esk, uk, mk, dk)
keeper, err := NewKeeper(cdc, storeService, &mockEngine, mockClient, txConfig, ak, esk, uk, dk)
require.NoError(t, err)
keeper.SetValidatorAddress(common.BytesToAddress([]byte("test")))
populateGenesisHead(ctx, t, keeper)
Expand Down Expand Up @@ -452,7 +450,6 @@ func TestKeeper_PostFinalize(t *testing.T) {
ak := moduletestutil.NewMockAccountKeeper(ctrl)
esk := moduletestutil.NewMockEvmStakingKeeper(ctrl)
uk := moduletestutil.NewMockUpgradeKeeper(ctrl)
mk := moduletestutil.NewMockMintKeeper(ctrl)
dk := moduletestutil.NewMockDistrKeeper(ctrl)

if tt.setupMocks != nil {
Expand All @@ -472,7 +469,7 @@ func TestKeeper_PostFinalize(t *testing.T) {
tt.mockEngine.EngineClient, err = ethclient.NewEngineMock(storeKey)
require.NoError(t, err)

k, err := NewKeeper(cdc, storeService, &tt.mockEngine, &tt.mockClient, txConfig, ak, esk, uk, mk, dk)
k, err := NewKeeper(cdc, storeService, &tt.mockEngine, &tt.mockClient, txConfig, ak, esk, uk, dk)
require.NoError(t, err)
k.SetCometAPI(cmtAPI)
k.SetValidatorAddress(nxtAddr)
Expand Down
3 changes: 0 additions & 3 deletions client/x/evmengine/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ type Keeper struct {
accountKeeper types.AccountKeeper
evmstakingKeeper types.EvmStakingKeeper
upgradeKeeper types.UpgradeKeeper
mintKeeper types.MintKeeper
distrKeeper types.DistrKeeper

upgradeContract *bindings.UpgradeEntrypoint
Expand All @@ -67,7 +66,6 @@ func NewKeeper(
ak types.AccountKeeper,
esk types.EvmStakingKeeper,
uk types.UpgradeKeeper,
mk types.MintKeeper,
dk types.DistrKeeper,
) (*Keeper, error) {
schema := &ormv1alpha1.ModuleSchemaDescriptor{SchemaFile: []*ormv1alpha1.ModuleSchemaDescriptor_FileEntry{
Expand Down Expand Up @@ -105,7 +103,6 @@ func NewKeeper(
upgradeKeeper: uk,
upgradeContract: upgradeContract,
ubiContract: ubiContract,
mintKeeper: mk,
distrKeeper: dk,
}, nil
}
Expand Down
6 changes: 2 additions & 4 deletions client/x/evmengine/keeper/keeper_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,13 @@ func createTestKeeper(t *testing.T) (context.Context, *Keeper) {
ak := moduletestutil.NewMockAccountKeeper(ctrl)
esk := moduletestutil.NewMockEvmStakingKeeper(ctrl)
uk := moduletestutil.NewMockUpgradeKeeper(ctrl)
mk := moduletestutil.NewMockMintKeeper(ctrl)
dk := moduletestutil.NewMockDistrKeeper(ctrl)

ctx, storeKey, storeService := setupCtxStore(t, &header)
mockEngine, err := newMockEngineAPI(storeKey, 0)
require.NoError(t, err)

keeper, err := NewKeeper(cdc, storeService, &mockEngine, mockClient, txConfig, ak, esk, uk, mk, dk)
keeper, err := NewKeeper(cdc, storeService, &mockEngine, mockClient, txConfig, ak, esk, uk, dk)
require.NoError(t, err)
keeper.SetCometAPI(cmtAPI)

Expand All @@ -80,13 +79,12 @@ func createKeeper(t *testing.T, args args) (sdk.Context, *mockCometAPI, *Keeper)
ak := moduletestutil.NewMockAccountKeeper(ctrl)
esk := moduletestutil.NewMockEvmStakingKeeper(ctrl)
uk := moduletestutil.NewMockUpgradeKeeper(ctrl)
mk := moduletestutil.NewMockMintKeeper(ctrl)
dk := moduletestutil.NewMockDistrKeeper(ctrl)

ctx, storeKey, storeService := setupCtxStore(t, &header)
mockEngine, err := newMockEngineAPI(storeKey, 0)
require.NoError(t, err)
keeper, err := NewKeeper(cdc, storeService, &mockEngine, mockClient, txConfig, ak, esk, uk, mk, dk)
keeper, err := NewKeeper(cdc, storeService, &mockEngine, mockClient, txConfig, ak, esk, uk, dk)
require.NoError(t, err)
keeper.SetCometAPI(cmtAPI)
keeper.SetValidatorAddress(nxtAddr)
Expand Down
3 changes: 0 additions & 3 deletions client/x/evmengine/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,6 @@ func (s msgServer) ExecutionPayload(ctx context.Context, msg *types.MsgExecution
if err := s.ProcessUpgradeEvents(ctx, payload.Number-1, msg.PrevPayloadEvents); err != nil {
return nil, errors.Wrap(err, "deliver upgrade-related event logs")
}
if err := s.mintKeeper.ProcessInflationEvents(ctx, payload.Number-1, msg.PrevPayloadEvents); err != nil {
return nil, errors.Wrap(err, "deliver inflation-related event logs")
}
if err := s.ProcessUbiEvents(ctx, payload.Number-1, msg.PrevPayloadEvents); err != nil {
return nil, errors.Wrap(err, "deliver ubi-related event logs")
}
Expand Down
4 changes: 1 addition & 3 deletions client/x/evmengine/keeper/msg_server_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ func Test_msgServer_ExecutionPayload(t *testing.T) {
ak := moduletestutil.NewMockAccountKeeper(ctrl)
esk := moduletestutil.NewMockEvmStakingKeeper(ctrl)
uk := moduletestutil.NewMockUpgradeKeeper(ctrl)
mk := moduletestutil.NewMockMintKeeper(ctrl)
dk := moduletestutil.NewMockDistrKeeper(ctrl)

cmtAPI := newMockCometAPI(t, nil)
Expand All @@ -55,7 +54,7 @@ func Test_msgServer_ExecutionPayload(t *testing.T) {
evmLogProc := mockLogProvider{deliverErr: errors.New("test error")}
mockEngine, err := newMockEngineAPI(storeKey, 2)
require.NoError(t, err)
keeper, err := NewKeeper(cdc, storeService, &mockEngine, mockClient, txConfig, ak, esk, uk, mk, dk)
keeper, err := NewKeeper(cdc, storeService, &mockEngine, mockClient, txConfig, ak, esk, uk, dk)
require.NoError(t, err)
keeper.SetCometAPI(cmtAPI)
keeper.SetValidatorAddress(nxtAddr)
Expand Down Expand Up @@ -101,7 +100,6 @@ func Test_msgServer_ExecutionPayload(t *testing.T) {
setup: func(c context.Context) sdk.Context {
esk.EXPECT().DequeueEligibleWithdrawals(c).Return(nil, nil)
esk.EXPECT().ProcessStakingEvents(c, gomock.Any(), gomock.Any()).Return(nil)
mk.EXPECT().ProcessInflationEvents(c, gomock.Any(), gomock.Any()).Return(nil)

return sdk.UnwrapSDKContext(c)
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,14 @@ func Test_proposalServer_ExecutionPayload(t *testing.T) {
ak := moduletestutil.NewMockAccountKeeper(ctrl)
esk := moduletestutil.NewMockEvmStakingKeeper(ctrl)
uk := moduletestutil.NewMockUpgradeKeeper(ctrl)
mk := moduletestutil.NewMockMintKeeper(ctrl)
dk := moduletestutil.NewMockDistrKeeper(ctrl)
esk.EXPECT().PeekEligibleWithdrawals(gomock.Any()).Return(nil, nil).AnyTimes()

sdkCtx, storeKey, storeService := setupCtxStore(t, &cmtproto.Header{AppHash: tutil.RandomHash().Bytes()})
sdkCtx = sdkCtx.WithExecMode(sdk.ExecModeFinalize)
mockEngine, err := newMockEngineAPI(storeKey, 0)
require.NoError(t, err)
keeper, err := NewKeeper(cdc, storeService, &mockEngine, mockClient, txConfig, ak, esk, uk, mk, dk)
keeper, err := NewKeeper(cdc, storeService, &mockEngine, mockClient, txConfig, ak, esk, uk, dk)
require.NoError(t, err)
populateGenesisHead(sdkCtx, t, keeper)
propSrv := NewProposalServer(keeper)
Expand Down
3 changes: 1 addition & 2 deletions client/x/evmengine/keeper/upgrades_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,14 +262,13 @@ func setupTestEnvironment(t *testing.T) (*Keeper, sdk.Context, *gomock.Controlle
ak := moduletestutil.NewMockAccountKeeper(ctrl)
esk := moduletestutil.NewMockEvmStakingKeeper(ctrl)
uk := moduletestutil.NewMockUpgradeKeeper(ctrl)
mk := moduletestutil.NewMockMintKeeper(ctrl)
dk := moduletestutil.NewMockDistrKeeper(ctrl)

ctx, storeKey, storeService := setupCtxStore(t, &header)
mockEngine, err := newMockEngineAPI(storeKey, 0)
require.NoError(t, err)

keeper, err := NewKeeper(cdc, storeService, &mockEngine, mockClient, txConfig, ak, esk, uk, mk, dk)
keeper, err := NewKeeper(cdc, storeService, &mockEngine, mockClient, txConfig, ak, esk, uk, dk)
require.NoError(t, err)
keeper.SetCometAPI(cmtAPI)
nxtAddr, err := k1util.PubKeyToAddress(cmtAPI.validatorSet.Validators[1].PubKey)
Expand Down
2 changes: 0 additions & 2 deletions client/x/evmengine/module/depinject.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ type ModuleInputs struct {
AccountKeeper types.AccountKeeper
EvmStakingKeeper types.EvmStakingKeeper
UpgradeKeeper types.UpgradeKeeper
MintKeeper types.MintKeeper
DistrKeeper types.DistrKeeper
}

Expand All @@ -58,7 +57,6 @@ func ProvideModule(in ModuleInputs) (ModuleOutputs, error) {
in.AccountKeeper,
in.EvmStakingKeeper,
in.UpgradeKeeper,
in.MintKeeper,
in.DistrKeeper,
)
if err != nil {
Expand Down
41 changes: 4 additions & 37 deletions client/x/evmengine/testutil/expected_keepers_mocks.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions client/x/evmengine/types/expected_keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ type UpgradeKeeper interface {
ScheduleUpgrade(ctx context.Context, plan upgradetypes.Plan) error
}

type MintKeeper interface {
ProcessInflationEvents(ctx context.Context, height uint64, logs []*EVMEvent) error
}

type DistrKeeper interface {
SetUbi(ctx context.Context, newUbi math.LegacyDec) error
}
2 changes: 1 addition & 1 deletion client/x/evmstaking/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func (k Keeper) ProcessStakingEvents(ctx context.Context, height uint64, logs []
// Convert the amount from wei to gwei (Eth2 spec withdrawal is specified in gwei) by dividing by 10^9.
// TODO: consider rounding and decimal precision when dividing bigint.

switch ethlog.Topics[0] { // TODO(rayden): update validator commission
switch ethlog.Topics[0] {
case types.UpdateValidatorCommission.ID:
ev, err := k.ipTokenStakingContract.ParseUpdateValidatorCommssion(ethlog)
if err != nil {
Expand Down
1 change: 0 additions & 1 deletion client/x/evmstaking/keeper/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ func (k Keeper) ProcessCreateValidator(ctx context.Context, ev *bindings.IPToken
skeeperMsgServer := skeeper.NewMsgServerImpl(evmstakingSKeeper)

if _, err = k.stakingKeeper.GetValidator(ctx, validatorAddr); err == nil {
// TODO(rayden): refund
return errors.New("validator already exists")
} else if !errors.Is(err, stypes.ErrNoValidatorFound) {
// Either the validator does not exist, or unknown error.
Expand Down
5 changes: 5 additions & 0 deletions client/x/evmstaking/testutil/expected_keepers_mocks.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion client/x/mint/keeper/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/suite"

"github.com/piplabs/story/client/x/mint/keeper"
mintmodule "github.com/piplabs/story/client/x/mint/module"
minttestutil "github.com/piplabs/story/client/x/mint/testutil"
"github.com/piplabs/story/client/x/mint/types"

"go.uber.org/mock/gomock"
)

var minterAcc = authtypes.NewEmptyModuleAccount(types.ModuleName, authtypes.Minter)
Expand Down
3 changes: 2 additions & 1 deletion client/x/mint/keeper/grpc_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/suite"

"github.com/piplabs/story/client/x/mint/keeper"
mintmodule "github.com/piplabs/story/client/x/mint/module"
minttestutil "github.com/piplabs/story/client/x/mint/testutil"
"github.com/piplabs/story/client/x/mint/types"

"go.uber.org/mock/gomock"
)

type MintTestSuite struct {
Expand Down
Loading
Loading