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

refactor(base_layer): remove unnecessary option + dep #849

Merged
merged 1 commit into from
Sep 19, 2024

Conversation

giladchase
Copy link
Contributor

@giladchase giladchase commented Sep 18, 2024

commit-id:19ed8b4a


Stack:

⚠️ Part of a stack created by spr. Do not merge manually using the UI - doing so may have unexpected results.


This change is Reviewable

@giladchase giladchase changed the title refactor(papyrus): remove unnecessary dep + style refactor(base_layer): remove unnecessary dep + style Sep 18, 2024
Copy link

Benchmark movements:
tree_computation_flow performance improved 😺
tree_computation_flow time: [66.289 ms 66.368 ms 66.456 ms]
change: [-9.1803% -5.7466% -2.7311%] (p = 0.00 < 0.05)
Performance has improved.
Found 2 outliers among 100 measurements (2.00%)
2 (2.00%) high severe

Copy link

Benchmark movements:
tree_computation_flow performance improved 😺
tree_computation_flow time: [66.585 ms 66.666 ms 66.753 ms]
change: [-8.9207% -5.6793% -2.7701%] (p = 0.00 < 0.05)
Performance has improved.
Found 3 outliers among 100 measurements (3.00%)
2 (2.00%) high mild
1 (1.00%) high severe

Copy link

codecov bot commented Sep 18, 2024

Codecov Report

Attention: Patch coverage is 33.33333% with 2 lines in your changes missing coverage. Please review.

Project coverage is 75.39%. Comparing base (18d22ef) to head (f0ce810).
Report is 12 commits behind head on main.

Files with missing lines Patch % Lines
...rus_base_layer/src/ethereum_base_layer_contract.rs 33.33% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #849      +/-   ##
==========================================
+ Coverage   74.47%   75.39%   +0.91%     
==========================================
  Files         368      368              
  Lines       38554    39217     +663     
  Branches    38554    39217     +663     
==========================================
+ Hits        28715    29569     +854     
+ Misses       7513     7365     -148     
+ Partials     2326     2283      -43     

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

Copy link
Contributor Author

@giladchase giladchase 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: 0 of 4 files reviewed, 1 unresolved discussion (waiting on @dan-starkware and @elintul)


crates/papyrus_base_layer/src/ethereum_base_layer_contract.rs line 94 at r1 (raw file):

    async fn latest_proved_block(
        &self,
        min_confirmations: Option<u64>,

Rename ok?

Also since most usages will likely require finality (?) I suggest adding a separate latest_proved_block_no_finality and keep finality non-optional here, WDYT?

Suggestion:

    async fn latest_proved_block(
        &self,
        finality: Option<u64>,

Copy link
Collaborator

@elintul elintul 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 4 files at r1, 2 of 2 files at r2, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @dan-starkware and @giladchase)


crates/papyrus_base_layer/src/ethereum_base_layer_contract.rs line 94 at r1 (raw file):

Previously, giladchase wrote…

Rename ok?

Also since most usages will likely require finality (?) I suggest adding a separate latest_proved_block_no_finality and keep finality non-optional here, WDYT?

Rename's good; not sure I understand the following suggestion.


crates/papyrus_base_layer/src/ethereum_base_layer_contract.rs line 84 at r2 (raw file):

        // The solidity contract was pre-compiled, and only the relevant functions were kept.
        let abi = serde_json::from_str(include_str!("core_contract_latest_block.abi"))?;

How come neither annotation nor turbofish is needed? 😬

Copy link

Benchmark movements:
tree_computation_flow performance improved 😺
tree_computation_flow time: [65.921 ms 65.968 ms 66.029 ms]
change: [-7.6514% -4.3997% -1.6244%] (p = 0.00 < 0.05)
Performance has improved.
Found 2 outliers among 100 measurements (2.00%)
1 (1.00%) high mild
1 (1.00%) high severe

Copy link
Collaborator

@elintul elintul left a comment

Choose a reason for hiding this comment

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

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

Copy link
Contributor Author

@giladchase giladchase 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, 2 unresolved discussions (waiting on @dan-starkware and @elintul)


crates/papyrus_base_layer/src/ethereum_base_layer_contract.rs line 94 at r1 (raw file):

Previously, elintul (Elin) wrote…

Rename's good; not sure I understand the following suggestion.

i'm wondering if Option is faithfully representing common usage.

If vast majority of use cases need finality, then it is misleading and unnecessarily cumbersome, and we can just do fn latest_proved_block(&self, finality: u64), and add an additional function for the few edge cases that need 0 finality:

fn latest_proved_block_no_finality(&self) {
   let finality = 0;
   self.latest_proved_block(finality)
}

crates/papyrus_base_layer/src/ethereum_base_layer_contract.rs line 84 at r2 (raw file):

Previously, elintul (Elin) wrote…

How come neither annotation nor turbofish is needed? 😬

So two things, first of all adding both is unnecessary, only one of them suffices when type can't be inferred.
However (and that is the second thing) here type can be inferred, from the type of the field in ContractInstance.

I went back and forth on this one for a bit, but since I need a whole new dependency (alloy-json-abi) just for this annotation, I felt that going without annotation is worth it.

Copy link

Benchmark movements:
tree_computation_flow performance improved 😺
tree_computation_flow time: [66.071 ms 66.138 ms 66.215 ms]
change: [-3.3091% -2.1280% -1.1306%] (p = 0.00 < 0.05)
Performance has improved.
Found 5 outliers among 100 measurements (5.00%)
2 (2.00%) high mild
3 (3.00%) high severe

Copy link
Collaborator

@elintul elintul 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 r4, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @dan-starkware and @giladchase)


crates/papyrus_base_layer/src/ethereum_base_layer_contract.rs line 94 at r1 (raw file):

Previously, giladchase wrote…

i'm wondering if Option is faithfully representing common usage.

If vast majority of use cases need finality, then it is misleading and unnecessarily cumbersome, and we can just do fn latest_proved_block(&self, finality: u64), and add an additional function for the few edge cases that need 0 finality:

fn latest_proved_block_no_finality(&self) {
   let finality = 0;
   self.latest_proved_block(finality)
}

I think 0 can represent no finality, no reason for None; unless I'm missing something.

@giladchase giladchase changed the base branch from spr/main/b8b28c1a to main September 18, 2024 15:23
Copy link

Benchmark movements:
tree_computation_flow performance improved 😺
tree_computation_flow time: [66.479 ms 66.576 ms 66.680 ms]
change: [-11.430% -6.5645% -2.9343%] (p = 0.00 < 0.05)
Performance has improved.
Found 4 outliers among 100 measurements (4.00%)
2 (2.00%) high mild
2 (2.00%) high severe

Copy link
Contributor Author

@giladchase giladchase 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: 2 of 4 files reviewed, 1 unresolved discussion (waiting on @dan-starkware and @elintul)


crates/papyrus_base_layer/src/ethereum_base_layer_contract.rs line 94 at r1 (raw file):

Previously, elintul (Elin) wrote…

I think 0 can represent no finality, no reason for None; unless I'm missing something.

yr right, added at the top of the stack, diff is big'ish

@giladchase giladchase changed the title refactor(base_layer): remove unnecessary dep + style refactor(base_layer): remove unnecessary option + dep Sep 18, 2024
Copy link
Collaborator

@elintul elintul 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 2 of 2 files at r5, 1 of 1 files at r6, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @dan-starkware)

Copy link
Collaborator

@elintul elintul 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 @dan-starkware and @giladchase)


crates/papyrus_base_layer/src/ethereum_base_layer_contract.rs line 97 at r6 (raw file):

    async fn latest_proved_block(
        &self,
        finality: Option<u64>,

Planning to remove Option?

Code quote:

finality: Option<u64>,

Copy link
Contributor Author

@giladchase giladchase 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: :shipit: complete! all files reviewed, all discussions resolved (waiting on @dan-starkware)


crates/papyrus_base_layer/src/ethereum_base_layer_contract.rs line 97 at r6 (raw file):

Previously, elintul (Elin) wrote…

Planning to remove Option?

Done at the end of the stack, diff is too distinct

@giladchase giladchase merged commit 6cb6971 into main Sep 19, 2024
29 of 45 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Sep 20, 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.

2 participants