Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V2 (placeholder) #351

Draft
wants to merge 24 commits into
base: igor/placeholder
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
ee32d03
Upgrade forge-std to v1.7.6
CodeSandwich May 27, 2024
3d235fa
Add Giver
CodeSandwich Dec 14, 2023
5f601b7
Add BridgedGovernor
CodeSandwich Mar 27, 2024
305d42a
Switch BridgedGovernor script from Mumbai to BSC testnet
CodeSandwich Jun 17, 2024
6a7b6c6
Switch BridgedGovernor to nonces and values encoded in messages
CodeSandwich Jun 17, 2024
7ae9949
Add BridgedGovernor documentation
CodeSandwich Jun 17, 2024
0d41212
Make GiversRegistry initialize automatically
CodeSandwich Jun 15, 2024
0937f61
Make Giver native token wrapper configurable
CodeSandwich Jun 17, 2024
d23652b
Add initialization to ManagedProxy
CodeSandwich Jul 18, 2024
357da78
Switch RepoDriver to Gelato
CodeSandwich Jul 18, 2024
c16db84
Add requestUpdateOwner request limit
CodeSandwich Aug 2, 2024
6b88651
Remove support for stuck Gelato transactions
CodeSandwich Aug 6, 2024
044bc35
Fix deployment after Gelato migration
CodeSandwich Aug 12, 2024
2f101e0
Refactor BridgedGovernor to enable more bridge variants
CodeSandwich Aug 20, 2024
d080e51
Add AxelarBridgedGovernor
CodeSandwich Aug 19, 2024
f3d7e6f
Fix BridgedGovernor issues found in the audit
CodeSandwich Sep 4, 2024
a92ea84
Refactor Giver to use IWrappedNativeToken
CodeSandwich Aug 28, 2024
6bc96df
Add NativeTokenUnwrapper
CodeSandwich Aug 28, 2024
f1bb35c
Add setting NFT URI
CodeSandwich Sep 3, 2024
3ff58c3
Add GelatoTasksOwner
CodeSandwich Sep 26, 2024
563dd96
Switch GovernorProxy to delegating to a Governor
CodeSandwich Sep 25, 2024
3aeccb7
Add an Ethereum to Filecoin upgrade script
CodeSandwich Sep 25, 2024
e07aac7
Create a new deployment mechanism
CodeSandwich Sep 25, 2024
0f64afc
Add Filecoin deployment
CodeSandwich Oct 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
node_modules
/out
/cache
/broadcast
12 changes: 9 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
[submodule "lib/openzeppelin-contracts"]
path = lib/openzeppelin-contracts
url = https://github.com/OpenZeppelin/openzeppelin-contracts
[submodule "lib/chainlink"]
path = lib/chainlink
url = https://github.com/smartcontractkit/chainlink
[submodule "lib/LayerZero-v2"]
path = lib/LayerZero-v2
url = https://github.com/LayerZero-Labs/LayerZero-v2
[submodule "lib/gelato-automate"]
path = lib/gelato-automate
url = https://github.com/gelatodigital/automate
[submodule "lib/axelar-gmp-sdk-solidity"]
path = lib/axelar-gmp-sdk-solidity
url = https://github.com/axelarnetwork/axelar-gmp-sdk-solidity
16 changes: 16 additions & 0 deletions deployments/filecoin-test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"AddressDriver": "0xEFcd912a5a67C3a7Cc70a2Fb9aa17781bf1cE68F",
"Caller": "0x7f2457421718A541B9Ee01E2F77F8BA749055F3b",
"Deployer": "0xEF4B994f97092fD22B8a880c47F053910788471b",
"Drips": "0x0B71C2a08d27E86d3841A6772332DEde0bc8DCa5",
"Drips cycle seconds": 86400,
"DripsDeployer": "0x79f3e7Aa55D39bBD42de31677B715B2e4D6e8ab0",
"GiversRegistry": "0x1F83E99813941a9bd701342560BFFaC794D707d1",
"ImmutableSplitsDriver": "0x990806c7EFC1C26be162a46F821ca281618F28AA",
"LZBridgedGovernor": "0x6bC5C5D7dA80dC1c30677852ce9AA01df368E76f",
"NFTDriver": "0x1397579E87AB255C8474907183B074947eBa7338",
"NativeTokenUnwrapper": "0x8A388BE3fb93C28b66365DCbf3eAc344690BD1C4",
"RepoDriver": "0xf3aE6ADDeEE195e91380F5F9Ce73698460BAdf79",
"RepoDriver tasks owner": "0x6D3A0fAE4FBa0f543b9e3280E85F4e4f59ba3D54",
"Salt": "test5"
}
17 changes: 17 additions & 0 deletions deployments/filecoin.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"AddressDriver": "0x04693D13826a37dDdF973Be4275546Ad978cb9EE",
"AxelarBridgedGovernor": "0xE9B15C572EB7Ba2E2856cc5eFaAb8fe1d0e34116",
"Caller": "0xd6Ab8e72dE3742d45AdF108fAa112Cd232718828",
"Chain ID": 314,
"Deployer": "0x7dCaCF417BA662840DcD2A35b67f55911815dD7e",
"Drips": "0xd320F59F109c618b19707ea5C5F068020eA333B3",
"Drips cycle seconds": 86400,
"GiversRegistry": "0x42c8b3dac5144511fc9Ae11D4Bc9cfF33dd88eAe",
"ImmutableSplitsDriver": "0x96EC722e1338f08bbd469b80394eE118a0bc6753",
"ModulesDeployer": "0xB1d6865994c16c12288e7DE36a3457e8a04be8E2",
"NFTDriver": "0x2F23217A87cAf04ae586eed7a3d689f6C48498dB",
"NativeTokenUnwrapper": "0x64e0d60C70e9778C2E649FfBc90259C86a6Bf396",
"RepoDriver": "0xe75f56B26857cAe06b455Bfc9481593Ae0FB4257",
"RepoDriver tasks owner": "0x6691F8fAaB86B023f09801D24E808344BEC1D314",
"Salt": "DripsV2Final"
}
1 change: 1 addition & 0 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ evm_version = 'shanghai'
optimizer_runs = 7_700
verbosity = 1
fuzz_runs = 5
fs_permissions = [{ access = "read-write", path = "./"}]
[fmt]
line_length = 100
[fuzz]
Expand Down
1 change: 1 addition & 0 deletions lib/LayerZero-v2
Submodule LayerZero-v2 added at 142846
1 change: 1 addition & 0 deletions lib/axelar-gmp-sdk-solidity
1 change: 0 additions & 1 deletion lib/chainlink
Submodule chainlink deleted from 594387
2 changes: 1 addition & 1 deletion lib/forge-std
1 change: 1 addition & 0 deletions lib/gelato-automate
Submodule gelato-automate added at ae1cac
4 changes: 3 additions & 1 deletion remappings.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
ds-test/=lib/forge-std/lib/ds-test/src/
forge-std/=lib/forge-std/src/
openzeppelin-contracts/=lib/openzeppelin-contracts/contracts/
chainlink/=lib/chainlink/contracts/src/v0.8/
layer-zero-v2/=lib/LayerZero-v2/
gelato-automate/=lib/gelato-automate/contracts/
axelar/=lib/axelar-gmp-sdk-solidity/contracts/
148 changes: 148 additions & 0 deletions script/DeployAxelarBridgedGovernor.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
// SPDX-License-Identifier: GPL-3.0-only
pragma solidity ^0.8.20;

import {console, Script} from "forge-std/Script.sol";
import {AxelarBridgedGovernor, GovernorProxy, Call} from "src/BridgedGovernor.sol";
import {UUPSUpgradeable} from "src/Managed.sol";
import {IAxelarGasService} from "axelar/interfaces/IAxelarGasService.sol";
import {IAxelarGMPGateway} from "axelar/interfaces/IAxelarGMPGateway.sol";
import {AddressToString} from "axelar/libs/AddressString.sol";

string constant SEPOLIA_CHAIN_NAME = "ethereum-sepolia";
string constant BSC_TESTNET_CHAIN_NAME = "binance";

IAxelarGMPGateway constant SEPOLIA_GATEWAY =
IAxelarGMPGateway(0xe432150cce91c13a887f7D836923d5597adD8E31);
IAxelarGasService constant BSC_TESTNET_GAS_SERVICE =
IAxelarGasService(0xbE406F0189A0B4cf3A05C286473D23791Dd44Cc6);
IAxelarGMPGateway constant BSC_TESTNET_GATEWAY =
IAxelarGMPGateway(0x4D147dCb984e6affEEC47e44293DA442580A3Ec0);

// forge script scripts/DeployAxelarBridgedGovernor.s.sol:DeployToBscTestnet $WALLET_ARGS -f "$ETH_RPC_URL"

// contract DeployToBscTestnet is Script {
// function run() public {
// address owner = vm.envOr("OWNER", msg.sender);

// require(block.chainid == 97, "Must be run on BSC testnet");
// vm.startBroadcast();
// AxelarBridgedGovernor logic =
// new AxelarBridgedGovernor(BSC_TESTNET_GATEWAY, SEPOLIA_CHAIN_NAME, owner);
// GovernorProxy governor = new GovernorProxy(address(logic), new Call[](0));
// vm.stopBroadcast();
// console.log("Deployed AxelarBridgedGovernor:", address(governor));
// }
// }

// Gateway and ddresses taken from https://docs.axelar.dev/resources/contract-addresses/testnet

// Run on BSC testnet
// forge create $WALLET_ARGS scripts/DeployAxelarBridgedGovernor.s.sol:ContractCaller \
// --constructor-args 0x4D147dCb984e6affEEC47e44293DA442580A3Ec0 0xbE406F0189A0B4cf3A05C286473D23791Dd44Cc6

// Run on Sepolia
// OWNER=0xdACfE6Bf5A06953EccC3755758C5aDFfed94e147 \
// GATEWAY=0xe432150cce91c13a887f7D836923d5597adD8E31 \
// SOURCE_CHAIN=binance \
// forge script scripts/DeployAxelarBridgedGovernor.s.sol:DeployGovernor $WALLET_ARGS -f "$ETH_RPC_URL"

// Run on BSC testnet
// cast send $WALLET_ARGS 0xdACfE6Bf5A06953EccC3755758C5aDFfed94e147 \
// 'setRecipient(string,address)' ethereum-sepolia 0x78EeC20c86e5f40Ceb1b651c38072DF528AE6407

// Run on BSC testnet
// CALLER=0xdACfE6Bf5A06953EccC3755758C5aDFfed94e147 \
// FEE=$(cast to-wei 0.00 eth) \
// NONCE=2 \
// forge script scripts/DeployAxelarBridgedGovernor.s.sol:ContractCall $WALLET_ARGS -f "$ETH_RPC_URL"

contract DeployGovernor is Script {
function run() public {
address owner = vm.envOr("OWNER", msg.sender);
IAxelarGMPGateway gateway = IAxelarGMPGateway(vm.envAddress("GATEWAY"));
string memory sourceChain = vm.envString("SOURCE_CHAIN");

vm.startBroadcast();
AxelarBridgedGovernor logic = new AxelarBridgedGovernor(gateway, sourceChain, owner);
GovernorProxy governor = new GovernorProxy(logic, new Call[](0));
vm.stopBroadcast();
console.log("Deployed AxelarBridgedGovernor:", address(governor));
}
}

contract ContractCaller {
address public immutable owner;
IAxelarGMPGateway public immutable gateway;
IAxelarGasService public immutable gasService;

string public destinationChain;
address public recipient;

constructor(IAxelarGMPGateway gateway_, IAxelarGasService gasService_) {
owner = msg.sender;
gateway = gateway_;
gasService = gasService_;
}

function setRecipient(string calldata destinationChain_, address recipient_) public {
require(msg.sender == owner, "Only owner");
destinationChain = destinationChain_;
recipient = recipient_;
}

function callContract(bytes calldata payload) public payable {
require(msg.sender == owner, "Only owner");
string memory recipient_ = AddressToString.toString(recipient);
if (msg.value > 0) {
gasService.payNativeGasForContractCall{value: msg.value}(
address(this), destinationChain, recipient_, payload, owner
);
}
gateway.callContract(destinationChain, recipient_, payload);
}
}

contract ContractCall is Script {
function run() public {
ContractCaller caller = ContractCaller(vm.envAddress("CALLER"));
uint256 fee = vm.envOr("FEE", uint256(0));
uint256 nonce = vm.envUint("NONCE");

Call[] memory calls = new Call[](1);
calls[0] = Call({
target: 0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14,
data: abi.encodeWithSignature("approve(address,uint256)", address(0x1234), 100 + nonce),
value: 0
});
// calls[0] = Call({
// target: 0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14,
// data: abi.encodeWithSignature("transferFrom(address,address,uint256)",
// msg.sender, address(0xdead), 1234),
// value: 0
// });

vm.broadcast();
caller.callContract{value: fee}(abi.encode(AxelarBridgedGovernor.Message(nonce, calls)));
}
}

contract CallUpgrade is Script {
function run() public {
require(block.chainid == 1, "Must be run on Ethereum");
require(msg.sender == 0xEF4B994f97092fD22B8a880c47F053910788471b, "Invalid sender");
uint256 nonce = 0;
Call[] memory calls = new Call[](1);
calls[0] = Call({
target: 0x186a0C0e2208df6073285cdCf20d8787fba8e302,
data: abi.encodeCall(
UUPSUpgradeable.upgradeTo, (0x6bEF578F8B86061f155761f700751Af3013751f6)
),
value: 0
});
bytes memory payload = abi.encode(AxelarBridgedGovernor.Message(nonce, calls));
vm.broadcast();
IAxelarGMPGateway(0x4F4495243837681061C4743b74B3eEdf548D56A5).callContract(
"filecoin", "0x3263D62B54D62F3d051736285DB4889D9E32C02b", payload
);
}
}
Loading
Loading