aptos-core
aptos-core copied to clipboard
[Feature Request] Add a -dev flag to aptos move compile
🚀 Feature Request
Add a -dev flag to the aptos move compile
command, so that users can compile move code using dev dependencies.
Motivation
Many users want to integrate with external code (such as oracles) in order to build Dapps. Frequent devnet and testnet releases make it difficult to rely on external code existing in a given environment. Additionally, due to the early state of the ecosystem, integrating with multiple codebases can lead to issues with dependency resolution. Forking dependencies in order to ensure compatibility and reliability is a great solution to these problems, but if a developer compiles their code using forked versions of dependencies (e.g. in order to test on devnet), when they deploy on mainnet (i.e. relying on non-forked versions of oracles) there will be module compatibility issues.
I believe giving developers more options for devnet testing and controlling dependencies will be a huge positive in the long run.
Pitch
I'd be happy to open a pull request closing this issue if the Aptos core team agrees this feature is useful.
Appreciate the offer, could you elaborate on what the offer is? Maybe a concrete example would be helpful here.
Currently the command aptos move compile
compiles move code using dependencies specified under [dependencies]
in the Move.toml. I'd like a way of compiling my code that includes dependencies specified with [dev-dependencies]
in the Move.toml (without resorting to aptos move test
, because I ultimately want to publish this version compiled with dev-dependencies).
I think the easiest way to implement this is to add a flag to aptos move compile
. I envision the implementation would ultimately set build_config.dev_mode = true
in the underlying move_cli like so: https://github.com/move-language/move/blob/main/language/tools/move-cli/src/base/test.rs#L157
I'd probably change the Aptos code here to accomplish this: https://github.com/aptos-labs/aptos-core/blob/154e7b169eb44df56dfe59874546a50f1e0c1d27/crates/aptos/src/move_tool/mod.rs#L272
why would you want to include the dev dependencies?
As a concrete example, certain oracles such as Pyth require a lot of external dependencies. On devnet these external dependencies have not been deployed. As a dapp builder, all I really care about is getting prices from Pyth. If I want to test my dapp's Pyth integration on devnet, I currently need to either:
- Deploy all of Pyth's associated dependencies and initialize them properly
- Deploy a forked version of Pyth that ignores the dependencies and gives me a simple price
#2 is a lot easier but if I'm compiling my dapp with a forked version of Pyth, my dapp will be incompatible with the actual Pyth version on mainnet. If I had an easy way to choose which git repo (or code version) I'm compiling my dapp with, I could compile and deploy my dapp with slightly different dependencies depending on my target environment. I think this gives developers a lot more flexibility.
Ideally the -dev flag would allow me to toggle between building with normal dependencies or dev dependencies, allowing me to build and deploy my dapp with a forked version of Pyth on devnet, and the "real "version on mainnet.
Yes, this is definitely a feature we want, that's why I assigned it (for further triage to me). Another example would be dependencies just for unit tests. Thanks for filing this.
PS. This is already supported by Move package system, just needs to be plumbed through to aptos CLI.
@gerben-stavenga are you working on this? Wanted to pick this up as my first contribution to Aptos, so let me know if I can do so :)
I have another github issue to work on so if you want please take it over, I havent started on this one
Awesome, would be more than happy to take this off your hands! Can you please assign it to me? Thanks
Awesome, would be more than happy to take this off your hands! Can you please assign it to me? Thanks
Done
#5463 is a duplicate of this one
Awesome, would be more than happy to take this off your hands! Can you please assign it to me? Thanks
@ameya-deshmukh Are you still working on this?
This issue is stale because it has been open 45 days with no activity. Remove the stale
label or comment - otherwise this will be closed in 15 days.
This issue is stale because it has been open 45 days with no activity. Remove the stale
label or comment - otherwise this will be closed in 15 days.
@gregnazario I think you already fixed this?
Seems to have been fixed here: https://github.com/aptos-labs/aptos-core/pull/8789
Tested and verified, feature is added with the PR mentioned above.