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

Alejo #83

Merged
merged 5 commits into from
Oct 4, 2021
Merged

Alejo #83

merged 5 commits into from
Oct 4, 2021

Conversation

alejoacosta74
Copy link
Collaborator

1. This PR implements the following 2 fixes on Janus

  • Cap on gasLimit > 40M on eth_call
  • Hex format verification in block numbers on eth_getLogs

For further details see below

2. Fix: Cap on gasLimit

  • Janus behaviour before the fix (when receiving RPC call with gasLimit=50M)
level=debug component=qtum.Client method=callcontract
=> qtum RPC request
{
  "jsonrpc": "1.0",
  "method": "callcontract",
  "id": "1",
  "params": [
    "1d670185fc3f7f3ee9008ce4966e9bad8f780b39",
    "18160ddd",
    "",
    50000000
  ]
}
<= qtum RPC response
{
  "error": null,
  "id": "1",
  "result": {
    "address": "1d670185fc3f7f3ee9008ce4966e9bad8f780b39",
    "executionResult": {
      "codeDeposit": 0,
      "depositSize": 0,
      "excepted": "BlockGasLimitReached",
      "exceptedMessage": "",
      "gasForDeposit": 0,
      "gasRefunded": 0,
      "gasUsed": 50000000,
      "newAddress": "1d670185fc3f7f3ee9008ce4966e9bad8f780b39",
      "output": ""
    },
    "transactionReceipt": {
      "bloom": "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
      "gasUsed": 50000000,
      "log": [],
      "stateRoot": "4dcfbefa1fd142d5c2c89f51da28160c8cc35817901478483e4b364dda1984e9",
      "utxoRoot": "fb4e64e526fa825947a6b6500aa54a81ddca96db4ac353d6c3cddba8a53b538a"
    }
  }
}
level=debug component=qtum.Client function=CallContract request="[\"1d670185fc3f7f3ee9008ce4966e9bad8f780b39\",\"18160ddd\",\"\",50000000]" msg="Successfully called contract"
Internalservererror=null
level=debug msg="ETH RPC"
=> ETH request
{
  "id": 1325,
  "jsonrpc": "2.0",
  "method": "eth_call",
  "params": [
    {
      "data": "0x18160ddd",
      "gas": "0x2faf080",
      "to": "0x1d670185fc3f7f3ee9008ce4966e9bad8f780b39"
    },
    "0xa9529"
  ]
}
<= ETH response
{
  "error": {
    "code": -32000,
    "message": "Revert: executionResult output is empty"
  },
  "id": 1325,
  "jsonrpc": "2.0"
}
  • Janus behaviour after fix (gasLimit=50M)
msg="proxy RPC" method=eth_call
component=qtum.Client msg="Caller gas above allowance, capping" requested=50000000 cap=40,000,000
level=debug msg="ETH RPC"
=> ETH request
{
  "id": 1325,
  "jsonrpc": "2.0",
  "method": "eth_call",
  "params": [
    {
      "data": "0x18160ddd",
      "gas": "0x2faf080",
      "to": "0x1d670185fc3f7f3ee9008ce4966e9bad8f780b39"
    },
    "0xa9529"
  ]
}
<= ETH response
{
  "id": 1325,
  "jsonrpc": "2.0",
  "result": "0x"
}

3. Fix: Hex format validation on block number

reference RPC call

  {
    "id": 1,
    "jsonrpc": "2.0",
    "method":"eth_getLogs",
    "params":[{
        "address" : "0x284937a9f5a1d28268d4e48d5eda03b04a7a1786",
        "fromBlock": "731010",
        "toBlock": "732009"
    }]
  }
  • Janus behaviour before the fix (output received in Postman)
{
    "jsonrpc": "2.0",
    "result": [],
    "id": 1
}
  • Janus behaviour after the fix (output received in Postman)
{
    "jsonrpc": "2.0",
    "error": {
        "code": 100,
        "message": "quantity values must start with 0x"
    },
    "id": 1
}

@VoR0220 VoR0220 merged commit 4c1506f into qtumproject:master Oct 4, 2021
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

Successfully merging this pull request may close these issues.

2 participants