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

StateDecodeParams Lotus-compatible RPC endpoint. #3769

Open
5 tasks
ruseinov opened this issue Nov 30, 2023 · 0 comments
Open
5 tasks

StateDecodeParams Lotus-compatible RPC endpoint. #3769

ruseinov opened this issue Nov 30, 2023 · 0 comments
Labels
Priority: 2 - High Very important and should be addressed ASAP Type: Bug Something isn't working

Comments

@ruseinov
Copy link
Contributor

ruseinov commented Nov 30, 2023

Issue summary

A part of #3639

This endpoint takes address, tipset_keys, actor_method_number and method_params and tries to find the parameter type for a given method, then decode given params. Basically it servers as means of validation that the params for a given method have a correct format.

Here's the Go version of this endpoint: https://github.com/filecoin-project/lotus/blob/5e76b05b17771da6939c7b0bf65127c3dc70ee23/node/impl/full/state.go#L542-L558

Forest is missing a sizeable piece of infrastructure in order to be able to implement this feature, the investigation can start here:
https://github.com/filecoinproject/lotus/blob/ac85a2e23b437f7935abeff24d7280b827ca88d9/chain/consensus/compute_state.go#L41-L58. This points at several missing pieces in fil-actor-states that allow for exporting methods.

Here's an example of how a method is exported in Lotus:

  1. List of exported actors: https://github.com/filecoin-project/specs-actors/blob/master/actors/builtin/exported/actors.go
  2. How methods are exported: https://github.com/filecoin-project/specs-actors/blob/master/actors/builtin/account/account_actor.go#L17-L20. Note, that we won't be able to do it exactly the same way as Rust does not have reflection, so we're going to have to represent params in a different way in order to be able to deserialise incoming bytes, perhaps using an enum.
  3. Here's how MethodMeta is put together on Lotus side: https://github.com/filecoin-project/lotus/blob/a83f120f3277501db6ee060701d789b4dbe6f1fa/chain/vm/invoker.go#L88-L167. All the methods seem to have exactly one param, it's type is extracted via reflection from any given actor method. For anything older that Version7 there is a special case, because there's also a runtime parameter on each of the methods.

Here's what we currently have:

  1. Exported method numbers: https://github.com/ChainSafe/fil-actor-states/blob/f44aadffb45c2930ce3b09bbd63ffa332616daa4/actors/cron/src/v11/mod.rs#L18-L21
  2. Method parameters: https://github.com/ChainSafe/fil-actor-states/blob/f44aadffb45c2930ce3b09bbd63ffa332616daa4/actors/cron/src/v11/mod.rs#L23C1-L29C2

The above is missing a mapping between methods and params. It also does not look like the Parameters are used anywhere.

Task summary

  • Create a registry that would allow us to find method params by actor code and method number.
  • Create enums that would represent said params for each actor of each version
  • Create version mapping so that we're able to register all the actors of all the available versions
  • Implement the RPC endpoint

Acceptance Criteria

  • RPC output is the same as Lotus'

Other information and links

@lemmih lemmih added Type: Bug Something isn't working Priority: 2 - High Very important and should be addressed ASAP labels Aug 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority: 2 - High Very important and should be addressed ASAP Type: Bug Something isn't working
Projects
No open projects
Status: Todo
Development

No branches or pull requests

2 participants