-
Notifications
You must be signed in to change notification settings - Fork 29
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
Gabe's review #56
Comments
ack, will try out CLion and see what's missing, all the ExecuteMsg's are tested but many of the helpers are indirectly tested through the ExecuteMsg tests, interested to see how CLion interprets this |
@grod220 Can you point me to a repo that mocks chain modules? When I first started working on the contracts, we were using cw-multi-test which lacked stargate messages and other chain modules (needed for Neutron transfer module). Also at that time, osmosis test-tube did not support the poolmanager module, so it seemed integration tests became more of a hassle than helpful. Currently, all cross-contract testing is happening on testnets, but I agree this is not ideal and I'd love a smooth local cross-contract testing flow. |
This may be just a personal preference after working in the Osmosis repo (they do similar things in their test cases where they have cases and a single function to handle the tests), but I am a fan of the test case structure. Agreed overkill when only two test cases but was just set up that way to keep a standard across all test files. |
These tests only output messages, none of the messages are ran (so bank balances are never changed, just bank sends are emitted). Would need to move to cw-multi-test to get state changes, but still am looking for a better way to use cw-multi-test with stargate and custom modules. |
I am seemingly on the wrong side of history, I write all my scripts in python, will explore this. @grod220 For our contracts in particular, FE typescript devs do not interact with our contracts, the messages are all generated by our server in Go (our users just use our API which gives them a message that they then send to a wallet to sign). With that understanding, would you recommend making the deploy scripts in Go since the main benefit you seem to be highlighting is type safety and example providing for the main service that interacts with the contracts? |
Ack, I have a .ipynb (more python) that I do execution of user flows (many of em, and was helpful to execute 1 by 1 and see results), but makes sense to couple more tightly with the main automated script. |
They actually do this today! The deploy script generates all the files in deployed-contracts |
Ack, thank you! Will continue to work though this design! |
ack, Larry also had a suggestion to use justfile, but we're currently using Makefile since it's a company standard at Skip across all our codebases |
This has no material impact right? This is just changing where the cache is stored? being in the makefile will make this command be changed anyways since pwd can't be used directly (will be shell pwd) and will also need to do Will change the target to /target as that seems to be the new standard defined in the changelog: https://github.com/CosmWasm/rust-optimizer/blob/main/CHANGELOG.md Done here: #58 |
Sweet, done here: #57 |
Makes sense, added here: #59 |
Good callout, updated here: #60 |
This is sweet, thanks, done: #61 |
This was just a naming we decided on and share across the contracts and our api service, no real reason beyond that |
@grod220 The query simulates the exact swap that is about to take place using the method provided by the dex (Osmosis poolmanager module, and Astroport router/pools), and there is no state transition between the query and the swap itself so the output of the query would align with the swap itself. That is, if I want 10 osmo out and the query returns that it requires 5 atom in, then I can swap in 5 atom and get 10 osmo. This can be an issue if the Osmosis poolmanager, Astroport router, or other dexes we add support for do not properly implement their query methods and they diverge from the actual swaps themselves, but under the assumption of correct query methods from the dex itself this should be fine. Is your understanding different or is the above issue what flagged you? |
Just for my understanding, the match implementation you linked to does the exact same thing as our implementation currently, correct (it only supports a single reply id that's a hardcoded constant)? But you're advocating that if we switch to the match pattern now, then if we ever wanted to add another submsg reply in the future it would be easier to implement? Or are there benefits of this approach even today with a single reply id? |
Ack, we decided against any owner/admin/upgradeability as we are unclear on the legal implications of that as a U.S. company. I think it is likely we do not implement these for those reasons. |
This makes sense, realized this as I was working on v0.2.0 but didn't want to make another interface breaking change, but it probably is worthwhile to do so, so will refactor it. Done here: #63 |
Ack, a little hesitant on adding a third-party dependency where a future maintainer may have to understand the source code instead of an easy to reason about map usage, but will explore |
I think this makes sense to me, is this what you had in mind?: #62 |
I believe ApolloDAO was doing this here: https://github.com/apollodao/cw-it/blob/master/src/multi_test/modules/token_factory.rs. There may be better examples in the wild though 🤔
You need a way to tightly couple the Rust message enums/types with your A) deploy scripts and B) language of consumers. For A, I'd say ts-codegen + typescript does this well. For B, how are you doing this now? Do you have a package that can automatically generate those types? If not, I think it's a worthwhile venture figuring that out. Maybe something like this?. Also, it doesn't look like you are generating the schema for your contracts. See v2-fields for a good example of how we do this. See the
Yes that's right
I don't know if that can be trusted or that your contract should be relying on what they say will happen. I think the contract needs to verify this itself. If not, it may expose a vulnerability to the services you integrate with. Those simulation endpoints are more for frontend querying I'd say.
Yes, that is correct. It's just like the way that execute or query is handled. Potentially, you could have more than one and therefore that function should just be concerned with routing and not business logic.
Whoa, bold move 😅 . Why not start with an owner and then execute the message that abolishes the role (makes it immutable) later?
Yes, that's a step in the direction. However, I'd say that you should have a |
Testing 🧪
Frontend scripts 🐍
Your deploy scripts are not type safe and are written in Python. I think you should convert this to Typescript (the sooner the better). Few things:
yarn build
checks andts-codegen
generation to your CI/CD so it ensures your contracts never unexpectedly break frontend types.Chain Abstraction ⛓️
Random observations ☕️
--mount type=volume,source="$(basename "$(pwd)")_cache",target=/target \
cargo upgrade
(in cargo-edit package) and run it often.main
as well. You always want to know if your main builds after a merge. There is a situation where someone merges an old PR that had passed all CI/CD checks, but breaks main. It’s good to be aware of that after merge and not the next time someone creates a new PR.skip = { workspace = true }
and add the dependency to the top level workspaceCargo.toml
like so:skip = { version = "2.0.0", path = "./packages/skip" }
. That way, it makes it easier for contracts to inherit.unchecked_swap_venue.checked()
method called in instantiate. That struct can also have other logic on it (e.g. how to assemble swap messages).owner
role that is allowed to update the config and state of the contract. Else, those values become immutable. I wrote this one and it’s in use with all Mars contracts. Examples: initialize / update / use in executeunreachable!()
.The text was updated successfully, but these errors were encountered: