Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added L2VotingPowerPaused and L2GovernorPaused contract with test cases #165

Merged
merged 16 commits into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
[submodule "lib/openzeppelin-contracts-upgradeable"]
path = lib/openzeppelin-contracts-upgradeable
url = https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable
[submodule "lib/properties"]
path = lib/properties
url = https://github.com/crytic/properties
[submodule "lib/openzeppelin-foundry-upgrades"]
path = lib/openzeppelin-foundry-upgrades
url = https://github.com/OpenZeppelin/openzeppelin-foundry-upgrades
4 changes: 1 addition & 3 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,10 @@ remappings = [
'openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/',
'openzeppelin-contracts/=lib/openzeppelin-contracts/',
'@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/',
'ERC4626/=lib/properties/lib/ERC4626/contracts/',
'properties/=lib/properties/contracts/',
'solmate/=lib/properties/lib/solmate/src/',
'openzeppelin-foundry-upgrades/=lib/openzeppelin-foundry-upgrades/src/',
'solidity-stringutils/=lib/openzeppelin-foundry-upgrades/lib/solidity-stringutils/',
]

ffi = true
ast = true
build_info = true
Expand Down
2 changes: 1 addition & 1 deletion lib/forge-std
matjazv marked this conversation as resolved.
Show resolved Hide resolved
1 change: 0 additions & 1 deletion lib/properties
Submodule properties deleted from bb1b78
2 changes: 1 addition & 1 deletion script/contracts/L2/paused/L2GovernorPaused.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ contract L2GovernorPausedScript is Script {
// implementation for the proxy contract.
Options memory opts;
opts.referenceContract = "L2Governor.sol";
opts.unsafeAllow = "constructor,external-library-linking";
opts.unsafeAllow = "constructor";
Upgrades.validateUpgrade("L2GovernorPaused.sol", opts);

console2.log("Deploying L2GovernorPaused contract...");
Expand Down
2 changes: 1 addition & 1 deletion script/contracts/L2/paused/L2VotingPowerPaused.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ contract L2VotingPowerPausedScript is Script {
// implementation for the proxy contract.
Options memory opts;
opts.referenceContract = "L2VotingPower.sol";
opts.unsafeAllow = "constructor,external-library-linking";
opts.unsafeAllow = "constructor";
Upgrades.validateUpgrade("L2VotingPowerPaused.sol", opts);

console2.log("Deploying L2VotingPowerPaused contract...");
Expand Down
12 changes: 10 additions & 2 deletions script/contracts/Utils.sol
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,10 @@ contract Utils is Script {
l2AddressesConfig.L2GovernorImplementation = l2GovernorImplementation;
} catch { }

try vm.parseJsonAddress(addressJson, ".L2GovernorPaused") returns (address l2GovernorPaused) {
l2AddressesConfig.L2GovernorPaused = l2GovernorPaused;
} catch { }

try vm.parseJsonAddress(addressJson, ".L2LiskToken") returns (address l2LiskToken) {
l2AddressesConfig.L2LiskToken = l2LiskToken;
} catch { }
Expand Down Expand Up @@ -227,6 +231,9 @@ contract Utils is Script {
) {
l2AddressesConfig.L2VotingPowerImplementation = l2VotingPowerImplementation;
} catch { }
try vm.parseJsonAddress(addressJson, ".L2VotingPowerPaused") returns (address l2VotingPowerPaused) {
l2AddressesConfig.L2VotingPowerPaused = l2VotingPowerPaused;
} catch { }

return l2AddressesConfig;
}
Expand All @@ -241,6 +248,7 @@ contract Utils is Script {
vm.serializeAddress(json, "L2ClaimImplementation", cfg.L2ClaimImplementation);
vm.serializeAddress(json, "L2Governor", cfg.L2Governor);
vm.serializeAddress(json, "L2GovernorImplementation", cfg.L2GovernorImplementation);
vm.serializeAddress(json, "L2GovernorPaused", cfg.L2GovernorPaused);
vm.serializeAddress(json, "L2LiskToken", cfg.L2LiskToken);
vm.serializeAddress(json, "L2LockingPosition", cfg.L2LockingPosition);
vm.serializeAddress(json, "L2LockingPositionImplementation", cfg.L2LockingPositionImplementation);
Expand All @@ -251,8 +259,8 @@ contract Utils is Script {
vm.serializeAddress(json, "L2TimelockController", cfg.L2TimelockController);
vm.serializeAddress(json, "L2VestingWalletImplementation", cfg.L2VestingWalletImplementation);
vm.serializeAddress(json, "L2VotingPower", cfg.L2VotingPower);
string memory finalJson =
vm.serializeAddress(json, "L2VotingPowerImplementation", cfg.L2VotingPowerImplementation);
vm.serializeAddress(json, "L2VotingPowerImplementation", cfg.L2VotingPowerImplementation);
string memory finalJson = vm.serializeAddress(json, "L2VotingPowerPaused", cfg.L2VotingPowerPaused);

finalJson.write(string.concat("deployment/", network, "/l2addresses.json"));
}
Expand Down
68 changes: 68 additions & 0 deletions script/paused/deployPausedDAO.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#!/usr/bin/env bash

echo "Instructing the shell to exit immediately if any command returns a non-zero exit status..."
set -e
echo "Done."

echo "Navigating to the root directory of the project..."
cd ../../
echo "Done."

echo "Setting environment variables..."
source .env
echo "Done."

echo "Creating $NETWORK directory inside deployment directory..."
if [ -z "$NETWORK" ]
then
echo "NETWORK variable inside .env file is not set. Please set NETWORK environment variable."
exit 1
else
if [ -d "deployment/$NETWORK" ]
then
echo "Directory deployment/$NETWORK already exists."
else
mkdir deployment/$NETWORK
fi
fi
echo "Done."

echo "Cleaning up the build artifacts to be able to deploy the contract..."
forge clean
echo "Done."

echo "Deploying and if enabled verifying L2GovernorPaused smart contract..."
if [ -z "$CONTRACT_VERIFIER" ]
then
forge script --rpc-url="$L2_RPC_URL" --broadcast -vvvv script/contracts/L2/paused/L2GovernorPaused.s.sol:L2GovernorPausedScript
else
if [ $CONTRACT_VERIFIER = "blockscout" ]
then
forge script --rpc-url="$L2_RPC_URL" --broadcast --verify --verifier blockscout --verifier-url $L2_VERIFIER_URL -vvvv script/contracts/L2/paused/L2GovernorPaused.s.sol:L2GovernorPausedScript
fi
if [ $CONTRACT_VERIFIER = "etherscan" ]
then
forge script --rpc-url="$L2_RPC_URL" --broadcast --verify --verifier etherscan --etherscan-api-key="$L2_ETHERSCAN_API_KEY" -vvvv script/contracts/L2/paused/L2GovernorPaused.s.sol:L2GovernorPausedScript
fi
fi
echo "Done."

echo "Cleaning up the build artifacts to be able to deploy the contract..."
forge clean
echo "Done."

echo "Deploying and if enabled verifying L2VotingPowerPaused smart contract..."
if [ -z "$CONTRACT_VERIFIER" ]
then
forge script --rpc-url="$L2_RPC_URL" --broadcast -vvvv script/contracts/L2/paused/L2VotingPowerPaused.s.sol:L2VotingPowerPausedScript
else
if [ $CONTRACT_VERIFIER = "blockscout" ]
then
forge script --rpc-url="$L2_RPC_URL" --broadcast --verify --verifier blockscout --verifier-url $L2_VERIFIER_URL -vvvv script/contracts/L2/paused/L2VotingPowerPaused.s.sol:L2VotingPowerPausedScript
fi
if [ $CONTRACT_VERIFIER = "etherscan" ]
then
forge script --rpc-url="$L2_RPC_URL" --broadcast --verify --verifier etherscan --etherscan-api-key="$L2_ETHERSCAN_API_KEY" -vvvv script/contracts/L2/paused/L2VotingPowerPaused.s.sol:L2VotingPowerPausedScript
fi
fi
echo "Done."
67 changes: 53 additions & 14 deletions src/L2/paused/L2GovernorPaused.sol
AndreasKendziorra marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import { TimelockControllerUpgradeable } from
import { L2Governor } from "../L2Governor.sol";

contract L2GovernorPaused is L2Governor {
error GovernorIsPaused();

/// @notice Setting global params.
function initializePaused() public reinitializer(2) { }

Expand All @@ -29,22 +31,22 @@ contract L2GovernorPaused is L2Governor {
override
returns (uint256)
{
revert("L2GovernorPaused: Governor is paused");
revert GovernorIsPaused();
}

/// @notice Override the castVote function to pause Governor interactions.
function castVote(uint256, uint8) public virtual override returns (uint256) {
revert("L2GovernorPaused: Governor is paused");
revert GovernorIsPaused();
}

/// @notice Override the castVoteBySig function to pause Governor interactions.
function castVoteBySig(uint256, uint8, address, bytes memory) public virtual override returns (uint256) {
revert("L2GovernorPaused: Governor is paused");
revert GovernorIsPaused();
}

/// @notice Override the castVoteWithReason function to pause Governor interactions.
function castVoteWithReason(uint256, uint8, string calldata) public virtual override returns (uint256) {
revert("L2GovernorPaused: Governor is paused");
revert GovernorIsPaused();
}

/// @notice Override the castVoteWithReasonAndParams function to pause Governor interactions.
Expand All @@ -59,7 +61,7 @@ contract L2GovernorPaused is L2Governor {
override
returns (uint256)
{
revert("L2GovernorPaused: Governor is paused");
revert GovernorIsPaused();
}

/// @notice Override the castVoteWithReasonAndParamsBySig function to pause Governor interactions.
Expand All @@ -76,7 +78,7 @@ contract L2GovernorPaused is L2Governor {
override
returns (uint256)
{
revert("L2GovernorPaused: Governor is paused");
revert GovernorIsPaused();
}

/// @notice Override the execute function to pause Governor interactions.
Expand All @@ -92,7 +94,44 @@ contract L2GovernorPaused is L2Governor {
override
returns (uint256)
{
revert("L2GovernorPaused: Governor is paused");
revert GovernorIsPaused();
}

/// @notice Override the onERC1155BatchReceived function to pause Governor interactions.
function onERC1155BatchReceived(
address,
address,
uint256[] memory,
uint256[] memory,
bytes memory
)
public
virtual
override
returns (bytes4)
{
revert GovernorIsPaused();
}

/// @notice Override the onERC1155Received function to pause Governor interactions.
function onERC1155Received(
address,
address,
uint256,
uint256,
bytes memory
)
public
virtual
override
returns (bytes4)
{
revert GovernorIsPaused();
}

/// @notice Override the onERC721Received function to pause Governor interactions.
function onERC721Received(address, address, uint256, bytes memory) public virtual override returns (bytes4) {
revert GovernorIsPaused();
}

/// @notice Override the propose function to pause Governor interactions.
Expand All @@ -107,7 +146,7 @@ contract L2GovernorPaused is L2Governor {
override
returns (uint256)
{
revert("L2GovernorPaused: Governor is paused");
revert GovernorIsPaused();
}

/// @notice Override the queue function to pause Governor interactions.
Expand All @@ -122,31 +161,31 @@ contract L2GovernorPaused is L2Governor {
override
returns (uint256)
{
revert("L2GovernorPaused: Governor is paused");
revert GovernorIsPaused();
}

/// @notice Override the relay function to pause Governor interactions.
function relay(address, uint256, bytes memory) public payable virtual override {
revert("L2GovernorPaused: Governor is paused");
revert GovernorIsPaused();
}

/// @notice Override the setProposalThreshold function to pause Governor interactions.
function setProposalThreshold(uint256) public virtual override {
revert("L2GovernorPaused: Governor is paused");
revert GovernorIsPaused();
}

/// @notice Override the setVotingDelay function to pause Governor interactions.
function setVotingDelay(uint48) public virtual override {
revert("L2GovernorPaused: Governor is paused");
revert GovernorIsPaused();
}

/// @notice Override the setVotingPeriod function to pause Governor interactions.
function setVotingPeriod(uint32) public virtual override {
revert("L2GovernorPaused: Governor is paused");
revert GovernorIsPaused();
}

/// @notice Override the updateTimelock function to pause Governor interactions.
function updateTimelock(TimelockControllerUpgradeable) public virtual override {
revert("L2GovernorPaused: Governor is paused");
revert GovernorIsPaused();
}
}
20 changes: 4 additions & 16 deletions src/L2/paused/L2VotingPowerPaused.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,23 @@ pragma solidity 0.8.23;
import { Ownable2StepUpgradeable } from "@openzeppelin-upgradeable/contracts/access/Ownable2StepUpgradeable.sol";
import { Initializable } from "@openzeppelin-upgradeable/contracts/proxy/utils/Initializable.sol";
import { UUPSUpgradeable } from "@openzeppelin/contracts/proxy/utils/UUPSUpgradeable.sol";
import { IL2LockingPosition } from "../../interfaces/L2/IL2LockingPosition.sol";
import { L2VotingPower } from "../L2VotingPower.sol";

contract L2VotingPowerPaused is L2VotingPower {
error VotingPowerIsPaused();

/// @notice Setting global params.
function initializePaused() public reinitializer(2) {
version = "1.0.0-paused";
}

/// @notice Override the modifyLockingPosition function to pause VotingPower interactions.
function adjustVotingPower(
address,
IL2LockingPosition.LockingPosition memory,
IL2LockingPosition.LockingPosition memory
)
public
virtual
override
{
revert("L2VotingPowerPaused: VotingPower is paused");
}

/// @notice Override the modifyLockingPosition function to pause VotingPower interactions.
function delegate(address) public virtual override {
revert("L2VotingPowerPaused: VotingPower is paused");
revert VotingPowerIsPaused();
}

/// @notice Override the modifyLockingPosition function to pause VotingPower interactions.
function delegateBySig(address, uint256, uint256, uint8, bytes32, bytes32) public virtual override {
revert("L2VotingPowerPaused: VotingPower is paused");
revert VotingPowerIsPaused();
}
}
Loading
Loading