@@ -1889,7 +1889,7 @@ deploy_l2() {
18891889 local exit_status=0
18901890 local temp_output=" /tmp/surge_l2_deploy_output_$$ "
18911891
1892- # Deploy L2 contracts
1892+ # Start L2 deployer in detached mode, then wait for it to finish
18931893 BROADCAST=true docker compose --profile l2-deployer up -d > " $temp_output " 2>&1 &
18941894 local deploy_pid=$!
18951895
@@ -1898,16 +1898,50 @@ deploy_l2() {
18981898 wait $deploy_pid
18991899 exit_status=$?
19001900
1901- if [[ $exit_status -eq 0 ]]; then
1902- log_success " L2 smart contracts deployed successfully"
1903- return 0
1904- else
1905- log_error " Failed to deploy L2 smart contracts (exit code: $exit_status )"
1901+ if [[ $exit_status -ne 0 ]]; then
1902+ log_error " Failed to start L2 deployer container (exit code: $exit_status )"
19061903 if [[ -f " $temp_output " ]]; then
1907- log_error " Deployment output saved in: $temp_output "
1904+ log_error " Output saved in: $temp_output "
1905+ fi
1906+ return 1
1907+ fi
1908+
1909+ # Wait for the deployer container to finish (up to 120s)
1910+ log_info " Waiting for L2 deployer to complete..."
1911+ local waited=0
1912+ local max_wait=120
1913+ while [[ $waited -lt $max_wait ]]; do
1914+ local status
1915+ status=$( docker inspect surge-l2-deployer --format ' {{.State.Status}}' 2> /dev/null || echo " not found" )
1916+ if [[ " $status " == " exited" ]]; then
1917+ local code
1918+ code=$( docker inspect surge-l2-deployer --format ' {{.State.ExitCode}}' 2> /dev/null || echo " 1" )
1919+ if [[ " $code " == " 0" ]]; then
1920+ break
1921+ else
1922+ log_error " L2 deployer exited with code $code "
1923+ docker logs surge-l2-deployer 2>&1 | tail -20 >&2
1924+ return 1
1925+ fi
19081926 fi
1927+ sleep 5
1928+ waited=$(( waited + 5 ))
1929+ done
1930+
1931+ if [[ $waited -ge $max_wait ]]; then
1932+ log_error " L2 deployer timed out after ${max_wait} s"
19091933 return 1
19101934 fi
1935+
1936+ # Verify the deployment artifact was produced
1937+ if [[ -f " $DEPLOYMENT_DIR /setup_l2.json" ]]; then
1938+ log_success " L2 smart contracts deployed successfully"
1939+ touch " $L2_LOCK_FILE "
1940+ else
1941+ log_warning " L2 deployer exited 0 but setup_l2.json not found, continuing..."
1942+ fi
1943+
1944+ return 0
19111945 fi
19121946}
19131947
@@ -1985,16 +2019,16 @@ start_l2_stack() {
19852019 $compose_cmd --profile catalyst --profile spammer --profile blockscout up -d > " $temp_output " 2>&1 &
19862020 ;;
19872021 4)
1988- log_info " Starting driver + proposer + prover + spammer"
2022+ log_info " Starting driver + proposer + prover ( spammer deferred until after L2 deploy) "
19892023 $compose_cmd --profile catalyst --profile prover --profile blockscout up -d > " $temp_output " 2>&1 &
19902024 ;;
19912025 5)
19922026 log_info " Starting all except spammer"
19932027 $compose_cmd --profile driver --profile catalyst --profile prover --profile blockscout up -d > " $temp_output " 2>&1 &
19942028 ;;
19952029 * )
1996- log_info " Starting all components"
1997- $compose_cmd --profile driver --profile catalyst --profile spammer --profile prover --profile blockscout up -d > " $temp_output " 2>&1 &
2030+ log_info " Starting all components (spammer deferred until after L2 deploy) "
2031+ $compose_cmd --profile driver --profile catalyst --profile prover --profile blockscout up -d > " $temp_output " 2>&1 &
19982032 ;;
19992033 esac
20002034
@@ -2021,7 +2055,7 @@ start_relayers() {
20212055 local should_start_relayers=" $1 "
20222056 local environment=" $2 "
20232057
2024- if [[ " $should_start_relayers " != " 0 " || " $should_start_relayers " == " true " ]]; then
2058+ if [[ " $should_start_relayers " == " 1 " ]]; then
20252059 log_info " Skipping relayers as requested"
20262060 return 0
20272061 fi
@@ -2553,6 +2587,12 @@ main() {
25532587 log_warning " Relayer startup had issues, but continuing..."
25542588 fi
25552589
2590+ # Step 5b: Start spammer now that L2 deploy is done (if stack option included it)
2591+ if [[ " $stack_choice " == " 3" || " $stack_choice " == " 4" || " $stack_choice " == " 6" || -z " $stack_choice " ]]; then
2592+ log_info " Starting tx spammer..."
2593+ docker compose --profile spammer up -d tx-spammer > /dev/null 2>&1 || true
2594+ fi
2595+
25562596 # Step 6: Verification
25572597 verify_rpc_endpoints
25582598
0 commit comments