Skip to content
This repository was archived by the owner on Nov 6, 2020. It is now read-only.

Allow Engine to count expensive system calls towards block gas limit. #11320

Closed
afck opened this issue Dec 10, 2019 · 0 comments
Closed

Allow Engine to count expensive system calls towards block gas limit. #11320

afck opened this issue Dec 10, 2019 · 0 comments
Labels
A3-stale 🍃 Pull request did not receive any updates in a long time. No review needed at this stage. Close it.

Comments

@afck
Copy link
Contributor

afck commented Dec 10, 2019

POSDAO will do some expensive calculations once per week to distribute aggregated block rewards. These are performed by a block reward contract as a system call. Currently, this happens in OpenBlock::close_and_lock, which, with the Authority Round engine, calls on_close_block, which calls the contract. If that call is very expensive and happens after the block has already been filled, possibly up to the gas limit, that means the EVM does much more work for that block, making block creation and verification slower than it should be, given the gas limit.

In #10928, we proposed a mechanism for a contract to tell the engine to temporarily lower the gas limit.

In a discussion with @dvdplm, we came up with a cleaner solution: To add a way for the system call's gas consumption to be subtracted from the block gas limit. That would require the call to be made when opening the block, not when closing it. So we would need to:

  • Add an Engine::on_open_block method that can make system calls and return their consumed gas, maybe in the form of Receipts?
  • Keep track of the system calls' gas consumption, maybe by adding them to ExecutedBlock::receipts before the actual transactions? Or with a new field in ExecutedBlock?
  • Modify Machine::execute_code_as_system so that it returns the gas consumption or receipt.

Please let me know whether that approach makes sense, and would be preferred.

@adria0 adria0 added the A3-stale 🍃 Pull request did not receive any updates in a long time. No review needed at this stage. Close it. label Jul 27, 2020
@adria0 adria0 closed this as completed Jul 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A3-stale 🍃 Pull request did not receive any updates in a long time. No review needed at this stage. Close it.
Projects
None yet
Development

No branches or pull requests

2 participants