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: add hardhat config RPC methods #4596

Merged
merged 4 commits into from
Nov 18, 2023
Merged

feat: add hardhat config RPC methods #4596

merged 4 commits into from
Nov 18, 2023

Conversation

Wodann
Copy link
Member

@Wodann Wodann commented Nov 17, 2023

As part of this change, I made the network_id a u64 as there was no need for it to support up to U256. It's represented as a string decimal in the JSON-RPC. The U64 allows deserialization of these values too, making it a convenient helper.

@Wodann Wodann self-assigned this Nov 17, 2023
Copy link

changeset-bot bot commented Nov 17, 2023

⚠️ No Changeset found

Latest commit: 3fa4a72

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

vercel bot commented Nov 17, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
hardhat ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 18, 2023 8:53am

@Wodann Wodann linked an issue Nov 17, 2023 that may be closed by this pull request
4 tasks
Copy link
Member

@agostbiro agostbiro left a comment

Choose a reason for hiding this comment

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

Thanks LGTM overall. I left some questions to double check some things, approving assuming none of those need changes.

@@ -118,7 +119,7 @@ pub enum Request {
serialize_with = "single_to_sequence",
deserialize_with = "sequence_to_single"
)]
SetPrevRandao(ZeroXPrefixedBytes),
SetPrevRandao(B256),
Copy link
Member

Choose a reason for hiding this comment

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

Just double checking: does B256 serializes into 0x... string?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, it does.

) -> Result<bool, ProviderError> {
let spec_id = data.spec_id();
if spec_id < SpecId::LONDON {
return Err(ProviderError::UnmetHardfork {
Copy link
Member

Choose a reason for hiding this comment

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

Wondering if this is going to match error returned by Hardhat. Is that a concern at all @alcuadrado @fvictorio ?

/// The number of the block that the network forked from.
pub fork_block_number: u64,
/// The hash of the block that the network forked from.
pub fork_block_hash: B256,
Copy link
Member

Choose a reason for hiding this comment

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

Noticed that the Hardhat type doesn't explicit say that this is a 0x-prefixed string. Are we sure it is?

    // The hash of the block that the network forked from.
    forkBlockHash: string;

Copy link
Member Author

Choose a reason for hiding this comment

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

    const latestBlockHashHex = latestBlock.header.hash().toString("hex");
    const latestBlockHash = `0x${latestBlockHashHex}`;

https://github.com/NomicFoundation/hardhat/blob/main/packages/hardhat-core/src/internal/hardhat-network/provider/node.ts#L2719

@Wodann Wodann force-pushed the edr/feat/rpc-config branch from a88a7d2 to d07025d Compare November 18, 2023 08:47
@Wodann Wodann force-pushed the edr/feat/rpc-config branch from d07025d to 3fa4a72 Compare November 18, 2023 08:52
@Wodann Wodann merged commit 4c1e5fa into edr/main Nov 18, 2023
49 checks passed
@Wodann Wodann deleted the edr/feat/rpc-config branch November 18, 2023 09:52
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Port hardhat_* config JSON-RPC APIs (part 2)
2 participants