Tadle

Tadle
DeFiFoundry
27,750 USDC
View results
Submission Details
Severity: low
Invalid

`TadleFactory::guardian` State Variable Should Be Declared as Immutable

## Summary
The `guardian` state variable in the `TadleFactory` contract is assigned during contract construction and is not intended to change. Declaring this variable as `immutable` can save gas and reinforce its immutability, ensuring that the `guardian` address remains constant throughout the contract's lifecycle.
## Vulnerability Details
### Description
The `guardian` state variable is assigned a value in the constructor and remains unchanged afterward. Declaring it as `immutable` offers two benefits:
1. **Gas Optimization**: The `immutable` keyword allows the variable to be stored directly in the contract’s code, which reduces the gas cost associated with accessing this variable.
2. **Enforcing Immutability**: Declaring the variable as `immutable` makes it clear that this value will not change after the initial assignment, enhancing the security and clarity of the contract.
### Code Snippet
Current implementation:
```solidity
address internal guardian;
constructor(address _guardian) {
guardian = _guardian;
}
```
Recommended update:
```solidity
address internal immutable guardian;
constructor(address _guardian) {
guardian = _guardian;
}
```
### Slither Analysis
Slither, a static analysis tool, flagged the `guardian` variable as a candidate for the `immutable` keyword since it is assigned in the constructor and is not modified thereafter.
## Impact
- **Gas Optimization**: Declaring `guardian` as `immutable` will slightly reduce the gas costs when accessing this variable.
- **Security and Readability**: Using `immutable` signals the intent that the `guardian` address is meant to remain constant, reducing the risk of errors or misunderstandings in future contract modifications.
## Tools Used
- **Slither**: Identified the opportunity to declare the `guardian` variable as `immutable`.
## Recommendations
Update the `guardian` state variable to be `immutable` for enhanced gas efficiency and to clearly indicate its immutability.
### Suggested Fix
```solidity
address internal immutable guardian;
constructor(address _guardian) {
guardian = _guardian;
}
```
## Severity
**Low**
The issue is classified as **low** severity because it does not pose a direct security threat. However, implementing the recommendation can optimize gas usage and reinforce best practices for code clarity and security.
Updates

Lead Judging Commences

0xnevi Lead Judge
about 1 year ago
0xnevi Lead Judge about 1 year ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.