-
Notifications
You must be signed in to change notification settings - Fork 1
feat: initial protocol manager interface + CredibleSafeGuard integration #95
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
Merged
makemake-kbo
merged 5 commits into
master
from
makemake/eng-4072-faetstd-add-initial-protocol-manager-interface-to-std
Jul 27, 2026
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
eda0f86
feat(credible-block): add initial protocol manager interface + abstra…
makemake-kbo 03fdf50
feat(safe): expose initial protocol manager on CredibleSafeGuard
makemake-kbo 5f2507d
test(safe): cover CredibleSafeGuard's initial protocol manager
makemake-kbo 39f0797
style(safe): satisfy forge fmt on guard constructor
makemake-kbo 2056aa1
refactor(credible-block): move initial protocol manager to promised path
makemake-kbo 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
Some comments aren't visible on the classic Files Changed page.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| // SPDX-License-Identifier: MIT | ||
| pragma solidity ^0.8.13; | ||
|
|
||
| /// @title IInitialProtocolManager | ||
| /// @author Phylax Systems | ||
| /// @notice Interface a protected contract exposes to declare the address allowed to manage its | ||
| /// assertions in the Credible Layer. Every protected contract needs a protocol manager; | ||
| /// exposing the intended manager on the contract itself lets the state oracle set it | ||
| /// without a manual review round. | ||
| /// @dev The state oracle calls {initialProtocolManager} on the contract when the protocol is | ||
| /// initialized in the Credible Layer and registers the returned address as the manager. | ||
| /// Because the value is defined by the contract's own code, deploying the contract is the | ||
| /// ownership proof: whoever controlled the deployment chose the manager. This is what makes | ||
| /// updated or redeployed contracts self-verifying, with no separate claim step. | ||
| /// | ||
| /// Implementing this interface is optional. Contracts that do not expose it (for example, | ||
| /// already-deployed contracts that cannot be changed) go through manual verification, where | ||
| /// Phylax confirms ownership directly and sets the manager. | ||
| interface IInitialProtocolManager { | ||
|
makemake-kbo marked this conversation as resolved.
|
||
| /// @notice The address to set as this contract's protocol manager when the protocol is | ||
| /// initialized in the Credible Layer. | ||
| /// @return The intended initial protocol manager address. | ||
| function initialProtocolManager() external view returns (address); | ||
| } | ||
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,37 @@ | ||
| // SPDX-License-Identifier: MIT | ||
| pragma solidity ^0.8.13; | ||
|
|
||
| import {IInitialProtocolManager} from "./IInitialProtocolManager.sol"; | ||
|
|
||
| /// @title InitialProtocolManager | ||
| /// @author Phylax Systems | ||
| /// @notice Reusable base that implements {IInitialProtocolManager} by fixing the intended manager | ||
| /// at deployment. Inherit it and forward the manager address to the constructor; the | ||
| /// public immutable satisfies the interface's {initialProtocolManager} getter. | ||
| /// @dev The manager is immutable, so the value the state oracle reads is exactly what the deployer | ||
| /// committed to in the deployment transaction — that is the ownership proof. Changing the | ||
| /// declared manager after deployment means redeploying the inheriting contract. Once the | ||
| /// protocol is initialized in the Credible Layer, the manager is managed there rather than | ||
| /// through this value. | ||
| /// | ||
| /// Example: | ||
| /// ```solidity | ||
| /// contract MyProtectedContract is InitialProtocolManager { | ||
| /// constructor(address manager) InitialProtocolManager(manager) {} | ||
| /// } | ||
| /// ``` | ||
| abstract contract InitialProtocolManager is IInitialProtocolManager { | ||
| /// @inheritdoc IInitialProtocolManager | ||
| address public immutable initialProtocolManager; | ||
|
|
||
| /// @notice Thrown when constructed with the zero address as the initial protocol manager. | ||
| error ZeroInitialProtocolManager(); | ||
|
|
||
| /// @param initialProtocolManager_ The address to declare as this contract's initial protocol | ||
| /// manager. Must be non-zero. | ||
| constructor(address initialProtocolManager_) { | ||
| if (initialProtocolManager_ == address(0)) revert ZeroInitialProtocolManager(); | ||
|
|
||
| initialProtocolManager = initialProtocolManager_; | ||
| } | ||
| } |
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
53 changes: 53 additions & 0 deletions
53
test/protection/credible_block/InitialProtocolManager.t.sol
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,53 @@ | ||
| // SPDX-License-Identifier: MIT | ||
| pragma solidity ^0.8.13; | ||
|
|
||
| import {Test} from "forge-std/Test.sol"; | ||
|
|
||
| import {IInitialProtocolManager} from "../../../src/protection/credible_block/IInitialProtocolManager.sol"; | ||
| import {InitialProtocolManager} from "../../../src/protection/credible_block/InitialProtocolManager.sol"; | ||
|
|
||
| /// @notice Minimal concrete contract that inherits the abstract base by forwarding the manager | ||
| /// address to its constructor, mirroring the intended inherit-and-forward usage. | ||
| contract ProtectedContract is InitialProtocolManager { | ||
| constructor(address manager) InitialProtocolManager(manager) {} | ||
| } | ||
|
|
||
| contract InitialProtocolManagerTest is Test { | ||
| address internal constant MANAGER = address(0xA11CE); | ||
|
|
||
| ProtectedContract internal protectedContract; | ||
|
|
||
| function setUp() public { | ||
| protectedContract = new ProtectedContract(MANAGER); | ||
| } | ||
|
|
||
| // --------------------------------------------------------------------- | ||
| // Construction | ||
| // --------------------------------------------------------------------- | ||
|
|
||
| function test_constructor_storesManager() public view { | ||
| assertEq(protectedContract.initialProtocolManager(), MANAGER); | ||
| } | ||
|
|
||
| function test_constructor_revertsOnZeroManager() public { | ||
| vm.expectRevert(InitialProtocolManager.ZeroInitialProtocolManager.selector); | ||
| new ProtectedContract(address(0)); | ||
| } | ||
|
|
||
| function testFuzz_constructor_storesAnyNonZeroManager(address manager) public { | ||
| vm.assume(manager != address(0)); | ||
| ProtectedContract instance = new ProtectedContract(manager); | ||
| assertEq(instance.initialProtocolManager(), manager); | ||
| } | ||
|
|
||
| // --------------------------------------------------------------------- | ||
| // Interface conformance | ||
| // --------------------------------------------------------------------- | ||
|
|
||
| /// @dev The state oracle reads the manager through {IInitialProtocolManager}, so the public | ||
| /// immutable must satisfy that interface's getter when called through the interface type. | ||
| function test_conformsToInterface() public view { | ||
| IInitialProtocolManager asInterface = IInitialProtocolManager(address(protectedContract)); | ||
| assertEq(asInterface.initialProtocolManager(), MANAGER); | ||
| } | ||
| } |
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.