Repository navigation
feat: move the Lighter signer to web-wasm (ORD-2040) - #617
Open
aaronmboyd wants to merge 4 commits into
Open
aaronmboyd wants to merge 4 commits into
aaronmboyd wants to merge 4 commits into
Conversation
Contributor
|
📦 Preview published under the Install the exact version(s) — npm i @lifi/perps-sdk-provider-hyperliquid@0.0.0-preview-47b7357
npm i @lifi/perps-sdk-provider-lighter@0.0.0-preview-47b7357
npm i @lifi/perps-sdk@0.0.0-preview-47b7357 |
Zeus QA Review — ORD-2040 · #617 · head 47b7357Verdict: ✅ Approve — 0 Critical · 0 High · 0 Medium · 0 Low findings. Route: broad (score 100); focused direct pass of the signer, loader, signActions and build files (no dimension fan-out). SummaryReplaces the vendored Lighter signer binary with a pinned web-wasm build of lighter-go ( Verified
🔵 Notes (not findings)
|
Replace the local go1.23.2 Docker build with the upstream web-wasm/main.wasm from lighter-go v1.0.10 (9d38261). A Docker rebuild with go1.25.6 and the build paths from the binary gives the same sha256 (5372ac1d...bf6b). Update wasm_exec.js to stock go1.25.6 (sha256 0c949f49...a14) to match the toolchain of the binary, and regenerate wasmExecRuntime.ts. Remove signer-wasm.Dockerfile and build-signer-wasm.sh.
Replace Lighter's hand-built web-wasm/main.wasm with a clean build of lighter-go v1.0.10 (9d38261): go1.25.6 in golang:1.25.6-bookworm@sha256:f4490d7b..., from the committed tree, with -trimpath -buildvcs=false -ldflags="-s -w". The binary holds no build paths or git state. Two builds, one from a fresh clone with no cache, give sha256 ad5ca504bc97140a87423b0ef3a8a16fd0497081c88383b36d9552545a996826. wasm_exec.js stays stock go1.25.6.
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.
Closes ORD-2040
Linear: https://linear.app/lifi-linear/issue/ORD-2040
Intent
This PR replaces the vendored Lighter signer binary with a reproducible build of lighter-go
web-wasm/at9d38261(v1.0.10).LighterSignermoves to the web-wasm call shapes, so cancel and modify sign anorder_indexabove 2^53 exactly.What changed
wasm/lighter-signer.wasm: a clean build of lighter-goweb-wasm/at9d38261(approximately 7.5 MB, sha256ad5ca504bc97140a87423b0ef3a8a16fd0497081c88383b36d9552545a996826). The toolchain is go1.25.6, the same as Lighter's own build, ingolang:1.25.6-bookworm@sha256:f4490d7b261d73af4543c46ac6597d7d101b6e1755bcdd8c5159fda7046b6b3e. The build uses the committed tree only and-trimpath -buildvcs=false -ldflags="-s -w", so the binary holds no build paths or git state.wasm/wasm_exec.js: stock go1.25.6 (sha2560c949f4996f9a89698e4b5c586de32249c3b69b7baadb64d220073cc04acba14), to match the toolchain of the binary.src/signers/generated/wasmExecRuntime.tsis regenerated from it.src/signers/wasmLoader.ts:LighterWasmExportstypes the 18_exports.LighterWasmTx,LighterWasmClient,LighterWasmL1Body,LighterWasmAuthToken,LighterWasmErrorandLighterWasmPending.callLighterWasmresolves both return shapes (a function that returns a Promise, or a Promise) and turns{ error }into aPerpsError.globalThis.src/signers/LighterSigner.ts:TX_TYPE_BY_ACTIONgives the tx type.int64StringFieldreadsorder_indexand the other int64 arguments.createSignerSeedmakes a 32-byte seed fromglobalThis.crypto.getRandomValues.createApiKeycalls_createClientand stores0x+prv.ensureClientkeys the per-account WASM client by chain id, api key index, skip-nonce and private key. It creates the client again when one of these changes.dispatchvalidates parameters before it loads WASM and returns a deferred call.getL1Messageand thensignL1Countersigned.embedL1Signatureis deleted.createAuthTokentakes no deadline.src/signers/signActions.ts,src/signers/createAuthToken.ts: the two-step L1 flow, and nolifetimeSeconds.src/LighterProvider.ts: thetokenLifetimeSecondsoption and the signerapiUrlare removed. The standard-token cache expiry uses a 1h constant that matches the Go deadline.src/types/action.ts:order_indexisstring | numberon cancel and modify.src/index.ts: exports the new WASM result types.scripts/verify-package-assets.mjs: the minimum binary size is 5 MB, because the new binary is approximately 7.5 MB.scripts/verify-consumer-bundlers.mjs,test/consumer/probe.js: the probe uses the new export names. The Node targets parse the last stdout line, because the Go runtime writes "Webassembly Started" before the probe result.Assumptions
SignModifyOrdertakes none. The order keeps the integrator fee from create time.fastwithdrawmemo: the reader accepts 32 raw bytes (the backend form), or 32 bytes as 64 hex chars with or without0x. Other values give aValidationError.order_indexabove 2^60-1 fails in Go. The SDK reader accepts the full int64 range, and the Go error surfaces as aPerpsError.web-wasm/main.go, and this PR does not change lighter-go.web-wasm/main.wasm(sha2565372ac1d…bf6b) has the same source and toolchain, but it embeds the build paths and git state of a developer machine. This PR does not ship it. Two builds of the clean binary, one from a fresh clone with no Docker cache, give the same sha256. The build script stays outside this repo. The committed binary is the reviewed artifact.globalThiskeeps the SDK surface to the 18 names that it calls.Tests
New:
src/signers/LighterSigner.legacy.unit.spec.ts+test/legacySignerGolden.ts: for each signed action, the new binary gives the sametxType,txHashandtxInfo(withoutSig) as golden output from the oldwasm/binary at a fixed time, key and nonce. The specs also check that the wallet messages for ChangePubKey, transfer and approve-integrator do not change, that an old-format key loads through_createClientByPrvwith the same public key, and the auth token deadline. Cancel and modify with order index9570149379440277contain that exact index.Edited:
src/signers/LighterSigner.unit.spec.ts:createSignerSeed(32 bytes fromgetRandomValues, a different seed on each call).order_indexacceptance and rejection, memo forms, andgetL1Messagemessages.embedL1Signaturespecs.src/signers/signActions.unit.spec.ts: the stubs use the two-step L1 flow. The ACCOUNT_TYPE token call has no lifetime.src/signers/createAuthToken.unit.spec.ts: the two deadline cases become one case that checks the forwarded context.src/signers/wasmLoader.unit.spec.ts: export names, both return shapes and{ error }mapping.src/signers/wasmExecRuntime.unit.spec.ts: binary size floor.src/LighterProvider.unit.spec.ts: the fake WASM uses web-wasm shapes, andtokenLifetimeSecondsis removed from the option keys.Gates:
pnpm check,pnpm check:types,pnpm build,pnpm test:unit(lighter: 1279 tests pass),pnpm test:consumers(8 consumer toolchains),pnpm knip:check.Follow-ups
Dependencies / upstream branches
feature/ord-2039(ORD-2039, PR 616). This branch builds on it, so the diff shows its commit too. Merge PR 616 first.@lifi/perps-sdk-provider-lighter. A human runs the release after merge.