Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ network_params:
# The block height of the shadowfork
# This is used to sync the network from a snapshot at a specific block height
# Defaults to "latest"
# Example: shadowfork_block_height: 240000
# Example: shadowfork_block_height: 340000 for hoodi
shadowfork_block_height: "latest"

# The number of data column sidecar subnets used in the gossipsub protocol
Expand Down
23 changes: 22 additions & 1 deletion src/network_launcher/public_network.star
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,27 @@ def launch(
index_str = shared_utils.zfill_custom(
index + 1, len(str(len(participants)))
)
latest_block = ""
if network_params.shadowfork_block_height == "latest":
latest_block = plan.run_sh(
name="fetch-latest-block",
description="Fetching the latest block",
run="mkdir -p /shadowfork && \
curl -s -o /shadowfork/latest_block.json "
+ network_params.network_sync_base_url
+ network_params.network
+ "/geth/"
+ str(network_params.shadowfork_block_height)
+ " && \
cat /shadowfork/latest_block.json",
store=[StoreSpec(src="/shadowfork", name="latest_blocks")],
)

block_height = (
latest_block.output
if network_params.shadowfork_block_height == "latest"
else network_params.shadowfork_block_height
)
el_service_name = "el-{0}-{1}-{2}".format(index_str, el_type, cl_type)
el_data = plan.add_service(
name="snapshot-{0}".format(el_service_name),
Expand All @@ -40,7 +60,8 @@ def launch(
+ network_params.network
+ "/"
+ el_type
+ "/latest"
+ "/"
+ str(block_height)
+ "/snapshot.tar.zst"
+ " | tar -I zstd -xvf - -C /data/"
+ el_type
Expand Down
36 changes: 21 additions & 15 deletions src/network_launcher/shadowfork.star
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,21 @@ def shadowfork_prep(
network_id = constants.NETWORK_ID[
base_network
] # overload the network id to match the network name
latest_block = plan.run_sh(
name="fetch-latest-block",
description="Fetching the latest block",
run="mkdir -p /shadowfork && \
curl -s -o /shadowfork/latest_block.json "
+ network_params.network_sync_base_url
+ base_network
+ "/geth/"
+ str(network_params.shadowfork_block_height)
+ "/_snapshot_eth_getBlockByNumber.json && \
cat /shadowfork/latest_block.json",
store=[StoreSpec(src="/shadowfork", name="latest_blocks")],
)
latest_block = ""
if network_params.shadowfork_block_height == "latest":
latest_block = plan.run_sh(
name="fetch-latest-block",
description="Fetching the latest block",
run="mkdir -p /shadowfork && \
curl -s -o /shadowfork/latest_block.json "
+ network_params.network_sync_base_url
+ base_network
+ "/geth/"
+ str(network_params.shadowfork_block_height)
+ " && \
cat /shadowfork/latest_block.json",
store=[StoreSpec(src="/shadowfork", name="latest_blocks")],
)

for index, participant in enumerate(participants):
tolerations = input_parser.get_client_tolerations(
Expand All @@ -54,7 +56,11 @@ def shadowfork_prep(

# Zero-pad the index using the calculated zfill value
index_str = shared_utils.zfill_custom(index + 1, len(str(len(participants))))

block_height = (
latest_block.output
if network_params.shadowfork_block_height == "latest"
else network_params.shadowfork_block_height
)
el_service_name = "el-{0}-{1}-{2}".format(index_str, el_type, cl_type)
shadowfork_data = plan.add_service(
name="shadowfork-{0}".format(el_service_name),
Expand All @@ -67,7 +73,7 @@ def shadowfork_prep(
+ "/"
+ el_type
+ "/"
+ str(network_params.shadowfork_block_height)
+ str(block_height)
+ "/snapshot.tar.zst"
+ " | tar -I zstd -xvf - -C /data/"
+ el_type
Expand Down