Skip to content

Use fixed lower call gas limit #627

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

Merged
merged 1 commit into from
Aug 18, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ contract MessageDelivery is BasicAMB, MessageProcessor {
using SafeMath for uint256;

uint256 internal constant SEND_TO_ORACLE_DRIVEN_LANE = 0x00;
// after EIP2929, call to warmed contract address costs 100 instead of 2600
uint256 internal constant MIN_GAS_PER_CALL = 100;

/**
* @dev Requests message relay to the opposite network
Expand All @@ -32,7 +34,7 @@ contract MessageDelivery is BasicAMB, MessageProcessor {
// it is not allowed to pass messages while other messages are processed
// if other is not explicitly configured
require(messageId() == bytes32(0) || allowReentrantRequests());
require(_gas >= getMinimumGasUsage(_data) && _gas <= maxGasPerTx());
require(_gas >= MIN_GAS_PER_CALL && _gas <= maxGasPerTx());

(bytes32 _messageId, bytes memory header) = _packHeader(_contract, _gas, _dataType);

Expand All @@ -42,17 +44,6 @@ contract MessageDelivery is BasicAMB, MessageProcessor {
return _messageId;
}

/**
* @dev Returns a lower limit on gas limit for the particular message data
* @param _data calldata passed to the executor on the other side
*/
function getMinimumGasUsage(bytes _data) public pure returns (uint256 gas) {
// From Ethereum Yellow Paper
// 68 gas is paid for every non-zero byte of data or code for a transaction
// Starting from Istanbul hardfork, 16 gas is paid (EIP-2028)
return _data.length.mul(16);
}

/**
* @dev Packs message header into a single bytes blob
* @param _contract executor address on the other side
Expand Down