-
Notifications
You must be signed in to change notification settings - Fork 8
fix: three pre-mainnet blockers — write-route 500 crashes (#306/#787) + public-CG host-mode ingest (#1124) #1239
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 7 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
218f60f
fix(daemon): reject malformed quads with 4xx instead of 500; guard go…
Bojan131 57d6f29
fix(agent/swm): public CGs reach storage-ACK quorum via host-mode ing…
Bojan131 133bf00
fix(agent/swm): address otReviewAgent #1239 findings (Kye-4 🔴 + Kye_C…
Bojan131 f0c8df8
fix(agent/swm): route public-CG host-mode verification through the sh…
Bojan131 9678a2a
fix(agent/swm): gate self-signed public ingest on OPEN PUBLISH policy…
Bojan131 ece492d
fix(publisher/swm): bind public-CG host-mode entries to a decoded req…
Bojan131 bb19c56
fix(#1124): force-fresh publishPolicy for host-mode admission + demon…
Bojan131 f26fe53
fix(#1124): apply confirmed-public plaintext into _shared_memory so a…
Bojan131 f850ea5
perf(#1124): lazy confirmedPublic + short publishPolicy cache window …
Bojan131 dfe15c0
fix(#1124): open-publish self-signed admission survives a stale allow…
Bojan131 95ce067
fix(#1124): verify public envelopes on host-catchup replay + wire ide…
Bojan131 56d7b38
fix(#1124): reattach SharedMemoryApplyOutcome JSDoc + drive identity …
Bojan131 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| /** | ||
| * GH #787 (regression) — `getWorkspaceGossipSigningAgent` must skip a local key | ||
| * record that has a privateKey but NO valid `agentAddress` (a node-level | ||
| * operational identity, not an agent). Such a record can't be a usable gossip | ||
| * signer: `encodeWorkspaceGossipMessage` emits `agentAddress` into the envelope | ||
| * and the host-mode authority check rejects a missing one. | ||
| * | ||
| * The #306/#787 daemon test exercises only the HTTP quad-shape validation, which | ||
| * now short-circuits at the route boundary BEFORE the signer is selected — so it | ||
| * would NOT catch a revert of this guard. This test drives the signer selection | ||
| * directly: a keyless-agent record placed AHEAD of a valid signer must be | ||
| * skipped (no `toLowerCase()`-of-undefined crash, and not chosen as fallback). | ||
| */ | ||
| import { afterEach, describe, expect, it } from 'vitest'; | ||
| import { ethers } from 'ethers'; | ||
| import { MockChainAdapter } from '@origintrail-official/dkg-chain'; | ||
| import { DKGAgent, agentFromPrivateKey, type AgentKeyRecord } from '../src/index.js'; | ||
|
|
||
| interface Internals { | ||
| localAgents: Map<string, AgentKeyRecord>; | ||
| defaultAgentAddress?: string; | ||
| getWorkspaceGossipSigningAgent(): (AgentKeyRecord & { privateKey: string }) | null; | ||
| encodeWorkspaceGossipMessage(cg: string, msg: Uint8Array): Promise<Uint8Array>; | ||
| } | ||
|
|
||
| function keylessAgentRecord(label: string): AgentKeyRecord { | ||
| const rec = agentFromPrivateKey(ethers.Wallet.createRandom().privateKey, label); | ||
| // A node-level operational key: has a privateKey but no agent identity. | ||
| delete (rec as { agentAddress?: string }).agentAddress; | ||
| return rec; | ||
| } | ||
|
|
||
| describe('GH #787 — gossip signer selection skips keyless-agent records', () => { | ||
| let agent: DKGAgent | null = null; | ||
| afterEach(async () => { if (agent) { await agent.stop().catch(() => {}); agent = null; } }); | ||
|
|
||
| it('keyless record placed FIRST + default match present → returns the valid signer (no throw)', async () => { | ||
| agent = await DKGAgent.create({ name: 'Signer787A', chainAdapter: new MockChainAdapter() }); | ||
| const g = agent as unknown as Internals; | ||
| g.localAgents.clear(); | ||
| const keyless = keylessAgentRecord('node-op'); | ||
| const valid = agentFromPrivateKey(ethers.Wallet.createRandom().privateKey, 'agent'); | ||
| g.localAgents.set('node-op-key', keyless); // FIRST — pre-fix this crashed on `.toLowerCase()` of undefined | ||
| g.localAgents.set(valid.agentAddress, valid); | ||
| g.defaultAgentAddress = valid.agentAddress; | ||
|
|
||
| const signer = g.getWorkspaceGossipSigningAgent(); | ||
| expect(signer).not.toBeNull(); | ||
| expect(signer!.agentAddress).toBe(valid.agentAddress); | ||
| // And signing actually works end to end (a real signed envelope, not a crash | ||
| // or the raw-payload passthrough that happens with no usable signer). | ||
| const env = await g.encodeWorkspaceGossipMessage('cg-787', new TextEncoder().encode('payload')); | ||
| expect(env.length).toBeGreaterThan(64); | ||
| }); | ||
|
|
||
| it('keyless record FIRST + NO default match → falls back to the valid signer (skips the keyless one)', async () => { | ||
| agent = await DKGAgent.create({ name: 'Signer787B', chainAdapter: new MockChainAdapter() }); | ||
| const g = agent as unknown as Internals; | ||
| g.localAgents.clear(); | ||
| g.localAgents.set('node-op-key', keylessAgentRecord('node-op')); | ||
| const valid = agentFromPrivateKey(ethers.Wallet.createRandom().privateKey, 'agent'); | ||
| g.localAgents.set(valid.agentAddress, valid); | ||
| g.defaultAgentAddress = undefined; // no default → exercise fallback selection | ||
|
|
||
| const signer = g.getWorkspaceGossipSigningAgent(); | ||
| expect(signer?.agentAddress).toBe(valid.agentAddress); | ||
| }); | ||
|
|
||
| it('ONLY keyless-agent records → no usable signer (null, no throw)', async () => { | ||
| agent = await DKGAgent.create({ name: 'Signer787C', chainAdapter: new MockChainAdapter() }); | ||
| const g = agent as unknown as Internals; | ||
| g.localAgents.clear(); | ||
| g.localAgents.set('k1', keylessAgentRecord('k1')); | ||
| g.defaultAgentAddress = undefined; | ||
| expect(g.getWorkspaceGossipSigningAgent()).toBeNull(); | ||
| }); | ||
| }); |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.