-
Notifications
You must be signed in to change notification settings - Fork 7
[BOOST-5517] allow 4byte function selectors in incentive criteria #450
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
base: main
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: 055e8cd The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR 💥 An error occurred when fetching the changed packages and changesets in this PR |
|
1 similar comment
|
WalkthroughPatched incentive payload encoding to pad criteria.signature to 32 bytes, enabling 4‑byte function selectors in ERC20 variable/pegged criteria (V1 and V2). Added tests validating deployment and stored signature format/suffix. Added a changeset to bump @boostxyz/sdk with a patch note. No public APIs changed. Changes
Sequence Diagram(s)sequenceDiagram
participant Dev as SDK caller
participant SDK as SDK Incentive Builder
participant viem as viem.pad
participant Chain as Chain/Contracts
Dev->>SDK: prepare...CriteriaIncentive(V1/V2) with 4-byte selector
SDK->>viem: pad(criteria.signature)
viem-->>SDK: 32-byte padded signature
SDK->>Chain: deploy Boost with encoded criteria (padded signature)
Chain-->>Dev: deployed incentive address
Dev->>Chain: read incentive criteria
Chain-->>Dev: criteria.signature (0x + 64 hex, ends with 4-byte selector)
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10–15 minutes Pre-merge checks (4 passed, 1 warning)❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Poem
Tip 👮 Agentic pre-merge checks are now available in preview!Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.
Example: reviews:
pre_merge_checks:
custom_checks:
- name: "Undocumented Breaking Changes"
mode: "warning"
instructions: |
Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).Please share your feedback with us on this Discord post. ✨ Finishing Touches
🧪 Generate unit tests
Comment |
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.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (3)
packages/sdk/src/Incentives/ERC20VariableCriteriaIncentiveV2.ts (1)
503-509: Only pad for FUNC; avoid silently accepting invalid EVENT signatures.Unconditionally padding
criteria.signaturewill also “accept” 4-byte values for EVENT criteria, which should remain 32-byte topics. That’s a silent correctness footgun vs. prior behavior (which would reject non-32B EVENT signatures). Pad only forSignatureType.FUNCand pass EVENT signatures through unchanged. Also be explicit about pad size/dir for future viem changes.Apply:
- signature: pad(criteria.signature), + signature: + criteria.criteriaType === SignatureType.FUNC + ? pad(criteria.signature, { size: 32, dir: 'left' }) + : criteria.signature,packages/sdk/src/Incentives/ERC20VariableCriteriaIncentive.ts (1)
431-437: Do not pad EVENT signatures; restrict padding to FUNC.Maintain strictness for EVENT topics and pad only FUNC selectors. This restores prior validation behavior and avoids misconfigured criteria slipping through.
- signature: pad(criteria.signature), + signature: + criteria.criteriaType === SignatureType.FUNC + ? pad(criteria.signature, { size: 32, dir: 'left' }) + : criteria.signature,packages/sdk/src/Incentives/ERC20PeggedVariableCriteriaIncentive.ts (1)
846-852: Pad only FUNC selectors; preserve strictness for EVENT topics.Mirrors the required guard in other payload builders.
- signature: pad(criteria.signature), + signature: + criteria.criteriaType === SignatureType.FUNC + ? pad(criteria.signature, { size: 32, dir: 'left' }) + : criteria.signature,
🧹 Nitpick comments (3)
.changeset/chilly-buses-itch.md (1)
1-6: Changeset present and scoped correctly.Patch for @boostxyz/sdk looks good and matches the PR intent. Consider briefly noting “pads 4-byte function selectors to bytes32 in criteria payloads” to make the changelog a touch clearer.
-allow 4-byte function selectors in incentive criteria +Allow 4-byte function selectors in incentive criteria by padding to bytes32 in payloadspackages/sdk/src/Incentives/ERC20VariableCriteriaIncentiveV2.test.ts (1)
275-302: Good coverage for 4-byte selector acceptance.Nice assertions on length (66) and suffix match; this guards the left-pad invariant without over-constraining. You could factor this into a small helper if duplicated elsewhere.
packages/sdk/src/Incentives/ERC20PeggedVariableCriteriaIncentiveV2.test.ts (1)
362-390: Test mirrors non-pegged variant well.Checks are appropriate and keep us honest on the bytes32 padding semantics.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (7)
.changeset/chilly-buses-itch.md(1 hunks)packages/sdk/src/Incentives/ERC20PeggedVariableCriteriaIncentive.ts(2 hunks)packages/sdk/src/Incentives/ERC20PeggedVariableCriteriaIncentiveV2.test.ts(1 hunks)packages/sdk/src/Incentives/ERC20PeggedVariableCriteriaIncentiveV2.ts(2 hunks)packages/sdk/src/Incentives/ERC20VariableCriteriaIncentive.ts(2 hunks)packages/sdk/src/Incentives/ERC20VariableCriteriaIncentiveV2.test.ts(1 hunks)packages/sdk/src/Incentives/ERC20VariableCriteriaIncentiveV2.ts(2 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
packages/sdk/src/Incentives/ERC20PeggedVariableCriteriaIncentiveV2.test.ts (3)
test/src/helpers.ts (1)
freshBoost(123-157)packages/sdk/src/BoostCore.ts (1)
ERC20PeggedVariableCriteriaIncentiveV2(2105-2114)packages/sdk/src/Incentives/ERC20PeggedVariableCriteriaIncentiveV2.ts (1)
ERC20PeggedVariableCriteriaIncentiveV2(147-868)
packages/sdk/src/Incentives/ERC20VariableCriteriaIncentiveV2.test.ts (3)
test/src/helpers.ts (1)
freshBoost(123-157)packages/sdk/src/BoostCore.ts (1)
ERC20VariableCriteriaIncentiveV2(2082-2091)packages/sdk/src/Incentives/ERC20VariableCriteriaIncentiveV2.ts (1)
ERC20VariableCriteriaIncentiveV2(132-418)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: Use Case Tests / Use Case Tests
- GitHub Check: Verify / Verify
- GitHub Check: danger
🔇 Additional comments (4)
packages/sdk/src/Incentives/ERC20VariableCriteriaIncentiveV2.ts (1)
17-17: Import change is fine.Adding
padfrom viem is expected for the new behavior.packages/sdk/src/Incentives/ERC20PeggedVariableCriteriaIncentiveV2.ts (1)
32-32: Import addition looks good.packages/sdk/src/Incentives/ERC20VariableCriteriaIncentive.ts (1)
16-16: Import addition is appropriate.packages/sdk/src/Incentives/ERC20PeggedVariableCriteriaIncentive.ts (1)
32-32: Import addition is fine.
| maxReward, | ||
| criteria: { | ||
| criteriaType: criteria.criteriaType, | ||
| signature: criteria.signature, | ||
| signature: pad(criteria.signature), | ||
| fieldIndex: criteria.fieldIndex, | ||
| targetContract: criteria.targetContract, | ||
| valueType: criteria.valueType, |
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.
🛠️ Refactor suggestion
Guard EVENT topics; pad only FUNC selectors.
Same rationale as the V2 variable file: keep EVENT topics strict 32B; pad 4B only for FUNC. Make pad explicit.
- signature: pad(criteria.signature),
+ signature:
+ criteria.criteriaType === SignatureType.FUNC
+ ? pad(criteria.signature, { size: 32, dir: 'left' })
+ : criteria.signature,📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| maxReward, | |
| criteria: { | |
| criteriaType: criteria.criteriaType, | |
| signature: criteria.signature, | |
| signature: pad(criteria.signature), | |
| fieldIndex: criteria.fieldIndex, | |
| targetContract: criteria.targetContract, | |
| valueType: criteria.valueType, | |
| maxReward, | |
| criteria: { | |
| criteriaType: criteria.criteriaType, | |
| signature: | |
| criteria.criteriaType === SignatureType.FUNC | |
| ? pad(criteria.signature, { size: 32, dir: 'left' }) | |
| : criteria.signature, | |
| fieldIndex: criteria.fieldIndex, | |
| targetContract: criteria.targetContract, | |
| valueType: criteria.valueType, |
Description
Allows for 4-byte function signatures in incentive criteria. This is so it is consistent with the claimant and actionsteps signature which also allows 4-byte format. Anytime a 4-byte function signature is provided, we automatically pad it to the required 32-bytes.
Related PR:
Allow 4-byte signature in claimant and actionsteps: #375
Summary by CodeRabbit
Bug Fixes
Tests
Chores