Gas error about AEX9 using the balances method

Hello everyone, I was alerted with gas error when I called the balance method in AEX9, but I did not know how much gas I should set. This was not a problem in the previous node, but the call failed after upgrading 6.0

This is the contract address, you can try it

ct_id

ct_7UfopTwsRuLGFEcsScbYgQ6YnySXuyMxQWhw6fjycnzS5Nyzq

Hi @Baixin.chain,

the Iris release introduced a new (public) API endpoint that allows to perform a dry-run call like seen on your screen for balances. This endpoint is deactivated by default and if activated it allows to run a maximum amount of 6 000 000 gas. Of course this can also be configured.

Introduced a new HTTP endpoint: /dry-run . It is part of the external interface and should be prefered over the existing debug endpoint. It comes with some protections for the node: all transactions/calls provided are limited to a total amount of gas that they can consume. There is a new setting in the config where the node operator can change this according to their needs, the default value is 6 000 000 gas. The new endpoint is disabled by default and can be enabled via the new API group dry-run .

see https://github.com/aeternity/aeternity/blob/v6.0.0/docs/release-notes/RELEASE-NOTES-6.0.0.md

In case of this contract this call seems to be very computational heavy as it will return all balances of the state. It seems like AEStudio right now doesn’t explicitely use the old debug endpoint for dry-run functionality which allows to execute unlimited amount of gas but the new external endpoint.

So currently the hosted node still allows the usage of the debug endpoint but this will probably change over time meaning that if someone needs to execute a computational heavy dry-run it will be required to host your own infrastructure which is allowing that.

@nikitafuchs.chain:

  • Does AEstudio use the network (and node) configured in the Superhero Wallet extension if it is in use? If this is the case it should be possible to change the network there to connect to a custom node where the external dry-run endpoint allows a higher gas limit
  • Ideally one could specify in AEStudio which endpoint to use for the static dry-run calls (debug vs. external)
4 Likes

This would be a task for the SDK, as the editor itself doesn’t make any http calls, but nut sure if cluttering up the SDK for this one feature is worth it. or can something be done in the SDK options here… ?

I wish it could, instead I have to pass it the following values (one can easily guess why this is a security issue, but I’ve been repeating that for too long already, will open a new issue on GH on this tomorrow again though) :

public MAINNET_URL = 'https://mainnet.aeternity.io';
public COMPILER_URL = 'https://latest.compiler.aepps.com';

well the SDK makes it possible to still use the debug endpoint for dry-runs. @davidyuk mentioned this workaround to achieve that without having to change any logic: https://github.com/aeternity/aepp-sdk-js/blob/37f33db4409394a8889ded45952edc14fb26622a/examples/node/contract.js#L59

not sure if I understand this correctly right now. looking forward to see the issue on GH :slight_smile:

There you go, I hope someone can prove me wrong here:
https://github.com/aeternity/AEXs/issues/140

well the SDK makes it possible to still use the debug endpoint for dry-runs. ← does anyone have some call to easily blow the gas limit, please, so I can test things ? Not feeling like adding 10000 entries to a map or so.

responded in the issue :slight_smile:

I guess you can just use an AEX-9 contract interface and initialize the contract instance at the address which @Baixin.chain provided in this thread. a call to balances should result in the error :wink:

1 Like

Have you made any progress? My usage scenario is to get the number of all user allocations of AEX9 token and implement the leaderboard function.

2 Likes

as already discussed private chat here an explanation for everybody facing that problem

first of all it is about the node configuration itself to enable the dry-run endpoints. there are two possibilites:

  1. enable the new public (and protected) dry-run endpoint in allow a higher amount of gas to be consumed (can be configured)

  2. enable the debug endpoints and make the SDK using the debug endpoint instead of the protected public dry-run endpoint (currently not sure if this is possible with Go SDK, but for the Javascript SDK there is a workaround to do that)

    • this is NOT recommended as it is an internal endpoint that allows unlimited gas consumption

here an example with the protected endpoint enabled using a custom (increased) gas limit:
image

the default gas limit of that protected dry-run endpoint is 6 000 000 gas

2 Likes

I changed the configuration of the node in Marco’s way and changed to the day-run interface of V3. At the same time, I am setting the gas quantity, and now my problem has been solved

In addition to submitting a proposal, I hope that aestudio can add a configuration that can set its own nodes
@marco.chain @nikitafuchs.chain

2 Likes

hey @Baixin.chain , thanks for your feedback ! The way to go for using own nodes is actually adding it to superhero wallet, like :

image

image

Whereas you can leave that middleware field empty I think, for compiler just take https://latest.compiler.aepps.com

There is a reason why I havn’t added using custom nodes to aestudio (yet): Where would you put your private keys then? It would force you to copy-paste them around, and paste them into aestudio. This is considered bad practice, which of course would be acceptable when just messing around with testnet, but there is no good way to prevent this and I don’t want people to get used to this sort of thing. So therefore, you can just add your own node to the Superhero Wallet and use it in aestudio easily.

3 Likes

I’m talking about the ability to customize the node address, instead of putting the private key in Aestudio, the private key is still connected using the wallet, as long as you can customize the node address and the compiler address, so you can choose your own local node or other scenarios

For security reasons, the wallet always uses its own node address per default. It’s not like the wallet just signs transactions, it also broadcasts them. That is to prevent dApp developers from injecting malicious node addresses providing malicious data. Therefore, the only place to set a custom node address is the wallet, for a good reason :wink:

The only other way would be having node address (and keys) in aestudio.

3 Likes