Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: unexpected zero gas_consumed #412

Closed
xJonathanLEI opened this issue Jun 25, 2022 · 6 comments
Closed

Bug: unexpected zero gas_consumed #412

xJonathanLEI opened this issue Jun 25, 2022 · 6 comments

Comments

@xJonathanLEI
Copy link
Contributor

xJonathanLEI commented Jun 25, 2022

Description

When calling starknet_estimateGas, the gas_consumed field returned in zero.

Steps to reproduce

Run this script:

#!/bin/sh

curl \
    "https://starknet.rpc.zklend.com" \
    -H "Content-Type: application/json" \
    -d '{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "starknet_estimateFee",
  "params": [
    {
      "calldata": [
        "0x1352dd0ac2a462cb53e4f125169b28f13bd6199091a9815c444dcae83056bbc"
      ],
      "contract_address": "0x49d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7",
      "entry_point_selector": "0x2e4263afad30923c891518314c3c95dbe830a16874e8abc5777a9a20b54c76e"
    },
    "0x0157b5a30652cf983bfddbd660bac463127902a68f7acefa62823963026850db"
  ]
}' | jq

Note: as of this writing the hosted node is running v0.2.3-alpha

Expected result

The field gas_consumed should be non-zero since the two other fields are also non-zero.

Actual result

{
  "jsonrpc": "2.0",
  "result": {
    "gas_consumed": "0x0",
    "gas_price": "0x68626f4a8",
    "overall_fee": "0x10fb9d68123"
  },
  "id": 1
}
@koivunej
Copy link
Contributor

@xJonathanLEI with #429 on latest mainnet it now gives:

{
  "jsonrpc": "2.0",
  "result": {
    "gas_consumed": "0x29",
    "gas_price": "0x75cb793bb",
    "overall_fee": "0x132a27795c7"
  },
  "id": 1
}

But of course this now on a different block, and I cannot find the block you executed this on. Could you specify block hash and the network just in case if this doesn't look more correct? Let's keep this issue open until you've confirmed regardless of how #429 progresses.

@xJonathanLEI
Copy link
Contributor Author

@koivunej My fault making the script non-deterministic. I've updated the script to use a block hash instead (response updated too).

@xJonathanLEI
Copy link
Contributor Author

BTW my script was actually running against alpha-goerli. It won't work on alpha-mainnet after the update with the block hash.

@koivunej
Copy link
Contributor

Oki I don't have the goerli snapshot at hand right now... Maybe you can test the PR branch directly or let us know how it looks later after merge? Feel free to close if this is okay approach.

It will be disputable if the floor or ceil operation on coercing the gas_consumed to integer over at python side is correct, or maybe it should be rounded. I went with floor/truncation for now, assuming that's what python does with int() function.

@xJonathanLEI
Copy link
Contributor Author

No worries I have a mainnet node too :)

Script and response updated again for alpha-mainnet.

@koivunej
Copy link
Contributor

koivunej commented Jul 5, 2022

Oki finally checked the latest version, the 0x29 gas used is the same from earlier testing:

{
  "jsonrpc": "2.0",
  "result": {
    "gas_consumed": "0x29",
    "gas_price": "0x68626f4a8",
    "overall_fee": "0x10fb9d68123"
  },
  "id": 1
}

Closing for now, feel free to ping/reopen.

@koivunej koivunej closed this as completed Jul 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants