Skip to content

Commit

Permalink
adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
TilakMaddy committed Aug 19, 2024
1 parent 322cd25 commit b7bdfe4
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 154 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::collections::{BTreeMap, HashSet};
use std::error::Error;

use crate::ast::NodeID;
use crate::ast::{Mutability, NodeID};

use crate::capture;
use crate::detect::detector::IssueDetectorNamePool;
Expand Down Expand Up @@ -35,7 +35,7 @@ impl IssueDetector for StateVariableCouldBeConstantDetector {
}

let mut all_state_changes = None;
for func in helpers::get_implemented_external_and_public_functions(context) {
for func in context.function_definitions() {
if let Some(changes) = func.state_variable_changes(context) {
if all_state_changes.is_none() {
all_state_changes = Some(changes);
Expand All @@ -62,6 +62,9 @@ impl IssueDetector for StateVariableCouldBeConstantDetector {
&& !type_string.starts_with("contract")
})
}) {
if variable.mutability() == Some(&Mutability::Immutable) {
continue;
}
if !collection_b_ids.contains(&variable.id) {
capture!(self, context, variable);
}
Expand Down
68 changes: 1 addition & 67 deletions reports/ccip-functions-report.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ This report was generated by [Aderyn](https://github.com/Cyfrin/aderyn), a stati
- [L-11: Contract still has TODOs](#l-11-contract-still-has-todos)
- [L-12: Unused Custom Error](#l-12-unused-custom-error)
- [L-13: Loop contains `require`/`revert` statements](#l-13-loop-contains-requirerevert-statements)
- [L-14: State variable could be declared constant](#l-14-state-variable-could-be-declared-constant)


# Summary
Expand Down Expand Up @@ -102,7 +101,7 @@ This report was generated by [Aderyn](https://github.com/Cyfrin/aderyn), a stati
| Category | No. of Issues |
| --- | --- |
| High | 3 |
| Low | 14 |
| Low | 13 |


# High Issues
Expand Down Expand Up @@ -2451,68 +2450,3 @@ Avoid `require` / `revert` statements in a loop because a single bad item can ca



## L-14: State variable could be declared constant

State variables that are not updated following deployment should be declared constant to save gas. Add the `constant` attribute to state variables that never change.

<details><summary>9 Found Instances</summary>


- Found in src/v0.8/functions/dev/v1_X/example/FunctionsClientExample.sol [Line: 15](../tests/ccip-contracts/contracts/src/v0.8/functions/dev/v1_X/example/FunctionsClientExample.sol#L15)

```solidity
bytes32 public s_lastResponse;
```

- Found in src/v0.8/functions/dev/v1_X/example/FunctionsClientExample.sol [Line: 16](../tests/ccip-contracts/contracts/src/v0.8/functions/dev/v1_X/example/FunctionsClientExample.sol#L16)

```solidity
bytes32 public s_lastError;
```

- Found in src/v0.8/functions/dev/v1_X/example/FunctionsClientExample.sol [Line: 17](../tests/ccip-contracts/contracts/src/v0.8/functions/dev/v1_X/example/FunctionsClientExample.sol#L17)

```solidity
uint32 public s_lastResponseLength;
```

- Found in src/v0.8/functions/dev/v1_X/example/FunctionsClientExample.sol [Line: 18](../tests/ccip-contracts/contracts/src/v0.8/functions/dev/v1_X/example/FunctionsClientExample.sol#L18)

```solidity
uint32 public s_lastErrorLength;
```

- Found in src/v0.8/functions/v1_0_0/example/FunctionsClientExample.sol [Line: 15](../tests/ccip-contracts/contracts/src/v0.8/functions/v1_0_0/example/FunctionsClientExample.sol#L15)

```solidity
bytes32 public s_lastResponse;
```

- Found in src/v0.8/functions/v1_0_0/example/FunctionsClientExample.sol [Line: 16](../tests/ccip-contracts/contracts/src/v0.8/functions/v1_0_0/example/FunctionsClientExample.sol#L16)

```solidity
bytes32 public s_lastError;
```

- Found in src/v0.8/functions/v1_0_0/example/FunctionsClientExample.sol [Line: 17](../tests/ccip-contracts/contracts/src/v0.8/functions/v1_0_0/example/FunctionsClientExample.sol#L17)

```solidity
uint32 public s_lastResponseLength;
```

- Found in src/v0.8/functions/v1_0_0/example/FunctionsClientExample.sol [Line: 18](../tests/ccip-contracts/contracts/src/v0.8/functions/v1_0_0/example/FunctionsClientExample.sol#L18)

```solidity
uint32 public s_lastErrorLength;
```

- Found in src/v0.8/functions/v1_0_0/ocr/OCR2Base.sol [Line: 16](../tests/ccip-contracts/contracts/src/v0.8/functions/v1_0_0/ocr/OCR2Base.sol#L16)

```solidity
bool internal immutable i_uniqueReports;
```

</details>



12 changes: 0 additions & 12 deletions reports/report.json
Original file line number Diff line number Diff line change
Expand Up @@ -5064,18 +5064,6 @@
"src": "92:8",
"src_char": "92:8"
},
{
"contract_path": "src/CompilerBugStorageSignedIntegerArray.sol",
"line_no": 5,
"src": "109:23",
"src_char": "109:23"
},
{
"contract_path": "src/CompilerBugStorageSignedIntegerArray.sol",
"line_no": 6,
"src": "138:25",
"src_char": "138:25"
},
{
"contract_path": "src/ConstantFuncsAssembly.sol",
"line_no": 6,
Expand Down
14 changes: 1 addition & 13 deletions reports/report.md
Original file line number Diff line number Diff line change
Expand Up @@ -5145,7 +5145,7 @@ Name clashes with a built-in-symbol. Consider renaming it.

State variables that are not updated following deployment should be declared constant to save gas. Add the `constant` attribute to state variables that never change.

<details><summary>79 Found Instances</summary>
<details><summary>77 Found Instances</summary>


- Found in src/AssemblyExample.sol [Line: 5](../tests/contract-playground/src/AssemblyExample.sol#L5)
Expand All @@ -5160,18 +5160,6 @@ State variables that are not updated following deployment should be declared con
uint now; // BAD
```

- Found in src/CompilerBugStorageSignedIntegerArray.sol [Line: 5](../tests/contract-playground/src/CompilerBugStorageSignedIntegerArray.sol#L5)

```solidity
int256[3] affectedArray;
```

- Found in src/CompilerBugStorageSignedIntegerArray.sol [Line: 6](../tests/contract-playground/src/CompilerBugStorageSignedIntegerArray.sol#L6)

```solidity
int256[4] unaffectedArray;
```

- Found in src/ConstantFuncsAssembly.sol [Line: 6](../tests/contract-playground/src/ConstantFuncsAssembly.sol#L6)

```solidity
Expand Down
22 changes: 0 additions & 22 deletions reports/report.sarif
Original file line number Diff line number Diff line change
Expand Up @@ -8337,28 +8337,6 @@
}
}
},
{
"physicalLocation": {
"artifactLocation": {
"uri": "src/CompilerBugStorageSignedIntegerArray.sol"
},
"region": {
"byteLength": 23,
"byteOffset": 109
}
}
},
{
"physicalLocation": {
"artifactLocation": {
"uri": "src/CompilerBugStorageSignedIntegerArray.sol"
},
"region": {
"byteLength": 25,
"byteOffset": 138
}
}
},
{
"physicalLocation": {
"artifactLocation": {
Expand Down
20 changes: 1 addition & 19 deletions reports/sablier-aderyn-toml-nested-root.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ This report was generated by [Aderyn](https://github.com/Cyfrin/aderyn), a stati
- [L-5: PUSH0 is not supported by all chains](#l-5-push0-is-not-supported-by-all-chains)
- [L-6: Large literal values multiples of 10000 can be replaced with scientific notation](#l-6-large-literal-values-multiples-of-10000-can-be-replaced-with-scientific-notation)
- [L-7: Internal functions called only once can be inlined](#l-7-internal-functions-called-only-once-can-be-inlined)
- [L-8: State variable could be declared constant](#l-8-state-variable-could-be-declared-constant)


# Summary
Expand Down Expand Up @@ -60,7 +59,7 @@ This report was generated by [Aderyn](https://github.com/Cyfrin/aderyn), a stati
| Category | No. of Issues |
| --- | --- |
| High | 0 |
| Low | 8 |
| Low | 7 |


# Low Issues
Expand Down Expand Up @@ -586,20 +585,3 @@ Instead of separating the logic into a separate function, consider inlining the



## L-8: State variable could be declared constant

State variables that are not updated following deployment should be declared constant to save gas. Add the `constant` attribute to state variables that never change.

<details><summary>1 Found Instances</summary>


- Found in src/abstracts/NoDelegateCall.sol [Line: 10](../tests/2024-05-Sablier/v2-core/src/abstracts/NoDelegateCall.sol#L10)

```solidity
address private immutable ORIGINAL;
```

</details>



20 changes: 1 addition & 19 deletions reports/templegold-report.md
Original file line number Diff line number Diff line change
Expand Up @@ -8706,7 +8706,7 @@ If `x` is a boolean, there is no need to do `if(x == true)` or `if(x == false)`.

State variables that are not updated following deployment should be declared constant to save gas. Add the `constant` attribute to state variables that never change.

<details><summary>11 Found Instances</summary>
<details><summary>8 Found Instances</summary>


- Found in contracts/amm/TempleUniswapV2Pair.sol [Line: 29](../tests/2024-07-templegold/protocol/contracts/amm/TempleUniswapV2Pair.sol#L29)
Expand All @@ -8715,18 +8715,6 @@ State variables that are not updated following deployment should be declared con
uint public kLast; // reserve0 * reserve1, as of immediately after the most recent liquidity event
```

- Found in contracts/core/RebasingERC20.sol [Line: 18](../tests/2024-07-templegold/protocol/contracts/core/RebasingERC20.sol#L18)

```solidity
uint256 public totalShares;
```

- Found in contracts/core/Vault.sol [Line: 33](../tests/2024-07-templegold/protocol/contracts/core/Vault.sol#L33)

```solidity
bytes32 public immutable WITHDRAW_FOR_TYPEHASH = keccak256("withdrawFor(address owner,address sender,uint256 amount,uint256 deadline,uint256 nonce)");
```

- Found in contracts/fakes/templegold/TempleGoldStakingMock.sol [Line: 39](../tests/2024-07-templegold/protocol/contracts/fakes/templegold/TempleGoldStakingMock.sol#L39)

```solidity
Expand Down Expand Up @@ -8769,12 +8757,6 @@ State variables that are not updated following deployment should be declared con
uint256 public override lastUpdateTime;
```

- Found in contracts/v2/strategies/AbstractStrategy.sol [Line: 26](../tests/2024-07-templegold/protocol/contracts/v2/strategies/AbstractStrategy.sol#L26)

```solidity
string public override strategyName;
```

</details>


Expand Down

0 comments on commit b7bdfe4

Please sign in to comment.