Skip to content

Commit

Permalink
Merge pull request #26 from aragon/f/global-skip-l2
Browse files Browse the repository at this point in the history
Adding a global setting to skip L2 votes
  • Loading branch information
brickpop authored Aug 1, 2024
2 parents 23d4dea + 41c29e4 commit 20a6273
Show file tree
Hide file tree
Showing 7 changed files with 227 additions and 56 deletions.
3 changes: 2 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ NETWORK="holesky"
DEPLOY_AS_PRODUCTION=true # With false, the script will deploy mock helpers

# GOVERNANCE PARAMETERS
MIN_VETO_RATIO="300000" # 30%
MIN_VETO_RATIO="300000" # 30% (base 1_000_000)
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
MIN_STD_PROPOSAL_DELAY="8864000" # in seconds (10 days)
MIN_STD_APPROVALS="5" # How many multisig approvals are required
MIN_EMERGENCY_APPROVALS="10" # How many emergency multisig approvals are required
Expand Down
2 changes: 2 additions & 0 deletions script/Deploy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ contract Deploy is Script {
taikoBridgeAddress: vm.envAddress("TAIKO_BRIDGE_ADDRESS"),
l2InactivityPeriod: uint64(vm.envUint("L2_INACTIVITY_PERIOD")),
l2AggregationGracePeriod: uint64(vm.envUint("L2_AGGREGATION_GRACE_PERIOD")),
skipL2: bool(vm.envBool("SKIP_L2")),
// Voting settings
minVetoRatio: uint32(vm.envUint("MIN_VETO_RATIO")),
minStdProposalDelay: uint64(vm.envUint("MIN_STD_PROPOSAL_DELAY")),
Expand Down Expand Up @@ -127,6 +128,7 @@ contract Deploy is Script {
taikoBridgeAddress: taikoBridgeAddress,
l2InactivityPeriod: uint64(vm.envUint("L2_INACTIVITY_PERIOD")),
l2AggregationGracePeriod: uint64(vm.envUint("L2_AGGREGATION_GRACE_PERIOD")),
skipL2: bool(vm.envBool("SKIP_L2")),
// Voting settings
minVetoRatio: uint32(vm.envUint("MIN_VETO_RATIO")),
minStdProposalDelay: uint64(vm.envUint("MIN_STD_PROPOSAL_DELAY")),
Expand Down
17 changes: 12 additions & 5 deletions src/OptimisticTokenVotingPlugin.sol
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,13 @@ contract OptimisticTokenVotingPlugin is
/// @param minDuration The minimum duration of the proposal vote in seconds.
/// @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;
bool skipL2;
}

/// @notice A container for proposal-related information.
Expand Down Expand Up @@ -107,8 +109,9 @@ contract OptimisticTokenVotingPlugin is
/// @param minDuration The minimum duration of the proposal vote in seconds.
/// @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.
event OptimisticGovernanceSettingsUpdated(
uint32 minVetoRatio, uint64 minDuration, uint64 l2AggregationGracePeriod, uint64 l2InactivityPeriod
uint32 minVetoRatio, uint64 minDuration, uint64 l2AggregationGracePeriod, uint64 l2InactivityPeriod, bool skipL2
);

/// @notice Emitted when a veto is cast by a voter.
Expand Down Expand Up @@ -201,9 +204,12 @@ contract OptimisticTokenVotingPlugin is
return _totalVotingPower;
}

/// @notice Determines whether the L2 is currently available
/// @notice Determines whether L2 votes are currently usable for voting
function isL2Available() public view returns (bool) {
if (taikoL1.paused()) return false;
// Actively disabled L2 voting?
if (governanceSettings.skipL2) return false;
// Is the L1 bridge paused?
else if (taikoL1.paused()) return false;

uint64 _id = taikoL1.slotB().numBlocks;
// No L2 blocks yet
Expand Down Expand Up @@ -342,7 +348,7 @@ contract OptimisticTokenVotingPlugin is
}

// Checks
bool _enableL2 = votingToken.getPastVotes(taikoBridge, snapshotTimestamp) > 0 && isL2Available();
bool _enableL2 = isL2Available() && votingToken.getPastVotes(taikoBridge, snapshotTimestamp) > 0;
if (effectiveVotingPower(snapshotTimestamp, _enableL2) == 0) {
revert NoVotingPower();
}
Expand Down Expand Up @@ -509,7 +515,8 @@ contract OptimisticTokenVotingPlugin is
minVetoRatio: _governanceSettings.minVetoRatio,
minDuration: _governanceSettings.minDuration,
l2AggregationGracePeriod: _governanceSettings.l2AggregationGracePeriod,
l2InactivityPeriod: _governanceSettings.l2InactivityPeriod
l2InactivityPeriod: _governanceSettings.l2InactivityPeriod,
skipL2: _governanceSettings.skipL2
});
}

Expand Down
4 changes: 3 additions & 1 deletion src/factory/TaikoDaoFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ contract TaikoDaoFactory {
address taikoBridgeAddress;
uint64 l2InactivityPeriod;
uint64 l2AggregationGracePeriod;
bool skipL2;
// Voting settings
uint32 minVetoRatio;
uint64 minStdProposalDelay;
Expand Down Expand Up @@ -227,7 +228,8 @@ contract TaikoDaoFactory {
settings.minVetoRatio,
0, // minDuration (the condition contract will enforce it)
settings.l2InactivityPeriod,
settings.l2AggregationGracePeriod
settings.l2AggregationGracePeriod,
settings.skipL2
);

OptimisticTokenVotingPluginSetup.TokenSettings memory existingTokenSettings =
Expand Down
Loading

0 comments on commit 20a6273

Please sign in to comment.