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

Scope deployment outputs, logs, dbs by deployment + make things work on testnets #86

Merged
merged 17 commits into from
Dec 22, 2023
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
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ __pycache__

# Build & runtime outputs
/bin
/db
/deployments
/logs

# Private configuration
/.env
Expand Down
12 changes: 5 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ always for your permission before installing anything outside the current direct
## Usage

```
usage: rollop [--name NAME] [--preset {dev,prod}] [--config CONFIG_PATH] [--clean] [--trace] [--no-ansi-esc] [--yes] <command> ...
usage: rollop [--name NAME] [--preset {dev,prod}] [--config CONFIG_PATH] [--clean] [--no-ansi-esc] [--yes] <command> ...

Helps you spin up an op-stack rollup.
Use `rollop <command> --help` to get more detailed help for a command.
Expand All @@ -66,7 +66,6 @@ options:
--preset {dev,prod} use a preset rollup configuration
--config CONFIG_PATH path to the config file
--clean clean command-related output before running the specified command
--trace display exception stack trace in case of failure
--no-ansi-esc disable ANSI escape codes for terminal manipulation
--yes answer yes to all prompts (install all requested dependencies)

Expand Down Expand Up @@ -95,9 +94,8 @@ commands:

-- CLEANUP --

clean-build cleans up build outputs (but not deployment outputs or databases)
clean-l1 cleans up deployment outputs & databases for L1, deploy config is preserved
clean-l2 cleans up deployment outputs & databases for L2, deploy config is preserved
clean-build cleans up build outputs (but not deployment outputs)
clean-l2 cleans up L2 deployment outputs
clean-aa cleans up deployment outputs for account abstraction
clean-explorer deletes the block explorer databases, logs, and containers
```
Expand Down Expand Up @@ -161,5 +159,5 @@ make fix && make check
- Blockscout will show an indexing warning on the page. The indexing percentage only goes down with
time, but restarting the explorer makes it jump up. Regardless, the explorer seems to work just
fine.
- When running the devnet, the deployment of the contracts to the temporary L1 will hang. Just abort
and restart the command.
- When running the devnet, the deployment of the contracts to the temporary L1 might hang.
In that case, just abort and restart the command.
38 changes: 27 additions & 11 deletions account_abstraction.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def is_setup():

# --------------------------------------------------------------------------------------------------

def setup():
def setup(config: Config):
"""
Sets up all components necessary to run the account abstraction setup (cloning directories,
building & installing sfotware).
Expand All @@ -45,7 +45,7 @@ def setup():
deps.check_or_install_node()
deps.check_or_install_yarn()

log_file = "logs/build_aa_contracts.log"
log_file = f"{config.logs_dir}/build_aa_contracts.log"
print(f"Building account abstraction contracts. Logging to {log_file}")

lib.run_roll_log(
Expand All @@ -59,7 +59,7 @@ def setup():
github_url = "github.com/stackup-wallet/stackup-bundler"
version = "v0.6.21"

log_file = "logs/install_bundler.log"
log_file = f"{config.logs_dir}/install_bundler.log"
print(f"Installing stackup bundler. Logging to {log_file}")

env = {**os.environ, "GOBIN": os.path.abspath("bin")}
Expand All @@ -72,7 +72,7 @@ def setup():

# === build paymaster dependencies ===

log_file = "logs/build_paymaster.log"
log_file = f"{config.logs_dir}/build_paymaster.log"
print(f"Building paymaster dependencies. {log_file}")
lib.run_roll_log(
"build paymaster dependencies",
Expand All @@ -93,7 +93,7 @@ def deploy(config: Config):
"PAYMASTER_PRIVATE_KEY": config.paymaster_key,
"RPC_URL": config.l2_engine_rpc_url}

log_file = f"logs/{config.deploy_aa_log_file_name}"
log_file = os.path.join(config.logs_dir, config.deploy_aa_log_file_name)
print(f"Deploying account abstraction contracts. Logging to {log_file}")

lib.run_roll_log(
Expand Down Expand Up @@ -130,7 +130,7 @@ def start_bundler(config: Config):
"ERC4337_BUNDLER_ETH_CLIENT_URL": config.l2_engine_rpc_url,
"ERC4337_BUNDLER_PRIVATE_KEY": bundler_key}

log_file_path = "logs/stackup_bundler.log"
log_file_path = f"{config.logs_dir}/stackup_bundler.log"
log_file = open(log_file_path, "w")
print(f"Starting the stackup bundler. Logging to {log_file_path}.")

Expand Down Expand Up @@ -160,7 +160,7 @@ def start_paymaster(config: Config):

paymaster_address = lib.run(
"parsing paymaster address",
f"grep '==VerifyingPaymaster addr=' logs/{config.deploy_aa_log_file_name}"
f"grep '==VerifyingPaymaster addr=' {config.logs_dir}/{config.deploy_aa_log_file_name}"
).strip().split(' ')[-1]

env = {**os.environ,
Expand All @@ -173,7 +173,7 @@ def start_paymaster(config: Config):
"PRIVATE_KEY": config.paymaster_key}

# start paymaster signer service
log_file_path = "logs/paymaster_signer.log"
log_file_path = f"{config.logs_dir}/paymaster_signer.log"
log_file = open(log_file_path, "w")
print(f"Starting paymaster signer service. Logging to {log_file_path}")

Expand All @@ -188,11 +188,27 @@ def start_paymaster(config: Config):

####################################################################################################

def clean():
def clean(config: Config):
"""
Deletes the account abstraction deployment artifacts.
Deletes the account abstraction deployment outputs and build logs.
"""
shutil.rmtree("account-abstraction/deployments/opstack", ignore_errors=True)
paths = [
os.path.join(config.logs_dir, "build_aa_contracts.log"),
os.path.join(config.logs_dir, "stackup_bundler.log"),
os.path.join(config.logs_dir, "install_bundler.log"),
os.path.join(config.logs_dir, "build_paymaster.log"),
os.path.join(config.logs_dir, config.deploy_aa_log_file_name),
os.path.join(config.logs_dir, "paymaster_signer.log")
]

for path in paths:
if os.path.exists(path):
lib.debug(f"Removing {path}")
os.remove(path)

path = "account-abstraction/deployments/opstack"
lib.debug(f"Removing {path}")
shutil.rmtree(path, ignore_errors=True)


####################################################################################################
15 changes: 3 additions & 12 deletions argparsing/argparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,18 +158,9 @@ def _build_parser(self):
prog=self.program_name,
description=self.description,
formatter_class=NewlineFormatter,
allow_abbrev=False,
add_help=False)

self.parser.add_argument(
# Suppressed via `add_help=False` but reintroduced here, undocumented.
"-h", "--help",
help=argparse.SUPPRESS,
default=False,
action="store_true",
dest="show_help")

self.parent_command_parser = argparse.ArgumentParser(add_help=False)
allow_abbrev=False)

# self.parent_command_parser = argparse.ArgumentParser(add_help=False)

self.subparsers = self.parser.add_subparsers(
title="commands",
Expand Down
29 changes: 18 additions & 11 deletions block_explorer.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def launch_blockscout(config: Config):
deps.check_docker()
setup_blockscout_repo()

log_file_name = "logs/launch_blockscout.log"
log_file_name = f"{config.logs_dir}/launch_blockscout.log"
log_file = open(log_file_name, "w")
print(f"Launching the blockscout block explorer. Logging to {log_file_name}\n"
"Explorer available at http://localhost/ in a little bit.")
Expand Down Expand Up @@ -133,19 +133,26 @@ def edit_backend_config(backend_config: dict):

####################################################################################################

def clean():
def clean(config: Config):
"""
Deletes the block explorer databases, logs, and containers.
"""
print("Cleaning up block explorer databases, logs, and containers...")
shutil.rmtree(
"blockscout/docker-compose/services/blockscout-db-data", ignore_errors=True)
shutil.rmtree(
"blockscout/docker-compose/services/logs", ignore_errors=True)
shutil.rmtree(
"blockscout/docker-compose/services/redis-data", ignore_errors=True)
shutil.rmtree(
"blockscout/docker-compose/services/stats-db-data", ignore_errors=True)

dir_paths = [
"blockscout/docker-compose/services/blockscout-db-data",
"blockscout/docker-compose/services/logs",
"blockscout/docker-compose/services/redis-data",
"blockscout/docker-compose/services/stats-db-data",
]

for path in dir_paths:
lib.debug(f"Removing {path}")
shutil.rmtree(path, ignore_errors=True)

path = os.path.join(config.logs_dir, "launch_blockscout.log")
if os.path.exists(path):
lib.debug(f"Removing {path}")
os.remove(path)

lib.run("remove blockscout containers",
f"docker compose --project-name {_COMPOSE_PROJECT_NAME} rm --stop --force")
Expand Down
Loading