Add invariant tests for spending limits across redelegation chains
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 53/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- solidity
- Lĩnh vực
- blockchain, testing
Hướng nghiên cứu
Read test/DelegationChainWithCaveatsTest.t.sol for existing chain test setup and documents/CaveatEnforcers.md for hook order. The proposed file is test/invariants/RedelegationSpendLimit.invariant.t.sol; begin by tracing how those tests construct links and inspect spentMap. Done means the stated balance, per-link limit, disabled-link, and redelegator-balance properties hold across generated redemption and toggle sequences.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Description
I'd like to add Foundry invariant tests for the amount enforcers when they sit on more than one link of a delegation chain.
The suite has no invariant or fuzz tests today, and the test files for the cumulative enforcers use root delegations only. Limits on a redelegation appear in fixed integration scenarios such as _createAdapterRedelegation in VedaLending.t.sol. A tree of delegations has more states than those reach: siblings sharing a parent's budget, batched redemptions, links disabled and re-enabled between spends.
Technical Details
- One new test file,
test/invariants/RedelegationSpendLimit.invariant.t.sol. No change tosrc/,foundry.tomlor CI; run length is set inline withforge-config. - A handler redeems down a fixed four-link tree, singly and in two-context batches, and disables or re-enables links between calls. Each link carries
ERC20TransferAmountEnforcer, and sibling limits add up to more than their parent's. - Ghost totals per link are compared with
spentMapand token balances after every call.
I have a working draft. On main at b4b8c41 all the properties below hold over 256 runs of 128 calls, in under 20 seconds. To check the tests can fail, I weakened four things in a local copy and each was caught: the enforcer's limit check, storing spent, the disabled-delegation check, and running beforeHook on every link.
Acceptance Criteria
Over any sequence of redemptions, batches and enable or disable calls:
- The root delegator's balance falls by at most the root link's limit.
spentMapfor each link stays within that link's limit.spentMapfor each link equals what left through it, so reverted redemptions count nothing.- Nothing moves through a disabled link.
- Redelegators' balances don't move.
Scenario:
- GIVEN a root link limited to 100, with redelegations to A (60) and B (70)
- WHEN A and B redeem in any order and any amounts
- THEN root pays at most 100, A's path at most 60 and B's at most 70
References
test/DelegationChainWithCaveatsTest.t.sol, the fixed three-level chain with per-call limitsdocuments/CaveatEnforcers.md, hook order across a chain
If this is useful, I'll open the PR against this issue. The native, period and streaming enforcers could follow separately if you want them.
AI use: an AI assistant helped write the tests and this issue; I reviewed both before posting.
- Ngôn ngữ chính
- Solidity
- Star
- 230
- Fork
- 122
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của MetaMask/delegation-framework
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 20/100
MetaMask/delegation-framework#215 ·
-
MultiSigDeleGator: support smart contract accounts as signers (ERC-1271)Có thể đã có người làm @Muhammad-Altabba đã nhận 30 ngày trước. Đang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 18/100
MetaMask/delegation-framework#213 ·
-
ExactCalldataBatchEnforcer should pin terms target and valueCó thể đã có người làm @SashaMIT đã nhận 95 ngày trước. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 74/100
MetaMask/delegation-framework#198 ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
MetaMask/delegation-framework#192 · 1 bình luận ·
-
UKZToken.solĐang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 15/100
MetaMask/delegation-framework#185 ·
Tất cả issue của MetaMask/delegation-framework
Issue tương tự
-
Log filters reject `"fromBlock": null` (and `toBlock`/`blockHash`) instead of treating it as unsetĐang mởL1 rpc-api
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
lambdaclass/ethrex#7530 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 91/100
Maintainer thường phản hồi trong vòng 1 ngày
-
[BUG]: Oracle with rewardBps above 1e5 can never accept a funded price submissionCó thể đã có người làm @kansalakshat đã nhận 1 ngày trước. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
StabilityNexus/OrbOracle-Solidity#27 · 1 bình luận ·
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
LFDT-Lineth/lineth-monorepo#4442 ·
Maintainer thường phản hồi trong vòng 1 ngày