Skip to content

Commit

Permalink
fix: fixing stack too deep errors
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosgj94 committed Mar 21, 2024
1 parent 72380ce commit ae26ca6
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 271 deletions.
3 changes: 3 additions & 0 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ src = "src"
out = "out"
libs = ["lib"]
evm_version = "shanghai"
optimizer = true
optimizer-runs = 10_000_000

# solc = "0.8.20"


Expand Down
49 changes: 29 additions & 20 deletions script/OptimisticTokenVotingPlugin.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,37 @@ pragma solidity ^0.8.13;
import {Script, console2} from "forge-std/Script.sol";
import {OptimisticTokenVotingPluginSetup} from "../src/OptimisticTokenVotingPluginSetup.sol";
import {OptimisticTokenVotingPlugin} from "../src/OptimisticTokenVotingPlugin.sol";
import {DAOFactory} from "@aragon/osx/framework/dao/DAOFactory.sol";
import {GovernanceERC20} from "@aragon/osx/token/ERC20/governance/GovernanceERC20.sol";
import {GovernanceWrappedERC20} from "@aragon/osx/token/ERC20/governance/GovernanceWrappedERC20.sol";
import {PluginRepoFactory} from "@aragon/osx/framework/plugin/repo/PluginRepoFactory.sol";
import {PluginRepo} from "@aragon/osx/framework/plugin/repo/PluginRepo.sol";
import {hashHelpers, PluginSetupRef} from "@aragon/osx/framework/plugin/setup/PluginSetupProcessorHelpers.sol";

contract OptimisticTokenVotingPluginScript is Script {
function setUp() public {}

function run() public {
address governanceERC20Base = vm.envAddress("GOVERNANCE_ERC20_BASE");
address governanceWrappedERC20Base = vm.envAddress(
address governanceERC20Base;
address governanceWrappedERC20Base;
address pluginRepoFactory;
DAOFactory daoFactory;
uint16 l2ChainId;
address lzEndpoint;
address tokenAddress;
address l2VotingAggregator;

function setUp() public {
governanceERC20Base = vm.envAddress("GOVERNANCE_ERC20_BASE");
governanceWrappedERC20Base = vm.envAddress(
"GOVERNANCE_WRAPPED_ERC20_BASE"
);
address pluginRepoFactory = vm.envAddress("PLUGIN_REPO_FACTORY");
DAOFactory daoFactory = DAOFactory(vm.envAddress("DAO_FACTORY"));
address tokenAddress = vm.envAddress("TOKEN_ADDRESS");

uint256 l2ChainId = vm.envUint("L2_CHAIN_ID");
address lzEndpoint = vm.envAddress("LZ_L1_ENDPOINT");
address l2VotingAggregator = vm.envAddress("L2_VOTING_AGG");
pluginRepoFactory = vm.envAddress("PLUGIN_REPO_FACTORY");
daoFactory = DAOFactory(vm.envAddress("DAO_FACTORY"));
l2ChainId = uint16(vm.envUint("L2_CHAIN_ID"));
lzEndpoint = vm.envAddress("LZ_L1_ENDPOINT");
tokenAddress = vm.envAddress("TOKEN_ADDRESS");
l2VotingAggregator = vm.envAddress("L2_VOTING_AGG");
}

function run() public {
// 0. Setting up Foundry
vm.startBroadcast(vm.envUint("PRIVATE_KEY"));

Expand Down Expand Up @@ -53,21 +67,16 @@ contract OptimisticTokenVotingPluginScript is Script {
memory votingSettings = OptimisticTokenVotingPlugin
.OptimisticGovernanceSettings(200000, 60 * 60 * 24 * 4, 0);
OptimisticTokenVotingPluginSetup.TokenSettings
memory tokenSettings = OptimisticTokenVotingPlugin.TokenSettings(
tokenAddress,
"",
""
);
memory tokenSettings = OptimisticTokenVotingPluginSetup
.TokenSettings(tokenAddress, "", "");

address[] memory holders = new address[](0);
uint256[] memory amounts = new uint256[](0);
GovernanceERC20.MintSettings memory mintSettings = GovernanceERC20
.MintSettings(holders, amounts);

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

OptimisticTokenVotingPlugin.BridgeSettings
memory bridgeSettings = OptimisticTokenVotingPlugin.BridgeSettings(
Expand Down
103 changes: 0 additions & 103 deletions scripts/OptimisticTokenVotingPlugin.s.sol

This file was deleted.

7 changes: 0 additions & 7 deletions src/IOptimisticTokenVoting.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,6 @@ interface IOptimisticTokenVoting {
/// @return The token used for voting.
function getVotingToken() external view returns (IVotesUpgradeable);

/// @notice Returns the total voting power checkpointed for a specific block number.
/// @param _blockNumber The block number.
/// @return The total voting power.
function totalVotingPower(
uint256 _blockNumber
) external view returns (uint256);

/// @notice Returns the veto ratio parameter stored in the optimistic governance settings.
/// @return The veto ratio parameter.
function minVetoRatio() external view returns (uint32);
Expand Down
11 changes: 3 additions & 8 deletions src/OptimisticTokenVotingPlugin.sol
Original file line number Diff line number Diff line change
Expand Up @@ -222,13 +222,6 @@ contract OptimisticTokenVotingPlugin is
return votingToken;
}

/// @inheritdoc IOptimisticTokenVoting
function totalVotingPower(
uint256 _blockNumber
) public view returns (uint256) {
return votingToken.getPastTotalSupply(_blockNumber);
}

/// @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.
Expand Down Expand Up @@ -386,7 +379,9 @@ contract OptimisticTokenVotingPlugin is
snapshotBlock = block.number - 1; // The snapshot block must be mined already to protect the transaction against backrunning transactions causing census changes.
}

uint256 totalVotingPower_ = totalVotingPower(snapshotBlock);
uint256 totalVotingPower_ = votingToken.getPastTotalSupply(
snapshotBlock
);

if (totalVotingPower_ == 0) {
revert NoVotingPower();
Expand Down
Loading

0 comments on commit ae26ca6

Please sign in to comment.