-
Notifications
You must be signed in to change notification settings - Fork 43
refactor: Workerize message signing #3376
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
Open
mondoreale
wants to merge
15
commits into
NET-1663-validation
Choose a base branch
from
worker-based-signing
base: NET-1663-validation
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
+515
−63
Conversation
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
…oncerns - SigningService: Container-scoped service that owns the signing worker, provides sign() method, and handles worker lifecycle (lazy init, cleanup) - MessageSigner: Now injects SigningService instead of managing worker directly This decouples the worker management from message signing logic. Each StreamrClient gets its own SigningService instance, with the worker destroyed automatically when the client is destroyed. Test utilities updated with createMessageSigner() helper that uses a mock SigningService (no worker) for faster, simpler tests.
This makes the fake env create clients that share the same signing worker.
Firing up them SigningService instances takes a while in tests.
Transfer signature buffer back to main thread instead of copying, improving performance for large messages.
13dac37 to
3209476
Compare
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.
Summary
Offload message signing to a Web Worker to avoid blocking the main thread during cryptographic operations. This mirrors the existing signature validation workerization pattern.
Changes
SigningServicefromMessageSignerfor clearer separation of concernsSigningWorkerandsigningUtilsfor worker-based signing_nodejs,_browser,_jest,_karma)IdentitywithgetPrivateKey()method to detect workerizable identitiesMessageSignerto use worker when identity provides a private key, falling back to direct signing for ERC-1271WORKERSregistryDestroySignalandSigningServicefrom SDK for external usagecreateMockSigningService()andcreateMessageSigner()test utilitiesSigningServiceinFakeEnvironmentfor test compatibilityLimitations and future improvements
EthereumProviderIdentity) cannot be workerized as they require browser UI interactionNote
Medium Risk
Touches core message signing flow and adds worker lifecycle/build configuration; regressions would affect publishing/signature generation across environments.
Overview
Moves message signing onto a dedicated worker thread via new
SigningService/SigningWorker, withMessageSignerchoosing the worker path when theIdentityexposes a private key (and falling back to direct signing forERC_1271).Adds platform-specific
createSigningWorkerfactories and updates build/test tooling (Rollup worker registry + inlined browser worker bundles, Jest/Karma module mapping, and increased timeouts). Tests are refactored to use new helpers (createMessageSigner/mock signing service),FakeEnvironmentnow registers a sharedSigningService, and the SDK exportsSigningServiceandDestroySignal.Written by Cursor Bugbot for commit 3209476. This will update automatically on new commits. Configure here.