Skip to content

Fix demo workflows: bootstrap hardhat owner-matrix addresses in CI#3840

Open
MontrealAI wants to merge 1 commit into
mainfrom
codex/fix-demo-workflows-by-bootstrapping-addresses
Open

Fix demo workflows: bootstrap hardhat owner-matrix addresses in CI#3840
MontrealAI wants to merge 1 commit into
mainfrom
codex/fix-demo-workflows-by-bootstrapping-addresses

Conversation

@MontrealAI
Copy link
Copy Markdown
Owner

Motivation

  • CI demo runs were failing during the Owner parameter matrix step because taxPolicy and rewardEngine addresses were resolving to the zero address when the local demo address book was absent.
  • The intent is to ensure Hardhat demo bootstrapping runs deterministically in CI so owner-parameter validation sees non-zero addresses, without weakening production validations.
  • Bootstrapping should remain hardhat/local-only and deterministic (no secrets, deploy minimal mocks), and should not commit ephemeral addresses into persistent config.
  • A minimal, centralized change is preferred so all demo scripts benefit and regressions are covered by tests.

Description

  • Detect CI and enable the existing hardhat demo bootstrap in prepareDemoOverrides by setting bootstrapEnabled = shouldBootstrapDemo() || process.env.CI === 'true' and use that flag to run runDemoBootstrap.
  • Leave validation logic intact; the change only enables the existing Hardhat bootstrap path in CI when overrides are missing.
  • Add a unit test case that simulates CI (process.env.CI = 'true') to verify the bootstrap path is invoked and writes demo overrides, and ensure test suite restores the original CI environment after each test.
  • Changes are limited to scripts/v2/ownerParameterMatrix.ts and scripts/v2/__tests__/ownerParameterMatrix.test.ts.

Testing

  • Updated unit tests: scripts/v2/__tests__/ownerParameterMatrix.test.ts now includes a CI-bootstrap test scenario covering the new behavior. (This test was added/modified in the patch.)
  • Existing unit tests that exercise demo address book derivation and bootstrap behavior were left intact and extended to restore CI env state between tests.
  • No automated test suite was executed as part of this change (tests were not run locally in this patch).
  • The change is strictly hardhat/CI-scoped and does not modify production validation paths; CI workflows should now trigger the deterministic Hardhat bootstrap when address overrides are missing.

Codex Task

addressBook = await deriveDemoAddressBookFromConfigs(network);
}
if (!addressBook && network && LOCAL_NETWORKS.has(network) && shouldBootstrapDemo()) {
if (!addressBook && network && LOCAL_NETWORKS.has(network) && bootstrapEnabled) {

Check warning

Code scanning / CodeQL

Useless conditional Warning

This use of variable 'network' always evaluates to true.

Copilot Autofix

AI 5 months ago

In general, when a condition includes a sub-expression that is provably always true at that program point (e.g., due to prior guards that throw or return in all other cases), you should remove the redundant part and keep only the part that can actually vary. This makes the intent clearer and avoids misleading readers into thinking there is a meaningful runtime check there.

Here, the initial guard:

if (!network || !LOCAL_NETWORKS.has(network)) {
  throw new Error(
    `${DEMO_ADDRESS_BOOK_ENV} is only supported on local hardhat networks`
  );
}

ensures that any subsequent code runs only when network is defined and LOCAL_NETWORKS.has(network) is true. Therefore, the later condition at line 419:

if (!addressBook && network && LOCAL_NETWORKS.has(network) && bootstrapEnabled) {

can be simplified by removing the redundant network && LOCAL_NETWORKS.has(network) check. The behavior is unchanged because those conditions are already guaranteed on all reachable paths. The best minimal fix is to change that if to:

if (!addressBook && bootstrapEnabled) {

No new imports or helper methods are required; we only adjust the conditional expression inside the existing function in scripts/v2/ownerParameterMatrix.ts.

Suggested changeset 1
scripts/v2/ownerParameterMatrix.ts

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/scripts/v2/ownerParameterMatrix.ts b/scripts/v2/ownerParameterMatrix.ts
--- a/scripts/v2/ownerParameterMatrix.ts
+++ b/scripts/v2/ownerParameterMatrix.ts
@@ -416,7 +416,7 @@
   if (!addressBook) {
     addressBook = await deriveDemoAddressBookFromConfigs(network);
   }
-  if (!addressBook && network && LOCAL_NETWORKS.has(network) && bootstrapEnabled) {
+  if (!addressBook && bootstrapEnabled) {
     const bootstrapPath = resolveBootstrapAddressBookPath(network, addressBookPath);
     await runDemoBootstrap(network, bootstrapPath);
     try {
EOF
@@ -416,7 +416,7 @@
if (!addressBook) {
addressBook = await deriveDemoAddressBookFromConfigs(network);
}
if (!addressBook && network && LOCAL_NETWORKS.has(network) && bootstrapEnabled) {
if (!addressBook && bootstrapEnabled) {
const bootstrapPath = resolveBootstrapAddressBookPath(network, addressBookPath);
await runDemoBootstrap(network, bootstrapPath);
try {
Copilot is powered by AI and may make mistakes. Always verify output.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants