Skip to content

Commit 80bedce

Browse files
authored
feat: sign with legacy accounts via host-papp legacy methods (#22)
1 parent aa16925 commit 80bedce

12 files changed

Lines changed: 467 additions & 160 deletions

File tree

apps/protocol/src/main.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -675,6 +675,7 @@ async function initDirectMode(): Promise<void> {
675675
resolveOwner,
676676
resolveRootManifest,
677677
setResolverAssetHubProvider,
678+
waitForPeopleFinalized,
678679
} = resolve;
679680
const { terminateSmoldot, onSmoldotFatal } = smoldotMod;
680681

@@ -718,6 +719,13 @@ async function initDirectMode(): Promise<void> {
718719
onWarmup: async () => {
719720
getSmoldot();
720721
await getRelayChain();
722+
// Warm People in the background so legacy-account auth reads do not race
723+
// a cold parachain warp sync. Not needed for resolution, so do not await.
724+
void waitForPeopleFinalized().catch((err: unknown) => {
725+
log.warn(
726+
`[dot.li protocol] People chain warm failed (retried on demand): ${String(err)}`,
727+
);
728+
});
721729
},
722730
resolveDotName,
723731
resolveOwner,

apps/protocol/src/protocol-shared-worker.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import {
3030
resolveRootManifest,
3131
setResolverAssetHubProvider,
3232
waitForAssetHubFinalized,
33+
waitForPeopleFinalized,
3334
} from "@dotli/resolver/resolve";
3435
import { onSmoldotFatal } from "@dotli/resolver/smoldot";
3536
import { m } from "@dotli/metrics/metrics";
@@ -214,6 +215,24 @@ async function presync(): Promise<void> {
214215
port.postMessage(readyMsg);
215216
}
216217
pendingPorts.length = 0;
218+
219+
// Warm the People chain in the background. Legacy-account auth reads the
220+
// username -> account map on People, and on a cold start that read races
221+
// the parachain warp sync (the source of the intermittent failures). Start
222+
// syncing it now so it is ready by the time auth runs. People is not needed
223+
// for resolution, so this must not gate the ready signal above.
224+
swLog("Warming People chain in background...");
225+
void waitForPeopleFinalized((msg) => {
226+
swLog(`People warm status: ${msg}`);
227+
})
228+
.then(() => {
229+
swLog("People chain warmed");
230+
})
231+
.catch((err: unknown) => {
232+
swLog(
233+
`People chain warm failed (retried on demand): ${serializeError(err)}`,
234+
);
235+
});
217236
} catch (err: unknown) {
218237
const msg = serializeError(err);
219238
swError(`Pre-sync failed: ${msg}`);

bun.lock

Lines changed: 18 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/auth/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@
2929
"@dotli/resolver": "workspace:*",
3030
"@dotli/shared": "workspace:*",
3131
"@noble/hashes": "^2.2.0",
32-
"@novasamatech/host-api": "0.8.7",
33-
"@novasamatech/host-papp": "0.8.7",
32+
"@novasamatech/host-api": "0.8.8",
33+
"@novasamatech/host-papp": "0.8.8",
3434
"@novasamatech/sdk-statement": "^0.6.0",
35-
"@novasamatech/statement-store": "0.8.7",
36-
"@novasamatech/storage-adapter": "0.8.7",
35+
"@novasamatech/statement-store": "0.8.8",
36+
"@novasamatech/storage-adapter": "0.8.8",
3737
"@scure/sr25519": "^2.2.0",
3838
"neverthrow": "^8.2.0",
3939
"polkadot-api": "^2.1.6",

packages/auth/src/account.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,15 @@ const ss58Codec = AccountId();
5252
export const productPublicKeyToAddress = (publicKey: Uint8Array): string =>
5353
ss58Codec.dec(publicKey);
5454

55+
/**
56+
* Inverse of `productPublicKeyToAddress`: decode an SS58 address string back to
57+
* its 32-byte public key. Used to turn a legacy account's `signer` address
58+
* (the wire format products send) into the `AccountId` bytes host-papp's
59+
* `signRawLegacy` expects. Throws on a malformed address.
60+
*/
61+
export const productAddressToPublicKey = (address: string): Uint8Array =>
62+
ss58Codec.enc(address);
63+
5564
// NOTE: Uncomment when derived product accounts get their own network
5665
// allowance (quota) on People Chain. Currently only the root session account
5766
// has allowance, so createProof signs with the root ssSecret directly.

0 commit comments

Comments
 (0)