Skip to content

Commit

Permalink
deploy config defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
trajan0x committed Sep 2, 2023
1 parent 396c6e7 commit 969a6cd
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 13 deletions.
6 changes: 6 additions & 0 deletions contrib/devnet/internal/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,16 @@ func deployContracts(ctx context.Context, info devnetInfo) error {

forgeEnv := append(os.Environ(), fmt.Sprintf("MESSAGING_DEPLOYER_PRIVATE_KEY=%s", deployer.PrivateKeyHex()))
fmt.Println(deployer.PrivateKeyHex())
fmt.Println(deployer.Address())
_ = forgeEnv

// do this next. TODO: a clean command should clean out everything in contracts-core/deployments/chain_a, contracts-core/deployments/chain_b, and contracts-core/deployments/chain_c
// forge script script/DeployCREATE3.sol --ffi -f chain_a --private-key 63e21d10fd50155dbba0e7d3f7431a400b84b4c2ac1ee38872f82448fe3ecfb9 --broadcast

// devnet is dependent on configs being in a different path specified by DEPLOY_CONFIG_PATH
// should be set on line 136

// note: for now summit must be chain_a (chain id *must be 10*) because of hardcoded constants

return nil
}
2 changes: 1 addition & 1 deletion docker/devnet/config/omnirpc.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
chains:
42:
10:
rpcs:
- http://chain_a:8545/
confirmations: 1
Expand Down
2 changes: 1 addition & 1 deletion docker/devnet/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ services:
entrypoint: anvil
command: >
--host=0.0.0.0
--chain-id=42
--chain-id=10
--allow-origin="*"
--steps-tracing
--mnemonic="tag volcano eight thank tide danger coast health above argue embrace heavy"
Expand Down
5 changes: 3 additions & 2 deletions packages/contracts-core/foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,14 @@ number_underscore = 'thousands'

[rpc_endpoints]
avalanche = "${RPC_AVALANCHE}"
optimism = "${RPC_OPTIMISM}"
# needs to be commented out in order for deployments not be reused when using chain_a
#optimism = "${RPC_OPTIMISM}"
polygon = "${RPC_POLYGON}"
arb_goerli = "${RPC_ARB_GOERLI}"
op_goerli = "${RPC_OP_GOERLI}"
sepolia = "${RPC_SEPOLIA}"
# devnet chains
chain_a = "http://localhost:9001/rpc/42"
chain_a = "http://localhost:9001/rpc/10"
chain_b = "http://localhost:9001/rpc/43"
chain_c = "http://localhost:9001/rpc/44"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ contract DeployMessaging003SynChainScript is DeployMessaging003BaseScript {
agentRootConfig.serialize("initialAgentRoot", agentRoot);
agentRootConfig = agentRootConfig.serialize("proofs", proofsJson);
string memory path = globalDeployConfigPath("Messaging003AgentRoot");
console.log(path);
agentRootConfig.write(path);
}

Expand Down
10 changes: 10 additions & 0 deletions packages/contracts-core/script/devnet-configs/Messaging003.dc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"agents": {
"0": ["0x2321A2271ebCdCE886cF6F8022D29b54e9e40e17"],
"137": ["0xFA68368bEaB2CbF134a481BD6FdCe6113e1D45f8"],
"43114": ["0x2d815594a1425f9d342E27b2B41d250251c51B86"]
},
"chainidSummit": 10,
"domains": [0, 137, 43114],
"owner": "0xC49926C4124cEe1cbA0Ea94Ea31a6c12318df947"
}
18 changes: 9 additions & 9 deletions packages/contracts-core/script/utils/DeployerUtils.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ contract DeployerUtils is Script {
/// @dev Path to artifacts, deployments and configs directories
string private constant ARTIFACTS = "artifacts/";
string private constant DEPLOYMENTS = "deployments/";
string private constant DEPLOY_CONFIGS = "script/configs/";
string private constant DEFAULT_DEPLOY_CONFIGS = "script/configs/";

/// @dev Whether the script will be broadcasted or not
bool internal isBroadcasted = false;
Expand Down Expand Up @@ -56,7 +56,7 @@ contract DeployerUtils is Script {
}

function setupDevnetChains() public {
setChain("chain_a", Chain("chain_a", 42, "chain_a", "http://localhost:9001/rpc/42"));
setChain("chain_a", Chain("chain_a", 10, "chain_a", "http://localhost:9001/rpc/10"));
setChain("chain_b", Chain("chain_b", 43, "chain_b", "http://localhost:9001/rpc/43"));
setChain("chain_c", Chain("chain_c", 44, "chain_c", "http://localhost:9001/rpc/44"));
}
Expand Down Expand Up @@ -210,7 +210,7 @@ contract DeployerUtils is Script {

/// @notice Loads deploy config for a given contract on the current chain.
/// Will revert if config doesn't exist.
function loadDeployConfig(string memory contractName) public view returns (string memory json) {
function loadDeployConfig(string memory contractName) public returns (string memory json) {
return vm.readFile(deployConfigPath(contractName));
}

Expand All @@ -225,7 +225,7 @@ contract DeployerUtils is Script {

/// @notice Loads deploy config for a given contract on the current chain.
/// Will revert if config doesn't exist.
function loadGlobalDeployConfig(string memory contractName) public view returns (string memory json) {
function loadGlobalDeployConfig(string memory contractName) public returns (string memory json) {
return vm.readFile(globalDeployConfigPath(contractName));
}

Expand All @@ -248,19 +248,19 @@ contract DeployerUtils is Script {
}

/// @notice Returns deploy config filename for the contract.
function deployConfigFn(string memory contractName) public pure returns (string memory path) {
function deployConfigFn(string memory contractName) public returns (string memory path) {
return string.concat(contractName, ".dc.json");
}

/// @notice Returns path to the contract deploy config JSON on the current chain.
function deployConfigPath(string memory contractName) public view returns (string memory path) {
function deployConfigPath(string memory contractName) public returns (string memory path) {
require(bytes(chainAlias).length != 0, "Chain not set");
return string.concat(DEPLOY_CONFIGS, chainAlias, "/", deployConfigFn(contractName));
return string.concat(vm.envOr("DEPLOY_CONFIG_PATH", DEFAULT_DEPLOY_CONFIGS), chainAlias, "/", deployConfigFn(contractName));
}

/// @notice Returns path to the global contract deploy config JSON.
function globalDeployConfigPath(string memory contractName) public pure returns (string memory path) {
return string.concat(DEPLOY_CONFIGS, deployConfigFn(contractName));
function globalDeployConfigPath(string memory contractName) public returns (string memory path) {
return string.concat(vm.envOr("DEPLOY_CONFIG_PATH", DEFAULT_DEPLOY_CONFIGS), deployConfigFn(contractName));
}

/// @notice Create directory if it not exists already
Expand Down

0 comments on commit 969a6cd

Please sign in to comment.