Skip to content

fix: address review findings from #176#179

Merged
lionakhnazarov merged 9 commits into
feat/testnet4-deployment-supportfrom
fix/testnet4-review-followup
May 5, 2026
Merged

fix: address review findings from #176#179
lionakhnazarov merged 9 commits into
feat/testnet4-deployment-supportfrom
fix/testnet4-review-followup

Conversation

@piotr-roslaniec
Copy link
Copy Markdown
Contributor

Summary

Follow-up to #176. Addresses all P1/P2/P3 findings from the multi-agent review.

P1 fixes:

  • deploy/54_upgrade_token_staking_extended.ts: add kind: "transparent" to upgradeProxy call; removes reliance on OZ manifest for proxy-type detection
  • scripts/setup-new-staking-provider.js: chmod 0600 env file after write (private keys were world-readable under default umask)
  • scripts/setup-multiple-operators.sh: replace cast wallet address --private-key "$KEY" with ETH_PRIVATE_KEY="$KEY" cast wallet address to avoid key exposure in process table
  • deployments/mainnet/TokenStaking.json: restore correct 6-param constructor ABI (PR had accidentally replaced it with a 2-param variant, breaking ABI correctness for the deployed mainnet contract)

P2 fixes:

  • Extract shared cast_send_ok with retry/backoff into scripts/lib/cast-helpers.sh; both run-new-operator-setup.sh and setup-multiple-operators.sh source it. Previously run-new-operator-setup.sh had no retry logic.
  • scripts/get-operator-key.js: --list mode now reads the unencrypted address field from keystore JSON directly, instead of attempting decryption with an empty password
  • scripts/fund-new-operator.sh: remove hardcoded fallback T address (0x60185Ef...); fail loudly with an error if T.json is missing; quote all cast send variables
  • deploy/07_deploy_token_staking.ts: remove dual-write to root TokenStaking.json (only write to deployments/<network>/); delete the previously committed root artifact

Also fixed (pre-existing hook findings triggered by touched files):

  • Replace sync fs.*Sync calls with fs.promises in deploy scripts
  • Wrap JSON.parse in try/catch where flagged
  • Replace == with === in network name checks

Test plan

  • CI passes on this branch
  • cast wallet address works with ETH_PRIVATE_KEY env var (Foundry supports it)
  • node scripts/get-operator-key.js --list lists addresses without password errors
  • deployments/mainnet/TokenStaking.json constructor shows 6 params matching the live contract

- Add kind: "transparent" to upgradeProxy call to match upgrade-token-staking.ts
  and eliminate dependency on OZ manifest for proxy-type detection
- Remove unused deployer variable from getNamedAccounts destructuring
- Replace sync fs calls with fs.promises equivalents
- Wrap JSON.parse in try/catch
Plaintext private keys written to .env.operator-N were world-readable
under the default umask. chmod 0600 limits access to the current user.
…ddress

Keys passed via --private-key are visible in /proc/<pid>/cmdline and
ps aux during execution. Use ETH_PRIVATE_KEY env var instead, which
Foundry's cast reads without exposing it in the process table.
The PR introduced a reformatted version that dropped 4 constructor
parameters (_keepStakingContract, _nucypherStakingContract,
_keepVendingMachine, _keepStake), leaving a 2-param ABI that does not
match the deployed contract at 0x01B67b...765dd7. Restore the original
6-param ABI from main so downstream tooling is not broken.
run-new-operator-setup.sh had a cast_send_ok without retry logic;
setup-multiple-operators.sh had one with exponential backoff. Nonce-lag
errors that were handled transparently in the multi-operator script would
fail silently in the single-operator script.

Extract the full retry implementation into scripts/lib/cast-helpers.sh
and source it from both scripts.
--list was calling fromEncryptedJson with an empty password to extract
the address. Keystore JSON contains an unencrypted "address" field;
reading it directly avoids spurious decryption errors for keystores
with real passwords and removes the dependency on the ethers decrypt path.
- Remove hardcoded fallback T token address; fail loudly with a clear
  error if T.json is missing rather than silently using a stale address
- Quote all shell variables in the cast send call to prevent word
  splitting on RPC URLs that include API key query parameters
07_deploy_token_staking.ts was writing to both the root TokenStaking.json
and deployments/<network>/TokenStaking.json. After the upgrade script runs,
only the network-specific file is updated, leaving the root file with a
stale ABI. Write only to deployments/<network>/ and delete the root-level
artifact that was previously committed.

Also fix pre-existing issues in the file: use strict equality, static
import for fs, const for jsonAbi, async fs.promises, and try/catch around
JSON.parse.
…s.sh to use positional arguments for cast wallet address

- Refactored fund-new-operator.sh to utilize cast_send_ok for sending tokens, improving error handling.
- Modified setup-multiple-operators.sh to pass private keys as positional arguments to cast wallet address, addressing security concerns with environment variable exposure.
Copy link
Copy Markdown

@lionakhnazarov lionakhnazarov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

setup-multiple-operators.sh should derive addresses with cast wallet address or --private-key, not ETH_PRIVATE_KEY=… cast wallet address (Foundry doesn’t wire that env for wallet address). - fixed in following commit

except this - LGTM

@lionakhnazarov lionakhnazarov merged commit 3ce2a09 into feat/testnet4-deployment-support May 5, 2026
11 checks passed
@lionakhnazarov lionakhnazarov deleted the fix/testnet4-review-followup branch May 5, 2026 16:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants