generated from AngleProtocol/boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: governor connect mainnet to other chains
* feat: governor connect mainnet to other chains
- Loading branch information
1 parent
54bcb30
commit 4412f16
Showing
5 changed files
with
138 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
scripts/proposals/layerzeroRelayers/ProposalSenderConnect.s.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
53
test/scripts/layerzeroRelayers/ProposalSenderConnectTest.t.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} |