Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

fix: track acknowledgements via a field #507

Merged
merged 6 commits into from
Jul 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/upgrades/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const (
V010404beta5UpgradeName = "v1.4.4-beta.5"
V010404beta7UpgradeName = "v1.4.4-beta.7"
V010404rc0UpgradeName = "v1.4.4-rc.0"
V010404beta8UpgradeName = "v1.4.4-beta.8"
)

// Upgrade defines a struct containing necessary fields that a SoftwareUpgradeProposal
Expand Down
25 changes: 25 additions & 0 deletions app/upgrades/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ func Upgrades() []Upgrade {
{UpgradeName: V010404beta5UpgradeName, CreateUpgradeHandler: V010404beta5UpgradeHandler},
{UpgradeName: V010404beta7UpgradeName, CreateUpgradeHandler: V010404beta7UpgradeHandler},
{UpgradeName: V010404rc0UpgradeName, CreateUpgradeHandler: V010404rc0UpgradeHandler},
{UpgradeName: V010404beta8UpgradeName, CreateUpgradeHandler: V010404beta8UpgradeHandler},
}
}

Expand Down Expand Up @@ -442,6 +443,30 @@ func V010404rc0UpgradeHandler(
}
}

func V010404beta8UpgradeHandler(
mm *module.Manager,
configurator module.Configurator,
appKeepers *keepers.AppKeepers,
) upgradetypes.UpgradeHandler {
return func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
if isTestnet(ctx) || isTest(ctx) || isDevnet(ctx) {
appKeepers.InterchainstakingKeeper.IterateWithdrawalRecords(ctx, func(index int64, record icstypes.WithdrawalRecord) (stop bool) {
if (record.Status == icstypes.WithdrawStatusSend) || record.Requeued || ((record.CompletionTime != time.Time{}) && (record.CompletionTime.Before(ctx.BlockTime()))) {
record.Acknowledged = true
}

if (record.ChainId == "elgafar-1") && (record.CompletionTime == time.Time{}) {
record.Acknowledged = true
}

appKeepers.InterchainstakingKeeper.SetWithdrawalRecord(ctx, record)
return false
})
}
return mm.RunMigrations(ctx, configurator, fromVM)
}
}

// func V010400UpgradeHandler(
// mm *module.Manager,
// configurator module.Configurator,
Expand Down
31 changes: 23 additions & 8 deletions docs/swagger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -764,6 +764,7 @@ paths:
- ClaimTypeOsmosisPool
- ClaimTypeCrescentPool
- ClaimTypeSifchainPool
- ClaimTypeUmeeToken
default: ClaimTypeUndefined
title: >-
- ClaimTypeUndefined: Undefined action (per protobuf
Expand Down Expand Up @@ -923,6 +924,7 @@ paths:
- ClaimTypeOsmosisPool
- ClaimTypeCrescentPool
- ClaimTypeSifchainPool
- ClaimTypeUmeeToken
default: ClaimTypeUndefined
title: >-
- ClaimTypeUndefined: Undefined action (per protobuf
Expand Down Expand Up @@ -1084,6 +1086,7 @@ paths:
- ClaimTypeOsmosisPool
- ClaimTypeCrescentPool
- ClaimTypeSifchainPool
- ClaimTypeUmeeToken
default: ClaimTypeUndefined
title: >-
- ClaimTypeUndefined: Undefined action (per protobuf
Expand Down Expand Up @@ -1245,6 +1248,7 @@ paths:
- ClaimTypeOsmosisPool
- ClaimTypeCrescentPool
- ClaimTypeSifchainPool
- ClaimTypeUmeeToken
default: ClaimTypeUndefined
title: >-
- ClaimTypeUndefined: Undefined action (per protobuf
Expand Down Expand Up @@ -1688,8 +1692,12 @@ paths:
if (any.is(Foo.class)) {
foo = any.unpack(Foo.class);
}
// or ...
if (any.isSameTypeAs(Foo.getDefaultInstance())) {
foo = any.unpack(Foo.getDefaultInstance());
}

Example 3: Pack and unpack a message in Python.
Example 3: Pack and unpack a message in Python.

foo = Foo(...)
any = Any()
Expand All @@ -1699,7 +1707,7 @@ paths:
any.Unpack(foo)
...

Example 4: Pack and unpack a message in Go
Example 4: Pack and unpack a message in Go

foo := &pb.Foo{...}
any, err := anypb.New(foo)
Expand Down Expand Up @@ -1727,10 +1735,8 @@ paths:
name "y.z".



JSON

====

The JSON representation of an `Any` value uses the regular

Expand Down Expand Up @@ -1999,8 +2005,12 @@ paths:
if (any.is(Foo.class)) {
foo = any.unpack(Foo.class);
}
// or ...
if (any.isSameTypeAs(Foo.getDefaultInstance())) {
foo = any.unpack(Foo.getDefaultInstance());
}

Example 3: Pack and unpack a message in Python.
Example 3: Pack and unpack a message in Python.

foo = Foo(...)
any = Any()
Expand All @@ -2010,7 +2020,7 @@ paths:
any.Unpack(foo)
...

Example 4: Pack and unpack a message in Go
Example 4: Pack and unpack a message in Go

foo := &pb.Foo{...}
any, err := anypb.New(foo)
Expand Down Expand Up @@ -2038,10 +2048,8 @@ paths:
name "y.z".



JSON

====

The JSON representation of an `Any` value uses the regular

Expand Down Expand Up @@ -2641,6 +2649,8 @@ paths:
format: date-time
requeued:
type: boolean
acknowledged:
type: boolean
pagination:
type: object
properties:
Expand Down Expand Up @@ -4415,6 +4425,8 @@ paths:
format: date-time
requeued:
type: boolean
acknowledged:
type: boolean
pagination:
type: object
properties:
Expand Down Expand Up @@ -4606,6 +4618,8 @@ paths:
format: date-time
requeued:
type: boolean
acknowledged:
type: boolean
pagination:
type: object
properties:
Expand Down Expand Up @@ -4914,6 +4928,7 @@ paths:
- ClaimTypeOsmosisPool
- ClaimTypeCrescentPool
- ClaimTypeSifchainPool
- ClaimTypeUmeeToken
default: ClaimTypeUndefined
title: '- ClaimTypeUndefined: Undefined action (per protobuf spec)'
proofs:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ message WithdrawalRecord {
(gogoproto.stdtime) = true
];
bool requeued = 10;
bool acknowledged = 11;
}

message UnbondingRecord {
Expand Down
5 changes: 4 additions & 1 deletion x/interchainstaking/keeper/ibc_packet_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ func (k *Keeper) GCCompletedRedelegations(ctx sdk.Context) error {

func (k *Keeper) HandleMaturedUnbondings(ctx sdk.Context, zone *types.Zone) error {
k.IterateZoneStatusWithdrawalRecords(ctx, zone.ChainId, types.WithdrawStatusUnbond, func(idx int64, withdrawal types.WithdrawalRecord) bool {
if ctx.BlockTime().After(withdrawal.CompletionTime) && !withdrawal.CompletionTime.Equal(time.Time{}) { // completion date has passed.
if ctx.BlockTime().After(withdrawal.CompletionTime) && withdrawal.Acknowledged { // completion date has passed.
ajansari95 marked this conversation as resolved.
Show resolved Hide resolved
k.Logger(ctx).Info("found completed unbonding")
sendMsg := &banktypes.MsgSend{FromAddress: zone.DelegationAddress.GetAddress(), ToAddress: withdrawal.Recipient, Amount: sdk.Coins{withdrawal.Amount[0]}}
err := k.SubmitTx(ctx, []sdk.Msg{sendMsg}, zone.DelegationAddress, types.TxUnbondSendMemo(withdrawal.Txhash), zone.MessagesPerTx)
Expand Down Expand Up @@ -712,6 +712,9 @@ func (k *Keeper) HandleUndelegate(ctx sdk.Context, msg sdk.Msg, completion time.
if !found {
return fmt.Errorf("unable to lookup withdrawal record; chain: %s, hash: %s", zone.ChainId, hash)
}

record.Acknowledged = true

if completion.After(record.CompletionTime) {
record.CompletionTime = completion
}
Expand Down
Loading