Skip to content

Commit

Permalink
Merge branch 'deneb-improve-makefile' into deneb
Browse files Browse the repository at this point in the history
  • Loading branch information
anti-ckp committed Aug 29, 2023
2 parents b565ec4 + af7ee92 commit ac667d4
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 49 deletions.
20 changes: 14 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
.PHONY: clean

REPO_DIR := $(abspath $(dir $(lastword $(MAKEFILE_LIST))))

log_level ?= "info"
# Build ethereum-testnet-bootstrapper image
build-bootstrapper:
Expand Down Expand Up @@ -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:
docker run -v $(shell pwd)/:/source/ -v $(shell pwd)/data/:/data ethereum-testnet-bootstrapper --clean --log-level $(log_level)
3 changes: 2 additions & 1 deletion bootstrapper.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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" ]
44 changes: 2 additions & 42 deletions src/testnet_bootstrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -535,25 +507,13 @@ 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":
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.")

0 comments on commit ac667d4

Please sign in to comment.