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

build: 303 deployments #59

Merged
merged 12 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ jobs:
with:
submodules: recursive

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'

- name: Install Vyper
run: pip install vyper==0.3.7

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ out/
!/broadcast
/broadcast/*/31337/
/broadcast/**/dry-run/
/broadcast/

# Docs
docs/
Expand Down
3 changes: 2 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ venv/
venv/
lib/
out/
cache/
cache/
broadcast/
26 changes: 11 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,22 @@

- First you will need to install [Foundry](https://book.getfoundry.sh/getting-started/installation).
NOTE: If you are on a windows machine it is recommended to use [WSL](https://learn.microsoft.com/en-us/windows/wsl/install)
- Install [Node.js](https://nodejs.org/en/download/package-manager/)

### Fork this repository

git clone https://github.com/yearn/vault-periphery
```sh
git clone --recursive https://github.com/yearn/vault-periphery

cd vault-periphery
cd vault-periphery


### Deployment
pip install vyper==0.3.7

make build

Deployment of periphery contracts such as the [Registry Factory](https://github.com/yearn/vault-periphery/blob/master/contracts/registry/RegistryFactory.sol) or [Address Provider](https://github.com/yearn/vault-periphery/blob/master/contracts/AddressProvider.vy) are done using a create2 factory in order to get a deterministic address that is the same on each EVM chain.
make test
```
### Deployment

This can be done permissionlessly if the most recent contract has not yet been deployed on a chain you would like to use it on.
Deployment of periphery contracts are done using a create2 factory in order to get a deterministic address that is the same on each EVM chain.

1. [Add an Ape account](https://docs.apeworx.io/ape/stable/commands/accounts.html)
2. Run the deployment the contracts specific deployment script under `scripts/`
```sh
ape run scripts/deploy_contract_name.py --network YOUR_RPC_URL
```
- For chains that don't support 1559 tx's you may need to add a `type="0x0"` argument at the end of the deployment tx.
- ie `tx = deployer_contract.deployCreate2(salt, init_code, sender=deployer, type="0x0")`
3. The address the contract was deployed at will print in the console and should match any other chain the same version has been deployed on.
This can be done permissionlessly if the most recent contract has not yet been deployed on a chain you would like to use it on using this repo https://github.com/wavey0x/yearn-v3-deployer
2 changes: 1 addition & 1 deletion lib/forge-std
Submodule forge-std updated 5 files
+181 −0 CONTRIBUTING.md
+16 −0 README.md
+12 −1 scripts/vm.py
+106 −16 src/Vm.sol
+2 −2 test/Vm.t.sol
41 changes: 41 additions & 0 deletions scripts/Deploy.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// SPDX-License-Identifier: AGPL-3.0
pragma solidity >=0.8.18;

import "forge-std/Script.sol";

// Deploy a contract to a deterministic address with create2 factory.
contract Deploy is Script {
// Create X address.
Deployer public deployer =
Deployer(0xba5Ed099633D3B313e4D5F7bdc1305d3c28ba5Ed);

address public initGov = 0x6f3cBE2ab3483EC4BA7B672fbdCa0E9B33F88db8;

function run() external {
vm.startBroadcast();

// Append constructor args to the bytecode
bytes memory bytecode = abi.encodePacked(
vm.getCode("registry/ReleaseRegistry.sol:ReleaseRegistry"),
abi.encode(initGov)
);

// Use salt of 0.
bytes32 salt;

address contractAddress = deployer.deployCreate2(salt, bytecode);

console.log("Address is ", contractAddress);

vm.stopBroadcast();
}
}

contract Deployer {
event ContractCreation(address indexed newContract, bytes32 indexed salt);

function deployCreate2(
bytes32 salt,
bytes memory initCode
) public payable returns (address newContract) {}
}
65 changes: 65 additions & 0 deletions scripts/DeployVyper.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
// SPDX-License-Identifier: AGPL-3.0
pragma solidity >=0.8.18;

import "forge-std/Script.sol";

///@notice This cheat codes interface is named _CheatCodes so you can use the CheatCodes interface in other testing files without errors
interface _CheatCodes {
function ffi(string[] calldata) external returns (bytes memory);
}

// Deploy a contract to a deterministic address with create2 factory.
contract DeployVyper is Script {
address constant HEVM_ADDRESS =
address(bytes20(uint160(uint256(keccak256("hevm cheat code")))));

/// @notice Initializes cheat codes in order to use ffi to compile Vyper contracts
_CheatCodes cheatCodes = _CheatCodes(HEVM_ADDRESS);

// Create X address.
Deployer public deployer =
Deployer(0xba5Ed099633D3B313e4D5F7bdc1305d3c28ba5Ed);

address public initGov = 0x6f3cBE2ab3483EC4BA7B672fbdCa0E9B33F88db8;

function run() external {
vm.startBroadcast();

///@notice compile the Vyper contract and return the bytecode
bytes memory bytecode = compileVyper(
"src/addressProviders/",
"ProtocolAddressProvider"
);

bytecode = abi.encodePacked(bytecode, abi.encode(initGov));

// Use salt of 0.
bytes32 salt;

address contractAddress = deployer.deployCreate2(salt, bytecode);

console.log("Address is ", contractAddress);

vm.stopBroadcast();
}

function compileVyper(
string memory path,
string memory fileName
) public returns (bytes memory) {
string[] memory cmds = new string[](2);
cmds[0] = "vyper";
cmds[1] = string.concat(path, fileName, ".vy");

return cheatCodes.ffi(cmds);
}
}

contract Deployer {
event ContractCreation(address indexed newContract, bytes32 indexed salt);

function deployCreate2(
bytes32 salt,
bytes memory initCode
) public payable returns (address newContract) {}
}
78 changes: 0 additions & 78 deletions scripts/deploy_accountant.py

This file was deleted.

35 changes: 0 additions & 35 deletions scripts/deploy_accountant_factory.py

This file was deleted.

41 changes: 0 additions & 41 deletions scripts/deploy_address_provider.py

This file was deleted.

43 changes: 0 additions & 43 deletions scripts/deploy_allocator_factory.py

This file was deleted.

Loading
Loading