Skip to content

Commit

Permalink
feat: blockscout support with sc verification (ethpandaops#481)
Browse files Browse the repository at this point in the history
addresses ethpandaops#372

---------

Co-authored-by: franjoespejo <franjosepejo@github.com>
  • Loading branch information
franjoespejo and franjoespejo authored Feb 2, 2024
1 parent 1e543e8 commit b3418cf
Show file tree
Hide file tree
Showing 5 changed files with 145 additions and 1 deletion.
1 change: 1 addition & 0 deletions .github/tests/mix-with-tools-mev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ additional_services:
- goomy_blob
- custom_flood
- blobscan
- blockscout
ethereum_metrics_exporter_enabled: true
snooper_enabled: true
mev_type: full
Expand Down
1 change: 1 addition & 0 deletions .github/tests/mix-with-tools.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@ additional_services:
- goomy_blob
- custom_flood
- blobscan
- blockscout
ethereum_metrics_exporter_enabled: true
snooper_enabled: true
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,7 @@ additional_services:
- custom_flood
- goomy_blob
- el_forkmon
- blockscout
- beacon_metrics_gazer
- dora
- full_beaconchain_explorer
Expand Down
12 changes: 11 additions & 1 deletion main.star
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ blobscan = import_module("./src/blobscan/blobscan_launcher.star")
full_beaconchain_explorer = import_module(
"./src/full_beaconchain/full_beaconchain_launcher.star"
)
blockscout = import_module("./src/blockscout/blockscout_launcher.star")
prometheus = import_module("./src/prometheus/prometheus_launcher.star")
grafana = import_module("./src/grafana/grafana_launcher.star")
mev_boost = import_module("./src/mev/mev_boost/mev_boost_launcher.star")
Expand Down Expand Up @@ -68,7 +69,6 @@ def run(plan, args={}):
static_files.GRAFANA_DASHBOARD_PROVIDERS_CONFIG_TEMPLATE_FILEPATH
)
prometheus_additional_metrics_jobs = []

raw_jwt_secret = read_file(static_files.JWT_PATH_FILEPATH)
jwt_file = plan.upload_files(
src=static_files.JWT_PATH_FILEPATH,
Expand Down Expand Up @@ -326,6 +326,12 @@ def run(plan, args={}):
beacon_metrics_gazer_prometheus_metrics_job
)
plan.print("Successfully launched beacon metrics gazer")
elif additional_service == "blockscout":
plan.print("Launching blockscout")
blockscout_sc_verif_url = blockscout.launch_blockscout(
plan, all_el_client_contexts, persistent
)
plan.print("Successfully launched blockscout")
elif additional_service == "dora":
plan.print("Launching dora")
dora_config_template = read_file(static_files.DORA_CONFIG_TEMPLATE_FILEPATH)
Expand Down Expand Up @@ -434,8 +440,12 @@ def run(plan, args={}):
user=GRAFANA_USER,
password=GRAFANA_PASSWORD,
)

output = struct(
grafana_info=grafana_info,
blockscout_sc_verif_url=None
if ("blockscout" in args_with_right_defaults.additional_services) == False
else blockscout_sc_verif_url,
all_participants=all_participants,
final_genesis_timestamp=final_genesis_timestamp,
genesis_validators_root=genesis_validators_root,
Expand Down
131 changes: 131 additions & 0 deletions src/blockscout/blockscout_launcher.star
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
shared_utils = import_module("../shared_utils/shared_utils.star")
constants = import_module("../package_io/constants.star")
postgres = import_module("github.com/kurtosis-tech/postgres-package/main.star")

IMAGE_NAME_BLOCKSCOUT = "blockscout/blockscout:6.0.0"
IMAGE_NAME_BLOCKSCOUT_VERIF = "ghcr.io/blockscout/smart-contract-verifier:v1.6.0"

SERVICE_NAME_BLOCKSCOUT = "blockscout"

HTTP_PORT_ID = "http"
HTTP_PORT_NUMBER = 4000
HTTP_PORT_NUMBER_VERIF = 8050

BLOCKSCOUT_MIN_CPU = 100
BLOCKSCOUT_MAX_CPU = 1000
BLOCKSCOUT_MIN_MEMORY = 1024
BLOCKSCOUT_MAX_MEMORY = 2048

BLOCKSCOUT_VERIF_MIN_CPU = 10
BLOCKSCOUT_VERIF_MAX_CPU = 1000
BLOCKSCOUT_VERIF_MIN_MEMORY = 10
BLOCKSCOUT_VERIF_MAX_MEMORY = 1024

USED_PORTS = {
HTTP_PORT_ID: shared_utils.new_port_spec(
HTTP_PORT_NUMBER,
shared_utils.TCP_PROTOCOL,
shared_utils.HTTP_APPLICATION_PROTOCOL,
)
}

VERIF_USED_PORTS = {
HTTP_PORT_ID: shared_utils.new_port_spec(
HTTP_PORT_NUMBER_VERIF,
shared_utils.TCP_PROTOCOL,
shared_utils.HTTP_APPLICATION_PROTOCOL,
)
}


def launch_blockscout(plan, el_client_contexts, persistent):
postgres_output = postgres.run(
plan,
service_name="{}-postgres".format(SERVICE_NAME_BLOCKSCOUT),
database="blockscout",
extra_configs=["max_connections=1000"],
persistent=persistent,
)

el_client_context = el_client_contexts[0]
el_client_rpc_url = "http://{}:{}/".format(
el_client_context.ip_addr, el_client_context.rpc_port_num
)
el_client_name = el_client_context.client_name

config_verif = get_config_verif()
verif_service_name = "{}-verif".format(SERVICE_NAME_BLOCKSCOUT)
verif_service = plan.add_service(verif_service_name, config_verif)
verif_url = "http://{}:{}/api".format(
verif_service.hostname, verif_service.ports["http"].number
)

config_backend = get_config_backend(
postgres_output, el_client_rpc_url, verif_url, el_client_name
)
blockscout_service = plan.add_service(SERVICE_NAME_BLOCKSCOUT, config_backend)
plan.print(blockscout_service)

blockscout_url = "http://{}:{}".format(
blockscout_service.hostname, blockscout_service.ports["http"].number
)

return blockscout_url


def get_config_verif():
return ServiceConfig(
image=IMAGE_NAME_BLOCKSCOUT_VERIF,
ports=VERIF_USED_PORTS,
env_vars={
"SMART_CONTRACT_VERIFIER__SERVER__HTTP__ADDR": "0.0.0.0:{}".format(
HTTP_PORT_NUMBER_VERIF
)
},
min_cpu=BLOCKSCOUT_VERIF_MIN_CPU,
max_cpu=BLOCKSCOUT_VERIF_MAX_CPU,
min_memory=BLOCKSCOUT_VERIF_MIN_MEMORY,
max_memory=BLOCKSCOUT_VERIF_MAX_MEMORY,
)


def get_config_backend(postgres_output, el_client_rpc_url, verif_url, el_client_name):
database_url = "{protocol}://{user}:{password}@{hostname}:{port}/{database}".format(
protocol="postgresql",
user=postgres_output.user,
password=postgres_output.password,
hostname=postgres_output.service.hostname,
port=postgres_output.port.number,
database=postgres_output.database,
)

return ServiceConfig(
image=IMAGE_NAME_BLOCKSCOUT,
ports=USED_PORTS,
cmd=[
"/bin/sh",
"-c",
'bin/blockscout eval "Elixir.Explorer.ReleaseTasks.create_and_migrate()" && bin/blockscout start',
],
env_vars={
"ETHEREUM_JSONRPC_VARIANT": el_client_name,
"ETHEREUM_JSONRPC_HTTP_URL": el_client_rpc_url,
"ETHEREUM_JSONRPC_TRACE_URL": el_client_rpc_url,
"DATABASE_URL": database_url,
"COIN": "ETH",
"MICROSERVICE_SC_VERIFIER_ENABLED": "true",
"MICROSERVICE_SC_VERIFIER_URL": verif_url,
"MICROSERVICE_SC_VERIFIER_TYPE": "sc_verifier",
"INDEXER_DISABLE_PENDING_TRANSACTIONS_FETCHER": "true",
"ECTO_USE_SSL": "false",
"NETWORK": "Kurtosis",
"SUBNETWORK": "Kurtosis",
"API_V2_ENABLED": "true",
"PORT": "{}".format(HTTP_PORT_NUMBER),
"SECRET_KEY_BASE": "56NtB48ear7+wMSf0IQuWDAAazhpb31qyc7GiyspBP2vh7t5zlCsF5QDv76chXeN",
},
min_cpu=BLOCKSCOUT_MIN_CPU,
max_cpu=BLOCKSCOUT_MAX_CPU,
min_memory=BLOCKSCOUT_MIN_MEMORY,
max_memory=BLOCKSCOUT_MAX_MEMORY,
)

0 comments on commit b3418cf

Please sign in to comment.