Allow enable-chunking flag to override chunk size limit#78
Conversation
Accept an optional positive-integer byte value on the enable-chunking URL param (e.g. ?enable-chunking=50000) so testers can drive the chunking boundary by hand without governance-changing the chain. Invalid values fall back to the chain config and surface a warning toast. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
✅ Deploy Preview for cosmos-proposal-builder ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Adds support for an optional numeric ?enable-chunking=<bytes> query param to override the chain-configured chunk size limit (while keeping the presence-only ?enable-chunking behavior unchanged), and warns testers when an invalid override value is provided.
Changes:
- Parse
enable-chunkingas either presence-only or a positive-integer byte override. - Emit a
toast.warnwhen an invalid override value is present and fall back to chain config. - Apply the override when computing
chunkSizeLimitfor bundle installation.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if (invalidOverrideRaw === null) return; | ||
| toast.warn( | ||
| `Ignoring invalid enable-chunking value ${JSON.stringify(invalidOverrideRaw)}; ` + | ||
| `expected a positive integer byte count. Falling back to chain config.`, |
There was a problem hiding this comment.
useEffect will run twice in development under React.StrictMode, so this warning toast can appear twice for the same invalid URL value. Consider deduping by providing a stable toastId (or guarding with a useRef flag) so testers only see one warning per page load.
| `expected a positive integer byte count. Falling back to chain config.`, | |
| `expected a positive integer byte count. Falling back to chain config.`, | |
| { | |
| toastId: `agoric-enable-chunking-invalid-${invalidOverrideRaw}`, | |
| }, |
There was a problem hiding this comment.
Good call — added a stable toastId (enable-chunking-invalid-${invalidOverrideRaw}) so StrictMode's double-invoke doesn't double-toast. Pushed in 7f487c2.
| const parsed = Number(raw); | ||
| if (!Number.isInteger(parsed) || parsed <= 0) { | ||
| return { |
There was a problem hiding this comment.
Validation uses Number(raw) + Number.isInteger, which will accept non-decimal forms like 1e3, 0x10, or values with surrounding whitespace. If the intent is a strict positive base-10 byte count (per PR description), validate with a digit-only check (e.g., /^[1-9]\d*$/) before parsing so typos don’t silently become valid overrides.
There was a problem hiding this comment.
All of these forms are acceptable.
| const { enableChunking, chunkSizeOverride, invalidOverrideRaw } = | ||
| useMemo(() => { | ||
| const params = new URLSearchParams(window.location.search); | ||
| if (!params.has("enable-chunking")) { | ||
| return { |
There was a problem hiding this comment.
This PR adds new URL parsing + warning behavior for enable-chunking, but there are no tests covering the override parsing or the invalid-value toast.warn path. Since there is already a src/config/agoric/agoric.spec.tsx, consider adding a test that sets window.location.search (or history.pushState) to an invalid value and asserts the warning fires and chunking falls back to chain config.
There was a problem hiding this comment.
Extracted the parser into an exported pure helper parseEnableChunking(search) and added unit tests in agoric.spec.tsx covering: absent param, valueless presence, valid positive-integer override, and invalid raw values ("0", "-5", "1.5", "abc"). Pushed in 7f487c2.
- Extract URL parsing into exported pure helper parseEnableChunking for testability - Dedupe the invalid-value warning toast with a stable toastId so React.StrictMode does not pop it twice in dev - Add unit tests covering absent / valueless / valid override / invalid override Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- Extract parseEnableChunking + EnableChunkingState into sibling enableChunking.ts so the pure helper does not have to be exported from a component module. - Switch state shape to a discriminated union (disabled / enabled / override / invalid) so impossible combinations like enabled-and-invalid-with-bytes can no longer be represented; consumers branch on .kind. - Replace toastId-based dedupe with a useRef one-shot guard so React.StrictMode's double-invoke cannot pop the warning twice regardless of toastify timing. - Rephrase the warning toast to drop "fall back to chain config" jargon in favor of "Using the chain's chunk_size_limit_bytes instead." - Add spec coverage for leading-`?`-less search strings and repeated occurrences of the param. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Aggregated multi-agent review of d4530bd. Acted on the high-value findings:
Not addressed here, deliberately:
|
pluralizeEn already prefixes the count ("7 transactions"), so prefixing
${txCount} again produced "7 7 transactions" / "6 6 chunks" in the
preflight toast.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Summary
?enable-chunkingURL flag to accept an optional positive-integer byte count (e.g.?enable-chunking=50000) that overrides the chain's configuredchunk_size_limit_bytesfor manual testing.?enable-chunking) is unchanged — still uses the chain config.toast.warnso the tester notices the typo.Test plan
?enable-chunking→ small bundles single-tx, bundles above chain limit chunked.?enable-chunking=10000→ preflight toast reports N chunks ≈ ceil(compressedSize / 10000).?enable-chunking=999999999→ normally-chunked bundle goes single-tx.?enable-chunking=abc/=0/=-5/=1.5→ warning toast on load, behaves as presence-only.🤖 Generated with Claude Code