Skip to content
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

[sozo] Deploy Account #1601

Merged
merged 21 commits into from
Apr 21, 2024
Merged

Conversation

JimmyFate
Copy link
Contributor

@JimmyFate JimmyFate commented Mar 3, 2024

Closes DOJ-176
Closes #1574

I would love to get some feedback on the PR before putting effort into writing the tests :)

Introduced changes

UI related changes:

  • sozo account new / deploy
  • sozo keystore new / from-key / inspect / inspect-private

Development related changes:

  • move private_key, keystore_path, keystore_password from AccountOptions into SignerOptions

Copy link

codecov bot commented Mar 3, 2024

Codecov Report

Attention: Patch coverage is 51.21951% with 320 lines in your changes are missing coverage. Please review.

Project coverage is 70.04%. Comparing base (a2412b3) to head (64271ff).

Files Patch % Lines
crates/sozo/ops/src/account.rs 27.36% 223 Missing ⚠️
bin/sozo/src/commands/options/fee.rs 2.12% 46 Missing ⚠️
bin/sozo/src/commands/account.rs 24.44% 34 Missing ⚠️
bin/sozo/src/commands/keystore.rs 60.00% 8 Missing ⚠️
crates/sozo/ops/src/keystore.rs 89.06% 7 Missing ⚠️
bin/sozo/src/commands/options/signer.rs 98.82% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1601      +/-   ##
==========================================
- Coverage   70.32%   70.04%   -0.29%     
==========================================
  Files         309      315       +6     
  Lines       35126    35547     +421     
==========================================
+ Hits        24703    24898     +195     
- Misses      10423    10649     +226     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@JimmyFate JimmyFate marked this pull request as ready for review March 5, 2024 23:22
Copy link
Collaborator

@glihm glihm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the work here!
Some minor comments for this first review. You can definitely start the testing phase to ensure everything is well supported.

I've made some tests with Katana, creating a new account and deploying it, works like a charm (tested with --disable-fee though).

I'm wondering if we can even simplify a bit, for instance without the simulate for the deployment. @ponderingdemocritus the idea here is not being exhaustive as Starkli, but supporting the minimum features to have sozo with all the basic account stuff, right?

@lambda-0x if you have a chance to revise this too, happy to have your feedback.

bin/sozo/src/commands/account.rs Outdated Show resolved Hide resolved
bin/sozo/src/commands/options/signer.rs Outdated Show resolved Hide resolved
bin/sozo/Cargo.toml Outdated Show resolved Hide resolved
bin/sozo/src/commands/account.rs Outdated Show resolved Hide resolved
bin/sozo/src/ops/account.rs Outdated Show resolved Hide resolved
@glihm
Copy link
Collaborator

glihm commented Mar 20, 2024

@JimmyFate how are you feeling about this? If you need any support or more information from the given reviews, don't hesitate to reach out to us. 👍

@glihm glihm added the sozo label Mar 20, 2024
@JimmyFate
Copy link
Contributor Author

@JimmyFate how are you feeling about this? If you need any support or more information from the given reviews, don't hesitate to reach out to us. 👍

Thanks for checking up ❤️ I'll try to complete the PR as soon as I can.
Unfortunately I've had some problems with git submodules between this and some other branch and lost some of the progress due to messed up git config

@JimmyFate
Copy link
Contributor Author

@glihm
Rebased (new with sozo ops in own crate) and updated the PR with the comments.

As for simplifying the logic - I feel like, for example the mentioned simulate flag, is a nice to have, and removing it wouldn't remove much of the code. However I'm down to do so if it gets decided on.

Could then also remove any other feature with the goal of simplification - probably FeeSetting would be the next thing to remove and leave just setting --max-fee manually.

Also probably should add sozo account fetch as well, since right now if waiting for the DEPLOY_ACCOUNT tx is interrupted, there is no way of getting the up-to-date valid account file.

Will add the tests soon.

@glihm
Copy link
Collaborator

glihm commented Mar 21, 2024

Unfortunately I've had some problems with git submodules between this and some other branch and lost some of the progress due to messed up git config

No problem at all, it was more a ping check to ensure you still interested working on that until having the PR in good shape to be merged. :)

@glihm Rebased (new with sozo ops in own crate) and updated the PR with the comments.

Awesome, appreciate the reactivity and the update on that.

As for simplifying the logic - I feel like, for example the mentioned simulate flag, is a nice to have, and removing it wouldn't remove much of the code. However I'm down to do so if it gets decided on.

Let's keep it then, good point.

Could then also remove any other feature with the goal of simplification - probably FeeSetting would be the next thing to remove and leave just setting --max-fee manually.

I was exactly thinking about this, and usually working with Katana, fees are disabled. But when users are working with other chain than Katana, it can be useful. Also, the sozo execute is not including any fee setting, and by default starknet-rs makes an estimation. It's out of the scope of this PR, but we may want to re-use this FeeSettings.

Also probably should add sozo account fetch as well, since right now if waiting for the DEPLOY_ACCOUNT tx is interrupted, there is no way of getting the up-to-date valid account file.

Shouldn't we deploy it again? Because the file is already written, but if not deployed, the file is not updated and still in undeployed state.
But independently from this use-case, having the account fetch can be very handy with working with remote Katana deployed on Slot for instance. So if you're ok, we can add it.

bin/sozo/src/commands/account.rs Outdated Show resolved Hide resolved
crates/dojo-utils/Cargo.toml Outdated Show resolved Hide resolved
Copy link
Collaborator

@glihm glihm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work @JimmyFate, thanks for that!

Made some testings, it's getting nice.
Could we add a test for the account deploy to have all 3 tested?
I've revised and the katana runner does not expose the --disable-fee. So you can to an execute first to transfer funds to the account to deploy.

sozo execute 0x49d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7 transfer -c <ACCOUNT_ADDRESS>,10000000000000000,0

And you can use the first pre-funded account to do this execute.

bin/sozo/src/commands/account.rs Outdated Show resolved Hide resolved
@JimmyFate
Copy link
Contributor Author

JimmyFate commented Mar 30, 2024

@glihm
I am having a hard time adding a test for deploy. Tried transferring from the erc20 as you suggested but somehow couldn't make it work. Another thing is the prompt for stdin which I guess could be omitted with checking if environment variable like "PASS_STDIN" (which would be set in the test) is set. Ofc the stdin could be mocked, but there isn't one in dojo yet and I haven't worked with mocking libs in rust previously (I guess mockall could work).

Also, overall this PR has grown quite bigger than I initially expected making it hard to maintain with the rebasing.
I am not sure if I'll have the time to finish this :/ (in a reasonable time at least, as the PR is already open for some time and I wouldn't want to stall for much longer)

Other than that my Mac is having a tough time lately with regards to its speed, especially noticeable when building / running dojo in debug mode, so it just pushes me to upgrade sooner than later 🫠

@glihm
Copy link
Collaborator

glihm commented Mar 30, 2024

@glihm I am having a hard time adding a test for deploy. Tried transferring from the erc20 as you suggested but somehow couldn't make it work. Another thing is the prompt for stdin which I guess could be omitted with checking if environment variable like "PASS_STDIN" (which would be set in the test) is set. Ofc the stdin could be mocked, but there isn't one in dojo yet and I haven't worked with mocking libs in rust previously (I guess mockall could work).

Also, overall this PR has grown quite bigger than I initially expected making it hard to maintain with the rebasing. I am not sure if I'll have the time to finish this :/ (in a reasonable time at least, as the PR is already open for some time and I wouldn't want to stall for much longer)

Other than that my Mac is having a tough time lately with regards to its speed, especially noticeable when building / running dojo in debug mode, so it just pushes me to upgrade sooner than later 🫠

Man, you did a great job and appreciate the dedication to that.
To ease the testing and also leveraging the ops crate, we could do the following:

  1. The new function into ops/account could return the address of the created account.
  2. The deploy function can have an argument --no-confirmation or something similar.
    Doing so, we can create the account, pre-funding it, and then deploy it without waiting stdin.

If you're ok to do it, let me know. But once again, great job on the PR here and thank you for your time to contribute!

Could you anyway please reach out to me on the Dojo discord when you have a chance? 👍

Copy link
Collaborator

@glihm glihm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some notes here to finish the PR and testing. I would do this in the week if not tackled before. 👍

crates/sozo/ops/src/account.rs Show resolved Hide resolved
format!("{:#064x}", target_deployment_address).bright_yellow()
);

eprint!("Press [ENTER] once you've funded the address.");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add an option to skip this to allow testing and automated deployments.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Cargo.toml Outdated
Comment on lines 153 to 167
serde = { version = "1.0.192", features = [ "derive" ] }
serde_json = { version = "1.0", features = [ "arbitrary_precision" ] }
serde = { version = "1.0.192", features = ["derive"] }
serde_json = { version = "1.0", features = ["arbitrary_precision"] }
serde_with = "2.3.1"
similar-asserts = "1.5.0"
smol_str = { version = "0.2.0", features = [ "serde" ] }
sqlx = { version = "0.7.2", features = [ "chrono", "macros", "regexp", "runtime-async-std", "runtime-tokio", "sqlite", "uuid" ] }
smol_str = { version = "0.2.0", features = ["serde"] }
sqlx = { version = "0.7.2", features = [
"chrono",
"macros",
"regexp",
"runtime-async-std",
"runtime-tokio",
"sqlite",
"uuid",
] }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any idea why this formatting changed? on main even after running cargo +nightly fmt it stays the same.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

while merging with main switched back to formatting we have on main to be consistent

format!("{:#064x}", target_deployment_address).bright_yellow()
);

eprint!("Press [ENTER] once you've funded the address.");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

crates/sozo/ops/src/account.rs Show resolved Hide resolved
@glihm
Copy link
Collaborator

glihm commented Apr 11, 2024

Should wait the #1808 to use TransactionOption instead.

@glihm glihm added the blocked This issue is blocked due to some other issues label Apr 11, 2024
Copy link
Collaborator

@lambda-0x lambda-0x left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@lambda-0x lambda-0x removed the blocked This issue is blocked due to some other issues label Apr 21, 2024
@lambda-0x lambda-0x merged commit d92decd into dojoengine:main Apr 21, 2024
10 of 12 checks passed
@lambda-0x
Copy link
Collaborator

Thank you @JimmyFate for your awesome work on this PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[sozo] Add Deploy Account functionality
4 participants