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

Make fuels-accounts WASM compatible #1165

Closed
ra0x3 opened this issue Oct 12, 2023 · 2 comments · Fixed by #1167
Closed

Make fuels-accounts WASM compatible #1165

ra0x3 opened this issue Oct 12, 2023 · 2 comments · Fixed by #1167
Assignees
Labels
help wanted Extra attention is needed

Comments

@ra0x3
Copy link

ra0x3 commented Oct 12, 2023

Background

  • We're adding support for indexing predicates on the indexer
  • Indexing predicates isn't enough, we also need to verify that predicates came from where they're supposed to come from
  • I have read over the SDK predicate docs here and understand that using the predicate ABI, and a provider, one can do some predicate derivations

Issue

  • In order to verify that predicates are from the proper source @Voxelot has been kind enough to list detailed steps for doing so, that are indexer friendly
    • Those steps are here
      • Specifically this comment
        • And specifically Section 3.2 within that ☝🏼 comment

What do I ideally need?

  • Ideally I need some way to derive the predicate root, at runtime, for an indexer, in a WASM-friendly way
    • The alternative is just using the non-WASM-friendly components (e.g., provider) and making FFI calls in/out of the indexer
      • Problem with this approach is that we'd effectively have to use a single provider for all indexers and all predicates
        • This might be fine?
  • I do have access to:
    • The predicate ABI
    • The predicate bytecode
    • The predicate data/args
    • The relevant input/output coins
  • I'm open on the best SDK way to do this however

cc @segfault-magnet @hal3e

@ra0x3 ra0x3 added the help wanted Extra attention is needed label Oct 12, 2023
@hal3e hal3e self-assigned this Oct 13, 2023
@ra0x3
Copy link
Author

ra0x3 commented Oct 13, 2023

@hal3e

  • I got a response from you on this via email, but I don't see the comment now 😅
  • Comment was:

There is an associated function called Predicate::calculate_address(code: &[u8], chain_id: u64) that returns the predicate root/address given the predicate bytecode and chain_id. Is this enough for the use-case ?

  • Yes, calculate_address is what I'll need to use

  • code being the literal predicate byte code?

  • @segfault-magnet previously mentioned that I'd have to make a network call to get the chain_id

    • Is this chain_id something that might change often for a given predicate?
      • I'm wondering if I can just grab this at compile time and then just bake it into the indexer module (again, this will only work if the chain_id never changes)
  • My last question was, the comment I linked to above ☝🏼 (the indexer comment with Brandon's explanation) mentions "injecting the predicate args/configurables into the predicate template"

    • This "injected predicate" (predicate with config vars injected) is what I would pass to calculate_address (I believe)
    • This sounds like something that would have to be done at runtime, since I'd have to extract the predicate data from the transaction when the transaction comes in
      • And if this has to be done at runtime, then I will need to call MyPredicateEncoder::encode_data and Predicate::load_from from the WASM module --- so these would have to be WASM-friendly
        • Is the usage of Predicate in this way WASM friendly?

Happy to hop on a call if that makes things easier, I know this is a lot :)

@ra0x3
Copy link
Author

ra0x3 commented Oct 13, 2023

Spoke with @hal3e offline about this and I'll update this issue title to reflect the work he mentions needs to be done

@ra0x3 ra0x3 changed the title How to derive Predicate root in SDK? Make fuels-accounts WASM compatible Oct 13, 2023
@digorithm digorithm reopened this Oct 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants