diff --git a/scripts/deployment/complete-config-ready-chains.sh b/scripts/deployment/complete-config-ready-chains.sh index b471da0..dcbbed9 100755 --- a/scripts/deployment/complete-config-ready-chains.sh +++ b/scripts/deployment/complete-config-ready-chains.sh @@ -75,15 +75,34 @@ fi # If a selector is missing, bridge.calculateFee / ccipSend revert with CCIPRouter: chain not supported. CCIP_ROUTER="${CCIP_ROUTER:-}" +# cast send often exits 0 even when the receipt shows status 0 (revert). Parse human receipt output. +report_cast_send_result() { + local _out="$1" + if echo "$_out" | grep -qE 'status[[:space:]]+0[[:space:]]+\(failed\)'; then + log_warn " On-chain revert (mined, status=0)" + echo " $_out" >&2 + elif echo "$_out" | grep -qE 'status[[:space:]]+1[[:space:]]+\(success\)'; then + log_success " OK (mined)" + [[ -n "$_out" ]] && echo " $_out" + elif echo "$_out" | grep -qiE 'Error:|revert|Failed|timeout|null response|invalid nonce'; then + log_warn " RPC / client failure (non-fatal)" + echo " $_out" >&2 + elif echo "$_out" | grep -q 'transactionHash'; then + log_success " OK (submitted; verify receipt if status line missing)" + [[ -n "$_out" ]] && echo " $_out" + else + log_warn " Ambiguous cast output (non-fatal)" + echo " $_out" >&2 + fi +} + run_or_echo() { if [[ "$DRY_RUN" = "1" ]]; then echo " [DRY RUN] $*" else - # With set -e, _out=$(eval ...) would exit the whole script on failure; use if to absorb it. local _out if _out=$(eval "$*" 2>&1); then - log_success " OK" - [[ -n "$_out" ]] && echo " $_out" + report_cast_send_result "$_out" else log_warn " Failed (non-fatal)" echo " $_out" >&2 diff --git a/scripts/deployment/fund-ccip-bridges-with-link.sh b/scripts/deployment/fund-ccip-bridges-with-link.sh index 61e23ba..6e6f455 100755 --- a/scripts/deployment/fund-ccip-bridges-with-link.sh +++ b/scripts/deployment/fund-ccip-bridges-with-link.sh @@ -16,14 +16,33 @@ parse_link_tags "$@" [[ -f "$SCRIPT_DIR/../lib/infura.sh" ]] && source "$SCRIPT_DIR/../lib/infura.sh" 2>/dev/null || true [[ -n "${PRIVATE_KEY:-}" && ! "$PRIVATE_KEY" =~ ^0x ]] && PRIVATE_KEY="0x$PRIVATE_KEY" +report_cast_send_result() { + local _out="$1" + if echo "$_out" | grep -qE 'status[[:space:]]+0[[:space:]]+\(failed\)'; then + echo " On-chain revert (mined, status=0)" >&2 + echo " $_out" >&2 + elif echo "$_out" | grep -qE 'status[[:space:]]+1[[:space:]]+\(success\)'; then + echo " OK (mined)" + [[ -n "$_out" ]] && echo " $_out" + elif echo "$_out" | grep -qiE 'Error:|revert|Failed|timeout|null response|invalid nonce'; then + echo " RPC / client failure (non-fatal)" >&2 + echo " $_out" >&2 + elif echo "$_out" | grep -q 'transactionHash'; then + echo " OK (submitted)" + [[ -n "$_out" ]] && echo " $_out" + else + echo " Ambiguous cast output (non-fatal)" >&2 + echo " $_out" >&2 + fi +} + run_or_echo() { if [[ "${DRY_RUN:-0}" = "1" ]]; then echo " [DRY RUN] $*" else local _out if _out=$(eval "$*" 2>&1); then - echo " OK" - [[ -n "$_out" ]] && echo " $_out" + report_cast_send_result "$_out" else echo " Failed (non-fatal)" >&2 echo " $_out" >&2 @@ -76,7 +95,7 @@ if [[ -n "${RPC_URL_138:-}" && -n "${LINK_TOKEN_CHAIN138:-${LINK_TOKEN:-}}" ]]; link="${link,,}" rpc=$(ensure_rpc "$RPC_URL_138") echo "Chain 138 (RPC: ${rpc%%\?*}...)" - _gas138="--legacy --gas-limit 250000 --gas-price 2000000000" + _gas138="--legacy --gas-limit 250000 --gas-price 2000000000 --timeout 120" if [[ -n "${CCIPWETH9_BRIDGE_CHAIN138:-}" ]]; then if has_sufficient_link "$link" "$DEPLOYER_ADDR" "$rpc" "$LINK_AMOUNT_WEI"; then run_or_echo "cast send $link \"transfer(address,uint256)\" ${CCIPWETH9_BRIDGE_CHAIN138,,} $LINK_AMOUNT_WEI --rpc-url \"$rpc\" --private-key \"\$PRIVATE_KEY\" $_gas138" @@ -99,16 +118,17 @@ if [[ -n "${ETHEREUM_MAINNET_RPC:-}" && -n "${MAINNET_LINK_TOKEN:-${CCIP_ETH_LIN link="${MAINNET_LINK_TOKEN:-$CCIP_ETH_LINK_TOKEN}" rpc=$(ensure_rpc "$ETHEREUM_MAINNET_RPC") echo "Ethereum Mainnet" + _pub_timeout="--timeout 300 --rpc-timeout 120" if [[ -n "${MAINNET_CCIP_WETH9_BRIDGE:-}" ]]; then if has_sufficient_link "$link" "$DEPLOYER_ADDR" "$rpc" "$LINK_AMOUNT_WEI"; then - run_or_echo "cast send $link \"transfer(address,uint256)\" $MAINNET_CCIP_WETH9_BRIDGE $LINK_AMOUNT_WEI --rpc-url \"$rpc\" --private-key \"\$PRIVATE_KEY\" --legacy" + run_or_echo "cast send $link \"transfer(address,uint256)\" $MAINNET_CCIP_WETH9_BRIDGE $LINK_AMOUNT_WEI --rpc-url \"$rpc\" --private-key \"\$PRIVATE_KEY\" --legacy $_pub_timeout" else print_skip "ETH/WETH9" "$link" "$DEPLOYER_ADDR" "$rpc" "$LINK_AMOUNT_WEI" fi fi if [[ -n "${MAINNET_CCIP_WETH10_BRIDGE:-}" ]]; then if has_sufficient_link "$link" "$DEPLOYER_ADDR" "$rpc" "$LINK_AMOUNT_WEI"; then - run_or_echo "cast send $link \"transfer(address,uint256)\" $MAINNET_CCIP_WETH10_BRIDGE $LINK_AMOUNT_WEI --rpc-url \"$rpc\" --private-key \"\$PRIVATE_KEY\" --legacy" + run_or_echo "cast send $link \"transfer(address,uint256)\" $MAINNET_CCIP_WETH10_BRIDGE $LINK_AMOUNT_WEI --rpc-url \"$rpc\" --private-key \"\$PRIVATE_KEY\" --legacy $_pub_timeout" else print_skip "ETH/WETH10" "$link" "$DEPLOYER_ADDR" "$rpc" "$LINK_AMOUNT_WEI" fi @@ -142,16 +162,17 @@ for label in BSC POLYGON BASE OPTIMISM ARBITRUM AVALANCHE CRONOS GNOSIS CELO WEM [[ -z "$addr9" && -z "$addr10" ]] && continue echo "$label" + _pub_timeout_loop="--timeout 300 --rpc-timeout 120" if [[ -n "$addr9" ]]; then if has_sufficient_link "$link" "$DEPLOYER_ADDR" "$rpc" "$LINK_AMOUNT_WEI"; then - run_or_echo "cast send ${link,,} \"transfer(address,uint256)\" ${addr9,,} $LINK_AMOUNT_WEI --rpc-url \"$rpc\" --private-key \"\$PRIVATE_KEY\" --legacy" + run_or_echo "cast send ${link,,} \"transfer(address,uint256)\" ${addr9,,} $LINK_AMOUNT_WEI --rpc-url \"$rpc\" --private-key \"\$PRIVATE_KEY\" --legacy $_pub_timeout_loop" else print_skip "$label/WETH9" "$link" "$DEPLOYER_ADDR" "$rpc" "$LINK_AMOUNT_WEI" fi fi if [[ -n "$addr10" ]]; then if has_sufficient_link "$link" "$DEPLOYER_ADDR" "$rpc" "$LINK_AMOUNT_WEI"; then - run_or_echo "cast send ${link,,} \"transfer(address,uint256)\" ${addr10,,} $LINK_AMOUNT_WEI --rpc-url \"$rpc\" --private-key \"\$PRIVATE_KEY\" --legacy" + run_or_echo "cast send ${link,,} \"transfer(address,uint256)\" ${addr10,,} $LINK_AMOUNT_WEI --rpc-url \"$rpc\" --private-key \"\$PRIVATE_KEY\" --legacy $_pub_timeout_loop" else print_skip "$label/WETH10" "$link" "$DEPLOYER_ADDR" "$rpc" "$LINK_AMOUNT_WEI" fi