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

add total superfluid delegation sum invariant #1018

Closed
wants to merge 9 commits into from
Closed
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,10 @@ require (
)

replace (
// branch: v0.22.0-osmo-v7, current tag: v0.22.0-osmo-v7.2.0
// branch: v0.22.0-osmo-v7, current tag: v0.22.0-osmo-v7.2.0
github.com/CosmWasm/wasmd => github.com/osmosis-labs/wasmd v0.22.0-osmo-v7.2
// Our cosmos-sdk branch is: https://github.com/osmosis-labs/cosmos-sdk v0.45.0x-osmo-v7
github.com/cosmos/cosmos-sdk => github.com/osmosis-labs/cosmos-sdk v0.45.1-0.20220221115656-75545ea8cb2d
github.com/cosmos/cosmos-sdk => github.com/osmosis-labs/cosmos-sdk v0.45.1-0.20220309174635-d81fb5657a15
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you PR the hook addition to the SDK branch, then we can get this merged?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


github.com/cosmos/iavl => github.com/osmosis-labs/iavl v0.17.3-osmo-v3
// Use osmosis fork of ibc-go
Expand Down
6 changes: 2 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -777,14 +777,12 @@ github.com/ory/dockertest v3.3.5+incompatible/go.mod h1:1vX4m9wsvi00u5bseYwXaSnh
github.com/ory/dockertest/v3 v3.6.2/go.mod h1:EFLcVUOl8qCwp9NyDAcCDtq/QviLtYswW/VbWzUnTNE=
github.com/osmosis-labs/bech32-ibc v0.2.0-rc2 h1:7xy1pLtNiF2KaRSkolayZf4z3OfCJsO3eqBtEAXg2VA=
github.com/osmosis-labs/bech32-ibc v0.2.0-rc2/go.mod h1:0JCaioRNOVUiw7c3MngmKACnumaQ2sjPenXCnwxCttI=
github.com/osmosis-labs/cosmos-sdk v0.45.1-0.20220221115656-75545ea8cb2d h1:Y0JpKFb4n04ViTMUGm7SO4OobWKr6dBB/l3cvuBe6EY=
github.com/osmosis-labs/cosmos-sdk v0.45.1-0.20220221115656-75545ea8cb2d/go.mod h1:HsD/JxengDcevHFRA+wlWgeM78Og3ZwYM+cya3yOa7c=
github.com/osmosis-labs/cosmos-sdk v0.45.1-0.20220309174635-d81fb5657a15 h1:qofL5v1ePm19zl4aoBtfHUwamFO5V8YxXSjLRTIkAnc=
github.com/osmosis-labs/cosmos-sdk v0.45.1-0.20220309174635-d81fb5657a15/go.mod h1:UXp4GVQX3+u5iP1VQ7YZtGuLs0Fj5RBSSIi3xMYdUWI=
github.com/osmosis-labs/iavl v0.17.3-osmo-v3 h1:q2Qv3+DK52w5b68I96VApHI05jBu7HeQK/YDttKh/jY=
github.com/osmosis-labs/iavl v0.17.3-osmo-v3/go.mod h1:lJEOIlsd3sVO0JDyXWIXa9/Ur5FBscP26zJx0KxHjto=
github.com/osmosis-labs/ibc-go/v2 v2.0.2-osmo h1:XyYyDTjPIu7qX2nhQp9mboj7Pa9FEnjg1RXw73Ctv5U=
github.com/osmosis-labs/ibc-go/v2 v2.0.2-osmo/go.mod h1:XUmW7wmubCRhIEAGtMGS+5IjiSSmcAwihoN/yPGd6Kk=
github.com/osmosis-labs/wasmd v0.22.0-osmo-alpha-0 h1:605q+qoaMULEEy3XDjQVAobbnDGG/IU68rwoXqpMnSA=
github.com/osmosis-labs/wasmd v0.22.0-osmo-alpha-0/go.mod h1:ku5ZRcrrlxUu01Bu5rE4HMnhwSh3peE8FhJh2fmfQGQ=
github.com/osmosis-labs/wasmd v0.22.0-osmo-v7.2 h1:R4Vs6cqePWvZudQPMNKWEJWw6JSMIjJ1/RtV+lPDUgQ=
github.com/osmosis-labs/wasmd v0.22.0-osmo-v7.2/go.mod h1:br6yXmCKm3/l3kv/Z54l6uM3t43OqTNgB6VzyuU7894=
github.com/otiai10/copy v1.6.0 h1:IinKAryFFuPONZ7cm6T6E2QX/vcJwSnlaA5lfoaXIiQ=
Expand Down
2 changes: 2 additions & 0 deletions x/claim/keeper/hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ func (h Hooks) AfterDelegationModified(ctx sdk.Context, delAddr sdk.AccAddress,
}
func (h Hooks) BeforeValidatorSlashed(ctx sdk.Context, valAddr sdk.ValAddress, _ int64, _ sdk.Dec, _ sdk.Dec) {
}
func (h Hooks) AfterValidatorSlashed(ctx sdk.Context, valAddr sdk.ValAddress, infractionHeight int64, slashFactor sdk.Dec, effectiveSlashFactor sdk.Dec) {
}
func (h Hooks) BeforeSlashingUnbondingDelegation(ctx sdk.Context, unbondingDelegation stakingtypes.UnbondingDelegation,
infractionHeight int64, slashFactor sdk.Dec) {
}
Expand Down
6 changes: 6 additions & 0 deletions x/superfluid/keeper/hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,9 @@ func (h Hooks) BeforeValidatorSlashed(ctx sdk.Context, valAddr sdk.ValAddress, i
}
h.k.SlashLockupsForValidatorSlash(ctx, valAddr, infractionHeight, slashFactor)
}
func (h Hooks) AfterValidatorSlashed(ctx sdk.Context, valAddr sdk.ValAddress, infractionHeight int64, slashFactor sdk.Dec, effectiveSlashFactor sdk.Dec) {
if slashFactor.IsZero() {
return
}
h.k.RefreshIntermediaryDelegationAmounts(ctx)
}
2 changes: 1 addition & 1 deletion x/superfluid/keeper/invariants.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func TotalSuperfluidDelegationInvariant(keeper Keeper) sdk.Invariant {
totalExpectedSuperfluidAmount = totalExpectedSuperfluidAmount.Add(amount)
}

if !totalExpectedSuperfluidAmount.Equal(totalSuperfluidDelegationTokens.RoundInt()) {
if !totalExpectedSuperfluidAmount.Equal(totalSuperfluidDelegationTokens.TruncateInt()) {
return sdk.FormatInvariant(types.ModuleName,
totalSuperfluidDelegationInvariantName,
fmt.Sprintf("\ttotal superfluid intermediary account delegation amount does not match total sum of lockup delegations: %s != %s\n", totalExpectedSuperfluidAmount.String(), totalSuperfluidDelegationTokens.String())),
Expand Down