-
Notifications
You must be signed in to change notification settings - Fork 607
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
Twap Wasm Bindings #2212
Twap Wasm Bindings #2212
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.
utACK
Figuring plans for testing w/ exact numbers for TWAP |
Converting to draft. Current status for this PR is that I've added test codes for new queries in custom bindings test, whilst getting error |
Confirmed that this is happening bc we don't have the |
This LGTM! |
This looks good to me. My only comment is that it's not clear which queries should have their own bindings and which should go through |
6b92ff0
to
cb64a5b
Compare
reflect := instantiateReflectContract(t, ctx, osmosis, actor) | ||
require.NotEmpty(t, reflect) | ||
|
||
// TODO: figure out why it errors when we use start time without second |
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.
wdym
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.
Oh I see, the query errors in this case, interesting
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.
here's the error message: looking for a time thats too old, not in the historical index. Try storing the accumulator value.
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.
ah the error is correct, this is a test error here =p
Committing fix here.
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.
Hrmm actually its not so clean, this is actually a deeper issue with the binding using Unix time for the time passing here.
The reason its not working at the start time is because its being passed in unix time in miliseocnds. However the state record has greater precision.
Trying to see more about how to fix this
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.
So I think what we need to do is make the TWAP binding parse from UnixMiliseconds, and then in the state machine we write at UnixMilisecond precision.
For this PR, can we change the binding to be from Unix milisecond and then call it good from that? Then in the test if we set ctx.BlockTime to be at a milisecond boundary, this should be fixed. Once we do #2209 should also get fixed state machine side as well.
@mattverse please check my latest commit to fix the time threading. if you agree, please make docs for the binding, for start time being in Unix time miliseconds. (and more importantly make the docs rust side) Also communicate to Mars that we can change the time input API to be whatever they'd prefer. Right now there will be an edge case with StartTime for a TWAP, that will get fixed in a subsequent commit pre-release. Namely that if start time = pool creation time, and the block time is not milisecond aligned, it may not work. Setting it to be 1 milisecond after pool creation time would fix this for now as workaround, until next week we change it state machine to not be nanosecond precise in state machine storage. (The state machine computes the correct result, its that this binding API doesn't offer sufficient precision) |
Agreed with using Unix time millisecond for now for precision, updated documentation |
e905c3b
to
af28fad
Compare
(I rebased this after I merged the twap branch) |
wasmbinding/queries.go
Outdated
poolId := arithmeticTwap.PoolId | ||
quoteAssetDenom := arithmeticTwap.QuoteAssetDenom | ||
baseAssetDenom := arithmeticTwap.BaseAssetDenom | ||
startTime := time.Unix(arithmeticTwap.StartTime, 0) |
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.
ah we forgot to make this milli in the version we sent to mars
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 can spin one up fairly quickly if this needs to be changed
Sub component of : #2187
What is the purpose of the change
This PR adds wasm bindings for query on two APIs
GetArithmeticTWAP
andGetArithmeticTwapToNow
.This PR invlolves adding twap keeper to the wasm query plugin to use the API provided by the twap keeper.
Brief Changelog
GetArithmeticTWAP
,GetArithmeticTWAPToNow
)Testing and Verifying
Testing is TBD and to be sorted out, as of right now, do not have exact test cases for testing.
Documentation and Release Note
Unreleased
section inCHANGELOG.md
? (yes / no)x/<module>/spec/
) / Osmosis docs repo / not documented)