-
Notifications
You must be signed in to change notification settings - Fork 610
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 v10.x state incompatability #2268
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, confirmed that this PR reverts the aforementioned Prs
} | ||
|
||
if k.hooks == nil { | ||
return lock, nil | ||
} | ||
|
||
k.hooks.AfterAddTokensToLock(ctx, lock.OwnerAddress(), lock.GetID(), sdk.NewCoins(tokensToAdd)) | ||
|
||
k.hooks.OnTokenLocked(ctx, lock.OwnerAddress(), lock.ID, sdk.Coins{coin}, lock.Duration, lock.EndTime) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is OnTokenLocked
hook called when AfterAddTokensToLock
is already called above? Are both the hook calls necessary?
err = suite.App.LockupKeeper.Lock(suite.Ctx, lock) | ||
suite.Require().NoError(err) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we start writing test that checks gas at every intermediate steps of lock functions? Is that even possible?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really like this idea, want to use this for state compatibility testing :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No this seems excessive. Let's just fix the reason that this was an issue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Im supposing its gonna take some time tho for this fix
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Depends on if we have agreement for this approach: cosmos/cosmos-sdk#12788
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agreeing on that & finishing tests in osmosis-labs/cosmos-sdk#304 << writing tooling for this lol.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🍍
if err != nil { | ||
return nil, err | ||
} | ||
if err := k.bk.SendCoinsFromAccountToModule(ctx, lock.OwnerAddress(), types.ModuleName, sdk.NewCoins(coin)); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if err := k.bk.SendCoinsFromAccountToModule(ctx, lock.OwnerAddress(), types.ModuleName, sdk.NewCoins(coin)); err != nil { | |
if err := k.bk.SendCoinsFromAccountToModule(ctx, lock.OwnerAddress(), types.ModuleName, sdk.NewCoins(coin)); err != nil { |
// modifications to accumulation store | ||
k.accumulationStore(ctx, coin.Denom).Increase(accumulationKey(lock.Duration), coin.Amount) | ||
|
||
// CONTRACT: lock will have synthetic lock only if it has a single coin |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// CONTRACT: lock will have synthetic lock only if it has a single coin | |
// CONTRACT: Lock will have synthetic lock only if it has a single coin |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a revert, can make these changes happen in another PR if we really care
What is the purpose of the change
There was a State machine incompatability in v10.x, due to the ordering of gas measuring methods. cref:
These two PRs caused several gas-behavior changing logics, it just happens that the subtle case is what we hit on mainnet:
ExtendLockup
API (backport #1937) #2030lock
method (backport #1936) #2029They changed the order of operations in the normal case (which is what caused the out of gas bug. They also cause wholly different behavior on error situations.
Brief Changelog
Testing and Verifying
I reviewed all the commits in https://github.com/osmosis-labs/osmosis/tree/v10.x to look for any other state machine incompatabilities due to ordering. I didn't see any. We changed ordering of things in mint, but that is begin block logic, which doesn't have gas measurement concerns.
I've tested that this syncs through the offending block in v10.1.x that caused app hash mismatches.
Documentation and Release Note
Unreleased
section inCHANGELOG.md
? yes