Skip to content

Commit

Permalink
feat: update blockscout with new frontend (#843)
Browse files Browse the repository at this point in the history
Signed-off-by: Barnabas Busa <[email protected]>
  • Loading branch information
barnabasbusa authored Dec 3, 2024
1 parent 55df658 commit 4f69962
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 15 deletions.
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -637,11 +637,14 @@ additional_services:
# Configuration place for blockscout explorer - https://github.com/blockscout/blockscout
blockscout_params:
# blockscout docker image to use
# Defaults to blockscout/blockscout:6.8.0
image: "blockscout/blockscout:6.8.0"
# Defaults to blockscout/blockscout:latest
image: "blockscout/blockscout:latest"
# blockscout smart contract verifier image to use
# Defaults to ghcr.io/blockscout/smart-contract-verifier:v1.9.0
verif_image: "ghcr.io/blockscout/smart-contract-verifier:v1.9.0"
# Defaults to ghcr.io/blockscout/smart-contract-verifier:latest
verif_image: "ghcr.io/blockscout/smart-contract-verifier:latest"
# Frontend image
# Defaults to ghcr.io/blockscout/frontend:latest
frontend_image: "ghcr.io/blockscout/frontend:latest"

# Configuration place for dora the explorer - https://github.com/ethpandaops/dora
dora_params:
Expand Down
4 changes: 2 additions & 2 deletions main.star
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,6 @@ def run(plan, args={}):
plan.print("Successfully launched beacon metrics gazer")
elif additional_service == "blockscout":
plan.print("Launching blockscout")
blockscout_params = args_with_right_defaults.blockscout_params
blockscout_sc_verif_url = blockscout.launch_blockscout(
plan,
all_el_contexts,
Expand All @@ -517,7 +516,8 @@ def run(plan, args={}):
args_with_right_defaults.port_publisher,
index,
args_with_right_defaults.docker_cache_params,
blockscout_params,
args_with_right_defaults.blockscout_params,
network_params,
)
plan.print("Successfully launched blockscout")
elif additional_service == "dora":
Expand Down
71 changes: 64 additions & 7 deletions src/blockscout/blockscout_launcher.star
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ postgres = import_module("github.com/kurtosis-tech/postgres-package/main.star")
POSTGRES_IMAGE = "library/postgres:alpine"

SERVICE_NAME_BLOCKSCOUT = "blockscout"

SERVICE_NAME_FRONTEND = "blockscout-frontend"
HTTP_PORT_NUMBER = 4000
HTTP_PORT_NUMBER_VERIF = 8050

HTTP_PORT_NUMBER_FRONTEND = 3000
BLOCKSCOUT_MIN_CPU = 100
BLOCKSCOUT_MAX_CPU = 1000
BLOCKSCOUT_MIN_MEMORY = 1024
Expand All @@ -35,6 +35,14 @@ VERIF_USED_PORTS = {
)
}

FRONTEND_USED_PORTS = {
constants.HTTP_PORT_ID: shared_utils.new_port_spec(
HTTP_PORT_NUMBER_FRONTEND,
shared_utils.TCP_PROTOCOL,
shared_utils.HTTP_APPLICATION_PROTOCOL,
)
}


def launch_blockscout(
plan,
Expand All @@ -45,6 +53,7 @@ def launch_blockscout(
additional_service_index,
docker_cache_params,
blockscout_params,
network_params,
):
postgres_output = postgres.run(
plan,
Expand Down Expand Up @@ -93,6 +102,16 @@ def launch_blockscout(
blockscout_service.hostname, blockscout_service.ports["http"].number
)

config_frontend = get_config_frontend(
plan,
el_client_rpc_url,
docker_cache_params,
blockscout_params,
network_params,
global_node_selectors,
blockscout_service,
)
plan.add_service(SERVICE_NAME_FRONTEND, config_frontend)
return blockscout_url


Expand All @@ -110,11 +129,10 @@ def get_config_verif(
0,
)

IMAGE_NAME_BLOCKSCOUT_VERIF = blockscout_params.verif_image
return ServiceConfig(
image=shared_utils.docker_cache_image_calc(
docker_cache_params,
IMAGE_NAME_BLOCKSCOUT_VERIF,
blockscout_params.verif_image,
),
ports=VERIF_USED_PORTS,
public_ports=public_ports,
Expand Down Expand Up @@ -158,12 +176,10 @@ def get_config_backend(
1,
)

IMAGE_NAME_BLOCKSCOUT = blockscout_params.image

return ServiceConfig(
image=shared_utils.docker_cache_image_calc(
docker_cache_params,
IMAGE_NAME_BLOCKSCOUT,
blockscout_params.image,
),
ports=USED_PORTS,
public_ports=public_ports,
Expand Down Expand Up @@ -197,3 +213,44 @@ def get_config_backend(
max_memory=BLOCKSCOUT_MAX_MEMORY,
node_selectors=node_selectors,
)


def get_config_frontend(
plan,
el_client_rpc_url,
docker_cache_params,
blockscout_params,
network_params,
node_selectors,
blockscout_service,
):
return ServiceConfig(
image=shared_utils.docker_cache_image_calc(
docker_cache_params,
blockscout_params.frontend_image,
),
ports=FRONTEND_USED_PORTS,
env_vars={
"NEXT_PUBLIC_API_PROTOCOL": "http",
"NEXT_PUBLIC_API_WEBSOCKET_PROTOCOL": "ws",
"NEXT_PUBLIC_NETWORK_NAME": "Kurtosis",
"NEXT_PUBLIC_NETWORK_ID": network_params.network_id,
"NEXT_PUBLIC_NETWORK_RPC_URL": el_client_rpc_url,
"NEXT_PUBLIC_APP_HOST": "0.0.0.0",
"NEXT_PUBLIC_API_HOST": blockscout_service.ip_address
+ ":"
+ str(blockscout_service.ports["http"].number),
"NEXT_PUBLIC_AD_BANNER_PROVIDER": "none",
"NEXT_PUBLIC_AD_TEXT_PROVIDER": "none",
"NEXT_PUBLIC_IS_TESTNET": "true",
"NEXT_PUBLIC_GAS_TRACKER_ENABLED": "true",
"NEXT_PUBLIC_HAS_BEACON_CHAIN": "true",
"NEXT_PUBLIC_NETWORK_VERIFICATION_TYPE": "validation",
"NEXT_PUBLIC_NETWORK_ICON": "https://ethpandaops.io/logo.png",
},
min_cpu=BLOCKSCOUT_MIN_CPU,
max_cpu=BLOCKSCOUT_MAX_CPU,
min_memory=BLOCKSCOUT_MIN_MEMORY,
max_memory=BLOCKSCOUT_MAX_MEMORY,
node_selectors=node_selectors,
)
6 changes: 4 additions & 2 deletions src/package_io/input_parser.star
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,7 @@ def input_parser(plan, input_args):
blockscout_params=struct(
image=result["blockscout_params"]["image"],
verif_image=result["blockscout_params"]["verif_image"],
frontend_image=result["blockscout_params"]["frontend_image"],
),
dora_params=struct(
image=result["dora_params"]["image"],
Expand Down Expand Up @@ -1011,8 +1012,9 @@ def default_participant():

def get_default_blockscout_params():
return {
"image": "blockscout/blockscout:6.8.0",
"verif_image": "ghcr.io/blockscout/smart-contract-verifier:v1.9.0",
"image": "blockscout/blockscout:latest",
"verif_image": "ghcr.io/blockscout/smart-contract-verifier:latest",
"frontend_image": "ghcr.io/blockscout/frontend:latest",
}


Expand Down
1 change: 1 addition & 0 deletions src/package_io/sanity_check.star
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ SUBCATEGORY_PARAMS = {
"blockscout_params": [
"image",
"verif_image",
"frontend_image",
],
"dora_params": [
"image",
Expand Down

0 comments on commit 4f69962

Please sign in to comment.