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

Create State specific JSON api-s #281

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

morph-dev
Copy link
Contributor

Add state specific JSON api-s:

  • portal_stateRecursiveFindAccountState
    • for a given state root and address, returns account state and proof
  • portal_stateRecursiveFindContractStorageAt
    • for a given address, contract storage root and storage slot, returns value from the storage trie and proof
  • portal_stateRecursiveFindContractBytecode
    • for a given address and codehash, returns contract's bytecode

This PR also defines few api-s that already exist (at least in trin):

  • portal_historyRadius
  • portal_stateTraceRecursiveFindContent
  • portal_stateRadius

Copy link
Member

@ogenev ogenev left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@@ -139,6 +139,26 @@
"$ref": "#/components/contentDescriptors/RecursiveFindContentResult"
}
},
{
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do I understand correctly that these calls walk down the state to get to a specific account / storage data?
So basically a bunch of different recursiveFindContent calls?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, that's the idea. It is a mid point between recursiveFindContent and eth_ state methods (eth_getBalance, eth_getStorageAt, eth_getTransactionCount, eth_getCode).

Copy link
Collaborator

@kdeme kdeme Mar 19, 2024

Choose a reason for hiding this comment

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

Right. I'm not a big fan of mixing these type of methods in the core Portal json-rpc API. Unless their logic is also required in the core protocol.

It seems they are not so different from the Execution layer JSON-RPC API counterparts, aside from directly requiring the state root versus the block root?

But if that is enough reason to still have them, then I'd say they perhaps should have a separate, more application focused, Portal json-rpc "namespace"? Or for now, atleast they could be made optional in the current Portal JSON-RPC specification (and moved when/if there are more?).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I would say that benefits are slightly better:

  • the Execution api-s actually don't allow block hash. They explicitly support block number or string ("latest", "earliest" or "pending"), and I don't think we support either (I assume we plan to in the long run, so this might not be so big issue)
  • official api for the eth_getStorageAt would have to always iterate over state trie (to find account state) and contract storage trie. The api that I propose splits those tree traversals into separate calls (meaning, if you want to get multiple values from the same contract, you will iterate state trie only once).

I'm fine with creating different namespace and / or making them optional. Maybe we can discuss this on the next team meeting.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Further thinking about it, having a different namespace is not just useful for us in keeping some logic separate, but even more interesting for end users.

Providing just one API which contains also all these lower level calls that are only useful for testing the actual protocol will be overwhelming and not great UX. Separate user focused API does sound better for that.

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.

3 participants