Skip to content

Commit

Permalink
Turning the timelock value into a governance setting
Browse files Browse the repository at this point in the history
  • Loading branch information
brickpop committed Nov 28, 2024
1 parent ace49cb commit 6b0cdaf
Show file tree
Hide file tree
Showing 8 changed files with 186 additions and 86 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ MULTISIG_MEMBERS_JSON_FILE_NAME="/script/multisig-members.json"

# GOVERNANCE PARAMETERS
MIN_VETO_RATIO="300000" # 30% (base 1_000_000)
TIME_LOCK_PERIOD="604800" # in seconds (7 days)
L2_INACTIVITY_PERIOD="600" # in seconds (10 minutes)
L2_AGGREGATION_GRACE_PERIOD="172800" # in seconds (2 days)
SKIP_L2=true # Determines whether vote aggregation from the L2 will be disabled
Expand Down
18 changes: 10 additions & 8 deletions script/Deploy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,13 @@ contract Deploy is Script {
tokenAddress: IVotesUpgradeable(vm.envAddress("TOKEN_ADDRESS")),
taikoL1ContractAddress: vm.envAddress("TAIKO_L1_ADDRESS"),
taikoBridgeAddress: vm.envAddress("TAIKO_BRIDGE_ADDRESS"),
l2InactivityPeriod: uint64(vm.envUint("L2_INACTIVITY_PERIOD")),
l2AggregationGracePeriod: uint64(vm.envUint("L2_AGGREGATION_GRACE_PERIOD")),
timelockPeriod: uint32(vm.envUint("TIME_LOCK_PERIOD")),
l2InactivityPeriod: uint32(vm.envUint("L2_INACTIVITY_PERIOD")),
l2AggregationGracePeriod: uint32(vm.envUint("L2_AGGREGATION_GRACE_PERIOD")),
skipL2: bool(vm.envBool("SKIP_L2")),
// Voting settings
minVetoRatio: uint32(vm.envUint("MIN_VETO_RATIO")),
minStdProposalDuration: uint64(vm.envUint("MIN_STD_PROPOSAL_DURATION")),
minStdProposalDuration: uint32(vm.envUint("MIN_STD_PROPOSAL_DURATION")),
minStdApprovals: uint16(vm.envUint("MIN_STD_APPROVALS")),
minEmergencyApprovals: uint16(vm.envUint("MIN_EMERGENCY_APPROVALS")),
// OSx contracts
Expand All @@ -92,7 +93,7 @@ contract Deploy is Script {
optimisticTokenVotingPluginSetup: OptimisticTokenVotingPluginSetup(optimisticTokenVotingPluginSetup),
// Multisig members
multisigMembers: readMultisigMembers(),
multisigExpirationPeriod: uint64(vm.envUint("MULTISIG_PROPOSAL_EXPIRATION_PERIOD")),
multisigExpirationPeriod: uint32(vm.envUint("MULTISIG_PROPOSAL_EXPIRATION_PERIOD")),
// ENS
stdMultisigEnsDomain: vm.envString("STD_MULTISIG_ENS_DOMAIN"),
emergencyMultisigEnsDomain: vm.envString("EMERGENCY_MULTISIG_ENS_DOMAIN"),
Expand All @@ -112,12 +113,13 @@ contract Deploy is Script {
tokenAddress: IVotesUpgradeable(votingToken),
taikoL1ContractAddress: address(new TaikoL1Mock()),
taikoBridgeAddress: taikoBridgeAddress,
l2InactivityPeriod: uint64(vm.envUint("L2_INACTIVITY_PERIOD")),
l2AggregationGracePeriod: uint64(vm.envUint("L2_AGGREGATION_GRACE_PERIOD")),
timelockPeriod: uint32(vm.envUint("TIME_LOCK_PERIOD")),
l2InactivityPeriod: uint32(vm.envUint("L2_INACTIVITY_PERIOD")),
l2AggregationGracePeriod: uint32(vm.envUint("L2_AGGREGATION_GRACE_PERIOD")),
skipL2: bool(vm.envBool("SKIP_L2")),
// Voting settings
minVetoRatio: uint32(vm.envUint("MIN_VETO_RATIO")),
minStdProposalDuration: uint64(vm.envUint("MIN_STD_PROPOSAL_DURATION")),
minStdProposalDuration: uint32(vm.envUint("MIN_STD_PROPOSAL_DURATION")),
minStdApprovals: uint16(vm.envUint("MIN_STD_APPROVALS")),
minEmergencyApprovals: uint16(vm.envUint("MIN_EMERGENCY_APPROVALS")),
// OSx contracts
Expand All @@ -130,7 +132,7 @@ contract Deploy is Script {
optimisticTokenVotingPluginSetup: OptimisticTokenVotingPluginSetup(optimisticTokenVotingPluginSetup),
// Multisig members
multisigMembers: multisigMembers,
multisigExpirationPeriod: uint64(vm.envUint("MULTISIG_PROPOSAL_EXPIRATION_PERIOD")),
multisigExpirationPeriod: uint32(vm.envUint("MULTISIG_PROPOSAL_EXPIRATION_PERIOD")),
// ENS
stdMultisigEnsDomain: vm.envString("STD_MULTISIG_ENS_DOMAIN"),
emergencyMultisigEnsDomain: vm.envString("EMERGENCY_MULTISIG_ENS_DOMAIN"),
Expand Down
13 changes: 6 additions & 7 deletions src/OptimisticTokenVotingPlugin.sol
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,16 @@ contract OptimisticTokenVotingPlugin is
/// @notice A container for the optimistic majority settings that will be applied as parameters on proposal creation.
/// @param minVetoRatio The support threshold value. Its value has to be in the interval [0, 10^6] defined by `RATIO_BASE = 10**6`.
/// @param minDuration The minimum duration of the proposal vote in seconds.
/// @param timelockPeriod The time in seconds between a proposal passing and execution being unlocked
/// @param l2InactivityPeriod The age in seconds of the latest block, after which the L2 is considered unavailable.
/// @param l2AggregationGracePeriod The amount of extra seconds to allow for L2 veto bridging after `vetoEndDate` is reached.
/// @param skipL2 Defines wether the plugin should ignore the voting power bridged to the L2, in terms of the token supply and L2 votes accepted. NOTE: Ongoing proposals will keep the value of the setting at the time of creation.
struct OptimisticGovernanceSettings {
uint32 minVetoRatio;
uint64 minDuration;
uint64 l2InactivityPeriod;
uint64 l2AggregationGracePeriod;
uint32 minDuration;
uint32 timelockPeriod;
uint32 l2InactivityPeriod;
uint32 l2AggregationGracePeriod;
bool skipL2;
}

Expand Down Expand Up @@ -84,9 +86,6 @@ contract OptimisticTokenVotingPlugin is
bytes32 public constant UPDATE_OPTIMISTIC_GOVERNANCE_SETTINGS_PERMISSION_ID =
keccak256("UPDATE_OPTIMISTIC_GOVERNANCE_SETTINGS_PERMISSION");

/// @notice The time gap between a proposal passing and execution being unlocked
uint64 public constant EXIT_WINDOW = 7 days;

/// @notice An [OpenZeppelin `Votes`](https://docs.openzeppelin.com/contracts/4.x/api/governance#Votes) compatible contract referencing the token being used for voting.
IVotesUpgradeable public votingToken;

Expand Down Expand Up @@ -580,7 +579,7 @@ contract OptimisticTokenVotingPlugin is
/// @param proposal_ The proposal struct.
/// @return True if the proposal cannot be executed because the exit window hasn't elapsed yet
function _proposalInExitWindow(Proposal storage proposal_) internal view virtual returns (bool) {
uint64 exitWindowTimestamp = proposal_.parameters.vetoEndDate + EXIT_WINDOW;
uint64 exitWindowTimestamp = proposal_.parameters.vetoEndDate + governanceSettings.timelockPeriod;

if (!proposal_.parameters.unavailableL2) {
exitWindowTimestamp += governanceSettings.l2AggregationGracePeriod;
Expand Down
10 changes: 6 additions & 4 deletions src/factory/TaikoDaoFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,13 @@ contract TaikoDaoFactory {
IVotesUpgradeable tokenAddress;
address taikoL1ContractAddress;
address taikoBridgeAddress;
uint64 l2InactivityPeriod;
uint64 l2AggregationGracePeriod;
uint32 timelockPeriod;
uint32 l2InactivityPeriod;
uint32 l2AggregationGracePeriod;
bool skipL2;
// Voting settings
uint32 minVetoRatio;
uint64 minStdProposalDuration;
uint32 minStdProposalDuration;
uint16 minStdApprovals;
uint16 minEmergencyApprovals;
// OSx contracts
Expand All @@ -69,7 +70,7 @@ contract TaikoDaoFactory {
OptimisticTokenVotingPluginSetup optimisticTokenVotingPluginSetup;
// Multisig
address[] multisigMembers;
uint64 multisigExpirationPeriod;
uint32 multisigExpirationPeriod;
// ENS
string stdMultisigEnsDomain;
string emergencyMultisigEnsDomain;
Expand Down Expand Up @@ -291,6 +292,7 @@ contract TaikoDaoFactory {
.OptimisticGovernanceSettings(
settings.minVetoRatio,
0, // minDuration (the condition contract will enforce it)
settings.timelockPeriod,
settings.l2InactivityPeriod,
settings.l2AggregationGracePeriod,
settings.skipL2
Expand Down
Loading

0 comments on commit 6b0cdaf

Please sign in to comment.