diff --git a/cspell.json b/cspell.json index 42e5efb87158..1e9853b9d548 100644 --- a/cspell.json +++ b/cspell.json @@ -6,7 +6,7 @@ "acvm", "addrs", "alphanet", - "Apella", + "Governance", "archiver", "assignement", "asyncify", @@ -102,7 +102,6 @@ "fullpath", "fuzzer", "fuzzers", - "Gerousia", "gitmodules", "gitrepo", "Gossipable", @@ -169,7 +168,6 @@ "nodebuffer", "noirc", "noirup", - "Nomismatokopio", "nullifer", "offchain", "onchain", @@ -250,7 +248,6 @@ "subrepo", "subroot", "suyash", - "Sysstia", "templating", "tldr", "toplevel", @@ -316,7 +313,5 @@ "lib", "*.cmake" ], - "flagWords": [ - "anonymous" - ] + "flagWords": ["anonymous"] } diff --git a/l1-contracts/.rebuild_patterns b/l1-contracts/.rebuild_patterns index e4678a467cc4..b13dbf67b617 100644 --- a/l1-contracts/.rebuild_patterns +++ b/l1-contracts/.rebuild_patterns @@ -1,2 +1,2 @@ ^l1-contracts/src/.*\.sol$ -^l1-contracts/test/governance/scenario/NewGerousiaPayload.sol$ \ No newline at end of file +^l1-contracts/test/governance/scenario/NewGovernanceProposerPayload.sol$ \ No newline at end of file diff --git a/l1-contracts/src/core/Rollup.sol b/l1-contracts/src/core/Rollup.sol index ea56a02b4293..17fc81737424 100644 --- a/l1-contracts/src/core/Rollup.sol +++ b/l1-contracts/src/core/Rollup.sol @@ -21,7 +21,7 @@ import {TxsDecoder} from "@aztec/core/libraries/TxsDecoder.sol"; import {Inbox} from "@aztec/core/messagebridge/Inbox.sol"; import {Outbox} from "@aztec/core/messagebridge/Outbox.sol"; import {ProofCommitmentEscrow} from "@aztec/core/ProofCommitmentEscrow.sol"; -import {ISysstia} from "@aztec/governance/interfaces/ISysstia.sol"; +import {IRewardDistributor} from "@aztec/governance/interfaces/IRewardDistributor.sol"; import {MockVerifier} from "@aztec/mock/MockVerifier.sol"; import {IERC20} from "@oz/token/ERC20/IERC20.sol"; import {SafeERC20} from "@oz/token/ERC20/utils/SafeERC20.sol"; @@ -64,7 +64,7 @@ contract Rollup is EIP712("Aztec Rollup", "1"), Leonidas, IRollup, ITestRollup { IProofCommitmentEscrow public immutable PROOF_COMMITMENT_ESCROW; uint256 public immutable VERSION; IFeeJuicePortal public immutable FEE_JUICE_PORTAL; - ISysstia public immutable SYSSTIA; + IRewardDistributor public immutable REWARD_DISTRIBUTOR; IERC20 public immutable ASSET; IVerifier public epochProofVerifier; @@ -87,7 +87,7 @@ contract Rollup is EIP712("Aztec Rollup", "1"), Leonidas, IRollup, ITestRollup { constructor( IFeeJuicePortal _fpcJuicePortal, - ISysstia _sysstia, + IRewardDistributor _rewardDistributor, bytes32 _vkTreeRoot, bytes32 _protocolContractTreeRoot, address _ares, @@ -95,7 +95,7 @@ contract Rollup is EIP712("Aztec Rollup", "1"), Leonidas, IRollup, ITestRollup { ) Leonidas(_ares) { epochProofVerifier = new MockVerifier(); FEE_JUICE_PORTAL = _fpcJuicePortal; - SYSSTIA = _sysstia; + REWARD_DISTRIBUTOR = _rewardDistributor; ASSET = _fpcJuicePortal.UNDERLYING(); PROOF_COMMITMENT_ESCROW = new ProofCommitmentEscrow(ASSET, address(this)); INBOX = IInbox(address(new Inbox(address(this), Constants.L1_TO_L2_MSG_SUBTREE_HEIGHT))); @@ -240,11 +240,11 @@ contract Rollup is EIP712("Aztec Rollup", "1"), Leonidas, IRollup, ITestRollup { // @note Only if the rollup is the canonical will it be able to meaningfully claim fees // Otherwise, the fees are unbacked #7938. bool isFeeCanonical = address(this) == FEE_JUICE_PORTAL.canonicalRollup(); - bool isSysstiaCanonical = address(this) == SYSSTIA.canonicalRollup(); + bool isRewardDistributorCanonical = address(this) == REWARD_DISTRIBUTOR.canonicalRollup(); uint256 totalProverReward = 0; - if (isFeeCanonical || isSysstiaCanonical) { + if (isFeeCanonical || isRewardDistributorCanonical) { for (uint256 i = 0; i < _epochSize; i++) { address coinbase = address(uint160(uint256(publicInputs[9 + i * 2]))); uint256 reward = 0; @@ -258,8 +258,8 @@ contract Rollup is EIP712("Aztec Rollup", "1"), Leonidas, IRollup, ITestRollup { } } - if (isSysstiaCanonical) { - reward += SYSSTIA.claim(address(this)); + if (isRewardDistributorCanonical) { + reward += REWARD_DISTRIBUTOR.claim(address(this)); } if (coinbase == address(0)) { @@ -498,7 +498,7 @@ contract Rollup is EIP712("Aztec Rollup", "1"), Leonidas, IRollup, ITestRollup { _fakeBlockNumberAsProven(blockNumber); bool isFeeCanonical = address(this) == FEE_JUICE_PORTAL.canonicalRollup(); - bool isSysstiaCanonical = address(this) == SYSSTIA.canonicalRollup(); + bool isRewardDistributorCanonical = address(this) == REWARD_DISTRIBUTOR.canonicalRollup(); if (isFeeCanonical && header.globalVariables.coinbase != address(0) && header.totalFees > 0) { // @note This will currently fail if there are insufficient funds in the bridge @@ -506,8 +506,8 @@ contract Rollup is EIP712("Aztec Rollup", "1"), Leonidas, IRollup, ITestRollup { // Consider allowing a failure. See #7938. FEE_JUICE_PORTAL.distributeFees(header.globalVariables.coinbase, header.totalFees); } - if (isSysstiaCanonical && header.globalVariables.coinbase != address(0)) { - SYSSTIA.claim(header.globalVariables.coinbase); + if (isRewardDistributorCanonical && header.globalVariables.coinbase != address(0)) { + REWARD_DISTRIBUTOR.claim(header.globalVariables.coinbase); } emit L2ProofVerified(blockNumber, "CHEAT"); diff --git a/l1-contracts/src/core/interfaces/IRollup.sol b/l1-contracts/src/core/interfaces/IRollup.sol index f730a160fb3f..cfb1f3100819 100644 --- a/l1-contracts/src/core/interfaces/IRollup.sol +++ b/l1-contracts/src/core/interfaces/IRollup.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: Apache-2.0 -// Copyright 2023 Aztec Labs. +// Copyright 2024 Aztec Labs. pragma solidity >=0.8.27; import {IInbox} from "@aztec/core/interfaces/messagebridge/IInbox.sol"; diff --git a/l1-contracts/src/core/interfaces/IVerifier.sol b/l1-contracts/src/core/interfaces/IVerifier.sol index ab412dc15009..45bf6acdcbc8 100644 --- a/l1-contracts/src/core/interfaces/IVerifier.sol +++ b/l1-contracts/src/core/interfaces/IVerifier.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: Apache-2.0 -// Copyright 2023 Aztec Labs. +// Copyright 2024 Aztec Labs. pragma solidity >=0.8.27; interface IVerifier { diff --git a/l1-contracts/src/core/interfaces/messagebridge/IInbox.sol b/l1-contracts/src/core/interfaces/messagebridge/IInbox.sol index 0bceddbc7e88..8c658a1264f2 100644 --- a/l1-contracts/src/core/interfaces/messagebridge/IInbox.sol +++ b/l1-contracts/src/core/interfaces/messagebridge/IInbox.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: Apache-2.0 -// Copyright 2023 Aztec Labs. +// Copyright 2024 Aztec Labs. pragma solidity >=0.8.27; import {DataStructures} from "../../libraries/DataStructures.sol"; diff --git a/l1-contracts/src/core/libraries/ConstantsGen.sol b/l1-contracts/src/core/libraries/ConstantsGen.sol index a6ff8b3458ba..1862d81b6b65 100644 --- a/l1-contracts/src/core/libraries/ConstantsGen.sol +++ b/l1-contracts/src/core/libraries/ConstantsGen.sol @@ -1,6 +1,6 @@ // GENERATED FILE - DO NOT EDIT, RUN yarn remake-constants in circuits.js // SPDX-License-Identifier: Apache-2.0 -// Copyright 2023 Aztec Labs. +// Copyright 2024 Aztec Labs. pragma solidity >=0.8.27; /** diff --git a/l1-contracts/src/core/libraries/Errors.sol b/l1-contracts/src/core/libraries/Errors.sol index 886214e45a1e..6e8454bfe33a 100644 --- a/l1-contracts/src/core/libraries/Errors.sol +++ b/l1-contracts/src/core/libraries/Errors.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: Apache-2.0 -// Copyright 2023 Aztec Labs. +// Copyright 2024 Aztec Labs. pragma solidity >=0.8.27; import {Timestamp, Slot, Epoch} from "@aztec/core/libraries/TimeMath.sol"; diff --git a/l1-contracts/src/core/libraries/HeaderLib.sol b/l1-contracts/src/core/libraries/HeaderLib.sol index fa5aff3033a0..4f29c4310392 100644 --- a/l1-contracts/src/core/libraries/HeaderLib.sol +++ b/l1-contracts/src/core/libraries/HeaderLib.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: Apache-2.0 -// Copyright 2023 Aztec Labs. +// Copyright 2024 Aztec Labs. pragma solidity >=0.8.27; import {Constants} from "@aztec/core/libraries/ConstantsGen.sol"; diff --git a/l1-contracts/src/core/libraries/TxsDecoder.sol b/l1-contracts/src/core/libraries/TxsDecoder.sol index e58dd5fe06bc..287491a8ec59 100644 --- a/l1-contracts/src/core/libraries/TxsDecoder.sol +++ b/l1-contracts/src/core/libraries/TxsDecoder.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: Apache-2.0 -// Copyright 2023 Aztec Labs. +// Copyright 2024 Aztec Labs. pragma solidity >=0.8.27; import {Constants} from "@aztec/core/libraries/ConstantsGen.sol"; diff --git a/l1-contracts/src/core/libraries/crypto/FrontierLib.sol b/l1-contracts/src/core/libraries/crypto/FrontierLib.sol index e907ec74b5dc..2b3ee24a4f3c 100644 --- a/l1-contracts/src/core/libraries/crypto/FrontierLib.sol +++ b/l1-contracts/src/core/libraries/crypto/FrontierLib.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: Apache-2.0 -// Copyright 2023 Aztec Labs. +// Copyright 2024 Aztec Labs. pragma solidity >=0.8.27; import {Hash} from "@aztec/core/libraries/crypto/Hash.sol"; diff --git a/l1-contracts/src/core/libraries/crypto/Hash.sol b/l1-contracts/src/core/libraries/crypto/Hash.sol index 766df2b08e0f..3c48e2f7285d 100644 --- a/l1-contracts/src/core/libraries/crypto/Hash.sol +++ b/l1-contracts/src/core/libraries/crypto/Hash.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: Apache-2.0 -// Copyright 2023 Aztec Labs. +// Copyright 2024 Aztec Labs. pragma solidity >=0.8.27; import {DataStructures} from "@aztec/core/libraries/DataStructures.sol"; diff --git a/l1-contracts/src/core/messagebridge/Inbox.sol b/l1-contracts/src/core/messagebridge/Inbox.sol index ade184eda553..4ad20884cef0 100644 --- a/l1-contracts/src/core/messagebridge/Inbox.sol +++ b/l1-contracts/src/core/messagebridge/Inbox.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: Apache-2.0 -// Copyright 2023 Aztec Labs. +// Copyright 2024 Aztec Labs. pragma solidity >=0.8.27; import {IInbox} from "@aztec/core/interfaces/messagebridge/IInbox.sol"; diff --git a/l1-contracts/src/governance/Nomismatokopio.sol b/l1-contracts/src/governance/CoinIssuer.sol similarity index 71% rename from l1-contracts/src/governance/Nomismatokopio.sol rename to l1-contracts/src/governance/CoinIssuer.sol index ab5543b92f85..37ac8f18b4df 100644 --- a/l1-contracts/src/governance/Nomismatokopio.sol +++ b/l1-contracts/src/governance/CoinIssuer.sol @@ -1,13 +1,18 @@ // SPDX-License-Identifier: Apache-2.0 -// Copyright 2023 Aztec Labs. +// Copyright 2024 Aztec Labs. pragma solidity >=0.8.27; +import {ICoinIssuer} from "@aztec/governance/interfaces/ICoinIssuer.sol"; import {IMintableERC20} from "@aztec/governance/interfaces/IMintableERC20.sol"; -import {INomismatokopio} from "@aztec/governance/interfaces/INomismatokopio.sol"; import {Errors} from "@aztec/governance/libraries/Errors.sol"; import {Ownable} from "@oz/access/Ownable.sol"; -contract Nomismatokopio is INomismatokopio, Ownable { +/** + * @title CoinIssuer + * @author Aztec Labs + * @notice A contract that allows minting of coins at a maximum fixed rate + */ +contract CoinIssuer is ICoinIssuer, Ownable { IMintableERC20 public immutable ASSET; uint256 public immutable RATE; uint256 public timeOfLastMint; @@ -26,9 +31,9 @@ contract Nomismatokopio is INomismatokopio, Ownable { * @param _to - The address to receive the funds * @param _amount - The amount to mint */ - function mint(address _to, uint256 _amount) external override(INomismatokopio) onlyOwner { + function mint(address _to, uint256 _amount) external override(ICoinIssuer) onlyOwner { uint256 maxMint = mintAvailable(); - require(_amount <= maxMint, Errors.Nomismatokopio__InssuficientMintAvailable(maxMint, _amount)); + require(_amount <= maxMint, Errors.CoinIssuer__InssuficientMintAvailable(maxMint, _amount)); timeOfLastMint = block.timestamp; ASSET.mint(_to, _amount); } @@ -38,7 +43,7 @@ contract Nomismatokopio is INomismatokopio, Ownable { * * @return The amount mintable */ - function mintAvailable() public view override(INomismatokopio) returns (uint256) { + function mintAvailable() public view override(ICoinIssuer) returns (uint256) { return RATE * (block.timestamp - timeOfLastMint); } } diff --git a/l1-contracts/src/governance/Apella.sol b/l1-contracts/src/governance/Governance.sol similarity index 70% rename from l1-contracts/src/governance/Apella.sol rename to l1-contracts/src/governance/Governance.sol index 658ad2348c79..93c914f4141d 100644 --- a/l1-contracts/src/governance/Apella.sol +++ b/l1-contracts/src/governance/Governance.sol @@ -1,8 +1,9 @@ -// SPDX-License-Identifier: UNLICENSED +// SPDX-License-Identifier: Apache-2.0 +// Copyright 2024 Aztec Labs. pragma solidity >=0.8.27; import {Timestamp} from "@aztec/core/libraries/TimeMath.sol"; -import {IApella} from "@aztec/governance/interfaces/IApella.sol"; +import {IGovernance} from "@aztec/governance/interfaces/IGovernance.sol"; import {IPayload} from "@aztec/governance/interfaces/IPayload.sol"; import {ConfigurationLib} from "@aztec/governance/libraries/ConfigurationLib.sol"; import {DataStructures} from "@aztec/governance/libraries/DataStructures.sol"; @@ -12,7 +13,16 @@ import {UserLib} from "@aztec/governance/libraries/UserLib.sol"; import {IERC20} from "@oz/token/ERC20/IERC20.sol"; import {SafeERC20} from "@oz/token/ERC20/utils/SafeERC20.sol"; -contract Apella is IApella { +/** + * @title Governance + * @author Aztec Labs + * @notice A contract that implements the governance logic, including proposal creation, voting, and execution + * A proposal is a payload which returns a list of actions to be executed by the governance, excluding + * calls to the governance token itself. + * The model is snapshot based and it is possible to make "partial" votes, using a fraction of one's power, + * making it simpler to build "aggregated" voting, for example for privately voting from inside the rollup. + */ +contract Governance is IGovernance { using SafeERC20 for IERC20; using ProposalLib for DataStructures.Proposal; using UserLib for DataStructures.User; @@ -20,7 +30,7 @@ contract Apella is IApella { IERC20 public immutable ASSET; - address public gerousia; + address public governanceProposer; mapping(uint256 proposalId => DataStructures.Proposal) internal proposals; mapping(uint256 proposalId => mapping(address user => DataStructures.Ballot)) public ballots; @@ -32,9 +42,9 @@ contract Apella is IApella { uint256 public proposalCount; uint256 public withdrawalCount; - constructor(IERC20 _asset, address _gerousia) { + constructor(IERC20 _asset, address _governanceProposer) { ASSET = _asset; - gerousia = _gerousia; + governanceProposer = _governanceProposer; configuration = DataStructures.Configuration({ proposeConfig: DataStructures.ProposeConfiguration({ @@ -52,17 +62,21 @@ contract Apella is IApella { configuration.assertValid(); } - function updateGerousia(address _gerousia) external override(IApella) { - require(msg.sender == address(this), Errors.Apella__CallerNotSelf(msg.sender, address(this))); - gerousia = _gerousia; - emit GerousiaUpdated(_gerousia); + function updateGovernanceProposer(address _governanceProposer) external override(IGovernance) { + require( + msg.sender == address(this), Errors.Governance__CallerNotSelf(msg.sender, address(this)) + ); + governanceProposer = _governanceProposer; + emit GovernanceProposerUpdated(_governanceProposer); } function updateConfiguration(DataStructures.Configuration memory _configuration) external - override(IApella) + override(IGovernance) { - require(msg.sender == address(this), Errors.Apella__CallerNotSelf(msg.sender, address(this))); + require( + msg.sender == address(this), Errors.Governance__CallerNotSelf(msg.sender, address(this)) + ); // This following MUST revert if the configuration is invalid _configuration.assertValid(); @@ -72,7 +86,7 @@ contract Apella is IApella { emit ConfigurationUpdated(Timestamp.wrap(block.timestamp)); } - function deposit(address _onBehalfOf, uint256 _amount) external override(IApella) { + function deposit(address _onBehalfOf, uint256 _amount) external override(IGovernance) { ASSET.safeTransferFrom(msg.sender, address(this), _amount); users[_onBehalfOf].add(_amount); total.add(_amount); @@ -82,18 +96,20 @@ contract Apella is IApella { function initiateWithdraw(address _to, uint256 _amount) external - override(IApella) + override(IGovernance) returns (uint256) { return _initiateWithdraw(_to, _amount, configuration.withdrawalDelay()); } - function finaliseWithdraw(uint256 _withdrawalId) external override(IApella) { + function finaliseWithdraw(uint256 _withdrawalId) external override(IGovernance) { DataStructures.Withdrawal storage withdrawal = withdrawals[_withdrawalId]; - require(!withdrawal.claimed, Errors.Apella__WithdrawalAlreadyclaimed()); + require(!withdrawal.claimed, Errors.Governance__WithdrawalAlreadyclaimed()); require( Timestamp.wrap(block.timestamp) >= withdrawal.unlocksAt, - Errors.Apella__WithdrawalNotUnlockedYet(Timestamp.wrap(block.timestamp), withdrawal.unlocksAt) + Errors.Governance__WithdrawalNotUnlockedYet( + Timestamp.wrap(block.timestamp), withdrawal.unlocksAt + ) ); withdrawal.claimed = true; @@ -102,20 +118,23 @@ contract Apella is IApella { ASSET.safeTransfer(withdrawal.recipient, withdrawal.amount); } - function propose(IPayload _proposal) external override(IApella) returns (bool) { - require(msg.sender == gerousia, Errors.Apella__CallerNotGerousia(msg.sender, gerousia)); + function propose(IPayload _proposal) external override(IGovernance) returns (bool) { + require( + msg.sender == governanceProposer, + Errors.Governance__CallerNotGovernanceProposer(msg.sender, governanceProposer) + ); return _propose(_proposal); } /** * @notice Propose a new proposal by locking up a bunch of power * - * Beware that if the gerousia changes these proposals will also be dropped + * Beware that if the governanceProposer changes these proposals will also be dropped * This is to ensure consistency around way proposals are made, and they should - * really be using the proposal logic in Gerousia, which might have a similar + * really be using the proposal logic in GovernanceProposer, which might have a similar * mechanism in place as well. * It is here for emergency purposes. - * Using the lock should be a last resort if the Gerousia is broken. + * Using the lock should be a last resort if the GovernanceProposer is broken. * * @param _proposal The proposal to propose * @param _to The address to send the lock to @@ -123,14 +142,15 @@ contract Apella is IApella { */ function proposeWithLock(IPayload _proposal, address _to) external - override(IApella) + override(IGovernance) returns (bool) { uint256 availablePower = users[msg.sender].powerNow(); uint256 amount = configuration.proposeConfig.lockAmount; require( - amount <= availablePower, Errors.Apella__InsufficientPower(msg.sender, availablePower, amount) + amount <= availablePower, + Errors.Governance__InsufficientPower(msg.sender, availablePower, amount) ); _initiateWithdraw(_to, amount, configuration.proposeConfig.lockDelay); @@ -139,11 +159,11 @@ contract Apella is IApella { function vote(uint256 _proposalId, uint256 _amount, bool _support) external - override(IApella) + override(IGovernance) returns (bool) { DataStructures.ProposalState state = getProposalState(_proposalId); - require(state == DataStructures.ProposalState.Active, Errors.Apella__ProposalNotActive()); + require(state == DataStructures.ProposalState.Active, Errors.Governance__ProposalNotActive()); // Compute the power at the time where we became active uint256 userPower = users[msg.sender].powerAt(proposals[_proposalId].pendingThrough()); @@ -153,7 +173,7 @@ contract Apella is IApella { uint256 availablePower = userPower - (userBallot.nea + userBallot.yea); require( _amount <= availablePower, - Errors.Apella__InsufficientPower(msg.sender, availablePower, _amount) + Errors.Governance__InsufficientPower(msg.sender, availablePower, _amount) ); DataStructures.Ballot storage summedBallot = proposals[_proposalId].summedBallot; @@ -170,10 +190,10 @@ contract Apella is IApella { return true; } - function execute(uint256 _proposalId) external override(IApella) returns (bool) { + function execute(uint256 _proposalId) external override(IGovernance) returns (bool) { DataStructures.ProposalState state = getProposalState(_proposalId); require( - state == DataStructures.ProposalState.Executable, Errors.Apella__ProposalNotExecutable() + state == DataStructures.ProposalState.Executable, Errors.Governance__ProposalNotExecutable() ); DataStructures.Proposal storage proposal = proposals[_proposalId]; @@ -182,11 +202,11 @@ contract Apella is IApella { IPayload.Action[] memory actions = proposal.payload.getActions(); for (uint256 i = 0; i < actions.length; i++) { - require(actions[i].target != address(ASSET), Errors.Apella__CannotCallAsset()); + require(actions[i].target != address(ASSET), Errors.Governance__CannotCallAsset()); // We allow calls to EOAs. If you really want be my guest. // solhint-disable-next-line avoid-low-level-calls (bool success,) = actions[i].target.call(actions[i].data); - require(success, Errors.Apella__CallFailed(actions[i].target)); + require(success, Errors.Governance__CallFailed(actions[i].target)); } emit ProposalExecuted(_proposalId); @@ -194,28 +214,34 @@ contract Apella is IApella { return true; } - function dropProposal(uint256 _proposalId) external override(IApella) returns (bool) { + function dropProposal(uint256 _proposalId) external override(IGovernance) returns (bool) { DataStructures.Proposal storage self = proposals[_proposalId]; require( - self.state != DataStructures.ProposalState.Dropped, Errors.Apella__ProposalAlreadyDropped() + self.state != DataStructures.ProposalState.Dropped, + Errors.Governance__ProposalAlreadyDropped() ); require( getProposalState(_proposalId) == DataStructures.ProposalState.Dropped, - Errors.Apella__ProposalCannotBeDropped() + Errors.Governance__ProposalCannotBeDropped() ); self.state = DataStructures.ProposalState.Dropped; return true; } - function powerAt(address _owner, Timestamp _ts) external view override(IApella) returns (uint256) { + function powerAt(address _owner, Timestamp _ts) + external + view + override(IGovernance) + returns (uint256) + { if (_ts == Timestamp.wrap(block.timestamp)) { return users[_owner].powerNow(); } return users[_owner].powerAt(_ts); } - function totalPowerAt(Timestamp _ts) external view override(IApella) returns (uint256) { + function totalPowerAt(Timestamp _ts) external view override(IGovernance) returns (uint256) { if (_ts == Timestamp.wrap(block.timestamp)) { return total.powerNow(); } @@ -225,7 +251,7 @@ contract Apella is IApella { function getConfiguration() external view - override(IApella) + override(IGovernance) returns (DataStructures.Configuration memory) { return configuration; @@ -234,7 +260,7 @@ contract Apella is IApella { function getProposal(uint256 _proposalId) external view - override(IApella) + override(IGovernance) returns (DataStructures.Proposal memory) { return proposals[_proposalId]; @@ -243,7 +269,7 @@ contract Apella is IApella { function getWithdrawal(uint256 _withdrawalId) external view - override(IApella) + override(IGovernance) returns (DataStructures.Withdrawal memory) { return withdrawals[_withdrawalId]; @@ -258,10 +284,10 @@ contract Apella is IApella { function getProposalState(uint256 _proposalId) public view - override(IApella) + override(IGovernance) returns (DataStructures.ProposalState) { - require(_proposalId < proposalCount, Errors.Apella__ProposalDoesNotExists(_proposalId)); + require(_proposalId < proposalCount, Errors.Governance__ProposalDoesNotExists(_proposalId)); DataStructures.Proposal storage self = proposals[_proposalId]; @@ -269,8 +295,8 @@ contract Apella is IApella { return self.state; } - // If the gerousia have changed we mark is as dropped - if (gerousia != self.gerousia) { + // If the governanceProposer have changed we mark is as dropped + if (governanceProposer != self.governanceProposer) { return DataStructures.ProposalState.Dropped; } @@ -329,7 +355,7 @@ contract Apella is IApella { config: configuration, state: DataStructures.ProposalState.Pending, payload: _proposal, - gerousia: gerousia, + governanceProposer: governanceProposer, creation: Timestamp.wrap(block.timestamp), summedBallot: DataStructures.Ballot({yea: 0, nea: 0}) }); diff --git a/l1-contracts/src/governance/Gerousia.sol b/l1-contracts/src/governance/GovernanceProposer.sol similarity index 64% rename from l1-contracts/src/governance/Gerousia.sol rename to l1-contracts/src/governance/GovernanceProposer.sol index 4759869450ea..7e665ee3aa82 100644 --- a/l1-contracts/src/governance/Gerousia.sol +++ b/l1-contracts/src/governance/GovernanceProposer.sol @@ -1,22 +1,23 @@ -// SPDX-License-Identifier: UNLICENSED +// SPDX-License-Identifier: Apache-2.0 +// Copyright 2024 Aztec Labs. pragma solidity >=0.8.27; import {ILeonidas} from "@aztec/core/interfaces/ILeonidas.sol"; import {Slot, SlotLib} from "@aztec/core/libraries/TimeMath.sol"; -import {IApella} from "@aztec/governance/interfaces/IApella.sol"; -import {IGerousia} from "@aztec/governance/interfaces/IGerousia.sol"; +import {IGovernance} from "@aztec/governance/interfaces/IGovernance.sol"; +import {IGovernanceProposer} from "@aztec/governance/interfaces/IGovernanceProposer.sol"; import {IPayload} from "@aztec/governance/interfaces/IPayload.sol"; import {IRegistry} from "@aztec/governance/interfaces/IRegistry.sol"; import {Errors} from "@aztec/governance/libraries/Errors.sol"; /** - * @notice A Gerousia implementation following the empire model + * @notice A GovernanceProposer implementation following the empire model * Beware that while governance generally do not care about the implementation * this implementation will since it is dependent on the sequencer selection. * This also means that the implementation here will need to be "updated" if - * the interfaces of the sequencer selection changes, for exampel going optimistic. + * the interfaces of the sequencer selection changes, for example going optimistic. */ -contract Gerousia is IGerousia { +contract GovernanceProposer is IGovernanceProposer { using SlotLib for Slot; struct RoundAccounting { @@ -39,8 +40,8 @@ contract Gerousia is IGerousia { N = _n; M = _m; - require(N > M / 2, Errors.Gerousia__InvalidNAndMValues(N, M)); - require(N <= M, Errors.Gerousia__NCannotBeLargerTHanM(N, M)); + require(N > M / 2, Errors.GovernanceProposer__InvalidNAndMValues(N, M)); + require(N <= M, Errors.GovernanceProposer__NCannotBeLargerTHanM(N, M)); } // Note that this one is heavily realying on the fact that this contract @@ -55,11 +56,13 @@ contract Gerousia is IGerousia { * * @return True if executed successfully, false otherwise */ - function vote(IPayload _proposal) external override(IGerousia) returns (bool) { - require(address(_proposal).code.length > 0, Errors.Gerousia__ProposalHaveNoCode(_proposal)); + function vote(IPayload _proposal) external override(IGovernanceProposer) returns (bool) { + require( + address(_proposal).code.length > 0, Errors.GovernanceProposer__ProposalHaveNoCode(_proposal) + ); address instance = REGISTRY.getRollup(); - require(instance.code.length > 0, Errors.Gerousia__InstanceHaveNoCode(instance)); + require(instance.code.length > 0, Errors.GovernanceProposer__InstanceHaveNoCode(instance)); ILeonidas selection = ILeonidas(instance); Slot currentSlot = selection.getCurrentSlot(); @@ -68,10 +71,14 @@ contract Gerousia is IGerousia { RoundAccounting storage round = rounds[instance][roundNumber]; - require(currentSlot > round.lastVote, Errors.Gerousia__VoteAlreadyCastForSlot(currentSlot)); + require( + currentSlot > round.lastVote, Errors.GovernanceProposer__VoteAlreadyCastForSlot(currentSlot) + ); address proposer = selection.getCurrentProposer(); - require(msg.sender == proposer, Errors.Gerousia__OnlyProposerCanVote(msg.sender, proposer)); + require( + msg.sender == proposer, Errors.GovernanceProposer__OnlyProposerCanVote(msg.sender, proposer) + ); round.yeaCount[_proposal] += 1; round.lastVote = currentSlot; @@ -93,31 +100,36 @@ contract Gerousia is IGerousia { * * @return True if executed successfully, false otherwise */ - function pushProposal(uint256 _roundNumber) external override(IGerousia) returns (bool) { + function pushProposal(uint256 _roundNumber) external override(IGovernanceProposer) returns (bool) { // Need to ensure that the round is not active. address instance = REGISTRY.getRollup(); - require(instance.code.length > 0, Errors.Gerousia__InstanceHaveNoCode(instance)); + require(instance.code.length > 0, Errors.GovernanceProposer__InstanceHaveNoCode(instance)); ILeonidas selection = ILeonidas(instance); Slot currentSlot = selection.getCurrentSlot(); uint256 currentRound = computeRound(currentSlot); - require(_roundNumber < currentRound, Errors.Gerousia__CanOnlyPushProposalInPast()); + require(_roundNumber < currentRound, Errors.GovernanceProposer__CanOnlyPushProposalInPast()); require( _roundNumber + LIFETIME_IN_ROUNDS >= currentRound, - Errors.Gerousia__ProposalTooOld(_roundNumber, currentRound) + Errors.GovernanceProposer__ProposalTooOld(_roundNumber, currentRound) ); RoundAccounting storage round = rounds[instance][_roundNumber]; - require(!round.executed, Errors.Gerousia__ProposalAlreadyExecuted(_roundNumber)); - require(round.leader != IPayload(address(0)), Errors.Gerousia__ProposalCannotBeAddressZero()); - require(round.yeaCount[round.leader] >= N, Errors.Gerousia__InsufficientVotes()); + require(!round.executed, Errors.GovernanceProposer__ProposalAlreadyExecuted(_roundNumber)); + require( + round.leader != IPayload(address(0)), Errors.GovernanceProposer__ProposalCannotBeAddressZero() + ); + require(round.yeaCount[round.leader] >= N, Errors.GovernanceProposer__InsufficientVotes()); round.executed = true; emit ProposalPushed(round.leader, _roundNumber); - require(getApella().propose(round.leader), Errors.Gerousia__FailedToPropose(round.leader)); + require( + getGovernance().propose(round.leader), + Errors.GovernanceProposer__FailedToPropose(round.leader) + ); return true; } @@ -133,7 +145,7 @@ contract Gerousia is IGerousia { function yeaCount(address _instance, uint256 _round, IPayload _proposal) external view - override(IGerousia) + override(IGovernanceProposer) returns (uint256) { return rounds[_instance][_round].yeaCount[_proposal]; @@ -146,11 +158,11 @@ contract Gerousia is IGerousia { * * @return The round number */ - function computeRound(Slot _slot) public view override(IGerousia) returns (uint256) { + function computeRound(Slot _slot) public view override(IGovernanceProposer) returns (uint256) { return _slot.unwrap() / M; } - function getApella() public view override(IGerousia) returns (IApella) { - return IApella(REGISTRY.getApella()); + function getGovernance() public view override(IGovernanceProposer) returns (IGovernance) { + return IGovernance(REGISTRY.getGovernance()); } } diff --git a/l1-contracts/src/governance/Registry.sol b/l1-contracts/src/governance/Registry.sol index 8595e664f9c2..f18989d73aec 100644 --- a/l1-contracts/src/governance/Registry.sol +++ b/l1-contracts/src/governance/Registry.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: Apache-2.0 -// Copyright 2023 Aztec Labs. +// Copyright 2024 Aztec Labs. pragma solidity >=0.8.27; import {IRegistry} from "@aztec/governance/interfaces/IRegistry.sol"; @@ -85,10 +85,10 @@ contract Registry is IRegistry, Ownable { } /** - * @notice Returns the address of the apella - * @return The apella address + * @notice Returns the address of the governance + * @return The governance address */ - function getApella() external view override(IRegistry) returns (address) { + function getGovernance() external view override(IRegistry) returns (address) { return owner(); } diff --git a/l1-contracts/src/governance/Sysstia.sol b/l1-contracts/src/governance/RewardDistributor.sol similarity index 69% rename from l1-contracts/src/governance/Sysstia.sol rename to l1-contracts/src/governance/RewardDistributor.sol index 1dfaf0ca9d89..759920b88252 100644 --- a/l1-contracts/src/governance/Sysstia.sol +++ b/l1-contracts/src/governance/RewardDistributor.sol @@ -1,15 +1,19 @@ // SPDX-License-Identifier: Apache-2.0 -// Copyright 2023 Aztec Labs. +// Copyright 2024 Aztec Labs. pragma solidity >=0.8.27; import {IRegistry} from "@aztec/governance/interfaces/IRegistry.sol"; -import {ISysstia} from "@aztec/governance/interfaces/ISysstia.sol"; +import {IRewardDistributor} from "@aztec/governance/interfaces/IRewardDistributor.sol"; import {Errors} from "@aztec/governance/libraries/Errors.sol"; import {Ownable} from "@oz/access/Ownable.sol"; import {IERC20} from "@oz/token/ERC20/IERC20.sol"; import {SafeERC20} from "@oz/token/ERC20/utils/SafeERC20.sol"; -contract Sysstia is ISysstia, Ownable { +/** + * @title RewardDistributor + * @notice This contract is responsible for distributing rewards. + */ +contract RewardDistributor is IRewardDistributor, Ownable { using SafeERC20 for IERC20; // This value is pulled out my ass. Don't take it seriously @@ -23,7 +27,7 @@ contract Sysstia is ISysstia, Ownable { registry = _registry; } - function updateRegistry(IRegistry _registry) external override(ISysstia) onlyOwner { + function updateRegistry(IRegistry _registry) external override(IRewardDistributor) onlyOwner { registry = _registry; emit RegistryUpdated(_registry); } @@ -37,9 +41,10 @@ contract Sysstia is ISysstia, Ownable { * * @return - the amount claimed */ - function claim(address _to) external override(ISysstia) returns (uint256) { + function claim(address _to) external override(IRewardDistributor) returns (uint256) { require( - msg.sender == canonicalRollup(), Errors.Sysstia__InvalidCaller(msg.sender, canonicalRollup()) + msg.sender == canonicalRollup(), + Errors.RewardDistributor__InvalidCaller(msg.sender, canonicalRollup()) ); uint256 bal = ASSET.balanceOf(address(this)); uint256 reward = bal > BLOCK_REWARD ? BLOCK_REWARD : bal; @@ -51,7 +56,7 @@ contract Sysstia is ISysstia, Ownable { return reward; } - function canonicalRollup() public view override(ISysstia) returns (address) { + function canonicalRollup() public view override(IRewardDistributor) returns (address) { return registry.getRollup(); } } diff --git a/l1-contracts/src/governance/interfaces/INomismatokopio.sol b/l1-contracts/src/governance/interfaces/ICoinIssuer.sol similarity index 76% rename from l1-contracts/src/governance/interfaces/INomismatokopio.sol rename to l1-contracts/src/governance/interfaces/ICoinIssuer.sol index 27f65cbafbdf..a2853f7ef770 100644 --- a/l1-contracts/src/governance/interfaces/INomismatokopio.sol +++ b/l1-contracts/src/governance/interfaces/ICoinIssuer.sol @@ -1,8 +1,8 @@ // SPDX-License-Identifier: Apache-2.0 -// Copyright 2023 Aztec Labs. +// Copyright 2024 Aztec Labs. pragma solidity >=0.8.27; -interface INomismatokopio { +interface ICoinIssuer { function mint(address _to, uint256 _amount) external; function mintAvailable() external view returns (uint256); } diff --git a/l1-contracts/src/governance/interfaces/IApella.sol b/l1-contracts/src/governance/interfaces/IGovernance.sol similarity index 89% rename from l1-contracts/src/governance/interfaces/IApella.sol rename to l1-contracts/src/governance/interfaces/IGovernance.sol index 527319538879..7f45d1bb981e 100644 --- a/l1-contracts/src/governance/interfaces/IApella.sol +++ b/l1-contracts/src/governance/interfaces/IGovernance.sol @@ -1,22 +1,23 @@ -// SPDX-License-Identifier: UNLICENSED +// SPDX-License-Identifier: Apache-2.0 +// Copyright 2024 Aztec Labs. pragma solidity >=0.8.27; import {Timestamp} from "@aztec/core/libraries/TimeMath.sol"; import {IPayload} from "@aztec/governance/interfaces/IPayload.sol"; import {DataStructures} from "@aztec/governance/libraries/DataStructures.sol"; -interface IApella { +interface IGovernance { event Proposed(uint256 indexed proposalId, address indexed proposal); event VoteCast(uint256 indexed proposalId, address indexed voter, bool support, uint256 amount); event ProposalExecuted(uint256 indexed proposalId); - event GerousiaUpdated(address indexed gerousia); + event GovernanceProposerUpdated(address indexed governanceProposer); event ConfigurationUpdated(Timestamp indexed time); event Deposit(address indexed depositor, address indexed onBehalfOf, uint256 amount); event WithdrawInitiated(uint256 indexed withdrawalId, address indexed recipient, uint256 amount); event WithdrawFinalised(uint256 indexed withdrawalId); - function updateGerousia(address _gerousia) external; + function updateGovernanceProposer(address _governanceProposer) external; function updateConfiguration(DataStructures.Configuration memory _configuration) external; function deposit(address _onBehalfOf, uint256 _amount) external; function initiateWithdraw(address _to, uint256 _amount) external returns (uint256); diff --git a/l1-contracts/src/governance/interfaces/IGerousia.sol b/l1-contracts/src/governance/interfaces/IGovernanceProposer.sol similarity index 72% rename from l1-contracts/src/governance/interfaces/IGerousia.sol rename to l1-contracts/src/governance/interfaces/IGovernanceProposer.sol index 12a5afd600f8..7539446a1de9 100644 --- a/l1-contracts/src/governance/interfaces/IGerousia.sol +++ b/l1-contracts/src/governance/interfaces/IGovernanceProposer.sol @@ -1,11 +1,12 @@ -// SPDX-License-Identifier: UNLICENSED +// SPDX-License-Identifier: Apache-2.0 +// Copyright 2024 Aztec Labs. pragma solidity >=0.8.27; import {Slot} from "@aztec/core/libraries/TimeMath.sol"; -import {IApella} from "@aztec/governance/interfaces/IApella.sol"; +import {IGovernance} from "@aztec/governance/interfaces/IGovernance.sol"; import {IPayload} from "@aztec/governance/interfaces/IPayload.sol"; -interface IGerousia { +interface IGovernanceProposer { event VoteCast(IPayload indexed proposal, uint256 indexed round, address indexed voter); event ProposalPushed(IPayload indexed proposal, uint256 indexed round); @@ -16,5 +17,5 @@ interface IGerousia { view returns (uint256); function computeRound(Slot _slot) external view returns (uint256); - function getApella() external view returns (IApella); + function getGovernance() external view returns (IGovernance); } diff --git a/l1-contracts/src/governance/interfaces/IMintableERC20.sol b/l1-contracts/src/governance/interfaces/IMintableERC20.sol index 20b5b69b47b4..f2bd66ffa877 100644 --- a/l1-contracts/src/governance/interfaces/IMintableERC20.sol +++ b/l1-contracts/src/governance/interfaces/IMintableERC20.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: Apache-2.0 -// Copyright 2023 Aztec Labs. +// Copyright 2024 Aztec Labs. pragma solidity >=0.8.27; import {IERC20} from "@oz/token/ERC20/IERC20.sol"; diff --git a/l1-contracts/src/governance/interfaces/IPayload.sol b/l1-contracts/src/governance/interfaces/IPayload.sol index e8f33910ec5f..9e3e23c81bb6 100644 --- a/l1-contracts/src/governance/interfaces/IPayload.sol +++ b/l1-contracts/src/governance/interfaces/IPayload.sol @@ -1,4 +1,5 @@ -// SPDX-License-Identifier: UNLICENSED +// SPDX-License-Identifier: Apache-2.0 +// Copyright 2024 Aztec Labs. pragma solidity >=0.8.27; interface IPayload { diff --git a/l1-contracts/src/governance/interfaces/IRegistry.sol b/l1-contracts/src/governance/interfaces/IRegistry.sol index 844c45bbddc6..5b300d3fab17 100644 --- a/l1-contracts/src/governance/interfaces/IRegistry.sol +++ b/l1-contracts/src/governance/interfaces/IRegistry.sol @@ -35,5 +35,5 @@ interface IRegistry { function isRollupRegistered(address _rollup) external view returns (bool); - function getApella() external view returns (address); + function getGovernance() external view returns (address); } diff --git a/l1-contracts/src/governance/interfaces/ISysstia.sol b/l1-contracts/src/governance/interfaces/IRewardDistributor.sol similarity index 91% rename from l1-contracts/src/governance/interfaces/ISysstia.sol rename to l1-contracts/src/governance/interfaces/IRewardDistributor.sol index baaa3ad721bd..5b4c9c30254c 100644 --- a/l1-contracts/src/governance/interfaces/ISysstia.sol +++ b/l1-contracts/src/governance/interfaces/IRewardDistributor.sol @@ -3,7 +3,7 @@ pragma solidity >=0.8.27; import {IRegistry} from "./IRegistry.sol"; -interface ISysstia { +interface IRewardDistributor { event RegistryUpdated(IRegistry indexed registry); function updateRegistry(IRegistry _registry) external; diff --git a/l1-contracts/src/governance/libraries/ConfigurationLib.sol b/l1-contracts/src/governance/libraries/ConfigurationLib.sol index 481f35dbc03b..2537e9b13c2b 100644 --- a/l1-contracts/src/governance/libraries/ConfigurationLib.sol +++ b/l1-contracts/src/governance/libraries/ConfigurationLib.sol @@ -1,4 +1,5 @@ -// SPDX-License-Identifier: UNLICENSED +// SPDX-License-Identifier: Apache-2.0 +// Copyright 2024 Aztec Labs. pragma solidity >=0.8.27; import {Timestamp} from "@aztec/core/libraries/TimeMath.sol"; @@ -33,20 +34,20 @@ library ConfigurationLib { * before writing it to state. */ function assertValid(DataStructures.Configuration memory _self) internal pure returns (bool) { - require(_self.quorum >= QUORUM_LOWER, Errors.Apella__ConfigurationLib__QuorumTooSmall()); - require(_self.quorum <= QUORUM_UPPER, Errors.Apella__ConfigurationLib__QuorumTooBig()); + require(_self.quorum >= QUORUM_LOWER, Errors.Governance__ConfigurationLib__QuorumTooSmall()); + require(_self.quorum <= QUORUM_UPPER, Errors.Governance__ConfigurationLib__QuorumTooBig()); require( _self.voteDifferential <= DIFFERENTIAL_UPPER, - Errors.Apella__ConfigurationLib__DifferentialTooBig() + Errors.Governance__ConfigurationLib__DifferentialTooBig() ); require( - _self.minimumVotes >= VOTES_LOWER, Errors.Apella__ConfigurationLib__InvalidMinimumVotes() + _self.minimumVotes >= VOTES_LOWER, Errors.Governance__ConfigurationLib__InvalidMinimumVotes() ); require( _self.proposeConfig.lockAmount >= VOTES_LOWER, - Errors.Apella__ConfigurationLib__LockAmountTooSmall() + Errors.Governance__ConfigurationLib__LockAmountTooSmall() ); // Beyond checking the bounds like this, it might be useful to ensure that the value is larger than the withdrawal delay @@ -54,43 +55,47 @@ library ConfigurationLib { // if this is a useful property, it is not enforced. require( _self.proposeConfig.lockDelay >= TIME_LOWER, - Errors.Apella__ConfigurationLib__TimeTooSmall("LockDelay") + Errors.Governance__ConfigurationLib__TimeTooSmall("LockDelay") ); require( _self.proposeConfig.lockDelay <= TIME_UPPER, - Errors.Apella__ConfigurationLib__TimeTooBig("LockDelay") + Errors.Governance__ConfigurationLib__TimeTooBig("LockDelay") ); require( - _self.votingDelay >= TIME_LOWER, Errors.Apella__ConfigurationLib__TimeTooSmall("VotingDelay") + _self.votingDelay >= TIME_LOWER, + Errors.Governance__ConfigurationLib__TimeTooSmall("VotingDelay") ); require( - _self.votingDelay <= TIME_UPPER, Errors.Apella__ConfigurationLib__TimeTooBig("VotingDelay") + _self.votingDelay <= TIME_UPPER, + Errors.Governance__ConfigurationLib__TimeTooBig("VotingDelay") ); require( _self.votingDuration >= TIME_LOWER, - Errors.Apella__ConfigurationLib__TimeTooSmall("VotingDuration") + Errors.Governance__ConfigurationLib__TimeTooSmall("VotingDuration") ); require( _self.votingDuration <= TIME_UPPER, - Errors.Apella__ConfigurationLib__TimeTooBig("VotingDuration") + Errors.Governance__ConfigurationLib__TimeTooBig("VotingDuration") ); require( _self.executionDelay >= TIME_LOWER, - Errors.Apella__ConfigurationLib__TimeTooSmall("ExecutionDelay") + Errors.Governance__ConfigurationLib__TimeTooSmall("ExecutionDelay") ); require( _self.executionDelay <= TIME_UPPER, - Errors.Apella__ConfigurationLib__TimeTooBig("ExecutionDelay") + Errors.Governance__ConfigurationLib__TimeTooBig("ExecutionDelay") ); require( - _self.gracePeriod >= TIME_LOWER, Errors.Apella__ConfigurationLib__TimeTooSmall("GracePeriod") + _self.gracePeriod >= TIME_LOWER, + Errors.Governance__ConfigurationLib__TimeTooSmall("GracePeriod") ); require( - _self.gracePeriod <= TIME_UPPER, Errors.Apella__ConfigurationLib__TimeTooBig("GracePeriod") + _self.gracePeriod <= TIME_UPPER, + Errors.Governance__ConfigurationLib__TimeTooBig("GracePeriod") ); return true; diff --git a/l1-contracts/src/governance/libraries/DataStructures.sol b/l1-contracts/src/governance/libraries/DataStructures.sol index c0238494462e..ea820eae466c 100644 --- a/l1-contracts/src/governance/libraries/DataStructures.sol +++ b/l1-contracts/src/governance/libraries/DataStructures.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: Apache-2.0 -// Copyright 2023 Aztec Labs. +// Copyright 2024 Aztec Labs. pragma solidity >=0.8.27; import {Timestamp} from "@aztec/core/libraries/TimeMath.sol"; @@ -59,7 +59,7 @@ library DataStructures { Configuration config; ProposalState state; IPayload payload; - address gerousia; + address governanceProposer; Timestamp creation; Ballot summedBallot; } diff --git a/l1-contracts/src/governance/libraries/Errors.sol b/l1-contracts/src/governance/libraries/Errors.sol index b0e10660f631..fb835660287d 100644 --- a/l1-contracts/src/governance/libraries/Errors.sol +++ b/l1-contracts/src/governance/libraries/Errors.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: Apache-2.0 -// Copyright 2023 Aztec Labs. +// Copyright 2024 Aztec Labs. pragma solidity >=0.8.27; import {Slot, Timestamp} from "@aztec/core/libraries/TimeMath.sol"; @@ -13,55 +13,55 @@ import {IPayload} from "@aztec/governance/interfaces/IPayload.sol"; * when there are multiple contracts that could have thrown the error. */ library Errors { - error Apella__CallerNotGerousia(address caller, address gerousia); - error Apella__CallerNotSelf(address caller, address self); - error Apella__NoCheckpointsFound(); - error Apella__InsufficientPower(address voter, uint256 have, uint256 required); - error Apella__InvalidConfiguration(); - error Apella__WithdrawalAlreadyclaimed(); - error Apella__WithdrawalNotUnlockedYet(Timestamp currentTime, Timestamp unlocksAt); - error Apella__ProposalNotActive(); - error Apella__ProposalNotExecutable(); - error Apella__CannotCallAsset(); - error Apella__CallFailed(address target); - error Apella__ProposalDoesNotExists(uint256 proposalId); - error Apella__ProposalAlreadyDropped(); - error Apella__ProposalCannotBeDropped(); + error Governance__CallerNotGovernanceProposer(address caller, address governanceProposer); + error Governance__CallerNotSelf(address caller, address self); + error Governance__NoCheckpointsFound(); + error Governance__InsufficientPower(address voter, uint256 have, uint256 required); + error Governance__InvalidConfiguration(); + error Governance__WithdrawalAlreadyclaimed(); + error Governance__WithdrawalNotUnlockedYet(Timestamp currentTime, Timestamp unlocksAt); + error Governance__ProposalNotActive(); + error Governance__ProposalNotExecutable(); + error Governance__CannotCallAsset(); + error Governance__CallFailed(address target); + error Governance__ProposalDoesNotExists(uint256 proposalId); + error Governance__ProposalAlreadyDropped(); + error Governance__ProposalCannotBeDropped(); - error Apella__UserLib__NotInPast(); + error Governance__UserLib__NotInPast(); - error Apella__ConfigurationLib__InvalidMinimumVotes(); - error Apella__ConfigurationLib__LockAmountTooSmall(); - error Apella__ConfigurationLib__QuorumTooSmall(); - error Apella__ConfigurationLib__QuorumTooBig(); - error Apella__ConfigurationLib__DifferentialTooSmall(); - error Apella__ConfigurationLib__DifferentialTooBig(); - error Apella__ConfigurationLib__TimeTooSmall(string name); - error Apella__ConfigurationLib__TimeTooBig(string name); + error Governance__ConfigurationLib__InvalidMinimumVotes(); + error Governance__ConfigurationLib__LockAmountTooSmall(); + error Governance__ConfigurationLib__QuorumTooSmall(); + error Governance__ConfigurationLib__QuorumTooBig(); + error Governance__ConfigurationLib__DifferentialTooSmall(); + error Governance__ConfigurationLib__DifferentialTooBig(); + error Governance__ConfigurationLib__TimeTooSmall(string name); + error Governance__ConfigurationLib__TimeTooBig(string name); - error Apella__ProposalLib__ZeroMinimum(); - error Apella__ProposalLib__ZeroVotesNeeded(); - error Apella__ProposalLib__MoreVoteThanExistNeeded(); - error Apella__ProposalLib__ZeroYeaVotesNeeded(); - error Apella__ProposalLib__MoreYeaVoteThanExistNeeded(); + error Governance__ProposalLib__ZeroMinimum(); + error Governance__ProposalLib__ZeroVotesNeeded(); + error Governance__ProposalLib__MoreVoteThanExistNeeded(); + error Governance__ProposalLib__ZeroYeaVotesNeeded(); + error Governance__ProposalLib__MoreYeaVoteThanExistNeeded(); - error Gerousia__CanOnlyPushProposalInPast(); // 0x49fdf611" - error Gerousia__FailedToPropose(IPayload proposal); // 0x6ca2a2ed - error Gerousia__InstanceHaveNoCode(address instance); // 0x20a3b441 - error Gerousia__InsufficientVotes(); // 0xba1e05ef - error Gerousia__InvalidNAndMValues(uint256 n, uint256 m); // 0x520d9704 - error Gerousia__NCannotBeLargerTHanM(uint256 n, uint256 m); // 0x2fdfc063 - error Gerousia__OnlyProposerCanVote(address caller, address proposer); // 0xba27df38 - error Gerousia__ProposalAlreadyExecuted(uint256 roundNumber); // 0x7aeacb17 - error Gerousia__ProposalCannotBeAddressZero(); // 0xdb3e4b6e - error Gerousia__ProposalHaveNoCode(IPayload proposal); // 0xdce0615b - error Gerousia__ProposalTooOld(uint256 roundNumber, uint256 currentRoundNumber); //0x02283b1a - error Gerousia__VoteAlreadyCastForSlot(Slot slot); //0xc2201452 + error GovernanceProposer__CanOnlyPushProposalInPast(); // 0x49fdf611" + error GovernanceProposer__FailedToPropose(IPayload proposal); // 0x6ca2a2ed + error GovernanceProposer__InstanceHaveNoCode(address instance); // 0x20a3b441 + error GovernanceProposer__InsufficientVotes(); // 0xba1e05ef + error GovernanceProposer__InvalidNAndMValues(uint256 n, uint256 m); // 0x520d9704 + error GovernanceProposer__NCannotBeLargerTHanM(uint256 n, uint256 m); // 0x2fdfc063 + error GovernanceProposer__OnlyProposerCanVote(address caller, address proposer); // 0xba27df38 + error GovernanceProposer__ProposalAlreadyExecuted(uint256 roundNumber); // 0x7aeacb17 + error GovernanceProposer__ProposalCannotBeAddressZero(); // 0xdb3e4b6e + error GovernanceProposer__ProposalHaveNoCode(IPayload proposal); // 0xdce0615b + error GovernanceProposer__ProposalTooOld(uint256 roundNumber, uint256 currentRoundNumber); //0x02283b1a + error GovernanceProposer__VoteAlreadyCastForSlot(Slot slot); //0xc2201452 - error Nomismatokopio__InssuficientMintAvailable(uint256 available, uint256 needed); // 0xf268b931 + error CoinIssuer__InssuficientMintAvailable(uint256 available, uint256 needed); // 0xf268b931 error Registry__RollupAlreadyRegistered(address rollup); // 0x3c34eabf error Registry__RollupNotRegistered(address rollup); // 0xa1fee4cf - error Sysstia__InvalidCaller(address caller, address canonical); // 0xb95e39f6 + error RewardDistributor__InvalidCaller(address caller, address canonical); // 0xb95e39f6 } diff --git a/l1-contracts/src/governance/libraries/ProposalLib.sol b/l1-contracts/src/governance/libraries/ProposalLib.sol index 9798f88089b7..56845cddacee 100644 --- a/l1-contracts/src/governance/libraries/ProposalLib.sol +++ b/l1-contracts/src/governance/libraries/ProposalLib.sol @@ -1,4 +1,5 @@ -// SPDX-License-Identifier: UNLICENSED +// SPDX-License-Identifier: Apache-2.0 +// Copyright 2024 Aztec Labs. pragma solidity >=0.8.27; import {Timestamp} from "@aztec/core/libraries/TimeMath.sol"; diff --git a/l1-contracts/src/governance/libraries/UserLib.sol b/l1-contracts/src/governance/libraries/UserLib.sol index 1d08a333cfae..e520ec99d116 100644 --- a/l1-contracts/src/governance/libraries/UserLib.sol +++ b/l1-contracts/src/governance/libraries/UserLib.sol @@ -1,4 +1,5 @@ -// SPDX-License-Identifier: UNLICENSED +// SPDX-License-Identifier: Apache-2.0 +// Copyright 2024 Aztec Labs. pragma solidity >=0.8.27; import {Timestamp} from "@aztec/core/libraries/TimeMath.sol"; @@ -32,10 +33,10 @@ library UserLib { if (_amount == 0) { return; } - require(_self.numCheckPoints > 0, Errors.Apella__NoCheckpointsFound()); + require(_self.numCheckPoints > 0, Errors.Governance__NoCheckpointsFound()); DataStructures.CheckPoint storage last = _self.checkpoints[_self.numCheckPoints - 1]; require( - last.power >= _amount, Errors.Apella__InsufficientPower(msg.sender, last.power, _amount) + last.power >= _amount, Errors.Governance__InsufficientPower(msg.sender, last.power, _amount) ); if (last.time == Timestamp.wrap(block.timestamp)) { last.power -= _amount; @@ -63,7 +64,7 @@ library UserLib { { // If not in the past, the values are not stable. // We disallow using it to avoid potential misuse. - require(_time < Timestamp.wrap(block.timestamp), Errors.Apella__UserLib__NotInPast()); + require(_time < Timestamp.wrap(block.timestamp), Errors.Governance__UserLib__NotInPast()); uint256 numCheckPoints = _self.numCheckPoints; if (numCheckPoints == 0) { diff --git a/l1-contracts/src/mock/MockVerifier.sol b/l1-contracts/src/mock/MockVerifier.sol index 6b1ec10746ae..77f84a9eede4 100644 --- a/l1-contracts/src/mock/MockVerifier.sol +++ b/l1-contracts/src/mock/MockVerifier.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: Apache-2.0 -// Copyright 2023 Aztec Labs. +// Copyright 2024 Aztec Labs. pragma solidity >=0.8.27; // Interfaces diff --git a/l1-contracts/terraform/main.tf b/l1-contracts/terraform/main.tf index 9221228ecd17..5a720d5c204a 100644 --- a/l1-contracts/terraform/main.tf +++ b/l1-contracts/terraform/main.tf @@ -66,38 +66,38 @@ output "FEE_JUICE_PORTAL_CONTRACT_ADDRESS" { value = var.FEE_JUICE_PORTAL_CONTRACT_ADDRESS } -variable "NOMISMATOKOPIO_CONTRACT_ADDRESS" { +variable "COIN_ISSUER_CONTRACT_ADDRESS" { type = string default = "" } -output "NOMISMATOKOPIO_CONTRACT_ADDRESS" { - value = var.NOMISMATOKOPIO_CONTRACT_ADDRESS +output "COIN_ISSUER_CONTRACT_ADDRESS" { + value = var.COIN_ISSUER_CONTRACT_ADDRESS } -variable "SYSSTIA_CONTRACT_ADDRESS" { +variable "REWARD_DISTRIBUTOR_CONTRACT_ADDRESS" { type = string default = "" } -output "SYSSTIA_CONTRACT_ADDRESS" { - value = var.SYSSTIA_CONTRACT_ADDRESS +output "REWARD_DISTRIBUTOR_CONTRACT_ADDRESS" { + value = var.REWARD_DISTRIBUTOR_CONTRACT_ADDRESS } -variable "GEROUSIA_CONTRACT_ADDRESS" { +variable "GOVERNANCE_PROPOSER_CONTRACT_ADDRESS" { type = string default = "" } -output "GEROUSIA_CONTRACT_ADDRESS" { - value = var.GEROUSIA_CONTRACT_ADDRESS +output "GOVERNANCE_PROPOSER_CONTRACT_ADDRESS" { + value = var.GOVERNANCE_PROPOSER_CONTRACT_ADDRESS } -variable "APELLA_CONTRACT_ADDRESS" { +variable "GOVERNANCE_CONTRACT_ADDRESS" { type = string default = "" } -output "APELLA_CONTRACT_ADDRESS" { - value = var.APELLA_CONTRACT_ADDRESS +output "GOVERNANCE_CONTRACT_ADDRESS" { + value = var.GOVERNANCE_CONTRACT_ADDRESS } \ No newline at end of file diff --git a/l1-contracts/test/Inbox.t.sol b/l1-contracts/test/Inbox.t.sol index 0447d1dd38ec..96375d4c205a 100644 --- a/l1-contracts/test/Inbox.t.sol +++ b/l1-contracts/test/Inbox.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: Apache-2.0 -// Copyright 2023 Aztec Labs. +// Copyright 2024 Aztec Labs. pragma solidity >=0.8.27; import {Test} from "forge-std/Test.sol"; diff --git a/l1-contracts/test/Rollup.t.sol b/l1-contracts/test/Rollup.t.sol index 457e35078459..67391b12cedc 100644 --- a/l1-contracts/test/Rollup.t.sol +++ b/l1-contracts/test/Rollup.t.sol @@ -22,7 +22,7 @@ import {Leonidas} from "@aztec/core/Leonidas.sol"; import {NaiveMerkle} from "./merkle/Naive.sol"; import {MerkleTestUtil} from "./merkle/TestUtil.sol"; import {TestERC20} from "@aztec/mock/TestERC20.sol"; -import {Sysstia} from "@aztec/governance/Sysstia.sol"; +import {RewardDistributor} from "@aztec/governance/RewardDistributor.sol"; import {TxsDecoderHelper} from "./decoders/helpers/TxsDecoderHelper.sol"; import {IERC20Errors} from "@oz/interfaces/draft-IERC6093.sol"; @@ -47,7 +47,7 @@ contract RollupTest is DecoderBase { TestERC20 internal testERC20; FeeJuicePortal internal feeJuicePortal; IProofCommitmentEscrow internal proofCommitmentEscrow; - Sysstia internal sysstia; + RewardDistributor internal rewardDistributor; SignatureLib.Signature[] internal signatures; EpochProofQuoteLib.EpochProofQuote internal quote; @@ -76,11 +76,12 @@ contract RollupTest is DecoderBase { ); testERC20.mint(address(feeJuicePortal), Constants.FEE_JUICE_INITIAL_MINT); feeJuicePortal.initialize(); - sysstia = new Sysstia(testERC20, registry, address(this)); - testERC20.mint(address(sysstia), 1e6 ether); + rewardDistributor = new RewardDistributor(testERC20, registry, address(this)); + testERC20.mint(address(rewardDistributor), 1e6 ether); - rollup = - new Rollup(feeJuicePortal, sysstia, bytes32(0), bytes32(0), address(this), new address[](0)); + rollup = new Rollup( + feeJuicePortal, rewardDistributor, bytes32(0), bytes32(0), address(this), new address[](0) + ); inbox = Inbox(address(rollup.INBOX())); outbox = Outbox(address(rollup.OUTBOX())); proofCommitmentEscrow = IProofCommitmentEscrow(address(rollup.PROOF_COMMITMENT_ESCROW())); @@ -644,7 +645,7 @@ contract RollupTest is DecoderBase { feeAmount ); - uint256 expectedReward = sysstia.BLOCK_REWARD() + feeAmount; + uint256 expectedReward = rewardDistributor.BLOCK_REWARD() + feeAmount; uint256 expectedProverReward = Math.mulDiv(expectedReward, quote.basisPointFee, 10_000); uint256 expectedSequencerReward = expectedReward - expectedProverReward; diff --git a/l1-contracts/test/decoders/Base.sol b/l1-contracts/test/decoders/Base.sol index 106584015a05..d91a3e7f8840 100644 --- a/l1-contracts/test/decoders/Base.sol +++ b/l1-contracts/test/decoders/Base.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: Apache-2.0 -// Copyright 2023 Aztec Labs. +// Copyright 2024 Aztec Labs. pragma solidity >=0.8.27; import {Test} from "forge-std/Test.sol"; diff --git a/l1-contracts/test/decoders/Decoders.t.sol b/l1-contracts/test/decoders/Decoders.t.sol index 973a46e6cb59..9087a5734ede 100644 --- a/l1-contracts/test/decoders/Decoders.t.sol +++ b/l1-contracts/test/decoders/Decoders.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: Apache-2.0 -// Copyright 2023 Aztec Labs. +// Copyright 2024 Aztec Labs. pragma solidity >=0.8.27; import {DecoderBase} from "./Base.sol"; diff --git a/l1-contracts/test/decoders/helpers/HeaderLibHelper.sol b/l1-contracts/test/decoders/helpers/HeaderLibHelper.sol index f265c6f61a53..02528023a7ca 100644 --- a/l1-contracts/test/decoders/helpers/HeaderLibHelper.sol +++ b/l1-contracts/test/decoders/helpers/HeaderLibHelper.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: Apache-2.0 -// Copyright 2023 Aztec Labs. +// Copyright 2024 Aztec Labs. pragma solidity >=0.8.27; import {HeaderLib} from "@aztec/core/libraries/HeaderLib.sol"; diff --git a/l1-contracts/test/decoders/helpers/TxsDecoderHelper.sol b/l1-contracts/test/decoders/helpers/TxsDecoderHelper.sol index fad4763dc3dd..6e35c77504f1 100644 --- a/l1-contracts/test/decoders/helpers/TxsDecoderHelper.sol +++ b/l1-contracts/test/decoders/helpers/TxsDecoderHelper.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: Apache-2.0 -// Copyright 2023 Aztec Labs. +// Copyright 2024 Aztec Labs. pragma solidity >=0.8.27; import {TxsDecoder} from "@aztec/core/libraries/TxsDecoder.sol"; diff --git a/l1-contracts/test/fee_portal/depositToAztecPublic.t.sol b/l1-contracts/test/fee_portal/depositToAztecPublic.t.sol index b77bdfa3cbcd..403e1cf63bb6 100644 --- a/l1-contracts/test/fee_portal/depositToAztecPublic.t.sol +++ b/l1-contracts/test/fee_portal/depositToAztecPublic.t.sol @@ -13,7 +13,7 @@ import {DataStructures} from "@aztec/core/libraries/DataStructures.sol"; import {Hash} from "@aztec/core/libraries/crypto/Hash.sol"; import {IInbox} from "@aztec/core/interfaces/messagebridge/IInbox.sol"; import {Inbox} from "@aztec/core/messagebridge/Inbox.sol"; -import {Sysstia} from "@aztec/governance/Sysstia.sol"; +import {RewardDistributor} from "@aztec/governance/RewardDistributor.sol"; contract DepositToAztecPublic is Test { using Hash for DataStructures.L1ToL2Msg; @@ -23,7 +23,7 @@ contract DepositToAztecPublic is Test { TestERC20 internal token; FeeJuicePortal internal feeJuicePortal; Rollup internal rollup; - Sysstia internal sysstia; + RewardDistributor internal rewardDistributor; function setUp() public { registry = new Registry(OWNER); @@ -33,9 +33,10 @@ contract DepositToAztecPublic is Test { token.mint(address(feeJuicePortal), Constants.FEE_JUICE_INITIAL_MINT); feeJuicePortal.initialize(); - sysstia = new Sysstia(token, registry, address(this)); - rollup = - new Rollup(feeJuicePortal, sysstia, bytes32(0), bytes32(0), address(this), new address[](0)); + rewardDistributor = new RewardDistributor(token, registry, address(this)); + rollup = new Rollup( + feeJuicePortal, rewardDistributor, bytes32(0), bytes32(0), address(this), new address[](0) + ); vm.prank(OWNER); registry.upgrade(address(rollup)); @@ -66,8 +67,9 @@ contract DepositToAztecPublic is Test { uint256 numberOfRollups = bound(_numberOfRollups, 1, 5); for (uint256 i = 0; i < numberOfRollups; i++) { - Rollup freshRollup = - new Rollup(feeJuicePortal, sysstia, bytes32(0), bytes32(0), address(this), new address[](0)); + Rollup freshRollup = new Rollup( + feeJuicePortal, rewardDistributor, bytes32(0), bytes32(0), address(this), new address[](0) + ); vm.prank(OWNER); registry.upgrade(address(freshRollup)); } diff --git a/l1-contracts/test/fee_portal/distributeFees.t.sol b/l1-contracts/test/fee_portal/distributeFees.t.sol index 103b890cdf44..c469e8fe74a8 100644 --- a/l1-contracts/test/fee_portal/distributeFees.t.sol +++ b/l1-contracts/test/fee_portal/distributeFees.t.sol @@ -12,7 +12,7 @@ import {Rollup} from "@aztec/core/Rollup.sol"; import {DataStructures} from "@aztec/core/libraries/DataStructures.sol"; import {Hash} from "@aztec/core/libraries/crypto/Hash.sol"; import {Errors} from "@aztec/core/libraries/Errors.sol"; -import {Sysstia} from "@aztec/governance/Sysstia.sol"; +import {RewardDistributor} from "@aztec/governance/RewardDistributor.sol"; contract DistributeFees is Test { using Hash for DataStructures.L1ToL2Msg; @@ -22,7 +22,7 @@ contract DistributeFees is Test { TestERC20 internal token; FeeJuicePortal internal feeJuicePortal; Rollup internal rollup; - Sysstia internal sysstia; + RewardDistributor internal rewardDistributor; function setUp() public { registry = new Registry(OWNER); @@ -32,9 +32,10 @@ contract DistributeFees is Test { token.mint(address(feeJuicePortal), Constants.FEE_JUICE_INITIAL_MINT); feeJuicePortal.initialize(); - sysstia = new Sysstia(token, registry, address(this)); - rollup = - new Rollup(feeJuicePortal, sysstia, bytes32(0), bytes32(0), address(this), new address[](0)); + rewardDistributor = new RewardDistributor(token, registry, address(this)); + rollup = new Rollup( + feeJuicePortal, rewardDistributor, bytes32(0), bytes32(0), address(this), new address[](0) + ); vm.prank(OWNER); registry.upgrade(address(rollup)); @@ -73,8 +74,9 @@ contract DistributeFees is Test { uint256 numberOfRollups = bound(_numberOfRollups, 1, 5); for (uint256 i = 0; i < numberOfRollups; i++) { - Rollup freshRollup = - new Rollup(feeJuicePortal, sysstia, bytes32(0), bytes32(0), address(this), new address[](0)); + Rollup freshRollup = new Rollup( + feeJuicePortal, rewardDistributor, bytes32(0), bytes32(0), address(this), new address[](0) + ); vm.prank(OWNER); registry.upgrade(address(freshRollup)); } diff --git a/l1-contracts/test/governance/apella/updateGerousia.t.sol b/l1-contracts/test/governance/apella/updateGerousia.t.sol deleted file mode 100644 index 1322eb15fbd7..000000000000 --- a/l1-contracts/test/governance/apella/updateGerousia.t.sol +++ /dev/null @@ -1,33 +0,0 @@ -// SPDX-License-Identifier: UNLICENSED -pragma solidity >=0.8.27; - -import {ApellaBase} from "./base.t.sol"; -import {Errors} from "@aztec/governance/libraries/Errors.sol"; -import {IApella} from "@aztec/governance/interfaces/IApella.sol"; - -contract UpdateGerousiaTest is ApellaBase { - function test_WhenCallerIsNotApella(address _caller, address _gerousia) external { - // it revert - vm.assume(_caller != address(apella)); - vm.expectRevert( - abi.encodeWithSelector(Errors.Apella__CallerNotSelf.selector, _caller, address(apella)) - ); - vm.prank(_caller); - apella.updateGerousia(_gerousia); - } - - function test_WhenCallerIsApella(address _gerousia) external { - // it updates the gerousia - // it emit the {GerousiaUpdated} event - - vm.assume(_gerousia != address(apella.gerousia())); - - vm.expectEmit(true, true, true, true, address(apella)); - emit IApella.GerousiaUpdated(_gerousia); - - vm.prank(address(apella)); - apella.updateGerousia(_gerousia); - - assertEq(_gerousia, apella.gerousia()); - } -} diff --git a/l1-contracts/test/governance/apella/updateGerousia.tree b/l1-contracts/test/governance/apella/updateGerousia.tree deleted file mode 100644 index d2fd3dac6229..000000000000 --- a/l1-contracts/test/governance/apella/updateGerousia.tree +++ /dev/null @@ -1,6 +0,0 @@ -UpdateGerousiaTest -├── when caller is not apella -│ └── it revert -└── when caller is apella - ├── it updates the gerousia - └── it emit the {GerousiaUpdated} event \ No newline at end of file diff --git a/l1-contracts/test/governance/nomismatokopio/Base.t.sol b/l1-contracts/test/governance/coin-issuer/Base.t.sol similarity index 66% rename from l1-contracts/test/governance/nomismatokopio/Base.t.sol rename to l1-contracts/test/governance/coin-issuer/Base.t.sol index a96a9db3a031..b2812e4c7e91 100644 --- a/l1-contracts/test/governance/nomismatokopio/Base.t.sol +++ b/l1-contracts/test/governance/coin-issuer/Base.t.sol @@ -6,15 +6,15 @@ import {Test} from "forge-std/Test.sol"; import {IMintableERC20} from "@aztec/governance/interfaces/IMintableERC20.sol"; import {TestERC20} from "@aztec/mock/TestERC20.sol"; -import {Nomismatokopio} from "@aztec/governance/Nomismatokopio.sol"; +import {CoinIssuer} from "@aztec/governance/CoinIssuer.sol"; -contract NomismatokopioBase is Test { +contract CoinIssuerBase is Test { IMintableERC20 internal token; - Nomismatokopio internal nom; + CoinIssuer internal nom; function _deploy(uint256 _rate) internal { token = IMintableERC20(address(new TestERC20())); - nom = new Nomismatokopio(token, _rate, address(this)); + nom = new CoinIssuer(token, _rate, address(this)); } } diff --git a/l1-contracts/test/governance/nomismatokopio/mint.t.sol b/l1-contracts/test/governance/coin-issuer/mint.t.sol similarity index 89% rename from l1-contracts/test/governance/nomismatokopio/mint.t.sol rename to l1-contracts/test/governance/coin-issuer/mint.t.sol index 052acba10d01..29304fbb5893 100644 --- a/l1-contracts/test/governance/nomismatokopio/mint.t.sol +++ b/l1-contracts/test/governance/coin-issuer/mint.t.sol @@ -4,9 +4,9 @@ pragma solidity >=0.8.27; import {Ownable} from "@oz/access/Ownable.sol"; import {IERC20} from "@oz/token/ERC20/IERC20.sol"; import {Errors} from "@aztec/governance/libraries/Errors.sol"; -import {NomismatokopioBase} from "./Base.t.sol"; +import {CoinIssuerBase} from "./Base.t.sol"; -contract MintTest is NomismatokopioBase { +contract MintTest is CoinIssuerBase { uint256 internal constant RATE = 1e18; uint256 internal maxMint; @@ -35,9 +35,7 @@ contract MintTest is NomismatokopioBase { // it reverts uint256 amount = bound(_amount, maxMint + 1, type(uint256).max); vm.expectRevert( - abi.encodeWithSelector( - Errors.Nomismatokopio__InssuficientMintAvailable.selector, maxMint, amount - ) + abi.encodeWithSelector(Errors.CoinIssuer__InssuficientMintAvailable.selector, maxMint, amount) ); nom.mint(address(0xdead), amount); } diff --git a/l1-contracts/test/governance/nomismatokopio/mint.tree b/l1-contracts/test/governance/coin-issuer/mint.tree similarity index 100% rename from l1-contracts/test/governance/nomismatokopio/mint.tree rename to l1-contracts/test/governance/coin-issuer/mint.tree diff --git a/l1-contracts/test/governance/nomismatokopio/mintAvailable.t.sol b/l1-contracts/test/governance/coin-issuer/mintAvailable.t.sol similarity index 90% rename from l1-contracts/test/governance/nomismatokopio/mintAvailable.t.sol rename to l1-contracts/test/governance/coin-issuer/mintAvailable.t.sol index 1addf16f5a01..287775775857 100644 --- a/l1-contracts/test/governance/nomismatokopio/mintAvailable.t.sol +++ b/l1-contracts/test/governance/coin-issuer/mintAvailable.t.sol @@ -1,9 +1,9 @@ // SPDX-License-Identifier: UNLICENSED pragma solidity >=0.8.27; -import {NomismatokopioBase} from "./Base.t.sol"; +import {CoinIssuerBase} from "./Base.t.sol"; -contract MintAvailableTest is NomismatokopioBase { +contract MintAvailableTest is CoinIssuerBase { function test_GivenRateIs0(uint256 _time) external { // it returns 0 _deploy(0); diff --git a/l1-contracts/test/governance/nomismatokopio/mintAvailable.tree b/l1-contracts/test/governance/coin-issuer/mintAvailable.tree similarity index 100% rename from l1-contracts/test/governance/nomismatokopio/mintAvailable.tree rename to l1-contracts/test/governance/coin-issuer/mintAvailable.tree diff --git a/l1-contracts/test/governance/gerousia/Base.t.sol b/l1-contracts/test/governance/gerousia/Base.t.sol deleted file mode 100644 index 8b3db4eb5469..000000000000 --- a/l1-contracts/test/governance/gerousia/Base.t.sol +++ /dev/null @@ -1,39 +0,0 @@ -// SPDX-License-Identifier: UNLICENSED -pragma solidity >=0.8.27; - -import {Test} from "forge-std/Test.sol"; - -import {Registry} from "@aztec/governance/Registry.sol"; -import {Gerousia} from "@aztec/governance/Gerousia.sol"; - -import {IPayload} from "@aztec/governance/interfaces/IPayload.sol"; - -contract FakeApella { - address immutable GEROUSIA; - - mapping(IPayload => bool) public proposals; - - constructor(address _gerousia) { - GEROUSIA = _gerousia; - } - - function propose(IPayload _proposal) external returns (bool) { - proposals[_proposal] = true; - return true; - } -} - -contract GerousiaBase is Test { - Registry internal registry; - FakeApella internal apella; - Gerousia internal gerousia; - - function setUp() public virtual { - registry = new Registry(address(this)); - - gerousia = new Gerousia(registry, 667, 1000); - apella = new FakeApella(address(gerousia)); - - registry.transferOwnership(address(apella)); - } -} diff --git a/l1-contracts/test/governance/governance-proposer/Base.t.sol b/l1-contracts/test/governance/governance-proposer/Base.t.sol new file mode 100644 index 000000000000..1f7209114380 --- /dev/null +++ b/l1-contracts/test/governance/governance-proposer/Base.t.sol @@ -0,0 +1,39 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity >=0.8.27; + +import {Test} from "forge-std/Test.sol"; + +import {Registry} from "@aztec/governance/Registry.sol"; +import {GovernanceProposer} from "@aztec/governance/GovernanceProposer.sol"; + +import {IPayload} from "@aztec/governance/interfaces/IPayload.sol"; + +contract FakeGovernance { + address immutable GOVERNANCE_PROPOSER; + + mapping(IPayload => bool) public proposals; + + constructor(address _governanceProposer) { + GOVERNANCE_PROPOSER = _governanceProposer; + } + + function propose(IPayload _proposal) external returns (bool) { + proposals[_proposal] = true; + return true; + } +} + +contract GovernanceProposerBase is Test { + Registry internal registry; + FakeGovernance internal governance; + GovernanceProposer internal governanceProposer; + + function setUp() public virtual { + registry = new Registry(address(this)); + + governanceProposer = new GovernanceProposer(registry, 667, 1000); + governance = new FakeGovernance(address(governanceProposer)); + + registry.transferOwnership(address(governance)); + } +} diff --git a/l1-contracts/test/governance/gerousia/constructor.t.sol b/l1-contracts/test/governance/governance-proposer/constructor.t.sol similarity index 67% rename from l1-contracts/test/governance/gerousia/constructor.t.sol rename to l1-contracts/test/governance/governance-proposer/constructor.t.sol index 47746bde059f..f32b8aefa59e 100644 --- a/l1-contracts/test/governance/gerousia/constructor.t.sol +++ b/l1-contracts/test/governance/governance-proposer/constructor.t.sol @@ -2,7 +2,7 @@ pragma solidity >=0.8.27; import {Test} from "forge-std/Test.sol"; -import {Gerousia} from "@aztec/governance/Gerousia.sol"; +import {GovernanceProposer} from "@aztec/governance/GovernanceProposer.sol"; import {Errors} from "@aztec/governance/libraries/Errors.sol"; import {IRegistry} from "@aztec/governance/interfaces/IRegistry.sol"; @@ -14,8 +14,10 @@ contract ConstructorTest is Test { uint256 n = bound(_n, 0, _m / 2); - vm.expectRevert(abi.encodeWithSelector(Errors.Gerousia__InvalidNAndMValues.selector, n, _m)); - new Gerousia(REGISTRY, n, _m); + vm.expectRevert( + abi.encodeWithSelector(Errors.GovernanceProposer__InvalidNAndMValues.selector, n, _m) + ); + new GovernanceProposer(REGISTRY, n, _m); } function test_WhenNLargerThanM(uint256 _n, uint256 _m) external { @@ -23,8 +25,10 @@ contract ConstructorTest is Test { uint256 m = bound(_m, 0, type(uint256).max - 1); uint256 n = bound(_n, m + 1, type(uint256).max); - vm.expectRevert(abi.encodeWithSelector(Errors.Gerousia__NCannotBeLargerTHanM.selector, n, m)); - new Gerousia(REGISTRY, n, m); + vm.expectRevert( + abi.encodeWithSelector(Errors.GovernanceProposer__NCannotBeLargerTHanM.selector, n, m) + ); + new GovernanceProposer(REGISTRY, n, m); } function test_WhenNIsGreatherThanHalfOfM(uint256 _n, uint256 _m) external { @@ -33,7 +37,7 @@ contract ConstructorTest is Test { uint256 m = bound(_m, 1, type(uint256).max); uint256 n = bound(_n, m / 2 + 1, m); - Gerousia g = new Gerousia(REGISTRY, n, m); + GovernanceProposer g = new GovernanceProposer(REGISTRY, n, m); assertEq(address(g.REGISTRY()), address(REGISTRY)); assertEq(g.N(), n); diff --git a/l1-contracts/test/governance/gerousia/constructor.tree b/l1-contracts/test/governance/governance-proposer/constructor.tree similarity index 100% rename from l1-contracts/test/governance/gerousia/constructor.tree rename to l1-contracts/test/governance/governance-proposer/constructor.tree diff --git a/l1-contracts/test/governance/gerousia/mocks/FalsyApella.sol b/l1-contracts/test/governance/governance-proposer/mocks/FalsyGovernance.sol similarity index 84% rename from l1-contracts/test/governance/gerousia/mocks/FalsyApella.sol rename to l1-contracts/test/governance/governance-proposer/mocks/FalsyGovernance.sol index 2dd591896e6e..29e7de41e62a 100644 --- a/l1-contracts/test/governance/gerousia/mocks/FalsyApella.sol +++ b/l1-contracts/test/governance/governance-proposer/mocks/FalsyGovernance.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: UNLICENSED pragma solidity >=0.8.27; -contract FalsyApella { +contract FalsyGovernance { function propose(address) external pure returns (bool) { return false; } diff --git a/l1-contracts/test/governance/gerousia/mocks/FaultyApella.sol b/l1-contracts/test/governance/governance-proposer/mocks/FaultyGovernance.sol similarity index 87% rename from l1-contracts/test/governance/gerousia/mocks/FaultyApella.sol rename to l1-contracts/test/governance/governance-proposer/mocks/FaultyGovernance.sol index 26cb736a8f28..7482a713749b 100644 --- a/l1-contracts/test/governance/gerousia/mocks/FaultyApella.sol +++ b/l1-contracts/test/governance/governance-proposer/mocks/FaultyGovernance.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: UNLICENSED pragma solidity >=0.8.27; -contract FaultyApella { +contract FaultyGovernance { error Faulty(); function propose(address) external pure returns (bool) { diff --git a/l1-contracts/test/governance/gerousia/pushProposal.t.sol b/l1-contracts/test/governance/governance-proposer/pushProposal.t.sol similarity index 57% rename from l1-contracts/test/governance/gerousia/pushProposal.t.sol rename to l1-contracts/test/governance/governance-proposer/pushProposal.t.sol index 5936b688dc90..3555f2310fbc 100644 --- a/l1-contracts/test/governance/gerousia/pushProposal.t.sol +++ b/l1-contracts/test/governance/governance-proposer/pushProposal.t.sol @@ -2,16 +2,16 @@ pragma solidity >=0.8.27; import {IPayload} from "@aztec/governance/interfaces/IPayload.sol"; -import {IGerousia} from "@aztec/governance/interfaces/IGerousia.sol"; -import {GerousiaBase} from "./Base.t.sol"; +import {IGovernanceProposer} from "@aztec/governance/interfaces/IGovernanceProposer.sol"; +import {GovernanceProposerBase} from "./Base.t.sol"; import {Leonidas} from "@aztec/core/Leonidas.sol"; import {Errors} from "@aztec/governance/libraries/Errors.sol"; import {Slot, SlotLib, Timestamp} from "@aztec/core/libraries/TimeMath.sol"; -import {FaultyApella} from "./mocks/FaultyApella.sol"; -import {FalsyApella} from "./mocks/FalsyApella.sol"; +import {FaultyGovernance} from "./mocks/FaultyGovernance.sol"; +import {FalsyGovernance} from "./mocks/FalsyGovernance.sol"; -contract PushProposalTest is GerousiaBase { +contract PushProposalTest is GovernanceProposerBase { using SlotLib for Slot; Leonidas internal leonidas; @@ -22,14 +22,16 @@ contract PushProposalTest is GerousiaBase { function test_GivenCanonicalInstanceHoldNoCode(uint256 _roundNumber) external { // it revert vm.expectRevert( - abi.encodeWithSelector(Errors.Gerousia__InstanceHaveNoCode.selector, address(0xdead)) + abi.encodeWithSelector( + Errors.GovernanceProposer__InstanceHaveNoCode.selector, address(0xdead) + ) ); - gerousia.pushProposal(_roundNumber); + governanceProposer.pushProposal(_roundNumber); } modifier givenCanonicalInstanceHoldCode() { leonidas = new Leonidas(address(this)); - vm.prank(registry.getApella()); + vm.prank(registry.getGovernance()); registry.upgrade(address(leonidas)); // We jump into the future since slot 0, will behave as if already voted in @@ -39,12 +41,14 @@ contract PushProposalTest is GerousiaBase { function test_WhenRoundNotInPast() external givenCanonicalInstanceHoldCode { // it revert - vm.expectRevert(abi.encodeWithSelector(Errors.Gerousia__CanOnlyPushProposalInPast.selector)); - gerousia.pushProposal(0); + vm.expectRevert( + abi.encodeWithSelector(Errors.GovernanceProposer__CanOnlyPushProposalInPast.selector) + ); + governanceProposer.pushProposal(0); } modifier whenRoundInPast() { - vm.warp(Timestamp.unwrap(leonidas.getTimestampForSlot(Slot.wrap(gerousia.M())))); + vm.warp(Timestamp.unwrap(leonidas.getTimestampForSlot(Slot.wrap(governanceProposer.M())))); _; } @@ -57,7 +61,8 @@ contract PushProposalTest is GerousiaBase { uint256 lower = Timestamp.unwrap( leonidas.getTimestampForSlot( - leonidas.getCurrentSlot() + Slot.wrap(gerousia.M() * gerousia.LIFETIME_IN_ROUNDS() + 1) + leonidas.getCurrentSlot() + + Slot.wrap(governanceProposer.M() * governanceProposer.LIFETIME_IN_ROUNDS() + 1) ) ); uint256 upper = @@ -68,12 +73,12 @@ contract PushProposalTest is GerousiaBase { vm.expectRevert( abi.encodeWithSelector( - Errors.Gerousia__ProposalTooOld.selector, + Errors.GovernanceProposer__ProposalTooOld.selector, 0, - gerousia.computeRound(leonidas.getCurrentSlot()) + governanceProposer.computeRound(leonidas.getCurrentSlot()) ) ); - gerousia.pushProposal(0); + governanceProposer.pushProposal(0); } modifier whenRoundInRecentPast() { @@ -90,23 +95,27 @@ contract PushProposalTest is GerousiaBase { { // Need to execute a proposal first here. - for (uint256 i = 0; i < gerousia.N(); i++) { + for (uint256 i = 0; i < governanceProposer.N(); i++) { vm.prank(proposer); - assertTrue(gerousia.vote(proposal)); + assertTrue(governanceProposer.vote(proposal)); vm.warp( Timestamp.unwrap(leonidas.getTimestampForSlot(leonidas.getCurrentSlot() + Slot.wrap(1))) ); } vm.warp( Timestamp.unwrap( - leonidas.getTimestampForSlot(leonidas.getCurrentSlot() + Slot.wrap(gerousia.M())) + leonidas.getTimestampForSlot( + leonidas.getCurrentSlot() + Slot.wrap(governanceProposer.M()) + ) ) ); - gerousia.pushProposal(1); + governanceProposer.pushProposal(1); } - vm.expectRevert(abi.encodeWithSelector(Errors.Gerousia__ProposalAlreadyExecuted.selector, 1)); - gerousia.pushProposal(1); + vm.expectRevert( + abi.encodeWithSelector(Errors.GovernanceProposer__ProposalAlreadyExecuted.selector, 1) + ); + governanceProposer.pushProposal(1); } modifier givenRoundNotExecutedBefore() { @@ -123,20 +132,23 @@ contract PushProposalTest is GerousiaBase { // it revert // The first slot in the next round (round 1) - Slot lowerSlot = Slot.wrap(gerousia.M()); + Slot lowerSlot = Slot.wrap(governanceProposer.M()); uint256 lower = Timestamp.unwrap(leonidas.getTimestampForSlot(lowerSlot)); // the last slot in the LIFETIME_IN_ROUNDS next round uint256 upper = Timestamp.unwrap( leonidas.getTimestampForSlot( - lowerSlot + Slot.wrap(gerousia.M() * (gerousia.LIFETIME_IN_ROUNDS() - 1)) + lowerSlot + + Slot.wrap(governanceProposer.M() * (governanceProposer.LIFETIME_IN_ROUNDS() - 1)) ) ); uint256 time = bound(_slotsToJump, lower, upper); vm.warp(time); - vm.expectRevert(abi.encodeWithSelector(Errors.Gerousia__ProposalCannotBeAddressZero.selector)); - gerousia.pushProposal(0); + vm.expectRevert( + abi.encodeWithSelector(Errors.GovernanceProposer__ProposalCannotBeAddressZero.selector) + ); + governanceProposer.pushProposal(0); } modifier givenLeaderIsNotAddress0() { @@ -154,30 +166,30 @@ contract PushProposalTest is GerousiaBase { // it revert vm.prank(proposer); - gerousia.vote(proposal); + governanceProposer.vote(proposal); vm.warp( Timestamp.unwrap( - leonidas.getTimestampForSlot(leonidas.getCurrentSlot() + Slot.wrap(gerousia.M())) + leonidas.getTimestampForSlot(leonidas.getCurrentSlot() + Slot.wrap(governanceProposer.M())) ) ); - vm.expectRevert(abi.encodeWithSelector(Errors.Gerousia__InsufficientVotes.selector)); - gerousia.pushProposal(1); + vm.expectRevert(abi.encodeWithSelector(Errors.GovernanceProposer__InsufficientVotes.selector)); + governanceProposer.pushProposal(1); } modifier givenSufficientYea(uint256 _yeas) { - uint256 limit = bound(_yeas, gerousia.N(), gerousia.M()); + uint256 limit = bound(_yeas, governanceProposer.N(), governanceProposer.M()); for (uint256 i = 0; i < limit; i++) { vm.prank(proposer); - assertTrue(gerousia.vote(proposal)); + assertTrue(governanceProposer.vote(proposal)); vm.warp( Timestamp.unwrap(leonidas.getTimestampForSlot(leonidas.getCurrentSlot() + Slot.wrap(1))) ); } vm.warp( Timestamp.unwrap( - leonidas.getTimestampForSlot(leonidas.getCurrentSlot() + Slot.wrap(gerousia.M())) + leonidas.getTimestampForSlot(leonidas.getCurrentSlot() + Slot.wrap(governanceProposer.M())) ) ); @@ -195,33 +207,37 @@ contract PushProposalTest is GerousiaBase { { // it revert - // When using a new registry we change the gerousia's interpetation of time :O + // When using a new registry we change the governanceProposer's interpetation of time :O Leonidas freshInstance = new Leonidas(address(this)); - vm.prank(registry.getApella()); + vm.prank(registry.getGovernance()); registry.upgrade(address(freshInstance)); // The old is still there, just not executable. - (, IPayload leader, bool executed) = gerousia.rounds(address(leonidas), 1); + (, IPayload leader, bool executed) = governanceProposer.rounds(address(leonidas), 1); assertFalse(executed); assertEq(address(leader), address(proposal)); // As time is perceived differently, round 1 is currently in the future - vm.expectRevert(abi.encodeWithSelector(Errors.Gerousia__CanOnlyPushProposalInPast.selector)); - gerousia.pushProposal(1); + vm.expectRevert( + abi.encodeWithSelector(Errors.GovernanceProposer__CanOnlyPushProposalInPast.selector) + ); + governanceProposer.pushProposal(1); // Jump 2 rounds, since we are currently in round 0 vm.warp( Timestamp.unwrap( freshInstance.getTimestampForSlot( - freshInstance.getCurrentSlot() + Slot.wrap(2 * gerousia.M()) + freshInstance.getCurrentSlot() + Slot.wrap(2 * governanceProposer.M()) ) ) ); - vm.expectRevert(abi.encodeWithSelector(Errors.Gerousia__ProposalCannotBeAddressZero.selector)); - gerousia.pushProposal(1); + vm.expectRevert( + abi.encodeWithSelector(Errors.GovernanceProposer__ProposalCannotBeAddressZero.selector) + ); + governanceProposer.pushProposal(1); } - function test_GivenApellaCallReturnFalse(uint256 _yeas) + function test_GivenGovernanceCallReturnFalse(uint256 _yeas) external givenCanonicalInstanceHoldCode whenRoundInPast @@ -231,14 +247,16 @@ contract PushProposalTest is GerousiaBase { givenSufficientYea(_yeas) { // it revert - FalsyApella falsy = new FalsyApella(); - vm.etch(address(apella), address(falsy).code); + FalsyGovernance falsy = new FalsyGovernance(); + vm.etch(address(governance), address(falsy).code); - vm.expectRevert(abi.encodeWithSelector(Errors.Gerousia__FailedToPropose.selector, proposal)); - gerousia.pushProposal(1); + vm.expectRevert( + abi.encodeWithSelector(Errors.GovernanceProposer__FailedToPropose.selector, proposal) + ); + governanceProposer.pushProposal(1); } - function test_GivenApellaCallFails(uint256 _yeas) + function test_GivenGovernanceCallFails(uint256 _yeas) external givenCanonicalInstanceHoldCode whenRoundInPast @@ -248,14 +266,14 @@ contract PushProposalTest is GerousiaBase { givenSufficientYea(_yeas) { // it revert - FaultyApella faulty = new FaultyApella(); - vm.etch(address(apella), address(faulty).code); + FaultyGovernance faulty = new FaultyGovernance(); + vm.etch(address(governance), address(faulty).code); - vm.expectRevert(abi.encodeWithSelector(FaultyApella.Faulty.selector)); - gerousia.pushProposal(1); + vm.expectRevert(abi.encodeWithSelector(FaultyGovernance.Faulty.selector)); + governanceProposer.pushProposal(1); } - function test_GivenApellaCallSucceeds(uint256 _yeas) + function test_GivenGovernanceCallSucceeds(uint256 _yeas) external givenCanonicalInstanceHoldCode whenRoundInPast @@ -267,10 +285,10 @@ contract PushProposalTest is GerousiaBase { // it update executed to true // it emits {ProposalPushed} event // it return true - vm.expectEmit(true, true, true, true, address(gerousia)); - emit IGerousia.ProposalPushed(proposal, 1); - assertTrue(gerousia.pushProposal(1)); - (, IPayload leader, bool executed) = gerousia.rounds(address(leonidas), 1); + vm.expectEmit(true, true, true, true, address(governanceProposer)); + emit IGovernanceProposer.ProposalPushed(proposal, 1); + assertTrue(governanceProposer.pushProposal(1)); + (, IPayload leader, bool executed) = governanceProposer.rounds(address(leonidas), 1); assertTrue(executed); assertEq(address(leader), address(proposal)); } diff --git a/l1-contracts/test/governance/gerousia/pushProposal.tree b/l1-contracts/test/governance/governance-proposer/pushProposal.tree similarity index 86% rename from l1-contracts/test/governance/gerousia/pushProposal.tree rename to l1-contracts/test/governance/governance-proposer/pushProposal.tree index c201b0ce67a6..2188b588fdeb 100644 --- a/l1-contracts/test/governance/gerousia/pushProposal.tree +++ b/l1-contracts/test/governance/governance-proposer/pushProposal.tree @@ -19,11 +19,11 @@ PushProposalTest └── given sufficient yea ├── given new canonical instance │ └── it revert - ├── given apella call return false + ├── given governance call return false │ └── it revert - ├── given apella call fails + ├── given governance call fails │ └── it revert - └── given apella call succeeds + └── given governance call succeeds ├── it update executed to true ├── it emits {ProposalPushed} event └── it return true \ No newline at end of file diff --git a/l1-contracts/test/governance/gerousia/vote.t.sol b/l1-contracts/test/governance/governance-proposer/vote.t.sol similarity index 61% rename from l1-contracts/test/governance/gerousia/vote.t.sol rename to l1-contracts/test/governance/governance-proposer/vote.t.sol index 023d58e734c8..7102d2f10b3e 100644 --- a/l1-contracts/test/governance/gerousia/vote.t.sol +++ b/l1-contracts/test/governance/governance-proposer/vote.t.sol @@ -2,13 +2,13 @@ pragma solidity >=0.8.27; import {IPayload} from "@aztec/governance/interfaces/IPayload.sol"; -import {IGerousia} from "@aztec/governance/interfaces/IGerousia.sol"; -import {GerousiaBase} from "./Base.t.sol"; +import {IGovernanceProposer} from "@aztec/governance/interfaces/IGovernanceProposer.sol"; +import {GovernanceProposerBase} from "./Base.t.sol"; import {Leonidas} from "@aztec/core/Leonidas.sol"; import {Errors} from "@aztec/governance/libraries/Errors.sol"; import {Slot, SlotLib, Timestamp} from "@aztec/core/libraries/TimeMath.sol"; -contract VoteTest is GerousiaBase { +contract VoteTest is GovernanceProposerBase { using SlotLib for Slot; IPayload internal proposal = IPayload(address(0xdeadbeef)); @@ -17,8 +17,10 @@ contract VoteTest is GerousiaBase { function test_WhenProposalHoldNoCode() external { // it revert - vm.expectRevert(abi.encodeWithSelector(Errors.Gerousia__ProposalHaveNoCode.selector, proposal)); - gerousia.vote(proposal); + vm.expectRevert( + abi.encodeWithSelector(Errors.GovernanceProposer__ProposalHaveNoCode.selector, proposal) + ); + governanceProposer.vote(proposal); } modifier whenProposalHoldCode() { @@ -29,14 +31,16 @@ contract VoteTest is GerousiaBase { function test_GivenCanonicalRollupHoldNoCode() external whenProposalHoldCode { // it revert vm.expectRevert( - abi.encodeWithSelector(Errors.Gerousia__InstanceHaveNoCode.selector, address(0xdead)) + abi.encodeWithSelector( + Errors.GovernanceProposer__InstanceHaveNoCode.selector, address(0xdead) + ) ); - gerousia.vote(proposal); + governanceProposer.vote(proposal); } modifier givenCanonicalRollupHoldCode() { leonidas = new Leonidas(address(this)); - vm.prank(registry.getApella()); + vm.prank(registry.getGovernance()); registry.upgrade(address(leonidas)); // We jump into the future since slot 0, will behave as if already voted in @@ -54,12 +58,14 @@ contract VoteTest is GerousiaBase { Slot currentSlot = leonidas.getCurrentSlot(); assertEq(currentSlot.unwrap(), 1); vm.prank(proposer); - gerousia.vote(proposal); + governanceProposer.vote(proposal); vm.expectRevert( - abi.encodeWithSelector(Errors.Gerousia__VoteAlreadyCastForSlot.selector, currentSlot) + abi.encodeWithSelector( + Errors.GovernanceProposer__VoteAlreadyCastForSlot.selector, currentSlot + ) ); - gerousia.vote(proposal); + governanceProposer.vote(proposal); } modifier givenNoVoteAlreadyCastInTheSlot() { @@ -76,9 +82,11 @@ contract VoteTest is GerousiaBase { vm.assume(_proposer != proposer); vm.prank(_proposer); vm.expectRevert( - abi.encodeWithSelector(Errors.Gerousia__OnlyProposerCanVote.selector, _proposer, proposer) + abi.encodeWithSelector( + Errors.GovernanceProposer__OnlyProposerCanVote.selector, _proposer, proposer + ) ); - gerousia.vote(proposal); + governanceProposer.vote(proposal); } modifier whenCallerIsProposer() { @@ -90,14 +98,15 @@ contract VoteTest is GerousiaBase { Timestamp.unwrap(leonidas.getTimestampForSlot(leonidas.getCurrentSlot() + Slot.wrap(1))) ); vm.prank(proposer); - gerousia.vote(proposal); + governanceProposer.vote(proposal); } Slot currentSlot = leonidas.getCurrentSlot(); - uint256 round = gerousia.computeRound(currentSlot); - (Slot lastVote, IPayload leader, bool executed) = gerousia.rounds(address(leonidas), round); + uint256 round = governanceProposer.computeRound(currentSlot); + (Slot lastVote, IPayload leader, bool executed) = + governanceProposer.rounds(address(leonidas), round); assertEq( - gerousia.yeaCount(address(leonidas), round, leader), + governanceProposer.yeaCount(address(leonidas), round, leader), votesOnProposal, "invalid number of votes" ); @@ -126,29 +135,31 @@ contract VoteTest is GerousiaBase { // it returns true Slot leonidasSlot = leonidas.getCurrentSlot(); - uint256 leonidasRound = gerousia.computeRound(leonidasSlot); - uint256 yeaBefore = gerousia.yeaCount(address(leonidas), leonidasRound, proposal); + uint256 leonidasRound = governanceProposer.computeRound(leonidasSlot); + uint256 yeaBefore = governanceProposer.yeaCount(address(leonidas), leonidasRound, proposal); Leonidas freshInstance = new Leonidas(address(this)); - vm.prank(registry.getApella()); + vm.prank(registry.getGovernance()); registry.upgrade(address(freshInstance)); vm.warp(Timestamp.unwrap(freshInstance.getTimestampForSlot(Slot.wrap(1)))); Slot freshSlot = freshInstance.getCurrentSlot(); - uint256 freshRound = gerousia.computeRound(freshSlot); + uint256 freshRound = governanceProposer.computeRound(freshSlot); vm.prank(proposer); - vm.expectEmit(true, true, true, true, address(gerousia)); - emit IGerousia.VoteCast(proposal, freshRound, proposer); - assertTrue(gerousia.vote(proposal)); + vm.expectEmit(true, true, true, true, address(governanceProposer)); + emit IGovernanceProposer.VoteCast(proposal, freshRound, proposer); + assertTrue(governanceProposer.vote(proposal)); // Check the new instance { (Slot lastVote, IPayload leader, bool executed) = - gerousia.rounds(address(freshInstance), freshRound); + governanceProposer.rounds(address(freshInstance), freshRound); assertEq( - gerousia.yeaCount(address(freshInstance), freshRound, leader), 1, "invalid number of votes" + governanceProposer.yeaCount(address(freshInstance), freshRound, leader), + 1, + "invalid number of votes" ); assertFalse(executed); assertEq(address(leader), address(proposal)); @@ -158,9 +169,9 @@ contract VoteTest is GerousiaBase { // The old instance { (Slot lastVote, IPayload leader, bool executed) = - gerousia.rounds(address(leonidas), leonidasRound); + governanceProposer.rounds(address(leonidas), leonidasRound); assertEq( - gerousia.yeaCount(address(leonidas), leonidasRound, proposal), + governanceProposer.yeaCount(address(leonidas), leonidasRound, proposal), yeaBefore, "invalid number of votes" ); @@ -201,18 +212,21 @@ contract VoteTest is GerousiaBase { // it returns true Slot currentSlot = leonidas.getCurrentSlot(); - uint256 round = gerousia.computeRound(currentSlot); + uint256 round = governanceProposer.computeRound(currentSlot); - uint256 yeaBefore = gerousia.yeaCount(address(leonidas), round, proposal); + uint256 yeaBefore = governanceProposer.yeaCount(address(leonidas), round, proposal); vm.prank(proposer); - vm.expectEmit(true, true, true, true, address(gerousia)); - emit IGerousia.VoteCast(proposal, round, proposer); - assertTrue(gerousia.vote(proposal)); + vm.expectEmit(true, true, true, true, address(governanceProposer)); + emit IGovernanceProposer.VoteCast(proposal, round, proposer); + assertTrue(governanceProposer.vote(proposal)); - (Slot lastVote, IPayload leader, bool executed) = gerousia.rounds(address(leonidas), round); + (Slot lastVote, IPayload leader, bool executed) = + governanceProposer.rounds(address(leonidas), round); assertEq( - gerousia.yeaCount(address(leonidas), round, leader), yeaBefore + 1, "invalid number of votes" + governanceProposer.yeaCount(address(leonidas), round, leader), + yeaBefore + 1, + "invalid number of votes" ); assertFalse(executed); assertEq(address(leader), address(proposal)); @@ -232,23 +246,24 @@ contract VoteTest is GerousiaBase { // it returns true Slot currentSlot = leonidas.getCurrentSlot(); - uint256 round = gerousia.computeRound(currentSlot); + uint256 round = governanceProposer.computeRound(currentSlot); - uint256 leaderYeaBefore = gerousia.yeaCount(address(leonidas), round, proposal); + uint256 leaderYeaBefore = governanceProposer.yeaCount(address(leonidas), round, proposal); vm.prank(proposer); - vm.expectEmit(true, true, true, true, address(gerousia)); - emit IGerousia.VoteCast(IPayload(address(leonidas)), round, proposer); - assertTrue(gerousia.vote(IPayload(address(leonidas)))); + vm.expectEmit(true, true, true, true, address(governanceProposer)); + emit IGovernanceProposer.VoteCast(IPayload(address(leonidas)), round, proposer); + assertTrue(governanceProposer.vote(IPayload(address(leonidas)))); - (Slot lastVote, IPayload leader, bool executed) = gerousia.rounds(address(leonidas), round); + (Slot lastVote, IPayload leader, bool executed) = + governanceProposer.rounds(address(leonidas), round); assertEq( - gerousia.yeaCount(address(leonidas), round, leader), + governanceProposer.yeaCount(address(leonidas), round, leader), leaderYeaBefore, "invalid number of votes" ); assertEq( - gerousia.yeaCount(address(leonidas), round, IPayload(address(leonidas))), + governanceProposer.yeaCount(address(leonidas), round, IPayload(address(leonidas))), 1, "invalid number of votes" ); @@ -271,15 +286,15 @@ contract VoteTest is GerousiaBase { // it returns true Slot currentSlot = leonidas.getCurrentSlot(); - uint256 round = gerousia.computeRound(currentSlot); + uint256 round = governanceProposer.computeRound(currentSlot); - uint256 leaderYeaBefore = gerousia.yeaCount(address(leonidas), round, proposal); + uint256 leaderYeaBefore = governanceProposer.yeaCount(address(leonidas), round, proposal); for (uint256 i = 0; i < leaderYeaBefore + 1; i++) { vm.prank(proposer); - vm.expectEmit(true, true, true, true, address(gerousia)); - emit IGerousia.VoteCast(IPayload(address(leonidas)), round, proposer); - assertTrue(gerousia.vote(IPayload(address(leonidas)))); + vm.expectEmit(true, true, true, true, address(governanceProposer)); + emit IGovernanceProposer.VoteCast(IPayload(address(leonidas)), round, proposer); + assertTrue(governanceProposer.vote(IPayload(address(leonidas)))); vm.warp( Timestamp.unwrap(leonidas.getTimestampForSlot(leonidas.getCurrentSlot() + Slot.wrap(1))) @@ -287,16 +302,17 @@ contract VoteTest is GerousiaBase { } { - (Slot lastVote, IPayload leader, bool executed) = gerousia.rounds(address(leonidas), round); + (Slot lastVote, IPayload leader, bool executed) = + governanceProposer.rounds(address(leonidas), round); assertEq( - gerousia.yeaCount(address(leonidas), round, IPayload(address(leonidas))), + governanceProposer.yeaCount(address(leonidas), round, IPayload(address(leonidas))), leaderYeaBefore + 1, "invalid number of votes" ); assertFalse(executed); assertEq(address(leader), address(leonidas)); assertEq( - gerousia.yeaCount(address(leonidas), round, proposal), + governanceProposer.yeaCount(address(leonidas), round, proposal), leaderYeaBefore, "invalid number of votes" ); diff --git a/l1-contracts/test/governance/gerousia/vote.tree b/l1-contracts/test/governance/governance-proposer/vote.tree similarity index 100% rename from l1-contracts/test/governance/gerousia/vote.tree rename to l1-contracts/test/governance/governance-proposer/vote.tree diff --git a/l1-contracts/test/governance/apella/TestPayloads.sol b/l1-contracts/test/governance/governance/TestPayloads.sol similarity index 91% rename from l1-contracts/test/governance/apella/TestPayloads.sol rename to l1-contracts/test/governance/governance/TestPayloads.sol index 1d541015ab02..db33d41aa54d 100644 --- a/l1-contracts/test/governance/apella/TestPayloads.sol +++ b/l1-contracts/test/governance/governance/TestPayloads.sol @@ -13,17 +13,17 @@ contract EmptyPayload is IPayload { contract CallAssetPayload is IPayload { IMintableERC20 internal immutable ASSET; address internal immutable OWNER; - address internal immutable APELLA; + address internal immutable GOVERNANCE; - constructor(IMintableERC20 _asset, address _apella) { + constructor(IMintableERC20 _asset, address _governance) { ASSET = _asset; OWNER = msg.sender; - APELLA = _apella; + GOVERNANCE = _governance; } function getActions() external view override(IPayload) returns (IPayload.Action[] memory) { IPayload.Action[] memory res = new IPayload.Action[](1); - uint256 balance = ASSET.balanceOf(APELLA); + uint256 balance = ASSET.balanceOf(GOVERNANCE); res[0] = Action({ target: address(ASSET), diff --git a/l1-contracts/test/governance/apella/base.t.sol b/l1-contracts/test/governance/governance/base.t.sol similarity index 70% rename from l1-contracts/test/governance/apella/base.t.sol rename to l1-contracts/test/governance/governance/base.t.sol index 105f948cc918..28e51b0e934b 100644 --- a/l1-contracts/test/governance/apella/base.t.sol +++ b/l1-contracts/test/governance/governance/base.t.sol @@ -2,8 +2,8 @@ pragma solidity >=0.8.27; import {TestBase} from "@test/base/Base.sol"; -import {Apella} from "@aztec/governance/Apella.sol"; -import {Gerousia} from "@aztec/governance/Gerousia.sol"; +import {Governance} from "@aztec/governance/Governance.sol"; +import {GovernanceProposer} from "@aztec/governance/GovernanceProposer.sol"; import {Registry} from "@aztec/governance/Registry.sol"; import {DataStructures} from "@aztec/governance/libraries/DataStructures.sol"; import {IMintableERC20} from "@aztec/governance/interfaces/IMintableERC20.sol"; @@ -21,13 +21,13 @@ import { CallAssetPayload, UpgradePayload, CallRevertingPayload, EmptyPayload } from "./TestPayloads.sol"; -contract ApellaBase is TestBase { +contract GovernanceBase is TestBase { using ProposalLib for DataStructures.Proposal; IMintableERC20 internal token; Registry internal registry; - Apella internal apella; - Gerousia internal gerousia; + Governance internal governance; + GovernanceProposer internal governanceProposer; mapping(bytes32 => DataStructures.Proposal) internal proposals; mapping(bytes32 => uint256) internal proposalIds; @@ -38,45 +38,45 @@ contract ApellaBase is TestBase { token = IMintableERC20(address(new TestERC20())); registry = new Registry(address(this)); - gerousia = new Gerousia(registry, 677, 1000); + governanceProposer = new GovernanceProposer(registry, 677, 1000); - apella = new Apella(token, address(gerousia)); - registry.transferOwnership(address(apella)); + governance = new Governance(token, address(governanceProposer)); + registry.transferOwnership(address(governance)); { - CallAssetPayload payload = new CallAssetPayload(token, address(apella)); - vm.prank(address(gerousia)); - assertTrue(apella.propose(payload)); + CallAssetPayload payload = new CallAssetPayload(token, address(governance)); + vm.prank(address(governanceProposer)); + assertTrue(governance.propose(payload)); - proposalIds["call_asset"] = apella.proposalCount() - 1; - proposals["call_asset"] = apella.getProposal(proposalIds["call_asset"]); + proposalIds["call_asset"] = governance.proposalCount() - 1; + proposals["call_asset"] = governance.getProposal(proposalIds["call_asset"]); } { UpgradePayload payload = new UpgradePayload(registry); - vm.prank(address(gerousia)); - assertTrue(apella.propose(payload)); + vm.prank(address(governanceProposer)); + assertTrue(governance.propose(payload)); - proposalIds["upgrade"] = apella.proposalCount() - 1; - proposals["upgrade"] = apella.getProposal(proposalIds["upgrade"]); + proposalIds["upgrade"] = governance.proposalCount() - 1; + proposals["upgrade"] = governance.getProposal(proposalIds["upgrade"]); } { CallRevertingPayload payload = new CallRevertingPayload(); - vm.prank(address(gerousia)); - assertTrue(apella.propose(payload)); + vm.prank(address(governanceProposer)); + assertTrue(governance.propose(payload)); - proposalIds["revert"] = apella.proposalCount() - 1; - proposals["revert"] = apella.getProposal(proposalIds["revert"]); + proposalIds["revert"] = governance.proposalCount() - 1; + proposals["revert"] = governance.getProposal(proposalIds["revert"]); } { EmptyPayload payload = new EmptyPayload(); - vm.prank(address(gerousia)); - assertTrue(apella.propose(payload)); + vm.prank(address(governanceProposer)); + assertTrue(governance.propose(payload)); - proposalIds["empty"] = apella.proposalCount() - 1; - proposals["empty"] = apella.getProposal(proposalIds["empty"]); + proposalIds["empty"] = governance.proposalCount() - 1; + proposals["empty"] = governance.getProposal(proposalIds["empty"]); } } @@ -92,17 +92,17 @@ contract ApellaBase is TestBase { // @note We jump to the point where it becomes active vm.warp(Timestamp.unwrap(proposal.pendingThrough()) + 1); - assertTrue(apella.getProposalState(proposalId) == DataStructures.ProposalState.Active); + assertTrue(governance.getProposalState(proposalId) == DataStructures.ProposalState.Active); } - function _stateDropped(bytes32 _proposalName, address _gerousia) internal { + function _stateDropped(bytes32 _proposalName, address _governanceProposer) internal { proposal = proposals[_proposalName]; proposalId = proposalIds[_proposalName]; - vm.assume(_gerousia != proposal.gerousia); + vm.assume(_governanceProposer != proposal.governanceProposer); - vm.prank(address(apella)); - apella.updateGerousia(_gerousia); + vm.prank(address(governance)); + governance.updateGovernanceProposer(_governanceProposer); } function _stateRejected(bytes32 _proposalName) internal { @@ -113,7 +113,7 @@ contract ApellaBase is TestBase { vm.warp(Timestamp.unwrap(proposal.activeThrough()) + 1); - assertTrue(apella.getProposalState(proposalId) == DataStructures.ProposalState.Rejected); + assertTrue(governance.getProposalState(proposalId) == DataStructures.ProposalState.Rejected); } function _stateQueued( @@ -138,21 +138,21 @@ contract ApellaBase is TestBase { token.mint(_voter, totalPower); vm.startPrank(_voter); - token.approve(address(apella), totalPower); - apella.deposit(_voter, totalPower); + token.approve(address(governance), totalPower); + governance.deposit(_voter, totalPower); vm.stopPrank(); _stateActive(_proposalName); vm.startPrank(_voter); - apella.vote(proposalId, yeas, true); - apella.vote(proposalId, votesCast - yeas, false); + governance.vote(proposalId, yeas, true); + governance.vote(proposalId, votesCast - yeas, false); vm.stopPrank(); vm.warp(Timestamp.unwrap(proposal.activeThrough()) + 1); assertEq( - apella.getProposalState(proposalId), DataStructures.ProposalState.Queued, "invalid state" + governance.getProposalState(proposalId), DataStructures.ProposalState.Queued, "invalid state" ); } @@ -171,7 +171,9 @@ contract ApellaBase is TestBase { vm.warp(Timestamp.unwrap(proposal.queuedThrough()) + 1); assertEq( - apella.getProposalState(proposalId), DataStructures.ProposalState.Executable, "invalid state" + governance.getProposalState(proposalId), + DataStructures.ProposalState.Executable, + "invalid state" ); } @@ -190,7 +192,7 @@ contract ApellaBase is TestBase { vm.warp(Timestamp.unwrap(proposal.executableThrough()) + 1); assertEq( - apella.getProposalState(proposalId), DataStructures.ProposalState.Expired, "invalid state" + governance.getProposalState(proposalId), DataStructures.ProposalState.Expired, "invalid state" ); } diff --git a/l1-contracts/test/governance/apella/deposit.t.sol b/l1-contracts/test/governance/governance/deposit.t.sol similarity index 64% rename from l1-contracts/test/governance/apella/deposit.t.sol rename to l1-contracts/test/governance/governance/deposit.t.sol index fb1edfc1a063..6089139a9d56 100644 --- a/l1-contracts/test/governance/apella/deposit.t.sol +++ b/l1-contracts/test/governance/governance/deposit.t.sol @@ -1,12 +1,12 @@ // SPDX-License-Identifier: UNLICENSED pragma solidity >=0.8.27; -import {ApellaBase} from "./base.t.sol"; -import {IApella} from "@aztec/governance/interfaces/IApella.sol"; +import {GovernanceBase} from "./base.t.sol"; +import {IGovernance} from "@aztec/governance/interfaces/IGovernance.sol"; import {IERC20Errors} from "@oz/interfaces/draft-IERC6093.sol"; import {Timestamp} from "@aztec/core/libraries/TimeMath.sol"; -contract DepositTest is ApellaBase { +contract DepositTest is GovernanceBase { uint256 internal constant DEPOSIT_COUNT = 8; mapping(address => uint256) internal sums; @@ -16,10 +16,10 @@ contract DepositTest is ApellaBase { uint256 amount = bound(_amount, 1, type(uint256).max); vm.expectRevert( abi.encodeWithSelector( - IERC20Errors.ERC20InsufficientAllowance.selector, address(apella), 0, amount + IERC20Errors.ERC20InsufficientAllowance.selector, address(governance), 0, amount ) ); - apella.deposit(address(this), amount); + governance.deposit(address(this), amount); } modifier whenCallerHaveSufficientAllowance() { @@ -33,14 +33,14 @@ contract DepositTest is ApellaBase { // it revert uint256 amount = bound(_amount, 1, type(uint256).max); - token.approve(address(apella), amount); + token.approve(address(governance), amount); vm.expectRevert( abi.encodeWithSelector( IERC20Errors.ERC20InsufficientBalance.selector, address(this), 0, amount ) ); - apella.deposit(address(this), amount); + governance.deposit(address(this), amount); } function test_WhenCallerHaveSufficientFunds( @@ -60,28 +60,29 @@ contract DepositTest is ApellaBase { uint256 timeJump = bound(_timejumps[i], 1, type(uint32).max); token.mint(address(this), amount); - token.approve(address(apella), amount); + token.approve(address(governance), amount); assertEq(token.balanceOf(address(this)), amount); - assertEq(token.allowance(address(this), address(apella)), amount); + assertEq(token.allowance(address(this), address(governance)), amount); sums[onBehalfOf] += amount; sum += amount; vm.warp(block.timestamp + timeJump); - vm.expectEmit(true, true, true, true, address(apella)); - emit IApella.Deposit(address(this), onBehalfOf, amount); - apella.deposit(onBehalfOf, amount); + vm.expectEmit(true, true, true, true, address(governance)); + emit IGovernance.Deposit(address(this), onBehalfOf, amount); + governance.deposit(onBehalfOf, amount); assertEq( - apella.powerAt(onBehalfOf, Timestamp.wrap(block.timestamp - 1)), sums[onBehalfOf] - amount + governance.powerAt(onBehalfOf, Timestamp.wrap(block.timestamp - 1)), + sums[onBehalfOf] - amount ); - assertEq(apella.powerAt(onBehalfOf, Timestamp.wrap(block.timestamp)), sums[onBehalfOf]); - assertEq(apella.totalPowerAt(Timestamp.wrap(block.timestamp - 1)), sum - amount); - assertEq(apella.totalPowerAt(Timestamp.wrap(block.timestamp)), sum); + assertEq(governance.powerAt(onBehalfOf, Timestamp.wrap(block.timestamp)), sums[onBehalfOf]); + assertEq(governance.totalPowerAt(Timestamp.wrap(block.timestamp - 1)), sum - amount); + assertEq(governance.totalPowerAt(Timestamp.wrap(block.timestamp)), sum); assertEq(token.balanceOf(address(this)), 0); - assertEq(token.allowance(address(this), address(apella)), 0); + assertEq(token.allowance(address(this), address(governance)), 0); } } } diff --git a/l1-contracts/test/governance/apella/deposit.tree b/l1-contracts/test/governance/governance/deposit.tree similarity index 100% rename from l1-contracts/test/governance/apella/deposit.tree rename to l1-contracts/test/governance/governance/deposit.tree diff --git a/l1-contracts/test/governance/apella/dropProposal.t.sol b/l1-contracts/test/governance/governance/dropProposal.t.sol similarity index 50% rename from l1-contracts/test/governance/apella/dropProposal.t.sol rename to l1-contracts/test/governance/governance/dropProposal.t.sol index 4cb9794547e0..c93269aded22 100644 --- a/l1-contracts/test/governance/apella/dropProposal.t.sol +++ b/l1-contracts/test/governance/governance/dropProposal.t.sol @@ -1,25 +1,25 @@ // SPDX-License-Identifier: UNLICENSED pragma solidity >=0.8.27; -import {ApellaBase} from "./base.t.sol"; +import {GovernanceBase} from "./base.t.sol"; import {DataStructures} from "@aztec/governance/libraries/DataStructures.sol"; import {Errors} from "@aztec/governance/libraries/Errors.sol"; -contract DropProposalTest is ApellaBase { +contract DropProposalTest is GovernanceBase { modifier givenProposalIsStable() { _; } - function test_GivenProposalIsDropped(address _gerousia) external givenProposalIsStable { + function test_GivenProposalIsDropped(address _governanceProposer) external givenProposalIsStable { // it revert - _stateDropped("empty", _gerousia); - assertEq(apella.getProposal(proposalId).state, DataStructures.ProposalState.Pending); - assertEq(apella.getProposalState(proposalId), DataStructures.ProposalState.Dropped); - assertTrue(apella.dropProposal(proposalId)); - assertEq(apella.getProposal(proposalId).state, DataStructures.ProposalState.Dropped); - - vm.expectRevert(abi.encodeWithSelector(Errors.Apella__ProposalAlreadyDropped.selector)); - apella.dropProposal(proposalId); + _stateDropped("empty", _governanceProposer); + assertEq(governance.getProposal(proposalId).state, DataStructures.ProposalState.Pending); + assertEq(governance.getProposalState(proposalId), DataStructures.ProposalState.Dropped); + assertTrue(governance.dropProposal(proposalId)); + assertEq(governance.getProposal(proposalId).state, DataStructures.ProposalState.Dropped); + + vm.expectRevert(abi.encodeWithSelector(Errors.Governance__ProposalAlreadyDropped.selector)); + governance.dropProposal(proposalId); } function test_GivenProposalIsExecuted( @@ -30,11 +30,11 @@ contract DropProposalTest is ApellaBase { ) external givenProposalIsStable { // it revert _stateExecutable("empty", _voter, _totalPower, _votesCast, _yeas); - assertTrue(apella.execute(proposalId)); - assertEq(apella.getProposal(proposalId).state, DataStructures.ProposalState.Executed); + assertTrue(governance.execute(proposalId)); + assertEq(governance.getProposal(proposalId).state, DataStructures.ProposalState.Executed); - vm.expectRevert(abi.encodeWithSelector(Errors.Apella__ProposalCannotBeDropped.selector)); - apella.dropProposal(proposalId); + vm.expectRevert(abi.encodeWithSelector(Errors.Governance__ProposalCannotBeDropped.selector)); + governance.dropProposal(proposalId); } modifier givenProposalIsUnstable() { @@ -43,8 +43,8 @@ contract DropProposalTest is ApellaBase { modifier whenGetProposalStateIsNotDropped() { _; - vm.expectRevert(abi.encodeWithSelector(Errors.Apella__ProposalCannotBeDropped.selector)); - apella.dropProposal(proposalId); + vm.expectRevert(abi.encodeWithSelector(Errors.Governance__ProposalCannotBeDropped.selector)); + governance.dropProposal(proposalId); } function test_WhenGetProposalStateIsPending() @@ -54,7 +54,7 @@ contract DropProposalTest is ApellaBase { { // it revert _statePending("empty"); - assertEq(apella.getProposalState(proposalId), DataStructures.ProposalState.Pending); + assertEq(governance.getProposalState(proposalId), DataStructures.ProposalState.Pending); } function test_WhenGetProposalStateIsActive() @@ -64,7 +64,7 @@ contract DropProposalTest is ApellaBase { { // it revert _stateActive("empty"); - assertEq(apella.getProposalState(proposalId), DataStructures.ProposalState.Active); + assertEq(governance.getProposalState(proposalId), DataStructures.ProposalState.Active); } function test_WhenGetProposalStateIsQueued( @@ -75,7 +75,7 @@ contract DropProposalTest is ApellaBase { ) external givenProposalIsUnstable whenGetProposalStateIsNotDropped { // it revert _stateQueued("empty", _voter, _totalPower, _votesCast, _yeas); - assertEq(apella.getProposalState(proposalId), DataStructures.ProposalState.Queued); + assertEq(governance.getProposalState(proposalId), DataStructures.ProposalState.Queued); } function test_WhenGetProposalStateIsExecutable( @@ -86,7 +86,7 @@ contract DropProposalTest is ApellaBase { ) external givenProposalIsUnstable whenGetProposalStateIsNotDropped { // it revert _stateExecutable("empty", _voter, _totalPower, _votesCast, _yeas); - assertEq(apella.getProposalState(proposalId), DataStructures.ProposalState.Executable); + assertEq(governance.getProposalState(proposalId), DataStructures.ProposalState.Executable); } function test_WhenGetProposalStateIsRejected() @@ -96,7 +96,7 @@ contract DropProposalTest is ApellaBase { { // it revert _stateRejected("empty"); - assertEq(apella.getProposalState(proposalId), DataStructures.ProposalState.Rejected); + assertEq(governance.getProposalState(proposalId), DataStructures.ProposalState.Rejected); } function test_WhenGetProposalStateIsExecuted( @@ -107,8 +107,8 @@ contract DropProposalTest is ApellaBase { ) external givenProposalIsUnstable whenGetProposalStateIsNotDropped { // it revert _stateExecutable("empty", _voter, _totalPower, _votesCast, _yeas); - assertTrue(apella.execute(proposalId)); - assertEq(apella.getProposalState(proposalId), DataStructures.ProposalState.Executed); + assertTrue(governance.execute(proposalId)); + assertEq(governance.getProposalState(proposalId), DataStructures.ProposalState.Executed); } function test_WhenGetProposalStateIsExpired( @@ -119,18 +119,21 @@ contract DropProposalTest is ApellaBase { ) external givenProposalIsUnstable whenGetProposalStateIsNotDropped { // it revert _stateExpired("empty", _voter, _totalPower, _votesCast, _yeas); - assertEq(apella.getProposalState(proposalId), DataStructures.ProposalState.Expired); + assertEq(governance.getProposalState(proposalId), DataStructures.ProposalState.Expired); } - function test_WhenGetProposalStateIsDropped(address _gerousia) external givenProposalIsUnstable { + function test_WhenGetProposalStateIsDropped(address _governanceProposer) + external + givenProposalIsUnstable + { // it updates state to Dropped // it return true - _stateDropped("empty", _gerousia); - assertEq(apella.getProposal(proposalId).state, DataStructures.ProposalState.Pending); - assertEq(apella.getProposalState(proposalId), DataStructures.ProposalState.Dropped); - assertTrue(apella.dropProposal(proposalId)); - assertEq(apella.getProposal(proposalId).state, DataStructures.ProposalState.Dropped); - assertEq(apella.getProposalState(proposalId), DataStructures.ProposalState.Dropped); + _stateDropped("empty", _governanceProposer); + assertEq(governance.getProposal(proposalId).state, DataStructures.ProposalState.Pending); + assertEq(governance.getProposalState(proposalId), DataStructures.ProposalState.Dropped); + assertTrue(governance.dropProposal(proposalId)); + assertEq(governance.getProposal(proposalId).state, DataStructures.ProposalState.Dropped); + assertEq(governance.getProposalState(proposalId), DataStructures.ProposalState.Dropped); } } diff --git a/l1-contracts/test/governance/apella/dropProposal.tree b/l1-contracts/test/governance/governance/dropProposal.tree similarity index 100% rename from l1-contracts/test/governance/apella/dropProposal.tree rename to l1-contracts/test/governance/governance/dropProposal.tree diff --git a/l1-contracts/test/governance/apella/execute.t.sol b/l1-contracts/test/governance/governance/execute.t.sol similarity index 65% rename from l1-contracts/test/governance/apella/execute.t.sol rename to l1-contracts/test/governance/governance/execute.t.sol index 10fe58a4e74f..200ef4562bc2 100644 --- a/l1-contracts/test/governance/apella/execute.t.sol +++ b/l1-contracts/test/governance/governance/execute.t.sol @@ -1,10 +1,10 @@ // SPDX-License-Identifier: UNLICENSED pragma solidity >=0.8.27; -import {ApellaBase} from "./base.t.sol"; +import {GovernanceBase} from "./base.t.sol"; import {Errors} from "@aztec/governance/libraries/Errors.sol"; import {DataStructures} from "@aztec/governance/libraries/DataStructures.sol"; -import {IApella} from "@aztec/governance/interfaces/IApella.sol"; +import {IGovernance} from "@aztec/governance/interfaces/IGovernance.sol"; import { ProposalLib, VoteTabulationReturn, @@ -13,27 +13,27 @@ import { import {CallAssetPayload, UpgradePayload, CallRevertingPayload} from "./TestPayloads.sol"; -contract ExecuteTest is ApellaBase { +contract ExecuteTest is GovernanceBase { using ProposalLib for DataStructures.Proposal; uint256 internal depositPower; modifier givenStateIsNotExecutable() { _; - vm.expectRevert(abi.encodeWithSelector(Errors.Apella__ProposalNotExecutable.selector)); - apella.execute(proposalId); + vm.expectRevert(abi.encodeWithSelector(Errors.Governance__ProposalNotExecutable.selector)); + governance.execute(proposalId); } function test_GivenStateIsPending() external givenStateIsNotExecutable { // it revert _statePending("empty"); - assertEq(apella.getProposalState(proposalId), DataStructures.ProposalState.Pending); + assertEq(governance.getProposalState(proposalId), DataStructures.ProposalState.Pending); } function test_GivenStateIsActive() external givenStateIsNotExecutable { // it revert _stateActive("empty"); - assertEq(apella.getProposalState(proposalId), DataStructures.ProposalState.Active); + assertEq(governance.getProposalState(proposalId), DataStructures.ProposalState.Active); } function test_GivenStateIsQueued( @@ -44,19 +44,19 @@ contract ExecuteTest is ApellaBase { ) external givenStateIsNotExecutable { // it revert _stateQueued("empty", _voter, _totalPower, _votesCast, _yeas); - assertEq(apella.getProposalState(proposalId), DataStructures.ProposalState.Queued); + assertEq(governance.getProposalState(proposalId), DataStructures.ProposalState.Queued); } function test_GivenStateIsRejected() external givenStateIsNotExecutable { // it revert _stateRejected("empty"); - assertEq(apella.getProposalState(proposalId), DataStructures.ProposalState.Rejected); + assertEq(governance.getProposalState(proposalId), DataStructures.ProposalState.Rejected); } - function test_GivenStateIsDropped(address _gerousia) external givenStateIsNotExecutable { + function test_GivenStateIsDropped(address _governanceProposer) external givenStateIsNotExecutable { // it revert - _stateDropped("empty", _gerousia); - assertEq(apella.getProposalState(proposalId), DataStructures.ProposalState.Dropped); + _stateDropped("empty", _governanceProposer); + assertEq(governance.getProposalState(proposalId), DataStructures.ProposalState.Dropped); } function test_GivenStateIsExecuted( @@ -67,8 +67,8 @@ contract ExecuteTest is ApellaBase { ) external givenStateIsNotExecutable { // it revert _stateExecutable("empty", _voter, _totalPower, _votesCast, _yeas); - assertTrue(apella.execute(proposalId)); - assertEq(apella.getProposalState(proposalId), DataStructures.ProposalState.Executed); + assertTrue(governance.execute(proposalId)); + assertEq(governance.getProposalState(proposalId), DataStructures.ProposalState.Executed); } function test_GivenStateIsExpired( @@ -79,7 +79,7 @@ contract ExecuteTest is ApellaBase { ) external givenStateIsNotExecutable { // it revert _stateExpired("empty", _voter, _totalPower, _votesCast, _yeas); - assertEq(apella.getProposalState(proposalId), DataStructures.ProposalState.Expired); + assertEq(governance.getProposalState(proposalId), DataStructures.ProposalState.Expired); } modifier givenStateIsExecutable( @@ -90,7 +90,7 @@ contract ExecuteTest is ApellaBase { bytes32 _proposalName ) { _stateExecutable(_proposalName, _voter, _totalPower, _votesCast, _yeas); - assertEq(apella.getProposalState(proposalId), DataStructures.ProposalState.Executable); + assertEq(governance.getProposalState(proposalId), DataStructures.ProposalState.Executable); _; } @@ -102,8 +102,8 @@ contract ExecuteTest is ApellaBase { ) external givenStateIsExecutable(_voter, _totalPower, _votesCast, _yeas, "call_asset") { // it revert - vm.expectRevert(abi.encodeWithSelector(Errors.Apella__CannotCallAsset.selector)); - apella.execute(proposalId); + vm.expectRevert(abi.encodeWithSelector(Errors.Governance__CannotCallAsset.selector)); + governance.execute(proposalId); } modifier givenPayloadDontCallAsset() { @@ -124,11 +124,11 @@ contract ExecuteTest is ApellaBase { vm.expectRevert( abi.encodeWithSelector( - Errors.Apella__CallFailed.selector, + Errors.Governance__CallFailed.selector, address(CallRevertingPayload(address(proposal.payload)).TARGET()) ) ); - apella.execute(proposalId); + governance.execute(proposalId); } function test_GivenAllPayloadCallSucceeds( @@ -146,13 +146,13 @@ contract ExecuteTest is ApellaBase { // it emits {ProposalExecuted} event // it return true - vm.expectEmit(true, true, true, true, address(apella)); - emit IApella.ProposalExecuted(proposalId); - assertTrue(apella.execute(proposalId)); + vm.expectEmit(true, true, true, true, address(governance)); + emit IGovernance.ProposalExecuted(proposalId); + assertTrue(governance.execute(proposalId)); - proposal = apella.getProposal(proposalId); + proposal = governance.getProposal(proposalId); - assertEq(apella.getProposalState(proposalId), DataStructures.ProposalState.Executed); + assertEq(governance.getProposalState(proposalId), DataStructures.ProposalState.Executed); assertEq(proposal.state, DataStructures.ProposalState.Executed); address rollup = registry.getRollup(); assertEq(rollup, UpgradePayload(address(proposal.payload)).NEW_ROLLUP()); diff --git a/l1-contracts/test/governance/apella/execute.tree b/l1-contracts/test/governance/governance/execute.tree similarity index 100% rename from l1-contracts/test/governance/apella/execute.tree rename to l1-contracts/test/governance/governance/execute.tree diff --git a/l1-contracts/test/governance/apella/finaliseWithdraw.t.sol b/l1-contracts/test/governance/governance/finaliseWithdraw.t.sol similarity index 72% rename from l1-contracts/test/governance/apella/finaliseWithdraw.t.sol rename to l1-contracts/test/governance/governance/finaliseWithdraw.t.sol index f4ae280fee3e..9d9b747467f8 100644 --- a/l1-contracts/test/governance/apella/finaliseWithdraw.t.sol +++ b/l1-contracts/test/governance/governance/finaliseWithdraw.t.sol @@ -1,15 +1,15 @@ // SPDX-License-Identifier: UNLICENSED pragma solidity >=0.8.27; -import {ApellaBase} from "./base.t.sol"; -import {IApella} from "@aztec/governance/interfaces/IApella.sol"; +import {GovernanceBase} from "./base.t.sol"; +import {IGovernance} from "@aztec/governance/interfaces/IGovernance.sol"; import {IERC20Errors} from "@oz/interfaces/draft-IERC6093.sol"; import {Timestamp} from "@aztec/core/libraries/TimeMath.sol"; import {Errors} from "@aztec/governance/libraries/Errors.sol"; import {DataStructures} from "@aztec/governance/libraries/DataStructures.sol"; import {ConfigurationLib} from "@aztec/governance/libraries/ConfigurationLib.sol"; -contract FinaliseWithdrawTest is ApellaBase { +contract FinaliseWithdrawTest is GovernanceBase { using ConfigurationLib for DataStructures.Configuration; uint256 internal constant WITHDRAWAL_COUNT = 8; @@ -20,7 +20,7 @@ contract FinaliseWithdrawTest is ApellaBase { function test_WhenIdMatchNoPendingWithdrawal(uint256 _id) external { // it revert vm.expectRevert(abi.encodeWithSelector(IERC20Errors.ERC20InvalidReceiver.selector, address(0))); - apella.finaliseWithdraw(_id); + governance.finaliseWithdraw(_id); } // Lot of this is similar to initiateWithdraw.t.sol::test_WhenCallerHaveSufficientDeposits @@ -34,12 +34,12 @@ contract FinaliseWithdrawTest is ApellaBase { uint256 sum = deposit; token.mint(address(this), deposit); - token.approve(address(apella), deposit); - apella.deposit(address(this), deposit); + token.approve(address(governance), deposit); + governance.deposit(address(this), deposit); for (uint256 i = 0; i < WITHDRAWAL_COUNT; i++) { address recipient = i % 2 == 0 ? _recipient[i] : address(0xdeadbeef); - vm.assume(recipient != address(apella) && recipient != address(0)); + vm.assume(recipient != address(governance) && recipient != address(0)); uint256 amount = bound(_withdrawals[i], 0, sum); // Note tiny time jumps so we do not need to jump back and forth in time. uint256 timeJump = bound(_timejumps[i], 1, type(uint8).max); @@ -51,7 +51,7 @@ contract FinaliseWithdrawTest is ApellaBase { sum -= amount; vm.warp(block.timestamp + timeJump); - apella.initiateWithdraw(recipient, amount); + governance.initiateWithdraw(recipient, amount); } _; @@ -65,16 +65,16 @@ contract FinaliseWithdrawTest is ApellaBase { ) external whenItMatchPendingWithdrawal(_depositAmount, _recipient, _withdrawals, _timejumps) { // it revert - uint256 withdrawalCount = apella.withdrawalCount(); + uint256 withdrawalCount = governance.withdrawalCount(); for (uint256 i = 0; i < withdrawalCount; i++) { - DataStructures.Withdrawal memory withdrawal = apella.getWithdrawal(i); + DataStructures.Withdrawal memory withdrawal = governance.getWithdrawal(i); vm.warp(Timestamp.unwrap(withdrawal.unlocksAt)); - apella.finaliseWithdraw(i); + governance.finaliseWithdraw(i); } for (uint256 i = 0; i < withdrawalCount; i++) { - vm.expectRevert(abi.encodeWithSelector(Errors.Apella__WithdrawalAlreadyclaimed.selector)); - apella.finaliseWithdraw(i); + vm.expectRevert(abi.encodeWithSelector(Errors.Governance__WithdrawalAlreadyclaimed.selector)); + governance.finaliseWithdraw(i); } } @@ -95,9 +95,9 @@ contract FinaliseWithdrawTest is ApellaBase { { // it revert - uint256 withdrawalCount = apella.withdrawalCount(); + uint256 withdrawalCount = governance.withdrawalCount(); for (uint256 i = 0; i < withdrawalCount; i++) { - DataStructures.Withdrawal memory withdrawal = apella.getWithdrawal(i); + DataStructures.Withdrawal memory withdrawal = governance.getWithdrawal(i); assertGt(withdrawal.unlocksAt, block.timestamp); uint256 time = @@ -107,12 +107,12 @@ contract FinaliseWithdrawTest is ApellaBase { vm.expectRevert( abi.encodeWithSelector( - Errors.Apella__WithdrawalNotUnlockedYet.selector, + Errors.Governance__WithdrawalNotUnlockedYet.selector, Timestamp.wrap(block.timestamp), withdrawal.unlocksAt ) ); - apella.finaliseWithdraw(i); + governance.finaliseWithdraw(i); } } @@ -131,30 +131,30 @@ contract FinaliseWithdrawTest is ApellaBase { // it transfer funds to account // it emits {WithdrawalFinalised} event - uint256 sum = token.balanceOf(address(apella)); + uint256 sum = token.balanceOf(address(governance)); - uint256 withdrawalCount = apella.withdrawalCount(); + uint256 withdrawalCount = governance.withdrawalCount(); for (uint256 i = 0; i < withdrawalCount; i++) { - DataStructures.Withdrawal memory withdrawal = apella.getWithdrawal(i); + DataStructures.Withdrawal memory withdrawal = governance.getWithdrawal(i); uint256 upper = i + 1 == withdrawalCount ? type(uint256).max - : Timestamp.unwrap(apella.getWithdrawal(i + 1).unlocksAt); + : Timestamp.unwrap(governance.getWithdrawal(i + 1).unlocksAt); uint256 time = bound(_timejumps2[i], Timestamp.unwrap(withdrawal.unlocksAt), upper); vm.warp(time); - vm.expectEmit(true, true, true, true, address(apella)); - emit IApella.WithdrawFinalised(i); - apella.finaliseWithdraw(i); + vm.expectEmit(true, true, true, true, address(governance)); + emit IGovernance.WithdrawFinalised(i); + governance.finaliseWithdraw(i); - DataStructures.Withdrawal memory withdrawal2 = apella.getWithdrawal(i); + DataStructures.Withdrawal memory withdrawal2 = governance.getWithdrawal(i); assertTrue(withdrawal2.claimed); sum -= withdrawal.amount; sums[withdrawal.recipient] += withdrawal.amount; - assertEq(token.balanceOf(address(apella)), sum, "total balance"); + assertEq(token.balanceOf(address(governance)), sum, "total balance"); assertEq( token.balanceOf(withdrawal.recipient), sums[withdrawal.recipient], "recipient balance" ); diff --git a/l1-contracts/test/governance/apella/finaliseWithdraw.tree b/l1-contracts/test/governance/governance/finaliseWithdraw.tree similarity index 100% rename from l1-contracts/test/governance/apella/finaliseWithdraw.tree rename to l1-contracts/test/governance/governance/finaliseWithdraw.tree diff --git a/l1-contracts/test/governance/apella/getProposalState.t.sol b/l1-contracts/test/governance/governance/getProposalState.t.sol similarity index 67% rename from l1-contracts/test/governance/apella/getProposalState.t.sol rename to l1-contracts/test/governance/governance/getProposalState.t.sol index 32d9d903074c..8ff0a9f521f9 100644 --- a/l1-contracts/test/governance/apella/getProposalState.t.sol +++ b/l1-contracts/test/governance/governance/getProposalState.t.sol @@ -3,21 +3,23 @@ pragma solidity >=0.8.27; import {stdStorage, StdStorage} from "forge-std/Test.sol"; -import {ApellaBase} from "./base.t.sol"; +import {GovernanceBase} from "./base.t.sol"; import {DataStructures} from "@aztec/governance/libraries/DataStructures.sol"; import {Errors} from "@aztec/governance/libraries/Errors.sol"; import {Timestamp} from "@aztec/core/libraries/TimeMath.sol"; import {ProposalLib, VoteTabulationReturn} from "@aztec/governance/libraries/ProposalLib.sol"; -contract GetProposalStateTest is ApellaBase { +contract GetProposalStateTest is GovernanceBase { using ProposalLib for DataStructures.Proposal; using stdStorage for StdStorage; function test_WhenProposalIsOutOfBounds(uint256 _index) external { // it revert - uint256 index = bound(_index, apella.proposalCount(), type(uint256).max); - vm.expectRevert(abi.encodeWithSelector(Errors.Apella__ProposalDoesNotExists.selector, index)); - apella.getProposalState(index); + uint256 index = bound(_index, governance.proposalCount(), type(uint256).max); + vm.expectRevert( + abi.encodeWithSelector(Errors.Governance__ProposalDoesNotExists.selector, index) + ); + governance.getProposalState(index); } modifier whenValidProposalId() { @@ -36,49 +38,49 @@ contract GetProposalStateTest is ApellaBase { ) external whenValidProposalId givenStateIsStable { // it return Executed _stateExecutable("empty", _voter, _totalPower, _votesCast, _yeas); - apella.execute(proposalId); + governance.execute(proposalId); assertEq(proposal.state, DataStructures.ProposalState.Pending); - assertEq(apella.getProposalState(proposalId), DataStructures.ProposalState.Executed); + assertEq(governance.getProposalState(proposalId), DataStructures.ProposalState.Executed); } - function test_GivenStateIsDropped(address _gerousia) + function test_GivenStateIsDropped(address _governanceProposer) external whenValidProposalId givenStateIsStable { // it return Dropped - _stateDropped("empty", _gerousia); + _stateDropped("empty", _governanceProposer); assertEq(proposal.state, DataStructures.ProposalState.Pending); - assertEq(apella.getProposalState(proposalId), DataStructures.ProposalState.Dropped); + assertEq(governance.getProposalState(proposalId), DataStructures.ProposalState.Dropped); - apella.dropProposal(proposalId); + governance.dropProposal(proposalId); - DataStructures.Proposal memory fresh = apella.getProposal(proposalId); + DataStructures.Proposal memory fresh = governance.getProposal(proposalId); assertEq(fresh.state, DataStructures.ProposalState.Dropped); } modifier givenStateIsUnstable() { _; - DataStructures.Proposal memory fresh = apella.getProposal(proposalId); + DataStructures.Proposal memory fresh = governance.getProposal(proposalId); assertEq(fresh.state, DataStructures.ProposalState.Pending); } - function test_GivenGerousiaHaveChanged(address _gerousia) + function test_GivenGovernanceProposerHaveChanged(address _governanceProposer) external whenValidProposalId givenStateIsUnstable { // it return Dropped - _stateDropped("empty", _gerousia); + _stateDropped("empty", _governanceProposer); assertEq(proposal.state, DataStructures.ProposalState.Pending); - assertEq(apella.getProposalState(proposalId), DataStructures.ProposalState.Dropped); + assertEq(governance.getProposalState(proposalId), DataStructures.ProposalState.Dropped); } - modifier givenGerousiaIsUnchanged() { + modifier givenGovernanceProposerIsUnchanged() { _; } @@ -86,7 +88,7 @@ contract GetProposalStateTest is ApellaBase { external whenValidProposalId givenStateIsUnstable - givenGerousiaIsUnchanged + givenGovernanceProposerIsUnchanged { // it return Pending _statePending("empty"); @@ -94,7 +96,7 @@ contract GetProposalStateTest is ApellaBase { uint256 time = bound(_timeJump, block.timestamp, Timestamp.unwrap(proposal.pendingThrough())); vm.warp(time); - assertEq(apella.getProposalState(proposalId), DataStructures.ProposalState.Pending); + assertEq(governance.getProposalState(proposalId), DataStructures.ProposalState.Pending); } modifier whenVotingDelayHavePassed() { @@ -105,7 +107,7 @@ contract GetProposalStateTest is ApellaBase { external whenValidProposalId givenStateIsUnstable - givenGerousiaIsUnchanged + givenGovernanceProposerIsUnchanged whenVotingDelayHavePassed { // it return Active @@ -114,7 +116,7 @@ contract GetProposalStateTest is ApellaBase { uint256 time = bound(_timeJump, block.timestamp, Timestamp.unwrap(proposal.activeThrough())); vm.warp(time); - assertEq(apella.getProposalState(proposalId), DataStructures.ProposalState.Active); + assertEq(governance.getProposalState(proposalId), DataStructures.ProposalState.Active); } modifier whenVotingDurationHavePassed() { @@ -125,17 +127,17 @@ contract GetProposalStateTest is ApellaBase { external whenValidProposalId givenStateIsUnstable - givenGerousiaIsUnchanged + givenGovernanceProposerIsUnchanged whenVotingDelayHavePassed whenVotingDurationHavePassed { // it return Rejected _stateRejected("empty"); - uint256 totalPower = apella.totalPowerAt(Timestamp.wrap(block.timestamp)); + uint256 totalPower = governance.totalPowerAt(Timestamp.wrap(block.timestamp)); (VoteTabulationReturn vtr,) = proposal.voteTabulation(totalPower); assertEq(vtr, VoteTabulationReturn.Rejected, "invalid return value"); - assertEq(apella.getProposalState(proposalId), DataStructures.ProposalState.Rejected); + assertEq(governance.getProposalState(proposalId), DataStructures.ProposalState.Rejected); } function test_GivenVoteTabulationIsInvalid( @@ -147,7 +149,7 @@ contract GetProposalStateTest is ApellaBase { external whenValidProposalId givenStateIsUnstable - givenGerousiaIsUnchanged + givenGovernanceProposerIsUnchanged whenVotingDelayHavePassed whenVotingDurationHavePassed { @@ -155,17 +157,17 @@ contract GetProposalStateTest is ApellaBase { _stateQueued("empty", _voter, _totalPower, _votesCast, _yeas); // We can overwrite the quorum to be 0 to hit an invalid case - assertGt(apella.getProposal(proposalId).config.quorum, 0); - stdstore.target(address(apella)).sig("getProposal(uint256)").with_key(proposalId).depth(6) + assertGt(governance.getProposal(proposalId).config.quorum, 0); + stdstore.target(address(governance)).sig("getProposal(uint256)").with_key(proposalId).depth(6) .checked_write(uint256(0)); - assertEq(apella.getProposal(proposalId).config.quorum, 0); + assertEq(governance.getProposal(proposalId).config.quorum, 0); - uint256 totalPower = apella.totalPowerAt(Timestamp.wrap(block.timestamp)); + uint256 totalPower = governance.totalPowerAt(Timestamp.wrap(block.timestamp)); - proposal = apella.getProposal(proposalId); + proposal = governance.getProposal(proposalId); (VoteTabulationReturn vtr,) = proposal.voteTabulation(totalPower); assertEq(vtr, VoteTabulationReturn.Invalid, "invalid return value"); - assertEq(apella.getProposalState(proposalId), DataStructures.ProposalState.Rejected); + assertEq(governance.getProposalState(proposalId), DataStructures.ProposalState.Rejected); } modifier givenVoteTabulationIsAccepted( @@ -188,7 +190,7 @@ contract GetProposalStateTest is ApellaBase { external whenValidProposalId givenStateIsUnstable - givenGerousiaIsUnchanged + givenGovernanceProposerIsUnchanged whenVotingDelayHavePassed whenVotingDurationHavePassed givenVoteTabulationIsAccepted(_voter, _totalPower, _votesCast, _yeas) @@ -197,7 +199,7 @@ contract GetProposalStateTest is ApellaBase { uint256 time = bound(_timeJump, block.timestamp, Timestamp.unwrap(proposal.queuedThrough())); vm.warp(time); - assertEq(apella.getProposalState(proposalId), DataStructures.ProposalState.Queued); + assertEq(governance.getProposalState(proposalId), DataStructures.ProposalState.Queued); } modifier givenExecutionDelayHavePassed() { @@ -215,7 +217,7 @@ contract GetProposalStateTest is ApellaBase { external whenValidProposalId givenStateIsUnstable - givenGerousiaIsUnchanged + givenGovernanceProposerIsUnchanged whenVotingDelayHavePassed whenVotingDurationHavePassed givenVoteTabulationIsAccepted(_voter, _totalPower, _votesCast, _yeas) @@ -225,7 +227,7 @@ contract GetProposalStateTest is ApellaBase { uint256 time = bound(_timeJump, block.timestamp, Timestamp.unwrap(proposal.executableThrough())); vm.warp(time); - assertEq(apella.getProposalState(proposalId), DataStructures.ProposalState.Executable); + assertEq(governance.getProposalState(proposalId), DataStructures.ProposalState.Executable); } function test_GivenGracePeriodHavePassed( @@ -237,7 +239,7 @@ contract GetProposalStateTest is ApellaBase { external whenValidProposalId givenStateIsUnstable - givenGerousiaIsUnchanged + givenGovernanceProposerIsUnchanged whenVotingDelayHavePassed whenVotingDurationHavePassed givenVoteTabulationIsAccepted(_voter, _totalPower, _votesCast, _yeas) @@ -245,6 +247,6 @@ contract GetProposalStateTest is ApellaBase { { // it return Expired vm.warp(Timestamp.unwrap(proposal.executableThrough()) + 1); - assertEq(apella.getProposalState(proposalId), DataStructures.ProposalState.Expired); + assertEq(governance.getProposalState(proposalId), DataStructures.ProposalState.Expired); } } diff --git a/l1-contracts/test/governance/apella/getProposalState.tree b/l1-contracts/test/governance/governance/getProposalState.tree similarity index 93% rename from l1-contracts/test/governance/apella/getProposalState.tree rename to l1-contracts/test/governance/governance/getProposalState.tree index 2a80ccd79d8b..72d141fc84c4 100644 --- a/l1-contracts/test/governance/apella/getProposalState.tree +++ b/l1-contracts/test/governance/governance/getProposalState.tree @@ -8,9 +8,9 @@ GetProposalStateTest │ └── given state is Dropped │ └── it return Dropped └── given state is unstable - ├── given gerousia have changed + ├── given governanceProposer have changed │ └── it return Dropped - └── given gerousia is unchanged + └── given governanceProposer is unchanged ├── when voting delay have not passed │ └── it return Pending └── when voting delay have passed diff --git a/l1-contracts/test/governance/apella/initiateWithdraw.t.sol b/l1-contracts/test/governance/governance/initiateWithdraw.t.sol similarity index 65% rename from l1-contracts/test/governance/apella/initiateWithdraw.t.sol rename to l1-contracts/test/governance/governance/initiateWithdraw.t.sol index ceff4beb0f5e..37a4105a344b 100644 --- a/l1-contracts/test/governance/apella/initiateWithdraw.t.sol +++ b/l1-contracts/test/governance/governance/initiateWithdraw.t.sol @@ -1,14 +1,14 @@ // SPDX-License-Identifier: UNLICENSED pragma solidity >=0.8.27; -import {ApellaBase} from "./base.t.sol"; -import {IApella} from "@aztec/governance/interfaces/IApella.sol"; +import {GovernanceBase} from "./base.t.sol"; +import {IGovernance} from "@aztec/governance/interfaces/IGovernance.sol"; import {Timestamp} from "@aztec/core/libraries/TimeMath.sol"; import {Errors} from "@aztec/governance/libraries/Errors.sol"; import {DataStructures} from "@aztec/governance/libraries/DataStructures.sol"; import {ConfigurationLib} from "@aztec/governance/libraries/ConfigurationLib.sol"; -contract InitiateWithdrawTest is ApellaBase { +contract InitiateWithdrawTest is GovernanceBase { using ConfigurationLib for DataStructures.Configuration; uint256 internal constant WITHDRAWAL_COUNT = 8; @@ -21,8 +21,8 @@ contract InitiateWithdrawTest is ApellaBase { function test_GivenNoCheckpoints(uint256 _amount) external whenCallerHaveInsufficientDeposits { // it revert uint256 amount = bound(_amount, 1, type(uint256).max); - vm.expectRevert(abi.encodeWithSelector(Errors.Apella__NoCheckpointsFound.selector)); - apella.initiateWithdraw(address(this), amount); + vm.expectRevert(abi.encodeWithSelector(Errors.Governance__NoCheckpointsFound.selector)); + governance.initiateWithdraw(address(this), amount); } function test_GivenCheckpoints(uint256 _depositAmount, uint256 _withdrawalAmount) @@ -34,15 +34,18 @@ contract InitiateWithdrawTest is ApellaBase { uint256 withdrawalAmount = bound(_withdrawalAmount, depositAmount + 1, type(uint256).max); token.mint(address(this), depositAmount); - token.approve(address(apella), depositAmount); - apella.deposit(address(this), depositAmount); + token.approve(address(governance), depositAmount); + governance.deposit(address(this), depositAmount); vm.expectRevert( abi.encodeWithSelector( - Errors.Apella__InsufficientPower.selector, address(this), depositAmount, withdrawalAmount + Errors.Governance__InsufficientPower.selector, + address(this), + depositAmount, + withdrawalAmount ) ); - apella.initiateWithdraw(address(this), withdrawalAmount); + governance.initiateWithdraw(address(this), withdrawalAmount); } function test_WhenCallerHaveSufficientDeposits( @@ -61,11 +64,11 @@ contract InitiateWithdrawTest is ApellaBase { uint256 withdrawalId = 0; token.mint(address(this), deposit); - token.approve(address(apella), deposit); - apella.deposit(address(this), deposit); - assertEq(token.balanceOf(address(apella)), deposit); + token.approve(address(governance), deposit); + governance.deposit(address(this), deposit); + assertEq(token.balanceOf(address(governance)), deposit); - config = apella.getConfiguration(); + config = governance.getConfiguration(); for (uint256 i = 0; i < WITHDRAWAL_COUNT; i++) { address recipient = i % 2 == 0 ? _recipient[i] : address(0xdeadbeef); @@ -79,11 +82,11 @@ contract InitiateWithdrawTest is ApellaBase { sum -= amount; vm.warp(block.timestamp + timeJump); - vm.expectEmit(true, true, true, true, address(apella)); - emit IApella.WithdrawInitiated(withdrawalId, recipient, amount); - apella.initiateWithdraw(recipient, amount); + vm.expectEmit(true, true, true, true, address(governance)); + emit IGovernance.WithdrawInitiated(withdrawalId, recipient, amount); + governance.initiateWithdraw(recipient, amount); - DataStructures.Withdrawal memory withdrawal = apella.getWithdrawal(withdrawalId); + DataStructures.Withdrawal memory withdrawal = governance.getWithdrawal(withdrawalId); assertEq(withdrawal.amount, amount, "invalid amount"); assertEq( withdrawal.unlocksAt, @@ -92,12 +95,12 @@ contract InitiateWithdrawTest is ApellaBase { ); assertEq(withdrawal.recipient, recipient, "invalid recipient"); assertFalse(withdrawal.claimed, "already claimed"); - assertEq(apella.totalPowerAt(Timestamp.wrap(block.timestamp)), sum); + assertEq(governance.totalPowerAt(Timestamp.wrap(block.timestamp)), sum); withdrawalId++; - assertEq(apella.withdrawalCount(), withdrawalId); + assertEq(governance.withdrawalCount(), withdrawalId); } - assertEq(token.balanceOf(address(apella)), deposit); + assertEq(token.balanceOf(address(governance)), deposit); } } diff --git a/l1-contracts/test/governance/apella/initiateWithdraw.tree b/l1-contracts/test/governance/governance/initiateWithdraw.tree similarity index 100% rename from l1-contracts/test/governance/apella/initiateWithdraw.tree rename to l1-contracts/test/governance/governance/initiateWithdraw.tree diff --git a/l1-contracts/test/governance/apella/proposallib/isStableState.t.sol b/l1-contracts/test/governance/governance/proposallib/isStableState.t.sol similarity index 100% rename from l1-contracts/test/governance/apella/proposallib/isStableState.t.sol rename to l1-contracts/test/governance/governance/proposallib/isStableState.t.sol diff --git a/l1-contracts/test/governance/apella/proposallib/isStableState.tree b/l1-contracts/test/governance/governance/proposallib/isStableState.tree similarity index 100% rename from l1-contracts/test/governance/apella/proposallib/isStableState.tree rename to l1-contracts/test/governance/governance/proposallib/isStableState.tree diff --git a/l1-contracts/test/governance/apella/proposallib/static.t.sol b/l1-contracts/test/governance/governance/proposallib/static.t.sol similarity index 100% rename from l1-contracts/test/governance/apella/proposallib/static.t.sol rename to l1-contracts/test/governance/governance/proposallib/static.t.sol diff --git a/l1-contracts/test/governance/apella/proposallib/voteTabulation.t.sol b/l1-contracts/test/governance/governance/proposallib/voteTabulation.t.sol similarity index 99% rename from l1-contracts/test/governance/apella/proposallib/voteTabulation.t.sol rename to l1-contracts/test/governance/governance/proposallib/voteTabulation.t.sol index 0543ac6747e3..db0c26dabee9 100644 --- a/l1-contracts/test/governance/apella/proposallib/voteTabulation.t.sol +++ b/l1-contracts/test/governance/governance/proposallib/voteTabulation.t.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: UNLICENSED pragma solidity >=0.8.27; -import {ApellaBase} from "../base.t.sol"; +import {GovernanceBase} from "../base.t.sol"; import {DataStructures} from "@aztec/governance/libraries/DataStructures.sol"; import { ProposalLib, @@ -12,7 +12,7 @@ import {ConfigurationLib} from "@aztec/governance/libraries/ConfigurationLib.sol import {Math} from "@oz/utils/math/Math.sol"; -contract VoteTabulationTest is ApellaBase { +contract VoteTabulationTest is GovernanceBase { using ProposalLib for DataStructures.Proposal; using ConfigurationLib for DataStructures.Configuration; diff --git a/l1-contracts/test/governance/apella/proposallib/voteTabulation.tree b/l1-contracts/test/governance/governance/proposallib/voteTabulation.tree similarity index 100% rename from l1-contracts/test/governance/apella/proposallib/voteTabulation.tree rename to l1-contracts/test/governance/governance/proposallib/voteTabulation.tree diff --git a/l1-contracts/test/governance/apella/propose.t.sol b/l1-contracts/test/governance/governance/propose.t.sol similarity index 56% rename from l1-contracts/test/governance/apella/propose.t.sol rename to l1-contracts/test/governance/governance/propose.t.sol index 5e24f1748180..317c7a113cef 100644 --- a/l1-contracts/test/governance/apella/propose.t.sol +++ b/l1-contracts/test/governance/governance/propose.t.sol @@ -2,39 +2,41 @@ pragma solidity >=0.8.27; import {IPayload} from "@aztec/governance/interfaces/IPayload.sol"; -import {ApellaBase} from "./base.t.sol"; -import {IApella} from "@aztec/governance/interfaces/IApella.sol"; +import {GovernanceBase} from "./base.t.sol"; +import {IGovernance} from "@aztec/governance/interfaces/IGovernance.sol"; import {Timestamp} from "@aztec/core/libraries/TimeMath.sol"; import {Errors} from "@aztec/governance/libraries/Errors.sol"; import {DataStructures} from "@aztec/governance/libraries/DataStructures.sol"; -contract ProposeTest is ApellaBase { - function test_WhenCallerIsNotGerousia() external { +contract ProposeTest is GovernanceBase { + function test_WhenCallerIsNotGovernanceProposer() external { // it revert vm.expectRevert( abi.encodeWithSelector( - Errors.Apella__CallerNotGerousia.selector, address(this), address(gerousia) + Errors.Governance__CallerNotGovernanceProposer.selector, + address(this), + address(governanceProposer) ) ); - apella.propose(IPayload(address(0))); + governance.propose(IPayload(address(0))); } - function test_WhenCallerIsGerousia(address _proposal) external { + function test_WhenCallerIsGovernanceProposer(address _proposal) external { // it creates a new proposal with current config // it emits a {ProposalCreated} event // it returns true - DataStructures.Configuration memory config = apella.getConfiguration(); + DataStructures.Configuration memory config = governance.getConfiguration(); - proposalId = apella.proposalCount(); + proposalId = governance.proposalCount(); - vm.expectEmit(true, true, true, true, address(apella)); - emit IApella.Proposed(proposalId, _proposal); + vm.expectEmit(true, true, true, true, address(governance)); + emit IGovernance.Proposed(proposalId, _proposal); - vm.prank(address(gerousia)); - assertTrue(apella.propose(IPayload(_proposal))); + vm.prank(address(governanceProposer)); + assertTrue(governance.propose(IPayload(_proposal))); - DataStructures.Proposal memory proposal = apella.getProposal(proposalId); + DataStructures.Proposal memory proposal = governance.getProposal(proposalId); assertEq(proposal.config.executionDelay, config.executionDelay); assertEq(proposal.config.gracePeriod, config.gracePeriod); assertEq(proposal.config.minimumVotes, config.minimumVotes); @@ -43,7 +45,7 @@ contract ProposeTest is ApellaBase { assertEq(proposal.config.votingDelay, config.votingDelay); assertEq(proposal.config.votingDuration, config.votingDuration); assertEq(proposal.creation, Timestamp.wrap(block.timestamp)); - assertEq(proposal.gerousia, address(gerousia)); + assertEq(proposal.governanceProposer, address(governanceProposer)); assertEq(proposal.summedBallot.nea, 0); assertEq(proposal.summedBallot.yea, 0); assertTrue(proposal.state == DataStructures.ProposalState.Pending); diff --git a/l1-contracts/test/governance/apella/propose.tree b/l1-contracts/test/governance/governance/propose.tree similarity index 65% rename from l1-contracts/test/governance/apella/propose.tree rename to l1-contracts/test/governance/governance/propose.tree index 566af1434db0..81a79f7755a4 100644 --- a/l1-contracts/test/governance/apella/propose.tree +++ b/l1-contracts/test/governance/governance/propose.tree @@ -1,7 +1,7 @@ ProposeTest -├── when caller is not gerousia +├── when caller is not governanceProposer │ └── it revert -└── when caller is gerousia +└── when caller is governanceProposer ├── it creates a new proposal with current config ├── it emits a {ProposalCreated} event └── it returns true \ No newline at end of file diff --git a/l1-contracts/test/governance/apella/proposeWithLock.t.sol b/l1-contracts/test/governance/governance/proposeWithLock.t.sol similarity index 58% rename from l1-contracts/test/governance/apella/proposeWithLock.t.sol rename to l1-contracts/test/governance/governance/proposeWithLock.t.sol index 55d90de0b848..1f65f7ee1d50 100644 --- a/l1-contracts/test/governance/apella/proposeWithLock.t.sol +++ b/l1-contracts/test/governance/governance/proposeWithLock.t.sol @@ -2,22 +2,25 @@ pragma solidity >=0.8.27; import {IPayload} from "@aztec/governance/interfaces/IPayload.sol"; -import {ApellaBase} from "./base.t.sol"; -import {IApella} from "@aztec/governance/interfaces/IApella.sol"; +import {GovernanceBase} from "./base.t.sol"; +import {IGovernance} from "@aztec/governance/interfaces/IGovernance.sol"; import {Timestamp} from "@aztec/core/libraries/TimeMath.sol"; import {Errors} from "@aztec/governance/libraries/Errors.sol"; import {DataStructures} from "@aztec/governance/libraries/DataStructures.sol"; -contract ProposeWithLockTest is ApellaBase { +contract ProposeWithLockTest is GovernanceBase { function test_WhenCallerHasInsufficientPower() external { // it revert - DataStructures.Configuration memory config = apella.getConfiguration(); + DataStructures.Configuration memory config = governance.getConfiguration(); vm.expectRevert( abi.encodeWithSelector( - Errors.Apella__InsufficientPower.selector, address(this), 0, config.proposeConfig.lockAmount + Errors.Governance__InsufficientPower.selector, + address(this), + 0, + config.proposeConfig.lockAmount ) ); - apella.proposeWithLock(IPayload(address(0)), address(this)); + governance.proposeWithLock(IPayload(address(0)), address(this)); } function test_WhenCallerHasSufficientPower(address _proposal) external { @@ -25,20 +28,20 @@ contract ProposeWithLockTest is ApellaBase { // it creates a new proposal with current config // it emits a {ProposalCreated} event // it returns true - DataStructures.Configuration memory config = apella.getConfiguration(); + DataStructures.Configuration memory config = governance.getConfiguration(); token.mint(address(this), config.proposeConfig.lockAmount); - token.approve(address(apella), config.proposeConfig.lockAmount); - apella.deposit(address(this), config.proposeConfig.lockAmount); + token.approve(address(governance), config.proposeConfig.lockAmount); + governance.deposit(address(this), config.proposeConfig.lockAmount); - proposalId = apella.proposalCount(); + proposalId = governance.proposalCount(); - vm.expectEmit(true, true, true, true, address(apella)); - emit IApella.Proposed(proposalId, _proposal); + vm.expectEmit(true, true, true, true, address(governance)); + emit IGovernance.Proposed(proposalId, _proposal); - assertTrue(apella.proposeWithLock(IPayload(_proposal), address(this))); + assertTrue(governance.proposeWithLock(IPayload(_proposal), address(this))); - DataStructures.Proposal memory proposal = apella.getProposal(proposalId); + DataStructures.Proposal memory proposal = governance.getProposal(proposalId); assertEq(proposal.config.executionDelay, config.executionDelay); assertEq(proposal.config.gracePeriod, config.gracePeriod); assertEq(proposal.config.minimumVotes, config.minimumVotes); @@ -47,7 +50,7 @@ contract ProposeWithLockTest is ApellaBase { assertEq(proposal.config.votingDelay, config.votingDelay); assertEq(proposal.config.votingDuration, config.votingDuration); assertEq(proposal.creation, Timestamp.wrap(block.timestamp)); - assertEq(proposal.gerousia, address(gerousia)); + assertEq(proposal.governanceProposer, address(governanceProposer)); assertEq(proposal.summedBallot.nea, 0); assertEq(proposal.summedBallot.yea, 0); assertTrue(proposal.state == DataStructures.ProposalState.Pending); diff --git a/l1-contracts/test/governance/apella/proposeWithLock.tree b/l1-contracts/test/governance/governance/proposeWithLock.tree similarity index 100% rename from l1-contracts/test/governance/apella/proposeWithLock.tree rename to l1-contracts/test/governance/governance/proposeWithLock.tree diff --git a/l1-contracts/test/governance/apella/scenarios/noVoteAndExit.t.sol b/l1-contracts/test/governance/governance/scenarios/noVoteAndExit.t.sol similarity index 69% rename from l1-contracts/test/governance/apella/scenarios/noVoteAndExit.t.sol rename to l1-contracts/test/governance/governance/scenarios/noVoteAndExit.t.sol index ecdbdb6f34c3..b4327a9daea4 100644 --- a/l1-contracts/test/governance/apella/scenarios/noVoteAndExit.t.sol +++ b/l1-contracts/test/governance/governance/scenarios/noVoteAndExit.t.sol @@ -1,14 +1,14 @@ // SPDX-License-Identifier: UNLICENSED pragma solidity >=0.8.27; -import {ApellaBase} from "../base.t.sol"; +import {GovernanceBase} from "../base.t.sol"; import {DataStructures} from "@aztec/governance/libraries/DataStructures.sol"; import {Errors} from "@aztec/governance/libraries/Errors.sol"; import {Math} from "@oz/utils/math/Math.sol"; import {Timestamp} from "@aztec/core/libraries/TimeMath.sol"; import {ProposalLib} from "@aztec/governance/libraries/ProposalLib.sol"; -contract NoVoteAndExitTest is ApellaBase { +contract NoVoteAndExitTest is GovernanceBase { using ProposalLib for DataStructures.Proposal; // Ensure that it is not possible to BOTH vote on proposal AND withdraw the funds before // it can be executed @@ -36,41 +36,41 @@ contract NoVoteAndExitTest is ApellaBase { token.mint(_voter, totalPower); vm.startPrank(_voter); - token.approve(address(apella), totalPower); - apella.deposit(_voter, totalPower); + token.approve(address(governance), totalPower); + governance.deposit(_voter, totalPower); vm.stopPrank(); // Jump up to the point where the proposal becomes active vm.warp(Timestamp.unwrap(proposal.pendingThrough()) + 1); - assertEq(apella.getProposalState(proposalId), DataStructures.ProposalState.Active); + assertEq(governance.getProposalState(proposalId), DataStructures.ProposalState.Active); vm.prank(_voter); - apella.vote(proposalId, yeas, true); + governance.vote(proposalId, yeas, true); vm.prank(_voter); - apella.vote(proposalId, votesCast - yeas, false); + governance.vote(proposalId, votesCast - yeas, false); vm.prank(_voter); - uint256 withdrawalId = apella.initiateWithdraw(_voter, totalPower); + uint256 withdrawalId = governance.initiateWithdraw(_voter, totalPower); // Jump to the block just before we become executable. vm.warp(Timestamp.unwrap(proposal.queuedThrough())); - assertEq(apella.getProposalState(proposalId), DataStructures.ProposalState.Queued); + assertEq(governance.getProposalState(proposalId), DataStructures.ProposalState.Queued); vm.warp(Timestamp.unwrap(proposal.queuedThrough()) + 1); - assertEq(apella.getProposalState(proposalId), DataStructures.ProposalState.Executable); + assertEq(governance.getProposalState(proposalId), DataStructures.ProposalState.Executable); - DataStructures.Withdrawal memory withdrawal = apella.getWithdrawal(withdrawalId); + DataStructures.Withdrawal memory withdrawal = governance.getWithdrawal(withdrawalId); vm.expectRevert( abi.encodeWithSelector( - Errors.Apella__WithdrawalNotUnlockedYet.selector, + Errors.Governance__WithdrawalNotUnlockedYet.selector, Timestamp.wrap(block.timestamp), withdrawal.unlocksAt ) ); - apella.finaliseWithdraw(withdrawalId); + governance.finaliseWithdraw(withdrawalId); - apella.execute(proposalId); + governance.execute(proposalId); } } diff --git a/l1-contracts/test/governance/apella/updateConfiguration.t.sol b/l1-contracts/test/governance/governance/updateConfiguration.t.sol similarity index 73% rename from l1-contracts/test/governance/apella/updateConfiguration.t.sol rename to l1-contracts/test/governance/governance/updateConfiguration.t.sol index b26cb44e53ef..65382f4682ba 100644 --- a/l1-contracts/test/governance/apella/updateConfiguration.t.sol +++ b/l1-contracts/test/governance/governance/updateConfiguration.t.sol @@ -1,15 +1,15 @@ // SPDX-License-Identifier: UNLICENSED pragma solidity >=0.8.27; -import {ApellaBase} from "./base.t.sol"; -import {IApella} from "@aztec/governance/interfaces/IApella.sol"; +import {GovernanceBase} from "./base.t.sol"; +import {IGovernance} from "@aztec/governance/interfaces/IGovernance.sol"; import {Timestamp} from "@aztec/core/libraries/TimeMath.sol"; import {Errors} from "@aztec/governance/libraries/Errors.sol"; import {DataStructures} from "@aztec/governance/libraries/DataStructures.sol"; import {ConfigurationLib} from "@aztec/governance/libraries/ConfigurationLib.sol"; import {Timestamp} from "@aztec/core/libraries/TimeMath.sol"; -contract UpdateConfigurationTest is ApellaBase { +contract UpdateConfigurationTest is GovernanceBase { using ConfigurationLib for DataStructures.Configuration; DataStructures.Configuration internal config; @@ -17,17 +17,19 @@ contract UpdateConfigurationTest is ApellaBase { // Doing this as we are using a lib that works on storage DataStructures.Configuration internal fresh; - function setUp() public override(ApellaBase) { + function setUp() public override(GovernanceBase) { super.setUp(); - config = apella.getConfiguration(); + config = governance.getConfiguration(); } function test_WhenCallerIsNotSelf() external { // it revert vm.expectRevert( - abi.encodeWithSelector(Errors.Apella__CallerNotSelf.selector, address(this), address(apella)) + abi.encodeWithSelector( + Errors.Governance__CallerNotSelf.selector, address(this), address(governance) + ) ); - apella.updateConfiguration(config); + governance.updateConfiguration(config); } modifier whenCallerIsSelf() { @@ -46,17 +48,19 @@ contract UpdateConfigurationTest is ApellaBase { // it revert config.quorum = bound(_val, 0, ConfigurationLib.QUORUM_LOWER - 1); vm.expectRevert( - abi.encodeWithSelector(Errors.Apella__ConfigurationLib__QuorumTooSmall.selector) + abi.encodeWithSelector(Errors.Governance__ConfigurationLib__QuorumTooSmall.selector) ); - vm.prank(address(apella)); - apella.updateConfiguration(config); + vm.prank(address(governance)); + governance.updateConfiguration(config); config.quorum = bound(_val, ConfigurationLib.QUORUM_UPPER + 1, type(uint256).max); - vm.expectRevert(abi.encodeWithSelector(Errors.Apella__ConfigurationLib__QuorumTooBig.selector)); + vm.expectRevert( + abi.encodeWithSelector(Errors.Governance__ConfigurationLib__QuorumTooBig.selector) + ); - vm.prank(address(apella)); - apella.updateConfiguration(config); + vm.prank(address(governance)); + governance.updateConfiguration(config); } function test_WhenDifferentialLtMinOrGtMax(uint256 _val) @@ -68,11 +72,11 @@ contract UpdateConfigurationTest is ApellaBase { config.voteDifferential = bound(_val, ConfigurationLib.DIFFERENTIAL_UPPER + 1, type(uint256).max); vm.expectRevert( - abi.encodeWithSelector(Errors.Apella__ConfigurationLib__DifferentialTooBig.selector) + abi.encodeWithSelector(Errors.Governance__ConfigurationLib__DifferentialTooBig.selector) ); - vm.prank(address(apella)); - apella.updateConfiguration(config); + vm.prank(address(governance)); + governance.updateConfiguration(config); } function test_WhenMinimumVotesLtMin(uint256 _val) @@ -83,11 +87,11 @@ contract UpdateConfigurationTest is ApellaBase { // it revert config.minimumVotes = bound(_val, 0, ConfigurationLib.VOTES_LOWER - 1); vm.expectRevert( - abi.encodeWithSelector(Errors.Apella__ConfigurationLib__InvalidMinimumVotes.selector) + abi.encodeWithSelector(Errors.Governance__ConfigurationLib__InvalidMinimumVotes.selector) ); - vm.prank(address(apella)); - apella.updateConfiguration(config); + vm.prank(address(governance)); + governance.updateConfiguration(config); } function test_WhenLockAmountLtMin(uint256 _val) @@ -98,11 +102,11 @@ contract UpdateConfigurationTest is ApellaBase { // it revert config.proposeConfig.lockAmount = bound(_val, 0, ConfigurationLib.VOTES_LOWER - 1); vm.expectRevert( - abi.encodeWithSelector(Errors.Apella__ConfigurationLib__LockAmountTooSmall.selector) + abi.encodeWithSelector(Errors.Governance__ConfigurationLib__LockAmountTooSmall.selector) ); - vm.prank(address(apella)); - apella.updateConfiguration(config); + vm.prank(address(governance)); + governance.updateConfiguration(config); } function test_WhenLockDelayLtMinOrGtMax(uint256 _val) @@ -114,19 +118,21 @@ contract UpdateConfigurationTest is ApellaBase { config.proposeConfig.lockDelay = Timestamp.wrap(bound(_val, 0, Timestamp.unwrap(ConfigurationLib.TIME_LOWER) - 1)); vm.expectRevert( - abi.encodeWithSelector(Errors.Apella__ConfigurationLib__TimeTooSmall.selector, "LockDelay") + abi.encodeWithSelector( + Errors.Governance__ConfigurationLib__TimeTooSmall.selector, "LockDelay" + ) ); - vm.prank(address(apella)); - apella.updateConfiguration(config); + vm.prank(address(governance)); + governance.updateConfiguration(config); config.proposeConfig.lockDelay = Timestamp.wrap( bound(_val, Timestamp.unwrap(ConfigurationLib.TIME_UPPER) + 1, type(uint256).max) ); vm.expectRevert( - abi.encodeWithSelector(Errors.Apella__ConfigurationLib__TimeTooBig.selector, "LockDelay") + abi.encodeWithSelector(Errors.Governance__ConfigurationLib__TimeTooBig.selector, "LockDelay") ); - vm.prank(address(apella)); - apella.updateConfiguration(config); + vm.prank(address(governance)); + governance.updateConfiguration(config); } function test_WhenVotingDelayLtMinOrGtMax(uint256 _val) @@ -139,19 +145,23 @@ contract UpdateConfigurationTest is ApellaBase { config.votingDelay = Timestamp.wrap(bound(_val, 0, Timestamp.unwrap(ConfigurationLib.TIME_LOWER) - 1)); vm.expectRevert( - abi.encodeWithSelector(Errors.Apella__ConfigurationLib__TimeTooSmall.selector, "VotingDelay") + abi.encodeWithSelector( + Errors.Governance__ConfigurationLib__TimeTooSmall.selector, "VotingDelay" + ) ); - vm.prank(address(apella)); - apella.updateConfiguration(config); + vm.prank(address(governance)); + governance.updateConfiguration(config); config.votingDelay = Timestamp.wrap( bound(_val, Timestamp.unwrap(ConfigurationLib.TIME_UPPER) + 1, type(uint256).max) ); vm.expectRevert( - abi.encodeWithSelector(Errors.Apella__ConfigurationLib__TimeTooBig.selector, "VotingDelay") + abi.encodeWithSelector( + Errors.Governance__ConfigurationLib__TimeTooBig.selector, "VotingDelay" + ) ); - vm.prank(address(apella)); - apella.updateConfiguration(config); + vm.prank(address(governance)); + governance.updateConfiguration(config); } function test_WhenVotingDurationLtMinOrGtMax(uint256 _val) @@ -165,20 +175,22 @@ contract UpdateConfigurationTest is ApellaBase { Timestamp.wrap(bound(_val, 0, Timestamp.unwrap(ConfigurationLib.TIME_LOWER) - 1)); vm.expectRevert( abi.encodeWithSelector( - Errors.Apella__ConfigurationLib__TimeTooSmall.selector, "VotingDuration" + Errors.Governance__ConfigurationLib__TimeTooSmall.selector, "VotingDuration" ) ); - vm.prank(address(apella)); - apella.updateConfiguration(config); + vm.prank(address(governance)); + governance.updateConfiguration(config); config.votingDuration = Timestamp.wrap( bound(_val, Timestamp.unwrap(ConfigurationLib.TIME_UPPER) + 1, type(uint256).max) ); vm.expectRevert( - abi.encodeWithSelector(Errors.Apella__ConfigurationLib__TimeTooBig.selector, "VotingDuration") + abi.encodeWithSelector( + Errors.Governance__ConfigurationLib__TimeTooBig.selector, "VotingDuration" + ) ); - vm.prank(address(apella)); - apella.updateConfiguration(config); + vm.prank(address(governance)); + governance.updateConfiguration(config); } function test_WhenExecutionDelayLtMinOrGtMax(uint256 _val) @@ -192,20 +204,22 @@ contract UpdateConfigurationTest is ApellaBase { Timestamp.wrap(bound(_val, 0, Timestamp.unwrap(ConfigurationLib.TIME_LOWER) - 1)); vm.expectRevert( abi.encodeWithSelector( - Errors.Apella__ConfigurationLib__TimeTooSmall.selector, "ExecutionDelay" + Errors.Governance__ConfigurationLib__TimeTooSmall.selector, "ExecutionDelay" ) ); - vm.prank(address(apella)); - apella.updateConfiguration(config); + vm.prank(address(governance)); + governance.updateConfiguration(config); config.executionDelay = Timestamp.wrap( bound(_val, Timestamp.unwrap(ConfigurationLib.TIME_UPPER) + 1, type(uint256).max) ); vm.expectRevert( - abi.encodeWithSelector(Errors.Apella__ConfigurationLib__TimeTooBig.selector, "ExecutionDelay") + abi.encodeWithSelector( + Errors.Governance__ConfigurationLib__TimeTooBig.selector, "ExecutionDelay" + ) ); - vm.prank(address(apella)); - apella.updateConfiguration(config); + vm.prank(address(governance)); + governance.updateConfiguration(config); } function test_WhenGracePeriodLtMinOrGtMax(uint256 _val) @@ -218,34 +232,38 @@ contract UpdateConfigurationTest is ApellaBase { config.gracePeriod = Timestamp.wrap(bound(_val, 0, Timestamp.unwrap(ConfigurationLib.TIME_LOWER) - 1)); vm.expectRevert( - abi.encodeWithSelector(Errors.Apella__ConfigurationLib__TimeTooSmall.selector, "GracePeriod") + abi.encodeWithSelector( + Errors.Governance__ConfigurationLib__TimeTooSmall.selector, "GracePeriod" + ) ); - vm.prank(address(apella)); - apella.updateConfiguration(config); + vm.prank(address(governance)); + governance.updateConfiguration(config); config.gracePeriod = Timestamp.wrap( bound(_val, Timestamp.unwrap(ConfigurationLib.TIME_UPPER) + 1, type(uint256).max) ); vm.expectRevert( - abi.encodeWithSelector(Errors.Apella__ConfigurationLib__TimeTooBig.selector, "GracePeriod") + abi.encodeWithSelector( + Errors.Governance__ConfigurationLib__TimeTooBig.selector, "GracePeriod" + ) ); - vm.prank(address(apella)); - apella.updateConfiguration(config); + vm.prank(address(governance)); + governance.updateConfiguration(config); } modifier whenConfigurationIsValid() { // the local `config` will be modified throughout the execution // We check that it matches the what is seen on chain afterwards - DataStructures.Configuration memory old = apella.getConfiguration(); + DataStructures.Configuration memory old = governance.getConfiguration(); _; - vm.expectEmit(true, true, true, true, address(apella)); - emit IApella.ConfigurationUpdated(Timestamp.wrap(block.timestamp)); - vm.prank(address(apella)); - apella.updateConfiguration(config); + vm.expectEmit(true, true, true, true, address(governance)); + emit IGovernance.ConfigurationUpdated(Timestamp.wrap(block.timestamp)); + vm.prank(address(governance)); + governance.updateConfiguration(config); - fresh = apella.getConfiguration(); + fresh = governance.getConfiguration(); assertEq(config.executionDelay, fresh.executionDelay); assertEq(config.gracePeriod, fresh.gracePeriod); diff --git a/l1-contracts/test/governance/apella/updateConfiguration.tree b/l1-contracts/test/governance/governance/updateConfiguration.tree similarity index 100% rename from l1-contracts/test/governance/apella/updateConfiguration.tree rename to l1-contracts/test/governance/governance/updateConfiguration.tree diff --git a/l1-contracts/test/governance/governance/updateGovernanceProposer.t.sol b/l1-contracts/test/governance/governance/updateGovernanceProposer.t.sol new file mode 100644 index 000000000000..49dfb392f619 --- /dev/null +++ b/l1-contracts/test/governance/governance/updateGovernanceProposer.t.sol @@ -0,0 +1,35 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity >=0.8.27; + +import {GovernanceBase} from "./base.t.sol"; +import {Errors} from "@aztec/governance/libraries/Errors.sol"; +import {IGovernance} from "@aztec/governance/interfaces/IGovernance.sol"; + +contract UpdateGovernanceProposerTest is GovernanceBase { + function test_WhenCallerIsNotGovernance(address _caller, address _governanceProposer) external { + // it revert + vm.assume(_caller != address(governance)); + vm.expectRevert( + abi.encodeWithSelector( + Errors.Governance__CallerNotSelf.selector, _caller, address(governance) + ) + ); + vm.prank(_caller); + governance.updateGovernanceProposer(_governanceProposer); + } + + function test_WhenCallerIsGovernance(address _governanceProposer) external { + // it updates the governanceProposer + // it emit the {GovernanceProposerUpdated} event + + vm.assume(_governanceProposer != address(governance.governanceProposer())); + + vm.expectEmit(true, true, true, true, address(governance)); + emit IGovernance.GovernanceProposerUpdated(_governanceProposer); + + vm.prank(address(governance)); + governance.updateGovernanceProposer(_governanceProposer); + + assertEq(_governanceProposer, governance.governanceProposer()); + } +} diff --git a/l1-contracts/test/governance/governance/updateGovernanceProposer.tree b/l1-contracts/test/governance/governance/updateGovernanceProposer.tree new file mode 100644 index 000000000000..8ca858f638c1 --- /dev/null +++ b/l1-contracts/test/governance/governance/updateGovernanceProposer.tree @@ -0,0 +1,6 @@ +UpdateGovernanceProposerTest +├── when caller is not governance +│ └── it revert +└── when caller is governance + ├── it updates the governanceProposer + └── it emit the {GovernanceProposerUpdated} event \ No newline at end of file diff --git a/l1-contracts/test/governance/apella/userlib/add.t.sol b/l1-contracts/test/governance/governance/userlib/add.t.sol similarity index 100% rename from l1-contracts/test/governance/apella/userlib/add.t.sol rename to l1-contracts/test/governance/governance/userlib/add.t.sol diff --git a/l1-contracts/test/governance/apella/userlib/add.tree b/l1-contracts/test/governance/governance/userlib/add.tree similarity index 100% rename from l1-contracts/test/governance/apella/userlib/add.tree rename to l1-contracts/test/governance/governance/userlib/add.tree diff --git a/l1-contracts/test/governance/apella/userlib/base.t.sol b/l1-contracts/test/governance/governance/userlib/base.t.sol similarity index 100% rename from l1-contracts/test/governance/apella/userlib/base.t.sol rename to l1-contracts/test/governance/governance/userlib/base.t.sol diff --git a/l1-contracts/test/governance/apella/userlib/powerAt.t.sol b/l1-contracts/test/governance/governance/userlib/powerAt.t.sol similarity index 96% rename from l1-contracts/test/governance/apella/userlib/powerAt.t.sol rename to l1-contracts/test/governance/governance/userlib/powerAt.t.sol index 64eacf8cfd30..f4becc2e5d9e 100644 --- a/l1-contracts/test/governance/apella/userlib/powerAt.t.sol +++ b/l1-contracts/test/governance/governance/userlib/powerAt.t.sol @@ -14,7 +14,7 @@ contract PowerAtTest is UserLibBase { function test_WhenTimeNotInPast() external { // it revert - vm.expectRevert(abi.encodeWithSelector(Errors.Apella__UserLib__NotInPast.selector)); + vm.expectRevert(abi.encodeWithSelector(Errors.Governance__UserLib__NotInPast.selector)); user.powerAt(Timestamp.wrap(block.timestamp)); } diff --git a/l1-contracts/test/governance/apella/userlib/powerAt.tree b/l1-contracts/test/governance/governance/userlib/powerAt.tree similarity index 100% rename from l1-contracts/test/governance/apella/userlib/powerAt.tree rename to l1-contracts/test/governance/governance/userlib/powerAt.tree diff --git a/l1-contracts/test/governance/apella/userlib/powerNow.t.sol b/l1-contracts/test/governance/governance/userlib/powerNow.t.sol similarity index 100% rename from l1-contracts/test/governance/apella/userlib/powerNow.t.sol rename to l1-contracts/test/governance/governance/userlib/powerNow.t.sol diff --git a/l1-contracts/test/governance/apella/userlib/powerNow.tree b/l1-contracts/test/governance/governance/userlib/powerNow.tree similarity index 100% rename from l1-contracts/test/governance/apella/userlib/powerNow.tree rename to l1-contracts/test/governance/governance/userlib/powerNow.tree diff --git a/l1-contracts/test/governance/apella/userlib/sub.t.sol b/l1-contracts/test/governance/governance/userlib/sub.t.sol similarity index 95% rename from l1-contracts/test/governance/apella/userlib/sub.t.sol rename to l1-contracts/test/governance/governance/userlib/sub.t.sol index 438edf91da96..4be54e2bc987 100644 --- a/l1-contracts/test/governance/apella/userlib/sub.t.sol +++ b/l1-contracts/test/governance/governance/userlib/sub.t.sol @@ -26,7 +26,7 @@ contract SubTest is UserLibBase { function test_GivenUserHaveNoCheckpoints(uint256 _amount) external whenAmountGt0(_amount) { // it revert - vm.expectRevert(abi.encodeWithSelector(Errors.Apella__NoCheckpointsFound.selector)); + vm.expectRevert(abi.encodeWithSelector(Errors.Governance__NoCheckpointsFound.selector)); user.sub(amount); } @@ -42,7 +42,7 @@ contract SubTest is UserLibBase { vm.expectRevert( abi.encodeWithSelector( - Errors.Apella__InsufficientPower.selector, msg.sender, sumBefore, amount + Errors.Governance__InsufficientPower.selector, msg.sender, sumBefore, amount ) ); user.sub(amount); diff --git a/l1-contracts/test/governance/apella/userlib/sub.tree b/l1-contracts/test/governance/governance/userlib/sub.tree similarity index 100% rename from l1-contracts/test/governance/apella/userlib/sub.tree rename to l1-contracts/test/governance/governance/userlib/sub.tree diff --git a/l1-contracts/test/governance/apella/vote.t.sol b/l1-contracts/test/governance/governance/vote.t.sol similarity index 70% rename from l1-contracts/test/governance/apella/vote.t.sol rename to l1-contracts/test/governance/governance/vote.t.sol index b49330ae3918..97dc30fd65f2 100644 --- a/l1-contracts/test/governance/apella/vote.t.sol +++ b/l1-contracts/test/governance/governance/vote.t.sol @@ -2,19 +2,19 @@ pragma solidity >=0.8.27; import {IPayload} from "@aztec/governance/interfaces/IPayload.sol"; -import {ApellaBase} from "./base.t.sol"; +import {GovernanceBase} from "./base.t.sol"; import {Errors} from "@aztec/governance/libraries/Errors.sol"; import {DataStructures} from "@aztec/governance/libraries/DataStructures.sol"; import {ProposalLib} from "@aztec/governance/libraries/ProposalLib.sol"; import {Timestamp} from "@aztec/core/libraries/TimeMath.sol"; -import {IApella} from "@aztec/governance/interfaces/IApella.sol"; +import {IGovernance} from "@aztec/governance/interfaces/IGovernance.sol"; -contract VoteTest is ApellaBase { +contract VoteTest is GovernanceBase { using ProposalLib for DataStructures.Proposal; uint256 internal depositPower; - function setUp() public override(ApellaBase) { + function setUp() public override(GovernanceBase) { super.setUp(); proposal = proposals["empty"]; @@ -24,8 +24,8 @@ contract VoteTest is ApellaBase { modifier givenStateIsNotActive(address _voter, uint256 _amount, bool _support) { _; vm.prank(_voter); - vm.expectRevert(abi.encodeWithSelector(Errors.Apella__ProposalNotActive.selector)); - apella.vote(proposalId, _amount, _support); + vm.expectRevert(abi.encodeWithSelector(Errors.Governance__ProposalNotActive.selector)); + governance.vote(proposalId, _amount, _support); } function test_GivenStateIsPending(address _voter, uint256 _amount, bool _support) @@ -34,7 +34,7 @@ contract VoteTest is ApellaBase { { // it revert _statePending("empty"); - assertEq(apella.getProposalState(proposalId), DataStructures.ProposalState.Pending); + assertEq(governance.getProposalState(proposalId), DataStructures.ProposalState.Pending); } function test_GivenStateIsQueued( @@ -47,7 +47,7 @@ contract VoteTest is ApellaBase { ) external givenStateIsNotActive(_voter, _amount, _support) { // it revert _stateQueued("empty", _voter, _totalPower, _votesCast, _yeas); - assertEq(apella.getProposalState(proposalId), DataStructures.ProposalState.Queued); + assertEq(governance.getProposalState(proposalId), DataStructures.ProposalState.Queued); } function test_GivenStateIsExecutable( @@ -60,7 +60,7 @@ contract VoteTest is ApellaBase { ) external givenStateIsNotActive(_voter, _amount, _support) { // it revert _stateExecutable("empty", _voter, _totalPower, _votesCast, _yeas); - assertEq(apella.getProposalState(proposalId), DataStructures.ProposalState.Executable); + assertEq(governance.getProposalState(proposalId), DataStructures.ProposalState.Executable); } function test_GivenStateIsRejected(address _voter, uint256 _amount, bool _support) @@ -69,18 +69,18 @@ contract VoteTest is ApellaBase { { // it revert _stateRejected("empty"); - assertEq(apella.getProposalState(proposalId), DataStructures.ProposalState.Rejected); + assertEq(governance.getProposalState(proposalId), DataStructures.ProposalState.Rejected); } function test_GivenStateIsDropped( address _voter, uint256 _amount, bool _support, - address _gerousia + address _governanceProposer ) external givenStateIsNotActive(_voter, _amount, _support) { // it revert - _stateDropped("empty", _gerousia); - assertEq(apella.getProposalState(proposalId), DataStructures.ProposalState.Dropped); + _stateDropped("empty", _governanceProposer); + assertEq(governance.getProposalState(proposalId), DataStructures.ProposalState.Dropped); } function test_GivenStateIsExpired( @@ -93,7 +93,7 @@ contract VoteTest is ApellaBase { ) external givenStateIsNotActive(_voter, _amount, _support) { // it revert _stateExpired("empty", _voter, _totalPower, _votesCast, _yeas); - assertEq(apella.getProposalState(proposalId), DataStructures.ProposalState.Expired); + assertEq(governance.getProposalState(proposalId), DataStructures.ProposalState.Expired); } modifier givenStateIsActive(address _voter, uint256 _depositPower) { @@ -102,12 +102,12 @@ contract VoteTest is ApellaBase { token.mint(_voter, depositPower); vm.startPrank(_voter); - token.approve(address(apella), depositPower); - apella.deposit(_voter, depositPower); + token.approve(address(governance), depositPower); + governance.deposit(_voter, depositPower); vm.stopPrank(); - assertEq(token.balanceOf(address(apella)), depositPower); - assertEq(apella.powerAt(_voter, Timestamp.wrap(block.timestamp)), depositPower); + assertEq(token.balanceOf(address(governance)), depositPower); + assertEq(governance.powerAt(_voter, Timestamp.wrap(block.timestamp)), depositPower); _stateActive("empty"); @@ -125,10 +125,12 @@ contract VoteTest is ApellaBase { uint256 power = bound(_votePower, depositPower + 1, type(uint256).max); vm.expectRevert( - abi.encodeWithSelector(Errors.Apella__InsufficientPower.selector, _voter, depositPower, power) + abi.encodeWithSelector( + Errors.Governance__InsufficientPower.selector, _voter, depositPower, power + ) ); vm.prank(_voter); - apella.vote(proposalId, power, _support); + governance.vote(proposalId, power, _support); } function test_GivenAmountSmallerOrEqAvailablePower( @@ -144,12 +146,12 @@ contract VoteTest is ApellaBase { uint256 power = bound(_votePower, 1, depositPower); - vm.expectEmit(true, true, true, true, address(apella)); - emit IApella.VoteCast(proposalId, _voter, _support, power); + vm.expectEmit(true, true, true, true, address(governance)); + emit IGovernance.VoteCast(proposalId, _voter, _support, power); vm.prank(_voter); - apella.vote(proposalId, power, _support); + governance.vote(proposalId, power, _support); - DataStructures.Proposal memory fresh = apella.getProposal(proposalId); + DataStructures.Proposal memory fresh = governance.getProposal(proposalId); assertEq(proposal.config.executionDelay, fresh.config.executionDelay, "executionDelay"); assertEq(proposal.config.gracePeriod, fresh.config.gracePeriod, "gracePeriod"); @@ -159,7 +161,7 @@ contract VoteTest is ApellaBase { assertEq(proposal.config.votingDelay, fresh.config.votingDelay, "votingDelay"); assertEq(proposal.config.votingDuration, fresh.config.votingDuration, "votingDuration"); assertEq(proposal.creation, fresh.creation, "creation"); - assertEq(proposal.gerousia, fresh.gerousia, "gerousia"); + assertEq(proposal.governanceProposer, fresh.governanceProposer, "governanceProposer"); assertEq(proposal.summedBallot.nea + (_support ? 0 : power), fresh.summedBallot.nea, "nea"); assertEq(proposal.summedBallot.yea + (_support ? power : 0), fresh.summedBallot.yea, "yea"); // The "written" state is still the same. diff --git a/l1-contracts/test/governance/apella/vote.tree b/l1-contracts/test/governance/governance/vote.tree similarity index 100% rename from l1-contracts/test/governance/apella/vote.tree rename to l1-contracts/test/governance/governance/vote.tree diff --git a/l1-contracts/test/governance/sysstia/Base.t.sol b/l1-contracts/test/governance/reward-distributor/Base.t.sol similarity index 67% rename from l1-contracts/test/governance/sysstia/Base.t.sol rename to l1-contracts/test/governance/reward-distributor/Base.t.sol index 64798c056ebe..8b3c6c511b1c 100644 --- a/l1-contracts/test/governance/sysstia/Base.t.sol +++ b/l1-contracts/test/governance/reward-distributor/Base.t.sol @@ -6,18 +6,18 @@ import {Test} from "forge-std/Test.sol"; import {IMintableERC20} from "@aztec/governance/interfaces/IMintableERC20.sol"; import {Registry} from "@aztec/governance/Registry.sol"; -import {Sysstia} from "@aztec/governance/Sysstia.sol"; +import {RewardDistributor} from "@aztec/governance/RewardDistributor.sol"; import {TestERC20} from "@aztec/mock/TestERC20.sol"; -contract SysstiaBase is Test { +contract RewardDistributorBase is Test { IMintableERC20 internal token; Registry internal registry; - Sysstia internal sysstia; + RewardDistributor internal rewardDistributor; function setUp() public { token = IMintableERC20(address(new TestERC20())); registry = new Registry(address(this)); - sysstia = new Sysstia(token, registry, address(this)); + rewardDistributor = new RewardDistributor(token, registry, address(this)); } } diff --git a/l1-contracts/test/governance/sysstia/claim.t.sol b/l1-contracts/test/governance/reward-distributor/claim.t.sol similarity index 66% rename from l1-contracts/test/governance/sysstia/claim.t.sol rename to l1-contracts/test/governance/reward-distributor/claim.t.sol index 6324178773f9..f4f964acbc4e 100644 --- a/l1-contracts/test/governance/sysstia/claim.t.sol +++ b/l1-contracts/test/governance/reward-distributor/claim.t.sol @@ -1,11 +1,11 @@ // SPDX-License-Identifier: UNLICENSED pragma solidity >=0.8.27; -import {SysstiaBase} from "./Base.t.sol"; +import {RewardDistributorBase} from "./Base.t.sol"; import {Errors} from "@aztec/governance/libraries/Errors.sol"; -contract ClaimTest is SysstiaBase { +contract ClaimTest is RewardDistributorBase { address internal caller; function test_WhenCallerIsNotCanonical(address _caller) external { @@ -13,10 +13,12 @@ contract ClaimTest is SysstiaBase { vm.assume(_caller != address(0xdead)); vm.expectRevert( - abi.encodeWithSelector(Errors.Sysstia__InvalidCaller.selector, _caller, address(0xdead)) + abi.encodeWithSelector( + Errors.RewardDistributor__InvalidCaller.selector, _caller, address(0xdead) + ) ); vm.prank(_caller); - sysstia.claim(_caller); + rewardDistributor.claim(_caller); } modifier whenCallerIsCanonical() { @@ -28,7 +30,7 @@ contract ClaimTest is SysstiaBase { // it return 0 vm.record(); vm.prank(caller); - assertEq(sysstia.claim(caller), 0); + assertEq(rewardDistributor.claim(caller), 0); (, bytes32[] memory writes) = vm.accesses(address(this)); assertEq(writes.length, 0); } @@ -38,19 +40,20 @@ contract ClaimTest is SysstiaBase { // it return min(balance, BLOCK_REWARD) uint256 balance = bound(_balance, 1, type(uint256).max); - token.mint(address(sysstia), balance); + token.mint(address(rewardDistributor), balance); - uint256 reward = balance > sysstia.BLOCK_REWARD() ? sysstia.BLOCK_REWARD() : balance; + uint256 reward = + balance > rewardDistributor.BLOCK_REWARD() ? rewardDistributor.BLOCK_REWARD() : balance; uint256 callerBalance = token.balanceOf(caller); vm.prank(caller); vm.record(); - uint256 claimed = sysstia.claim(caller); + uint256 claimed = rewardDistributor.claim(caller); (, bytes32[] memory writes) = vm.accesses(address(token)); assertEq(claimed, reward); assertEq(token.balanceOf(caller), callerBalance + reward); - assertEq(token.balanceOf(address(sysstia)), balance - reward); + assertEq(token.balanceOf(address(rewardDistributor)), balance - reward); assertEq(writes.length, 2, "writes"); } diff --git a/l1-contracts/test/governance/sysstia/claim.tree b/l1-contracts/test/governance/reward-distributor/claim.tree similarity index 100% rename from l1-contracts/test/governance/sysstia/claim.tree rename to l1-contracts/test/governance/reward-distributor/claim.tree diff --git a/l1-contracts/test/governance/sysstia/updateRegistry.t.sol b/l1-contracts/test/governance/reward-distributor/updateRegistry.t.sol similarity index 50% rename from l1-contracts/test/governance/sysstia/updateRegistry.t.sol rename to l1-contracts/test/governance/reward-distributor/updateRegistry.t.sol index e5d8e402c922..0d278a2d859d 100644 --- a/l1-contracts/test/governance/sysstia/updateRegistry.t.sol +++ b/l1-contracts/test/governance/reward-distributor/updateRegistry.t.sol @@ -1,23 +1,23 @@ // SPDX-License-Identifier: UNLICENSED pragma solidity >=0.8.27; -import {SysstiaBase} from "./Base.t.sol"; +import {RewardDistributorBase} from "./Base.t.sol"; import {Ownable} from "@oz/access/Ownable.sol"; import {Registry} from "@aztec/governance/Registry.sol"; import {IRegistry} from "@aztec/governance/interfaces/IRegistry.sol"; -import {ISysstia} from "@aztec/governance/interfaces/ISysstia.sol"; +import {IRewardDistributor} from "@aztec/governance/interfaces/IRewardDistributor.sol"; -contract UpdateRegistryTest is SysstiaBase { +contract UpdateRegistryTest is RewardDistributorBase { address internal caller; function test_WhenCallerIsNotOwner(address _caller) external { // it reverts - vm.assume(_caller != sysstia.owner()); + vm.assume(_caller != rewardDistributor.owner()); vm.expectRevert(abi.encodeWithSelector(Ownable.OwnableUnauthorizedAccount.selector, _caller)); vm.prank(_caller); - sysstia.updateRegistry(IRegistry(address(0xdead))); + rewardDistributor.updateRegistry(IRegistry(address(0xdead))); } function test_WhenCallerIsOwner() external { @@ -27,17 +27,17 @@ contract UpdateRegistryTest is SysstiaBase { Registry registry = new Registry(address(this)); registry.upgrade(address(0xbeef)); - IRegistry oldRegistry = sysstia.registry(); - address oldCanonical = sysstia.canonicalRollup(); + IRegistry oldRegistry = rewardDistributor.registry(); + address oldCanonical = rewardDistributor.canonicalRollup(); - vm.prank(sysstia.owner()); - vm.expectEmit(true, true, false, true, address(sysstia)); - emit ISysstia.RegistryUpdated(registry); - sysstia.updateRegistry(registry); + vm.prank(rewardDistributor.owner()); + vm.expectEmit(true, true, false, true, address(rewardDistributor)); + emit IRewardDistributor.RegistryUpdated(registry); + rewardDistributor.updateRegistry(registry); - assertEq(address(sysstia.registry()), address(registry)); + assertEq(address(rewardDistributor.registry()), address(registry)); assertNotEq(address(oldRegistry), address(registry)); - assertEq(sysstia.canonicalRollup(), address(0xbeef)); + assertEq(rewardDistributor.canonicalRollup(), address(0xbeef)); assertNotEq(oldCanonical, address(0xbeef)); } } diff --git a/l1-contracts/test/governance/sysstia/updateRegistry.tree b/l1-contracts/test/governance/reward-distributor/updateRegistry.tree similarity index 100% rename from l1-contracts/test/governance/sysstia/updateRegistry.tree rename to l1-contracts/test/governance/reward-distributor/updateRegistry.tree diff --git a/l1-contracts/test/governance/scenario/NewGerousiaPayload.sol b/l1-contracts/test/governance/scenario/NewGerousiaPayload.sol deleted file mode 100644 index ef943ebfbf85..000000000000 --- a/l1-contracts/test/governance/scenario/NewGerousiaPayload.sol +++ /dev/null @@ -1,35 +0,0 @@ -// SPDX-License-Identifier: UNLICENSED -pragma solidity >=0.8.27; - -import {IPayload} from "@aztec/governance/interfaces/IPayload.sol"; -import {IRegistry} from "@aztec/governance/interfaces/IRegistry.sol"; -import {Apella} from "@aztec/governance/Apella.sol"; -import {Gerousia} from "@aztec/governance/Gerousia.sol"; - -/** - * @title NewGerousiaPayload - * @author Aztec Labs - * @notice A payload that upgrades the Gerousia contract to a new version. - */ -contract NewGerousiaPayload is IPayload { - IRegistry public immutable REGISTRY; - address public immutable NEW_GEROUSIA; - - constructor(IRegistry _registry) { - REGISTRY = _registry; - NEW_GEROUSIA = address(new Gerousia(_registry, 667, 1000)); - } - - function getActions() external view override(IPayload) returns (IPayload.Action[] memory) { - IPayload.Action[] memory res = new IPayload.Action[](1); - - Apella apella = Apella(REGISTRY.getApella()); - - res[0] = Action({ - target: address(apella), - data: abi.encodeWithSelector(apella.updateGerousia.selector, NEW_GEROUSIA) - }); - - return res; - } -} diff --git a/l1-contracts/test/governance/scenario/NewGovernanceProposerPayload.sol b/l1-contracts/test/governance/scenario/NewGovernanceProposerPayload.sol new file mode 100644 index 000000000000..613dc7006b47 --- /dev/null +++ b/l1-contracts/test/governance/scenario/NewGovernanceProposerPayload.sol @@ -0,0 +1,37 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity >=0.8.27; + +import {IPayload} from "@aztec/governance/interfaces/IPayload.sol"; +import {IRegistry} from "@aztec/governance/interfaces/IRegistry.sol"; +import {Governance} from "@aztec/governance/Governance.sol"; +import {GovernanceProposer} from "@aztec/governance/GovernanceProposer.sol"; + +/** + * @title NewGovernanceProposerPayload + * @author Aztec Labs + * @notice A payload that upgrades the GovernanceProposer contract to a new version. + */ +contract NewGovernanceProposerPayload is IPayload { + IRegistry public immutable REGISTRY; + address public immutable NEW_GOVERNANCE_PROPOSER; + + constructor(IRegistry _registry) { + REGISTRY = _registry; + NEW_GOVERNANCE_PROPOSER = address(new GovernanceProposer(_registry, 667, 1000)); + } + + function getActions() external view override(IPayload) returns (IPayload.Action[] memory) { + IPayload.Action[] memory res = new IPayload.Action[](1); + + Governance governance = Governance(REGISTRY.getGovernance()); + + res[0] = Action({ + target: address(governance), + data: abi.encodeWithSelector( + governance.updateGovernanceProposer.selector, NEW_GOVERNANCE_PROPOSER + ) + }); + + return res; + } +} diff --git a/l1-contracts/test/governance/scenario/UpgradeGerousia.t.sol b/l1-contracts/test/governance/scenario/UpgradeGovernanceProposerTest.t.sol similarity index 57% rename from l1-contracts/test/governance/scenario/UpgradeGerousia.t.sol rename to l1-contracts/test/governance/scenario/UpgradeGovernanceProposerTest.t.sol index b9f445931684..58a05584806c 100644 --- a/l1-contracts/test/governance/scenario/UpgradeGerousia.t.sol +++ b/l1-contracts/test/governance/scenario/UpgradeGovernanceProposerTest.t.sol @@ -5,8 +5,8 @@ import {IPayload} from "@aztec/governance/interfaces/IPayload.sol"; import {TestBase} from "@test/base/Base.sol"; import {IMintableERC20} from "@aztec/governance/interfaces/IMintableERC20.sol"; import {Rollup} from "@aztec/core/Rollup.sol"; -import {Apella} from "@aztec/governance/Apella.sol"; -import {Gerousia} from "@aztec/governance/Gerousia.sol"; +import {Governance} from "@aztec/governance/Governance.sol"; +import {GovernanceProposer} from "@aztec/governance/GovernanceProposer.sol"; import {Registry} from "@aztec/governance/Registry.sol"; import {DataStructures} from "@aztec/governance/libraries/DataStructures.sol"; import {IMintableERC20} from "@aztec/governance/interfaces/IMintableERC20.sol"; @@ -16,21 +16,21 @@ import {MockFeeJuicePortal} from "@aztec/mock/MockFeeJuicePortal.sol"; import {Slot} from "@aztec/core/libraries/TimeMath.sol"; import {ProposalLib} from "@aztec/governance/libraries/ProposalLib.sol"; import {Errors} from "@aztec/governance/libraries/Errors.sol"; -import {NewGerousiaPayload} from "./NewGerousiaPayload.sol"; -import {Sysstia} from "@aztec/governance/Sysstia.sol"; +import {NewGovernanceProposerPayload} from "./NewGovernanceProposerPayload.sol"; +import {RewardDistributor} from "@aztec/governance/RewardDistributor.sol"; + /** - * @title UpgradeGerousiaTest + * @title UpgradeGovernanceProposerTest * @author Aztec Labs - * @notice A test that showcases an upgrade of the governance system, here the gerousia contract. + * @notice A test that showcases an upgrade of the governance system, here the governanceProposer contract. */ - -contract UpgradeGerousiaTest is TestBase { +contract UpgradeGovernanceProposerTest is TestBase { using ProposalLib for DataStructures.Proposal; IMintableERC20 internal token; Registry internal registry; - Apella internal apella; - Gerousia internal gerousia; + Governance internal governance; + GovernanceProposer internal governanceProposer; Rollup internal rollup; DataStructures.Proposal internal proposal; @@ -47,9 +47,9 @@ contract UpgradeGerousiaTest is TestBase { token = IMintableERC20(address(new TestERC20())); registry = new Registry(address(this)); - gerousia = new Gerousia(registry, 7, 10); + governanceProposer = new GovernanceProposer(registry, 7, 10); - apella = new Apella(token, address(gerousia)); + governance = new Governance(token, address(governanceProposer)); address[] memory initialValidators = new address[](VALIDATOR_COUNT); for (uint256 i = 1; i <= VALIDATOR_COUNT; i++) { @@ -60,64 +60,72 @@ contract UpgradeGerousiaTest is TestBase { initialValidators[i - 1] = validator; } - Sysstia sysstia = new Sysstia(token, registry, address(this)); + RewardDistributor rewardDistributor = new RewardDistributor(token, registry, address(this)); rollup = new Rollup( - new MockFeeJuicePortal(), sysstia, bytes32(0), bytes32(0), address(this), initialValidators + new MockFeeJuicePortal(), + rewardDistributor, + bytes32(0), + bytes32(0), + address(this), + initialValidators ); registry.upgrade(address(rollup)); - registry.transferOwnership(address(apella)); + registry.transferOwnership(address(governance)); } function test_UpgradeIntoNewVersion() external { - payload = IPayload(address(new NewGerousiaPayload(registry))); + payload = IPayload(address(new NewGovernanceProposerPayload(registry))); vm.warp(Timestamp.unwrap(rollup.getTimestampForSlot(Slot.wrap(1)))); for (uint256 i = 0; i < 10; i++) { address proposer = rollup.getCurrentProposer(); vm.prank(proposer); - gerousia.vote(payload); + governanceProposer.vote(payload); vm.warp(Timestamp.unwrap(rollup.getTimestampForSlot(rollup.getCurrentSlot() + Slot.wrap(1)))); } - gerousia.pushProposal(0); - proposal = apella.getProposal(0); + governanceProposer.pushProposal(0); + proposal = governance.getProposal(0); assertEq(address(proposal.payload), address(payload)); token.mint(EMPEROR, 10000 ether); vm.startPrank(EMPEROR); - token.approve(address(apella), 10000 ether); - apella.deposit(EMPEROR, 10000 ether); + token.approve(address(governance), 10000 ether); + governance.deposit(EMPEROR, 10000 ether); vm.stopPrank(); vm.warp(Timestamp.unwrap(proposal.pendingThrough()) + 1); - assertTrue(apella.getProposalState(0) == DataStructures.ProposalState.Active); + assertTrue(governance.getProposalState(0) == DataStructures.ProposalState.Active); vm.prank(EMPEROR); - apella.vote(0, 10000 ether, true); + governance.vote(0, 10000 ether, true); vm.warp(Timestamp.unwrap(proposal.activeThrough()) + 1); - assertTrue(apella.getProposalState(0) == DataStructures.ProposalState.Queued); + assertTrue(governance.getProposalState(0) == DataStructures.ProposalState.Queued); vm.warp(Timestamp.unwrap(proposal.queuedThrough()) + 1); - assertTrue(apella.getProposalState(0) == DataStructures.ProposalState.Executable); - assertEq(apella.gerousia(), address(gerousia)); + assertTrue(governance.getProposalState(0) == DataStructures.ProposalState.Executable); + assertEq(governance.governanceProposer(), address(governanceProposer)); - apella.execute(0); + governance.execute(0); - assertNotEq(apella.gerousia(), address(gerousia)); - address newGerousia = address(NewGerousiaPayload(address(payload)).NEW_GEROUSIA()); - assertEq(apella.gerousia(), newGerousia); + assertNotEq(governance.governanceProposer(), address(governanceProposer)); + address newGovernanceProposer = + address(NewGovernanceProposerPayload(address(payload)).NEW_GOVERNANCE_PROPOSER()); + assertEq(governance.governanceProposer(), newGovernanceProposer); // Ensure that we cannot push a proposal after the upgrade. vm.expectRevert( abi.encodeWithSelector( - Errors.Apella__CallerNotGerousia.selector, address(gerousia), newGerousia + Errors.Governance__CallerNotGovernanceProposer.selector, + address(governanceProposer), + newGovernanceProposer ) ); - vm.prank(address(gerousia)); - apella.propose(payload); + vm.prank(address(governanceProposer)); + governance.propose(payload); } } diff --git a/l1-contracts/test/harnesses/Frontier.sol b/l1-contracts/test/harnesses/Frontier.sol index 60cc4d800a1a..719e5692c8b5 100644 --- a/l1-contracts/test/harnesses/Frontier.sol +++ b/l1-contracts/test/harnesses/Frontier.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: Apache-2.0 -// Copyright 2023 Aztec Labs. +// Copyright 2024 Aztec Labs. pragma solidity >=0.8.27; import {FrontierLib} from "@aztec/core/libraries/crypto/FrontierLib.sol"; diff --git a/l1-contracts/test/harnesses/InboxHarness.sol b/l1-contracts/test/harnesses/InboxHarness.sol index f88f266270df..a9e1779d6d3c 100644 --- a/l1-contracts/test/harnesses/InboxHarness.sol +++ b/l1-contracts/test/harnesses/InboxHarness.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: Apache-2.0 -// Copyright 2023 Aztec Labs. +// Copyright 2024 Aztec Labs. pragma solidity >=0.8.27; import {Inbox} from "@aztec/core/messagebridge/Inbox.sol"; diff --git a/l1-contracts/test/portals/TokenPortal.t.sol b/l1-contracts/test/portals/TokenPortal.t.sol index d462f0e16aa8..51df3054a537 100644 --- a/l1-contracts/test/portals/TokenPortal.t.sol +++ b/l1-contracts/test/portals/TokenPortal.t.sol @@ -20,7 +20,7 @@ import {TestERC20} from "@aztec/mock/TestERC20.sol"; import {NaiveMerkle} from "../merkle/Naive.sol"; import {MockFeeJuicePortal} from "@aztec/mock/MockFeeJuicePortal.sol"; -import {Sysstia} from "@aztec/governance/Sysstia.sol"; +import {RewardDistributor} from "@aztec/governance/RewardDistributor.sol"; contract TokenPortalTest is Test { using Hash for DataStructures.L1ToL2Msg; @@ -31,7 +31,7 @@ contract TokenPortalTest is Test { uint256 internal constant L1_TO_L2_MSG_SUBTREE_SIZE = 2 ** Constants.L1_TO_L2_MSG_SUBTREE_HEIGHT; Registry internal registry; - Sysstia internal sysstia; + RewardDistributor internal rewardDistributor; IInbox internal inbox; IOutbox internal outbox; @@ -62,9 +62,14 @@ contract TokenPortalTest is Test { function setUp() public { registry = new Registry(address(this)); testERC20 = new TestERC20(); - sysstia = new Sysstia(testERC20, registry, address(this)); + rewardDistributor = new RewardDistributor(testERC20, registry, address(this)); rollup = new Rollup( - new MockFeeJuicePortal(), sysstia, bytes32(0), bytes32(0), address(this), new address[](0) + new MockFeeJuicePortal(), + rewardDistributor, + bytes32(0), + bytes32(0), + address(this), + new address[](0) ); inbox = rollup.INBOX(); outbox = rollup.OUTBOX(); diff --git a/l1-contracts/test/portals/UniswapPortal.t.sol b/l1-contracts/test/portals/UniswapPortal.t.sol index b96c59ff8c8b..11783bead7d1 100644 --- a/l1-contracts/test/portals/UniswapPortal.t.sol +++ b/l1-contracts/test/portals/UniswapPortal.t.sol @@ -20,7 +20,7 @@ import {TokenPortal} from "./TokenPortal.sol"; import {UniswapPortal} from "./UniswapPortal.sol"; import {MockFeeJuicePortal} from "@aztec/mock/MockFeeJuicePortal.sol"; -import {Sysstia} from "@aztec/governance/Sysstia.sol"; +import {RewardDistributor} from "@aztec/governance/RewardDistributor.sol"; contract UniswapPortalTest is Test { using Hash for DataStructures.L2ToL1Msg; @@ -54,9 +54,14 @@ contract UniswapPortalTest is Test { vm.selectFork(forkId); registry = new Registry(address(this)); - Sysstia sysstia = new Sysstia(DAI, registry, address(this)); + RewardDistributor rewardDistributor = new RewardDistributor(DAI, registry, address(this)); rollup = new Rollup( - new MockFeeJuicePortal(), sysstia, bytes32(0), bytes32(0), address(this), new address[](0) + new MockFeeJuicePortal(), + rewardDistributor, + bytes32(0), + bytes32(0), + address(this), + new address[](0) ); registry.upgrade(address(rollup)); diff --git a/l1-contracts/test/sparta/Sampling.t.sol b/l1-contracts/test/sparta/Sampling.t.sol index 8e6932f1d239..013512c877bc 100644 --- a/l1-contracts/test/sparta/Sampling.t.sol +++ b/l1-contracts/test/sparta/Sampling.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: Apache-2.0 -// Copyright 2023 Aztec Labs. +// Copyright 2024 Aztec Labs. pragma solidity >=0.8.27; import {Test} from "forge-std/Test.sol"; diff --git a/l1-contracts/test/sparta/Sparta.t.sol b/l1-contracts/test/sparta/Sparta.t.sol index 4df558471fe3..e892c5e54a52 100644 --- a/l1-contracts/test/sparta/Sparta.t.sol +++ b/l1-contracts/test/sparta/Sparta.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: Apache-2.0 -// Copyright 2023 Aztec Labs. +// Copyright 2024 Aztec Labs. pragma solidity >=0.8.27; import {DecoderBase} from "../decoders/Base.sol"; @@ -22,7 +22,7 @@ import {MessageHashUtils} from "@oz/utils/cryptography/MessageHashUtils.sol"; import {MockFeeJuicePortal} from "@aztec/mock/MockFeeJuicePortal.sol"; import {Slot, Epoch, SlotLib, EpochLib} from "@aztec/core/libraries/TimeMath.sol"; -import {Sysstia} from "@aztec/governance/Sysstia.sol"; +import {RewardDistributor} from "@aztec/governance/RewardDistributor.sol"; // solhint-disable comprehensive-interface /** @@ -46,7 +46,7 @@ contract SpartaTest is DecoderBase { MerkleTestUtil internal merkleTestUtil; TxsDecoderHelper internal txsHelper; TestERC20 internal testERC20; - Sysstia internal sysstia; + RewardDistributor internal rewardDistributor; SignatureLib.Signature internal emptySignature; mapping(address validator => uint256 privateKey) internal privateKeys; mapping(address => bool) internal _seenValidators; @@ -76,9 +76,14 @@ contract SpartaTest is DecoderBase { testERC20 = new TestERC20(); Registry registry = new Registry(address(this)); - sysstia = new Sysstia(testERC20, registry, address(this)); + rewardDistributor = new RewardDistributor(testERC20, registry, address(this)); rollup = new Rollup( - new MockFeeJuicePortal(), sysstia, bytes32(0), bytes32(0), address(this), initialValidators + new MockFeeJuicePortal(), + rewardDistributor, + bytes32(0), + bytes32(0), + address(this), + initialValidators ); inbox = Inbox(address(rollup.INBOX())); outbox = Outbox(address(rollup.OUTBOX())); diff --git a/spartan/aztec-network/files/config/config-prover-env.sh b/spartan/aztec-network/files/config/config-prover-env.sh index cdb44e9b2d1f..4ee7106cb731 100644 --- a/spartan/aztec-network/files/config/config-prover-env.sh +++ b/spartan/aztec-network/files/config/config-prover-env.sh @@ -16,10 +16,10 @@ inbox_address=$(echo "$output" | grep -oP 'L1 -> L2 Inbox Address: \K0x[a-fA-F0- outbox_address=$(echo "$output" | grep -oP 'L2 -> L1 Outbox Address: \K0x[a-fA-F0-9]{40}') fee_juice_address=$(echo "$output" | grep -oP 'Fee Juice Address: \K0x[a-fA-F0-9]{40}') fee_juice_portal_address=$(echo "$output" | grep -oP 'Fee Juice Portal Address: \K0x[a-fA-F0-9]{40}') -nomismatokopio_address=$(echo "$output" | grep -oP 'Nomismatokopio Address: \K0x[a-fA-F0-9]{40}') -sysstia_address=$(echo "$output" | grep -oP 'Sysstia Address: \K0x[a-fA-F0-9]{40}') -gerousia_address=$(echo "$output" | grep -oP 'Gerousia Address: \K0x[a-fA-F0-9]{40}') -apella_address=$(echo "$output" | grep -oP 'Apella Address: \K0x[a-fA-F0-9]{40}') +coin_issuer_address=$(echo "$output" | grep -oP 'CoinIssuer Address: \K0x[a-fA-F0-9]{40}') +reward_distributor_address=$(echo "$output" | grep -oP 'RewardDistributor Address: \K0x[a-fA-F0-9]{40}') +governance_proposer_address=$(echo "$output" | grep -oP 'GovernanceProposer Address: \K0x[a-fA-F0-9]{40}') +governance_address=$(echo "$output" | grep -oP 'Governance Address: \K0x[a-fA-F0-9]{40}') # Write the addresses to a file in the shared volume cat < /shared/contracts.env @@ -30,10 +30,10 @@ export INBOX_CONTRACT_ADDRESS=$inbox_address export OUTBOX_CONTRACT_ADDRESS=$outbox_address export FEE_JUICE_CONTRACT_ADDRESS=$fee_juice_address export FEE_JUICE_PORTAL_CONTRACT_ADDRESS=$fee_juice_portal_address -export NOMISMATOKOPIO_CONTRACT_ADDRESS=$nomismatokopio_address -export SYSSTIA_CONTRACT_ADDRESS=$sysstia_address -export GEROUSIA_CONTRACT_ADDRESS=$gerousia_address -export APELLA_CONTRACT_ADDRESS=$apella_address +export COIN_ISSUER_CONTRACT_ADDRESS=$coin_issuer_address +export REWARD_DISTRIBUTOR_CONTRACT_ADDRESS=$reward_distributor_address +export GOVERNANCE_PROPOSER_CONTRACT_ADDRESS=$governance_proposer_address +export GOVERNANCE_CONTRACT_ADDRESS=$governance_address EOF cat /shared/contracts.env diff --git a/spartan/aztec-network/files/config/config-validator-env.sh b/spartan/aztec-network/files/config/config-validator-env.sh index e60d578771fd..174482492c47 100644 --- a/spartan/aztec-network/files/config/config-validator-env.sh +++ b/spartan/aztec-network/files/config/config-validator-env.sh @@ -16,10 +16,10 @@ inbox_address=$(echo "$output" | grep -oP 'L1 -> L2 Inbox Address: \K0x[a-fA-F0- outbox_address=$(echo "$output" | grep -oP 'L2 -> L1 Outbox Address: \K0x[a-fA-F0-9]{40}') fee_juice_address=$(echo "$output" | grep -oP 'Fee Juice Address: \K0x[a-fA-F0-9]{40}') fee_juice_portal_address=$(echo "$output" | grep -oP 'Fee Juice Portal Address: \K0x[a-fA-F0-9]{40}') -nomismatokopio_address=$(echo "$output" | grep -oP 'Nomismatokopio Address: \K0x[a-fA-F0-9]{40}') -sysstia_address=$(echo "$output" | grep -oP 'Sysstia Address: \K0x[a-fA-F0-9]{40}') -gerousia_address=$(echo "$output" | grep -oP 'Gerousia Address: \K0x[a-fA-F0-9]{40}') -apella_address=$(echo "$output" | grep -oP 'Apella Address: \K0x[a-fA-F0-9]{40}') +coin_issuer_address=$(echo "$output" | grep -oP 'CoinIssuer Address: \K0x[a-fA-F0-9]{40}') +reward_distributor_address=$(echo "$output" | grep -oP 'RewardDistributor Address: \K0x[a-fA-F0-9]{40}') +governance_proposer_address=$(echo "$output" | grep -oP 'GovernanceProposer Address: \K0x[a-fA-F0-9]{40}') +governance_address=$(echo "$output" | grep -oP 'Governance Address: \K0x[a-fA-F0-9]{40}') # We assume that there is an env var set for validator keys from the config map # We get the index in the config map from the pod name, which will have the validator index within it @@ -36,10 +36,10 @@ export INBOX_CONTRACT_ADDRESS=$inbox_address export OUTBOX_CONTRACT_ADDRESS=$outbox_address export FEE_JUICE_CONTRACT_ADDRESS=$fee_juice_address export FEE_JUICE_PORTAL_CONTRACT_ADDRESS=$fee_juice_portal_address -export NOMISMATOKOPIO_CONTRACT_ADDRESS=$nomismatokopio_address -export SYSSTIA_CONTRACT_ADDRESS=$sysstia_address -export GEROUSIA_CONTRACT_ADDRESS=$gerousia_address -export APELLA_CONTRACT_ADDRESS=$apella_address +export COIN_ISSUER_CONTRACT_ADDRESS=$coin_issuer_address +export REWARD_DISTRIBUTOR_CONTRACT_ADDRESS=$reward_distributor_address +export GOVERNANCE_PROPOSER_CONTRACT_ADDRESS=$governance_proposer_address +export GOVERNANCE_CONTRACT_ADDRESS=$governance_address export VALIDATOR_PRIVATE_KEY=$private_key export L1_PRIVATE_KEY=$private_key export SEQ_PUBLISHER_PRIVATE_KEY=$private_key diff --git a/spartan/aztec-network/files/config/deploy-l1-contracts.sh b/spartan/aztec-network/files/config/deploy-l1-contracts.sh index 532ca4b9239f..114820ff4a1f 100644 --- a/spartan/aztec-network/files/config/deploy-l1-contracts.sh +++ b/spartan/aztec-network/files/config/deploy-l1-contracts.sh @@ -21,10 +21,10 @@ inbox_address=$(echo "$output" | grep -oP 'L1 -> L2 Inbox Address: \K0x[a-fA-F0- outbox_address=$(echo "$output" | grep -oP 'L2 -> L1 Outbox Address: \K0x[a-fA-F0-9]{40}') fee_juice_address=$(echo "$output" | grep -oP 'Fee Juice Address: \K0x[a-fA-F0-9]{40}') fee_juice_portal_address=$(echo "$output" | grep -oP 'Fee Juice Portal Address: \K0x[a-fA-F0-9]{40}') -nomismatokopio_address=$(echo "$output" | grep -oP 'Nomismatokopio Address: \K0x[a-fA-F0-9]{40}') -sysstia_address=$(echo "$output" | grep -oP 'Sysstia Address: \K0x[a-fA-F0-9]{40}') -gerousia_address=$(echo "$output" | grep -oP 'Gerousia Address: \K0x[a-fA-F0-9]{40}') -apella_address=$(echo "$output" | grep -oP 'Apella Address: \K0x[a-fA-F0-9]{40}') +coin_issuer_address=$(echo "$output" | grep -oP 'CoinIssuer Address: \K0x[a-fA-F0-9]{40}') +reward_distributor_address=$(echo "$output" | grep -oP 'RewardDistributor Address: \K0x[a-fA-F0-9]{40}') +governance_proposer_address=$(echo "$output" | grep -oP 'GovernanceProposer Address: \K0x[a-fA-F0-9]{40}') +governance_address=$(echo "$output" | grep -oP 'Governance Address: \K0x[a-fA-F0-9]{40}') # Write the addresses to a file in the shared volume cat < /shared/contracts.env @@ -34,10 +34,10 @@ export INBOX_CONTRACT_ADDRESS=$inbox_address export OUTBOX_CONTRACT_ADDRESS=$outbox_address export FEE_JUICE_CONTRACT_ADDRESS=$fee_juice_address export FEE_JUICE_PORTAL_CONTRACT_ADDRESS=$fee_juice_portal_address -export NOMISMATOKOPIO_CONTRACT_ADDRESS=$nomismatokopio_address -export SYSSTIA_CONTRACT_ADDRESS=$sysstia_address -export GEROUSIA_CONTRACT_ADDRESS=$gerousia_address -export APELLA_CONTRACT_ADDRESS=$apella_address +export COIN_ISSUER_CONTRACT_ADDRESS=$coin_issuer_address +export REWARD_DISTRIBUTOR_CONTRACT_ADDRESS=$reward_distributor_address +export GOVERNANCE_PROPOSER_CONTRACT_ADDRESS=$governance_proposer_address +export GOVERNANCE_CONTRACT_ADDRESS=$governance_address EOF cat /shared/contracts.env diff --git a/yarn-project/aztec.js/src/contract/contract.test.ts b/yarn-project/aztec.js/src/contract/contract.test.ts index 751571bc537b..8658743a10bc 100644 --- a/yarn-project/aztec.js/src/contract/contract.test.ts +++ b/yarn-project/aztec.js/src/contract/contract.test.ts @@ -41,10 +41,10 @@ describe('Contract Class', () => { outboxAddress: EthAddress.random(), feeJuiceAddress: EthAddress.random(), feeJuicePortalAddress: EthAddress.random(), - apellaAddress: EthAddress.random(), - nomismatokopioAddress: EthAddress.random(), - sysstiaAddress: EthAddress.random(), - gerousiaAddress: EthAddress.random(), + governanceAddress: EthAddress.random(), + coinIssuerAddress: EthAddress.random(), + rewardDistributorAddress: EthAddress.random(), + governanceProposerAddress: EthAddress.random(), }; const mockNodeInfo: NodeInfo = { nodeVersion: 'vx.x.x', diff --git a/yarn-project/circuit-types/src/interfaces/configs.ts b/yarn-project/circuit-types/src/interfaces/configs.ts index 262229d6e6dd..45e6a37ca7cc 100644 --- a/yarn-project/circuit-types/src/interfaces/configs.ts +++ b/yarn-project/circuit-types/src/interfaces/configs.ts @@ -38,7 +38,7 @@ export interface SequencerConfig { /** Whether to require every tx to have a fee payer */ enforceFees?: boolean; /** Payload address to vote for */ - gerousiaPayload?: EthAddress; + governanceProposerPayload?: EthAddress; /** Whether to enforce the time table when building blocks */ enforceTimeTable?: boolean; } diff --git a/yarn-project/cli/src/cmds/l1/deploy_l1_contracts.ts b/yarn-project/cli/src/cmds/l1/deploy_l1_contracts.ts index fcc44b39e7d5..cb16ce26dc23 100644 --- a/yarn-project/cli/src/cmds/l1/deploy_l1_contracts.ts +++ b/yarn-project/cli/src/cmds/l1/deploy_l1_contracts.ts @@ -39,9 +39,9 @@ export async function deployL1Contracts( log(`L2 -> L1 Outbox Address: ${l1ContractAddresses.outboxAddress.toString()}`); log(`Fee Juice Address: ${l1ContractAddresses.feeJuiceAddress.toString()}`); log(`Fee Juice Portal Address: ${l1ContractAddresses.feeJuicePortalAddress.toString()}`); - log(`Nomismatokopio Address: ${l1ContractAddresses.nomismatokopioAddress.toString()}`); - log(`Sysstia Address: ${l1ContractAddresses.sysstiaAddress.toString()}`); - log(`Gerousia Address: ${l1ContractAddresses.gerousiaAddress.toString()}`); - log(`Apella Address: ${l1ContractAddresses.apellaAddress.toString()}`); + log(`CoinIssuer Address: ${l1ContractAddresses.coinIssuerAddress.toString()}`); + log(`RewardDistributor Address: ${l1ContractAddresses.rewardDistributorAddress.toString()}`); + log(`GovernanceProposer Address: ${l1ContractAddresses.governanceProposerAddress.toString()}`); + log(`Governance Address: ${l1ContractAddresses.governanceAddress.toString()}`); } } diff --git a/yarn-project/cli/src/cmds/pxe/get_node_info.ts b/yarn-project/cli/src/cmds/pxe/get_node_info.ts index 473fb690e7d2..dd5939277fb1 100644 --- a/yarn-project/cli/src/cmds/pxe/get_node_info.ts +++ b/yarn-project/cli/src/cmds/pxe/get_node_info.ts @@ -15,10 +15,10 @@ export async function getNodeInfo(rpcUrl: string, debugLogger: DebugLogger, log: log(` L2 -> L1 Outbox Address: ${info.l1ContractAddresses.outboxAddress.toString()}`); log(` Fee Juice Address: ${info.l1ContractAddresses.feeJuiceAddress.toString()}`); log(` Fee Juice Portal Address: ${info.l1ContractAddresses.feeJuicePortalAddress.toString()}`); - log(` Nomismatokopio Address: ${info.l1ContractAddresses.nomismatokopioAddress.toString()}`); - log(` Sysstia Address: ${info.l1ContractAddresses.sysstiaAddress.toString()}`); - log(` Gerousia Address: ${info.l1ContractAddresses.gerousiaAddress.toString()}`); - log(` Apella Address: ${info.l1ContractAddresses.apellaAddress.toString()}`); + log(` CoinIssuer Address: ${info.l1ContractAddresses.coinIssuerAddress.toString()}`); + log(` RewardDistributor Address: ${info.l1ContractAddresses.rewardDistributorAddress.toString()}`); + log(` GovernanceProposer Address: ${info.l1ContractAddresses.governanceProposerAddress.toString()}`); + log(` Governance Address: ${info.l1ContractAddresses.governanceAddress.toString()}`); log(`L2 Contract Addresses:`); log(` Class Registerer: ${info.protocolContractAddresses.classRegisterer.toString()}`); diff --git a/yarn-project/end-to-end/scripts/native-network/deploy-l1-contracts.sh b/yarn-project/end-to-end/scripts/native-network/deploy-l1-contracts.sh index 4ee84d7f3914..9e9dad3f195f 100755 --- a/yarn-project/end-to-end/scripts/native-network/deploy-l1-contracts.sh +++ b/yarn-project/end-to-end/scripts/native-network/deploy-l1-contracts.sh @@ -43,10 +43,10 @@ INBOX_CONTRACT_ADDRESS=$(echo "$output" | grep -oP 'L1 -> L2 Inbox Address: \K0x OUTBOX_CONTRACT_ADDRESS=$(echo "$output" | grep -oP 'L2 -> L1 Outbox Address: \K0x[a-fA-F0-9]{40}') FEE_JUICE_CONTRACT_ADDRESS=$(echo "$output" | grep -oP 'Fee Juice Address: \K0x[a-fA-F0-9]{40}') FEE_JUICE_PORTAL_CONTRACT_ADDRESS=$(echo "$output" | grep -oP 'Fee Juice Portal Address: \K0x[a-fA-F0-9]{40}') -NOMISMATOKOPIO_CONTRACT_ADDRESS=$(echo "$output" | grep -oP 'Nomismatokopio Address: \K0x[a-fA-F0-9]{40}') -SYSSTIA_CONTRACT_ADDRESS=$(echo "$output" | grep -oP 'Sysstia Address: \K0x[a-fA-F0-9]{40}') -GEROUSIA_CONTRACT_ADDRESS=$(echo "$output" | grep -oP 'Gerousia Address: \K0x[a-fA-F0-9]{40}') -APELLA_CONTRACT_ADDRESS=$(echo "$output" | grep -oP 'Apella Address: \K0x[a-fA-F0-9]{40}') +COIN_ISSUER_CONTRACT_ADDRESS=$(echo "$output" | grep -oP 'CoinIssuer Address: \K0x[a-fA-F0-9]{40}') +REWARD_DISTRIBUTOR_CONTRACT_ADDRESS=$(echo "$output" | grep -oP 'RewardDistributor Address: \K0x[a-fA-F0-9]{40}') +GOVERNANCE_PROPOSER_CONTRACT_ADDRESS=$(echo "$output" | grep -oP 'GovernanceProposer Address: \K0x[a-fA-F0-9]{40}') +GOVERNANCE_CONTRACT_ADDRESS=$(echo "$output" | grep -oP 'Governance Address: \K0x[a-fA-F0-9]{40}') # Save contract addresses to state/l1-contracts.env @@ -57,10 +57,10 @@ export INBOX_CONTRACT_ADDRESS=$INBOX_CONTRACT_ADDRESS export OUTBOX_CONTRACT_ADDRESS=$OUTBOX_CONTRACT_ADDRESS export FEE_JUICE_CONTRACT_ADDRESS=$FEE_JUICE_CONTRACT_ADDRESS export FEE_JUICE_PORTAL_CONTRACT_ADDRESS=$FEE_JUICE_PORTAL_CONTRACT_ADDRESS -export NOMISMATOKOPIO_CONTRACT_ADDRESS=$NOMISMATOKOPIO_CONTRACT_ADDRESS -export SYSSTIA_CONTRACT_ADDRESS=$SYSSTIA_CONTRACT_ADDRESS -export GEROUSIA_CONTRACT_ADDRESS=$GEROUSIA_CONTRACT_ADDRESS -export APELLA_CONTRACT_ADDRESS=$APELLA_CONTRACT_ADDRESS +export COIN_ISSUER_CONTRACT_ADDRESS=$COIN_ISSUER_CONTRACT_ADDRESS +export REWARD_DISTRIBUTOR_CONTRACT_ADDRESS=$REWARD_DISTRIBUTOR_CONTRACT_ADDRESS +export GOVERNANCE_PROPOSER_CONTRACT_ADDRESS=$GOVERNANCE_PROPOSER_CONTRACT_ADDRESS +export GOVERNANCE_CONTRACT_ADDRESS=$GOVERNANCE_CONTRACT_ADDRESS EOCONFIG echo "Contract addresses saved to state/l1-contracts.env" diff --git a/yarn-project/end-to-end/src/e2e_p2p/gerousia.test.ts b/yarn-project/end-to-end/src/e2e_p2p/upgrade_governance_proposer.test.ts similarity index 75% rename from yarn-project/end-to-end/src/e2e_p2p/gerousia.test.ts rename to yarn-project/end-to-end/src/e2e_p2p/upgrade_governance_proposer.test.ts index 7a6e90d62581..1340958204a8 100644 --- a/yarn-project/end-to-end/src/e2e_p2p/gerousia.test.ts +++ b/yarn-project/end-to-end/src/e2e_p2p/upgrade_governance_proposer.test.ts @@ -1,11 +1,11 @@ import { type AztecNodeService } from '@aztec/aztec-node'; import { deployL1Contract, sleep } from '@aztec/aztec.js'; import { - ApellaAbi, TestERC20Abi as FeeJuiceAbi, - GerousiaAbi, - NewGerousiaPayloadAbi, - NewGerousiaPayloadBytecode, + GovernanceAbi, + GovernanceProposerAbi, + NewGovernanceProposerPayloadAbi, + NewGovernanceProposerPayloadBytecode, RollupAbi, } from '@aztec/l1-artifacts'; @@ -22,10 +22,10 @@ const BOOT_NODE_UDP_PORT = 40600; const DATA_DIR = './data/gossip'; /** - * This tests emulate the same test as in l1-contracts/test/governance/scenario/full.t.sol + * This tests emulate the same test as in l1-contracts/test/governance/scenario/UpgradeGovernanceProposerTest.t.sol * but it does so in an end-to-end manner with multiple "real" nodes. */ -describe('e2e_p2p_gerousia', () => { +describe('e2e_p2p_governance_proposer', () => { let t: P2PNetworkTest; let nodes: AztecNodeService[]; @@ -48,21 +48,21 @@ describe('e2e_p2p_gerousia', () => { * For this reason we are not running it as part of the CI. * TODO(https://github.com/AztecProtocol/aztec-packages/issues/9164): Currently flakey */ - it('Should cast votes to upgrade gerousia', async () => { + it('Should cast votes to upgrade governanceProposer', async () => { // create the bootstrap node for the network if (!t.bootstrapNodeEnr) { throw new Error('Bootstrap node ENR is not available'); } - const gerousia = getContract({ - address: getAddress(t.ctx.deployL1ContractsValues.l1ContractAddresses.gerousiaAddress.toString()), - abi: GerousiaAbi, + const governanceProposer = getContract({ + address: getAddress(t.ctx.deployL1ContractsValues.l1ContractAddresses.governanceProposerAddress.toString()), + abi: GovernanceProposerAbi, client: t.ctx.deployL1ContractsValues.publicClient, }); - const apella = getContract({ - address: getAddress(t.ctx.deployL1ContractsValues.l1ContractAddresses.apellaAddress.toString()), - abi: ApellaAbi, + const governance = getContract({ + address: getAddress(t.ctx.deployL1ContractsValues.l1ContractAddresses.governanceAddress.toString()), + abi: GovernanceAbi, client: t.ctx.deployL1ContractsValues.publicClient, }); @@ -90,8 +90,8 @@ describe('e2e_p2p_gerousia', () => { const { address: newPayloadAddress } = await deployL1Contract( t.ctx.deployL1ContractsValues.walletClient, t.ctx.deployL1ContractsValues.publicClient, - NewGerousiaPayloadAbi, - NewGerousiaPayloadBytecode, + NewGovernanceProposerPayloadAbi, + NewGovernanceProposerPayloadBytecode, [t.ctx.deployL1ContractsValues.l1ContractAddresses.registryAddress.toString()], ); @@ -102,13 +102,13 @@ describe('e2e_p2p_gerousia', () => { const govInfo = async () => { const bn = await t.ctx.cheatCodes.eth.blockNumber(); const slot = await rollup.read.getCurrentSlot(); - const round = await gerousia.read.computeRound([slot]); + const round = await governanceProposer.read.computeRound([slot]); - const info = await gerousia.read.rounds([ + const info = await governanceProposer.read.rounds([ t.ctx.deployL1ContractsValues.l1ContractAddresses.rollupAddress.toString(), round, ]); - const leaderVotes = await gerousia.read.yeaCount([ + const leaderVotes = await governanceProposer.read.yeaCount([ t.ctx.deployL1ContractsValues.l1ContractAddresses.rollupAddress.toString(), round, info[1], @@ -125,7 +125,7 @@ describe('e2e_p2p_gerousia', () => { t.logger.info('Creating nodes'); nodes = await createNodes( - { ...t.ctx.aztecNodeConfig, gerousiaPayload: newPayloadAddress }, + { ...t.ctx.aztecNodeConfig, governanceProposerPayload: newPayloadAddress }, t.peerIdPrivateKeys, t.bootstrapNodeEnr, NUM_NODES, @@ -136,8 +136,8 @@ describe('e2e_p2p_gerousia', () => { await sleep(4000); t.logger.info('Start progressing time to cast votes'); - const quorumSize = await gerousia.read.N(); - t.logger.info(`Quorum size: ${quorumSize}, round size: ${await gerousia.read.M()}`); + const quorumSize = await governanceProposer.read.N(); + t.logger.info(`Quorum size: ${quorumSize}, round size: ${await governanceProposer.read.M()}`); let govData; while (true) { @@ -157,7 +157,7 @@ describe('e2e_p2p_gerousia', () => { await waitL1Block(); - const txHash = await gerousia.write.pushProposal([govData.round], { account: emperor, gas: 1_000_000n }); + const txHash = await governanceProposer.write.pushProposal([govData.round], { account: emperor, gas: 1_000_000n }); await t.ctx.deployL1ContractsValues.publicClient.waitForTransactionReceipt({ hash: txHash }); const token = getContract({ @@ -167,18 +167,18 @@ describe('e2e_p2p_gerousia', () => { }); await token.write.mint([emperor.address, 10000n * 10n ** 18n], { account: emperor }); - await token.write.approve([apella.address, 10000n * 10n ** 18n], { account: emperor }); - const depositTx = await apella.write.deposit([emperor.address, 10000n * 10n ** 18n], { account: emperor }); + await token.write.approve([governance.address, 10000n * 10n ** 18n], { account: emperor }); + const depositTx = await governance.write.deposit([emperor.address, 10000n * 10n ** 18n], { account: emperor }); await t.ctx.deployL1ContractsValues.publicClient.waitForTransactionReceipt({ hash: depositTx }); - const proposal = await apella.read.getProposal([0n]); + const proposal = await governance.read.getProposal([0n]); const timeToActive = proposal.creation + proposal.config.votingDelay; await t.ctx.cheatCodes.eth.warp(Number(timeToActive + 1n)); await waitL1Block(); - const voteTx = await apella.write.vote([0n, 10000n * 10n ** 18n, true], { account: emperor }); + const voteTx = await governance.write.vote([0n, 10000n * 10n ** 18n, true], { account: emperor }); await t.ctx.deployL1ContractsValues.publicClient.waitForTransactionReceipt({ hash: voteTx }); const timeToExecutable = timeToActive + proposal.config.votingDuration + proposal.config.executionDelay + 1n; @@ -186,18 +186,18 @@ describe('e2e_p2p_gerousia', () => { await waitL1Block(); - expect(await apella.read.gerousia()).toEqual( - getAddress(t.ctx.deployL1ContractsValues.l1ContractAddresses.gerousiaAddress.toString()), + expect(await governance.read.governanceProposer()).toEqual( + getAddress(t.ctx.deployL1ContractsValues.l1ContractAddresses.governanceProposerAddress.toString()), ); - const executeTx = await apella.write.execute([0n], { account: emperor }); + const executeTx = await governance.write.execute([0n], { account: emperor }); await t.ctx.deployL1ContractsValues.publicClient.waitForTransactionReceipt({ hash: executeTx }); - const newGerousia = await apella.read.gerousia(); - expect(newGerousia).not.toEqual( - getAddress(t.ctx.deployL1ContractsValues.l1ContractAddresses.gerousiaAddress.toString()), + const newGovernanceProposer = await governance.read.governanceProposer(); + expect(newGovernanceProposer).not.toEqual( + getAddress(t.ctx.deployL1ContractsValues.l1ContractAddresses.governanceProposerAddress.toString()), ); - expect(await apella.read.getProposalState([0n])).toEqual(5); + expect(await governance.read.getProposalState([0n])).toEqual(5); }, 1_000_000); }); diff --git a/yarn-project/end-to-end/src/e2e_prover/e2e_prover_test.ts b/yarn-project/end-to-end/src/e2e_prover/e2e_prover_test.ts index 8d1bfb5b4566..737575c3597f 100644 --- a/yarn-project/end-to-end/src/e2e_prover/e2e_prover_test.ts +++ b/yarn-project/end-to-end/src/e2e_prover/e2e_prover_test.ts @@ -101,7 +101,7 @@ export class FullProverTest { this.snapshotManager = createSnapshotManager( `full_prover_integration/${testName}`, dataPath, - { startProverNode: true, fundSysstia: true, coinbase }, + { startProverNode: true, fundRewardDistributor: true, coinbase }, { assumeProvenThrough: undefined }, ); } diff --git a/yarn-project/end-to-end/src/e2e_prover/full.test.ts b/yarn-project/end-to-end/src/e2e_prover/full.test.ts index a19bd41cc0fe..15662b971066 100644 --- a/yarn-project/end-to-end/src/e2e_prover/full.test.ts +++ b/yarn-project/end-to-end/src/e2e_prover/full.test.ts @@ -1,5 +1,5 @@ import { type AztecAddress, EthAddress, retryUntil } from '@aztec/aztec.js'; -import { RollupAbi, SysstiaAbi, TestERC20Abi } from '@aztec/l1-artifacts'; +import { RewardDistributorAbi, RollupAbi, TestERC20Abi } from '@aztec/l1-artifacts'; import '@jest/globals'; import { type Chain, type GetContractReturnType, type HttpTransport, type PublicClient, getContract } from 'viem'; @@ -22,7 +22,7 @@ describe('full_prover', () => { let rollup: GetContractReturnType>; let feeJuice: GetContractReturnType>; - let sysstia: GetContractReturnType>; + let rewardDistributor: GetContractReturnType>; beforeAll(async () => { await t.applyBaseSnapshots(); @@ -45,9 +45,9 @@ describe('full_prover', () => { client: t.l1Contracts.publicClient, }); - sysstia = getContract({ - abi: SysstiaAbi, - address: t.l1Contracts.l1ContractAddresses.sysstiaAddress.toString(), + rewardDistributor = getContract({ + abi: RewardDistributorAbi, + address: t.l1Contracts.l1ContractAddresses.rewardDistributorAddress.toString(), client: t.l1Contracts.publicClient, }); }); @@ -140,7 +140,7 @@ describe('full_prover', () => { const provenBn = await rollup.read.getProvenBlockNumber(); const balanceAfterCoinbase = await feeJuice.read.balanceOf([COINBASE_ADDRESS.toString()]); const balanceAfterProver = await feeJuice.read.balanceOf([t.proverAddress.toString()]); - const blockReward = (await sysstia.read.BLOCK_REWARD()) as bigint; + const blockReward = (await rewardDistributor.read.BLOCK_REWARD()) as bigint; const fees = ( await Promise.all([t.aztecNode.getBlock(Number(provenBn - 1n)), t.aztecNode.getBlock(Number(provenBn))]) ).map(b => b!.header.totalFees.toBigInt()); diff --git a/yarn-project/end-to-end/src/fixtures/snapshot_manager.ts b/yarn-project/end-to-end/src/fixtures/snapshot_manager.ts index d8a9502d340e..2caf027e280c 100644 --- a/yarn-project/end-to-end/src/fixtures/snapshot_manager.ts +++ b/yarn-project/end-to-end/src/fixtures/snapshot_manager.ts @@ -344,16 +344,16 @@ async function setupFromFresh( aztecNodeConfig.l1Contracts = deployL1ContractsValues.l1ContractAddresses; aztecNodeConfig.l1PublishRetryIntervalMS = 100; - if (opts.fundSysstia) { - // Mints block rewards for 10000 blocks to the sysstia contract + if (opts.fundRewardDistributor) { + // Mints block rewards for 10000 blocks to the rewardDistributor contract - const sysstia = getContract({ - address: deployL1ContractsValues.l1ContractAddresses.sysstiaAddress.toString(), - abi: l1Artifacts.sysstia.contractAbi, + const rewardDistributor = getContract({ + address: deployL1ContractsValues.l1ContractAddresses.rewardDistributorAddress.toString(), + abi: l1Artifacts.rewardDistributor.contractAbi, client: deployL1ContractsValues.publicClient, }); - const blockReward = await sysstia.read.BLOCK_REWARD([]); + const blockReward = await rewardDistributor.read.BLOCK_REWARD([]); const mintAmount = 10_000n * (blockReward as bigint); const feeJuice = getContract({ @@ -362,9 +362,9 @@ async function setupFromFresh( client: deployL1ContractsValues.walletClient, }); - const sysstiaMintTxHash = await feeJuice.write.mint([sysstia.address, mintAmount], {} as any); - await deployL1ContractsValues.publicClient.waitForTransactionReceipt({ hash: sysstiaMintTxHash }); - logger.info(`Funding sysstia in ${sysstiaMintTxHash}`); + const rewardDistributorMintTxHash = await feeJuice.write.mint([rewardDistributor.address, mintAmount], {} as any); + await deployL1ContractsValues.publicClient.waitForTransactionReceipt({ hash: rewardDistributorMintTxHash }); + logger.info(`Funding rewardDistributor in ${rewardDistributorMintTxHash}`); } const watcher = new AnvilTestWatcher( diff --git a/yarn-project/end-to-end/src/fixtures/utils.ts b/yarn-project/end-to-end/src/fixtures/utils.ts index b5321c702b19..3df1c5103689 100644 --- a/yarn-project/end-to-end/src/fixtures/utils.ts +++ b/yarn-project/end-to-end/src/fixtures/utils.ts @@ -248,8 +248,8 @@ export type SetupOptions = { assumeProvenThrough?: number; /** Whether to start a prover node */ startProverNode?: boolean; - /** Whether to fund the sysstia */ - fundSysstia?: boolean; + /** Whether to fund the rewardDistributor */ + fundRewardDistributor?: boolean; } & Partial; /** Context for an end-to-end test as returned by the `setup` function */ @@ -363,16 +363,16 @@ export async function setup( config.l1Contracts = deployL1ContractsValues.l1ContractAddresses; - if (opts.fundSysstia) { - // Mints block rewards for 10000 blocks to the sysstia contract + if (opts.fundRewardDistributor) { + // Mints block rewards for 10000 blocks to the rewardDistributor contract - const sysstia = getContract({ - address: deployL1ContractsValues.l1ContractAddresses.sysstiaAddress.toString(), - abi: l1Artifacts.sysstia.contractAbi, + const rewardDistributor = getContract({ + address: deployL1ContractsValues.l1ContractAddresses.rewardDistributorAddress.toString(), + abi: l1Artifacts.rewardDistributor.contractAbi, client: deployL1ContractsValues.publicClient, }); - const blockReward = await sysstia.read.BLOCK_REWARD([]); + const blockReward = await rewardDistributor.read.BLOCK_REWARD([]); const mintAmount = 10_000n * (blockReward as bigint); const feeJuice = getContract({ @@ -381,9 +381,9 @@ export async function setup( client: deployL1ContractsValues.walletClient, }); - const sysstiaMintTxHash = await feeJuice.write.mint([sysstia.address, mintAmount], {} as any); - await deployL1ContractsValues.publicClient.waitForTransactionReceipt({ hash: sysstiaMintTxHash }); - logger.info(`Funding sysstia in ${sysstiaMintTxHash}`); + const rewardDistributorMintTxHash = await feeJuice.write.mint([rewardDistributor.address, mintAmount], {} as any); + await deployL1ContractsValues.publicClient.waitForTransactionReceipt({ hash: rewardDistributorMintTxHash }); + logger.info(`Funding rewardDistributor in ${rewardDistributorMintTxHash}`); } if (opts.l2StartTime) { diff --git a/yarn-project/ethereum/src/deploy_l1_contracts.ts b/yarn-project/ethereum/src/deploy_l1_contracts.ts index 3bc0f440a6b1..8a23efc46baa 100644 --- a/yarn-project/ethereum/src/deploy_l1_contracts.ts +++ b/yarn-project/ethereum/src/deploy_l1_contracts.ts @@ -3,25 +3,25 @@ import { EthAddress } from '@aztec/foundation/eth-address'; import { type Fr } from '@aztec/foundation/fields'; import { type DebugLogger } from '@aztec/foundation/log'; import { - ApellaAbi, - ApellaBytecode, + CoinIssuerAbi, + CoinIssuerBytecode, FeeJuicePortalAbi, FeeJuicePortalBytecode, - GerousiaAbi, - GerousiaBytecode, + GovernanceAbi, + GovernanceBytecode, + GovernanceProposerAbi, + GovernanceProposerBytecode, InboxAbi, InboxBytecode, - NomismatokopioAbi, - NomismatokopioBytecode, OutboxAbi, OutboxBytecode, RegistryAbi, RegistryBytecode, + RewardDistributorAbi, + RewardDistributorBytecode, RollupAbi, RollupBytecode, RollupLinkReferences, - SysstiaAbi, - SysstiaBytecode, TestERC20Abi, TestERC20Bytecode, TxsDecoderAbi, @@ -132,21 +132,21 @@ export interface L1ContractArtifactsForDeployment { */ feeJuicePortal: ContractArtifacts; /** - * Nomismatokopio contract artifacts. + * CoinIssuer contract artifacts. */ - nomismatokopio: ContractArtifacts; + coinIssuer: ContractArtifacts; /** - * Sysstia contract artifacts. + * RewardDistributor contract artifacts. */ - sysstia: ContractArtifacts; + rewardDistributor: ContractArtifacts; /** - * Gerousia contract artifacts. + * GovernanceProposer contract artifacts. */ - gerousia: ContractArtifacts; + governanceProposer: ContractArtifacts; /** - * Apella contract artifacts. + * Governance contract artifacts. */ - apella: ContractArtifacts; + governance: ContractArtifacts; } export const l1Artifacts: L1ContractArtifactsForDeployment = { @@ -183,21 +183,21 @@ export const l1Artifacts: L1ContractArtifactsForDeployment = { contractAbi: FeeJuicePortalAbi, contractBytecode: FeeJuicePortalBytecode, }, - sysstia: { - contractAbi: SysstiaAbi, - contractBytecode: SysstiaBytecode, + rewardDistributor: { + contractAbi: RewardDistributorAbi, + contractBytecode: RewardDistributorBytecode, }, - nomismatokopio: { - contractAbi: NomismatokopioAbi, - contractBytecode: NomismatokopioBytecode, + coinIssuer: { + contractAbi: CoinIssuerAbi, + contractBytecode: CoinIssuerBytecode, }, - gerousia: { - contractAbi: GerousiaAbi, - contractBytecode: GerousiaBytecode, + governanceProposer: { + contractAbi: GovernanceProposerAbi, + contractBytecode: GovernanceProposerBytecode, }, - apella: { - contractAbi: ApellaAbi, - contractBytecode: ApellaBytecode, + governance: { + contractAbi: GovernanceAbi, + contractBytecode: GovernanceBytecode, }, }; @@ -319,32 +319,32 @@ export const deployL1Contracts = async ( // @note These numbers are just chosen to make testing simple. const quorumSize = 6n; const roundSize = 10n; - const gerousiaAddress = await govDeployer.deploy(l1Artifacts.gerousia, [ + const governanceProposerAddress = await govDeployer.deploy(l1Artifacts.governanceProposer, [ registryAddress.toString(), quorumSize, roundSize, ]); - logger.info(`Deployed Gerousia at ${gerousiaAddress}`); + logger.info(`Deployed GovernanceProposer at ${governanceProposerAddress}`); - const apellaAddress = await govDeployer.deploy(l1Artifacts.apella, [ + const governanceAddress = await govDeployer.deploy(l1Artifacts.governance, [ feeJuiceAddress.toString(), - gerousiaAddress.toString(), + governanceProposerAddress.toString(), ]); - logger.info(`Deployed Apella at ${apellaAddress}`); + logger.info(`Deployed Governance at ${governanceAddress}`); - const nomismatokopioAddress = await govDeployer.deploy(l1Artifacts.nomismatokopio, [ + const coinIssuerAddress = await govDeployer.deploy(l1Artifacts.coinIssuer, [ feeJuiceAddress.toString(), 1n * 10n ** 18n, // @todo #8084 - apellaAddress.toString(), + governanceAddress.toString(), ]); - logger.info(`Deployed Nomismatokopio at ${nomismatokopioAddress}`); + logger.info(`Deployed CoinIssuer at ${coinIssuerAddress}`); - const sysstiaAddress = await govDeployer.deploy(l1Artifacts.sysstia, [ + const rewardDistributorAddress = await govDeployer.deploy(l1Artifacts.rewardDistributor, [ feeJuiceAddress.toString(), registryAddress.toString(), - apellaAddress.toString(), + governanceAddress.toString(), ]); - logger.info(`Deployed Sysstia at ${sysstiaAddress}`); + logger.info(`Deployed RewardDistributor at ${rewardDistributorAddress}`); await govDeployer.waitForDeployments(); logger.info(`All governance contracts deployed`); @@ -360,7 +360,7 @@ export const deployL1Contracts = async ( const rollupAddress = await deployer.deploy(l1Artifacts.rollup, [ feeJuicePortalAddress.toString(), - sysstiaAddress.toString(), + rewardDistributorAddress.toString(), args.vkTreeRoot.toString(), args.protocolContractTreeRoot.toString(), account.address.toString(), @@ -468,16 +468,16 @@ export const deployL1Contracts = async ( logger.verbose(`Registry ${registryAddress} has already registered rollup ${rollupAddress}`); } - // If the owner is not the Apella contract, transfer ownership to the Apella contract - if ((await registryContract.read.owner([])) !== getAddress(apellaAddress.toString())) { + // If the owner is not the Governance contract, transfer ownership to the Governance contract + if ((await registryContract.read.owner([])) !== getAddress(governanceAddress.toString())) { const transferOwnershipTxHash = await registryContract.write.transferOwnership( - [getAddress(apellaAddress.toString())], + [getAddress(governanceAddress.toString())], { account, }, ); logger.verbose( - `Transferring the ownership of the registry contract at ${registryAddress} to the Apella ${apellaAddress} in tx ${transferOwnershipTxHash}`, + `Transferring the ownership of the registry contract at ${registryAddress} to the Governance ${governanceAddress} in tx ${transferOwnershipTxHash}`, ); txHashes.push(transferOwnershipTxHash); } @@ -493,10 +493,10 @@ export const deployL1Contracts = async ( outboxAddress, feeJuiceAddress, feeJuicePortalAddress, - nomismatokopioAddress, - sysstiaAddress, - gerousiaAddress, - apellaAddress, + coinIssuerAddress, + rewardDistributorAddress, + governanceProposerAddress, + governanceAddress, }; return { diff --git a/yarn-project/ethereum/src/l1_contract_addresses.ts b/yarn-project/ethereum/src/l1_contract_addresses.ts index 6aa5477cc203..340b48722638 100644 --- a/yarn-project/ethereum/src/l1_contract_addresses.ts +++ b/yarn-project/ethereum/src/l1_contract_addresses.ts @@ -13,10 +13,10 @@ export const l1ContractsNames = [ 'outboxAddress', 'feeJuiceAddress', 'feeJuicePortalAddress', - 'nomismatokopioAddress', - 'sysstiaAddress', - 'gerousiaAddress', - 'apellaAddress', + 'coinIssuerAddress', + 'rewardDistributorAddress', + 'governanceProposerAddress', + 'governanceAddress', ] as const; /** @@ -59,24 +59,24 @@ export const l1ContractAddressesMapping: ConfigMappingsType description: 'The deployed L1 Fee Juice portal contract address.', parseEnv, }, - nomismatokopioAddress: { - env: 'NOMISMATOKOPIO_CONTRACT_ADDRESS', - description: 'The deployed L1 nomismatokopio contract address', + coinIssuerAddress: { + env: 'COIN_ISSUER_CONTRACT_ADDRESS', + description: 'The deployed L1 coinIssuer contract address', parseEnv, }, - sysstiaAddress: { - env: 'SYSSTIA_CONTRACT_ADDRESS', - description: 'The deployed L1 sysstia contract address', + rewardDistributorAddress: { + env: 'REWARD_DISTRIBUTOR_CONTRACT_ADDRESS', + description: 'The deployed L1 rewardDistributor contract address', parseEnv, }, - gerousiaAddress: { - env: 'GEROUSIA_CONTRACT_ADDRESS', - description: 'The deployed L1 gerousia contract address', + governanceProposerAddress: { + env: 'GOVERNANCE_PROPOSER_CONTRACT_ADDRESS', + description: 'The deployed L1 governanceProposer contract address', parseEnv, }, - apellaAddress: { - env: 'APELLA_CONTRACT_ADDRESS', - description: 'The deployed L1 apella contract address', + governanceAddress: { + env: 'GOVERNANCE_CONTRACT_ADDRESS', + description: 'The deployed L1 governance contract address', parseEnv, }, }; diff --git a/yarn-project/foundation/src/config/env_var.ts b/yarn-project/foundation/src/config/env_var.ts index 42e419b1b664..0e7ec7624343 100644 --- a/yarn-project/foundation/src/config/env_var.ts +++ b/yarn-project/foundation/src/config/env_var.ts @@ -1,7 +1,7 @@ export type EnvVar = | 'ACVM_BINARY_PATH' | 'ACVM_WORKING_DIRECTORY' - | 'APELLA_CONTRACT_ADDRESS' + | 'GOVERNANCE_CONTRACT_ADDRESS' | 'API_KEY' | 'API_PREFIX' | 'ARCHIVER_MAX_LOGS' @@ -46,8 +46,8 @@ export type EnvVar = | 'FEE_JUICE_CONTRACT_ADDRESS' | 'FEE_JUICE_PORTAL_CONTRACT_ADDRESS' | 'FEE_RECIPIENT' - | 'GEROUSIA_CONTRACT_ADDRESS' - | 'GEROUSIA_PAYLOAD_ADDRESS' + | 'GOVERNANCE_PROPOSER_CONTRACT_ADDRESS' + | 'GOVERNANCE_PROPOSER_PAYLOAD_ADDRESS' | 'INBOX_CONTRACT_ADDRESS' | 'L1_CHAIN_ID' | 'L1_PRIVATE_KEY' @@ -57,7 +57,7 @@ export type EnvVar = | 'MNEMONIC' | 'NETWORK_NAME' | 'NETWORK' - | 'NOMISMATOKOPIO_CONTRACT_ADDRESS' + | 'COIN_ISSUER_CONTRACT_ADDRESS' | 'OTEL_EXPORTER_OTLP_METRICS_ENDPOINT' | 'OTEL_EXPORTER_OTLP_TRACES_ENDPOINT' | 'OTEL_EXPORTER_OTLP_LOGS_ENDPOINT' @@ -132,7 +132,7 @@ export type EnvVar = | 'SEQ_REQUIRED_CONFIRMATIONS' | 'SEQ_TX_POLLING_INTERVAL_MS' | 'SEQ_ENFORCE_TIME_TABLE' - | 'SYSSTIA_CONTRACT_ADDRESS' + | 'REWARD_DISTRIBUTOR_CONTRACT_ADDRESS' | 'TELEMETRY' | 'TEST_ACCOUNTS' | 'TX_GOSSIP_VERSION' diff --git a/yarn-project/l1-artifacts/scripts/generate-artifacts.sh b/yarn-project/l1-artifacts/scripts/generate-artifacts.sh index d70904724e84..4ddefda991c5 100755 --- a/yarn-project/l1-artifacts/scripts/generate-artifacts.sh +++ b/yarn-project/l1-artifacts/scripts/generate-artifacts.sh @@ -23,11 +23,11 @@ CONTRACTS=( "l1-contracts:IVerifier" "l1-contracts:IProofCommitmentEscrow" "l1-contracts:ProofCommitmentEscrow" - "l1-contracts:Nomismatokopio" - "l1-contracts:Sysstia" - "l1-contracts:Gerousia" - "l1-contracts:Apella" - "l1-contracts:NewGerousiaPayload" + "l1-contracts:CoinIssuer" + "l1-contracts:RewardDistributor" + "l1-contracts:GovernanceProposer" + "l1-contracts:Governance" + "l1-contracts:NewGovernanceProposerPayload" "l1-contracts:TxsDecoder" ) diff --git a/yarn-project/pxe/src/pxe_service/test/pxe_service.test.ts b/yarn-project/pxe/src/pxe_service/test/pxe_service.test.ts index 0f06bec2e72a..ca0d00de0dbc 100644 --- a/yarn-project/pxe/src/pxe_service/test/pxe_service.test.ts +++ b/yarn-project/pxe/src/pxe_service/test/pxe_service.test.ts @@ -32,10 +32,10 @@ function createPXEService(): Promise { outboxAddress: EthAddress.random(), feeJuiceAddress: EthAddress.random(), feeJuicePortalAddress: EthAddress.random(), - apellaAddress: EthAddress.random(), - nomismatokopioAddress: EthAddress.random(), - sysstiaAddress: EthAddress.random(), - gerousiaAddress: EthAddress.random(), + governanceAddress: EthAddress.random(), + coinIssuerAddress: EthAddress.random(), + rewardDistributorAddress: EthAddress.random(), + governanceProposerAddress: EthAddress.random(), }; node.getL1ContractAddresses.mockResolvedValue(mockedContracts); diff --git a/yarn-project/sequencer-client/src/config.ts b/yarn-project/sequencer-client/src/config.ts index c5d6a3e5cbc8..3dfa3b8b96fd 100644 --- a/yarn-project/sequencer-client/src/config.ts +++ b/yarn-project/sequencer-client/src/config.ts @@ -109,9 +109,9 @@ export const sequencerConfigMappings: ConfigMappingsType = { ...booleanConfigHelper(), defaultValue: false, }, - gerousiaPayload: { - env: 'GEROUSIA_PAYLOAD_ADDRESS', - description: 'The address of the payload for the gerousia', + governanceProposerPayload: { + env: 'GOVERNANCE_PROPOSER_PAYLOAD_ADDRESS', + description: 'The address of the payload for the governanceProposer', parseEnv: (val: string) => EthAddress.fromString(val), defaultValue: EthAddress.ZERO, }, diff --git a/yarn-project/sequencer-client/src/publisher/l1-publisher.ts b/yarn-project/sequencer-client/src/publisher/l1-publisher.ts index 4486cd6c859c..3a1fc87b18e4 100644 --- a/yarn-project/sequencer-client/src/publisher/l1-publisher.ts +++ b/yarn-project/sequencer-client/src/publisher/l1-publisher.ts @@ -26,7 +26,7 @@ import { createDebugLogger } from '@aztec/foundation/log'; import { type Tuple, serializeToBuffer } from '@aztec/foundation/serialize'; import { InterruptibleSleep } from '@aztec/foundation/sleep'; import { Timer } from '@aztec/foundation/timer'; -import { GerousiaAbi, RollupAbi } from '@aztec/l1-artifacts'; +import { GovernanceProposerAbi, RollupAbi } from '@aztec/l1-artifacts'; import { type TelemetryClient } from '@aztec/telemetry-client'; import pick from 'lodash.pick'; @@ -149,8 +149,8 @@ export class L1Publisher { typeof RollupAbi, WalletClient >; - private gerousiaContract?: GetContractReturnType< - typeof GerousiaAbi, + private governanceProposerContract?: GetContractReturnType< + typeof GovernanceProposerAbi, WalletClient > = undefined; @@ -188,10 +188,10 @@ export class L1Publisher { client: this.walletClient, }); - if (l1Contracts.gerousiaAddress) { - this.gerousiaContract = getContract({ - address: getAddress(l1Contracts.gerousiaAddress.toString()), - abi: GerousiaAbi, + if (l1Contracts.governanceProposerAddress) { + this.governanceProposerContract = getContract({ + address: getAddress(l1Contracts.governanceProposerAddress.toString()), + abi: GovernanceProposerAbi, client: this.walletClient, }); } @@ -385,7 +385,7 @@ export class L1Publisher { return false; } - if (!this.gerousiaContract) { + if (!this.governanceProposerContract) { return false; } @@ -398,14 +398,17 @@ export class L1Publisher { const [proposer, roundNumber] = await Promise.all([ this.rollupContract.read.getProposerAt([timestamp]), - this.gerousiaContract.read.computeRound([slotNumber]), + this.governanceProposerContract.read.computeRound([slotNumber]), ]); if (proposer != this.account.address) { return false; } - const [slotForLastVote] = await this.gerousiaContract.read.rounds([this.rollupContract.address, roundNumber]); + const [slotForLastVote] = await this.governanceProposerContract.read.rounds([ + this.rollupContract.address, + roundNumber, + ]); if (slotForLastVote >= slotNumber) { return false; @@ -418,7 +421,7 @@ export class L1Publisher { let txHash; try { - txHash = await this.gerousiaContract.write.vote([this.payload.toString()], { + txHash = await this.governanceProposerContract.write.vote([this.payload.toString()], { account: this.account, }); } catch (err) { diff --git a/yarn-project/sequencer-client/src/sequencer/sequencer.ts b/yarn-project/sequencer-client/src/sequencer/sequencer.ts index 2e30f8cab68a..17224529de70 100644 --- a/yarn-project/sequencer-client/src/sequencer/sequencer.ts +++ b/yarn-project/sequencer-client/src/sequencer/sequencer.ts @@ -151,8 +151,8 @@ export class Sequencer { if (config.maxBlockSizeInBytes !== undefined) { this.maxBlockSizeInBytes = config.maxBlockSizeInBytes; } - if (config.gerousiaPayload) { - this.publisher.setPayload(config.gerousiaPayload); + if (config.governanceProposerPayload) { + this.publisher.setPayload(config.governanceProposerPayload); } this.enforceTimeTable = config.enforceTimeTable === true;