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(eth_client): Use BlockId for block_id instead of String in eth_client #499

Merged
merged 4 commits into from
Nov 30, 2023

Conversation

RedaOps
Copy link
Contributor

@RedaOps RedaOps commented Nov 16, 2023

What ❔

The block function within eth_client now uses the type BlockId instead of String for its block_id parameter.

Why ❔

TODO comment:

// TODO (PLA-333): at the moment the latest version of `web3` crate doesn't have `Finalized` variant in `BlockNumber`.
// However, it's already added in github repo and probably will be included in the next released version.
// Scope of PLA-333 includes forking/using crate directly from github, after that we will be able to change
// type of `block_id` from `String` to `BlockId` and use `self.web3.eth().block(block_id)`.
async fn block(
&self,
block_id: String,
component: &'static str,
) -> Result<Option<Block<H256>>, Error> {
COUNTERS.call[&(Method::Block, component)].inc();
let latency = LATENCIES.direct[&Method::Block].start();
let block = CallFuture::new(
self.web3
.transport()
.execute("eth_getBlockByNumber", vec![block_id.into(), false.into()]),
)
.await?;
latency.observe();
Ok(block)
}

This PR fixes the TODO.

The web3 crate being used inside the project was updated to version 0.19.0 inside core/lib/basic_types/Cargo.toml in commit 829ef50.

The web3 crate now supports BlockNumber::Finalized.
Source: https://docs.rs/web3/latest/web3/types/enum.BlockNumber.html
Source: https://github.com/tomusdrw/rust-web3/releases/tag/v0.19.0

Checklist

  • PR title corresponds to the body of PR (we generate changelog entries from PRs).
  • Code has been formatted via zk fmt and zk lint.

@RedaOps RedaOps requested a review from a team as a code owner November 16, 2023 02:17
Copy link
Member

@popzxc popzxc left a comment

Choose a reason for hiding this comment

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

Thanks!

@popzxc popzxc added this pull request to the merge queue Nov 30, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 30, 2023
@popzxc popzxc added this pull request to the merge queue Nov 30, 2023
Merged via the queue into matter-labs:main with commit 26767b6 Nov 30, 2023
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants