From d934bbc5cfc5b81adb87f80514711932e181f638 Mon Sep 17 00:00:00 2001 From: ezreal1997 Date: Thu, 17 Oct 2024 13:02:20 -0700 Subject: [PATCH 1/8] feat(x/evmstaking): ubi auto withdraw --- client/x/evmstaking/keeper/abci.go | 36 ++++++ .../testutil/expected_keepers_mocks.go | 122 ++++++++++++++++++ client/x/evmstaking/types/expected_keepers.go | 3 + client/x/evmstaking/types/params.pb.go | 99 ++++++++++---- client/x/evmstaking/types/params.proto | 5 +- go.mod | 2 +- go.sum | 4 +- 7 files changed, 244 insertions(+), 27 deletions(-) diff --git a/client/x/evmstaking/keeper/abci.go b/client/x/evmstaking/keeper/abci.go index a1b222bb..75194ab4 100644 --- a/client/x/evmstaking/keeper/abci.go +++ b/client/x/evmstaking/keeper/abci.go @@ -37,6 +37,42 @@ func (k *Keeper) EndBlock(ctx context.Context) (abci.ValidatorUpdates, error) { return nil, err } + // Check if the ubi balance is enough to be withdrawn. + params, err := k.GetParams(ctx) + if err != nil { + return nil, errors.Wrap(err, "get params") + } + ubiBalance, err := k.distributionKeeper.GetUbiBalanceByDenom(ctx, sdk.DefaultBondDenom) + if err != nil { + return nil, errors.Wrap(err, "get ubi balance by denom") + } + if ubiBalance.Uint64() >= params.MinPartialWithdrawalAmount { + // Withdraw ubi coins to evmstaking module. + ubiCoin, err := k.distributionKeeper.WithdrawUbiByDenomToModule( + ctx, sdk.DefaultBondDenom, types.ModuleName, + ) + if err != nil { + return nil, errors.Wrap(err, "withdraw ubi by denom to module") + } + // Burn tokens from the ubi. + if err = k.bankKeeper.BurnCoins( + ctx, types.ModuleName, + sdk.NewCoins(ubiCoin), + ); err != nil { + return nil, errors.Wrap(err, "burn ubi coins") + } + // Add withdrawal entry to the withdrawal queue. + if err = k.AddWithdrawalToQueue(ctx, types.NewWithdrawal( + uint64(blockHeight), + "", + "", + params.UbiWithdrawAddress, + ubiBalance.Uint64(), + )); err != nil { + return nil, err + } + } + log.Debug(ctx, "Processing mature unbonding delegations", "count", len(unbondedEntries)) for _, entry := range unbondedEntries { diff --git a/client/x/evmstaking/testutil/expected_keepers_mocks.go b/client/x/evmstaking/testutil/expected_keepers_mocks.go index 33924c54..4fbbeea2 100644 --- a/client/x/evmstaking/testutil/expected_keepers_mocks.go +++ b/client/x/evmstaking/testutil/expected_keepers_mocks.go @@ -16,6 +16,7 @@ import ( address "cosmossdk.io/core/address" store "cosmossdk.io/core/store" + math "cosmossdk.io/math" types "github.com/cometbft/cometbft/abci/types" types0 "github.com/cosmos/cosmos-sdk/types" types1 "github.com/cosmos/cosmos-sdk/x/distribution/types" @@ -438,6 +439,22 @@ func (mr *MockStakingKeeperMockRecorder) EndBlocker(ctx any) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "EndBlocker", reflect.TypeOf((*MockStakingKeeper)(nil).EndBlocker), ctx) } +// EndBlockerWithUnbondedEntries mocks base method. +func (m *MockStakingKeeper) EndBlockerWithUnbondedEntries(ctx context.Context) ([]types.ValidatorUpdate, []types2.UnbondedEntry, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "EndBlockerWithUnbondedEntries", ctx) + ret0, _ := ret[0].([]types.ValidatorUpdate) + ret1, _ := ret[1].([]types2.UnbondedEntry) + ret2, _ := ret[2].(error) + return ret0, ret1, ret2 +} + +// EndBlockerWithUnbondedEntries indicates an expected call of EndBlockerWithUnbondedEntries. +func (mr *MockStakingKeeperMockRecorder) EndBlockerWithUnbondedEntries(ctx any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "EndBlockerWithUnbondedEntries", reflect.TypeOf((*MockStakingKeeper)(nil).EndBlockerWithUnbondedEntries), ctx) +} + // GetAllDelegations mocks base method. func (m *MockStakingKeeper) GetAllDelegations(ctx context.Context) ([]types2.Delegation, error) { m.ctrl.T.Helper() @@ -468,6 +485,66 @@ func (mr *MockStakingKeeperMockRecorder) GetAllValidators(ctx any) *gomock.Call return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAllValidators", reflect.TypeOf((*MockStakingKeeper)(nil).GetAllValidators), ctx) } +// GetFlexiblePeriodType mocks base method. +func (m *MockStakingKeeper) GetFlexiblePeriodType(ctx context.Context) (int32, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetFlexiblePeriodType", ctx) + ret0, _ := ret[0].(int32) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetFlexiblePeriodType indicates an expected call of GetFlexiblePeriodType. +func (mr *MockStakingKeeperMockRecorder) GetFlexiblePeriodType(ctx any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetFlexiblePeriodType", reflect.TypeOf((*MockStakingKeeper)(nil).GetFlexiblePeriodType), ctx) +} + +// GetLockedTokenType mocks base method. +func (m *MockStakingKeeper) GetLockedTokenType(ctx context.Context) (int32, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetLockedTokenType", ctx) + ret0, _ := ret[0].(int32) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetLockedTokenType indicates an expected call of GetLockedTokenType. +func (mr *MockStakingKeeperMockRecorder) GetLockedTokenType(ctx any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetLockedTokenType", reflect.TypeOf((*MockStakingKeeper)(nil).GetLockedTokenType), ctx) +} + +// GetPeriodInfo mocks base method. +func (m *MockStakingKeeper) GetPeriodInfo(ctx context.Context, periodType int32) (types2.Period, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetPeriodInfo", ctx, periodType) + ret0, _ := ret[0].(types2.Period) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetPeriodInfo indicates an expected call of GetPeriodInfo. +func (mr *MockStakingKeeperMockRecorder) GetPeriodInfo(ctx, periodType any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetPeriodInfo", reflect.TypeOf((*MockStakingKeeper)(nil).GetPeriodInfo), ctx, periodType) +} + +// GetTokenTypeInfo mocks base method. +func (m *MockStakingKeeper) GetTokenTypeInfo(ctx context.Context, tokenType int32) (types2.TokenTypeInfo, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetTokenTypeInfo", ctx, tokenType) + ret0, _ := ret[0].(types2.TokenTypeInfo) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetTokenTypeInfo indicates an expected call of GetTokenTypeInfo. +func (mr *MockStakingKeeperMockRecorder) GetTokenTypeInfo(ctx, tokenType any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTokenTypeInfo", reflect.TypeOf((*MockStakingKeeper)(nil).GetTokenTypeInfo), ctx, tokenType) +} + // GetUnbondingDelegation mocks base method. func (m *MockStakingKeeper) GetUnbondingDelegation(ctx context.Context, delAddr types0.AccAddress, valAddr types0.ValAddress) (types2.UnbondingDelegation, error) { m.ctrl.T.Helper() @@ -543,6 +620,21 @@ func (mr *MockStakingKeeperMockRecorder) GetValidatorDelegations(ctx, valAddr an return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetValidatorDelegations", reflect.TypeOf((*MockStakingKeeper)(nil).GetValidatorDelegations), ctx, valAddr) } +// MinDelegation mocks base method. +func (m *MockStakingKeeper) MinDelegation(ctx context.Context) (math.Int, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "MinDelegation", ctx) + ret0, _ := ret[0].(math.Int) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// MinDelegation indicates an expected call of MinDelegation. +func (mr *MockStakingKeeperMockRecorder) MinDelegation(ctx any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "MinDelegation", reflect.TypeOf((*MockStakingKeeper)(nil).MinDelegation), ctx) +} + // UBDQueueIterator mocks base method. func (m *MockStakingKeeper) UBDQueueIterator(ctx context.Context, endTime time.Time) (store.Iterator, error) { m.ctrl.T.Helper() @@ -647,6 +739,21 @@ func (mr *MockDistributionKeeperMockRecorder) CalculateDelegationRewards(ctx, va return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CalculateDelegationRewards", reflect.TypeOf((*MockDistributionKeeper)(nil).CalculateDelegationRewards), ctx, val, del, endingPeriod) } +// GetUbiBalanceByDenom mocks base method. +func (m *MockDistributionKeeper) GetUbiBalanceByDenom(ctx context.Context, denom string) (math.Int, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetUbiBalanceByDenom", ctx, denom) + ret0, _ := ret[0].(math.Int) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetUbiBalanceByDenom indicates an expected call of GetUbiBalanceByDenom. +func (mr *MockDistributionKeeperMockRecorder) GetUbiBalanceByDenom(ctx, denom any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetUbiBalanceByDenom", reflect.TypeOf((*MockDistributionKeeper)(nil).GetUbiBalanceByDenom), ctx, denom) +} + // GetValidatorAccumulatedCommission mocks base method. func (m *MockDistributionKeeper) GetValidatorAccumulatedCommission(ctx context.Context, val types0.ValAddress) (types1.ValidatorAccumulatedCommission, error) { m.ctrl.T.Helper() @@ -707,6 +814,21 @@ func (mr *MockDistributionKeeperMockRecorder) WithdrawDelegationRewards(ctx, del return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WithdrawDelegationRewards", reflect.TypeOf((*MockDistributionKeeper)(nil).WithdrawDelegationRewards), ctx, delAddr, valAddr) } +// WithdrawUbiByDenomToModule mocks base method. +func (m *MockDistributionKeeper) WithdrawUbiByDenomToModule(ctx context.Context, denom, recipientModule string) (types0.Coin, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "WithdrawUbiByDenomToModule", ctx, denom, recipientModule) + ret0, _ := ret[0].(types0.Coin) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// WithdrawUbiByDenomToModule indicates an expected call of WithdrawUbiByDenomToModule. +func (mr *MockDistributionKeeperMockRecorder) WithdrawUbiByDenomToModule(ctx, denom, recipientModule any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WithdrawUbiByDenomToModule", reflect.TypeOf((*MockDistributionKeeper)(nil).WithdrawUbiByDenomToModule), ctx, denom, recipientModule) +} + // WithdrawValidatorCommission mocks base method. func (m *MockDistributionKeeper) WithdrawValidatorCommission(ctx context.Context, valAddr types0.ValAddress) (types0.Coins, error) { m.ctrl.T.Helper() diff --git a/client/x/evmstaking/types/expected_keepers.go b/client/x/evmstaking/types/expected_keepers.go index b38e81d3..bdc6e2e1 100644 --- a/client/x/evmstaking/types/expected_keepers.go +++ b/client/x/evmstaking/types/expected_keepers.go @@ -89,4 +89,7 @@ type DistributionKeeper interface { WithdrawValidatorCommission(ctx context.Context, valAddr sdk.ValAddress) (sdk.Coins, error) IncrementValidatorPeriod(ctx context.Context, val stakingtypes.ValidatorI) (uint64, error) + + GetUbiBalanceByDenom(ctx context.Context, denom string) (math.Int, error) + WithdrawUbiByDenomToModule(ctx context.Context, denom string, recipientModule string) (sdk.Coin, error) } diff --git a/client/x/evmstaking/types/params.pb.go b/client/x/evmstaking/types/params.pb.go index ca798f66..162749c0 100644 --- a/client/x/evmstaking/types/params.pb.go +++ b/client/x/evmstaking/types/params.pb.go @@ -29,7 +29,8 @@ type Params struct { MaxSweepPerBlock uint32 `protobuf:"varint,2,opt,name=max_sweep_per_block,json=maxSweepPerBlock,proto3" json:"max_sweep_per_block,omitempty" yaml:"max_sweep_per_block"` MinPartialWithdrawalAmount uint64 `protobuf:"varint,3,opt,name=min_partial_withdrawal_amount,json=minPartialWithdrawalAmount,proto3" json:"min_partial_withdrawal_amount,omitempty" yaml:"min_partial_withdrawal_amount"` // the block height until singularity is activated - SingularityHeight uint64 `protobuf:"varint,4,opt,name=singularity_height,json=singularityHeight,proto3" json:"singularity_height,omitempty" yaml:"singularity_height"` + SingularityHeight uint64 `protobuf:"varint,4,opt,name=singularity_height,json=singularityHeight,proto3" json:"singularity_height,omitempty" yaml:"singularity_height"` + UbiWithdrawAddress string `protobuf:"bytes,5,opt,name=ubi_withdraw_address,json=ubiWithdrawAddress,proto3" json:"ubi_withdraw_address,omitempty" yaml:"ubi_withdraw_address"` } func (m *Params) Reset() { *m = Params{} } @@ -93,6 +94,13 @@ func (m *Params) GetSingularityHeight() uint64 { return 0 } +func (m *Params) GetUbiWithdrawAddress() string { + if m != nil { + return m.UbiWithdrawAddress + } + return "" +} + func init() { proto.RegisterType((*Params)(nil), "client.x.evmstaking.types.Params") } @@ -102,28 +110,30 @@ func init() { } var fileDescriptor_dddf03d6f1b350f8 = []byte{ - // 328 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x91, 0xcd, 0x4a, 0xf3, 0x40, - 0x14, 0x86, 0x9b, 0x7e, 0xa5, 0x8b, 0xc0, 0x07, 0x1a, 0x15, 0xd2, 0x42, 0x27, 0x25, 0x8a, 0x74, - 0x95, 0x2c, 0xba, 0x73, 0x67, 0x56, 0x2e, 0x14, 0x4a, 0x5c, 0x08, 0x22, 0x84, 0xd3, 0x3a, 0xa4, - 0x43, 0xe7, 0x8f, 0xc9, 0xd4, 0xa6, 0x77, 0xe1, 0x65, 0xb9, 0xec, 0xd2, 0x55, 0x90, 0xf6, 0x06, - 0x24, 0x57, 0x20, 0x99, 0x48, 0x5b, 0x94, 0xba, 0x1b, 0xde, 0xf7, 0x99, 0xe7, 0x1c, 0x38, 0xf6, - 0xe5, 0x84, 0x12, 0xcc, 0x75, 0x98, 0x87, 0xf8, 0x85, 0x65, 0x1a, 0x66, 0x84, 0xa7, 0xa1, 0x5e, - 0x4a, 0x9c, 0x85, 0x12, 0x14, 0xb0, 0x2c, 0x90, 0x4a, 0x68, 0xe1, 0x74, 0x6a, 0x2e, 0xc8, 0x83, - 0x1d, 0x17, 0x18, 0xae, 0x7b, 0x9a, 0x8a, 0x54, 0x18, 0x2a, 0xac, 0x5e, 0xf5, 0x07, 0xff, 0xb3, - 0x69, 0xb7, 0x47, 0xc6, 0xe0, 0x3c, 0xd9, 0x2e, 0x83, 0x3c, 0x59, 0x10, 0x3d, 0x7d, 0x56, 0xb0, - 0x00, 0x9a, 0x48, 0xac, 0x92, 0x31, 0x15, 0x93, 0x99, 0x6b, 0xf5, 0xad, 0xc1, 0xff, 0xe8, 0xbc, - 0x2c, 0x3c, 0x6f, 0x09, 0x8c, 0x5e, 0xf9, 0x87, 0x48, 0x3f, 0x3e, 0x63, 0x90, 0x3f, 0x6c, 0x9b, - 0x11, 0x56, 0x51, 0x95, 0x3b, 0x77, 0xf6, 0x49, 0xf5, 0x27, 0x5b, 0x60, 0x2c, 0xf7, 0xc4, 0x4d, - 0x23, 0x46, 0x65, 0xe1, 0x75, 0x77, 0xe2, 0x1f, 0x90, 0x1f, 0x1f, 0x31, 0xc8, 0xef, 0xab, 0x70, - 0xab, 0x9b, 0xd9, 0x3d, 0x46, 0x78, 0x22, 0x41, 0x69, 0x02, 0x74, 0x7f, 0x15, 0x60, 0x62, 0xce, - 0xb5, 0xfb, 0xaf, 0x6f, 0x0d, 0x5a, 0xd1, 0xa0, 0x2c, 0xbc, 0x8b, 0x6f, 0xf1, 0x5f, 0xb8, 0x1f, - 0x77, 0x19, 0xe1, 0xa3, 0xba, 0xde, 0x6d, 0x7f, 0x6d, 0x4a, 0xe7, 0xd6, 0x76, 0x32, 0xc2, 0xd3, - 0x39, 0x05, 0x45, 0xf4, 0x32, 0x99, 0x62, 0x92, 0x4e, 0xb5, 0xdb, 0x32, 0x13, 0x7a, 0x65, 0xe1, - 0x75, 0xea, 0x09, 0xbf, 0x19, 0x3f, 0x3e, 0xde, 0x0b, 0x6f, 0x4c, 0x16, 0x0d, 0xdf, 0xd6, 0xc8, - 0x5a, 0xad, 0x91, 0xf5, 0xb1, 0x46, 0xd6, 0xeb, 0x06, 0x35, 0x56, 0x1b, 0xd4, 0x78, 0xdf, 0xa0, - 0xc6, 0x63, 0xe7, 0xe0, 0x95, 0xc7, 0x6d, 0x73, 0xae, 0xe1, 0x57, 0x00, 0x00, 0x00, 0xff, 0xff, - 0x78, 0x93, 0xa8, 0x7a, 0x09, 0x02, 0x00, 0x00, + // 365 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x92, 0xb1, 0x4a, 0xc3, 0x40, + 0x18, 0xc7, 0x1b, 0x5b, 0x0b, 0x06, 0x04, 0x8d, 0x15, 0xd2, 0x4a, 0x93, 0x12, 0x45, 0x32, 0x25, + 0x43, 0x37, 0xb7, 0x66, 0x72, 0x50, 0xa8, 0x71, 0x10, 0x44, 0x08, 0x5f, 0xda, 0x23, 0x3d, 0x9a, + 0x4b, 0xc2, 0xdd, 0xc5, 0xa6, 0x6f, 0xe1, 0x3b, 0xb9, 0x38, 0x76, 0x74, 0x0a, 0xd2, 0xbe, 0x41, + 0x9e, 0x40, 0x72, 0xd1, 0xb6, 0xa8, 0x75, 0x3b, 0xfe, 0xdf, 0xef, 0x7e, 0xdf, 0x7f, 0xf8, 0xe4, + 0xcb, 0x51, 0x88, 0x51, 0xc4, 0xed, 0xcc, 0x46, 0xcf, 0x84, 0x71, 0x98, 0xe2, 0x28, 0xb0, 0xf9, + 0x3c, 0x41, 0xcc, 0x4e, 0x80, 0x02, 0x61, 0x56, 0x42, 0x63, 0x1e, 0x2b, 0xed, 0x8a, 0xb3, 0x32, + 0x6b, 0xc3, 0x59, 0x82, 0xeb, 0xb4, 0x82, 0x38, 0x88, 0x05, 0x65, 0x97, 0xaf, 0xea, 0x83, 0xf1, + 0x5a, 0x97, 0x9b, 0x43, 0x61, 0x50, 0x9e, 0x64, 0x95, 0x40, 0xe6, 0xcd, 0x30, 0x9f, 0x8c, 0x29, + 0xcc, 0x20, 0xf4, 0x12, 0x44, 0x3d, 0x3f, 0x8c, 0x47, 0x53, 0x55, 0xea, 0x49, 0xe6, 0xa1, 0x73, + 0x5e, 0xe4, 0xba, 0x3e, 0x07, 0x12, 0x5e, 0x19, 0xbb, 0x48, 0xc3, 0x3d, 0x25, 0x90, 0x3d, 0xac, + 0x27, 0x43, 0x44, 0x9d, 0x32, 0x57, 0x6e, 0xe5, 0x93, 0xf2, 0x0f, 0x9b, 0x21, 0x94, 0x6c, 0x89, + 0xf7, 0x84, 0x58, 0x2b, 0x72, 0xbd, 0xb3, 0x11, 0xff, 0x80, 0x0c, 0xf7, 0x88, 0x40, 0x76, 0x5f, + 0x86, 0x6b, 0xdd, 0x54, 0xee, 0x12, 0x1c, 0x79, 0x09, 0x50, 0x8e, 0x21, 0xdc, 0xae, 0x02, 0x24, + 0x4e, 0x23, 0xae, 0xd6, 0x7b, 0x92, 0xd9, 0x70, 0xcc, 0x22, 0xd7, 0x2f, 0xbe, 0xc4, 0xff, 0xe1, + 0x86, 0xdb, 0x21, 0x38, 0x1a, 0x56, 0xe3, 0x4d, 0xfb, 0x81, 0x18, 0x2a, 0x37, 0xb2, 0xc2, 0x70, + 0x14, 0xa4, 0x21, 0x50, 0xcc, 0xe7, 0xde, 0x04, 0xe1, 0x60, 0xc2, 0xd5, 0x86, 0xd8, 0xd0, 0x2d, + 0x72, 0xbd, 0x5d, 0x6d, 0xf8, 0xcd, 0x18, 0xee, 0xf1, 0x56, 0x78, 0x2d, 0x32, 0xe5, 0x4e, 0x6e, + 0xa5, 0x3e, 0x5e, 0x77, 0xf0, 0x60, 0x3c, 0xa6, 0x88, 0x31, 0x75, 0xbf, 0x27, 0x99, 0x07, 0x8e, + 0x5e, 0xe4, 0xfa, 0x59, 0xe5, 0xfb, 0x8b, 0x32, 0x5c, 0x25, 0xf5, 0xf1, 0x77, 0xc3, 0x41, 0x15, + 0x3a, 0xfd, 0xb7, 0xa5, 0x26, 0x2d, 0x96, 0x9a, 0xf4, 0xb1, 0xd4, 0xa4, 0x97, 0x95, 0x56, 0x5b, + 0xac, 0xb4, 0xda, 0xfb, 0x4a, 0xab, 0x3d, 0xb6, 0x77, 0x1e, 0x8e, 0xdf, 0x14, 0x17, 0xd0, 0xff, + 0x0c, 0x00, 0x00, 0xff, 0xff, 0x6e, 0xcc, 0x76, 0x0b, 0x5c, 0x02, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -146,6 +156,13 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.UbiWithdrawAddress) > 0 { + i -= len(m.UbiWithdrawAddress) + copy(dAtA[i:], m.UbiWithdrawAddress) + i = encodeVarintParams(dAtA, i, uint64(len(m.UbiWithdrawAddress))) + i-- + dAtA[i] = 0x2a + } if m.SingularityHeight != 0 { i = encodeVarintParams(dAtA, i, uint64(m.SingularityHeight)) i-- @@ -198,6 +215,10 @@ func (m *Params) Size() (n int) { if m.SingularityHeight != 0 { n += 1 + sovParams(uint64(m.SingularityHeight)) } + l = len(m.UbiWithdrawAddress) + if l > 0 { + n += 1 + l + sovParams(uint64(l)) + } return n } @@ -312,6 +333,38 @@ func (m *Params) Unmarshal(dAtA []byte) error { break } } + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field UbiWithdrawAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.UbiWithdrawAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipParams(dAtA[iNdEx:]) diff --git a/client/x/evmstaking/types/params.proto b/client/x/evmstaking/types/params.proto index e92f77d7..44b6e999 100644 --- a/client/x/evmstaking/types/params.proto +++ b/client/x/evmstaking/types/params.proto @@ -20,4 +20,7 @@ message Params { uint64 singularity_height = 4 [ (gogoproto.moretags) = "yaml:\"singularity_height\"" ]; -} \ No newline at end of file + string ubi_withdraw_address = 5 [ + (gogoproto.moretags) = "yaml:\"ubi_withdraw_address\"" + ]; +} diff --git a/go.mod b/go.mod index cec8540c..f593bb8c 100644 --- a/go.mod +++ b/go.mod @@ -295,7 +295,7 @@ replace ( cosmossdk.io/core v0.12.0 => cosmossdk.io/core v0.11.0 // Direct cosmos-sdk branch link: https://github.com/piplabs/cosmos-sdk/tree/piplabs/v0.50.7, current branch: piplabs/v0.50.7 - github.com/cosmos/cosmos-sdk => github.com/piplabs/cosmos-sdk v0.50.7-piplabs-v0.6 + github.com/cosmos/cosmos-sdk => github.com/piplabs/cosmos-sdk v0.50.7-piplabs-v0.7 // See https://github.com/cosmos/cosmos-sdk/pull/14952 // Also https://github.com/cosmos/cosmos-db/blob/main/go.mod#L11-L12 diff --git a/go.sum b/go.sum index c8c702d6..2fd1ed8c 100644 --- a/go.sum +++ b/go.sum @@ -1032,8 +1032,8 @@ github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0 github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4= github.com/pingcap/errors v0.11.4/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8= -github.com/piplabs/cosmos-sdk v0.50.7-piplabs-v0.6 h1:MmAiOqWneV3j1pbWS4t3oUyhUxkysIt0RkJ5MX83Mdw= -github.com/piplabs/cosmos-sdk v0.50.7-piplabs-v0.6/go.mod h1:84xDDJEHttRT7NDGwBaUOLVOMN0JNE9x7NbsYIxXs1s= +github.com/piplabs/cosmos-sdk v0.50.7-piplabs-v0.7 h1:gHKPCEoP7dj2jiA9htL/GVLrx+EshZ5yDd8hBdIkDSY= +github.com/piplabs/cosmos-sdk v0.50.7-piplabs-v0.7/go.mod h1:84xDDJEHttRT7NDGwBaUOLVOMN0JNE9x7NbsYIxXs1s= github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ= github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU= github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= From a6cc51e4c47e4f0c10056cc5bc88b2d1cf43d468 Mon Sep 17 00:00:00 2001 From: ezreal1997 Date: Thu, 17 Oct 2024 15:08:17 -0700 Subject: [PATCH 2/8] feat(x/evmstaking): add ubi withdraw --- client/x/evmstaking/keeper/abci.go | 90 ++------------------------ client/x/evmstaking/keeper/ubi.go | 56 ++++++++++++++++ client/x/evmstaking/keeper/withdraw.go | 48 ++++++++++++++ 3 files changed, 110 insertions(+), 84 deletions(-) create mode 100644 client/x/evmstaking/keeper/ubi.go diff --git a/client/x/evmstaking/keeper/abci.go b/client/x/evmstaking/keeper/abci.go index 75194ab4..48cc8059 100644 --- a/client/x/evmstaking/keeper/abci.go +++ b/client/x/evmstaking/keeper/abci.go @@ -6,7 +6,6 @@ import ( abci "github.com/cometbft/cometbft/abci/types" "github.com/cosmos/cosmos-sdk/telemetry" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/piplabs/story/client/x/evmstaking/types" "github.com/piplabs/story/lib/errors" @@ -20,14 +19,10 @@ func (k *Keeper) EndBlock(ctx context.Context) (abci.ValidatorUpdates, error) { log.Debug(ctx, "EndBlock.evmstaking") defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), telemetry.MetricKeyEndBlocker) - sdkCtx := sdk.UnwrapSDKContext(ctx) - blockHeight := sdkCtx.BlockHeader().Height - isSingularity, err := k.IsSingularity(ctx) if err != nil { return nil, err } - if isSingularity { return nil, nil } @@ -36,85 +31,8 @@ func (k *Keeper) EndBlock(ctx context.Context) (abci.ValidatorUpdates, error) { if err != nil { return nil, err } - - // Check if the ubi balance is enough to be withdrawn. - params, err := k.GetParams(ctx) - if err != nil { - return nil, errors.Wrap(err, "get params") - } - ubiBalance, err := k.distributionKeeper.GetUbiBalanceByDenom(ctx, sdk.DefaultBondDenom) - if err != nil { - return nil, errors.Wrap(err, "get ubi balance by denom") - } - if ubiBalance.Uint64() >= params.MinPartialWithdrawalAmount { - // Withdraw ubi coins to evmstaking module. - ubiCoin, err := k.distributionKeeper.WithdrawUbiByDenomToModule( - ctx, sdk.DefaultBondDenom, types.ModuleName, - ) - if err != nil { - return nil, errors.Wrap(err, "withdraw ubi by denom to module") - } - // Burn tokens from the ubi. - if err = k.bankKeeper.BurnCoins( - ctx, types.ModuleName, - sdk.NewCoins(ubiCoin), - ); err != nil { - return nil, errors.Wrap(err, "burn ubi coins") - } - // Add withdrawal entry to the withdrawal queue. - if err = k.AddWithdrawalToQueue(ctx, types.NewWithdrawal( - uint64(blockHeight), - "", - "", - params.UbiWithdrawAddress, - ubiBalance.Uint64(), - )); err != nil { - return nil, err - } - } - - log.Debug(ctx, "Processing mature unbonding delegations", "count", len(unbondedEntries)) - - for _, entry := range unbondedEntries { - delegatorAddr, err := k.authKeeper.AddressCodec().StringToBytes(entry.DelegatorAddress) - if err != nil { - return nil, errors.Wrap(err, "delegator address from bech32") - } - - log.Debug(ctx, "Adding undelegation to withdrawal queue", - "delegator", entry.DelegatorAddress, - "validator", entry.ValidatorAddress, - "amount", entry.Amount.String()) - - // Burn tokens from the delegator - _, coins := IPTokenToBondCoin(entry.Amount.BigInt()) - err = k.bankKeeper.SendCoinsFromAccountToModule(ctx, delegatorAddr, types.ModuleName, coins) - if err != nil { - return nil, errors.Wrap(err, "send coins from account to module") - } - err = k.bankKeeper.BurnCoins(ctx, types.ModuleName, coins) - if err != nil { - return nil, errors.Wrap(err, "burn coins") - } - - // This should not produce error, as all delegations are done via the evmstaking module via EL. - // However, we should gracefully handle in case Get fails. - delEvmAddr, err := k.DelegatorWithdrawAddress.Get(ctx, entry.DelegatorAddress) - if err != nil { - return nil, errors.Wrap(err, "map delegator pubkey to evm address") - } - - // push the undelegation to the withdrawal queue - err = k.AddWithdrawalToQueue(ctx, types.NewWithdrawal( - uint64(blockHeight), - entry.DelegatorAddress, - entry.ValidatorAddress, - delEvmAddr, - entry.Amount.Uint64(), - )) - if err != nil { - return nil, err - } + if err := k.ProcessUnbondingWithdrawals(ctx, unbondedEntries); err != nil { + return nil, err } partialWithdrawals, err := k.ExpectedPartialWithdrawals(ctx) @@ -125,5 +43,9 @@ func (k *Keeper) EndBlock(ctx context.Context) (abci.ValidatorUpdates, error) { return nil, err } + if err := k.ProcessUbiWithdrawal(ctx); err != nil { + return nil, errors.Wrap(err, "process ubi withdrawal") + } + return valUpdates, nil } diff --git a/client/x/evmstaking/keeper/ubi.go b/client/x/evmstaking/keeper/ubi.go new file mode 100644 index 00000000..efe5b2b0 --- /dev/null +++ b/client/x/evmstaking/keeper/ubi.go @@ -0,0 +1,56 @@ +package keeper + +import ( + "context" + + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/piplabs/story/client/x/evmstaking/types" + "github.com/piplabs/story/lib/errors" + "github.com/piplabs/story/lib/log" +) + +func (k Keeper) ProcessUbiWithdrawal(ctx context.Context) error { + log.Debug(ctx, "Processing eligible ubi withdraw") + + params, err := k.GetParams(ctx) + if err != nil { + return errors.Wrap(err, "get ubi params") + } + ubiBalance, err := k.distributionKeeper.GetUbiBalanceByDenom(ctx, sdk.DefaultBondDenom) + if err != nil { + return errors.Wrap(err, "get ubi balance by denom") + } + + if ubiBalance.Uint64() < params.MinPartialWithdrawalAmount { + return nil + } + + // Withdraw and burn ubi coins. + ubiCoin, err := k.distributionKeeper.WithdrawUbiByDenomToModule( + ctx, sdk.DefaultBondDenom, types.ModuleName, + ) + if err != nil { + return errors.Wrap(err, "withdraw ubi by denom to module") + } + // Burn tokens from the ubi. + if err = k.bankKeeper.BurnCoins( + ctx, types.ModuleName, + sdk.NewCoins(ubiCoin), + ); err != nil { + return errors.Wrap(err, "burn ubi coins") + } + + // Add withdrawal entry to the withdrawal queue. + if err = k.AddWithdrawalToQueue(ctx, types.NewWithdrawal( + uint64(sdk.UnwrapSDKContext(ctx).BlockHeight()), + "", + "", + params.UbiWithdrawAddress, + ubiBalance.Uint64(), + )); err != nil { + return errors.Wrap(err, "add ubi withdrawal to queue") + } + + return nil +} diff --git a/client/x/evmstaking/keeper/withdraw.go b/client/x/evmstaking/keeper/withdraw.go index c21222aa..464d253e 100644 --- a/client/x/evmstaking/keeper/withdraw.go +++ b/client/x/evmstaking/keeper/withdraw.go @@ -19,6 +19,54 @@ import ( "github.com/piplabs/story/lib/promutil" ) +func (k Keeper) ProcessUnbondingWithdrawals(ctx context.Context, unbondedEntries []stypes.UnbondedEntry) error { + log.Debug(ctx, "Processing mature unbonding delegations", "count", len(unbondedEntries)) + + for _, entry := range unbondedEntries { + delegatorAddr, err := k.authKeeper.AddressCodec().StringToBytes(entry.DelegatorAddress) + if err != nil { + return errors.Wrap(err, "delegator address from bech32") + } + + log.Debug(ctx, "Adding undelegation to withdrawal queue", + "delegator", entry.DelegatorAddress, + "validator", entry.ValidatorAddress, + "amount", entry.Amount.String()) + + // Burn tokens from the delegator + _, coins := IPTokenToBondCoin(entry.Amount.BigInt()) + err = k.bankKeeper.SendCoinsFromAccountToModule(ctx, delegatorAddr, estypes.ModuleName, coins) + if err != nil { + return errors.Wrap(err, "send coins from account to module") + } + err = k.bankKeeper.BurnCoins(ctx, estypes.ModuleName, coins) + if err != nil { + return errors.Wrap(err, "burn coins") + } + + // This should not produce error, as all delegations are done via the evmstaking module via EL. + // However, we should gracefully handle in case Get fails. + delEvmAddr, err := k.DelegatorWithdrawAddress.Get(ctx, entry.DelegatorAddress) + if err != nil { + return errors.Wrap(err, "map delegator pubkey to evm address") + } + + // push the undelegation to the withdrawal queue + err = k.AddWithdrawalToQueue(ctx, estypes.NewWithdrawal( + uint64(sdk.UnwrapSDKContext(ctx).BlockHeight()), + entry.DelegatorAddress, + entry.ValidatorAddress, + delEvmAddr, + entry.Amount.Uint64(), + )) + if err != nil { + return errors.Wrap(err, "add unbonding withdrawal to queue") + } + } + + return nil +} + func (k Keeper) ExpectedPartialWithdrawals(ctx context.Context) ([]estypes.Withdrawal, error) { nextValIndex, nextValDelIndex, err := k.GetValidatorSweepIndex(ctx) if err != nil { From e262ae628a6180e818b1f4c52fc7831b8b69450c Mon Sep 17 00:00:00 2001 From: ezreal1997 Date: Thu, 17 Oct 2024 15:37:57 -0700 Subject: [PATCH 3/8] feat(x/evmstaking): add ubi withdraw --- client/x/evmstaking/keeper/abci.go | 13 +- client/x/evmstaking/keeper/grpc_query.go | 2 - client/x/evmstaking/keeper/grpc_query_test.go | 6 +- client/x/evmstaking/keeper/keeper_test.go | 2 - client/x/evmstaking/keeper/msg_server.go | 93 -- client/x/evmstaking/keeper/msg_server_test.go | 136 -- client/x/evmstaking/keeper/ubi.go | 2 - client/x/evmstaking/keeper/withdraw.go | 63 +- .../keeper/withdrawal_queue_test.go | 8 +- client/x/evmstaking/module/module.go | 1 - client/x/evmstaking/types/codec.go | 16 +- client/x/evmstaking/types/evmstaking.pb.go | 132 +- client/x/evmstaking/types/evmstaking.proto | 12 +- client/x/evmstaking/types/tx.pb.go | 1142 ----------------- client/x/evmstaking/types/tx.proto | 44 - client/x/evmstaking/types/withdraw.go | 14 +- client/x/evmstaking/types/withdraw_test.go | 41 +- 17 files changed, 91 insertions(+), 1636 deletions(-) delete mode 100644 client/x/evmstaking/keeper/msg_server.go delete mode 100644 client/x/evmstaking/keeper/msg_server_test.go delete mode 100644 client/x/evmstaking/types/tx.pb.go delete mode 100644 client/x/evmstaking/types/tx.proto diff --git a/client/x/evmstaking/keeper/abci.go b/client/x/evmstaking/keeper/abci.go index 48cc8059..cd11457e 100644 --- a/client/x/evmstaking/keeper/abci.go +++ b/client/x/evmstaking/keeper/abci.go @@ -29,18 +29,15 @@ func (k *Keeper) EndBlock(ctx context.Context) (abci.ValidatorUpdates, error) { valUpdates, unbondedEntries, err := k.stakingKeeper.EndBlockerWithUnbondedEntries(ctx) if err != nil { - return nil, err + return nil, errors.Wrap(err, "process staking EndBlocker") } + if err := k.ProcessUnbondingWithdrawals(ctx, unbondedEntries); err != nil { - return nil, err + return nil, errors.Wrap(err, "process unbonding withdrawals") } - partialWithdrawals, err := k.ExpectedPartialWithdrawals(ctx) - if err != nil { - return nil, err - } - if err := k.EnqueueEligiblePartialWithdrawal(ctx, partialWithdrawals); err != nil { - return nil, err + if err := k.ProcessRewardWithdrawals(ctx); err != nil { + return nil, errors.Wrap(err, "process reward withdrawals") } if err := k.ProcessUbiWithdrawal(ctx); err != nil { diff --git a/client/x/evmstaking/keeper/grpc_query.go b/client/x/evmstaking/keeper/grpc_query.go index 7b1b13f2..50b324e8 100644 --- a/client/x/evmstaking/keeper/grpc_query.go +++ b/client/x/evmstaking/keeper/grpc_query.go @@ -53,8 +53,6 @@ func (k Keeper) GetWithdrawalQueue(ctx context.Context, request *types.QueryGetW for _, w := range withdrawals { ws = append(ws, &types.Withdrawal{ CreationHeight: w.CreationHeight, - DelegatorAddress: w.DelegatorAddress, - ValidatorAddress: w.ValidatorAddress, ExecutionAddress: w.ExecutionAddress, Amount: w.Amount, }) diff --git a/client/x/evmstaking/keeper/grpc_query_test.go b/client/x/evmstaking/keeper/grpc_query_test.go index 25d15a12..c8b37c67 100644 --- a/client/x/evmstaking/keeper/grpc_query_test.go +++ b/client/x/evmstaking/keeper/grpc_query_test.go @@ -33,9 +33,9 @@ func (s *TestSuite) TestGetWithdrawalQueue() { valAddr = "storyvaloper1hmjw3pvkjtndpg8wqppwdn8udd835qpaa6r6y0" evmAddr = common.HexToAddress("0x131D25EDE18178BAc9275b312001a63C081722d2") withdrawals := []types.Withdrawal{ - types.NewWithdrawal(1, delAddr, valAddr, evmAddr.String(), 100), - types.NewWithdrawal(2, delAddr, valAddr, evmAddr.String(), 200), - types.NewWithdrawal(3, delAddr, valAddr, evmAddr.String(), 300), + types.NewWithdrawal(1, evmAddr.String(), 100), + types.NewWithdrawal(2, evmAddr.String(), 200), + types.NewWithdrawal(3, evmAddr.String(), 300), } require.Len(withdrawals, 3) for _, w := range withdrawals { diff --git a/client/x/evmstaking/keeper/keeper_test.go b/client/x/evmstaking/keeper/keeper_test.go index 01d777d5..0a75337e 100644 --- a/client/x/evmstaking/keeper/keeper_test.go +++ b/client/x/evmstaking/keeper/keeper_test.go @@ -94,7 +94,6 @@ type TestSuite struct { StakingKeeper *skeeper.Keeper SlashingKeeper *estestutil.MockSlashingKeeper EVMStakingKeeper *keeper.Keeper - msgServer types.MsgServiceServer queryClient types.QueryClient encCfg moduletestutil.TestEncodingConfig @@ -176,7 +175,6 @@ func (s *TestSuite) SetupTest() { ) s.Require().NoError(evmstakingKeeper.SetParams(s.Ctx, types.DefaultParams())) s.EVMStakingKeeper = evmstakingKeeper - s.msgServer = keeper.NewMsgServerImpl(evmstakingKeeper) queryHelper := baseapp.NewQueryServerTestHelper(s.Ctx, s.encCfg.InterfaceRegistry) types.RegisterQueryServer(queryHelper, evmstakingKeeper) s.queryClient = types.NewQueryClient(queryHelper) diff --git a/client/x/evmstaking/keeper/msg_server.go b/client/x/evmstaking/keeper/msg_server.go deleted file mode 100644 index 00dab721..00000000 --- a/client/x/evmstaking/keeper/msg_server.go +++ /dev/null @@ -1,93 +0,0 @@ -package keeper - -import ( - "context" - "strconv" - - errorsmod "cosmossdk.io/errors" - - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - - "github.com/piplabs/story/client/x/evmstaking/types" -) - -type msgServer struct { - *Keeper - types.UnimplementedMsgServiceServer -} - -func NewMsgServerImpl(keeper *Keeper) types.MsgServiceServer { - return &msgServer{Keeper: keeper} -} - -func (s msgServer) AddWithdrawal(ctx context.Context, msg *types.MsgAddWithdrawal) (*types.MsgAddWithdrawalResponse, error) { - validatorAddr, err := s.validatorAddressCodec.StringToBytes(msg.Withdrawal.ValidatorAddress) - if err != nil { - return nil, sdkerrors.ErrInvalidAddress.Wrapf("invalid validator address: %s", err) - } - - // delegatorAddr - _, err = s.authKeeper.AddressCodec().StringToBytes(msg.Withdrawal.DelegatorAddress) - if err != nil { - return nil, sdkerrors.ErrInvalidAddress.Wrapf("invalid delegator address: %s", err) - } - - if msg.Withdrawal.Amount <= 0 { - return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "invalid withdrawal amount") - } - - validator, err := (s.stakingKeeper).GetValidator(ctx, validatorAddr) - if err != nil { - return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "validator not found") - } - - if validator.IsJailed() { - return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "validator is jailed") - } - - // if validator.IsUnbonding() { - // return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "validator is unbonding") - //} - - // TODO: when validator is unbonded and stakes are also unbonded back to delegates, figure out how to allow withdrawal to EL - if validator.IsUnbonded() { - return nil, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "validator is unbonded") - } - - // TODO: check bond denom once Amount is math.Int with coin type - - // bondDenom, err := (*s.stakingKeeper).BondDenom(ctx) - // if err != nil { - // return nil, err - //} - // - // if msg.Withdrawal.Amount.Denom != bondDenom { - // return nil, errorsmod.Wrapf( - // sdkerrors.ErrInvalidRequest, "invalid coin denomination: got %s, expected %s", msg.Withdrawal.Amount.Denom, bondDenom, - // ) - //} - - // TODO: balance check and transfer balance into this module, so that the module can burn the balance when the withdrawal is executed - - err = s.AddWithdrawalToQueue(ctx, types.NewWithdrawalFromMsg(msg)) - if err != nil { - return nil, errorsmod.Wrap(err, "add withdrawal") - } - - sdkCtx := sdk.UnwrapSDKContext(ctx) - sdkCtx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - types.EventTypeAddWithdrawal, - sdk.NewAttribute(types.AttributeKeyValidator, msg.Withdrawal.ValidatorAddress), - sdk.NewAttribute(types.AttributeKeyDelegator, msg.Withdrawal.DelegatorAddress), - sdk.NewAttribute(types.AttributeKeyExecutionAddress, msg.Withdrawal.ExecutionAddress), - sdk.NewAttribute(sdk.AttributeKeyAmount, strconv.FormatUint(msg.Withdrawal.Amount, 10)), - sdk.NewAttribute(types.AttributeKeyCreationHeight, strconv.FormatUint(msg.Withdrawal.CreationHeight, 10)), - ), - }) - - return &types.MsgAddWithdrawalResponse{ - //RequestIndex: s., - }, nil -} diff --git a/client/x/evmstaking/keeper/msg_server_test.go b/client/x/evmstaking/keeper/msg_server_test.go deleted file mode 100644 index b769b697..00000000 --- a/client/x/evmstaking/keeper/msg_server_test.go +++ /dev/null @@ -1,136 +0,0 @@ -package keeper_test - -/* -func (s *TestSuite) TestAddWithdrawal() { - require := s.Require() - ctx, msgServer, keeper := s.Ctx, s.msgServer, s.EVMStakingKeeper - - pubKeys, accAddrs, valAddrs := createAddresses(3) - delAddr := accAddrs[0] - delPubKey := pubKeys[0] - valAddr := valAddrs[1] - valPubKey := pubKeys[1] - // self delegation - valTokens := s.StakingKeeper.TokensFromConsensusPower(ctx, 10) - - tcs := []struct { - name string - preRun func(c context.Context) - msg *types.MsgAddWithdrawal - expectedError string - }{ - { - name: "fail: invalid validator address", - msg: &types.MsgAddWithdrawal{ - Withdrawal: &types.Withdrawal{ - ValidatorAddress: "invalid", - DelegatorAddress: delAddr.String(), - Amount: 1, - }, - }, - expectedError: "invalid validator address", - }, - { - name: "fail: invalid delegator address", - msg: &types.MsgAddWithdrawal{ - Withdrawal: &types.Withdrawal{ - ValidatorAddress: valAddr.String(), - DelegatorAddress: "invalid", - Amount: 1, - }, - }, - expectedError: "invalid delegator address", - }, - { - name: "fail: invalid amount (should be > 0)", - msg: &types.MsgAddWithdrawal{ - Withdrawal: &types.Withdrawal{ - ValidatorAddress: valAddr.String(), - DelegatorAddress: delAddr.String(), - Amount: 0, - }, - }, - expectedError: "invalid withdrawal amount", - }, - { - name: "fail: unknown validator", - msg: &types.MsgAddWithdrawal{ - Withdrawal: &types.Withdrawal{ - ValidatorAddress: valAddr.String(), - DelegatorAddress: delAddr.String(), - Amount: 1, - }, - }, - expectedError: "validator not found", - }, - { - name: "fail: jailed validator", - preRun: func(c context.Context) { - s.setupValidatorAndDelegation(c, valPubKey, delPubKey, valAddr, delAddr, valTokens) - validator, err := s.StakingKeeper.GetValidator(c, valAddr) - require.NoError(err) - validator.Jailed = true - require.NoError(s.StakingKeeper.SetValidator(c, validator)) - }, - msg: &types.MsgAddWithdrawal{ - Withdrawal: &types.Withdrawal{ - ValidatorAddress: valAddr.String(), - DelegatorAddress: delAddr.String(), - Amount: 1, - }, - }, - expectedError: "validator is jailed", - }, - { - name: "fail: unbonded validator", - preRun: func(c context.Context) { - s.setupValidatorAndDelegation(c, valPubKey, delPubKey, valAddr, delAddr, valTokens) - validator, err := s.StakingKeeper.GetValidator(c, valAddr) - require.NoError(err) - validator.Status = stypes.Unbonded - require.NoError(s.StakingKeeper.SetValidator(c, validator)) - }, - msg: &types.MsgAddWithdrawal{ - Withdrawal: &types.Withdrawal{ - ValidatorAddress: valAddr.String(), - DelegatorAddress: delAddr.String(), - Amount: 1, - }, - }, - expectedError: "validator is unbonded", - }, - { - name: "pass", - preRun: func(c context.Context) { - s.setupValidatorAndDelegation(c, valPubKey, delPubKey, valAddr, delAddr, valTokens) - }, - msg: &types.MsgAddWithdrawal{ - Withdrawal: &types.Withdrawal{ - ValidatorAddress: valAddr.String(), - DelegatorAddress: delAddr.String(), - Amount: 1, - }, - }, - }, - } - - for _, tc := range tcs { - s.Run(tc.name, func() { - if tc.preRun != nil { - tc.preRun(ctx) - } - cachedCtx, _ := ctx.CacheContext() - resp, err := msgServer.AddWithdrawal(cachedCtx, tc.msg) - if tc.expectedError != "" { - require.Error(err) - require.Contains(err.Error(), tc.expectedError) - } else { - require.NoError(err) - require.NotNil(resp) - // check withdrawal is queued - require.Equal(uint64(1), keeper.WithdrawalQueue.Len(cachedCtx)) - } - }) - } -} -*/ diff --git a/client/x/evmstaking/keeper/ubi.go b/client/x/evmstaking/keeper/ubi.go index efe5b2b0..e7972e0f 100644 --- a/client/x/evmstaking/keeper/ubi.go +++ b/client/x/evmstaking/keeper/ubi.go @@ -44,8 +44,6 @@ func (k Keeper) ProcessUbiWithdrawal(ctx context.Context) error { // Add withdrawal entry to the withdrawal queue. if err = k.AddWithdrawalToQueue(ctx, types.NewWithdrawal( uint64(sdk.UnwrapSDKContext(ctx).BlockHeight()), - "", - "", params.UbiWithdrawAddress, ubiBalance.Uint64(), )); err != nil { diff --git a/client/x/evmstaking/keeper/withdraw.go b/client/x/evmstaking/keeper/withdraw.go index 464d253e..208ca261 100644 --- a/client/x/evmstaking/keeper/withdraw.go +++ b/client/x/evmstaking/keeper/withdraw.go @@ -19,6 +19,12 @@ import ( "github.com/piplabs/story/lib/promutil" ) +type RewardWithdrawal struct { + DelegatorAddress string + ValidatorAddress string + WithdrawalEntry estypes.Withdrawal +} + func (k Keeper) ProcessUnbondingWithdrawals(ctx context.Context, unbondedEntries []stypes.UnbondedEntry) error { log.Debug(ctx, "Processing mature unbonding delegations", "count", len(unbondedEntries)) @@ -54,8 +60,6 @@ func (k Keeper) ProcessUnbondingWithdrawals(ctx context.Context, unbondedEntries // push the undelegation to the withdrawal queue err = k.AddWithdrawalToQueue(ctx, estypes.NewWithdrawal( uint64(sdk.UnwrapSDKContext(ctx).BlockHeight()), - entry.DelegatorAddress, - entry.ValidatorAddress, delEvmAddr, entry.Amount.Uint64(), )) @@ -67,7 +71,22 @@ func (k Keeper) ProcessUnbondingWithdrawals(ctx context.Context, unbondedEntries return nil } -func (k Keeper) ExpectedPartialWithdrawals(ctx context.Context) ([]estypes.Withdrawal, error) { +func (k Keeper) ProcessRewardWithdrawals(ctx context.Context) error { + log.Debug(ctx, "Processing reward withdrawals") + + rewardWithdrawals, err := k.ExpectedRewardWithdrawals(ctx) + if err != nil { + return errors.Wrap(err, "get expected reward withdrawals") + } + + if err := k.EnqueueEligibleRewardWithdrawal(ctx, rewardWithdrawals); err != nil { + return errors.Wrap(err, "enqueue eligible reward withdrawals") + } + + return nil +} + +func (k Keeper) ExpectedRewardWithdrawals(ctx context.Context) ([]RewardWithdrawal, error) { nextValIndex, nextValDelIndex, err := k.GetValidatorSweepIndex(ctx) if err != nil { return nil, err @@ -94,7 +113,7 @@ func (k Keeper) ExpectedPartialWithdrawals(ctx context.Context) ([]estypes.Withd // Iterate all validators from `nextValidatorIndex` to find out eligible partial withdrawals. var ( swept uint32 - withdrawals []estypes.Withdrawal + withdrawals []RewardWithdrawal ) // Get sweep limit per block. @@ -181,13 +200,15 @@ func (k Keeper) ExpectedPartialWithdrawals(ctx context.Context) ([]estypes.Withd return nil, errors.Wrap(err, "map delegator pubkey to evm reward address") } - withdrawals = append(withdrawals, estypes.NewWithdrawal( - uint64(sdk.UnwrapSDKContext(ctx).BlockHeight()), - nextDelegators[i].DelegatorAddress, - valAddr.String(), - delEvmAddr, - bondDenomAmount, - )) + withdrawals = append(withdrawals, RewardWithdrawal{ + DelegatorAddress: nextDelegators[i].DelegatorAddress, + ValidatorAddress: valAddr.String(), + WithdrawalEntry: estypes.NewWithdrawal( + uint64(sdk.UnwrapSDKContext(ctx).BlockHeight()), + delEvmAddr, + bondDenomAmount, + ), + }) } nextValDelIndex++ @@ -226,9 +247,9 @@ func (k Keeper) ExpectedPartialWithdrawals(ctx context.Context) ([]estypes.Withd return withdrawals, nil } -func (k Keeper) EnqueueEligiblePartialWithdrawal(ctx context.Context, withdrawals []estypes.Withdrawal) error { - for i := range withdrawals { - valAddr, err := sdk.ValAddressFromBech32(withdrawals[i].ValidatorAddress) +func (k Keeper) EnqueueEligibleRewardWithdrawal(ctx context.Context, rewardWithdrawals []RewardWithdrawal) error { + for i := range rewardWithdrawals { + valAddr, err := sdk.ValAddressFromBech32(rewardWithdrawals[i].ValidatorAddress) if err != nil { return errors.Wrap(err, "validator address from bech32") } @@ -236,19 +257,19 @@ func (k Keeper) EnqueueEligiblePartialWithdrawal(ctx context.Context, withdrawal valAccAddr := sdk.AccAddress(valAddr).String() // Withdraw delegation rewards. - delAddr := sdk.MustAccAddressFromBech32(withdrawals[i].DelegatorAddress) + delAddr := sdk.MustAccAddressFromBech32(rewardWithdrawals[i].DelegatorAddress) delRewards, err := k.distributionKeeper.WithdrawDelegationRewards(ctx, delAddr, valAddr) if err != nil { return err } // Withdraw commission if it is a self delegation. - if withdrawals[i].DelegatorAddress == valAccAddr { + if rewardWithdrawals[i].DelegatorAddress == valAccAddr { commissionRewards, err := k.distributionKeeper.WithdrawValidatorCommission(ctx, valAddr) if errors.Is(err, dtypes.ErrNoValidatorCommission) { log.Debug( ctx, "No validator commission", - "validator_addr", withdrawals[i].ValidatorAddress, + "validator_addr", rewardWithdrawals[i].ValidatorAddress, "validator_account_addr", valAccAddr, ) } else if err != nil { @@ -260,10 +281,10 @@ func (k Keeper) EnqueueEligiblePartialWithdrawal(ctx context.Context, withdrawal curBondDenomAmount := delRewards.AmountOf(sdk.DefaultBondDenom).Uint64() log.Debug( ctx, "Withdraw delegator rewards", - "validator_addr", withdrawals[i].ValidatorAddress, + "validator_addr", rewardWithdrawals[i].ValidatorAddress, "validator_account_addr", valAccAddr, - "delegator_addr", withdrawals[i].DelegatorAddress, - "amount_calculate", withdrawals[i].Amount, + "delegator_addr", rewardWithdrawals[i].DelegatorAddress, + "amount_calculate", rewardWithdrawals[i].WithdrawalEntry.Amount, "amount_withdraw", curBondDenomAmount, ) @@ -280,7 +301,7 @@ func (k Keeper) EnqueueEligiblePartialWithdrawal(ctx context.Context, withdrawal // Enqueue to the global withdrawal queue. if err := k.AddWithdrawalToQueue(ctx, estypes.NewWithdrawal( uint64(sdk.UnwrapSDKContext(ctx).BlockHeight()), - withdrawals[i].DelegatorAddress, withdrawals[i].ValidatorAddress, withdrawals[i].ExecutionAddress, + rewardWithdrawals[i].WithdrawalEntry.ExecutionAddress, curBondDenomAmount, )); err != nil { return err diff --git a/client/x/evmstaking/keeper/withdrawal_queue_test.go b/client/x/evmstaking/keeper/withdrawal_queue_test.go index 433c0375..36c6fb96 100644 --- a/client/x/evmstaking/keeper/withdrawal_queue_test.go +++ b/client/x/evmstaking/keeper/withdrawal_queue_test.go @@ -14,9 +14,9 @@ var ( valAddr = "storyvaloper1hmjw3pvkjtndpg8wqppwdn8udd835qpaa6r6y0" evmAddr = common.HexToAddress("0x131D25EDE18178BAc9275b312001a63C081722d2") withdrawals = []types.Withdrawal{ - types.NewWithdrawal(1, delAddr, valAddr, evmAddr.String(), 100), - types.NewWithdrawal(2, delAddr, valAddr, evmAddr.String(), 200), - types.NewWithdrawal(3, delAddr, valAddr, evmAddr.String(), 300), + types.NewWithdrawal(1, evmAddr.String(), 100), + types.NewWithdrawal(2, evmAddr.String(), 200), + types.NewWithdrawal(3, evmAddr.String(), 300), } ) @@ -40,7 +40,7 @@ func (s *TestSuite) TestAddWithdrawalToQueue() { s.initQueue() // Add a withdrawal to the queue - withdrawal := types.NewWithdrawal(1, delAddr, valAddr, evmAddr.String(), 100) + withdrawal := types.NewWithdrawal(1, evmAddr.String(), 100) err := s.EVMStakingKeeper.AddWithdrawalToQueue(s.Ctx, withdrawal) require.NoError(err) diff --git a/client/x/evmstaking/module/module.go b/client/x/evmstaking/module/module.go index 2f38081e..c0e74c71 100644 --- a/client/x/evmstaking/module/module.go +++ b/client/x/evmstaking/module/module.go @@ -113,7 +113,6 @@ func (AppModule) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { // RegisterServices registers a gRPC query service to respond to the module-specific gRPC queries. func (am AppModule) RegisterServices(cfg module.Configurator) { types.RegisterQueryServer(cfg.QueryServer(), am.keeper) - types.RegisterMsgServiceServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper)) } // ValidateGenesis performs genesis state validation for the module. diff --git a/client/x/evmstaking/types/codec.go b/client/x/evmstaking/types/codec.go index a27d1231..7f8d8259 100644 --- a/client/x/evmstaking/types/codec.go +++ b/client/x/evmstaking/types/codec.go @@ -3,21 +3,9 @@ package types import ( "github.com/cosmos/cosmos-sdk/codec" cdctypes "github.com/cosmos/cosmos-sdk/codec/types" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/msgservice" ) -func RegisterCodec(_ *codec.LegacyAmino) { - // cdc.RegisterConcrete(&MsgAddWithdrawal{}, "evmstaking/MsgAddWithdrawal", nil) - // cdc.RegisterConcrete(&MsgRemoveWithdrawal{}, "evmstaking/MsgRemoveWithdrawal", nil) -} +func RegisterCodec(_ *codec.LegacyAmino) {} // RegisterInterfaces registers the x/staking interfaces types with the interface registry. -func RegisterInterfaces(registrar cdctypes.InterfaceRegistry) { - registrar.RegisterImplementations((*sdk.Msg)(nil), - &MsgAddWithdrawal{}, - &MsgRemoveWithdrawal{}, - ) - - msgservice.RegisterMsgServiceDesc(registrar, &_MsgService_serviceDesc) -} +func RegisterInterfaces(_ cdctypes.InterfaceRegistry) {} diff --git a/client/x/evmstaking/types/evmstaking.pb.go b/client/x/evmstaking/types/evmstaking.pb.go index e6b5e0c0..a3b88050 100644 --- a/client/x/evmstaking/types/evmstaking.pb.go +++ b/client/x/evmstaking/types/evmstaking.pb.go @@ -25,12 +25,10 @@ var _ = math.Inf const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type Withdrawal struct { - CreationHeight uint64 `protobuf:"varint,1,opt,name=creation_height,json=creationHeight,proto3" json:"creation_height,omitempty"` - DelegatorAddress string `protobuf:"bytes,2,opt,name=delegator_address,json=delegatorAddress,proto3" json:"delegator_address,omitempty" yaml:"delegator_address"` - ValidatorAddress string `protobuf:"bytes,3,opt,name=validator_address,json=validatorAddress,proto3" json:"validator_address,omitempty" yaml:"validator_address"` + CreationHeight uint64 `protobuf:"varint,1,opt,name=creation_height,json=creationHeight,proto3" json:"creation_height,omitempty"` // TODO: use ethcommon.Address type - ExecutionAddress string `protobuf:"bytes,4,opt,name=execution_address,json=executionAddress,proto3" json:"execution_address,omitempty" yaml:"execution_address"` - Amount uint64 `protobuf:"varint,5,opt,name=amount,proto3" json:"amount,omitempty" yaml:"amount"` + ExecutionAddress string `protobuf:"bytes,2,opt,name=execution_address,json=executionAddress,proto3" json:"execution_address,omitempty" yaml:"execution_address"` + Amount uint64 `protobuf:"varint,3,opt,name=amount,proto3" json:"amount,omitempty" yaml:"amount"` } func (m *Withdrawal) Reset() { *m = Withdrawal{} } @@ -75,29 +73,25 @@ func init() { } var fileDescriptor_185991fb447209d8 = []byte{ - // 340 bytes of a gzipped FileDescriptorProto + // 281 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xd2, 0x4a, 0xce, 0xc9, 0x4c, 0xcd, 0x2b, 0xd1, 0xaf, 0xd0, 0x4f, 0x2d, 0xcb, 0x2d, 0x2e, 0x49, 0xcc, 0xce, 0xcc, 0x4b, 0xd7, 0x2f, 0xa9, 0x2c, 0x48, 0x2d, 0x46, 0x12, 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x92, 0x84, 0xa8, 0xd5, 0xab, 0xd0, 0x43, 0x92, 0x02, 0xab, 0x95, 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x07, 0xab, 0xd2, 0x07, 0xb1, 0x20, 0x1a, 0xa4, 0x24, 0x93, 0xf3, 0x8b, 0x73, 0xf3, 0x8b, 0xe3, 0x21, 0x12, - 0x10, 0x0e, 0x44, 0x4a, 0x69, 0x0e, 0x33, 0x17, 0x57, 0x78, 0x66, 0x49, 0x46, 0x4a, 0x51, 0x62, + 0x10, 0x0e, 0x44, 0x4a, 0xe9, 0x2c, 0x23, 0x17, 0x57, 0x78, 0x66, 0x49, 0x46, 0x4a, 0x51, 0x62, 0x79, 0x62, 0x8e, 0x90, 0x3a, 0x17, 0x7f, 0x72, 0x51, 0x6a, 0x62, 0x49, 0x66, 0x7e, 0x5e, 0x7c, 0x46, 0x6a, 0x66, 0x7a, 0x46, 0x89, 0x04, 0xa3, 0x02, 0xa3, 0x06, 0x4b, 0x10, 0x1f, 0x4c, 0xd8, - 0x03, 0x2c, 0x2a, 0x94, 0xc8, 0x25, 0x98, 0x92, 0x9a, 0x93, 0x9a, 0x9e, 0x58, 0x92, 0x5f, 0x14, - 0x9f, 0x98, 0x92, 0x52, 0x94, 0x5a, 0x5c, 0x2c, 0xc1, 0xa4, 0xc0, 0xa8, 0xc1, 0xe9, 0x64, 0xf2, - 0xe9, 0x9e, 0xbc, 0x44, 0x65, 0x62, 0x6e, 0x8e, 0x95, 0x12, 0x86, 0x12, 0xa5, 0x4b, 0x5b, 0x74, - 0x45, 0xa0, 0x0e, 0x70, 0x84, 0x08, 0x05, 0x97, 0x14, 0x65, 0xe6, 0xa5, 0x07, 0x09, 0xc0, 0xd5, - 0x42, 0xc5, 0x85, 0xb2, 0xb8, 0x04, 0xcb, 0x12, 0x73, 0x32, 0x53, 0x50, 0xac, 0x60, 0x06, 0x5b, - 0x61, 0x8b, 0xb0, 0x02, 0x43, 0x09, 0xc8, 0x0a, 0x59, 0xa8, 0x15, 0x61, 0x30, 0x49, 0x34, 0xbb, - 0xca, 0xd0, 0xc4, 0x41, 0xde, 0x49, 0xad, 0x48, 0x4d, 0x2e, 0x05, 0x7b, 0x1c, 0x66, 0x17, 0x0b, - 0xba, 0x77, 0x30, 0x94, 0xe0, 0xf1, 0x0e, 0x5c, 0x2d, 0xcc, 0x0a, 0x4d, 0x2e, 0xb6, 0xc4, 0xdc, - 0xfc, 0xd2, 0xbc, 0x12, 0x09, 0x56, 0x50, 0x88, 0x3a, 0x09, 0x7e, 0xba, 0x27, 0xcf, 0x0b, 0x31, - 0x17, 0x22, 0xae, 0x14, 0x04, 0x55, 0x60, 0xc5, 0xd1, 0xb1, 0x40, 0x9e, 0xe1, 0xc5, 0x02, 0x79, - 0x46, 0x27, 0xe3, 0x13, 0x8f, 0xe4, 0x18, 0x2f, 0x3c, 0x92, 0x63, 0x7c, 0xf0, 0x48, 0x8e, 0x71, - 0xc2, 0x63, 0x39, 0x86, 0x0b, 0x8f, 0xe5, 0x18, 0x6e, 0x3c, 0x96, 0x63, 0x88, 0x92, 0xc4, 0x99, - 0x60, 0x92, 0xd8, 0xc0, 0x51, 0x6b, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, 0x18, 0x6c, 0x63, 0x24, - 0x54, 0x02, 0x00, 0x00, + 0x03, 0x2c, 0x2a, 0x94, 0xc8, 0x25, 0x98, 0x5a, 0x91, 0x9a, 0x5c, 0x0a, 0x56, 0x99, 0x98, 0x92, + 0x52, 0x94, 0x5a, 0x5c, 0x2c, 0xc1, 0xa4, 0xc0, 0xa8, 0xc1, 0xe9, 0x64, 0xf2, 0xe9, 0x9e, 0xbc, + 0x44, 0x65, 0x62, 0x6e, 0x8e, 0x95, 0x12, 0x86, 0x12, 0xa5, 0x4b, 0x5b, 0x74, 0x45, 0xa0, 0x0e, + 0x70, 0x84, 0x08, 0x05, 0x97, 0x14, 0x65, 0xe6, 0xa5, 0x07, 0x09, 0xc0, 0xd5, 0x42, 0xc5, 0x85, + 0x34, 0xb9, 0xd8, 0x12, 0x73, 0xf3, 0x4b, 0xf3, 0x4a, 0x24, 0x98, 0x41, 0x4e, 0x70, 0x12, 0xfc, + 0x74, 0x4f, 0x9e, 0x17, 0x62, 0x2e, 0x44, 0x5c, 0x29, 0x08, 0xaa, 0xc0, 0x8a, 0xa3, 0x63, 0x81, + 0x3c, 0xc3, 0x8b, 0x05, 0xf2, 0x8c, 0x4e, 0xc6, 0x27, 0x1e, 0xc9, 0x31, 0x5e, 0x78, 0x24, 0xc7, + 0xf8, 0xe0, 0x91, 0x1c, 0xe3, 0x84, 0xc7, 0x72, 0x0c, 0x17, 0x1e, 0xcb, 0x31, 0xdc, 0x78, 0x2c, + 0xc7, 0x10, 0x25, 0x89, 0x33, 0x84, 0x93, 0xd8, 0xc0, 0x61, 0x61, 0x0c, 0x08, 0x00, 0x00, 0xff, + 0xff, 0xea, 0x83, 0x36, 0x44, 0x85, 0x01, 0x00, 0x00, } func (this *Withdrawal) Equal(that interface{}) bool { @@ -122,12 +116,6 @@ func (this *Withdrawal) Equal(that interface{}) bool { if this.CreationHeight != that1.CreationHeight { return false } - if this.DelegatorAddress != that1.DelegatorAddress { - return false - } - if this.ValidatorAddress != that1.ValidatorAddress { - return false - } if this.ExecutionAddress != that1.ExecutionAddress { return false } @@ -159,27 +147,13 @@ func (m *Withdrawal) MarshalToSizedBuffer(dAtA []byte) (int, error) { if m.Amount != 0 { i = encodeVarintEvmstaking(dAtA, i, uint64(m.Amount)) i-- - dAtA[i] = 0x28 + dAtA[i] = 0x18 } if len(m.ExecutionAddress) > 0 { i -= len(m.ExecutionAddress) copy(dAtA[i:], m.ExecutionAddress) i = encodeVarintEvmstaking(dAtA, i, uint64(len(m.ExecutionAddress))) i-- - dAtA[i] = 0x22 - } - if len(m.ValidatorAddress) > 0 { - i -= len(m.ValidatorAddress) - copy(dAtA[i:], m.ValidatorAddress) - i = encodeVarintEvmstaking(dAtA, i, uint64(len(m.ValidatorAddress))) - i-- - dAtA[i] = 0x1a - } - if len(m.DelegatorAddress) > 0 { - i -= len(m.DelegatorAddress) - copy(dAtA[i:], m.DelegatorAddress) - i = encodeVarintEvmstaking(dAtA, i, uint64(len(m.DelegatorAddress))) - i-- dAtA[i] = 0x12 } if m.CreationHeight != 0 { @@ -210,14 +184,6 @@ func (m *Withdrawal) Size() (n int) { if m.CreationHeight != 0 { n += 1 + sovEvmstaking(uint64(m.CreationHeight)) } - l = len(m.DelegatorAddress) - if l > 0 { - n += 1 + l + sovEvmstaking(uint64(l)) - } - l = len(m.ValidatorAddress) - if l > 0 { - n += 1 + l + sovEvmstaking(uint64(l)) - } l = len(m.ExecutionAddress) if l > 0 { n += 1 + l + sovEvmstaking(uint64(l)) @@ -283,70 +249,6 @@ func (m *Withdrawal) Unmarshal(dAtA []byte) error { } } case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field DelegatorAddress", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEvmstaking - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthEvmstaking - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthEvmstaking - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.DelegatorAddress = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ValidatorAddress", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEvmstaking - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthEvmstaking - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthEvmstaking - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ValidatorAddress = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 4: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ExecutionAddress", wireType) } @@ -378,7 +280,7 @@ func (m *Withdrawal) Unmarshal(dAtA []byte) error { } m.ExecutionAddress = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 5: + case 3: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) } diff --git a/client/x/evmstaking/types/evmstaking.proto b/client/x/evmstaking/types/evmstaking.proto index 128bb12a..ce93c4c0 100644 --- a/client/x/evmstaking/types/evmstaking.proto +++ b/client/x/evmstaking/types/evmstaking.proto @@ -11,20 +11,12 @@ message Withdrawal { option (gogoproto.goproto_getters) = false; uint64 creation_height = 1; - string delegator_address = 2 [ - (cosmos_proto.scalar) = "cosmos.AddressString", - (gogoproto.moretags) = "yaml:\"delegator_address\"" - ]; - string validator_address = 3 [ - (cosmos_proto.scalar) = "cosmos.ValidatorAddressString", - (gogoproto.moretags) = "yaml:\"validator_address\"" - ]; // TODO: use ethcommon.Address type - string execution_address = 4 [ + string execution_address = 2 [ (cosmos_proto.scalar) = "cosmos.AddressString", (gogoproto.moretags) = "yaml:\"execution_address\"" ]; - uint64 amount = 5 [ + uint64 amount = 3 [ // TODO: use custom Int type, need to resolve issue in auto-generated pb.go // (cosmos_proto.scalar) = "cosmos.Int", // (gogoproto.customtype) = "cosmossdk.io/math.Int", diff --git a/client/x/evmstaking/types/tx.pb.go b/client/x/evmstaking/types/tx.pb.go deleted file mode 100644 index 2e3ad392..00000000 --- a/client/x/evmstaking/types/tx.pb.go +++ /dev/null @@ -1,1142 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: client/x/evmstaking/types/tx.proto - -package types - -import ( - context "context" - fmt "fmt" - _ "github.com/cosmos/cosmos-sdk/types/msgservice" - _ "github.com/cosmos/gogoproto/gogoproto" - grpc1 "github.com/cosmos/gogoproto/grpc" - proto "github.com/cosmos/gogoproto/proto" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" - io "io" - math "math" - math_bits "math/bits" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package - -// MsgAddWithdrawal represents a message to add a withdrawal request to the withdrawal queue. -type MsgAddWithdrawal struct { - Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` - Withdrawal *Withdrawal `protobuf:"bytes,2,opt,name=withdrawal,proto3" json:"withdrawal,omitempty" yaml:"withdrawal"` -} - -func (m *MsgAddWithdrawal) Reset() { *m = MsgAddWithdrawal{} } -func (m *MsgAddWithdrawal) String() string { return proto.CompactTextString(m) } -func (*MsgAddWithdrawal) ProtoMessage() {} -func (*MsgAddWithdrawal) Descriptor() ([]byte, []int) { - return fileDescriptor_9acb5c9b0992bb37, []int{0} -} -func (m *MsgAddWithdrawal) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgAddWithdrawal) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgAddWithdrawal.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *MsgAddWithdrawal) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgAddWithdrawal.Merge(m, src) -} -func (m *MsgAddWithdrawal) XXX_Size() int { - return m.Size() -} -func (m *MsgAddWithdrawal) XXX_DiscardUnknown() { - xxx_messageInfo_MsgAddWithdrawal.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgAddWithdrawal proto.InternalMessageInfo - -func (m *MsgAddWithdrawal) GetAuthority() string { - if m != nil { - return m.Authority - } - return "" -} - -func (m *MsgAddWithdrawal) GetWithdrawal() *Withdrawal { - if m != nil { - return m.Withdrawal - } - return nil -} - -// MsgAddWithdrawalResponse defines the Msg/AddWithdrawal response type. -type MsgAddWithdrawalResponse struct { - RequestIndex uint64 `protobuf:"varint,1,opt,name=request_index,json=requestIndex,proto3" json:"request_index,omitempty" yaml:"request_index"` - RequestIdDelegatorValidator uint64 `protobuf:"varint,2,opt,name=request_id_delegator_validator,json=requestIdDelegatorValidator,proto3" json:"request_id_delegator_validator,omitempty" yaml:"request_id_delegator_validator"` -} - -func (m *MsgAddWithdrawalResponse) Reset() { *m = MsgAddWithdrawalResponse{} } -func (m *MsgAddWithdrawalResponse) String() string { return proto.CompactTextString(m) } -func (*MsgAddWithdrawalResponse) ProtoMessage() {} -func (*MsgAddWithdrawalResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_9acb5c9b0992bb37, []int{1} -} -func (m *MsgAddWithdrawalResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgAddWithdrawalResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgAddWithdrawalResponse.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *MsgAddWithdrawalResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgAddWithdrawalResponse.Merge(m, src) -} -func (m *MsgAddWithdrawalResponse) XXX_Size() int { - return m.Size() -} -func (m *MsgAddWithdrawalResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgAddWithdrawalResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgAddWithdrawalResponse proto.InternalMessageInfo - -func (m *MsgAddWithdrawalResponse) GetRequestIndex() uint64 { - if m != nil { - return m.RequestIndex - } - return 0 -} - -func (m *MsgAddWithdrawalResponse) GetRequestIdDelegatorValidator() uint64 { - if m != nil { - return m.RequestIdDelegatorValidator - } - return 0 -} - -// MsgRemoveWithdrawal represents a message to remove a withdrawal request from the withdrawal queue. -type MsgRemoveWithdrawal struct { - Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` - Delegator string `protobuf:"bytes,2,opt,name=delegator,proto3" json:"delegator,omitempty" yaml:"delegator"` - Validator string `protobuf:"bytes,3,opt,name=validator,proto3" json:"validator,omitempty" yaml:"validator"` - RequestIdDelegatorValidator uint64 `protobuf:"varint,4,opt,name=request_id_delegator_validator,json=requestIdDelegatorValidator,proto3" json:"request_id_delegator_validator,omitempty" yaml:"request_id_delegator_validator"` -} - -func (m *MsgRemoveWithdrawal) Reset() { *m = MsgRemoveWithdrawal{} } -func (m *MsgRemoveWithdrawal) String() string { return proto.CompactTextString(m) } -func (*MsgRemoveWithdrawal) ProtoMessage() {} -func (*MsgRemoveWithdrawal) Descriptor() ([]byte, []int) { - return fileDescriptor_9acb5c9b0992bb37, []int{2} -} -func (m *MsgRemoveWithdrawal) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgRemoveWithdrawal) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgRemoveWithdrawal.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *MsgRemoveWithdrawal) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgRemoveWithdrawal.Merge(m, src) -} -func (m *MsgRemoveWithdrawal) XXX_Size() int { - return m.Size() -} -func (m *MsgRemoveWithdrawal) XXX_DiscardUnknown() { - xxx_messageInfo_MsgRemoveWithdrawal.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgRemoveWithdrawal proto.InternalMessageInfo - -func (m *MsgRemoveWithdrawal) GetAuthority() string { - if m != nil { - return m.Authority - } - return "" -} - -func (m *MsgRemoveWithdrawal) GetDelegator() string { - if m != nil { - return m.Delegator - } - return "" -} - -func (m *MsgRemoveWithdrawal) GetValidator() string { - if m != nil { - return m.Validator - } - return "" -} - -func (m *MsgRemoveWithdrawal) GetRequestIdDelegatorValidator() uint64 { - if m != nil { - return m.RequestIdDelegatorValidator - } - return 0 -} - -// MsgRemoveWithdrawalResponse defines the Msg/RemoveWithdrawal response type. -type MsgRemoveWithdrawalResponse struct { -} - -func (m *MsgRemoveWithdrawalResponse) Reset() { *m = MsgRemoveWithdrawalResponse{} } -func (m *MsgRemoveWithdrawalResponse) String() string { return proto.CompactTextString(m) } -func (*MsgRemoveWithdrawalResponse) ProtoMessage() {} -func (*MsgRemoveWithdrawalResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_9acb5c9b0992bb37, []int{3} -} -func (m *MsgRemoveWithdrawalResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgRemoveWithdrawalResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgRemoveWithdrawalResponse.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *MsgRemoveWithdrawalResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgRemoveWithdrawalResponse.Merge(m, src) -} -func (m *MsgRemoveWithdrawalResponse) XXX_Size() int { - return m.Size() -} -func (m *MsgRemoveWithdrawalResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgRemoveWithdrawalResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgRemoveWithdrawalResponse proto.InternalMessageInfo - -func init() { - proto.RegisterType((*MsgAddWithdrawal)(nil), "client.x.evmstaking.types.MsgAddWithdrawal") - proto.RegisterType((*MsgAddWithdrawalResponse)(nil), "client.x.evmstaking.types.MsgAddWithdrawalResponse") - proto.RegisterType((*MsgRemoveWithdrawal)(nil), "client.x.evmstaking.types.MsgRemoveWithdrawal") - proto.RegisterType((*MsgRemoveWithdrawalResponse)(nil), "client.x.evmstaking.types.MsgRemoveWithdrawalResponse") -} - -func init() { - proto.RegisterFile("client/x/evmstaking/types/tx.proto", fileDescriptor_9acb5c9b0992bb37) -} - -var fileDescriptor_9acb5c9b0992bb37 = []byte{ - // 472 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x4a, 0xce, 0xc9, 0x4c, - 0xcd, 0x2b, 0xd1, 0xaf, 0xd0, 0x4f, 0x2d, 0xcb, 0x2d, 0x2e, 0x49, 0xcc, 0xce, 0xcc, 0x4b, 0xd7, - 0x2f, 0xa9, 0x2c, 0x48, 0x2d, 0xd6, 0x2f, 0xa9, 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x92, - 0x84, 0xa8, 0xd1, 0xab, 0xd0, 0x43, 0xa8, 0xd1, 0x03, 0xab, 0x91, 0x12, 0x49, 0xcf, 0x4f, 0xcf, - 0x07, 0xab, 0xd2, 0x07, 0xb1, 0x20, 0x1a, 0xa4, 0xc4, 0x93, 0xf3, 0x8b, 0x73, 0xf3, 0x8b, 0xf5, - 0x73, 0x8b, 0xd3, 0xf5, 0xcb, 0x0c, 0x41, 0x14, 0x54, 0x42, 0x0b, 0xb7, 0x6d, 0x48, 0x46, 0x83, - 0xd5, 0x2a, 0xcd, 0x63, 0xe4, 0x12, 0xf0, 0x2d, 0x4e, 0x77, 0x4c, 0x49, 0x09, 0xcf, 0x2c, 0xc9, - 0x48, 0x29, 0x4a, 0x2c, 0x4f, 0xcc, 0x11, 0x92, 0xe1, 0xe2, 0x4c, 0x2c, 0x2d, 0xc9, 0xc8, 0x2f, - 0xca, 0x2c, 0xa9, 0x94, 0x60, 0x54, 0x60, 0xd4, 0xe0, 0x0c, 0x42, 0x08, 0x08, 0xc5, 0x70, 0x71, - 0x95, 0xc3, 0xd5, 0x4a, 0x30, 0x29, 0x30, 0x6a, 0x70, 0x1b, 0xa9, 0xea, 0xe1, 0x74, 0xbd, 0x1e, - 0xc2, 0x60, 0x27, 0xd1, 0x4f, 0xf7, 0xe4, 0x05, 0x2b, 0x13, 0x73, 0x73, 0xac, 0x94, 0x10, 0x46, - 0x28, 0x05, 0x21, 0x99, 0x67, 0xc5, 0xd7, 0xf4, 0x7c, 0x83, 0x16, 0xc2, 0x36, 0xa5, 0x93, 0x8c, - 0x5c, 0x12, 0xe8, 0x0e, 0x0c, 0x4a, 0x2d, 0x2e, 0xc8, 0xcf, 0x2b, 0x4e, 0x15, 0xb2, 0xe5, 0xe2, - 0x2d, 0x4a, 0x2d, 0x2c, 0x4d, 0x2d, 0x2e, 0x89, 0xcf, 0xcc, 0x4b, 0x49, 0xad, 0x00, 0x3b, 0x96, - 0xc5, 0x49, 0xe2, 0xd3, 0x3d, 0x79, 0x11, 0x88, 0x35, 0x28, 0xd2, 0x4a, 0x41, 0x3c, 0x50, 0xbe, - 0x27, 0x88, 0x2b, 0x94, 0xc7, 0x25, 0x07, 0x97, 0x4f, 0x89, 0x4f, 0x49, 0xcd, 0x49, 0x4d, 0x4f, - 0x2c, 0xc9, 0x2f, 0x8a, 0x2f, 0x4b, 0xcc, 0xc9, 0x4c, 0x01, 0xb1, 0xc0, 0xbe, 0x63, 0x71, 0xd2, - 0xfc, 0x74, 0x4f, 0x5e, 0x15, 0xcd, 0x3c, 0xac, 0xea, 0x95, 0x82, 0xa4, 0x61, 0x16, 0xa4, 0xb8, - 0xc0, 0xa4, 0xc3, 0xe0, 0xb2, 0xb3, 0x99, 0xb8, 0x84, 0x7d, 0x8b, 0xd3, 0x83, 0x52, 0x73, 0xf3, - 0xcb, 0x52, 0x89, 0x0e, 0x6f, 0x23, 0x2e, 0x4e, 0xb8, 0x55, 0x60, 0x07, 0x71, 0x3a, 0x89, 0x7c, - 0xba, 0x27, 0x2f, 0x00, 0x71, 0x10, 0x5c, 0x4a, 0x29, 0x08, 0xa1, 0x0c, 0xa4, 0x07, 0xe1, 0x09, - 0x66, 0x74, 0x3d, 0x48, 0xee, 0x45, 0x28, 0x23, 0x22, 0x34, 0x58, 0xa8, 0x19, 0x1a, 0x18, 0x31, - 0x2d, 0xcb, 0x25, 0x8d, 0x25, 0x70, 0x60, 0x71, 0x6d, 0xd4, 0xc4, 0xc4, 0xc5, 0xe5, 0x5b, 0x9c, - 0x1e, 0x9c, 0x5a, 0x54, 0x96, 0x99, 0x9c, 0x2a, 0x54, 0xc8, 0xc5, 0x8b, 0x9a, 0x68, 0xb5, 0xf1, - 0x24, 0x41, 0xf4, 0x04, 0x24, 0x65, 0x4c, 0x82, 0x62, 0x78, 0x6a, 0xab, 0xe2, 0x12, 0xc0, 0x88, - 0x3a, 0x3d, 0xfc, 0x06, 0xa1, 0xab, 0x97, 0x32, 0x23, 0x4d, 0x3d, 0xcc, 0x6e, 0x29, 0xd6, 0x86, - 0xe7, 0x1b, 0xb4, 0x18, 0x9d, 0x8c, 0x4f, 0x3c, 0x92, 0x63, 0xbc, 0xf0, 0x48, 0x8e, 0xf1, 0xc1, - 0x23, 0x39, 0xc6, 0x09, 0x8f, 0xe5, 0x18, 0x2e, 0x3c, 0x96, 0x63, 0xb8, 0xf1, 0x58, 0x8e, 0x21, - 0x4a, 0x12, 0x67, 0xa6, 0x4f, 0x62, 0x03, 0x67, 0x75, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, - 0xef, 0xcf, 0x54, 0x76, 0x86, 0x04, 0x00, 0x00, -} - -// Reference imports to suppress errors if they are not otherwise used. -var _ context.Context -var _ grpc.ClientConn - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -const _ = grpc.SupportPackageIsVersion4 - -// MsgServiceClient is the client API for MsgService service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type MsgServiceClient interface { - // AddWithdrawal defines a method to add a withdrawal to the withdrawal queue. - AddWithdrawal(ctx context.Context, in *MsgAddWithdrawal, opts ...grpc.CallOption) (*MsgAddWithdrawalResponse, error) - // RemoveWithdrawal defines a method to remove a withdrawal request from the withdrawal queue. - RemoveWithdrawal(ctx context.Context, in *MsgRemoveWithdrawal, opts ...grpc.CallOption) (*MsgRemoveWithdrawalResponse, error) -} - -type msgServiceClient struct { - cc grpc1.ClientConn -} - -func NewMsgServiceClient(cc grpc1.ClientConn) MsgServiceClient { - return &msgServiceClient{cc} -} - -func (c *msgServiceClient) AddWithdrawal(ctx context.Context, in *MsgAddWithdrawal, opts ...grpc.CallOption) (*MsgAddWithdrawalResponse, error) { - out := new(MsgAddWithdrawalResponse) - err := c.cc.Invoke(ctx, "/client.x.evmstaking.types.MsgService/AddWithdrawal", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *msgServiceClient) RemoveWithdrawal(ctx context.Context, in *MsgRemoveWithdrawal, opts ...grpc.CallOption) (*MsgRemoveWithdrawalResponse, error) { - out := new(MsgRemoveWithdrawalResponse) - err := c.cc.Invoke(ctx, "/client.x.evmstaking.types.MsgService/RemoveWithdrawal", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// MsgServiceServer is the server API for MsgService service. -type MsgServiceServer interface { - // AddWithdrawal defines a method to add a withdrawal to the withdrawal queue. - AddWithdrawal(context.Context, *MsgAddWithdrawal) (*MsgAddWithdrawalResponse, error) - // RemoveWithdrawal defines a method to remove a withdrawal request from the withdrawal queue. - RemoveWithdrawal(context.Context, *MsgRemoveWithdrawal) (*MsgRemoveWithdrawalResponse, error) -} - -// UnimplementedMsgServiceServer can be embedded to have forward compatible implementations. -type UnimplementedMsgServiceServer struct { -} - -func (*UnimplementedMsgServiceServer) AddWithdrawal(ctx context.Context, req *MsgAddWithdrawal) (*MsgAddWithdrawalResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method AddWithdrawal not implemented") -} -func (*UnimplementedMsgServiceServer) RemoveWithdrawal(ctx context.Context, req *MsgRemoveWithdrawal) (*MsgRemoveWithdrawalResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method RemoveWithdrawal not implemented") -} - -func RegisterMsgServiceServer(s grpc1.Server, srv MsgServiceServer) { - s.RegisterService(&_MsgService_serviceDesc, srv) -} - -func _MsgService_AddWithdrawal_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgAddWithdrawal) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServiceServer).AddWithdrawal(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/client.x.evmstaking.types.MsgService/AddWithdrawal", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServiceServer).AddWithdrawal(ctx, req.(*MsgAddWithdrawal)) - } - return interceptor(ctx, in, info, handler) -} - -func _MsgService_RemoveWithdrawal_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgRemoveWithdrawal) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServiceServer).RemoveWithdrawal(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/client.x.evmstaking.types.MsgService/RemoveWithdrawal", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServiceServer).RemoveWithdrawal(ctx, req.(*MsgRemoveWithdrawal)) - } - return interceptor(ctx, in, info, handler) -} - -var _MsgService_serviceDesc = grpc.ServiceDesc{ - ServiceName: "client.x.evmstaking.types.MsgService", - HandlerType: (*MsgServiceServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "AddWithdrawal", - Handler: _MsgService_AddWithdrawal_Handler, - }, - { - MethodName: "RemoveWithdrawal", - Handler: _MsgService_RemoveWithdrawal_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "client/x/evmstaking/types/tx.proto", -} - -func (m *MsgAddWithdrawal) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *MsgAddWithdrawal) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgAddWithdrawal) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Withdrawal != nil { - { - size, err := m.Withdrawal.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - if len(m.Authority) > 0 { - i -= len(m.Authority) - copy(dAtA[i:], m.Authority) - i = encodeVarintTx(dAtA, i, uint64(len(m.Authority))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *MsgAddWithdrawalResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *MsgAddWithdrawalResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgAddWithdrawalResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.RequestIdDelegatorValidator != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.RequestIdDelegatorValidator)) - i-- - dAtA[i] = 0x10 - } - if m.RequestIndex != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.RequestIndex)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *MsgRemoveWithdrawal) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *MsgRemoveWithdrawal) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgRemoveWithdrawal) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.RequestIdDelegatorValidator != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.RequestIdDelegatorValidator)) - i-- - dAtA[i] = 0x20 - } - if len(m.Validator) > 0 { - i -= len(m.Validator) - copy(dAtA[i:], m.Validator) - i = encodeVarintTx(dAtA, i, uint64(len(m.Validator))) - i-- - dAtA[i] = 0x1a - } - if len(m.Delegator) > 0 { - i -= len(m.Delegator) - copy(dAtA[i:], m.Delegator) - i = encodeVarintTx(dAtA, i, uint64(len(m.Delegator))) - i-- - dAtA[i] = 0x12 - } - if len(m.Authority) > 0 { - i -= len(m.Authority) - copy(dAtA[i:], m.Authority) - i = encodeVarintTx(dAtA, i, uint64(len(m.Authority))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *MsgRemoveWithdrawalResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *MsgRemoveWithdrawalResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgRemoveWithdrawalResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} - -func encodeVarintTx(dAtA []byte, offset int, v uint64) int { - offset -= sovTx(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *MsgAddWithdrawal) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Authority) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - if m.Withdrawal != nil { - l = m.Withdrawal.Size() - n += 1 + l + sovTx(uint64(l)) - } - return n -} - -func (m *MsgAddWithdrawalResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.RequestIndex != 0 { - n += 1 + sovTx(uint64(m.RequestIndex)) - } - if m.RequestIdDelegatorValidator != 0 { - n += 1 + sovTx(uint64(m.RequestIdDelegatorValidator)) - } - return n -} - -func (m *MsgRemoveWithdrawal) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Authority) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.Delegator) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.Validator) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - if m.RequestIdDelegatorValidator != 0 { - n += 1 + sovTx(uint64(m.RequestIdDelegatorValidator)) - } - return n -} - -func (m *MsgRemoveWithdrawalResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - -func sovTx(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozTx(x uint64) (n int) { - return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *MsgAddWithdrawal) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: MsgAddWithdrawal: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgAddWithdrawal: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Authority", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Authority = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Withdrawal", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Withdrawal == nil { - m.Withdrawal = &Withdrawal{} - } - if err := m.Withdrawal.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *MsgAddWithdrawalResponse) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: MsgAddWithdrawalResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgAddWithdrawalResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field RequestIndex", wireType) - } - m.RequestIndex = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.RequestIndex |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field RequestIdDelegatorValidator", wireType) - } - m.RequestIdDelegatorValidator = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.RequestIdDelegatorValidator |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *MsgRemoveWithdrawal) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: MsgRemoveWithdrawal: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgRemoveWithdrawal: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Authority", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Authority = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Delegator", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Delegator = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Validator", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Validator = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 4: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field RequestIdDelegatorValidator", wireType) - } - m.RequestIdDelegatorValidator = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.RequestIdDelegatorValidator |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *MsgRemoveWithdrawalResponse) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: MsgRemoveWithdrawalResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgRemoveWithdrawalResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipTx(dAtA []byte) (n int, err error) { - l := len(dAtA) - iNdEx := 0 - depth := 0 - for iNdEx < l { - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowTx - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - wireType := int(wire & 0x7) - switch wireType { - case 0: - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowTx - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - iNdEx++ - if dAtA[iNdEx-1] < 0x80 { - break - } - } - case 1: - iNdEx += 8 - case 2: - var length int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowTx - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - length |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if length < 0 { - return 0, ErrInvalidLengthTx - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupTx - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthTx - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthTx = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowTx = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupTx = fmt.Errorf("proto: unexpected end of group") -) diff --git a/client/x/evmstaking/types/tx.proto b/client/x/evmstaking/types/tx.proto deleted file mode 100644 index 5466c3ba..00000000 --- a/client/x/evmstaking/types/tx.proto +++ /dev/null @@ -1,44 +0,0 @@ -syntax = "proto3"; -package client.x.evmstaking.types; - -import "gogoproto/gogo.proto"; -import "cosmos/msg/v1/msg.proto"; -import "client/x/evmstaking/types/evmstaking.proto"; - -option go_package = "client/x/evmstaking/types"; - -//// MsgService defines all the gRPC methods exposed by the evmstaking module. -service MsgService { - option (cosmos.msg.v1.service) = true; - - // AddWithdrawal defines a method to add a withdrawal to the withdrawal queue. - rpc AddWithdrawal(MsgAddWithdrawal) returns (MsgAddWithdrawalResponse); - - // RemoveWithdrawal defines a method to remove a withdrawal request from the withdrawal queue. - rpc RemoveWithdrawal(MsgRemoveWithdrawal) returns (MsgRemoveWithdrawalResponse); -} - -// MsgAddWithdrawal represents a message to add a withdrawal request to the withdrawal queue. -message MsgAddWithdrawal { - option (cosmos.msg.v1.signer) = "authority"; - string authority = 1; // authtypes.NewModuleAddress(types.ModuleName).String() - Withdrawal withdrawal = 2 [(gogoproto.moretags) = "yaml:\"withdrawal\""]; -} - -// MsgAddWithdrawalResponse defines the Msg/AddWithdrawal response type. -message MsgAddWithdrawalResponse { - uint64 request_index = 1 [(gogoproto.moretags) = "yaml:\"request_index\""]; - uint64 request_id_delegator_validator = 2 [(gogoproto.moretags) = "yaml:\"request_id_delegator_validator\""]; -} - -// MsgRemoveWithdrawal represents a message to remove a withdrawal request from the withdrawal queue. -message MsgRemoveWithdrawal { - option (cosmos.msg.v1.signer) = "authority"; - string authority = 1; // authtypes.NewModuleAddress(types.ModuleName).String() - string delegator = 2 [(gogoproto.moretags) = "yaml:\"delegator\""]; - string validator = 3 [(gogoproto.moretags) = "yaml:\"validator\""]; - uint64 request_id_delegator_validator = 4 [(gogoproto.moretags) = "yaml:\"request_id_delegator_validator\""]; -} - -// MsgRemoveWithdrawalResponse defines the Msg/RemoveWithdrawal response type. -message MsgRemoveWithdrawalResponse {} \ No newline at end of file diff --git a/client/x/evmstaking/types/withdraw.go b/client/x/evmstaking/types/withdraw.go index 60893a4b..b63a0cdd 100644 --- a/client/x/evmstaking/types/withdraw.go +++ b/client/x/evmstaking/types/withdraw.go @@ -25,22 +25,10 @@ func (ws Withdrawals) Len() int { } // TODO amount as math.Int. -func NewWithdrawal(creationHeight uint64, delegatorAddr string, validatorAddr string, executionAddr string, amount uint64) Withdrawal { +func NewWithdrawal(creationHeight uint64, executionAddr string, amount uint64) Withdrawal { return Withdrawal{ CreationHeight: creationHeight, - DelegatorAddress: delegatorAddr, - ValidatorAddress: validatorAddr, ExecutionAddress: executionAddr, Amount: amount, } } - -func NewWithdrawalFromMsg(msg *MsgAddWithdrawal) Withdrawal { - return Withdrawal{ - CreationHeight: msg.Withdrawal.CreationHeight, - DelegatorAddress: msg.Withdrawal.DelegatorAddress, - ValidatorAddress: msg.Withdrawal.ValidatorAddress, - ExecutionAddress: msg.Withdrawal.ExecutionAddress, - Amount: msg.Withdrawal.Amount, - } -} diff --git a/client/x/evmstaking/types/withdraw_test.go b/client/x/evmstaking/types/withdraw_test.go index 29f873b4..1153215f 100644 --- a/client/x/evmstaking/types/withdraw_test.go +++ b/client/x/evmstaking/types/withdraw_test.go @@ -39,23 +39,23 @@ func (suite *WithdrawTestSuite) TestString() { }{ { name: "Normal values", - withdrawal: types.NewWithdrawal(1, suite.delAddr, suite.valAddr, suite.evmAddr.String(), 100), - expectedString: fmt.Sprintf("creation_height:1 delegator_address:\"%s\" validator_address:\"%s\" execution_address:\"%s\" amount:100 ", suite.delAddr, suite.valAddr, suite.evmAddr.String()), + withdrawal: types.NewWithdrawal(1, suite.evmAddr.String(), 100), + expectedString: fmt.Sprintf("creation_height:1 execution_address:\"%s\" amount:100 ", suite.evmAddr.String()), }, { name: "Empty addresses", - withdrawal: types.NewWithdrawal(1, "", "", "", 1), + withdrawal: types.NewWithdrawal(1, "", 1), expectedString: "creation_height:1 amount:1 ", }, { name: "Large amount", - withdrawal: types.NewWithdrawal(1, suite.delAddr, suite.valAddr, suite.evmAddr.String(), math.MaxUint64), - expectedString: fmt.Sprintf("creation_height:1 delegator_address:\"%s\" validator_address:\"%s\" execution_address:\"%s\" amount:%s ", suite.delAddr, suite.valAddr, suite.evmAddr.String(), new(big.Int).SetUint64(math.MaxUint64).String()), + withdrawal: types.NewWithdrawal(1, suite.evmAddr.String(), math.MaxUint64), + expectedString: fmt.Sprintf("creation_height:1 execution_address:\"%s\" amount:%s ", suite.evmAddr.String(), new(big.Int).SetUint64(math.MaxUint64).String()), }, { name: "Zero amount", - withdrawal: types.NewWithdrawal(1, suite.delAddr, suite.valAddr, suite.evmAddr.String(), 0), - expectedString: fmt.Sprintf("creation_height:1 delegator_address:\"%s\" validator_address:\"%s\" execution_address:\"%s\" ", suite.delAddr, suite.valAddr, suite.evmAddr.String()), + withdrawal: types.NewWithdrawal(1, suite.evmAddr.String(), 0), + expectedString: fmt.Sprintf("creation_height:1 execution_address:\"%s\" ", suite.evmAddr.String()), }, } @@ -72,16 +72,16 @@ func (suite *WithdrawTestSuite) TestWithdrawalsString() { require := suite.Require() ws := types.Withdrawals{ Withdrawals: []types.Withdrawal{ - types.NewWithdrawal(1, suite.delAddr, suite.valAddr, suite.evmAddr.String(), 1), - types.NewWithdrawal(2, suite.delAddr, suite.valAddr, suite.evmAddr.String(), 2), + types.NewWithdrawal(1, suite.evmAddr.String(), 1), + types.NewWithdrawal(2, suite.evmAddr.String(), 2), }, } expectedString := fmt.Sprintf( - "creation_height:1 delegator_address:\"%s\" validator_address:\"%s\" execution_address:\"%s\" amount:1 \n"+ - "creation_height:2 delegator_address:\"%s\" validator_address:\"%s\" execution_address:\"%s\" amount:2", - suite.delAddr, suite.valAddr, suite.evmAddr.String(), - suite.delAddr, suite.valAddr, suite.evmAddr.String(), + "creation_height:1 execution_address:\"%s\" amount:1 \n"+ + "creation_height:2 execution_address:\"%s\" amount:2", + suite.evmAddr.String(), + suite.evmAddr.String(), ) require.Equal(expectedString, ws.String()) } @@ -90,25 +90,14 @@ func (suite *WithdrawTestSuite) TestWithdrawalsLen() { require := suite.Require() ws := types.Withdrawals{ Withdrawals: []types.Withdrawal{ - types.NewWithdrawal(1, suite.delAddr, suite.valAddr, suite.evmAddr.String(), 1), - types.NewWithdrawal(2, suite.delAddr, suite.valAddr, suite.evmAddr.String(), 2), + types.NewWithdrawal(1, suite.evmAddr.String(), 1), + types.NewWithdrawal(2, suite.evmAddr.String(), 2), }, } require.Equal(2, ws.Len()) } -func (suite *WithdrawTestSuite) TestNewWithdrawalFromMsg() { - require := suite.Require() - withdrawal := types.NewWithdrawal(1, suite.delAddr, suite.valAddr, suite.evmAddr.String(), 1) - msgAddwithdrawal := types.MsgAddWithdrawal{ - Authority: "gov", - Withdrawal: &withdrawal, - } - w := types.NewWithdrawalFromMsg(&msgAddwithdrawal) - require.Equal(withdrawal, w, "NewWithdrawalFromMsg should return the same withdrawal") -} - func TestWithdrawalTestSuite(t *testing.T) { t.Parallel() suite.Run(t, new(WithdrawTestSuite)) From cfaa244f58d224d1a7f7b60b97ea41a574b12ecd Mon Sep 17 00:00:00 2001 From: ezreal1997 Date: Thu, 17 Oct 2024 15:53:55 -0700 Subject: [PATCH 4/8] feat(x/evmstaking): genesis file changes --- lib/netconf/local/genesis.json | 42 +++++++++++++++++++++++++++++--- lib/netconf/odyssey/genesis.json | 42 +++++++++++++++++++++++++++++--- 2 files changed, 78 insertions(+), 6 deletions(-) diff --git a/lib/netconf/local/genesis.json b/lib/netconf/local/genesis.json index 74ef6018..f34bb8eb 100644 --- a/lib/netconf/local/genesis.json +++ b/lib/netconf/local/genesis.json @@ -88,7 +88,7 @@ }, "evmengine": { "params": { - "execution_block_hash": "jz/Faw3DoAnmdx2pn/c3kA2oS5rq4V0briJcyLTbvcM=" + "execution_block_hash": "SKN77ZT8Hkr0IgtlckPZ0cAC94Pzu5FU/EYuAYtEqKM=" } }, "genutil": { @@ -160,7 +160,42 @@ "max_entries": 7, "historical_entries": 10000, "bond_denom": "stake", - "min_commission_rate": "0.000000000000000000" + "min_commission_rate": "0.000000000000000000", + "min_delegation": "1024", + "flexible_period_type": 0, + "periods": [ + { + "period_type": 0, + "duration": "0s", + "rewards_multiplier": "1.000000000000000000" + }, + { + "period_type": 1, + "duration": "60s", + "rewards_multiplier": "1.051000000000000000" + }, + { + "period_type": 2, + "duration": "120s", + "rewards_multiplier": "1.160000000000000000" + }, + { + "period_type": 3, + "duration": "180s", + "rewards_multiplier": "1.340000000000000000" + } + ], + "locked_token_type": 0, + "token_types": [ + { + "token_type": 0, + "rewards_multiplier": "0.500000000000000000" + }, + { + "token_type": 1, + "rewards_multiplier": "1.000000000000000000" + } + ] }, "last_total_power": "0", "last_validator_powers": [], @@ -176,7 +211,8 @@ "max_withdrawal_per_block": 32, "max_sweep_per_block": 128, "min_partial_withdrawal_amount": 100000000, - "singularity_height": "30" + "singularity_height": "30", + "ubi_withdraw_address": "0x09a4A605bed3369Bc161B93922f0fd3Ff08bfC33" } }, "mint": { diff --git a/lib/netconf/odyssey/genesis.json b/lib/netconf/odyssey/genesis.json index 16493400..48f6e508 100644 --- a/lib/netconf/odyssey/genesis.json +++ b/lib/netconf/odyssey/genesis.json @@ -212,7 +212,7 @@ }, "evmengine": { "params": { - "execution_block_hash": "9evG8Jgui/f9Uys/lZ+E0Ss97dKCevjTH1OJRHvtr8Y=" + "execution_block_hash": "SKN77ZT8Hkr0IgtlckPZ0cAC94Pzu5FU/EYuAYtEqKM=" } }, "genutil": { @@ -613,7 +613,42 @@ "max_entries": 7, "historical_entries": 10000, "bond_denom": "stake", - "min_commission_rate": "0.000000000000000000" + "min_commission_rate": "0.000000000000000000", + "min_delegation": "1024", + "flexible_period_type": 0, + "periods": [ + { + "period_type": 0, + "duration": "0s", + "rewards_multiplier": "1.000000000000000000" + }, + { + "period_type": 1, + "duration": "60s", + "rewards_multiplier": "1.051000000000000000" + }, + { + "period_type": 2, + "duration": "120s", + "rewards_multiplier": "1.160000000000000000" + }, + { + "period_type": 3, + "duration": "180s", + "rewards_multiplier": "1.340000000000000000" + } + ], + "locked_token_type": 0, + "token_types": [ + { + "token_type": 0, + "rewards_multiplier": "0.500000000000000000" + }, + { + "token_type": 1, + "rewards_multiplier": "1.000000000000000000" + } + ] }, "last_total_power": "0", "last_validator_powers": [], @@ -627,7 +662,8 @@ "params": { "max_withdrawal_per_block": 32, "max_sweep_per_block": 128, - "min_partial_withdrawal_amount": 100000000 + "min_partial_withdrawal_amount": 100000000, + "ubi_withdraw_address": "0x09a4A605bed3369Bc161B93922f0fd3Ff08bfC33" } }, "mint": { From be5b746bb6fca98cf3a4f75a41e81ac7506ed2c1 Mon Sep 17 00:00:00 2001 From: ezreal1997 Date: Thu, 17 Oct 2024 16:03:05 -0700 Subject: [PATCH 5/8] feat(x/evmstaking): genesis file changes --- lib/netconf/odyssey/genesis.json | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/netconf/odyssey/genesis.json b/lib/netconf/odyssey/genesis.json index 48f6e508..326ed82b 100644 --- a/lib/netconf/odyssey/genesis.json +++ b/lib/netconf/odyssey/genesis.json @@ -663,6 +663,7 @@ "max_withdrawal_per_block": 32, "max_sweep_per_block": 128, "min_partial_withdrawal_amount": 100000000, + "singularity_height": "512000", "ubi_withdraw_address": "0x09a4A605bed3369Bc161B93922f0fd3Ff08bfC33" } }, From 037f7d9d6d6d882dad6497ecaf2d70dae0a9727d Mon Sep 17 00:00:00 2001 From: ezreal1997 Date: Thu, 17 Oct 2024 16:05:52 -0700 Subject: [PATCH 6/8] feat(x/evmstaking): go.mod --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index f593bb8c..b8c295ad 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( // (Replace is done below) cosmossdk.io/core v0.12.0 cosmossdk.io/depinject v1.0.0-alpha.4 - cosmossdk.io/errors v1.0.1 + cosmossdk.io/errors v1.0.1 // indirect cosmossdk.io/log v1.3.1 cosmossdk.io/math v1.3.0 cosmossdk.io/orm v1.0.0-beta.3 From a8126457a69f9253628945b96a39392140e0607d Mon Sep 17 00:00:00 2001 From: ezreal1997 Date: Thu, 17 Oct 2024 16:18:46 -0700 Subject: [PATCH 7/8] fix(x/distribution): update cosmos sdk deps version --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index b8c295ad..3f0d9207 100644 --- a/go.mod +++ b/go.mod @@ -295,7 +295,7 @@ replace ( cosmossdk.io/core v0.12.0 => cosmossdk.io/core v0.11.0 // Direct cosmos-sdk branch link: https://github.com/piplabs/cosmos-sdk/tree/piplabs/v0.50.7, current branch: piplabs/v0.50.7 - github.com/cosmos/cosmos-sdk => github.com/piplabs/cosmos-sdk v0.50.7-piplabs-v0.7 + github.com/cosmos/cosmos-sdk => github.com/piplabs/cosmos-sdk v0.50.7-piplabs-v0.8 // See https://github.com/cosmos/cosmos-sdk/pull/14952 // Also https://github.com/cosmos/cosmos-db/blob/main/go.mod#L11-L12 diff --git a/go.sum b/go.sum index 2fd1ed8c..654c2d5d 100644 --- a/go.sum +++ b/go.sum @@ -1032,8 +1032,8 @@ github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0 github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4= github.com/pingcap/errors v0.11.4/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8= -github.com/piplabs/cosmos-sdk v0.50.7-piplabs-v0.7 h1:gHKPCEoP7dj2jiA9htL/GVLrx+EshZ5yDd8hBdIkDSY= -github.com/piplabs/cosmos-sdk v0.50.7-piplabs-v0.7/go.mod h1:84xDDJEHttRT7NDGwBaUOLVOMN0JNE9x7NbsYIxXs1s= +github.com/piplabs/cosmos-sdk v0.50.7-piplabs-v0.8 h1:e32GjvgyT4tZ1YDy64bMLKHP3r5GY1a2GqDuzL4ZaWQ= +github.com/piplabs/cosmos-sdk v0.50.7-piplabs-v0.8/go.mod h1:84xDDJEHttRT7NDGwBaUOLVOMN0JNE9x7NbsYIxXs1s= github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ= github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU= github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= From fd30d41f76a0d3f90074c6d6044676c645908606 Mon Sep 17 00:00:00 2001 From: ezreal1997 Date: Thu, 17 Oct 2024 16:33:35 -0700 Subject: [PATCH 8/8] fix(x/evmengine): update evm block hash --- lib/netconf/local/genesis.json | 2 +- lib/netconf/odyssey/genesis.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/netconf/local/genesis.json b/lib/netconf/local/genesis.json index f34bb8eb..97af95fe 100644 --- a/lib/netconf/local/genesis.json +++ b/lib/netconf/local/genesis.json @@ -88,7 +88,7 @@ }, "evmengine": { "params": { - "execution_block_hash": "SKN77ZT8Hkr0IgtlckPZ0cAC94Pzu5FU/EYuAYtEqKM=" + "execution_block_hash": "MtGd+Hzb4VnGm+PGTXDJhSkChm+iUjUGCX7LUS8o754=" } }, "genutil": { diff --git a/lib/netconf/odyssey/genesis.json b/lib/netconf/odyssey/genesis.json index 326ed82b..642c2665 100644 --- a/lib/netconf/odyssey/genesis.json +++ b/lib/netconf/odyssey/genesis.json @@ -212,7 +212,7 @@ }, "evmengine": { "params": { - "execution_block_hash": "SKN77ZT8Hkr0IgtlckPZ0cAC94Pzu5FU/EYuAYtEqKM=" + "execution_block_hash": "MtGd+Hzb4VnGm+PGTXDJhSkChm+iUjUGCX7LUS8o754=" } }, "genutil": {