From 8342f0d699c0b2c519a567db37b6617d7ab9fb8b Mon Sep 17 00:00:00 2001 From: Cameron Pinnegar Date: Fri, 25 Aug 2023 12:02:50 +0100 Subject: [PATCH 1/2] simplify make clean --- Makefile | 2 +- src/testnet_bootstrapper.py | 32 -------------------------------- 2 files changed, 1 insertion(+), 33 deletions(-) diff --git a/Makefile b/Makefile index e1dc18fa..132d3ebc 100644 --- a/Makefile +++ b/Makefile @@ -40,4 +40,4 @@ run-bootstrapper: # remove last run. clean: - docker run -v $(shell pwd)/:/source/ -v $(shell pwd)/data/:/data ethereum-testnet-bootstrapper --clean --log-level $(log_level) + rm -rf docker-compose.yaml data/ diff --git a/src/testnet_bootstrapper.py b/src/testnet_bootstrapper.py index dc47fd61..19f6e303 100644 --- a/src/testnet_bootstrapper.py +++ b/src/testnet_bootstrapper.py @@ -74,26 +74,6 @@ class EthereumTestnetBootstrapper: def __init__(self): pass - def clean(self): - """Cleans up the testnet root directory and docker-compose file. - - @return: - """ - files_config = FilesConfig() - logging.info( - f"Cleaning up the testnet directories: {files_config.testnet_root}" - ) - docker_compose_file = files_config.docker_compose_file - if files_config.testnet_root.exists(): - for root, dirs, files in os.walk(files_config.testnet_root): - for file in files: - pathlib.Path(f"{root}/{file}").unlink() - for directory in dirs: - shutil.rmtree(f"{root}/{directory}") - - if docker_compose_file.exists(): - docker_compose_file.unlink() - def init_testnet(self, config_path: Path): """Initializes the testnet directory, 3 phases. @@ -495,14 +475,6 @@ def get_deposit_contract_deployment_block( help="Which config file to use to create a testnet.", ) - parser.add_argument( - "--clean", - dest="clean", - action="store_true", - default=False, - help="Clear the last run.", - ) - parser.add_argument( "--init-testnet", dest="init_testnet", @@ -535,10 +507,6 @@ def get_deposit_contract_deployment_block( etb = EthereumTestnetBootstrapper() - if args.clean: - etb.clean() - logging.debug("testnet_bootstrapper has finished cleaning up.") - if args.init_testnet: # make sure we are going from source. if args.config.split("/")[0] != "source": From af7ee9282647445f6173588dbdb747c59c650f1d Mon Sep 17 00:00:00 2001 From: Cameron Pinnegar Date: Fri, 25 Aug 2023 14:40:58 +0100 Subject: [PATCH 2/2] simplify makefile --- Makefile | 20 ++++++++++++++------ bootstrapper.Dockerfile | 3 ++- src/testnet_bootstrapper.py | 12 ++---------- 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/Makefile b/Makefile index 132d3ebc..91e780d9 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,7 @@ .PHONY: clean + +REPO_DIR := $(abspath $(dir $(lastword $(MAKEFILE_LIST)))) + log_level ?= "info" # Build ethereum-testnet-bootstrapper image build-bootstrapper: @@ -29,15 +32,20 @@ rebuild-client-images-inst: build-all-images: build-bootstrapper build-client-images build-config rebuild-all-images: rebuild-bootstrapper rebuild-client-images rebuild-config +# remove last run. +clean: + rm -rf docker-compose.yaml data/ + mkdir -p data # init the testnet dirs and all files needed to later bootstrap the testnet. -init-testnet: - docker run -v $(shell pwd)/:/source/ -v $(shell pwd)/data/:/data ethereum-testnet-bootstrapper --config $(config) --init-testnet --log-level $(log_level) +init-testnet: clean + docker run -v $(REPO_DIR)/:/source/ -v $(REPO_DIR)/data/:/data ethereum-testnet-bootstrapper --config $(config) --init-testnet --log-level $(log_level) + +# get an interactive shell into the testnet-bootstrapper +shell: + docker run --rm --entrypoint /bin/bash -it -v $(REPO_DIR)/:/source/ -v $(REPO_DIR)/data/:/data ethereum-testnet-bootstrapper # after an init this runs the bootstrapper and start up the testnet. run-bootstrapper: - docker run -it -v $(shell pwd)/:/source/ -v $(shell pwd)/data/:/data ethereum-testnet-bootstrapper --config $(config) --bootstrap-testnet --log-level $(log_level) + docker run -it -v $(REPO_DIR)/:/source/ -v $(REPO_DIR)/data/:/data ethereum-testnet-bootstrapper --config $(config) --bootstrap-testnet --log-level $(log_level) -# remove last run. -clean: - rm -rf docker-compose.yaml data/ diff --git a/bootstrapper.Dockerfile b/bootstrapper.Dockerfile index ab2b22f2..4126c60c 100644 --- a/bootstrapper.Dockerfile +++ b/bootstrapper.Dockerfile @@ -42,5 +42,6 @@ COPY --from=builder /go/bin/ethdo /usr/local/bin/ethdo RUN chmod +x /usr/local/bin/bootnode COPY ./ /source +WORKDIR /source -ENTRYPOINT [ "/source/entrypoint.sh" ] +ENTRYPOINT [ "./entrypoint.sh" ] diff --git a/src/testnet_bootstrapper.py b/src/testnet_bootstrapper.py index 19f6e303..8675f56d 100644 --- a/src/testnet_bootstrapper.py +++ b/src/testnet_bootstrapper.py @@ -508,20 +508,12 @@ def get_deposit_contract_deployment_block( etb = EthereumTestnetBootstrapper() if args.init_testnet: - # make sure we are going from source. - if args.config.split("/")[0] != "source": - logging.debug( - "prepending source to the config path in order to map in the config file." - ) - path_to_config = pathlib.Path(f"source/{args.config}") - else: - path_to_config = pathlib.Path(args.config) - + path_to_config = pathlib.Path(args.config) etb.init_testnet(path_to_config) logging.debug("testnet_bootstrapper has finished init-ing the testnet.") if args.bootstrap_testnet: # the config path lies in /source/data/etb-config.yaml - path_to_config = pathlib.Path("source/data/etb-config.yaml") + path_to_config = pathlib.Path("/source/data/etb-config.yaml") etb.bootstrap_testnet(path_to_config) logging.debug("testnet_bootstrapper has finished bootstrapping the testnet.")