-
Notifications
You must be signed in to change notification settings - Fork 1
Audit cyfrin #155
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
gonzaloetjo
wants to merge
32
commits into
main
Choose a base branch
from
audit-cyfrin
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Audit cyfrin #155
Changes from 6 commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
6b7f870
fix(vaultTokenized.sol): M-01
gonzaloetjo 1dfeec0
fix(vaultTokenized.sol): M-02
gonzaloetjo d3f98b8
fix(vaultFactory.sol): H-01
gonzaloetjo 292d5b7
fix(delegatorFactory.sol): H-02
gonzaloetjo d198969
fix(Checkpoints.sol): M-03
gonzaloetjo ee2bdd5
fix(AvalancheL1Middleware.sol): C-01
gonzaloetjo 32b1a6c
fix(AvalancheL1Middleware.sol): C-02
gonzaloetjo 2a88616
fix(AvalancheL1Middleware.sol): H-04
gonzaloetjo 35f6e56
fix(AvalancheL1Middleware.sol): M-04
gonzaloetjo f0a6a49
fix(AvalancheL1Middleware.sol): M-05
gonzaloetjo 91ae0e3
fix(AvalancheL1Middleware.sol): M-06
gonzaloetjo 98bd130
fix(vaultTokenized.sol): M-07
gonzaloetjo 8f4adaa
fix(Rewards.sol): H-06
gonzaloetjo 9bbbcfc
fix(AvalancheL1Middleware.sol): H-07
gonzaloetjo 001cf04
fix(Rewards.sol): H-08
gonzaloetjo 43e09e6
fix(Rewards.sol): H-09
gonzaloetjo 9ac7bf0
fix(Rewards.sol): H-10
gonzaloetjo 5157351
fix(AvalancheL1Middleware): H-03 (H-06)
gonzaloetjo dc63daa
fix(AvalancheL1Middleware): M08 (M12)
gonzaloetjo ccd5e7d
fix(AvalancheL1Middleware): M09 (M14)
gonzaloetjo a5c4913
fix(Rewards.sol): M10 (M15)
gonzaloetjo 6a0cbb1
fix(Rewards.sol): H04
gonzaloetjo f9bfdf7
fix(Rewards.sol): H07
gonzaloetjo f76d1f4
fix(Rewards.sol): M11 (M16)
gonzaloetjo 6c37d1c
fix(Rewards.sol): M12 (M17)
gonzaloetjo 71e9093
fix(Rewards.sol): M06
gonzaloetjo b94d488
fix(MiddlewareVaultManager.sol): M07
gonzaloetjo 4c9231a
fix(AvalancheMiddleware.sol): M18
gonzaloetjo d4d2df7
fix(AvalancheMiddleware.sol): M19
gonzaloetjo e0b64e0
fix: comments @leopaul36
gonzaloetjo 0e0d4ae
fix(AvalancheMiddleware.sol): L07
gonzaloetjo b38dfed
fix(AvalancheMiddleware.sol): L10
gonzaloetjo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
// SPDX-License-Identifier: MIT | ||
// SPDX-FileCopyrightText: Copyright 2024 ADDPHO | ||
|
||
pragma solidity 0.8.25; | ||
|
||
import {Test, console2} from "forge-std/Test.sol"; | ||
import {DelegatorFactory} from "../src/contracts/DelegatorFactory.sol"; | ||
import {IDelegatorFactory} from "../src/interfaces/IDelegatorFactory.sol"; | ||
import {Strings} from "@openzeppelin/contracts/utils/Strings.sol"; | ||
import {IEntity} from "../src/interfaces/common/IEntity.sol"; | ||
import {ERC165} from "@openzeppelin/contracts/utils/introspection/ERC165.sol"; | ||
import "@openzeppelin/contracts/utils/introspection/IERC165.sol"; | ||
|
||
contract DelegatorFactoryTest is Test { | ||
address owner; | ||
address operator1; | ||
address operator2; | ||
|
||
DelegatorFactory factory; | ||
MockEntity mockImpl; | ||
|
||
function setUp() public { | ||
owner = address(this); | ||
operator1 = makeAddr("operator1"); | ||
operator2 = makeAddr("operator2"); | ||
|
||
factory = new DelegatorFactory(owner); | ||
|
||
// Deploy a mock implementation that conforms to IEntity | ||
mockImpl = new MockEntity(address(factory), 0); | ||
|
||
// Whitelist the implementation | ||
factory.whitelist(address(mockImpl)); | ||
} | ||
|
||
function testCreateBeforeBlacklist() public { | ||
bytes memory initData = abi.encode("test"); | ||
|
||
address created = factory.create(0, initData); | ||
|
||
assertTrue(factory.isEntity(created), "Entity should be created and registered"); | ||
} | ||
|
||
// function testCreateFailsAfterBlacklist() public { | ||
// bytes memory initData = abi.encode("test"); | ||
|
||
// factory.blacklist(0); | ||
|
||
// factory.create(0, initData); //@note no revert although blacklisted | ||
// } | ||
|
||
function testCreateFailsAfterBlacklistFix() public { | ||
bytes memory initData = abi.encode("test"); | ||
|
||
factory.blacklist(0); | ||
|
||
vm.expectRevert(abi.encodeWithSignature("DelegatorFactory__VersionBlacklisted()")); | ||
factory.create(0, initData); | ||
} | ||
} | ||
|
||
|
||
contract MockEntity is IEntity, ERC165 { | ||
address public immutable FACTORY; | ||
uint64 public immutable TYPE; | ||
|
||
string public data; | ||
|
||
constructor(address factory_, uint64 type_) { | ||
FACTORY = factory_; | ||
TYPE = type_; | ||
} | ||
|
||
function initialize( | ||
bytes calldata initData | ||
) external { | ||
data = abi.decode(initData, (string)); | ||
} | ||
|
||
function supportsInterface( | ||
bytes4 interfaceId | ||
) public view virtual override(ERC165, IERC165) returns (bool) { | ||
return interfaceId == type(IEntity).interfaceId || super.supportsInterface(interfaceId); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.