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

PortalNetwork: Implement UltralightProvider Enhancements for EIP-1193 JSON-RPC Support #699

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

cjustinobi
Copy link

Key Enhancements:

  1. EIP-1193 Method Support:

    • Implements commonly used Ethereum JSON-RPC methods:
      • eth_getBlockByHash
      • eth_getBlockByNumber
      • eth_getTransactionCount
      • eth_getCode
      • eth_getBalance
      • eth_getStorageAt
      • eth_call
  2. Error Handling:

    • Adds robust error codes and messages based on JSON-RPC specifications:
      • 4200 for unsupported methods.
      • -32602 for invalid parameters.
      • -32603 for internal errors.
  3. Removed unused methods from provider.spec.ts

Copy link
Collaborator

@acolytec3 acolytec3 left a comment

Choose a reason for hiding this comment

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

This is looking great so far. One thing we need to address is that the provider should return JSON-RPC formatted data and not just the raw block/transaction/state data our portalnetwork.ETH module returns. If you want to do that work as well, let me know and I can provide guidance on next steps or else I can do that in a subsequent PR.

Basically, we need to use these helpers with some slight edits that I can outline.

@cjustinobi
Copy link
Author

This is looking great so far. One thing we need to address is that the provider should return JSON-RPC formatted data and not just the raw block/transaction/state data our portalnetwork.ETH module returns. If you want to do that work as well, let me know and I can provide guidance on next steps or else I can do that in a subsequent PR.

Basically, we need to use these helpers with some slight edits that I can outline.

Please go ahead with the guidance. Would love to handle as well

@cjustinobi cjustinobi changed the title WIP: Implement UltralightProvider Enhancements for EIP-1193 JSON-RPC Support Portalnetwork: Implement UltralightProvider Enhancements for EIP-1193 JSON-RPC Support Dec 28, 2024
@cjustinobi cjustinobi marked this pull request as ready for review December 28, 2024 14:37
@cjustinobi cjustinobi changed the title Portalnetwork: Implement UltralightProvider Enhancements for EIP-1193 JSON-RPC Support PortalNetwork: Implement UltralightProvider Enhancements for EIP-1193 JSON-RPC Support Dec 28, 2024
@acolytec3
Copy link
Collaborator

To make the provider fully EIP compliant, each of the supported methods needs to return the values formatted to match the Ethereum JSON-RPC specification. So for each method listed in the PR description, you need to verify that the values returned by that method correspond to the JSON-RPC spec.

For the methods that return blocks, you can copy the the toJSONRPCBlock from the ethereumjs-monorepo client helpers here.

You'll need to update the toJSONRPCBlock method to remove the chainId parameter and then remove the totalDifficulty calculation. Instead, just use the difficulty from the block header object as that field in the return value.

For the other methods (getCode, getBalance, getStorage, call), you can reference the corresponding methods in the eth module in the ethereumjs client RPC implementation as a reference point for how to format the return values (or just reference the official spec).

Also, if you can update your test script to make calls to these additional methods, that would be great. For the state related methods, you'll have to pick an account that was present in the Ethereum state in ancient chain history (so maybe before block 10000000) since the state network doesn't fully support current state yet. Let me know if you need help with this part of it.

@cjustinobi
Copy link
Author

To make the provider fully EIP compliant, each of the supported methods needs to return the values formatted to match the Ethereum JSON-RPC specification. So for each method listed in the PR description, you need to verify that the values returned by that method correspond to the JSON-RPC spec.

For the methods that return blocks, you can copy the the toJSONRPCBlock from the ethereumjs-monorepo client helpers here.

You'll need to update the toJSONRPCBlock method to remove the chainId parameter and then remove the totalDifficulty calculation. Instead, just use the difficulty from the block header object as that field in the return value.

For the other methods (getCode, getBalance, getStorage, call), you can reference the corresponding methods in the eth module in the ethereumjs client RPC implementation as a reference point for how to format the return values (or just reference the official spec).

Also, if you can update your test script to make calls to these additional methods, that would be great. For the state related methods, you'll have to pick an account that was present in the Ethereum state in ancient chain history (so maybe before block 10000000) since the state network doesn't fully support current state yet. Let me know if you need help with this part of it.

Got it

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