-
Notifications
You must be signed in to change notification settings - Fork 76
Deploy through Accounts #276
Deploy through Accounts #276
Conversation
…through-account-#259
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.
Looking really good, @ericnordelo! I left a few comments.
Also, I think we should add some tests for deploy_contract
from deploy.py and account.py. We can probably reuse most of the existing deploy
tests with some adjustments.
Co-authored-by: Andrew Fleming <fleming.andrew@protonmail.com>
…delo/nile into feat/deploy-through-account-#259
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.
Looking good! I left some comments :)
Some other notes:
- I think we need to remove line
#85
in deployments: https://github.com/ericnordelo/nile/blob/feat/deploy-through-account-%23259/src/nile/deployments.py#L84-L85 - It might be a good idea to document the requirement of declaring contracts prior to deploying them. At this early stage, I'm not sure it's obvious to do so.
src/nile/core/deploy.py
Outdated
if unique: | ||
# Match UDC address generation | ||
salt = compute_hash_chain(data=[account.address, salt]) | ||
deployer_for_address_generation = deployer_address |
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.
What do you think about including a random salt generator for deployments without --salt
like StarkWare does? => https://github.com/starkware-libs/cairo-lang/blob/master/src/starkware/starknet/cli/starknet_cli.py#L846-L847
Otherwise, trying to deploy multiple instances of the same contract will result in:
raise StarkException(code=code, message=message) starkware.starkware_utils.error_handling.StarkException: (500, {'code': <StarknetErrorCode.CONTRACT_ADDRESS_UNAVAILABLE: 1>, 'message': 'Requested contract address 1999693730423262048654525999365022023777068478432229193013554800567845966099 is unavailable for deployment.'})
Users can add salt
to avoid this, but automating salt seems preferable
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.
If we agree^, I definitely suggest adding some salt tests
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 think this salt should be part of the protocol (like nonce in Ethereum deployments), but I am not sure why it is left to be passed from the end users (am I missing an important reason?). With this said, agreeing on a format for the automatic generation of this salt, I think, is content enough for another issue/PR. Shouldn't be any problem with releasing this version, right? I don't see a reason to delay it to another milestone.
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 think this salt should be part of the protocol
I agree in general haha but since we're deploying contracts through an account.send
tx, the burden seems to fall on Nile. When Nile interacts with the starknet_cli directly (and when Nile most likely bypasses the cli in the future), I imagine defining a salt generator will not be necessary
agreeing on a format for the automatic generation of this salt, I think, is content enough for another issue/PR
That sounds reasonable to me
I don't see a reason to delay it to another milestone.
I don't disagree
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.
Thanks for the changes! This is almost done
Co-authored-by: Martín Triay <martriay@gmail.com>
Co-authored-by: Martín Triay <martriay@gmail.com>
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.
The improvements look great! Making the API consistent with nile deploy <key> <contract>
is much more intuitive, so kudos on the change!
I left a +1
to Marto's comment in removing the _tx
on the signer methods. I don't think there's much to gain with it included.
Otherwise, this looks good to go for me :)
The _tx can be removed, but the change I wanted to introduce was replacing |
That's fair... |
…through-account-#259
…delo/nile into feat/deploy-through-account-#259
I chose invoke over execute to follow the starknet source code wording (as you can see here.) |
I get the point, but That being said, I don't think it makes a big difference either, I lean towards |
That sounds fair, but we are still using invoke (not execute) in important parts of the project, like in logging for cli (with |
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.
either sign_invoke
or sing_execute
are fine with me as long as we drop _tx
. this is ready :)
Removed the _tx suffix :) |
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 think we're good to go!
Fixes #259, #277