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

fix: rpc_state_reader return default for nonce and class_hash #284

Merged
merged 1 commit into from
Jun 27, 2024

Conversation

Yael-Starkware
Copy link
Contributor

@Yael-Starkware Yael-Starkware commented Jun 25, 2024

This change is Reviewable

Copy link
Contributor Author

@Yael-Starkware Yael-Starkware left a comment

Choose a reason for hiding this comment

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

bugfix or rpc_state_reader, need to return 0 in case that address was not found for nonce and class_hash
This is consistent with the PapyrusStateReader implemented by the blockifier.

Reviewable status: 0 of 1 files reviewed, all discussions resolved (waiting on @ArniStarkware and @dafnamatsry)

Copy link
Contributor Author

@Yael-Starkware Yael-Starkware left a comment

Choose a reason for hiding this comment

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

*of

Reviewable status: 0 of 1 files reviewed, all discussions resolved (waiting on @ArniStarkware and @dafnamatsry)

@ArniStarkware
Copy link
Contributor

crates/gateway/src/rpc_state_reader.rs line 167 at r1 (raw file):

            Err(StateError::StateReadError(msg)) if msg.contains("Contract address not found") => {
                Ok(ClassHash::default())
            }

?

Suggestion:

            Err(StateError::StateReadError(msg)) if msg.contains("Class hash not found") => {
                Ok(ClassHash::default())
            }

Copy link
Contributor

@ArniStarkware ArniStarkware left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 1 files at r1, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @dafnamatsry and @Yael-Starkware)

Copy link
Contributor Author

@Yael-Starkware Yael-Starkware left a comment

Choose a reason for hiding this comment

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

Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @ArniStarkware and @dafnamatsry)


crates/gateway/src/rpc_state_reader.rs line 167 at r1 (raw file):

Previously, ArniStarkware (Arnon Hod) wrote…

?

The error is contract_address not found, see the spec
https://github.com/starkware-libs/starknet-specs/blob/304b952121dafe47c013ed2c4c39bef4cf4c2823/api/starknet_api_openrpc.json#L479C57-L479C67

Copy link
Contributor

@ArniStarkware ArniStarkware left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @dafnamatsry)


crates/gateway/src/rpc_state_reader.rs line 167 at r1 (raw file):

Previously, Yael-Starkware (YaelD) wrote…

The error is contract_address not found, see the spec
https://github.com/starkware-libs/starknet-specs/blob/304b952121dafe47c013ed2c4c39bef4cf4c2823/api/starknet_api_openrpc.json#L479C57-L479C67

Right. The address has no corresponding Class hash. Exactly as in the previous case.

@Yael-Starkware Yael-Starkware force-pushed the yael/fix_rpc_state_reader_defaults branch from a6f3eda to 8ea8a5c Compare June 27, 2024 07:40
@codecov-commenter
Copy link

codecov-commenter commented Jun 27, 2024

Codecov Report

Attention: Patch coverage is 28.94737% with 27 lines in your changes missing coverage. Please review.

Project coverage is 76.30%. Comparing base (52a30e1) to head (3f3cdcf).

Files Patch % Lines
crates/gateway/src/rpc_state_reader.rs 37.50% 11 Missing and 4 partials ⚠️
crates/gateway/src/errors.rs 0.00% 12 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #284      +/-   ##
==========================================
+ Coverage   75.97%   76.30%   +0.32%     
==========================================
  Files          28       28              
  Lines        1386     1384       -2     
  Branches     1386     1384       -2     
==========================================
+ Hits         1053     1056       +3     
+ Misses        275      272       -3     
+ Partials       58       56       -2     

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

@Yael-Starkware Yael-Starkware force-pushed the yael/fix_rpc_state_reader_defaults branch 2 times, most recently from 3c44d73 to 24eae73 Compare June 27, 2024 08:11
Copy link
Contributor

@ArniStarkware ArniStarkware left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 2 files at r2, 1 of 2 files at r3, 1 of 1 files at r4, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @dafnamatsry and @Yael-Starkware)


crates/gateway/src/errors.rs line 137 at r4 (raw file):

            }
            _ => StateError::StateReadError(err.to_string()),
        }

At some point, do we want to make this from more comprehensive? Is it possible?

If so - please add a todo/ do it.

Code quote:

        match err {
            RPCStateReaderError::ClassHashNotFound(request) => {
                match serde_json::from_value(request["params"]["class_hash"].clone()) {
                    Ok(class_hash) => StateError::UndeclaredClassHash(class_hash),
                    Err(e) => serde_err_to_state_err(e),
                }
            }
            _ => StateError::StateReadError(err.to_string()),
        }

crates/gateway/src/rpc_state_reader.rs line 80 at r4 (raw file):

impl MempoolStateReader for RpcStateReader {
    fn get_block_info(&self) -> Result<BlockInfo, StateError> {

Suggestion:

StateResult<BlockInfo>

@Yael-Starkware Yael-Starkware force-pushed the yael/fix_rpc_state_reader_defaults branch from 24eae73 to 3f3cdcf Compare June 27, 2024 08:36
Copy link
Contributor Author

@Yael-Starkware Yael-Starkware left a comment

Choose a reason for hiding this comment

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

Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @ArniStarkware and @dafnamatsry)


crates/gateway/src/errors.rs line 137 at r4 (raw file):

Previously, ArniStarkware (Arnon Hod) wrote…

At some point, do we want to make this from more comprehensive? Is it possible?

If so - please add a todo/ do it.

I don't see any reason to do that atm, The only error that can be mapped to StateError is the one I handled.


crates/gateway/src/rpc_state_reader.rs line 80 at r4 (raw file):

impl MempoolStateReader for RpcStateReader {
    fn get_block_info(&self) -> Result<BlockInfo, StateError> {

done.

Copy link
Collaborator

@dafnamatsry dafnamatsry left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 1 of 2 files at r3, 1 of 1 files at r4, 1 of 1 files at r5, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @ArniStarkware)

Copy link
Contributor

@ArniStarkware ArniStarkware left a comment

Choose a reason for hiding this comment

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

Reviewed all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @Yael-Starkware)

Copy link
Contributor

@ArniStarkware ArniStarkware left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 1 files at r5.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @Yael-Starkware)

@Yael-Starkware Yael-Starkware merged commit 24eb95a into main Jun 27, 2024
8 checks passed
@Yael-Starkware Yael-Starkware deleted the yael/fix_rpc_state_reader_defaults branch June 27, 2024 09:18
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.

4 participants