Skip to content

Commit

Permalink
Addressing review comments (WIP)
Browse files Browse the repository at this point in the history
  • Loading branch information
brickpop committed Jul 31, 2024
1 parent b9edbbe commit e1082f1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion lib/taiko-mono
Submodule taiko-mono updated 1250 files
19 changes: 8 additions & 11 deletions src/OptimisticTokenVotingPlugin.sol
Original file line number Diff line number Diff line change
Expand Up @@ -185,12 +185,13 @@ contract OptimisticTokenVotingPlugin is

/// @inheritdoc IOptimisticTokenVoting
function totalVotingPower(uint256 _timestamp) public view returns (uint256) {
return votingToken.getPastTotalSupply(_timestamp);
// Removing the votes of `taikoL1` which holds a lot of TAIKO as bond deposits
return votingToken.getPastTotalSupply(_timestamp) - votingToken.getPastVotes(address(taikoL1), _timestamp);
}

/// @inheritdoc IOptimisticTokenVoting
function bridgedVotingPower(uint256 _timestamp) public view returns (uint256) {
return votingToken.getPastVotes(taikoBridge, _timestamp);
return votingToken.getPastVotes(taikoERC20Vault, _timestamp);
}

/// @inheritdoc IOptimisticTokenVoting
Expand All @@ -213,12 +214,8 @@ contract OptimisticTokenVotingPlugin is
// No L2 blocks yet
if (_id == 0) return false;

// The last L2 block is too old
TaikoData.Block memory _block = taikoL1.getBlock(_id - 1);
// proposedAt < (block.timestamp - l2InactivityPeriod), written as a sum
if ((_block.proposedAt + governanceSettings.l2InactivityPeriod) < block.timestamp) return false;

return true;
(,, uint64 lastBlockVerifiedTimestamp) = taikoL1.getLastVerifiedBlock();
return (lastBlockVerifiedTimestamp + governanceSettings.l2InactivityPeriod) >= block.timestamp;
}

/// @inheritdoc IOptimisticTokenVoting
Expand Down Expand Up @@ -256,8 +253,8 @@ contract OptimisticTokenVotingPlugin is
return false;
}

// The bridge cannot vote directly. It must use a dedicated function.
if (_voter == taikoBridge) {
// Protocol contracts cannot vote directly. Bridged L2 tokens must use a dedicated function.
if (_voter == taikoBridge || _voter == taikoL1 || _voter == taikoERC20Vault) {
return false;
}

Expand Down Expand Up @@ -346,7 +343,7 @@ contract OptimisticTokenVotingPlugin is
}

// Checks
bool _enableL2 = isL2Available() && votingToken.getPastVotes(taikoBridge, snapshotTimestamp) > 0;
bool _enableL2 = isL2Available() && votingToken.getPastVotes(taikoERC20Vault, snapshotTimestamp) > 0;
if (effectiveVotingPower(snapshotTimestamp, _enableL2) == 0) {
revert NoVotingPower();
}
Expand Down
5 changes: 5 additions & 0 deletions src/adapted-dependencies/TaikoL1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ abstract contract TaikoL1 {
function slotB() public view virtual returns (TaikoData.SlotB memory);

function getBlock(uint64 _blockId) public view virtual returns (TaikoData.Block memory);
function getLastVerifiedBlock()
public
view
virtual
returns (uint64 blockId_, bytes32 blockHash_, bytes32 stateRoot_);
}

library TaikoData {
Expand Down

0 comments on commit e1082f1

Please sign in to comment.