You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, we recently have conducted a systematic study about Solidity event usage, evolution, and impact, and we are attempting to build a tool to improve the practice of Solidity event use based on our findings. We have tried our prototype tool on some of the most popular GitHub Solidity repositories, and for your repository, we find a potential optimization of gas consumption arisen from event use.
The point is that when we use emit operation to store the value of a certain variable, local memory type variable would be preferable to global storage type (state) variable if they hold the same value. The reason is that an extra SLOAD operation would be needed to access the variable if it is storage type, and the SLOAD operation costs 800 gas.
For your repository, we find that the following event use can be improved:
sOlympusERC20.sol function name:initialize event name:TransferLogStakingContractUpdated variable:stakingContract->_stakingContract
function name:pushGovernor event name:GovernorPushed variable:newGovernor->_newGovernor
function pushGovernor(address_newGovernor, bool_effectiveImmediately) external onlyGovernor {
if (_effectiveImmediately) governor = _newGovernor;
newGovernor = _newGovernor;
emitGovernorPushed(governor, newGovernor, _effectiveImmediately);
}
function name:pushGuardian event name:GuardianPushed variable:newGuardian->_newGuardian
function pushGuardian(address_newGuardian, bool_effectiveImmediately) external onlyGovernor {
if (_effectiveImmediately) guardian = _newGuardian;
newGuardian = _newGuardian;
emitGuardianPushed(guardian, newGuardian, _effectiveImmediately);
}
function name:pushPolicy event name:PolicyPushed variable:newPolicy->_newPolicy
function pushPolicy(address_newPolicy, bool_effectiveImmediately) external onlyGovernor {
if (_effectiveImmediately) policy = _newPolicy;
newPolicy = _newPolicy;
emitPolicyPushed(policy, newPolicy, _effectiveImmediately);
}
function name:pushVault event name:VaultPushed variable:newVault->_newVault
function pushVault(address_newVault, bool_effectiveImmediately) external onlyGovernor {
if (_effectiveImmediately) vault = _newVault;
newVault = _newVault;
emitVaultPushed(vault, newVault, _effectiveImmediately);
}
Timelock.sol function name:setDelay event name:NewDelay variable:delay->delay_
function setDelay(uint256delay_) public {
require(msg.sender==address(this), "Timelock::setDelay: Call must come from Timelock.");
require(delay_ >= MINIMUM_DELAY, "Timelock::setDelay: Delay must exceed minimum delay.");
require(delay_ <= MAXIMUM_DELAY, "Timelock::setDelay: Delay must not exceed maximum delay.");
delay = delay_;
emitNewDelay(delay);
}
function name:setPendingAdmin event name:NewPendingAdmin variable:pendingAdmin->pendingAdmin_
function setPendingAdmin(addresspendingAdmin_) public {
require(msg.sender==address(this), "Timelock::setPendingAdmin: Call must come from Timelock.");
pendingAdmin = pendingAdmin_;
emitNewPendingAdmin(pendingAdmin);
}
Do you find our results useful? Your reply and invaluable suggestions would be greatly appreciated, and are vital for improving our tool. Thanks a lot for your time!
The text was updated successfully, but these errors were encountered:
Hi, we recently have conducted a systematic study about Solidity event usage, evolution, and impact, and we are attempting to build a tool to improve the practice of Solidity event use based on our findings. We have tried our prototype tool on some of the most popular GitHub Solidity repositories, and for your repository, we find a potential optimization of gas consumption arisen from event use.
The point is that when we use emit operation to store the value of a certain variable, local memory type variable would be preferable to global storage type (state) variable if they hold the same value. The reason is that an extra SLOAD operation would be needed to access the variable if it is storage type, and the SLOAD operation costs 800 gas.
For your repository, we find that the following event use can be improved:
function name: initialize
event name: Transfer LogStakingContractUpdated
variable: stakingContract->_stakingContract
function name: constructor
event name: GovernorPushed GuardianPushed PolicyPushed VaultPushed
variable: governor->_governor guardian->_guardian policy->_policy vault->_vault
function name: pushGovernor
event name: GovernorPushed
variable: newGovernor->_newGovernor
function name: pushGuardian
event name: GuardianPushed
variable: newGuardian->_newGuardian
function name: pushPolicy
event name: PolicyPushed
variable: newPolicy->_newPolicy
function name: pushVault
event name: VaultPushed
variable: newVault->_newVault
function name: setDelay
event name: NewDelay
variable: delay->delay_
function name: setPendingAdmin
event name: NewPendingAdmin
variable: pendingAdmin->pendingAdmin_
Do you find our results useful? Your reply and invaluable suggestions would be greatly appreciated, and are vital for improving our tool. Thanks a lot for your time!
The text was updated successfully, but these errors were encountered: