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

Add voyager verification to the verify command #2566

Open
wants to merge 17 commits into
base: master
Choose a base branch
from

Conversation

cwkang1998
Copy link

@cwkang1998 cwkang1998 commented Oct 7, 2024

This is a follow up PR to complete changes that #2288 wants to introduce.

Closes #2287

Introduced changes

Additional context on a possible edge case

As Voyager backend limits the http alive time to less than 30s, given a large contract which compilation might take longer, we might have to have the compilation task run asynchronously in order and have the status polled. This is currently not implemented in this PR as testing is being done to see if this is significant enough of a problem to be addressed this way.

Checklist

  • Linked relevant issue
  • Updated relevant documentation
  • Added relevant tests
  • Performed self-review of the code
  • Added changes to CHANGELOG.md

Will complete this checklist after another self review.

@cwkang1998 cwkang1998 changed the title Add Voyager as a contract verifier Add voyager verification interface to the verify command Oct 7, 2024
@cwkang1998 cwkang1998 changed the title Add voyager verification interface to the verify command Add voyager verification to the verify command Oct 7, 2024
@cwkang1998 cwkang1998 marked this pull request as ready for review October 10, 2024 10:05
@cwkang1998
Copy link
Author

cwkang1998 commented Oct 10, 2024

Addressing some of @integraledelebesgue comments from #2288

#[async_trait] attribute is not required #2288 (comment)

Seems that its failing to compile without the macro. Any alternatives you might have had in your mind?

Please add descriptions of all parameters to display in help

We would like to unify the wole configuration to a TOML file. Could you please redesign the url acquisition logic to use an enum provied via CastConfig rather than an environmental variable?

Both implementations of this method are identical. You can make it a default implementation

Sure

  1. Similarly to verify, implementations of this method differ only with the url source. How about introducing a new trait method, let's say get_base_url, implementing it manually on both types and using in a default implementation of gen_explorer_url?
  2. This method never fails. Are there any reasons for it to return a Result?
    refactor verification crate & add voyager interface  #2288 (comment)
  1. I'll try that out.
  2. I don't think so, removing it.

@cwkang1998
Copy link
Author

cwkang1998 commented Oct 12, 2024

Successfully made some of the methods default, and remove the need of using a base struct inside each concrete verification interface struct.

Since the verification provider api is constructed slightly differently, I don't think that replacinggen_explorer_url is a valid choice anymore since the last review. However, I did still move the configuration for the custom base api url to CastConfig as suggested.

Will move on to update the current tests tomorrow.

@cwkang1998
Copy link
Author

Tests updated! Reviews would be appreciated.

@piotmag769
Copy link
Member

cc @cptartur

Copy link
Member

@cptartur cptartur left a comment

Choose a reason for hiding this comment

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

Hey, thanks for contributing. I think some parts may be improved.

Also, I haven't reviewed the tests yet but will do soon.

CHANGELOG.md Outdated Show resolved Hide resolved
crates/sncast/src/starknet_commands/verification/base.rs Outdated Show resolved Hide resolved
crates/sncast/src/starknet_commands/verification/base.rs Outdated Show resolved Hide resolved
crates/sncast/src/helpers/configuration.rs Outdated Show resolved Hide resolved
crates/sncast/src/starknet_commands/mod.rs Outdated Show resolved Hide resolved
crates/sncast/src/starknet_commands/verification/base.rs Outdated Show resolved Hide resolved

The address of the contract that is to be verified.

## `--class-name <CONTRACT_NAME>`
Copy link
Member

Choose a reason for hiding this comment

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

Why are we renaming this?

Copy link
Author

Choose a reason for hiding this comment

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

This is renamed as we feel its more accurate to call it class name rather than contract name. The class (or the code ) is what is being verified, and the contract is an instance of the class (contract). Thus why we decided to change the name to better reflect it.

Changing it to<CLASS_NAME> to make it clearer too.

Copy link
Member

Choose a reason for hiding this comment

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

I wonder about this. I get your point about it verifying the class. However, we're using --contract-name in sncast declare even though it just declares the contract class, so this was named mostly for consistency.

Copy link
Author

Choose a reason for hiding this comment

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

if that's the case then let's make it --contract-name for consistency. I think it all comes down to preferences, and we can wait and see if there's any feedback on this once its released.

Copy link
Author

Choose a reason for hiding this comment

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

Sorry, just went through the specs and realized that changing this might not be a good idea since prior to this we had changed the specs and walnut had followed suit with the spec change where we use --class-name instead of --contract-name. Do we want to change this again?

We can change it on our side and preserve the api payload schema, which should work. Wdyt @cptartur ?

crates/sncast/src/starknet_commands/verification/verify.rs Outdated Show resolved Hide resolved
docs/src/appendix/sncast/verify.md Outdated Show resolved Hide resolved
@cwkang1998
Copy link
Author

Addressed partially, will continue in awhile to address the rest.

crates/sncast/src/starknet_commands/verify/base.rs Outdated Show resolved Hide resolved
crates/sncast/src/starknet_commands/verify/mod.rs Outdated Show resolved Hide resolved
crates/sncast/src/starknet_commands/verify/mod.rs Outdated Show resolved Hide resolved
crates/sncast/tests/e2e/verify/voyager.rs Show resolved Hide resolved
docs/src/appendix/sncast/verify.md Outdated Show resolved Hide resolved

The address of the contract that is to be verified.

## `--class-name <CONTRACT_NAME>`
Copy link
Member

Choose a reason for hiding this comment

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

I wonder about this. I get your point about it verifying the class. However, we're using --contract-name in sncast declare even though it just declares the contract class, so this was named mostly for consistency.

docs/src/starknet/verify.md Show resolved Hide resolved
@cwkang1998 cwkang1998 force-pushed the feat/add-voyager-verification branch 2 times, most recently from 9fb1de9 to 4d46251 Compare October 31, 2024 23:02
Copy link
Member

@cptartur cptartur left a comment

Choose a reason for hiding this comment

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

Looking good. Just some minor comments.

#[clap(flatten)]
pub contract_address_or_class_hash: ContractAddressOrClassHashGroup,

/// Class name of the contract to be verified. Either this or class hash should be provided.
Copy link
Member

Choose a reason for hiding this comment

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

This is required, no?

Copy link
Author

Choose a reason for hiding this comment

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

Yes, that's a mistake on my part, will amend it now.

#[clap(short, long)]
pub class_name: String,

/// Where you want your contract to be verified
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
/// Where you want your contract to be verified
/// Verification provider to be used

#[clap(long, default_value = "false")]
pub confirm_verification: bool,

/// Optionally specify package with the contract to be verified
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
/// Optionally specify package with the contract to be verified
/// Specify package with the contract to be verified


The address of the contract that is to be verified.
The address of the contract that is to be verified. Either this or the class hash should be provided.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
The address of the contract that is to be verified. Either this or the class hash should be provided.
The address of the contract that is to be verified.

@@ -17,6 +17,11 @@ For detailed CLI description, see [verify command reference](../appendix/sncast/

Walnut is a tool for step-by-step debugging of Starknet transactions. You can learn more about Walnut here [walnut.dev](https://walnut.dev). Note that Walnut requires you to specify the Starknet version in your `Scarb.toml` config file.

### Voyager

[Voyager](https://voyager.online) is a block explorer for Starknet. It gives developers immediate insight into the state of the starknetnetwork. It also intends to become the one-stop location for all Starknet statistics. Note that Voyager requires you to specify the Starknet version in your `Scarb.toml` config file.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
[Voyager](https://voyager.online) is a block explorer for Starknet. It gives developers immediate insight into the state of the starknetnetwork. It also intends to become the one-stop location for all Starknet statistics. Note that Voyager requires you to specify the Starknet version in your `Scarb.toml` config file.
[Voyager](https://voyager.online) is a block explorer for Starknet. It gives developers immediate insight into the state of the Starknet network. Note that Voyager requires you to specify the Starknet version in your `Scarb.toml` config file.

Copy link
Member

Choose a reason for hiding this comment

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

Let's keep it simple

@cptartur cptartur self-requested a review November 6, 2024 12:12
Copy link
Collaborator

@kkawula kkawula left a comment

Choose a reason for hiding this comment

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

Maybe it was mentioned, but you potentially by mistake reformated the entire CHANGELOG.md file. Please revert these changes.

Copy link
Member

@cptartur cptartur left a comment

Choose a reason for hiding this comment

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

Looks good, let's just restore the formatting of the changelog file

CHANGELOG.md Show resolved Hide resolved
@@ -26,7 +30,7 @@ Then run:
```shell
$ sncast \
verify \
--contract-address 0x01e4ebe3278ab4633a9d0d3f5c4290001f29bc3179a70e570b6817dd7f8264fa \
--contract-address 0x8448a68b5ea1affc45e3fd4b8b480ea36a51dc34e337a16d2567d32d0c6f8b \
Copy link
Member

Choose a reason for hiding this comment

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

Why was this address changed? It doesn't seem like a class hash of any existing contract

Copy link
Author

Choose a reason for hiding this comment

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

hmm, I'm not sure why this was changed. Let me revert this.

CHANGELOG.md Outdated
@@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- You can skip `--name` flag when using `account import` - a default name will be generated.
- Addresses outputted when calling `sncast account create`, `sncast deploy` and `sncast declare` are now padded to 64 characters length and prefixed with `0x0`
- Voyager API support for `verify` subcommand [Read more here](https://foundry-rs.github.io/starknet-foundry/appendix/sncast/verify.html).
Copy link
Member

Choose a reason for hiding this comment

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

Generally, I try to limit the usage of links in CHANGELOG.md because they often eventually become outdated.

Suggested change
- Voyager API support for `verify` subcommand [Read more here](https://foundry-rs.github.io/starknet-foundry/appendix/sncast/verify.html).
- Voyager API support for sncast `verify` subcommand

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

Successfully merging this pull request may close these issues.

Add voyager verification interface to the verify command
5 participants