Fix resumed lazy deploys missing eSIMs, and add a large lazy-history user flow test - #41
Merged
Merged
Conversation
…device One of the moved eSIMs is the lazy one with the longest history, which must travel with it intact.
Each step prints the transactions it sends and the eSIMs and bundles they add or move. USDCt is the settlement token on Base Sepolia.
A resumed deploy returned only the wallets from its own batches, and an empty list when everything had already landed. A caller copying history from the result then skipped the eSIMs an earlier call deployed, leaving their purchases blocked. The wallets from earlier calls are now read back from the lazy registry. batches still holds only what this call sent.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this does
Two things:
HistoryNotFullyCopied.The bug
admin.lazyWalletRegistry.deployLazyWalletAndSetESIMIdentifierdeploys a device wallet and all its eSIM wallets, in several transactions when needed. If a run stops partway, for example after an RPC timeout or a crash, calling it again picks up where it left off.Before this change, the resumed call's
eSIMWalletsandeSIMIdentifiersonly listed what that call deployed:alreadyComplete: true.Kokio-BFF's deployment job stores this result and uses it to copy each eSIM's history and to save the wallet addresses. Nothing else rebuilds the list. On a fork, a 12 eSIM device resumed after its first batch returned 2 identifiers, and 10 eSIMs were left with their history never copied.
The fix
eSIMWalletsandeSIMIdentifiersnow always list every eSIM wallet the device has, in deploy order. On a resume, the earlier ones are read back from the lazy registry.batchesstill lists only the transactions this call sent.Kokio-BFF needs no code change. It gets the fix when it upgrades to 3.2.1 (it pins 3.1.0 today).
New test: a user with 88 purchases signs up
tests/consumer/lazyWalletDeploy.fork.test.ts, on a Base Sepolia fork with a local bundler and paymaster:Each step logs the transactions it sends and the eSIMs and bundles it adds or moves. To see the logs:
npm run build && INTEGRATION=1 npx vitest run tests/consumer/lazyWalletDeploy.fork.test.ts --no-file-parallelism --reporter=verbosePurchases in this flow pay in USDCt, the settlement token on Base Sepolia.
Other changes
tests/consumer/fixtures/forkFlowTarget.ts.docs/admin/lazy-wallet-registry.mdand theLazyDeploymenttype describe the new result.tests/README.mddescribes the new flow.Compatibility
deployLazyWalletAndSetESIMIdentifiernow returns more entries on a resume than before. Any caller that relied on it returning only newly deployed wallets should readbatchesinstead. Kokio-BFF is the only known caller, and it needs the full list.Tests
Version
3.2.0 to 3.2.1