You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(kms/auth-eth): migrate from Hardhat to Foundry
Migrates the KMS authorization smart contracts and bootAuth server from
Hardhat to Foundry. The Solidity sources are functionally identical to
master (pragma bumped ^0.8.22 → ^0.8.24 for OpenZeppelin 5.x, forge fmt
applied); the ABI, events, and storage layout are byte-compatible with
the live UUPS proxies on Phala mainnet.
Stack changes:
- Hardhat dependencies and config removed (hardhat.config.ts, typechain
types, jest.integration config, all hardhat-bound .test.ts files,
scripts/{deploy,upgrade,verify}.ts).
- Foundry stack added: foundry.toml, three lib/ submodules pinned at
forge-std v1.9.7, openzeppelin-contracts-upgradeable v5.4.0, and
openzeppelin-foundry-upgrades v0.4.0; a Foundry .t.sol test suite
(46 unit tests covering TCB toggle, factory deploy, upgrade paths,
and storage compatibility from legacy 5-arg initializers); production
deployment / management / query / upgrade scripts under script/.
- BootAuth Fastify server retained byte-identical except src/ethereum.ts,
which swaps typechain for a 4-method hand-written ABI (same struct,
same selectors, functionally identical).
- .openzeppelin/unknown-2035.json (proxy registry for the four live
Phala-mainnet proxies) restored for historical reference.
Operator-script fixes surfaced during a post-rebase audit:
- script/Upgrade.s.sol previously only had UpgradeKmsToV2 /
UpgradeAppToV2 pointing at test-only mock contracts. Added UpgradeKms
/ UpgradeApp scripts that upgrade live proxies to the current
production source.
- script/Manage.s.sol::DeployApp was calling the legacy 5-arg
deployAndRegisterApp, silently forcing requireTcbUpToDate=false. Now
reads REQUIRE_TCB_UP_TO_DATE env var and uses the 6-arg overload to
match master's hardhat-task semantics.
Security hardening:
- Both contracts switched from OwnableUpgradeable to
Ownable2StepUpgradeable. ERC-7201 namespaced storage means no slot
collision on upgrade; transferOwnership now stages a pending owner
who must acceptOwnership, eliminating the typo-bricks-contract risk.
- registerApp's permissionless-by-design intent documented inline in
natspec (any non-zero address can be registered by anyone; the
downstream allowedOsImages whitelist + delegated isAppAllowed gate
authorization).
- Slither static analysis configured in slither.config.json with
per-line suppression comments + justifications on the four
noise-detector hits (factory reentrancy-benign, unused-return on the
named-return forward pattern, two unindexed-event-address for
backward-compatible log indexers). Baseline: 0 findings.
- Inherited Prek hooks (trailing-whitespace, end-of-file-fixer,
shellcheck) cleaned up across the anvil helper scripts that came in
with the original migration.
Verification: forge fmt --check, forge build, forge test --ffi (46/46),
slither (0 findings), npx jest (4/4 server tests), npx tsc --noEmit
all clean.
Note: The auth-api uses `KMS_CONTRACT_ADDR`, while Hardhat tasks use `KMS_CONTRACT_ADDRESS`.
56
-
57
59
The auth-api validates boot requests against the smart contract. See [Deployment Guide](./deployment.md#2-deploy-kms-as-cvm) for complete setup instructions.
0 commit comments