beamer icon indicating copy to clipboard operation
beamer copied to clipboard

Rework deployment infrastructure

Open fredo opened this issue 2 years ago • 10 comments

We need to make it easy to deploy Beamer contracts on new chains, or redeploy on chains where a deployment already exists. To that end, a split approach like the following may prove useful.

New deployment directory structure

The new deployments directory structure would look like this:

deployments/                         
├── config                           
│   └── mainnet
│       └── rpc.json
│       └── 288-boba.json                
│       └── 10-optimism.json            
│   └── goerli
│       └── rpc.json
│       └── 2888-boba.json                
│       └── 599-metis.json               
├── artifacts                           
│   └── mainnet                      
│       └── base.deployment.json   
│       └── 288-boba.deployment.json     
│       └── 10-optimism.deployment.json 
│   └── goerli                      
│       └── base.deployment.json   
│       └── 2888-boba.deployment.json     

The config dir is where all the deployment config files are stored, organized per layer1 chain. The artifacts dir is where all the deployment artifacts are stored, again, organized per layer1 chain.

Note the absence of contract ABI files. The ABI files will be obtained by another script that reads deployment file(s) and outputs ABI files. For that reason, it is important that each .deployment.json file has a beamer_commit entry, e.g.

beamer_commit": "3fc75ed6e281309d9c504d9794874a7f6500a5fe",

The deployment process

The overall deployment process can be split into 3 distinct actions, each available as a separate beamer command:

* beamer <command> Description Inputs Outputs Affected chains
1 deploy-base deploy Resolver rpc.json base.deployment.json L1
2 deploy deploy chain-specific contracts and set up trusted call chain rpc.json, base.deployment.json $chain.deployment.json L1, L2
3 configure configure contracts all configuration files, all deployment artifacts L2

Contract-related beamer commands

In command examples that follow, options --keystore-file, --password and --rpc-file have been omitted for brevity.

Note: in sections below, CHAIN refers to a concatenation of a chain ID and a human-readable name, {chain-id}-{name}. For example, 288-boba or 10-optimism.

beamer deploy-base --artifacts-dir ARTIFACTS_DIR CHAIN_ID

Deploy the Resolver contract on the base chain. The deployment information is written to $ARTIFACTS_DIR/base.deployment.json. Example:

beamer deploy-base --artifacts-dir deployments/artifacts/mainnet 1

beamer deploy --artifacts-dir ARTIFACTS_DIR CHAIN.json [CHAIN.json]...

Deploy L2 Beamer contracts on the specified chains and set up the trusted call chain.

The working of this command can be roughly described as follows. Preparation:

  • read $ARTIFACTS_DIR/base.deployment.json to get Resolver deployment info

For each given configuration file:

  • deploy all needed contracts on chain and write the deployment info to $ARTIFACTS_DIR/$CHAIN.deployment.json
  • deploy the chain-specific L1 messenger contract on the base chain and add the deployment info to $ARTIFACTS_DIR/base.deployment.json
  • set up the trusted call chain

Example:

beamer deploy --artifacts-dir deployments/artifacts/mainnet
       deployments/config/mainnet/288-boba.json
       deployments/config/mainnet/10-optimism.json

The above example will produce:

  deployments/artifacts/mainnet/288-boba.deployment.json
  deployments/artifacts/mainnet/10-optimism.deployment.json

beamer configure --config-dir CONFDIR CHAIN.deployment.json [CHAIN.deployment.json]...

Configure contract data specified by the config file(s). The working of this command can be roughly described as follows.

For each given deployment file CHAIN.deployment.json:

  • for each X.json in CONFDIR:
    • if X == CHAIN, do nothing;
    • otherwise:
    • read configuration from $CONFDIR/X.json
    • update appropriate contract data of X in CHAIN

Example:

beamer configure --config-dir deployments/config/mainnet
       deployments/artifacts/mainnet/288-boba.deployment.json
       deployments/artifacts/mainnet/10-optimism.deployment.json

fredo avatar Jun 20 '22 10:06 fredo