fcl-js icon indicating copy to clipboard operation
fcl-js copied to clipboard

[FEATURE] Verify fcl-js works with gRPC endpoint on archive node

Open bthaile opened this issue 2 years ago • 4 comments
trafficstars

Issue to be solved

API endpoints to check

  • execute script at block,
  • execute script at height
  • get account at height

test against block older than 100 back. HTTP/REST supports going back 100 blocks. Need to very going further back.

Suggest A Solution

Add integration test that can be manually executed when archive node is available. This will also give reference to community

What are you currently working on that this is blocking?

Community node.js script fails.

const fcl = require("@onflow/fcl");
const { send: transportGRPC } = require("@onflow/transport-grpc");

fcl.config({
  "accessNode.api": "archive.mainnet.nodes.onflow.org:9000",
  "sdk.transport": transportGRPC
})

async function test() {
  const result = await fcl.send([
    fcl.script`
      pub fun main(): PublicAccount{
        return getAccount(0x8f3e345219de6fed)
      }
    `,
    fcl.atBlockHeight(99452067)
  ]).then(fcl.decode);
  console.log(result);
}

test()

bthaile avatar Apr 18 '23 23:04 bthaile

"accessNode.api": "archive.mainnet.nodes.onflow.org:9000",

it needs grpcWeb proxy in front ( and probably archive.onflow.org endpoint )

bluesign avatar Apr 25 '23 07:04 bluesign

Hey @bthaile - the solution here is as @bluesign mentioned, that the archive nodes require a grpcWeb proxy in front of them such that web clients using FCL can communicate with them.

@peterargue - is this something we could add for the archive node(s)?

JeffreyDoyle avatar May 17 '23 22:05 JeffreyDoyle

@peterargue Actually, we're planning to deprecate GRPC support in FCL in FCL 2.0 (see: https://github.com/onflow/fcl-js/issues/1650). It would be best to instead plan to add REST/HTTP support to the archive node(s) instead, as that will be what is supported by FCL.

JeffreyDoyle avatar May 17 '23 22:05 JeffreyDoyle

I don't expect archive nodes will get their own REST server, but there is some work underway to add support for proxying requests from an AN to an RN (instead of an EN). This would expose the archive node's data and script execution from AN APIs. Longer term, I expect the archive node functionality to be folded directly into ANs and ONs.

I can look into how much work it would be to setup the grpc-web transcoder for the current archive nodes as a short term solution.

peterargue avatar May 18 '23 17:05 peterargue