-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bc82294
commit 411ae5a
Showing
5 changed files
with
116 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ out/ | |
!/broadcast | ||
/broadcast/*/31337/ | ||
/broadcast/**/dry-run/ | ||
|
||
broadcast/ | ||
# Dotenv file | ||
.env | ||
|
||
|
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 |
---|---|---|
|
@@ -2,3 +2,6 @@ | |
src = 'src' | ||
out = 'out' | ||
libs = ['lib'] | ||
|
||
[rpc_endpoints] | ||
goerli = "${GOERLI_RPC_URL}" |
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,69 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity ^0.8.13; | ||
|
||
import "forge-std/Script.sol"; | ||
import "../src/HandlerV1.sol"; | ||
import "../src/EvmHost.sol"; | ||
import "../test/TestHost.sol"; | ||
import "../src/modules/CrossChainGovernor.sol"; | ||
import "../src/beefy/BeefyV1.sol"; | ||
|
||
contract DeployScript is Script { | ||
address public deployer = 0x4e59b44847b379578588920cA78FbF26c0B4956C; | ||
bytes32 public salt = 0xc023405e9aa0e9ea794732e4076a4f5baca75496cfc2179e94829661ba6396d8; | ||
address public admin = 0x123463a4B065722E99115D6c222f267d9cABb524; | ||
uint256 public paraId = 2021; | ||
|
||
function run() external { | ||
uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY"); | ||
vm.startBroadcast(deployerPrivateKey); | ||
|
||
BeefyV1 c = new BeefyV1{salt: salt}(paraId); | ||
address consensusClient = getAddress(type(BeefyV1).creationCode, abi.encode(paraId)); | ||
console.logAddress(consensusClient); | ||
assert(consensusClient == address(c)); | ||
|
||
HandlerV1 hv1 = new HandlerV1{salt: salt}(); | ||
address handler = getAddress(type(HandlerV1).creationCode, new bytes(0)); | ||
console.logAddress(handler); | ||
assert(handler == address(hv1)); | ||
|
||
GovernorParams memory gParams = GovernorParams(admin, address(0), paraId); | ||
CrossChainGovernor g = new CrossChainGovernor{salt: salt}(gParams); | ||
address governor = getAddress(type(CrossChainGovernor).creationCode, abi.encode(gParams)); | ||
console.logAddress(governor); | ||
assert(governor == address(g)); | ||
|
||
HostParams memory params = HostParams({ | ||
admin: admin, | ||
crosschainGovernor: governor, | ||
handler: handler, | ||
defaultTimeout: 5000, | ||
unStakingPeriod: 5000, | ||
// for this test | ||
challengePeriod: 0, | ||
consensusClient: consensusClient, | ||
lastUpdated: 0, | ||
consensusState: new bytes(0) | ||
}); | ||
TestHost h = new TestHost{salt: salt}(params); | ||
address host = getAddress(type(TestHost).creationCode, abi.encode(params)); | ||
console.logAddress(host); | ||
assert(host == address(h)); | ||
|
||
// set the ismphost on the cross-chain governor | ||
g.setIsmpHost(host); | ||
|
||
vm.stopBroadcast(); | ||
} | ||
|
||
function getAddress(bytes memory code, bytes memory init) public returns (address) { | ||
return address( | ||
uint160( | ||
uint256( | ||
keccak256(abi.encodePacked(bytes1(0xff), deployer, salt, keccak256(abi.encodePacked(code, init)))) | ||
) | ||
) | ||
); | ||
} | ||
} |
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,19 @@ | ||
# How to deploy | ||
|
||
Ensure you have a local beacon chain testnet running, see [polytope-labs/eth-pos-devnet](https://github.com/polytope-labs/eth-pos-devnet). | ||
|
||
Fill out an `.env` file at the root of this repo with the given contents. | ||
|
||
```dotenv | ||
GOERLI_RPC_URL=ws://127.0.0.1:8545 | ||
PRIVATE_KEY=2e0834786285daccd064ca17f1654f67b4aef298acbb82cef9ec422fb4975622 | ||
ETHERSCAN_API_KEY= | ||
``` | ||
|
||
The given private key is for the prefunded `0x123463a4B065722E99115D6c222f267d9cABb524` account in the devnet. | ||
|
||
Run the command below to deploy | ||
|
||
```shell | ||
forge script script/Deploy.s.sol:DeployScript --rpc-url http://127.0.0.1:8545 --broadcast --sender=0x123463a4b065722e99115d6c222f267d9cabb524 | ||
``` |
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