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

Limit gas to 3500 #127

Merged
merged 1 commit into from
Dec 20, 2022
Merged
Show file tree
Hide file tree
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
11 changes: 11 additions & 0 deletions contracts/extensions/RONTransferHelper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,15 @@ abstract contract RONTransferHelper {
function _unsafeSendRON(address payable _recipient, uint256 _amount) internal returns (bool _success) {
(_success, ) = _recipient.call{ value: _amount }("");
}

/**
* @dev Same purpose with {_unsafeSendRON(address,uin256)} but containing gas limit stipend forwarded in the call.
*/
function _unsafeSendRON(
address payable _recipient,
uint256 _amount,
uint256 _gas
) internal returns (bool _success) {
(_success, ) = _recipient.call{ value: _amount, gas: _gas }("");
}
}
2 changes: 1 addition & 1 deletion contracts/ronin/staking/CandidateStaking.sol
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ abstract contract CandidateStaking is BaseStaking, ICandidateStaking {
_amount = _pool.stakingAmount;
if (_amount > 0) {
_deductStakingAmount(_pool, _amount);
if (!_unsafeSendRON(payable(_pool.admin), _amount)) {
if (!_unsafeSendRON(payable(_pool.admin), _amount, 3500)) {
emit StakingAmountTransferFailed(_pool.addr, _pool.admin, _amount, address(this).balance);
}
}
Expand Down
2 changes: 1 addition & 1 deletion contracts/ronin/staking/Staking.sol
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ contract Staking is IStaking, CandidateStaking, DelegatorStaking, Initializable
{
_actualDeductingAmount = _deductStakingAmount(_stakingPool[_consensusAddr], _amount);
address payable _recipientAddr = payable(validatorContract());
if (!_unsafeSendRON(_recipientAddr, _actualDeductingAmount)) {
if (!_unsafeSendRON(_recipientAddr, _actualDeductingAmount, 3500)) {
emit StakingAmountDeductFailed(_consensusAddr, _recipientAddr, _actualDeductingAmount, address(this).balance);
}
}
Expand Down
4 changes: 2 additions & 2 deletions contracts/ronin/validator/CoinbaseExecution.sol
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ abstract contract CoinbaseExecution is
function _distributeMiningReward(address _consensusAddr, address payable _treasury) private {
uint256 _amount = _miningReward[_consensusAddr];
if (_amount > 0) {
if (_unsafeSendRON(_treasury, _amount)) {
if (_unsafeSendRON(_treasury, _amount, 3500)) {
emit MiningRewardDistributed(_consensusAddr, _treasury, _amount);
return;
}
Expand All @@ -277,7 +277,7 @@ abstract contract CoinbaseExecution is
) private {
uint256 _amount = _bridgeOperatingReward[_consensusAddr];
if (_amount > 0) {
if (_unsafeSendRON(_treasury, _amount)) {
if (_unsafeSendRON(_treasury, _amount, 3500)) {
emit BridgeOperatorRewardDistributed(_consensusAddr, _bridgeOperator, _treasury, _amount);
return;
}
Expand Down