Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emergency pause improvements #829

Merged
merged 17 commits into from
Oct 10, 2024
24 changes: 4 additions & 20 deletions .github/workflows/diamondEmergencyPause.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
name: Pause PRODUCTION diamond (CAREFUL)
name: EMERGENCY >> Pause all PROD diamonds

on:
workflow_dispatch:
inputs:
Warning:
description: 'By clicking the next button you are pausing all PROUCTION diamonds. Please proceed with extreme caution !!!'
description: "By clicking the next button you are pausing all PROUCTION diamonds. Please proceed with extreme caution !!! You must type 'UNDERSTOOD' to proceed"
required: true
default: 'Type UNDERSTOOD to continue'

jobs:
diamond-emergency-pause:
Expand All @@ -18,24 +17,9 @@ jobs:
- name: Check input
if: ${{ inputs.Warning != 'UNDERSTOOD' }}
run: |
echo -e "\033[31mYou must type 'UNDERSTOOD' to proceed.\033[0m"
echo -e "\033[31mYou must type 'UNDERSTOOD' to proceed. Please try again. \033[0m"
exit 1

# Keeping this code for now until team member authentication has been tested successfully
# - name: Authenticate user
# id: check_user
# run: |
# ALLOWED_USERS=("0xDEnYO" "maxklenk" "ezynda3")
# USER=${{ github.actor }}
# if [[ ! " ${ALLOWED_USERS[@]} " =~ " $USER " ]]; then
# echo "User $USER is not allowed to run this workflow. Only the following users are:"
# echo "$ALLOWED_USERS"
# exit 1
# else
# echo "User $USER is allowed to run this workflow."
# fi
# shell: bash

- name: Authenticate git user (check membership in 'DiamondPauser' group)
if: ${{ inputs.Warning == 'UNDERSTOOD' }}
id: authenticate-user
Expand Down Expand Up @@ -96,7 +80,7 @@ jobs:
ETH_NODE_URI_TAIKO: ${{ secrets.ETH_NODE_URI_TAIKO }}
ETH_NODE_URI_XLAYER: ${{ secrets.ETH_NODE_URI_XLAYER }}
ETH_NODE_URI_ZKSYNC: ${{ secrets.ETH_NODE_URI_ZKSYNC }}
PRIVATE_KEY_PAUSER_WALLET: ${{ secrets.TEST_PRIV_KEY_SECRET }}
PRIVATE_KEY_PAUSER_WALLET: ${{ secrets.PRIV_KEY_PAUSER_WALLET }}

- name: Send Discord message
uses: Ilshidur/action-discord@0.3.2
Expand Down
6 changes: 0 additions & 6 deletions audit/auditLog.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,6 @@
"EmergencyPauseFacet": {
"1.0.0": ["audit20240913"]
},
"GenericErrors": {
"1.0.0": ["audit20240913"]
},
"LibDiamondLoupe": {
"1.0.0": ["audit20240913"]
},
"StargateFacetV2": {
"1.0.1": ["audit20240814"]
}
Expand Down
1 change: 0 additions & 1 deletion config/global.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"pauserWallet": "0x3b6211981d47Fb6375E0125A6a401830616f7906",
"lifuelRebalanceWallet": "0xC71284231A726A18ac85c94D75f9fe17A185BeAF",
"deployerWallet": "0x11F1022cA6AdEF6400e5677528a80d49a069C00c",
"pauserWallet": "0x29DaCdF7cCaDf4eE67c923b4C22255A4B2494eD7",
"approvedSigsForRefundWallet": [
{
"sig": "0x0d19e519",
Expand Down
26 changes: 13 additions & 13 deletions deployments/_deployments_log_file.json
Original file line number Diff line number Diff line change
Expand Up @@ -23345,12 +23345,12 @@
"staging": {
"1.0.0": [
{
"ADDRESS": "0x6DCDA5EEb0eb10D61eB9AAF93C3B89704955dA42",
"ADDRESS": "0x17Bb203F42d8e404ac7E8dB6ff972B7E8473850b",
"OPTIMIZER_RUNS": "1000000",
"TIMESTAMP": "2024-07-21 15:50:57",
"CONSTRUCTOR_ARGS": "0x00000000000000000000000029dacdf7ccadf4ee67c923b4c22255a4b2494ed7",
"SALT": "",
"VERIFIED": "false"
"TIMESTAMP": "2024-10-09 13:34:31",
"CONSTRUCTOR_ARGS": "0x000000000000000000000000b9c0de368bece5e76b52545a8e377a4c118f597b",
"SALT": "20241009",
"VERIFIED": "true"
}
]
}
Expand All @@ -23373,11 +23373,11 @@
"staging": {
"1.0.0": [
{
"ADDRESS": "0x9a0988b17D4419807DfC8E8fd2182A21eabB1361",
"ADDRESS": "0x17Bb203F42d8e404ac7E8dB6ff972B7E8473850b",
"OPTIMIZER_RUNS": "1000000",
"TIMESTAMP": "2024-10-08 11:23:04",
"CONSTRUCTOR_ARGS": "0x00000000000000000000000029dacdf7ccadf4ee67c923b4c22255a4b2494ed7",
"SALT": "",
"TIMESTAMP": "2024-10-09 13:37:13",
"CONSTRUCTOR_ARGS": "0x000000000000000000000000b9c0de368bece5e76b52545a8e377a4c118f597b",
"SALT": "20241009",
"VERIFIED": "true"
}
]
Expand All @@ -23387,11 +23387,11 @@
"staging": {
"1.0.0": [
{
"ADDRESS": "0x9a0988b17D4419807DfC8E8fd2182A21eabB1361",
"ADDRESS": "0x17Bb203F42d8e404ac7E8dB6ff972B7E8473850b",
"OPTIMIZER_RUNS": "1000000",
"TIMESTAMP": "2024-10-08 11:25:56",
"CONSTRUCTOR_ARGS": "0x00000000000000000000000029dacdf7ccadf4ee67c923b4c22255a4b2494ed7",
"SALT": "",
"TIMESTAMP": "2024-10-09 13:32:11",
"CONSTRUCTOR_ARGS": "0x000000000000000000000000b9c0de368bece5e76b52545a8e377a4c118f597b",
"SALT": "20241009",
"VERIFIED": "true"
}
]
Expand Down
10 changes: 7 additions & 3 deletions deployments/arbitrum.diamond.staging.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{
"LiFiDiamond": {
"Facets": {
"0x17Bb203F42d8e404ac7E8dB6ff972B7E8473850b": {
"Name": "EmergencyPauseFacet",
"Version": "1.0.0"
},
"0xB2A8517734CDf985d53F303A1f7759A34fdC772F": {
"Name": "DiamondCutFacet",
"Version": "1.0.0"
Expand Down Expand Up @@ -133,9 +137,9 @@
"Name": "",
"Version": ""
},
"0x9a0988b17D4419807DfC8E8fd2182A21eabB1361": {
"Name": "EmergencyPauseFacet",
"Version": "1.0.0"
"0xaF5001e4cd39B3515B244B18A88DD5b2fE65c5cD": {
"Name": "",
"Version": ""
}
},
"Periphery": {
Expand Down
2 changes: 1 addition & 1 deletion deployments/arbitrum.staging.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,5 @@
"HopFacetOptimized": "0xf82135385765f1324257ffF74489F16382EBBb8A",
"LiFuelFeeCollector": "0x94EA56D8049e93E0308B9c7d1418Baf6A7C68280",
"TokenWrapper": "0xF63b27AE2Dc887b88f82E2Cc597d07fBB2E78E70",
"EmergencyPauseFacet": "0x9a0988b17D4419807DfC8E8fd2182A21eabB1361"
"EmergencyPauseFacet": "0x17Bb203F42d8e404ac7E8dB6ff972B7E8473850b"
}
8 changes: 4 additions & 4 deletions deployments/optimism.diamond.staging.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{
"LiFiDiamond": {
"Facets": {
"0x17Bb203F42d8e404ac7E8dB6ff972B7E8473850b": {
"Name": "EmergencyPauseFacet",
"Version": "1.0.0"
},
"0xB2A8517734CDf985d53F303A1f7759A34fdC772F": {
"Name": "DiamondCutFacet",
"Version": "1.0.0"
Expand Down Expand Up @@ -120,10 +124,6 @@
"0x4352459F6BE1C7D1278F8c34Bb598b0feeB50f8b": {
"Name": "",
"Version": ""
},
"0x9a0988b17D4419807DfC8E8fd2182A21eabB1361": {
"Name": "EmergencyPauseFacet",
"Version": "1.0.0"
}
},
"Periphery": {
Expand Down
2 changes: 1 addition & 1 deletion deployments/optimism.staging.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,5 @@
"LiFuelFeeCollector": "0x94EA56D8049e93E0308B9c7d1418Baf6A7C68280",
"RelayerCelerIM": "0xC1906dC6b43EbE6AE511cc4abeB8711120Ab622e",
"TokenWrapper": "0xF63b27AE2Dc887b88f82E2Cc597d07fBB2E78E70",
"EmergencyPauseFacet": "0x9a0988b17D4419807DfC8E8fd2182A21eabB1361"
"EmergencyPauseFacet": "0x17Bb203F42d8e404ac7E8dB6ff972B7E8473850b"
}
10 changes: 9 additions & 1 deletion deployments/polygon.diamond.staging.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,14 @@
"0x21571D628B0bCBeb954D5933A604eCac35bAF2c7": {
"Name": "SymbiosisFacet",
"Version": "1.0.0"
},
"0xaF5001e4cd39B3515B244B18A88DD5b2fE65c5cD": {
"Name": "",
"Version": ""
},
"0x17Bb203F42d8e404ac7E8dB6ff972B7E8473850b": {
"Name": "EmergencyPauseFacet",
"Version": "1.0.0"
}
},
"Periphery": {
Expand All @@ -128,4 +136,4 @@
"TokenWrapper": "0xF63b27AE2Dc887b88f82E2Cc597d07fBB2E78E70"
}
}
}
}
4 changes: 2 additions & 2 deletions deployments/polygon.staging.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@
"GasRebateDistributor": "0x3116B8F099D7eFA6e24f39F80146Aac423365EB9",
"GenericSwapFacetV3": "0xFf6Fa203573Baaaa4AE375EB7ac2819d539e16FF",
"StargateFacetV2": "0xeb3f9490d8cbD0C34C0642a8d0495e5E0B0745AA",
"EmergencyPauseFacet": "0x6DCDA5EEb0eb10D61eB9AAF93C3B89704955dA42",
"EmergencyPauseFacet": "0x17Bb203F42d8e404ac7E8dB6ff972B7E8473850b",
"StandardizedCallFacet": "0xA7ffe57ee70Ac4998e9E9fC6f17341173E081A8f",
"CalldataVerificationFacet": "0x90B5b319cA20D9E466cB5b843952363C34d1b54E",
"CelerCircleBridgeFacet": "0x371E073f6A09DCBEE1D2Ac56E940F878a0Ba9DAE",
"HopFacetOptimized": "0xf82135385765f1324257ffF74489F16382EBBb8A",
"SymbiosisFacet": "0x21571D628B0bCBeb954D5933A604eCac35bAF2c7"
}
}
32 changes: 32 additions & 0 deletions script/tasks/diamondEMERGENCYPause.sh
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,38 @@ function handleNetwork() {
echoDebug "BLACKLIST=$BLACKLIST"
echo ""

# check if the diamond is already paused by calling owner() function and analyzing the response
local RESPONSE=$(cast call "$DIAMOND_ADDRESS" "owner()" --rpc-url "$RPC_URL" 2>&1)
# only required if we dont expect the diamond to be paused
if [[ "$ACTION" != "unpause the diamond" ]]; then
# Check for errors in the response
if [[ "$RESPONSE" == 0x* ]]; then
# If the response starts with "0x", it is a valid response, and the diamond is not paused
echo "[network: $NETWORK] The diamond is not yet paused. Proceeding..."
elif [[ "$RESPONSE" == *"$DIAMOND_IS_PAUSED_SELECTOR"* || "$RESPONSE" == *"DiamondIsPaused"* ]]; then
# If the response contains the pause selector or "DiamondIsPaused", the diamond is paused
success "[network: $NETWORK] The diamond is already paused."
echo "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< end network $NETWORK <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
exit 0
else
# Handle other RPC or network errors
error "[network: $NETWORK] RPC or network error while checking if diamond is paused: $RESPONSE"
fi
fi


if [[ "$ACTION" != "unpause the diamond" && ( "$RESPONSE" == *"$DIAMOND_IS_PAUSED_SELECTOR"* || "$RESPONSE" == *"DiamondIsPaused"* ) ]]; then
if [[ "$ACTION" == "remove a single facet" ]]; then
error "[network: $NETWORK] Cannot remove a facet while diamond is paused."
echo "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< end network $NETWORK <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
exit 1
else
success "[network: $NETWORK] The diamond is already paused. No further action required."
echo "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< end network $NETWORK <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
exit 0
fi
fi

# execute the requested action
local ATTEMPTS=1
while [ $ATTEMPTS -le "$MAX_ATTEMPTS_PER_SCRIPT_EXECUTION" ]; do
Expand Down
89 changes: 75 additions & 14 deletions script/utils/diamondEMERGENCYPauseGitHub.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@
# for all other actions the diamondEMERGENCYPause.sh script should be called
# via scriptMaster.sh in local CLI for more flexibility


# load helper functions
source ./script/helperFunctions.sh

DIAMOND_IS_PAUSED_SELECTOR="0x0149422e"

# the number of attempts the script will max try to execute the pause transaction
MAX_ATTEMPTS=10

Expand Down Expand Up @@ -45,6 +48,31 @@ function handleNetwork() {
echo "[network: $NETWORK] RPC URL found"
fi

# get diamond address for this network
DIAMOND_ADDRESS=$(getContractAddressFromDeploymentLogs "$NETWORK" "production" "LiFiDiamond")
if [[ $? -ne 0 ]]; then
error "[network: $NETWORK] could not find diamond address in PROD deploy log. Cannot continue for this network."
return 1
else
echo "[network: $NETWORK] diamond address found in deploy log file: $DIAMOND_ADDRESS"
fi

# check if the diamond is already paused by calling owner() function and analyzing the response
local RESPONSE=$(cast call "$DIAMOND_ADDRESS" "owner()" --rpc-url "$RPC_URL" 2>&1)
# Check for errors in the response
if [[ "$RESPONSE" == 0x* ]]; then
# If the response starts with "0x", it is a valid response, and the diamond is not paused
echo "[network: $NETWORK] The diamond is not yet paused. Proceeding..."
elif [[ "$RESPONSE" == *"$DIAMOND_IS_PAUSED_SELECTOR"* || "$RESPONSE" == *"DiamondIsPaused"* ]]; then
# If the response contains the pause selector or "DiamondIsPaused", the diamond is paused
success "[network: $NETWORK] The diamond is already paused."
echo "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< end network $NETWORK <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
return 0
else
# Handle other RPC or network errors
error "[network: $NETWORK] RPC or network error while checking if diamond is paused: $RESPONSE"
fi

# ensure PauserWallet has positive balance
BALANCE_PAUSER_WALLET=$(cast balance "$PRIV_KEY_ADDRESS" --rpc-url "$RPC_URL")
if [[ "$BALANCE_PAUSER_WALLET" == 0 ]]; then
Expand All @@ -55,16 +83,6 @@ function handleNetwork() {
echo "[network: $NETWORK] balance pauser wallet: $BALANCE_PAUSER_WALLET"
fi

# get diamond address for this network
# DIAMOND_ADDRESS=$(getContractAddressFromDeploymentLogs "$NETWORK" "production" "LiFiDiamond")
DIAMOND_ADDRESS="0xD3b2b0aC0AFdd0d166a495f5E9fca4eCc715a782" # TODO: remove <<<<<<<<<---------------------------------------------------------------------------------------- (STAGING DIAMOND ON POL, ARB, OPT)
if [[ $? -ne 0 ]]; then
error "[network: $NETWORK] could not find diamond address in PROD deploy log. Cannot continue for this network."
return 1
else
echo "[network: $NETWORK] diamond address found in deploy log file: $DIAMOND_ADDRESS"
fi

# this fails currently since the EmergencyPauseFacet is not yet deployed to all diamonds
DIAMOND_PAUSER_WALLET=$(cast call "$DIAMOND_ADDRESS" "pauserWallet() external returns (address)" --rpc-url "$RPC_URL")

Expand Down Expand Up @@ -116,22 +134,56 @@ function handleNetwork() {
fi
}

function printStatus() {
local NETWORK="$1"

# get RPC URL for given network
local RPC_KEY="ETH_NODE_URI_$(tr '[:lower:]' '[:upper:]' <<<"$NETWORK")"
# Use eval to read the environment variable named like the RPC_KEY (our normal syntax like 'RPC_URL=${!RPC_URL}' doesnt work on Github)
eval "RPC_URL=\$$(echo "$RPC_KEY" | tr '-' '_')"

# skip any non-prod networks
case "$NETWORK" in
"bsc-testnet" | "localanvil" | "sepolia" | "mumbai" | "lineatest")
echo "skipping $NETWORK (Testnet)"
return 0
;;
esac

# get diamond address for this network
DIAMOND_ADDRESS=$(getContractAddressFromDeploymentLogs "$NETWORK" "production" "LiFiDiamond")

# check if the diamond is paused by calling owner() function and analyzing the response
local RESPONSE=$(cast call "$DIAMOND_ADDRESS" "owner()" --rpc-url "$RPC_URL" 2>&1)
# Check for errors in the response
if [[ "$RESPONSE" == 0x* ]]; then
# If the response starts with "0x", it is a valid response, and the diamond is not paused
error "[network: $NETWORK] diamond not paused."
elif [[ "$RESPONSE" == *"$DIAMOND_IS_PAUSED_SELECTOR"* || "$RESPONSE" == *"DiamondIsPaused"* ]]; then
# If the response contains the pause selector or "DiamondIsPaused", the diamond is paused
success "[network: $NETWORK] diamond paused."
else
# Handle other RPC or network errors
error "[network: $NETWORK] RPC or network error while checking if diamond is paused: $RESPONSE"
fi
}

function main {
# create array with network/s for which the script should be executed
local NETWORKS=()

# loop through networks list and add each network to ARRAY that is not excluded
# while IFS= read -r line; do
# NETWORKS+=("$line")
# done <"./networks"
NETWORKS=("arbitrum" "polygon" "optimism") # TODO: remove <<<<<<<<<---------------------------------------------------------------------------------------- (WILL MAKE SURE THAT THE TEST RUNS ONLY ON THREE
while IFS= read -r line; do
NETWORKS+=("$line")
done <"./networks"

echo "networks found: ${NETWORKS[@]}"

PRIV_KEY_ADDRESS=$(cast wallet address "$PRIVATE_KEY_PAUSER_WALLET")
echo "Address PauserWallet: $PRIV_KEY_ADDRESS"
echo "Networks will be executed in parallel, therefore the log might appear messy."
echo "Watch out for red and green colored entries as they mark endpoints of each network thread"
echo "A summary will be printed after all jobs/networks have been completed"

# go through all networks and start background tasks for each network (to execute in parallel)
RETURN=0
Expand All @@ -146,6 +198,15 @@ function main {
wait $JOB || RETURN=1
done

echo "-------------------------------------------------------------------------------------"
echo "--------------------------------ALL JOBS DONE----------------------------------------"
echo "-------------------------------------------------------------------------------------"
echo "[info] all jobs completed, now going through all networks again to print their status"
# run through all networks to print a easy-to-read summary
for NETWORK in "${NETWORKS[@]}"; do
printStatus "$NETWORK" &
done

echo "[info] <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< script diamondEMERGENCYPause completed"
}

Expand Down
Loading