code-423n4 / 2022-02-skale-findings

0 stars 0 forks source link

Gas Optimizations #61

Open code423n4 opened 2 years ago

code423n4 commented 2 years ago
  1. consider using ++i can save gas https://github.com/skalenetwork/ima-c4-audit/blob/main/contracts/MessageProxy.sol#L221 // gas cost 34321

change to:

 for (uint256 i = from; i < to; ++i) {

// gas cost 34271

Tools used: Remix

========================================================================

  1. using multipe require can save gas https://github.com/skalenetwork/ima-c4-audit/blob/main/contracts/MessageProxy.sol#L216 // gas cost 34324

Change to:

require( from < to );
require( to - from <= 10 );
require( to < schainHash,"Range is incorrect");

// gas cost 34305

========================================================================

yavrsky commented 2 years ago

Only marginal gas improvements.

GalloDaSballo commented 2 years ago

consider using ++i can save gas

Saves 3 gas per instance

using multipe require can save gas

Saves the gas from the && 3 gas

6 gas total