Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

batching delegations and undelegations #1263

Merged
merged 46 commits into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
10a1abd
Batched delegations (#1201)
sampocs Jun 13, 2024
74c51cb
batched undelegations (#1195)
sampocs Jun 13, 2024
99d773f
staketia migration (#1212)
sampocs Jun 13, 2024
a5b31a6
fixed unit tests
sampocs Jun 13, 2024
1582770
V23 upgrade handler (batching and stTIA) (#1219)
sampocs Jun 13, 2024
95f12fd
added TODO
sampocs Jun 14, 2024
cd8d976
[AUDIT FIX] - short circuit callback on completed records
sampocs Jun 14, 2024
def6f4a
[AUDIT FIX] - decrement remaining delegated balance in redeem stake
sampocs Jun 20, 2024
f1fe92c
[AUDIT FIX] - set min/max inner redemption rate after migration
sampocs Jun 20, 2024
df38a31
[AUDIT FIX] - updated total delegations in confirm delegation
sampocs Jun 20, 2024
c3ffbf6
Merge branch 'main' into v23
sampocs Jun 20, 2024
25ed61b
[AUDIT FIX] migrate halted field, remove prepare delegation, clarifyi…
sampocs Jun 29, 2024
66041f3
[AUDIT FIX] decrement total delegations in adjust delegated balance
sampocs Jul 9, 2024
82a007b
[AUDIT FIX] enable stakeibc redemptions with if exact remaining amoun…
sampocs Jul 9, 2024
7e4a9a9
[AUDIT FIX] set delegation/undelegationTxsInProgress in migration
sampocs Jul 10, 2024
07d8a83
reset delegation txs in progress to 0 in restore-ica
sampocs Jul 18, 2024
639777d
addressed riley and vishal pr comments
sampocs Jul 26, 2024
38555eb
updated package from v22 -> v23
sampocs Jul 26, 2024
81f7cc9
generated protos
sampocs Jul 26, 2024
68deb54
moved upgrade to v24
sampocs Jul 26, 2024
8fdf6c6
removed trade route migration from v24 upgrade
sampocs Jul 26, 2024
d35a8e8
Merge branch 'main' into v23
sampocs Jul 26, 2024
72b9b41
fixed unit tests
sampocs Jul 26, 2024
13288dd
copied over the redemption rate update functions into staketia migration
sampocs Jul 26, 2024
ec24683
fixed build errors and updated RR functions
sampocs Jul 26, 2024
046f992
added invariant from RR change
sampocs Jul 26, 2024
5c79959
removed debug logs
sampocs Jul 26, 2024
07f1411
fixed unit test
sampocs Jul 26, 2024
c9b390d
nit
sampocs Jul 26, 2024
059843d
moved up RR invariant check and removed balance check
sampocs Aug 6, 2024
a57552d
nit, used GetActiveHostZone and moved epoch tracker
sampocs Aug 6, 2024
f5574b1
fixed unit tests
sampocs Aug 6, 2024
19e3617
nit: fixed comment typo in icacallbacks_undelegate.go
sampocs Aug 7, 2024
b58fea0
Merge branch 'main' into v23
assafmo Aug 8, 2024
afa4bfb
Merge branch 'main' into v23
sampocs Aug 16, 2024
308de94
reverted all stTIA migration changes
sampocs Aug 16, 2024
79a0028
removed net new files from sttia
sampocs Aug 16, 2024
6d39b4e
removed staketia migration call from upgrade handler
sampocs Aug 16, 2024
3db83e2
added full upgrade handler test
sampocs Aug 16, 2024
3a3745f
moved redemption sweep to stride epoch (#1265)
sampocs Aug 16, 2024
c176fe6
fixed unit tests
sampocs Aug 23, 2024
af9debb
fixed lint errors in claim/utils/icacallbacks/mint/icaoracle/intercha…
sampocs Aug 23, 2024
ad10e1e
fixed lint errors in icacallbacks
sampocs Aug 23, 2024
a0ef012
fixed lint errors in the rest of stakeibc
sampocs Aug 23, 2024
c3642aa
fixed lint errors in upgrades, autopilot, icacallbacks, and mint
sampocs Aug 26, 2024
90d4085
addressed riley pr comments
sampocs Aug 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/upgrades/v14/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ func ClearPendingQueries(ctx sdk.Context, k icqkeeper.Keeper) {
func EnableLSMForGaia(ctx sdk.Context, k stakeibckeeper.Keeper) error {
hostZone, found := k.GetHostZone(ctx, GaiaChainId)
if !found {
return stakeibctypes.ErrHostZoneNotFound.Wrapf(GaiaChainId)
return stakeibctypes.ErrHostZoneNotFound.Wrap(GaiaChainId)
}

hostZone.LsmLiquidStakeEnabled = true
Expand Down
4 changes: 1 addition & 3 deletions app/upgrades/v6/upgrades.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package v6

import (
"fmt"

errorsmod "cosmossdk.io/errors"
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
Expand All @@ -29,7 +27,7 @@ func CreateUpgradeHandler(
airdropClaimTypes := []string{"stride", "gaia", "osmosis", "juno", "stars"}
for _, claimType := range airdropClaimTypes {
if err := claimKeeper.ResetClaimStatus(ctx, claimType); err != nil {
return vm, errorsmod.Wrapf(err, fmt.Sprintf("unable to reset %s claim status", claimType))
return vm, errorsmod.Wrapf(err, "unable to reset %s claim status", claimType)
}
}
return mm.RunMigrations(ctx, configurator, vm)
Expand Down
3 changes: 1 addition & 2 deletions app/upgrades/v8/upgrades.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package v8

import (
"fmt"
"time"

errorsmod "cosmossdk.io/errors"
Expand Down Expand Up @@ -45,7 +44,7 @@ func CreateUpgradeHandler(
ctx.Logger().Info("Resetting airdrop claims...")
for _, claimType := range ResetAirdropIdentifiers {
if err := claimKeeper.ResetClaimStatus(ctx, claimType); err != nil {
return vm, errorsmod.Wrapf(err, fmt.Sprintf("unable to reset %s claim status", claimType))
return vm, errorsmod.Wrapf(err, "unable to reset %s claim status", claimType)
}
}

Expand Down
4 changes: 2 additions & 2 deletions x/airdrop/keeper/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func (k Keeper) Airdrop(goCtx context.Context, req *types.QueryAirdropRequest) (
if err == types.ErrAirdropNotStarted || err == types.ErrAirdropEnded {
currentDateIndex = -1
} else if err != nil {
return nil, status.Errorf(codes.FailedPrecondition, err.Error())
return nil, status.Error(codes.FailedPrecondition, err.Error())
}

airdropResponse := types.QueryAirdropResponse{
Expand Down Expand Up @@ -148,7 +148,7 @@ func (k Keeper) UserSummary(goCtx context.Context, req *types.QueryUserSummaryRe
} else if err == types.ErrAirdropNotStarted || err == types.ErrAirdropEnded {
claimable = sdkmath.ZeroInt()
} else {
return nil, status.Errorf(codes.FailedPrecondition, err.Error())
return nil, status.Error(codes.FailedPrecondition, err.Error())
}

claimType := types.CLAIM_DAILY
Expand Down
2 changes: 1 addition & 1 deletion x/autopilot/keeper/airdrop.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func (k Keeper) TryUpdateAirdropClaim(
// grab relevant addresses
senderStrideAddress := utils.ConvertAddressToStrideAddress(transferMetadata.Sender)
if senderStrideAddress == "" {
return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, fmt.Sprintf("invalid sender address (%s)", transferMetadata.Sender))
return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid sender address (%s)", transferMetadata.Sender)
}
newStrideAddress := transferMetadata.Receiver

Expand Down
8 changes: 4 additions & 4 deletions x/autopilot/types/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func ParseAutopilotMetadata(metadata string) (*AutopilotMetadata, error) {
middlewareModulesEnabled++
}
if middlewareModulesEnabled > 1 {
return nil, errorsmod.Wrapf(ErrInvalidPacketMetadata,
return nil, errorsmod.Wrap(ErrInvalidPacketMetadata,
"only one of autopilot, pfm, and wasm can both be used in the same packet")
}

Expand All @@ -91,7 +91,7 @@ func ParseAutopilotMetadata(metadata string) (*AutopilotMetadata, error) {

// Confirm a receiver address was supplied
if _, err := sdk.AccAddressFromBech32(raw.Autopilot.Receiver); err != nil {
return nil, errorsmod.Wrapf(ErrInvalidPacketMetadata, ErrInvalidReceiverAddress.Error())
return nil, errorsmod.Wrap(ErrInvalidPacketMetadata, ErrInvalidReceiverAddress.Error())
}

// Parse the packet info into the specific module type
Expand All @@ -111,12 +111,12 @@ func ParseAutopilotMetadata(metadata string) (*AutopilotMetadata, error) {
routingInfo = *raw.Autopilot.Claim
}
if moduleCount != 1 {
return nil, errorsmod.Wrapf(ErrInvalidPacketMetadata, ErrInvalidModuleRoutes.Error())
return nil, errorsmod.Wrap(ErrInvalidPacketMetadata, ErrInvalidModuleRoutes.Error())
}

// Validate the packet info according to the specific module type
if err := routingInfo.Validate(); err != nil {
return nil, errorsmod.Wrapf(err, ErrInvalidPacketMetadata.Error())
return nil, errorsmod.Wrap(err, ErrInvalidPacketMetadata.Error())
}

return &AutopilotMetadata{
Expand Down
4 changes: 1 addition & 3 deletions x/icacallbacks/ibc_module.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,7 @@ func (im IBCModule) OnTimeoutPacket(
}

if err := im.keeper.CallRegisteredICACallback(ctx, packet, &ackResponse); err != nil {
errMsg := fmt.Sprintf("Unable to call registered ICACallback from OnTimeoutPacket, Packet: %+v", packet)
im.keeper.Logger(ctx).Error(errMsg)
return errorsmod.Wrapf(types.ErrCallbackFailed, errMsg)
return errorsmod.Wrapf(err, "Unable to call registered ICACallback from OnTimeoutPacket, Packet: %+v", packet)
}
return nil
}
Expand Down
12 changes: 6 additions & 6 deletions x/icacallbacks/migrations/v2/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,14 @@ func convertCallbackData(oldCallbackData icacallbacktypes.CallbackData) (icacall
// Deserialize the callback args with the old DelegateCallback type
oldDelegateCallback := oldstakeibctypes.DelegateCallback{}
if err := proto.Unmarshal(oldCallbackData.CallbackArgs, &oldDelegateCallback); err != nil {
return icacallbacktypes.CallbackData{}, errorsmod.Wrapf(stakeibctypes.ErrUnmarshalFailure, err.Error())
return icacallbacktypes.CallbackData{}, errorsmod.Wrapf(err, "failed to unmarshal")
sampocs marked this conversation as resolved.
Show resolved Hide resolved
}

// Convert and serialize with the new DelegateCallback type
newDelegateCallback := convertDelegateCallback(oldDelegateCallback)
newDelegateCallbackBz, err := proto.Marshal(&newDelegateCallback)
if err != nil {
return icacallbacktypes.CallbackData{}, errorsmod.Wrapf(stakeibctypes.ErrMarshalFailure, err.Error())
return icacallbacktypes.CallbackData{}, errorsmod.Wrapf(err, "failed to marshal")
}

// Update the CallbackData with the new args
Expand All @@ -91,14 +91,14 @@ func convertCallbackData(oldCallbackData icacallbacktypes.CallbackData) (icacall
// Deserialize the callback args with the old UndelegateCallback type
oldUndelegateCallback := oldstakeibctypes.UndelegateCallback{}
if err := proto.Unmarshal(oldCallbackData.CallbackArgs, &oldUndelegateCallback); err != nil {
return icacallbacktypes.CallbackData{}, errorsmod.Wrapf(stakeibctypes.ErrUnmarshalFailure, err.Error())
return icacallbacktypes.CallbackData{}, errorsmod.Wrapf(err, "failed to unmarshal")
}

// Convert and serialize with the new UndelegateCallback type
newUndelegateCallback := convertUndelegateCallback(oldUndelegateCallback)
newUndelegateCallbackBz, err := proto.Marshal(&newUndelegateCallback)
if err != nil {
return icacallbacktypes.CallbackData{}, errorsmod.Wrapf(stakeibctypes.ErrMarshalFailure, err.Error())
return icacallbacktypes.CallbackData{}, errorsmod.Wrapf(err, "failed to marshal")
}

// Update the CallbackData with the new args
Expand All @@ -108,14 +108,14 @@ func convertCallbackData(oldCallbackData icacallbacktypes.CallbackData) (icacall
// Deserialize the callback args with the old RebalanceCallback type
oldRebalanceCallback := oldstakeibctypes.RebalanceCallback{}
if err := proto.Unmarshal(oldCallbackData.CallbackArgs, &oldRebalanceCallback); err != nil {
return icacallbacktypes.CallbackData{}, errorsmod.Wrapf(stakeibctypes.ErrUnmarshalFailure, err.Error())
return icacallbacktypes.CallbackData{}, errorsmod.Wrapf(err, "failed to unmarshal")
}

// Convert and serialize with the new RebalanceCallback type
newRebalanceCallback := convertRebalanceCallback(oldRebalanceCallback)
newRebalanceCallbackBz, err := proto.Marshal(&newRebalanceCallback)
if err != nil {
return icacallbacktypes.CallbackData{}, errorsmod.Wrapf(stakeibctypes.ErrMarshalFailure, err.Error())
return icacallbacktypes.CallbackData{}, errorsmod.Wrapf(err, "failed to marshal")
}

// Update the CallbackData with the new args
Expand Down
4 changes: 2 additions & 2 deletions x/icacallbacks/migrations/v2/convert_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ func TestConvertCallbackData_Delegate_Error(t *testing.T) {

// The convert function should fail since it cannot unmarshal the callback args into a DelegateCallback
_, err := convertCallbackData(oldCallbackData)
require.ErrorContains(t, err, "unable to unmarshal data structure")
require.ErrorContains(t, err, "failed to unmarshal")
}

func TestConvertCallbackData_Rebalance_Success(t *testing.T) {
Expand Down Expand Up @@ -207,7 +207,7 @@ func TestConvertCallbackData_Rebalance_Error(t *testing.T) {

// The convert function should fail since it cannot unmarshal the callback args into a RebalanceCallback
_, err := convertCallbackData(oldCallbackData)
require.ErrorContains(t, err, "unable to unmarshal data structure")
require.ErrorContains(t, err, "failed to unmarshal")
}

func TestConvertCallbackData_Other(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion x/mint/types/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ func validateDistributionProportions(i interface{}) error {
totalProportions := v.Staking.Add(v.CommunityPoolGrowth).Add(v.CommunityPoolSecurityBudget).Add(v.StrategicReserve)

if !totalProportions.Equal(sdk.NewDec(1)) {
return fmt.Errorf(fmt.Sprintf("total distributions ratio should be 1, instead got %s", totalProportions.String()))
return fmt.Errorf("total distributions ratio should be 1, instead got %s", totalProportions.String())
}

return nil
Expand Down
Loading