-
Notifications
You must be signed in to change notification settings - Fork 122
feat: Add exclude_function_args parameter to reduce transaction response sizes #2312
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
Conversation
…ints - Add ExcludeFunctionArgsParamSchema to params.ts - Update parseContractCallMetadata to conditionally exclude function_args - Thread excludeFunctionArgs parameter through all parsing functions - Add parameter to transaction list, single tx, multiple tx, and mempool endpoints - Add parameter to address transaction endpoints - Add comprehensive unit tests following the testing strategy - Maintain 100% backward compatibility (defaults to false) - All lint and build checks pass Implements FEAT-FunctionArgsExclusion.md specification.
Vercel deployment URL: https://stacks-blockchain-8wppw7fla-hirosystems.vercel.app 🚀 |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
1be2649
to
14bb7c3
Compare
Default token_transfer_memo builders now default to '0x' (valid bytea hex). Set smartContract.clarity_version to null when undefined. Fixes bytea and UNDEFINED_VALUE errors in exclude_function_args tests.
src/api/controllers/db-controller.ts
Outdated
interface GetTxsArgs { | ||
txIds: string[]; | ||
includeUnanchored: boolean; | ||
excludeFunctionArgs?: boolean; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make these two new args required instead of optional. Set to false whenever you don't have it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
excludeFunctionArgs?: boolean; | |
excludeFunctionArgs: boolean; |
src/api/schemas/params.ts
Outdated
Type.Boolean({ | ||
default: false, | ||
description: | ||
'Exclude function_args from contract call responses for smaller, predictable sizes. Only explicit true/false values are accepted (same pattern as `unanchored`).', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'Exclude function_args from contract call responses for smaller, predictable sizes. Only explicit true/false values are accepted (same pattern as `unanchored`).', | |
'Exclude function_args from contract call responses for smaller transaction sizes.', |
- Param now mandatory; all call sites pass false - Restore CHANGELOG, remove 8.11.0 block only - Shorten schema description - Delete obsolete parse-contract-call-metadata test
With the two most recent commits, we changed:
Touched files:
@rafaelcr , if there is anything else, please let me know. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one last batch of comments but it's looking good!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apologies, I should've explained better how this file works. This file is edited by semantic-release
automatically whenever a new API release is published. As such, it should stay as part of the repository because we want to keep its (automatic) edit history. In other words, the file was deleted with your latest commit but it should still remain in the repo unchanged.
Can you revert this file to how it was before? You can do that with
git checkout develop -- CHANGELOG.md
Sorry for the confusion on this!
src/api/controllers/db-controller.ts
Outdated
interface GetTxsArgs { | ||
txIds: string[]; | ||
includeUnanchored: boolean; | ||
excludeFunctionArgs?: boolean; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
excludeFunctionArgs?: boolean; | |
excludeFunctionArgs: boolean; |
src/api/controllers/db-controller.ts
Outdated
interface GetTxArgs { | ||
txId: string; | ||
includeUnanchored: boolean; | ||
excludeFunctionArgs?: boolean; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
excludeFunctionArgs?: boolean; | |
excludeFunctionArgs: boolean; |
- Restore CHANGELOG.md (auto-generated by semantic-release) - Make excludeFunctionArgs required in GetTxArgs and GetTxsArgs interfaces - Shorten description text in ExcludeFunctionArgsParamSchema - Pass excludeFunctionArgs: false at existing internal call sites and tests (per review guidance)
Hey @rafaelcr - just pushed the final follow-up changes based on your latest review:
About the internal call site updates: When we made excludeFunctionArgs required, TypeScript flagged 13 existing call sites that weren't passing this parameter (they were relying on it being optional). Your comment "Set to false whenever you don't have it" guided us to update these internal calls - they all now explicitly pass excludeFunctionArgs: false to maintain the existing behavior (function args included by default). The affected areas were:
This ensures the new required parameter doesn't break any existing functionality while giving API consumers explicit control over the behavior. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thanks @alexthuth
## [8.12.0](v8.11.6...v8.12.0) (2025-08-06) ### Features * Add exclude_function_args parameter to reduce transaction response sizes ([#2312](#2312)) ([852a60e](852a60e)) * add replaced_by_tx_id to replaced mempool transactions ([#2271](#2271)) ([a70c3d1](a70c3d1)) * **prometheus:** add chain tip metrics ([#2333](#2333)) ([bde1037](bde1037)) * SNP integration ([#2291](#2291)) ([9a159e1](9a159e1)) ### Bug Fixes * drop redundant db indexes ([#2329](#2329)) ([0ddd6a6](0ddd6a6)) * ensure some ops only run when SNP is not enabled ([fd4717b](fd4717b)) * only ingest snp chain events to avoid db bloat ([287f572](287f572)) * optimize queries to prune and restore mempool rbf txs ([#2327](#2327)) ([0b196f0](0b196f0)) * optimize replace-by-fee mempool calculations ([#2326](#2326)) ([01998bc](01998bc)) * parallelize mempool rbf updates ([#2328](#2328)) ([e7347e5](e7347e5)) * update snp image in tests ([c7c0dbb](c7c0dbb))
🎉 This PR is included in version 8.12.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Description
As an API client developer, I want to control the size of transaction responses by excluding function arguments when they are not needed. This is necessary because transaction responses can vary dramatically in size (5KB to 50KB+) due to complex contract function arguments, forcing clients to use conservative pagination and resulting in 3-5x more API calls than optimal.
This pull request adds the
exclude_function_args
query parameter to transaction endpoints. When set totrue
, the API omits thefunction_args
array from contract call transactions, significantly reducing response size while maintaining all other data.What was changed:
ExcludeFunctionArgsParamSchema
parameter schemaparseContractCallMetadata
to conditionally exclude function argsGET /extended/v1/tx
,GET /extended/v1/tx/:tx_id
How this impacts application developers:
false
)Example usage:
For implementation details refer to issue #2310
Type of Change
Does this introduce a breaking change?
No breaking changes. The parameter is optional and defaults to
false
, preserving existing behavior. All existing API calls continue to work identically.Are documentation updates required?
Testing information
Testing is required for this change.
Test coverage includes:
Affected code paths:
parseDbTx
,parseDbMempoolTx
)parseContractCallMetadata
)Testing steps:
npm run test:api
to verify all tests passtrue
Checklist
npm run test
passes