Static calls taking too long

Hey guys. We are connecting the final dots for the decentralized exchange implementation, but we are struggling with the requests to the epoch node.

Our use case is the following:

When the user starts loading the aepp, we need to get some information from the smart contract through several static calls. However each of these calls is taking between 5 and 7 seconds, which is a lot of time and kills huge part of the UX. We are using the JS-SDK and currently the smart contract is on the testnet.

Any suggestions how to reduce the times will be highly appreciated.

Thanks in advance.

2 Likes

Hello, one thing you can do to get way better performance right away is using your own node to execute static calls, as the provided ones get varying load from public use and thus can’t provide the lowest latency for everyone.

Also this is a known issue with the aeternity node, one thing you can do is ensure that you use the dry-run api instead of static calls, but I am unsure what the current implementation of this in the js-sdk is.

Additionally it helps if you build an aeternity node from source and disable all means of logging, as the VM still includes lots of debugging helpers in the current build. (Edit: this behaviour is not present with the dry-run endpoints)

1 Like

So no actual fix yet? Thanks for answering.

The “actual” fix is to use the non-deprecated endpoint…

2 Likes

I guess I can find in in the swagger documentation?

Yes, under /debug/transactions/dry-run

You can basically pass exactly the same transaction as you would pass to create/call the contract on-chain - except that you should not sign the transactions.

Note that the dry-run API accepts a list of transactions! I.e. you can deploy and make a series of calls to a contract with one API call. In this way it is much easier to experiment with the implementation of the contract since you don’t have to actually deploy it to the chain.

There is also a few lines about dry-run here: protocol/contract_api_usage.md at master · aeternity/protocol · GitHub

2 Likes

Damn, that’s really cool! I will definitely check this out.
P. S. in what format each transaction should be? To be honest I’ve never seen a raw tx. Is there a way to compose one using the SDK?

1 Like

Sorry, that is outside my comfort zone - I’m at loss when it comes to the SDK I am afraid…

You should be able to create transactions using the debug/contracts/create and debug/contracts/call endpoints - but I would guess that there is support in the SDK that makes it more convenient!

2 Likes

Can someone from the SDK team shed some light on that matter. Is it possible to use the dry-run functionality using the js-sdk? And if not then can you provide some assistance on how to setup the raw txs so we can call the api manually?

P.S. @hanssv.chain thanks a lot <3

We are using the dry-run API. The sequence of calls is currently-

  • For make contract call we do:
  1. Build transaction: getAccount(get nonce), getTop(calculate ttl), buildCallData
  2. txDryRun
  • at least 4 API calls

So we’re not sure why this isn’t faster.

1 Like