multiversx / mx-chain-proxy-go

🐙 MultiversX Proxy: The official implementation of the web proxy for the MultiversX blockchain. An intermediary that abstracts away the complexity of sharding, through a friendly HTTP API.
https://docs.multiversx.com/sdk-and-tools/proxy/
56 stars 18 forks source link

transaction/cost broken for cross-chain transactions #280

Open lcswillems opened 3 years ago

lcswillems commented 3 years ago

Hi,

I think the transaction/cost endpoint is broken for cross-shard transactions.

I attach the reproduction. It has the extension .txt but it should be replaced by .http (I could not attach a .http file directly here). Then this .http file can be ran in VSCode.

bug-cost.txt

I have to account on testnet:

Both accounts own some SFT token MEXFARM-c070e3-9426.

In the file I attached, you can find 2 POST requests to transaction/cost endpoint.

In request 1, account 1 (in shard 1) transfers a quantity X of MEXFARM-c070e3-9426 to the compoundRewards method of MEX farm SC. The cost estimation of this call is: 17815967. This call is an intrashard one.

In request 2, account 2 (in shard 2) transfers same quantity X of MEXFARM-c070e3-9426 to the compoundRewards method of MEX farm SC. The cost estimation of this call is: 1052300, i.e. 17 times lower than the call for account 1.

Request 1 and request 2 have the same data field and are barely the same transactions. The only difference is that one is made by an account in shard 1 and the other by an account in shard 2. Hence, having a 17x difference between cost estimation seems there is something in proxy's estimation.

I hope my explanations are clear enough. Let me know if I can help more.

Lucas

silvestrst-crypto commented 2 years ago

Another thing is that it doesn't just calculate the cost, but also performs check as for the normal transaction. For example, if total accumulated staking rewards are below 1EGLD, reDelegateRewards cost calculation at the /cost endpoint will fail with the message delegate value must be higher than 0. Which doesn't seem right, cost calculation should be about cost calculation.

Although I guess developers tried to reuse existing message validation code.