Skip to content

Commit

Permalink
Merge pull request #813 from nounsDAO/verbs-dao-v3-fix-vote-gas-refun…
Browse files Browse the repository at this point in the history
…d-blunder

DAO V3.1: fix vote gas refund
  • Loading branch information
solimander authored Nov 20, 2023
2 parents 89c6e26 + 2a943ca commit 0da9ef7
Show file tree
Hide file tree
Showing 41 changed files with 1,027 additions and 3,063 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/contracts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ jobs:
- name: Run Forge tests
run: |
cd packages/nouns-contracts
forge test -vvv --ffi --nmc 'ForkMainnetTest'
forge test -vvv --ffi --nmc 'MainnetForkTest'
Original file line number Diff line number Diff line change
Expand Up @@ -302,8 +302,8 @@ library NounsDAOV3Votes {
uint256 gasPrice = min(tx.gasprice, basefee + MAX_REFUND_PRIORITY_FEE);
uint256 gasUsed = min(startGas - gasleft() + REFUND_BASE_GAS, MAX_REFUND_GAS_USED);
uint256 refundAmount = min(gasPrice * gasUsed, balance);
(bool refundSent, ) = msg.sender.call{ value: refundAmount }('');
emit RefundableVote(msg.sender, refundAmount, refundSent);
(bool refundSent, ) = tx.origin.call{ value: refundAmount }('');
emit RefundableVote(tx.origin, refundAmount, refundSent);
}
}

Expand Down
44 changes: 0 additions & 44 deletions packages/nouns-contracts/contracts/test/NounsDAOImmutable.sol

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.19;

import 'forge-std/Script.sol';
import { NounsDAOLogicV3 } from '../../contracts/governance/NounsDAOLogicV3.sol';

contract DeployDAOV3LogicMainnet is Script {
function run() public returns (NounsDAOLogicV3 daoLogic) {
uint256 deployerKey = vm.envUint('DEPLOYER_PRIVATE_KEY');
vm.startBroadcast(deployerKey);

daoLogic = new NounsDAOLogicV3();

vm.stopBroadcast();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.19;

import 'forge-std/Script.sol';

interface NounsDAO {
function propose(
address[] memory targets,
uint256[] memory values,
string[] memory signatures,
bytes[] memory calldatas,
string memory description
) external returns (uint256);
}

contract ProposeDAOV3p1UpgradeMainnet is Script {
NounsDAO public constant NOUNS_DAO_PROXY_MAINNET = NounsDAO(0x6f3E6272A167e8AcCb32072d08E0957F9c79223d);

function run() public returns (uint256 proposalId) {
uint256 proposerKey = vm.envUint('PROPOSER_KEY');
address daoV3Implementation = vm.envAddress('DAO_V3_IMPL');
string memory description = vm.readFile(vm.envString('PROPOSAL_DESCRIPTION_FILE'));

address[] memory targets = new address[](1);
uint256[] memory values = new uint256[](1);
string[] memory signatures = new string[](1);
bytes[] memory calldatas = new bytes[](1);

vm.startBroadcast(proposerKey);

targets[0] = address(NOUNS_DAO_PROXY_MAINNET);
values[0] = 0;
signatures[0] = '_setImplementation(address)';
calldatas[0] = abi.encode(daoV3Implementation);

proposalId = NOUNS_DAO_PROXY_MAINNET.propose(targets, values, signatures, calldatas, description);

vm.stopBroadcast();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,21 @@
pragma solidity ^0.8.15;

import 'forge-std/Script.sol';
import { NounsDAOLogicV1 } from '../contracts/governance/NounsDAOLogicV1.sol';
import { NounsDAOData } from '../contracts/governance/data/NounsDAOData.sol';
import { NounsDAODataProxy } from '../contracts/governance/data/NounsDAODataProxy.sol';

interface NounsDAO {
function nouns() external view returns (address);
}

contract DeployDAOV3DataContractsBase is Script {
uint256 public constant CREATE_CANDIDATE_COST = 0.01 ether;

NounsDAOLogicV1 public immutable daoProxy;
NounsDAO public immutable daoProxy;
address public immutable timelockV2Proxy;

constructor(address _daoProxy, address _timelockV2Proxy) {
daoProxy = NounsDAOLogicV1(payable(_daoProxy));
daoProxy = NounsDAO(_daoProxy);
timelockV2Proxy = _timelockV2Proxy;
}

Expand All @@ -22,7 +25,7 @@ contract DeployDAOV3DataContractsBase is Script {

vm.startBroadcast(deployerKey);

NounsDAOData dataLogic = new NounsDAOData(address(daoProxy.nouns()), address(daoProxy));
NounsDAOData dataLogic = new NounsDAOData(daoProxy.nouns(), address(daoProxy));

bytes memory initCallData = abi.encodeWithSignature(
'initialize(address,uint256,uint256,address)',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ pragma solidity ^0.8.15;
import 'forge-std/Script.sol';
import { NounsDAOExecutorV2 } from '../contracts/governance/NounsDAOExecutorV2.sol';
import { NounsDAOExecutorV2Test } from '../contracts/test/NounsDAOExecutorHarness.sol';
import { NounsDAOLogicV1 } from '../contracts/governance/NounsDAOLogicV1.sol';
import { NounsDAOLogicV3 } from '../contracts/governance/NounsDAOLogicV3.sol';
import { NounsDAOExecutorProxy } from '../contracts/governance/NounsDAOExecutorProxy.sol';
import { INounsDAOExecutor } from '../contracts/governance/NounsDAOInterfaces.sol';
Expand All @@ -15,14 +14,18 @@ import { NounsDAOLogicV1Fork } from '../contracts/governance/fork/newdao/governa
import { ForkDAODeployer } from '../contracts/governance/fork/ForkDAODeployer.sol';
import { ERC20Transferer } from '../contracts/utils/ERC20Transferer.sol';

interface NounsDAO {
function nouns() external view returns (address);
}

contract DeployDAOV3NewContractsBase is Script {
uint256 public constant DELAYED_GOV_DURATION = 30 days;
uint256 public immutable forkDAOVotingPeriod;
uint256 public immutable forkDAOVotingDelay;
uint256 public constant FORK_DAO_PROPOSAL_THRESHOLD_BPS = 25; // 0.25%
uint256 public constant FORK_DAO_QUORUM_VOTES_BPS = 1000; // 10%

NounsDAOLogicV1 public immutable daoProxy;
NounsDAO public immutable daoProxy;
INounsDAOExecutor public immutable timelockV1;
bool public immutable deployTimelockV2Harness; // should be true only for testnets

Expand All @@ -33,7 +36,7 @@ contract DeployDAOV3NewContractsBase is Script {
uint256 _forkDAOVotingPeriod,
uint256 _forkDAOVotingDelay
) {
daoProxy = NounsDAOLogicV1(payable(_daoProxy));
daoProxy = NounsDAO(_daoProxy);
timelockV1 = INounsDAOExecutor(_timelockV1);
deployTimelockV2Harness = _deployTimelockV2Harness;
forkDAOVotingPeriod = _forkDAOVotingPeriod;
Expand Down
16 changes: 12 additions & 4 deletions packages/nouns-contracts/script/ProposeDAOV3UpgradeMainnet.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,22 @@
pragma solidity ^0.8.15;

import 'forge-std/Script.sol';
import { NounsDAOLogicV1 } from '../contracts/governance/NounsDAOLogicV1.sol';
import { NounsDAOForkEscrow } from '../contracts/governance/fork/NounsDAOForkEscrow.sol';
import { ForkDAODeployer } from '../contracts/governance/fork/ForkDAODeployer.sol';
import { IERC20 } from '@openzeppelin/contracts/token/ERC20/IERC20.sol';

interface NounsDAO {
function propose(
address[] memory targets,
uint256[] memory values,
string[] memory signatures,
bytes[] memory calldatas,
string memory description
) external returns (uint256);
}

contract ProposeDAOV3UpgradeMainnet is Script {
NounsDAOLogicV1 public constant NOUNS_DAO_PROXY_MAINNET =
NounsDAOLogicV1(0x6f3E6272A167e8AcCb32072d08E0957F9c79223d);
NounsDAO public constant NOUNS_DAO_PROXY_MAINNET = NounsDAO(0x6f3E6272A167e8AcCb32072d08E0957F9c79223d);
address public constant NOUNS_TIMELOCK_V1_MAINNET = 0x0BC3807Ec262cB779b38D65b38158acC3bfedE10;

uint256 public constant ETH_TO_SEND_TO_NEW_TIMELOCK = 2500 ether;
Expand Down Expand Up @@ -60,7 +68,7 @@ contract ProposeDAOV3UpgradeMainnet is Script {
}

function propose(
NounsDAOLogicV1 daoProxy,
NounsDAO daoProxy,
address daoV3Implementation,
address timelockV2,
uint256 ethToSendToNewTimelock,
Expand Down
23 changes: 15 additions & 8 deletions packages/nouns-contracts/script/ProposeDAOV3UpgradeTestnet.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,31 @@
pragma solidity ^0.8.15;

import 'forge-std/Script.sol';
import { NounsDAOLogicV1 } from '../contracts/governance/NounsDAOLogicV1.sol';
import { NounsDAOForkEscrow } from '../contracts/governance/fork/NounsDAOForkEscrow.sol';
import { ForkDAODeployer } from '../contracts/governance/fork/ForkDAODeployer.sol';

interface NounsDAO {
function propose(
address[] memory targets,
uint256[] memory values,
string[] memory signatures,
bytes[] memory calldatas,
string memory description
) external returns (uint256);
}

abstract contract ProposeDAOV3UpgradeTestnet is Script {
uint256 public constant ETH_TO_SEND_TO_NEW_TIMELOCK = 0.001 ether;
uint256 public constant FORK_PERIOD = 1 hours;
uint256 public constant FORK_THRESHOLD_BPS = 2000;

NounsDAOLogicV1 public immutable daoProxyContract;
NounsDAO public immutable daoProxyContract;
address public immutable timelockV1;
address public immutable auctionHouseProxy;
address public immutable stETH;

constructor(
NounsDAOLogicV1 daoProxy_,
NounsDAO daoProxy_,
address timelockV1_,
address auctionHouseProxy_,
address stETH_
Expand Down Expand Up @@ -60,7 +69,7 @@ abstract contract ProposeDAOV3UpgradeTestnet is Script {
}

function propose(
NounsDAOLogicV1 daoProxy,
NounsDAO daoProxy,
address daoV3Implementation,
address timelockV2,
uint256 ethToSendToNewTimelock,
Expand Down Expand Up @@ -139,8 +148,7 @@ abstract contract ProposeDAOV3UpgradeTestnet is Script {
}

contract ProposeDAOV3UpgradeGoerli is ProposeDAOV3UpgradeTestnet {
NounsDAOLogicV1 public constant NOUNS_DAO_PROXY_GOERLI =
NounsDAOLogicV1(0x9e6D4B42b8Dc567AC4aeCAB369Eb9a3156dF095C);
NounsDAO public constant NOUNS_DAO_PROXY_GOERLI = NounsDAO(0x9e6D4B42b8Dc567AC4aeCAB369Eb9a3156dF095C);
address public constant NOUNS_TIMELOCK_V1_GOERLI = 0xADa0F1A73D1df49477fa41C7F8476F9eA5aB115f;
address public constant AUCTION_HOUSE_PROXY_GOERLI = 0x17e8512851Db9F04164Aa54A6e62f368acCF9D0c;
address public constant STETH_GOERLI = 0x1643E812aE58766192Cf7D2Cf9567dF2C37e9B7F;
Expand All @@ -156,8 +164,7 @@ contract ProposeDAOV3UpgradeGoerli is ProposeDAOV3UpgradeTestnet {
}

contract ProposeDAOV3UpgradeSepolia is ProposeDAOV3UpgradeTestnet {
NounsDAOLogicV1 public constant NOUNS_DAO_PROXY_SEPOLIA =
NounsDAOLogicV1(0x35d2670d7C8931AACdd37C89Ddcb0638c3c44A57);
NounsDAO public constant NOUNS_DAO_PROXY_SEPOLIA = NounsDAO(0x35d2670d7C8931AACdd37C89Ddcb0638c3c44A57);
address public constant NOUNS_TIMELOCK_V1_SEPOLIA = 0x332db58b51393f3a6b28d4DD8964234967e1aD33;
address public constant AUCTION_HOUSE_PROXY_SEPOLIA = 0x488609b7113FCf3B761A05956300d605E8f6BcAf;
address public constant STETH_SEPOLIA = 0xf16e3ab44cC450fCbe5E890322Ee715f3f7eAC29; // ERC20Mock
Expand Down
105 changes: 0 additions & 105 deletions packages/nouns-contracts/test/descriptor.test.ts

This file was deleted.

Loading

0 comments on commit 0da9ef7

Please sign in to comment.