massalabs / station

A gateway to the Massa blockchain
https://station.massa.net
27 stars 107 forks source link

function to callibrate max_gas parameter for web-on-chain #1269

Closed Thykof closed 9 months ago

Thykof commented 10 months ago

The problem(s) On the web on chain, we have no idea what to use as max_gas, so we use the maximum value. The consequence is that the operation could never be chosen by a block creator.

To Reproduce

On secure net for example, try to deploy a website with several chunks (laby) ans maybe on operation of appending a chunk will not passe.

MassaStation version The version of MassaStation the bug is present in.

main branch as of https://github.com/massalabs/station/commit/c1b8cfd04eb88941aec772336dbea43763258c72

Thykof commented 10 months ago

Context: I have worked on this task during the preparation for the migration of buildnet v24.1 to v27.

After experimentation, some error occur: execute_read_only_call v24 : OK execute_read_only_call v27 : Invalid params execute_read_only_bytecode v24 : Internal error execute_read_only_bytecode v27 : Invalid params

So in the 2 PRs, the gas cost estimation function ignore the error of the node and return the default gas limit value.

Now, we are only interested in having this estimation functions work on v27, so the PR are ready, but the node isn't.

Thykof commented 9 months ago

execute_read_only_bytecode v27 and execute_read_only_call v27 are supposed to work.

We need to take this value for max_gas: min(max allowed gas, readonly gas cost result)

max allowed gas =

MaxGasAllowedExecuteSC     = 3_980_167_295
MaxGasAllowedCallSC        = 4_294_167_295

gas cost result = the result of the read only, if no error, gives the gas cost