FuelLabs / sway

🌴 Empowering everyone to build reliable and efficient smart contracts.
https://docs.fuel.network/docs/sway/
Apache License 2.0
62.58k stars 5.37k forks source link

Why `forc deploy` will rebuild code? #6533

Closed lispking closed 2 months ago

lispking commented 2 months ago

Why does the forc build --release command require the code to be rebuilt when executing forc deploy afterwards? This design doesn't seem user-friendly; deploy doesn't need to rebuild the code again, it should simply check if there are artifacts in the release directory.

sdankel commented 2 months ago

Hi @lispking, This is done to make sure that what's being deployed is compiled from the latest source code. If we didn't do this, it would be easy for a user to accidentally deploy the wrong (stale) bytecode.

lispking commented 2 months ago

Hi @lispking, This is done to make sure that what's being deployed is compiled from the latest source code. If we didn't do this, it would be easy for a user to accidentally deploy the wrong (stale) bytecode.

Understood, but we could consider it as an optional feature, allowing users to avoid recompiling, for instance by adding a 'non-compile' flag. When users add this option, they can reuse the output/release artifacts. @sdankel

sdankel commented 2 months ago

Could you explain more about your use case? You said "This design doesn't seem user-friendly", is that just because it takes longer to recompile, or is it something else?

lispking commented 2 months ago

This is related to the issue here. The amp tool will separate these steps and build these capabilities in. You can see the specific implementation code here.

If you look closely, you'll notice that the code here hardcodes a wallet. In fact, I also want to change this to the 'wallet import' command, which would allow users to input their own private_key and password. This way, users can deploy using their own wallets.

If feasible, I can help implement these patches. @sdankel

sdankel commented 2 months ago

I'm still not sure I understand why you need the compile step to be separated from the deploy step, but I'm okay with having a --skip-compile option.

It might require significant refactoring. The current implementation uses the compiler output structures directly rather than reading from the compiled artifact files. I'll reopen this if you want to take it on.

lispking commented 2 months ago

Yeah. I understand that we should add the --skip-compile option.