Add invariant tests for spending limits across redelegation chains
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 53/100
- Tipo de issue
- Nueva funcionalidad
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- solidity
- Área
- blockchain, testing
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- Solidity
- Estrellas
- 230
- Forks
- 122
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de MetaMask/delegation-framework
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 20/100
MetaMask/delegation-framework#215 ·
-
MultiSigDeleGator: support smart contract accounts as signers (ERC-1271)Posiblemente ocupada @Muhammad-Altabba la tomó hace 30 días. Abierto
Dificultad 5/5 Más de una semana Aptitud para principiantes 18/100
MetaMask/delegation-framework#213 ·
-
ExactCalldataBatchEnforcer should pin terms target and valuePosiblemente ocupada @SashaMIT la tomó hace 95 días. Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 74/100
MetaMask/delegation-framework#198 ·
-
Dificultad 4/5 3-5 días Aptitud para principiantes 45/100
MetaMask/delegation-framework#192 · 1 comentario ·
-
UKZToken.solAbierto
Dificultad 5/5 Más de una semana Aptitud para principiantes 15/100
MetaMask/delegation-framework#185 ·
Todos los issues de MetaMask/delegation-framework
Issues similares
-
Log filters reject `"fromBlock": null` (and `toBlock`/`blockHash`) instead of treating it as unsetAbiertoL1 rpc-api
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
lambdaclass/ethrex#7530 ·
Los mantenedores suelen responder en 2 días
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 91/100
Los mantenedores suelen responder en 1 día
-
[BUG]: Oracle with rewardBps above 1e5 can never accept a funded price submissionPosiblemente ocupada @kansalakshat la tomó hace 1 día. Abiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
StabilityNexus/OrbOracle-Solidity#27 · 1 comentario ·
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
LFDT-Lineth/lineth-monorepo#4442 ·
Los mantenedores suelen responder en 1 día