Skip to content

Commit 114b47a

Browse files
author
Pavel Hornak
committed
fix: correct DefaultStrategy library link + surface deploy errors
The library-link step reused norm() (strips leading zeros) to substitute the deployed AddressSortedLinkedList address into DefaultStrategy's bytecode placeholder. If the library address has a leading zero this produces a wrong-length (malformed) link and the deploy fails - which is what happened on the mainnet attempt. Preserve the full 40-hex address (0x stripped, lowercased, leading zeros kept) and assert no unlinked placeholder remains. Also: deploy() no longer swallows cast stderr - it prints the real error and aborts, so a failed deploy (bad link, gas, or insufficient funds) is diagnosable instead of an empty address.
1 parent d8dc8bc commit 114b47a

1 file changed

Lines changed: 20 additions & 7 deletions

File tree

scripts/release-stuck-withdrawal-fix.sh

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,26 @@ fi
8282

8383
# ---------------------------------------------------------------------------
8484
echo "=== deploying the 4 new implementations ==="
85-
deploy(){ cast send --rpc-url "$RPC" --private-key "$DEPLOY_KEY" $SEND_EXTRA --create "$1" --json 2>/dev/null | jq -r .contractAddress; }
86-
A_IMPL=$(deploy "$(jq -r .bytecode artifacts/contracts/Account.sol/Account.json)")
87-
M_IMPL=$(deploy "$(jq -r .bytecode artifacts/contracts/Manager.sol/Manager.json)")
88-
S_IMPL=$(deploy "$(jq -r .bytecode artifacts/contracts/SpecificGroupStrategy.sol/SpecificGroupStrategy.json)")
89-
LIB=$(deploy "$(jq -r .bytecode artifacts/contracts/common/linkedlists/AddressSortedLinkedList.sol/AddressSortedLinkedList.json)")
90-
DBC=$(jq -r .bytecode artifacts/contracts/DefaultStrategy.sol/DefaultStrategy.json | sed "s/__\$[0-9a-f]*\$__/$(norm "$LIB")/g")
91-
D_IMPL=$(deploy "$DBC")
85+
# Deploy creation bytecode; surface the cast error (and abort) on failure.
86+
deploy(){
87+
local out addr
88+
out=$(cast send --rpc-url "$RPC" --private-key "$DEPLOY_KEY" $SEND_EXTRA --create "$1" --json 2>/tmp/deploy-err.log)
89+
addr=$(echo "$out" | jq -r '.contractAddress // empty' 2>/dev/null)
90+
if [ -z "$addr" ] || [ "$addr" = "null" ]; then
91+
echo "DEPLOY FAILED:" >&2; tail -5 /tmp/deploy-err.log >&2; return 1
92+
fi
93+
echo "$addr"
94+
}
95+
A_IMPL=$(deploy "$(jq -r .bytecode artifacts/contracts/Account.sol/Account.json)") || exit 1
96+
M_IMPL=$(deploy "$(jq -r .bytecode artifacts/contracts/Manager.sol/Manager.json)") || exit 1
97+
S_IMPL=$(deploy "$(jq -r .bytecode artifacts/contracts/SpecificGroupStrategy.sol/SpecificGroupStrategy.json)") || exit 1
98+
LIB=$(deploy "$(jq -r .bytecode artifacts/contracts/common/linkedlists/AddressSortedLinkedList.sol/AddressSortedLinkedList.json)") || exit 1
99+
# Link DefaultStrategy to the deployed library. The placeholder must be replaced
100+
# by the full 40-hex address (lowercased, 0x stripped, LEADING ZEROS PRESERVED).
101+
LIB_HEX=$(echo "${LIB#0x}" | tr 'A-Z' 'a-z')
102+
DBC=$(jq -r .bytecode artifacts/contracts/DefaultStrategy.sol/DefaultStrategy.json | sed "s/__\$[0-9a-f]*\$__/$LIB_HEX/g")
103+
case "$DBC" in *'__$'*) echo "ERROR: DefaultStrategy bytecode still has an unlinked library placeholder" >&2; exit 1;; esac
104+
D_IMPL=$(deploy "$DBC") || exit 1
92105
for v in "$A_IMPL:Account" "$M_IMPL:Manager" "$S_IMPL:SpecificGroupStrategy" "$D_IMPL:DefaultStrategy" "$LIB:AddressSortedLinkedList"; do
93106
[ -n "${v%%:*}" ] && [ "${v%%:*}" != null ] || { echo "deploy failed: ${v##*:}"; exit 1; }
94107
echo " ${v##*:}: ${v%%:*}"

0 commit comments

Comments
 (0)