-
Notifications
You must be signed in to change notification settings - Fork 184
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
chore: move governance out of core #8823
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. Join @LHerskind and the rest of your teammates on Graphite |
52bfd34
to
bbdfe90
Compare
Changes to public function bytecode sizes
🧾 Summary (100% most significant diffs)
Full diff report 👇
|
Docs PreviewHey there! 👋 You can check your preview at https://66f6dafe3c30e087373391f3--aztec-docs-dev.netlify.app |
bbdfe90
to
28da2a1
Compare
Bulloak installation should be added to ./bootstrap.sh |
@@ -32,8 +31,8 @@ contract Registry is IRegistry, Ownable { | |||
* @notice Returns the rollup contract | |||
* @return The rollup contract (of type IRollup) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return type here out of date
/** | ||
* @title Data Structures Library | ||
* @author Aztec Labs | ||
* @notice Library that contains data structures used throughout the Aztec protocol |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @notice Library that contains data structures used throughout the Aztec protocol | |
* @notice Library that contains data structures used throughout Aztec governance |
28da2a1
to
96a1938
Compare
Not adding it to the bootstrap as it is mainly something useful for us when building. Checking in ci would require bulloak which make them need cargo as well so seems like a bunch of extra things to download for something most other won't know of or need. Added a readme with information though so we can use it. |
Slight extension on #8818 to separate gov and instance more clearly. Gov does not have dependencies on core, but core can depend on the gov. Removes the registry value from the `Rollup` does not address that an upgrade would make the fee contract unbacked, that is to be handled separately in #8756. Updates testing for the `Registry` contract to use the [Branching Tree Technique](https://www.youtube.com/watch?v=0-EmbNVgFA4) from Paul. Found it quite neat. If using `bulloak` as well quite convenient to build the setups. The TL;DR is, build a `.tree` file outlining the test for a function, and then use `bulloak scaffold` to prepare a testing file and then fill in the logic. Makes it quite nice to follow the logic. # Example time ```.tree UpgradeTest ├── when caller is not owner │ └── it should revert └── when caller is owner ├── when rollup already in set │ └── it should revert └── when rollup not already in set ├── it should add the rollup to state └── it should emit a {InstanceAdded} event ``` ```solidity // SPDX-License-Identifier: UNLICENSED pragma solidity >=0.8.27; import {Test} from "forge-std/Test.sol"; import {Registry} from "@aztec/governance/Registry.sol"; contract RegistryBase is Test { Registry internal registry; function setUp() public { registry = new Registry(address(this)); } } ``` ```solidity // SPDX-License-Identifier: UNLICENSED pragma solidity >=0.8.27; import {RegistryBase} from "./Base.t.sol"; import {Ownable} from "@oz/access/Ownable.sol"; import {IRegistry} from "@aztec/governance/interfaces/IRegistry.sol"; import {Errors} from "@aztec/governance/libraries/Errors.sol"; import {DataStructures} from "@aztec/governance/libraries/DataStructures.sol"; contract UpgradeTest is RegistryBase { function test_RevertWhen_CallerIsNotOwner(address _caller) external { // it should revert vm.assume(_caller != address(this)); vm.prank(_caller); vm.expectRevert(abi.encodeWithSelector(Ownable.OwnableUnauthorizedAccount.selector, _caller)); registry.upgrade(address(uint160(uint256(bytes32("new instance"))))); } modifier whenCallerIsOwner() { _; } function test_RevertWhen_RollupAlreadyInSet() external whenCallerIsOwner { // it should revert address rollup = registry.getRollup(); vm.expectRevert( abi.encodeWithSelector(Errors.Registry__RollupAlreadyRegistered.selector, rollup) ); registry.upgrade(rollup); } function test_WhenRollupNotAlreadyInSet(address _rollup) external whenCallerIsOwner { // it should add the rollup to state // it should emit a {InstanceAdded} event vm.assume(_rollup != address(0xdead)); { DataStructures.RegistrySnapshot memory snapshotBefore = registry.getCurrentSnapshot(); assertEq(snapshotBefore.blockNumber, block.number); assertEq(snapshotBefore.rollup, address(0xdead)); assertEq(registry.numberOfVersions(), 1); } vm.expectEmit(true, true, false, false, address(registry)); emit IRegistry.InstanceAdded(_rollup, 1); registry.upgrade(_rollup); assertEq(registry.numberOfVersions(), 2); DataStructures.RegistrySnapshot memory snapshot = registry.getCurrentSnapshot(); assertEq(snapshot.blockNumber, block.number); assertGt(snapshot.blockNumber, 0); assertEq(snapshot.rollup, _rollup); } } ```
Slight extension on #8818 to separate gov and instance more clearly. Gov does not have dependencies on core, but core can depend on the gov. Removes the registry value from the `Rollup` does not address that an upgrade would make the fee contract unbacked, that is to be handled separately in #8756. Updates testing for the `Registry` contract to use the [Branching Tree Technique](https://www.youtube.com/watch?v=0-EmbNVgFA4) from Paul. Found it quite neat. If using `bulloak` as well quite convenient to build the setups. The TL;DR is, build a `.tree` file outlining the test for a function, and then use `bulloak scaffold` to prepare a testing file and then fill in the logic. Makes it quite nice to follow the logic. # Example time ```.tree UpgradeTest ├── when caller is not owner │ └── it should revert └── when caller is owner ├── when rollup already in set │ └── it should revert └── when rollup not already in set ├── it should add the rollup to state └── it should emit a {InstanceAdded} event ``` ```solidity // SPDX-License-Identifier: UNLICENSED pragma solidity >=0.8.27; import {Test} from "forge-std/Test.sol"; import {Registry} from "@aztec/governance/Registry.sol"; contract RegistryBase is Test { Registry internal registry; function setUp() public { registry = new Registry(address(this)); } } ``` ```solidity // SPDX-License-Identifier: UNLICENSED pragma solidity >=0.8.27; import {RegistryBase} from "./Base.t.sol"; import {Ownable} from "@oz/access/Ownable.sol"; import {IRegistry} from "@aztec/governance/interfaces/IRegistry.sol"; import {Errors} from "@aztec/governance/libraries/Errors.sol"; import {DataStructures} from "@aztec/governance/libraries/DataStructures.sol"; contract UpgradeTest is RegistryBase { function test_RevertWhen_CallerIsNotOwner(address _caller) external { // it should revert vm.assume(_caller != address(this)); vm.prank(_caller); vm.expectRevert(abi.encodeWithSelector(Ownable.OwnableUnauthorizedAccount.selector, _caller)); registry.upgrade(address(uint160(uint256(bytes32("new instance"))))); } modifier whenCallerIsOwner() { _; } function test_RevertWhen_RollupAlreadyInSet() external whenCallerIsOwner { // it should revert address rollup = registry.getRollup(); vm.expectRevert( abi.encodeWithSelector(Errors.Registry__RollupAlreadyRegistered.selector, rollup) ); registry.upgrade(rollup); } function test_WhenRollupNotAlreadyInSet(address _rollup) external whenCallerIsOwner { // it should add the rollup to state // it should emit a {InstanceAdded} event vm.assume(_rollup != address(0xdead)); { DataStructures.RegistrySnapshot memory snapshotBefore = registry.getCurrentSnapshot(); assertEq(snapshotBefore.blockNumber, block.number); assertEq(snapshotBefore.rollup, address(0xdead)); assertEq(registry.numberOfVersions(), 1); } vm.expectEmit(true, true, false, false, address(registry)); emit IRegistry.InstanceAdded(_rollup, 1); registry.upgrade(_rollup); assertEq(registry.numberOfVersions(), 2); DataStructures.RegistrySnapshot memory snapshot = registry.getCurrentSnapshot(); assertEq(snapshot.blockNumber, block.number); assertGt(snapshot.blockNumber, 0); assertEq(snapshot.rollup, _rollup); } } ```
Slight extension on #8818 to separate gov and instance more clearly.
Gov does not have dependencies on core, but core can depend on the gov.
Removes the registry value from the
Rollup
does not address that an upgrade would make the fee contract unbacked, that is to be handled separately in #8756.Updates testing for the
Registry
contract to use the Branching Tree Technique from Paul. Found it quite neat. If usingbulloak
as well quite convenient to build the setups.The TL;DR is, build a
.tree
file outlining the test for a function, and then usebulloak scaffold
to prepare a testing file and then fill in the logic. Makes it quite nice to follow the logic.Example time