Skip to content

Commit

Permalink
feat: governor connect mainnet to other chains
Browse files Browse the repository at this point in the history
* feat: governor connect mainnet to other chains
  • Loading branch information
GuillaumeNervoXS authored Jan 16, 2024
1 parent 54bcb30 commit 4412f16
Show file tree
Hide file tree
Showing 5 changed files with 138 additions and 21 deletions.
6 changes: 3 additions & 3 deletions helpers/createProposal.sh
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,9 @@ function main {
echo "Would you like to create the proposal ? (yes/no)"
read execute

# if [[ $execute == "yes" ]]; then
# forge script scripts/interaction/Propose.s.sol:Propose --fork-url $mainnet_uri --broadcast
# fi
if [[ $execute == "yes" ]]; then
FOUNDRY_PROFILE=dev forge script scripts/proposals/Propose.s.sol:Propose --fork-url $mainnet_uri --broadcast
fi
}

main $@
2 changes: 1 addition & 1 deletion scripts/proposals/Wrapper.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ contract Wrapper is Utils {
}

if (chainId == CHAIN_SOURCE) {
vm.selectFork(forkIdentifier[1]);
vm.selectFork(forkIdentifier[CHAIN_SOURCE]);
(targets[finalPropLength], values[finalPropLength], calldatas[finalPropLength]) = wrapTimelock(
chainId,
prop
Expand Down
44 changes: 44 additions & 0 deletions scripts/proposals/layerzeroRelayers/ProposalSenderConnect.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.20;

import { console } from "forge-std/console.sol";
import { ProposalSender } from "contracts/ProposalSender.sol";

import { Wrapper } from "../Wrapper.s.sol";
import "../../Constants.s.sol";

contract ProposalSenderConnect is Wrapper {
function _setReceiver(uint256 chainId, address sender) private returns (address, uint256, bytes memory) {
address receiver = _chainToContract(chainId, ContractType.ProposalReceiver);
return (
sender,
0,
abi.encodeWithSelector(
ProposalSender.setTrustedRemoteAddress.selector,
getLZChainId(chainId),
abi.encodePacked(receiver)
)
);
}

function run() external {
uint256[] memory chainIds = vm.envUint("CHAIN_IDS", ",");
string memory description = "ipfs://QmRSdyuXeemVEn97RPRSiit6UEUonvwVr9we7bEe2w8v2E";

address sender = _chainToContract(CHAIN_SOURCE, ContractType.ProposalSender);

address[] memory targets = new address[](chainIds.length);
uint256[] memory values = new uint256[](chainIds.length);
bytes[] memory calldatas = new bytes[](chainIds.length);

vm.selectFork(forkIdentifier[CHAIN_SOURCE]);
for (uint256 i = 0; i < chainIds.length; i++) {
(address target, uint256 value, bytes memory data) = _setReceiver(chainIds[i], sender);
targets[i] = target;
values[i] = value;
calldatas[i] = data;
}

_serializeJson(targets, values, calldatas, chainIds, description);
}
}
54 changes: 37 additions & 17 deletions scripts/proposals/payload.json
Original file line number Diff line number Diff line change
@@ -1,31 +1,51 @@
{
"calldatas": {
"0": "0xbb5a944f0000000000000000000000000000000000000000000000000000000000000066000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000003800000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001600000000000000000000000000000000000000000000000000000000000000001000000000000000000000000c9025cef778a8032a689ac52798c66939c17c22f0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000012401d5062a000000000000000000000000c9025cef778a8032a689ac52798c66939c17c22f000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000015180000000000000000000000000000000000000000000000000000000000000002464d623530000000000000000000000000000000000000000000000000000000000093a8000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000022000100000000000000000000000000000000000000000000000000000000000493e0000000000000000000000000000000000000000000000000000000000000",
"1": "0xbb5a944f000000000000000000000000000000000000000000000000000000000000006e000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000003800000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001600000000000000000000000000000000000000000000000000000000000000001000000000000000000000000169487a55de79476125a56b07c36ca8dbf37a3730000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000012401d5062a000000000000000000000000169487a55de79476125a56b07c36ca8dbf37a373000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000015180000000000000000000000000000000000000000000000000000000000000002464d623530000000000000000000000000000000000000000000000000000000000093a8000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000022000100000000000000000000000000000000000000000000000000000000000493e0000000000000000000000000000000000000000000000000000000000000",
"2": "0xbb5a944f000000000000000000000000000000000000000000000000000000000000009e000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000003800000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001600000000000000000000000000000000000000000000000000000000000000001000000000000000000000000c1f9266c6d3389e981639ee873121199a7acdb8f0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000012401d5062a000000000000000000000000c1f9266c6d3389e981639ee873121199a7acdb8f000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000015180000000000000000000000000000000000000000000000000000000000000002464d623530000000000000000000000000000000000000000000000000000000000093a8000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000022000100000000000000000000000000000000000000000000000000000000000493e0000000000000000000000000000000000000000000000000000000000000",
"3": "0xbb5a944f000000000000000000000000000000000000000000000000000000000000006f000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000003800000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001600000000000000000000000000000000000000000000000000000000000000001000000000000000000000000343902fe4d72e24b29f22d787b2e54eeea5e82270000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000012401d5062a000000000000000000000000343902fe4d72e24b29f22d787b2e54eeea5e8227000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000015180000000000000000000000000000000000000000000000000000000000000002464d623530000000000000000000000000000000000000000000000000000000000093a8000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000022000100000000000000000000000000000000000000000000000000000000000493e0000000000000000000000000000000000000000000000000000000000000",
"4": "0xbb5a944f0000000000000000000000000000000000000000000000000000000000000091000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000003800000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001600000000000000000000000000000000000000000000000000000000000000001000000000000000000000000b2ea590fcea142dcceaeb3912da4c1df721848ef0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000012401d5062a000000000000000000000000b2ea590fcea142dcceaeb3912da4c1df721848ef000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000015180000000000000000000000000000000000000000000000000000000000000002464d623530000000000000000000000000000000000000000000000000000000000093a8000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000022000100000000000000000000000000000000000000000000000000000000000493e0000000000000000000000000000000000000000000000000000000000000"
"0": "0xa6c3d165000000000000000000000000000000000000000000000000000000000000006e00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000014cda39b74054effb230156f21b334e50295ca8df4000000000000000000000000",
"1": "0xa6c3d165000000000000000000000000000000000000000000000000000000000000006d000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000142c159fcb745570de3ecd934cab92ae3085d19c04000000000000000000000000",
"2": "0xa6c3d1650000000000000000000000000000000000000000000000000000000000000091000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000144d9a15925f972bc4d45233132efd0fb498836cfc000000000000000000000000",
"3": "0xa6c3d165000000000000000000000000000000000000000000000000000000000000006a000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000140750b6fdada48057dbc7103e1e9286f00f997d81000000000000000000000000",
"4": "0xa6c3d16500000000000000000000000000000000000000000000000000000000000000b800000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000014892bf71463bd9fa57f3c2266ab74dbe1b96decea000000000000000000000000",
"5": "0xa6c3d165000000000000000000000000000000000000000000000000000000000000006600000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000014b9807831b01ecb7b20d9fbe2b5454d066cd2de8e000000000000000000000000",
"6": "0xa6c3d165000000000000000000000000000000000000000000000000000000000000007d00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000014456f478a7210e0dc35ed67a5fec1d86cdcdabd6b000000000000000000000000",
"7": "0xa6c3d165000000000000000000000000000000000000000000000000000000000000009e0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000001492d84b0687361cd0753e95f5a8746fbaf42e9135000000000000000000000000",
"8": "0xa6c3d165000000000000000000000000000000000000000000000000000000000000006f00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000014d6788102627462d1a679282e726125ccdebab514000000000000000000000000",
"9": "0xa6c3d16500000000000000000000000000000000000000000000000000000000000000b7000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000144a44f77978daa3e92eb3d97210bd11645cf935ab000000000000000000000000"
},
"chainIds": {
"0": 56,
"1": 42161,
"2": 1101,
"3": 10,
"4": 100
"0": 42161,
"1": 137,
"2": 100,
"3": 43114,
"4": 8453,
"5": 56,
"6": 42220,
"7": 1101,
"8": 10,
"9": 59144
},
"description": "Set min delay for timelock",
"description": "ipfs://QmRSdyuXeemVEn97RPRSiit6UEUonvwVr9we7bEe2w8v2E",
"targets": {
"0": "0x896D64B4B7265273dDCD00808f3579563f9790A8",
"1": "0x896D64B4B7265273dDCD00808f3579563f9790A8",
"2": "0x896D64B4B7265273dDCD00808f3579563f9790A8",
"3": "0x896D64B4B7265273dDCD00808f3579563f9790A8",
"4": "0x896D64B4B7265273dDCD00808f3579563f9790A8"
"4": "0x896D64B4B7265273dDCD00808f3579563f9790A8",
"5": "0x896D64B4B7265273dDCD00808f3579563f9790A8",
"6": "0x896D64B4B7265273dDCD00808f3579563f9790A8",
"7": "0x896D64B4B7265273dDCD00808f3579563f9790A8",
"8": "0x896D64B4B7265273dDCD00808f3579563f9790A8",
"9": "0x896D64B4B7265273dDCD00808f3579563f9790A8"
},
"values": {
"0": 100000000000000000,
"1": 100000000000000000,
"2": 100000000000000000,
"3": 100000000000000000,
"4": 100000000000000000
"0": 0,
"1": 0,
"2": 0,
"3": 0,
"4": 0,
"5": 0,
"6": 0,
"7": 0,
"8": 0,
"9": 0
}
}
53 changes: 53 additions & 0 deletions test/scripts/layerzeroRelayers/ProposalSenderConnectTest.t.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.19;

import { stdJson } from "forge-std/StdJson.sol";
import { console } from "forge-std/console.sol";
import { ScriptHelpers } from "../ScriptHelpers.t.sol";
import "../../../scripts/Constants.s.sol";
import { TimelockControllerWithCounter } from "contracts/TimelockControllerWithCounter.sol";
import { ProposalSender } from "contracts/ProposalSender.sol";
import { ProposalReceiver } from "contracts/ProposalReceiver.sol";

contract ProposalSenderConnectTest is ScriptHelpers {
using stdJson for string;

function setUp() public override {
super.setUp();
}

function testScript() external {
(
bytes[] memory calldatas,
string memory description,
address[] memory targets,
uint256[] memory values,
uint256[] memory chainIds
) = _deserializeJson();

AngleGovernor governor = AngleGovernor(payable(_chainToContract(CHAIN_SOURCE, ContractType.Governor)));
ProposalSender sender = ProposalSender(payable(_chainToContract(CHAIN_SOURCE, ContractType.ProposalSender)));

vm.selectFork(forkIdentifier[CHAIN_SOURCE]);

vm.startPrank(whale);
uint256 proposalId = governor.propose(targets, values, calldatas, description);
vm.warp(block.timestamp + governor.votingDelay() + 1);
vm.roll(block.number + governor.$votingDelayBlocks() + 1);

governor.castVote(proposalId, 1);
vm.warp(block.timestamp + governor.votingPeriod() + 1);

governor.execute{ value: valueEther }(targets, values, calldatas, keccak256(bytes(description)));
vm.stopPrank();

for (uint256 i; i < chainIds.length; i++) {
uint256 chainId = chainIds[i];

address receiver = _chainToContract(chainId, ContractType.ProposalReceiver);
bytes memory trustedRemote = sender.trustedRemoteLookup(getLZChainId(chainId));
address connectedReceiver = address(bytes20(slice(trustedRemote, 0, 20)));
assertEq(receiver, connectedReceiver);
}
}
}

0 comments on commit 4412f16

Please sign in to comment.