Skip to content

Conversation

@lpahlavi
Copy link
Contributor

(XC-412) This PR continues the effort to add support for all EVM RPC canister endpoints to the client by adding support for the eth_getBlockByNumber endpoint.

lpahlavi and others added 30 commits August 6, 2025 15:33
Co-authored-by: gregorydemay <[email protected]>
@lpahlavi lpahlavi requested a review from a team as a code owner August 27, 2025 14:53
@lpahlavi lpahlavi requested a review from gregorydemay August 28, 2025 13:45
Base automatically changed from lpahlavi/XC-412-evm-rpc-client-int-tests to main September 4, 2025 13:38
Copy link
Contributor

@gregorydemay gregorydemay left a comment

Choose a reason for hiding this comment

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

Thanks @lpahlavi for this PR! Some minor comments but otherwise looks already very good to me

Comment on lines +83 to +85
blob_gas_used: None,
excess_blob_gas: None,
parent_beacon_block_root: None,
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's maybe create a ticket to add support for those 3 fields, see ethereum/execution-apis#477.

Copy link
Contributor Author

@lpahlavi lpahlavi left a comment

Choose a reason for hiding this comment

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

Thanks a lot for the feedback @gregorydemay! Should be good for another round of review.

Copy link
Contributor

@gregorydemay gregorydemay left a comment

Choose a reason for hiding this comment

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

Thanks @lpahlavi ! There is a minor comment regarding the difficulty post-paris blocks, but otherwise LGTM!

}
}

fn serialize_alloy_block(block: alloy_rpc_types::Block) -> Value {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: this is not just serialization, but also some form of canonicalization to be able to compare it with the other serialized type. It might be clearer if all mutations happen in some canonicalize methods, e.g.

#[test]
        fn should_convert_pre_paris_block_to_alloy(block in arb_pre_paris_block()) {
            let serialized = serde_json::to_value(&block).unwrap();

            let alloy_block = alloy_rpc_types::Block::try_from(block.clone()).unwrap();
            let alloy_serialized = serde_json::to_value(&alloy_block).unwrap();

            prop_assert_eq!(serialized, canonicalize(alloy_serialized));
        }


fn canonicalize(block: serde_json::Value) -> serde_json::Value { //take ownership to return mutated type

}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense. I've extracted the canonicalization logic to a separate method and applied it to both serialized objects. Theoretically, it's only really needed to canonicalize serialized in should_convert_post_paris_block_to_alloy to ensure that there are no null difficulty values, but I thought it's then clearer to just apply the same canonicalization to both sides of the equation in all tests for clarity. WDYT?

Copy link
Contributor

Choose a reason for hiding this comment

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

but I thought it's then clearer to just apply the same canonicalization to both sides of the equation in all tests for clarity. WDYT?

This part is less clear to me, the canonicalization does not do anything in case of the Candid type, or am I missing something? If that's the case I actually find it confusing to have it (could also be error-prone in case a field is wrongly set to some value in both cases that does not match the actual behavior of the productive logic)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, there is one edge case where the serialized evm_rpc_types::Block needs to be canonicalized. Namely, when the difficulty field is null which would correspond to 0x0 for alloy (since there the difficulty is never null). This is however just needed in the post Paris upgrade test. I extracted that canonicalization and applied it more restrictively, only where needed.

@lpahlavi lpahlavi merged commit 6bd564b into main Sep 11, 2025
11 checks passed
@lpahlavi lpahlavi deleted the lpahlavi/XC-412-eth-get-block-by-number branch September 11, 2025 08:01
@github-actions github-actions bot mentioned this pull request Sep 24, 2025
This was referenced Oct 20, 2025
lpahlavi added a commit that referenced this pull request Oct 21, 2025
## 🤖 New release

* `evm_rpc_types`: 2.1.0 -> 3.0.0 (✓ API compatible changes)
* `evm_rpc_client`: 0.1.0
* `evm_rpc`: 2.5.0 -> 2.6.0 (✓ API compatible changes)

<details><summary><i><b>Changelog</b></i></summary><p>

## `evm_rpc_types`

<blockquote>

## [3.0.0] - 2025-10-20

### Added

- Add conversions between several types in this crate and the
corresponding `alloy` types. These conversions are only available with
the `alloy` feature
([#465](#465),
[#466](#466),
[#467](#467),
[#476](#476)).
- **Breaking:** Add `root` and `cumulativeGasUsed` fields to
`TransactionsReceipt` type
([#474](#474))

[3.0.0]:
https://github.com/dfinity/evm-rpc-canister/compare/evm_rpc_types-v2.1.0..evm_rpc_types-v3.0.0
</blockquote>

## `evm_rpc_client`

<blockquote>

## [0.1.0] - 2025-10-20

### Added

- Add methods to modify RPC config to `RequestBuilder`
([#494](#494))
- Add `alloy` feature flag to `evm_rpc_client`
([#484](#484))
- Add new `json_request` endpoint
([#477](#477))
- Add client support for `eth_getTransactionReceipt`
([#476](#476))
- Add `eth_sendRawTransaction` client support
([#467](#467))
- Add client support for `eth_call`
([#466](#466))
- Add client support for `eth_getTransactionCount`
([#465](#465))
- Add support for `eth_feeHistory` to client
([#460](#460))
- Add support for `eth_getBlockByNumber` to client
([#459](#459))
- Add EVM RPC canister client
([#447](#447))

[0.1.0]:
https://github.com/dfinity/evm-rpc-canister/releases/tag/evm_rpc_client-v0.1.0
</blockquote>

## `evm_rpc`

<blockquote>

## [2.6.0] - 2025-10-20

### Added

- Add support for `root` and `cumulativeGasUsed` fields in
`eth_getTransactionReceipt` response
([#474](#474))
- Add new `json_request` endpoint and deprecate existing `request`
endpoint ([#477](#477))

### Changed

- Update `ic-cdk` to `v0.18.7`
([#489](#489))
- Update `dfx` to `v0.29.0`
([#490](#490))
- Cleanup unused dependencies
([#491](#491))

### Removed

- **Breaking**: Remove `getMetrics` endpoint, this is acceptable since
it was a debugging endpoint
([#479](#479))

### Fixed

- Add `err_max_response_size_exceeded` to Prometheus metrics
([#487](#487))

[2.6.0]:
v2.5.0...v2.6.0
</blockquote>


</p></details>

---
This PR was generated with
[release-plz](https://github.com/release-plz/release-plz/).

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Louis Pahlavi <[email protected]>
brightverdellmkf-61 added a commit to brightverdellmkf-61/evmrpcc that referenced this pull request Oct 27, 2025
## 🤖 New release

* `evm_rpc_types`: 2.1.0 -> 3.0.0 (✓ API compatible changes)
* `evm_rpc_client`: 0.1.0
* `evm_rpc`: 2.5.0 -> 2.6.0 (✓ API compatible changes)

<details><summary><i><b>Changelog</b></i></summary><p>

## `evm_rpc_types`

<blockquote>

## [3.0.0] - 2025-10-20

### Added

- Add conversions between several types in this crate and the
corresponding `alloy` types. These conversions are only available with
the `alloy` feature
([#465](dfinity/evm-rpc-canister#465),
[#466](dfinity/evm-rpc-canister#466),
[#467](dfinity/evm-rpc-canister#467),
[#476](dfinity/evm-rpc-canister#476)).
- **Breaking:** Add `root` and `cumulativeGasUsed` fields to
`TransactionsReceipt` type
([#474](dfinity/evm-rpc-canister#474))

[3.0.0]:
https://github.com/dfinity/evm-rpc-canister/compare/evm_rpc_types-v2.1.0..evm_rpc_types-v3.0.0
</blockquote>

## `evm_rpc_client`

<blockquote>

## [0.1.0] - 2025-10-20

### Added

- Add methods to modify RPC config to `RequestBuilder`
([#494](dfinity/evm-rpc-canister#494))
- Add `alloy` feature flag to `evm_rpc_client`
([#484](dfinity/evm-rpc-canister#484))
- Add new `json_request` endpoint
([#477](dfinity/evm-rpc-canister#477))
- Add client support for `eth_getTransactionReceipt`
([#476](dfinity/evm-rpc-canister#476))
- Add `eth_sendRawTransaction` client support
([#467](dfinity/evm-rpc-canister#467))
- Add client support for `eth_call`
([#466](dfinity/evm-rpc-canister#466))
- Add client support for `eth_getTransactionCount`
([#465](dfinity/evm-rpc-canister#465))
- Add support for `eth_feeHistory` to client
([#460](dfinity/evm-rpc-canister#460))
- Add support for `eth_getBlockByNumber` to client
([#459](dfinity/evm-rpc-canister#459))
- Add EVM RPC canister client
([#447](dfinity/evm-rpc-canister#447))

[0.1.0]:
https://github.com/dfinity/evm-rpc-canister/releases/tag/evm_rpc_client-v0.1.0
</blockquote>

## `evm_rpc`

<blockquote>

## [2.6.0] - 2025-10-20

### Added

- Add support for `root` and `cumulativeGasUsed` fields in
`eth_getTransactionReceipt` response
([#474](dfinity/evm-rpc-canister#474))
- Add new `json_request` endpoint and deprecate existing `request`
endpoint ([#477](dfinity/evm-rpc-canister#477))

### Changed

- Update `ic-cdk` to `v0.18.7`
([#489](dfinity/evm-rpc-canister#489))
- Update `dfx` to `v0.29.0`
([#490](dfinity/evm-rpc-canister#490))
- Cleanup unused dependencies
([#491](dfinity/evm-rpc-canister#491))

### Removed

- **Breaking**: Remove `getMetrics` endpoint, this is acceptable since
it was a debugging endpoint
([#479](dfinity/evm-rpc-canister#479))

### Fixed

- Add `err_max_response_size_exceeded` to Prometheus metrics
([#487](dfinity/evm-rpc-canister#487))

[2.6.0]:
dfinity/evm-rpc-canister@v2.5.0...v2.6.0
</blockquote>


</p></details>

---
This PR was generated with
[release-plz](https://github.com/release-plz/release-plz/).

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Louis Pahlavi <[email protected]>
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.

2 participants