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(base_layer): start migrating ethers->alloy #848

Merged
merged 1 commit into from
Sep 18, 2024
Merged

Conversation

giladchase
Copy link
Contributor

@giladchase giladchase commented Sep 18, 2024

Minimal logic changes, strictly migration.
Refactors of existing code are added on a separate commit on top
of this one, to separate the migration from the refactor.

Notable changes

  • Errors:
  • ProviderError on ethers was only the node_url parse error, which
    isn't needed for on_http since it already expects a Url argument.
  • AbiError and BadContract type errors are both sub-variants of
    the Contract variant, that is, both errors types are variants
    of alloy_contract::Error.
  • API:
    • Return type of the call API now only implements IntoFuture,
      rather than Future like on ethers, hence manually calling
      into_future() is required before passing it to tokio.
    • call() in alloy returns a dynamic type, which is alloy
      discourages
      when types are known at compilation-time. Therefore using call_raw,
      which returns Bytes, and casting statically.

commit-id:b8b28c1a


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 feat(papyrus): start migrating ethers->alloy feat(base_layer): start migrating ethers->alloy Sep 18, 2024
@giladchase giladchase force-pushed the spr/main/b8b28c1a branch 2 times, most recently from 04a9b92 to 0021b18 Compare September 18, 2024 06:19
Copy link

Benchmark movements:
tree_computation_flow performance improved 😺
tree_computation_flow time: [67.172 ms 67.245 ms 67.331 ms]
change: [-8.2483% -4.9213% -2.0849%] (p = 0.00 < 0.05)
Performance has improved.
Found 4 outliers among 100 measurements (4.00%)
4 (4.00%) high severe

Copy link

codecov bot commented Sep 18, 2024

Codecov Report

Attention: Patch coverage is 53.84615% with 6 lines in your changes missing coverage. Please review.

Project coverage is 74.50%. Comparing base (8aa893b) to head (e8546e9).
Report is 23 commits behind head on main.

Files with missing lines Patch % Lines
...rus_base_layer/src/ethereum_base_layer_contract.rs 53.84% 0 Missing and 6 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #848      +/-   ##
==========================================
+ Coverage   74.44%   74.50%   +0.05%     
==========================================
  Files         364      368       +4     
  Lines       38395    38648     +253     
  Branches    38395    38648     +253     
==========================================
+ Hits        28583    28794     +211     
- Misses       7493     7524      +31     
- Partials     2319     2330      +11     

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

Copy link

Benchmark movements:
tree_computation_flow performance improved 😺
tree_computation_flow time: [66.135 ms 66.250 ms 66.384 ms]
change: [-10.360% -6.5897% -3.3735%] (p = 0.00 < 0.05)
Performance has improved.
Found 8 outliers among 100 measurements (8.00%)
4 (4.00%) high mild
4 (4.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 5 of 5 files at r1, 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 24 at r1 (raw file):

#[derive(thiserror::Error, Debug)]
pub enum EthereumBaseLayerError {

Alphabetize?

Code quote:

EthereumBaseLayerError

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

        // The solidity contract was pre-compiled, and only the relevant functions were kept.
        let abi: JsonAbi =

Is annotation still needed, given turbofish?

Code quote:

: JsonAbi

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: 3 of 5 files reviewed, 2 unresolved discussions (waiting on @dan-starkware and @elintul)


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

Previously, elintul (Elin) wrote…

Alphabetize?

Added to the refactor PR


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

Previously, elintul (Elin) wrote…

Is annotation still needed, given turbofish?

Nope, removing it in the second PR altogether.

Kept it here to keep the diff migration-only, without mixing in refactoring.

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 r2, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @dan-starkware)

Copy link

Benchmark movements:
tree_computation_flow performance improved 😺
tree_computation_flow time: [66.609 ms 66.703 ms 66.803 ms]
change: [-8.3960% -5.1229% -2.3128%] (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

Benchmark movements:
tree_computation_flow performance improved 😺
tree_computation_flow time: [66.946 ms 67.011 ms 67.084 ms]
change: [-8.5829% -4.9824% -1.9414%] (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

Minimal logic changes, strictly migration.
Refactors of existing code are added on a separate commit on top
of this one, to separate the migration from the refactor.

*Notable changes*

- Errors:
 * `ProviderError` on `ethers` was only the node_url parse error, which
 isn't needed for `on_http` since it already expects a `Url` argument.
 * `AbiError` and `BadContract` type errors are both sub-variants of
   the `Contract` variant, that is, both errors types are variants
   of `alloy_contract::Error`.

- API:
  * Return type of the call API now only implements `IntoFuture`,
  rather than `Future` like on `ethers`, hence manually calling
  `into_future()` is required before passing it to `tokio`.
  * `call()` in alloy returns a dynamic type, which is alloy
  [discourages](https://docs.rs/alloy-dyn-abi/latest/alloy_dyn_abi/)
  when types are known at compilation-time. Therefore using `call_raw`,
  which returns `Bytes`, and casting statically.

commit-id:b8b28c1a
Copy link

Benchmark movements:
tree_computation_flow performance improved 😺
tree_computation_flow time: [66.539 ms 66.651 ms 66.768 ms]
change: [-8.1939% -4.9151% -2.1860%] (p = 0.00 < 0.05)
Performance has improved.
Found 2 outliers among 100 measurements (2.00%)
2 (2.00%) high mild

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

@giladchase giladchase merged commit 701fbb2 into main Sep 18, 2024
29 of 54 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