aptos-core icon indicating copy to clipboard operation
aptos-core copied to clipboard

[Feature Request] Add a -dev flag to aptos move compile

Open Turbo-Gus opened this issue 2 years ago • 6 comments

🚀 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.

Turbo-Gus avatar Oct 14 '22 19:10 Turbo-Gus

Appreciate the offer, could you elaborate on what the offer is? Maybe a concrete example would be helpful here.

davidiw avatar Oct 15 '22 19:10 davidiw

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

Turbo-Gus avatar Oct 16 '22 14:10 Turbo-Gus

why would you want to include the dev dependencies?

davidiw avatar Oct 21 '22 03:10 davidiw

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:

  1. Deploy all of Pyth's associated dependencies and initialize them properly
  2. 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.

Turbo-Gus avatar Oct 24 '22 14:10 Turbo-Gus

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.

wrwg avatar Oct 24 '22 17:10 wrwg

PS. This is already supported by Move package system, just needs to be plumbed through to aptos CLI.

wrwg avatar Oct 24 '22 17:10 wrwg

@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 :)

ameya-deshmukh avatar Feb 21 '23 14:02 ameya-deshmukh

I have another github issue to work on so if you want please take it over, I havent started on this one

gerben-stavenga avatar Feb 21 '23 16:02 gerben-stavenga

Awesome, would be more than happy to take this off your hands! Can you please assign it to me? Thanks

ameya-deshmukh avatar Feb 21 '23 16:02 ameya-deshmukh

Awesome, would be more than happy to take this off your hands! Can you please assign it to me? Thanks

Done

gerben-stavenga avatar Feb 21 '23 17:02 gerben-stavenga

#5463 is a duplicate of this one

wrwg avatar Feb 24 '23 01:02 wrwg

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?

movekevin avatar Apr 18 '23 13:04 movekevin

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.

github-actions[bot] avatar Jun 03 '23 02:06 github-actions[bot]

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.

github-actions[bot] avatar Jul 19 '23 02:07 github-actions[bot]

@gregnazario I think you already fixed this?

wrwg avatar Aug 28 '23 17:08 wrwg

Seems to have been fixed here: https://github.com/aptos-labs/aptos-core/pull/8789

brmataptos avatar Sep 12 '23 20:09 brmataptos

Tested and verified, feature is added with the PR mentioned above.

lbmeiyi avatar Sep 12 '23 20:09 lbmeiyi