Skip to content

Commit

Permalink
Adding a global setting to skip L2 votes
Browse files Browse the repository at this point in the history
  • Loading branch information
brickpop committed Jul 26, 2024
1 parent 18858c3 commit 5381072
Show file tree
Hide file tree
Showing 7 changed files with 171 additions and 49 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ DEPLOY_AS_PRODUCTION=true # With false, the script will deploy mock helpers
MIN_VETO_RATIO="300000" # 30%
L2_INACTIVITY_PERIOD="600" # in seconds (10 minutes)
L2_AGGREGATION_GRACE_PERIOD="172800" # in seconds (2 days)
SKIP_L2=true
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
6 changes: 4 additions & 2 deletions src/OptimisticTokenVotingPlugin.sol
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ contract OptimisticTokenVotingPlugin is
uint64 minDuration;
uint64 l2InactivityPeriod;
uint64 l2AggregationGracePeriod;
bool skipL2;
}

/// @notice A container for proposal-related information.
Expand Down Expand Up @@ -203,7 +204,8 @@ contract OptimisticTokenVotingPlugin is

/// @notice Determines whether the L2 is currently available
function isL2Available() public view returns (bool) {
if (taikoL1.paused()) return false;
if (governanceSettings.skipL2) return false;
else if (taikoL1.paused()) return false;

uint64 _id = taikoL1.slotB().numBlocks;
// No L2 blocks yet
Expand Down Expand Up @@ -342,7 +344,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
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
140 changes: 106 additions & 34 deletions test/OptimisticTokenVotingPlugin.t.sol

Large diffs are not rendered by default.

53 changes: 42 additions & 11 deletions test/OptimisticTokenVotingPluginSetup.t.sol

Large diffs are not rendered by default.

14 changes: 13 additions & 1 deletion test/helpers/DaoBuilder.sol
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ contract DaoBuilder is Test {
uint64 public minDuration = 4 days;
uint64 public l2InactivityPeriod = 10 minutes;
uint64 public l2AggregationGracePeriod = 2 days;
bool public skipL2 = false;

bool public onlyListed = true;
uint16 public minApprovals = 1;
Expand Down Expand Up @@ -98,6 +99,16 @@ contract DaoBuilder is Test {
return this;
}

function withSkipL2() public returns (DaoBuilder) {
skipL2 = true;
return this;
}

function withoutSkipL2() public returns (DaoBuilder) {
skipL2 = false;
return this;
}

function withTaikoBridge(address newTaikoBridge) public returns (DaoBuilder) {
taikoBridge = newTaikoBridge;
return this;
Expand Down Expand Up @@ -177,7 +188,8 @@ contract DaoBuilder is Test {
minVetoRatio: minVetoRatio,
minDuration: minDuration,
l2InactivityPeriod: l2InactivityPeriod,
l2AggregationGracePeriod: l2AggregationGracePeriod
l2AggregationGracePeriod: l2AggregationGracePeriod,
skipL2: skipL2
});

optimisticPlugin = OptimisticTokenVotingPlugin(
Expand Down

0 comments on commit 5381072

Please sign in to comment.