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

SKALED-1600 Use correct fork in gas estimation #1743

Merged
merged 7 commits into from
Dec 12, 2023

Conversation

dimalit
Copy link
Contributor

@dimalit dimalit commented Dec 6, 2023

1 Now eth_estimateGas() has two parameters: transaction and block number (which is ignored)
2 eth_estimateGas was using "default" fork, now it is using correct fork for current block

Testing:

  1. JsonRpcSuite/eth_estimateGas tests 1 or 2 parameters
  2. ClientTestSuite/EstimateGas tests correct estimates (checked by running transaction)

Call examples:

$ curl -X POST --data '{"id":1492278625,"jsonrpc":"2.0","method":"eth_estimateGas","params":[]}' http://127.0.0.1:1234
{"error":{"code":-32602,"data":null,"message":"INVALID_PARAMS: Invalid method parameters (invali
$ curl -X POST --data '{"id":1492278625,"jsonrpc":"2.0","method":"eth_estimateGas","params":[{"data":"0x608060405234801561001057600080fd5b506101a4806100206000396000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c80632098776714610046578063b8bd717f14610074578063fdde8d66146100a2575b600080fd5b6100726004803603602081101561005c57600080fd5b81019080803590602001909291905050506100d0565b005b6100a06004803603602081101561008a57600080fd5b81019080803590602001909291905050506100fd565b005b6100ce600480360360208110156100b857600080fd5b8101908080359060200190929190505050610137565b005b60005a90505b815a820310156100e5576100d6565b600080fd5b815a820310156100f9576100ea565b5050565b60005a90505b815a8203101561011257610103565b600060011461012057600080fd5b5a90505b815a8203101561013357610124565b5050565b60005a90505b815a8203101561014c5761013d565b600161015757600080fd5b5a90505b815a8203101561016a5761015b565b505056fea2646970667358221220e9b1c1788428bf0551c2f98cefec517a6be52c40d2610bff8d67331698e8d69164736f6c63430006000033","from":"0xf15f970e370486d5137461c5936dc6019898e6c8","type":"0x1","value":"0x0"}]}' http://127.0.0.1:1234
{"id":1492278625,"jsonrpc":"2.0","result":"0x23203"}
$ curl -X POST --data '{"id":1492278625,"jsonrpc":"2.0","method":"eth_estimateGas","params":[{"data":"0x608060405234801561001057600080fd5b506101a4806100206000396000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c80632098776714610046578063b8bd717f14610074578063fdde8d66146100a2575b600080fd5b6100726004803603602081101561005c57600080fd5b81019080803590602001909291905050506100d0565b005b6100a06004803603602081101561008a57600080fd5b81019080803590602001909291905050506100fd565b005b6100ce600480360360208110156100b857600080fd5b8101908080359060200190929190505050610137565b005b60005a90505b815a820310156100e5576100d6565b600080fd5b815a820310156100f9576100ea565b5050565b60005a90505b815a8203101561011257610103565b600060011461012057600080fd5b5a90505b815a8203101561013357610124565b5050565b60005a90505b815a8203101561014c5761013d565b600161015757600080fd5b5a90505b815a8203101561016a5761015b565b505056fea2646970667358221220e9b1c1788428bf0551c2f98cefec517a6be52c40d2610bff8d67331698e8d69164736f6c63430006000033","from":"0xf15f970e370486d5137461c5936dc6019898e6c8","type":"0x1","value":"0x0"}, "latest"]}' http://127.0.0.1:1234
{"id":1492278625,"jsonrpc":"2.0","result":"0x23203"}
$ curl -X POST --data '{"id":1492278625,"jsonrpc":"2.0","method":"eth_estimateGas","params":[{"data":"0x608060405234801561001057600080fd5b506101a4806100206000396000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c80632098776714610046578063b8bd717f14610074578063fdde8d66146100a2575b600080fd5b6100726004803603602081101561005c57600080fd5b81019080803590602001909291905050506100d0565b005b6100a06004803603602081101561008a57600080fd5b81019080803590602001909291905050506100fd565b005b6100ce600480360360208110156100b857600080fd5b8101908080359060200190929190505050610137565b005b60005a90505b815a820310156100e5576100d6565b600080fd5b815a820310156100f9576100ea565b5050565b60005a90505b815a8203101561011257610103565b600060011461012057600080fd5b5a90505b815a8203101561013357610124565b5050565b60005a90505b815a8203101561014c5761013d565b600161015757600080fd5b5a90505b815a8203101561016a5761015b565b505056fea2646970667358221220e9b1c1788428bf0551c2f98cefec517a6be52c40d2610bff8d67331698e8d69164736f6c63430006000033","from":"0xf15f970e370486d5137461c5936dc6019898e6c8","type":"0x1","value":"0x0"}, 2]}' http://127.0.0.1:1234
{"id":1492278625,"jsonrpc":"2.0","result":"0x23203"}

@dimalit dimalit linked an issue Dec 6, 2023 that may be closed by this pull request
Copy link

codecov bot commented Dec 7, 2023

Codecov Report

Merging #1743 (885fb52) into v3.18.0 (2fcb104) will increase coverage by 0.00%.
The diff coverage is 97.95%.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff            @@
##           v3.18.0    #1743   +/-   ##
========================================
  Coverage    45.52%   45.53%           
========================================
  Files          356      356           
  Lines        51685    51720   +35     
========================================
+ Hits         23532    23553   +21     
- Misses       28153    28167   +14     

@dimalit dimalit merged commit f7c560a into v3.18.0 Dec 12, 2023
8 checks passed
@dimalit dimalit deleted the bug/SKALED-1600-estimateGas branch December 12, 2023 16:01
@github-actions github-actions bot locked and limited conversation to collaborators Dec 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Invalid gas computation/fork block in estimateGas
3 participants