Skip to content

fix(deploy): persist session key only after map_account confirms on chain (#94)#106

Merged
EnderOfWorlds007 merged 1 commit into
mainfrom
fix/session-persist-after-map
May 3, 2026
Merged

fix(deploy): persist session key only after map_account confirms on chain (#94)#106
EnderOfWorlds007 merged 1 commit into
mainfrom
fix/session-persist-after-map

Conversation

@EnderOfWorlds007

Copy link
Copy Markdown
Collaborator

Closes #94.

Bug

Session-key creation writes to accounts.json BEFORE the on-chain map_account extrinsic is confirmed. If map_account fails (race-induced Stale nonce, network blip, etc), the local file says "key created" but the chain has no mapping. Retries find the existing key (created=false), skip the mapping step, and dry-run fails with Revive::AccountUnmapped.

Fix

Split create-from-or-load-disk from persist-to-disk. The deploy flow now:

  1. getOrCreateSessionAccount — returns key (created in-memory if new, loaded from disk if existing). Does NOT write to disk.
  2. If created: map_account extrinsic — fail loudly here if anything goes wrong, no on-disk side effect.
  3. persistSessionAccount — write to disk only AFTER mapping confirmed.

Failures between (1) and (3) leave the on-disk state untouched, so retries treat it as a fresh create and re-map.

Implementation notes

  • InMemoryKvStore added to session-account.ts to back SessionKeyManager.create() without touching the filesystem.
  • persistSessionAccount(info) exported from session-account.ts — writes the mnemonic under the "default" key, same shape as before.
  • run.ts updated: persistSessionAccount called immediately after submitAndWatch(map_account()) returns, inside the if (created) branch.
  • Direct migration — only one real caller (run.ts); no back-compat wrapper needed.

Test plan

  • getOrCreateSessionAccount fresh call: valid key returned, file absent
  • getOrCreateSessionAccountpersistSessionAccount: file written with correct mnemonic
  • getOrCreateSessionAccount after persist: created=false, same mnemonic loaded
  • map_account-fails scenario: no persist → retry returns created=true with different key → retry would re-map
  • Garbage-in-store scenario: fresh key minted, garbage file not overwritten
  • All 450 existing unit tests pass

@github-actions

github-actions Bot commented May 3, 2026

Copy link
Copy Markdown
Contributor

Dev build ready — try this branch:

curl -fsSL https://raw.githubusercontent.com/paritytech/playground-cli/main/install.sh | VERSION=dev/fix/session-persist-after-map bash

@github-actions

github-actions Bot commented May 3, 2026

Copy link
Copy Markdown
Contributor

E2E Test Pass · ✅ PASS

Tag: e2e-ci-pr · Branch: fix/session-persist-after-map · Commit: 00a7bb1 · Run logs

Cell Result Time
pr-deploy-foundry ✅ PASS 2m30s
pr-install ✅ PASS 0m37s
pr-deploy-frontend ✅ PASS 6m45s
pr-init-session ✅ PASS 1m22s
pr-preflight ✅ PASS 2m14s
pr-mod ✅ PASS 1m19s
${{ matrix.cell }} ⏭️ SKIP 0m00s
${{ matrix.cell }} ⏭️ SKIP 0m00s

Sentry traces: view spans for this run

@EnderOfWorlds007 EnderOfWorlds007 merged commit b9044f0 into main May 3, 2026
17 checks passed
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.

nightly-deploy-hardhat fails with Revive::AccountUnmapped

1 participant