Skip to content

Commit

Permalink
feat: making the necessary changes for the deployment (reducing bytec…
Browse files Browse the repository at this point in the history
…ode size)
  • Loading branch information
carlosgj94 committed Mar 28, 2024
1 parent 061fdd0 commit 2d5dcce
Show file tree
Hide file tree
Showing 16 changed files with 3,438 additions and 83 deletions.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

55 changes: 55 additions & 0 deletions broadcast/1.DeployL2VetoAggregation.s.sol/84532/run-latest.json

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

963 changes: 963 additions & 0 deletions broadcast/2.OptimisticTokenVotingPlugin.s.sol/11155111/run-latest.json

Large diffs are not rendered by default.

36 changes: 36 additions & 0 deletions broadcast/3.SetL2BridgeSettings.s.sol/84532/run-1711528394.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"transactions": [
{
"hash": "0x70d2dc7ddd206cbed8a6f9f4e8e507f2de962d897a5dbb9189e07dc543dc738f",
"transactionType": "CALL",
"contractName": null,
"contractAddress": "0x49Ae32cf606e5cCdcf0d7Fe494f94AaaC3deb894",
"function": "initialize((uint16,address,address))",
"arguments": [
"(10161, 0x55370E0fBB5f5b8dAeD978BA1c075a499eB107B8, 0x7AC7CE1FABf3F75836F5b93fb7b733aD86fc5596)"
],
"transaction": {
"type": "0x02",
"from": "0x258c7a0e0f5f4d2722c74899cfe66a4ce7a0b6b1",
"to": "0x49ae32cf606e5ccdcf0d7fe494f94aaac3deb894",
"gas": "0x38c44",
"value": "0x0",
"data": "0x7e3bba1300000000000000000000000000000000000000000000000000000000000027b100000000000000000000000055370e0fbb5f5b8daed978ba1c075a499eb107b80000000000000000000000007ac7ce1fabf3f75836f5b93fb7b733ad86fc5596",
"nonce": "0x5",
"accessList": []
},
"additionalContracts": [],
"isFixedGasLimit": false
}
],
"receipts": [],
"libraries": [],
"pending": [
"0x70d2dc7ddd206cbed8a6f9f4e8e507f2de962d897a5dbb9189e07dc543dc738f"
],
"returns": {},
"timestamp": 1711528394,
"chain": 84532,
"multi": false,
"commit": "061fdd0"
}
65 changes: 65 additions & 0 deletions broadcast/3.SetL2BridgeSettings.s.sol/84532/run-1711528400.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{
"transactions": [
{
"hash": "0x70d2dc7ddd206cbed8a6f9f4e8e507f2de962d897a5dbb9189e07dc543dc738f",
"transactionType": "CALL",
"contractName": null,
"contractAddress": "0x49Ae32cf606e5cCdcf0d7Fe494f94AaaC3deb894",
"function": "initialize((uint16,address,address))",
"arguments": [
"(10161, 0x55370E0fBB5f5b8dAeD978BA1c075a499eB107B8, 0x7AC7CE1FABf3F75836F5b93fb7b733aD86fc5596)"
],
"transaction": {
"type": "0x02",
"from": "0x258c7a0e0f5f4d2722c74899cfe66a4ce7a0b6b1",
"to": "0x49ae32cf606e5ccdcf0d7fe494f94aaac3deb894",
"gas": "0x38c44",
"value": "0x0",
"data": "0x7e3bba1300000000000000000000000000000000000000000000000000000000000027b100000000000000000000000055370e0fbb5f5b8daed978ba1c075a499eb107b80000000000000000000000007ac7ce1fabf3f75836f5b93fb7b733ad86fc5596",
"nonce": "0x5",
"accessList": []
},
"additionalContracts": [],
"isFixedGasLimit": false
}
],
"receipts": [
{
"transactionHash": "0x70d2dc7ddd206cbed8a6f9f4e8e507f2de962d897a5dbb9189e07dc543dc738f",
"transactionIndex": "0x1",
"blockHash": "0xc844c3865b71296ae47e1d75dac3e53025fce7e8a952ff239fdbbb197893886b",
"blockNumber": "0x783d76",
"from": "0x258c7A0e0F5F4D2722C74899cFE66a4Ce7a0B6b1",
"to": "0x49Ae32cf606e5cCdcf0d7Fe494f94AaaC3deb894",
"cumulativeGasUsed": "0x31879",
"gasUsed": "0x26d0a",
"contractAddress": null,
"logs": [
{
"address": "0x49Ae32cf606e5cCdcf0d7Fe494f94AaaC3deb894",
"topics": [
"0xfa41487ad5d6728f0b19276fa1eddc16558578f5109fc39d2dc33c3230470dab"
],
"data": "0x00000000000000000000000000000000000000000000000000000000000027b1000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000287ac7ce1fabf3f75836f5b93fb7b733ad86fc559649ae32cf606e5ccdcf0d7fe494f94aaac3deb894000000000000000000000000000000000000000000000000",
"blockHash": "0xc844c3865b71296ae47e1d75dac3e53025fce7e8a952ff239fdbbb197893886b",
"blockNumber": "0x783d76",
"transactionHash": "0x70d2dc7ddd206cbed8a6f9f4e8e507f2de962d897a5dbb9189e07dc543dc738f",
"transactionIndex": "0x1",
"logIndex": "0x0",
"removed": false
}
],
"status": "0x1",
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000080000000000000000000000200000000100000004000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"type": "0x2",
"effectiveGasPrice": "0xb2d05f07"
}
],
"libraries": [],
"pending": [],
"returns": {},
"timestamp": 1711528400,
"chain": 84532,
"multi": false,
"commit": "061fdd0"
}
65 changes: 65 additions & 0 deletions broadcast/3.SetL2BridgeSettings.s.sol/84532/run-latest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{
"transactions": [
{
"hash": "0x70d2dc7ddd206cbed8a6f9f4e8e507f2de962d897a5dbb9189e07dc543dc738f",
"transactionType": "CALL",
"contractName": null,
"contractAddress": "0x49Ae32cf606e5cCdcf0d7Fe494f94AaaC3deb894",
"function": "initialize((uint16,address,address))",
"arguments": [
"(10161, 0x55370E0fBB5f5b8dAeD978BA1c075a499eB107B8, 0x7AC7CE1FABf3F75836F5b93fb7b733aD86fc5596)"
],
"transaction": {
"type": "0x02",
"from": "0x258c7a0e0f5f4d2722c74899cfe66a4ce7a0b6b1",
"to": "0x49ae32cf606e5ccdcf0d7fe494f94aaac3deb894",
"gas": "0x38c44",
"value": "0x0",
"data": "0x7e3bba1300000000000000000000000000000000000000000000000000000000000027b100000000000000000000000055370e0fbb5f5b8daed978ba1c075a499eb107b80000000000000000000000007ac7ce1fabf3f75836f5b93fb7b733ad86fc5596",
"nonce": "0x5",
"accessList": []
},
"additionalContracts": [],
"isFixedGasLimit": false
}
],
"receipts": [
{
"transactionHash": "0x70d2dc7ddd206cbed8a6f9f4e8e507f2de962d897a5dbb9189e07dc543dc738f",
"transactionIndex": "0x1",
"blockHash": "0xc844c3865b71296ae47e1d75dac3e53025fce7e8a952ff239fdbbb197893886b",
"blockNumber": "0x783d76",
"from": "0x258c7A0e0F5F4D2722C74899cFE66a4Ce7a0B6b1",
"to": "0x49Ae32cf606e5cCdcf0d7Fe494f94AaaC3deb894",
"cumulativeGasUsed": "0x31879",
"gasUsed": "0x26d0a",
"contractAddress": null,
"logs": [
{
"address": "0x49Ae32cf606e5cCdcf0d7Fe494f94AaaC3deb894",
"topics": [
"0xfa41487ad5d6728f0b19276fa1eddc16558578f5109fc39d2dc33c3230470dab"
],
"data": "0x00000000000000000000000000000000000000000000000000000000000027b1000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000287ac7ce1fabf3f75836f5b93fb7b733ad86fc559649ae32cf606e5ccdcf0d7fe494f94aaac3deb894000000000000000000000000000000000000000000000000",
"blockHash": "0xc844c3865b71296ae47e1d75dac3e53025fce7e8a952ff239fdbbb197893886b",
"blockNumber": "0x783d76",
"transactionHash": "0x70d2dc7ddd206cbed8a6f9f4e8e507f2de962d897a5dbb9189e07dc543dc738f",
"transactionIndex": "0x1",
"logIndex": "0x0",
"removed": false
}
],
"status": "0x1",
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000080000000000000000000000200000000100000004000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"type": "0x2",
"effectiveGasPrice": "0xb2d05f07"
}
],
"libraries": [],
"pending": [],
"returns": {},
"timestamp": 1711528400,
"chain": 84532,
"multi": false,
"commit": "061fdd0"
}
4 changes: 2 additions & 2 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ optimizer-runs = 10_000_000

[rpc_endpoints]
sepolia = "${SEPOLIA_RPC_URL}"
sepolia_base = "${SEPOLIA_BASE_RPC_URL}"
base_sepolia = "${SEPOLIA_BASE_RPC_URL}"
mumbai = "${MUMBAI_RPC_URL}"

[etherscan]
sepolia = { key = "${ETHERSCAN_API_KEY}" }
sepolia_base = { key = "${ETHERSCAN_API_KEY}" }
base_sepolia = { key = "${ETHERSCAN_API_KEY}" }
mumbai = { key = "${ETHERSCAN_API_KEY}" }
2 changes: 1 addition & 1 deletion script/1.DeployL2VetoAggregation.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {Script, console2} from "forge-std/Script.sol";
import {L2VetoAggregation} from "../src/L2VetoAggregation.sol";
import {IVotesUpgradeable} from "@openzeppelin/contracts-upgradeable/governance/utils/IVotesUpgradeable.sol";

contract L2VetoAggregationDeployment is Script {
contract Deploy is Script {
address votingToken;

function setUp() public {
Expand Down
11 changes: 6 additions & 5 deletions script/2.OptimisticTokenVotingPlugin.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ contract Deploy is Script {
uint16 l2ChainId;
address lzEndpoint;
address tokenAddress;
address l2VotingAggregator;
address l2VetoAggregation;
string entropyName;
address[] pluginAddress;

Expand All @@ -34,7 +34,7 @@ contract Deploy is Script {
l2ChainId = uint16(vm.envUint("L2_CHAIN_ID"));
lzEndpoint = vm.envAddress("LZ_L1_ENDPOINT");
tokenAddress = vm.envAddress("TOKEN_ADDRESS");
l2VotingAggregator = vm.envAddress("L2_VOTING_AGG");
l2VetoAggregation = vm.envAddress("L2_VETO_AGGREGATION");
entropyName = string.concat(
"optimistic-crosschain-",
vm.toString(block.timestamp)
Expand Down Expand Up @@ -129,7 +129,7 @@ contract Deploy is Script {
) public view returns (DAOFactory.PluginSettings[] memory pluginSettings) {
OptimisticLzVotingPlugin.OptimisticGovernanceSettings
memory votingSettings = OptimisticLzVotingPlugin
.OptimisticGovernanceSettings(200000, 60 * 60 * 24 * 4, 0);
.OptimisticGovernanceSettings(200000, 60 * 60 * 24 * 6, 0);
OptimisticLzVotingPluginSetup.TokenSettings
memory tokenSettings = OptimisticLzVotingPluginSetup.TokenSettings(
tokenAddress,
Expand All @@ -142,15 +142,16 @@ contract Deploy is Script {
GovernanceERC20.MintSettings memory mintSettings = GovernanceERC20
.MintSettings(holders, amounts);

address[] memory proposers = new address[](2);
address[] memory proposers = new address[](3);
proposers[0] = 0x8bF1e340055c7dE62F11229A149d3A1918de3d74;
proposers[1] = 0x35911Cc89aaBe7Af6726046823D5b678B6A1498d;
proposers[2] = 0xa722c2c1f2218929945737EbdB8cB0f228E43265;

OptimisticLzVotingPlugin.BridgeSettings
memory bridgeSettings = OptimisticLzVotingPlugin.BridgeSettings(
l2ChainId,
lzEndpoint,
l2VotingAggregator
l2VetoAggregation
);

bytes memory pluginSettingsData = abi.encode(
Expand Down
28 changes: 4 additions & 24 deletions src/OptimisticLzVotingPlugin.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import {NonblockingLzApp} from "./lzApp/NonblockingLzApp.sol";
/// @dev This contract implements the `IOptimisticTokenVoting` interface.
contract OptimisticLzVotingPlugin is
IOptimisticTokenVoting,
IMembership,
Initializable,
ERC165Upgradeable,
PluginUUPSUpgradeable,
Expand Down Expand Up @@ -191,8 +190,6 @@ contract OptimisticLzVotingPlugin is
address(this)
);
setTrustedRemote(_bridgeSettings.chainId, remoteAddresses);

emit MembershipContractAnnounced({definingContract: address(_token)});
}

/// @notice Checks if this or the parent contract supports an interface by its ID.
Expand All @@ -219,14 +216,6 @@ contract OptimisticLzVotingPlugin is
return votingToken;
}

/// @inheritdoc IMembership
function isMember(address _account) external view returns (bool) {
// A member must own at least one token or have at least one token delegated to her/him.
return
votingToken.getVotes(_account) > 0 ||
IERC20Upgradeable(address(votingToken)).balanceOf(_account) > 0;
}

/// @inheritdoc IOptimisticTokenVoting
function hasVetoed(
uint256 _proposalId,
Expand Down Expand Up @@ -272,11 +261,12 @@ contract OptimisticLzVotingPlugin is
Proposal storage proposal_ = proposals[_proposalId];

// Verify that the vote has not been executed already.
uint64 currentTime = block.timestamp.toUint64();
if (proposal_.executed) {
return false;
}
// Check that the proposal vetoing time frame already expired
else if (!_isProposalEnded(proposal_)) {
else if (currentTime < proposal_.parameters.endDate) {
return false;
}
// Check that not enough voters have vetoed the proposal
Expand Down Expand Up @@ -549,17 +539,6 @@ contract OptimisticLzVotingPlugin is
!proposal_.executed;
}

/// @notice Internal function to check if a proposal already ended.
/// @param proposal_ The proposal struct.
/// @return True if the end date of the proposal is already in the past, false otherwise.
function _isProposalEnded(
Proposal storage proposal_
) internal view virtual returns (bool) {
uint64 currentTime = block.timestamp.toUint64();

return currentTime >= proposal_.parameters.endDate;
}

/// @notice Validates and returns the proposal vote dates.
/// @param _start The start date of the proposal vote. If 0, the current timestamp is used and the vote starts immediately.
/// @param _end The end date of the proposal vote. If 0, `_start + minDuration` is used.
Expand Down Expand Up @@ -640,5 +619,6 @@ contract OptimisticLzVotingPlugin is
}

/// @notice This empty reserved space is put in place to allow future versions to add new variables without shifting down storage in the inheritance chain (see [OpenZeppelin's guide about storage gaps](https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps)).
uint256[50] private __gap;
// TODO: Add this back in once deployment works
// uint256[50] private __gap;
}
51 changes: 0 additions & 51 deletions test/OptimisticTokenVotingPlugin.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -428,57 +428,6 @@ contract OptimisticLzVotingPluginTest is Test {
);
}

function test_TokenHoldersAreMembers() public {
assertEq(plugin.isMember(alice), true, "Alice should not be a member");
assertEq(plugin.isMember(bob), false, "Bob should not be a member");
assertEq(
plugin.isMember(randomWallet),
false,
"Random wallet should not be a member"
);

// New token
votingToken = ERC20VotesMock(
createProxyAndCall(
address(votingTokenBase),
abi.encodeWithSelector(ERC20VotesMock.initialize.selector)
)
);
votingToken.mint(alice, 10 ether);
votingToken.mint(bob, 5 ether);
vm.roll(block.number + 1);

// Deploy a new plugin instance
OptimisticLzVotingPlugin.OptimisticGovernanceSettings
memory settings = OptimisticLzVotingPlugin
.OptimisticGovernanceSettings({
minVetoRatio: uint32(RATIO_BASE / 10),
minDuration: 10 days,
minProposerVotingPower: 1 ether
});

plugin = OptimisticLzVotingPlugin(
createProxyAndCall(
address(pluginBase),
abi.encodeWithSelector(
OptimisticLzVotingPlugin.initialize.selector,
dao,
settings,
votingToken,
lzAppEndpoint
)
)
);

assertEq(plugin.isMember(alice), true, "Alice should be a member");
assertEq(plugin.isMember(bob), true, "Bob should be a member");
assertEq(
plugin.isMember(randomWallet),
false,
"Random wallet should not be a member"
);
}

// Create proposal
function test_CreateProposalRevertsWhenCalledByANonProposer() public {
vm.stopPrank();
Expand Down

0 comments on commit 2d5dcce

Please sign in to comment.