<!-- canonical: https://0xsimao.com/findings/orange-reentrancy-guard-implemented-gas -->

# Reentrancy guard can be implemented with a uint256 to save gas

Low/Info · Three Sigma · Cross-chain bridge · 15th July, 2024

Finding 3S-OB-N07 of the Orange Bridge security review.

- Protocol: https://www.orangeweb3.com/
- Report: /reports/orange
- Source: https://cdn.sanity.io/files/qoqld077/production/686ad4e1d5035d69002f5f97e281e3c5a8b7ce00.pdf

---

### Description

Storing a uint256 instead of a bool saves gas as it is cheaper changing storage from non
null to non null value.

### Recommendation

Implement the guard with a uint256. [Here](https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/ReentrancyGuard.sol#L37-L38) is an example implementation from
OpenZeppelin.

### Status

Addressed in [#1cbaf62](https://github.com/orangecryptohq/orange-bridge-contract/commit/1cbaf621b5d1c7a374ce92fb3651e5e457d8291a).

---

Related findings:

- [ClampLib::mulDivDownInverse reverts on `target == type(uint256).max` before the overflow guard runs](https://0xsimao.com/findings/tenor-markets-reverts-overflow-guard-runs): Tenor Morpho Migrations
- [In glAVAX, checking that amount > 0 earlier can save some gas](https://0xsimao.com/findings/glacier-avax-checking-earlier-gas): Glacier
- [Storage variables should be cached whenever possible to save gas](https://0xsimao.com/findings/glacier-storage-cached-whenever-gas): Glacier
- [MapleLoan change the order of require to save on gas.](https://0xsimao.com/findings/maple-finance-iii-change-require-save-gas): Maple Finance
