gelatodigital / gelato-network

V1 implementation of Gelato Network
https://gelato.network/
MIT License
231 stars 29 forks source link

Gelato core edits #209

Closed gitpusha closed 4 years ago

gitpusha commented 4 years ago

GelatoCore:

Change 1 Line 307:: - EXEC_TX_OVERHEAD

if (startGas < _gelatoMaxGas - EXEC_TX_OVERHEAD)
    emit LogExecReverted(msg.sender, _TR.id, 0, reason);

This makes sure that Executors can send gelatoMaxGas and still get a Refund because EXEC_TX_OVERHEAD is taken into account. We had this at some point already but must have lost it at some point during refactoring.

Change 2: Line 414:

uint256 estGasUsed = _startGas - gasleft() + EXEC_TX_OVERHEAD;

Let's account for the constant EXEC_TX_OVERHEAD in our gasUsed estimation. Makes code cleaner e.g. this is now cleaner:

uint256 cappedGasUsed = estGasUsed < _gelatoMaxGas ? estGasUsed : _gelatoMaxGas;
gitpusha commented 4 years ago

I applied your suggestion vis-a-vi EXEC_TX_OVERHEAD in gas calcs in a squashed commit and will make a new PR also with other Post-Audit changes tomorrow morning.