datahaven/.github/workflows
Ahmad Kaouk da2847bbbf
test: Add storage layout checks for upgradeable contracts (#420)
## Summary

Implements storage layout testing for the upgradeable
`DataHavenServiceManager` contract to prevent state
   corruption during proxy upgrades.

  ## Changes

  ### New Files
- **`contracts/storage-snapshots/DataHavenServiceManager.storage.json`**
- Baseline storage layout
  snapshot
- **`contracts/storage-snapshots/README.md`** - Documentation for
updating snapshots and known
  limitations
- **`contracts/scripts/check-storage-layout.sh`** - CI script that
compares current layout against
  snapshot
- **`contracts/test/storage/StorageLayout.t.sol`** - Upgrade simulation
tests verifying state
  preservation
- **`.github/workflows/task-storage-layout.yml`** - CI workflow for
storage layout checks

  ### Modified Files
- **`.github/workflows/CI.yml`** - Added `storage-layout` job to run in
parallel with other checks

  ## How It Works

  **Two-pronged approach:**

1. **Snapshot Diff** - Compares current storage layout against committed
snapshot using `forge inspect`.
Catches unintended variable reordering, type changes, or gap
modifications.

2. **Upgrade Simulation** - Foundry tests that populate state, perform a
proxy upgrade, and verify all
  values survive:
     - `test_upgradePreservesState` - Verifies core state variables
- `test_upgradePreservesValidatorMappings` - Verifies
`validatorEthAddressToSolochainAddress` mapping
- `test_upgradePreservesMultipleValidators` - Verifies
`validatorsAllowlist` with multiple entries
- `test_functionalityAfterUpgrade` - Verifies contract remains
functional post-upgrade

  ## Normalization

  The snapshot comparison normalizes JSON to avoid false positives:
  - Removes `astId` (changes with compiler runs)
  - Removes `contract` (contains full file path)
- Removes `.types` section (contains unstable AST IDs embedded in type
keys)
  - Sorts by slot number

  ## Usage

  ```bash
  # Check storage layout against snapshot
  ./scripts/check-storage-layout.sh

  # Run upgrade simulation tests
  forge test --match-contract StorageLayoutTest -vvv

  # Update snapshot (when intentionally changing storage)
  forge inspect DataHavenServiceManager storage --json >
  storage-snapshots/DataHavenServiceManager.storage.json
```
  ## Test Plan

  - ./scripts/check-storage-layout.sh passes
  - forge test --match-contract StorageLayoutTest -vvv passes (4 tests)
  - CI workflow runs successfully
2026-02-05 11:08:35 +00:00
..
actions ci: Add sccache warm-up job for better cache hit rates (#375) 2026-01-08 13:44:45 +01:00
CI.yml test: Add storage layout checks for upgradeable contracts (#420) 2026-02-05 11:08:35 +00:00
enforce-pr-labels.yml ci: Enforce PR labels for breaking changes and auditability (#169) 2025-09-17 14:21:33 +02:00
release.yml fix: 🔨 Add missing 'packages: write' permission for docker-build-release job (#387) 2026-01-09 16:34:44 +01:00
task-build-operator.yml security: 🛡️ Harden GitHub Actions workflows (#349) 2025-12-12 09:52:50 +00:00
task-build-static-operator.yaml feat: add feature to build binary with postgres bundled (#346) 2026-01-06 13:13:25 +00:00
task-check-licenses.yml revert: ♻ Revert Rust toolchain to 1.88.0 (revert PR #362) (#392) 2026-01-14 08:37:27 +01:00
task-check-metadata.yml security: 🛡️ Harden GitHub Actions workflows (#349) 2025-12-12 09:52:50 +00:00
task-docker-ci.yml refactor: Consolidate and optimize Docker image architecture (#233) 2025-10-15 01:33:20 +02:00
task-docker-release.yml security: 🛡️ Harden GitHub Actions workflows (#349) 2025-12-12 09:52:50 +00:00
task-e2e.yml ci: Remove unused Foundry cache steps (#431) 2026-02-05 11:21:02 +01:00
task-foundry-tests.yml ci: Remove unused Foundry cache steps (#431) 2026-02-05 11:21:02 +01:00
task-moonwall-tests.yml security: 🛡️ Harden GitHub Actions workflows (#349) 2025-12-12 09:52:50 +00:00
task-publish-binary.yml security: 🛡️ Harden GitHub Actions workflows (#349) 2025-12-12 09:52:50 +00:00
task-publish-runtime.yml security: 🛡️ Harden GitHub Actions workflows (#349) 2025-12-12 09:52:50 +00:00
task-rust-lint.yml security: 🛡️ Harden GitHub Actions workflows (#349) 2025-12-12 09:52:50 +00:00
task-rust-tests.yml ci: Add sccache warm-up job for better cache hit rates (#375) 2026-01-08 13:44:45 +01:00
task-storage-layout.yml test: Add storage layout checks for upgradeable contracts (#420) 2026-02-05 11:08:35 +00:00
task-ts-build.yml security: 🛡️ Harden GitHub Actions workflows (#349) 2025-12-12 09:52:50 +00:00
task-ts-lint.yml security: 🛡️ Harden GitHub Actions workflows (#349) 2025-12-12 09:52:50 +00:00
task-warm-sccache.yml ci: Add sccache warm-up job for better cache hit rates (#375) 2026-01-08 13:44:45 +01:00
weekly-audit.yml security: 🛡️ Harden GitHub Actions workflows (#349) 2025-12-12 09:52:50 +00:00