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

feat(sync): implement get_block in StateSync #2285

Merged
merged 1 commit into from
Nov 27, 2024

Conversation

noamsp-starkware
Copy link
Contributor

No description provided.

@reviewable-StarkWare
Copy link

This change is Reviewable

Copy link
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

Copy link

codecov bot commented Nov 26, 2024

Codecov Report

Attention: Patch coverage is 8.00000% with 23 lines in your changes missing coverage. Please review.

Project coverage is 77.03%. Comparing base (e3165c4) to head (e7dc16b).
Report is 601 commits behind head on main.

Files with missing lines Patch % Lines
crates/starknet_state_sync/src/runner/mod.rs 9.09% 19 Missing and 1 partial ⚠️
crates/starknet_state_sync_types/src/errors.rs 0.00% 3 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main    #2285       +/-   ##
===========================================
+ Coverage   40.10%   77.03%   +36.92%     
===========================================
  Files          26      386      +360     
  Lines        1895    40552    +38657     
  Branches     1895    40552    +38657     
===========================================
+ Hits          760    31239    +30479     
- Misses       1100     7009     +5909     
- Partials       35     2304     +2269     

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

@noamsp-starkware noamsp-starkware force-pushed the noam.s/implement_get_block_in_state_sync branch from 5549f4a to 1af5f69 Compare November 26, 2024 10:34
@noamsp-starkware noamsp-starkware changed the title implement get_block in StateSync feat(sync): implement get_block in StateSync Nov 26, 2024
@noamsp-starkware noamsp-starkware marked this pull request as ready for review November 26, 2024 11:19
Copy link
Contributor

@ShahakShama ShahakShama left a comment

Choose a reason for hiding this comment

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

Reviewed 2 of 2 files at r1, all commit messages.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @noamsp-starkware)


crates/starknet_state_sync/src/runner/mod.rs line 52 at r1 (raw file):

        tokio::select! {
            result = &mut self.sync_future => result.map_err(|_| ComponentError::InternalComponentError),
            Some((request, sender)) = self.request_receiver.next() => {

Run this inside an async block that loops for requests. Right now it will only handle one request and stop


crates/starknet_state_sync/src/runner/mod.rs line 55 at r1 (raw file):

                let response = match request {
                    StateSyncRequest::GetBlock(block_number) => {
                        StateSyncResponse::GetBlock(self.get_block(block_number))

See comment below, and then change this to Ok(self.get_block....map_err(|_| ComponentError::Int...)?


crates/starknet_state_sync/src/runner/mod.rs line 110 at r1 (raw file):

    }

    fn get_block(&self, block_number: BlockNumber) -> StateSyncResult<Option<SyncBlock>> {

This wasn't the last thing we said today. We said it should be Result<Option, StorageError>, and all the unwraps should be ? instead

Copy link
Contributor Author

@noamsp-starkware noamsp-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, 3 unresolved discussions (waiting on @ShahakShama)


crates/starknet_state_sync/src/runner/mod.rs line 52 at r1 (raw file):

Previously, ShahakShama wrote…

Run this inside an async block that loops for requests. Right now it will only handle one request and stop

Ack


crates/starknet_state_sync/src/runner/mod.rs line 55 at r1 (raw file):

Previously, ShahakShama wrote…

See comment below, and then change this to Ok(self.get_block....map_err(|_| ComponentError::Int...)?

Ack


crates/starknet_state_sync/src/runner/mod.rs line 110 at r1 (raw file):

Previously, ShahakShama wrote…

This wasn't the last thing we said today. We said it should be Result<Option, StorageError>, and all the unwraps should be ? instead

We also said that we should panic if encountered an error, so I thought it was more readable this way.

@noamsp-starkware noamsp-starkware force-pushed the noam.s/implement_get_block_in_state_sync branch from 1af5f69 to 3481d54 Compare November 26, 2024 17:04
Copy link
Contributor

@ShahakShama ShahakShama 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 r2, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @noamsp-starkware)


crates/starknet_state_sync/src/runner/mod.rs line 52 at r1 (raw file):

Previously, noamsp-starkware wrote…

Ack

This also works :)


crates/starknet_state_sync/src/runner/mod.rs line 108 at r2 (raw file):

    }

    fn get_block(&self, block_number: BlockNumber) -> Result<Option<SyncBlock>, StorageError> {

I thought about it this morning, and I think that we should return the error to the user instead of crashing. This means that you should return this back to StateSyncResult and add a StorageError variant to StateSyncError

sorry for the mess

Copy link
Contributor Author

@noamsp-starkware noamsp-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 @ShahakShama)


crates/starknet_state_sync/src/runner/mod.rs line 52 at r1 (raw file):

Previously, ShahakShama wrote…

This also works :)

It was really problematic (ownership-wise) to put the loop in the select. I figured this would have the same effect and be much less of a hassle.


crates/starknet_state_sync/src/runner/mod.rs line 108 at r2 (raw file):

Previously, ShahakShama wrote…

I thought about it this morning, and I think that we should return the error to the user instead of crashing. This means that you should return this back to StateSyncResult and add a StorageError variant to StateSyncError

sorry for the mess

On it

@noamsp-starkware noamsp-starkware force-pushed the noam.s/implement_get_block_in_state_sync branch from 3481d54 to 814ce4d Compare November 27, 2024 09:47
Copy link

github-actions bot commented Nov 27, 2024

Artifacts upload workflows:

@noamsp-starkware noamsp-starkware force-pushed the noam.s/implement_get_block_in_state_sync branch from 814ce4d to e7dc16b Compare November 27, 2024 11:41
Copy link
Contributor

@ShahakShama ShahakShama 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 4 of 4 files at r3, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @noamsp-starkware)

@noamsp-starkware noamsp-starkware merged commit ea8fef7 into main Nov 27, 2024
23 checks passed
@noamsp-starkware noamsp-starkware deleted the noam.s/implement_get_block_in_state_sync branch November 27, 2024 13:05
@github-actions github-actions bot locked and limited conversation to collaborators Nov 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants