kaiachain / kaia

GNU Lesser General Public License v3.0
21 stars 26 forks source link

[API] Interleaved state override to `EstimateGas` #86

Closed hyunsooda closed 2 months ago

hyunsooda commented 2 months ago

Proposed changes

Overwrite state if the overrides fields is given in kaia_estimateGas and eth_estimateGas APIs.

Geth has updated the override.Apply() function, a new feature that modifies the precompiled contract address, but it is not imported in this PR. (also, this feature is not triggered against EstimateGas API)

Example usage:

#!/bin/bash

curl -X 'POST' \
  'http://localhost:8551' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{
  "method": "kaia_estimateGas",
  "id": 1,
  "jsonrpc": "2.0",
  "params": [
    {
      "from": "0x9a8d1dfdad4806605e3c63067897e4f13b06a5b4",
      "to": "0x10235AC9fCb213e1B229f636913637CD35Bf4031",
      "gas": "0x1cbf1",
      "value": "0x0",
      "gasPrice":"0x5d21dba00",
      "input": "0xe3dc878300000000000000000000000000000000000000000000000000000000000004d2"
    },
    "0x7bd",                                                                       # block number
    {                                                                                    # state override
      "0x9a8d1dfdad4806605e3c63067897e4f13b06a5b4": {
        "balance": "0xde0b6b3a7640000"
      }
    }
  ]
}'

Types of changes

Please put an x in the boxes related to your change.

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

Related issues

Further comments

If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution you did and what alternatives you considered, etc...