Skip to content

Commit e6e8c72

Browse files
authored
feat(spl): support Rent data_len (#873)
1 parent 796b2d5 commit e6e8c72

2 files changed

Lines changed: 41 additions & 0 deletions

File tree

kmir/src/kmir/kdist/mir-semantics/symbolic/spl-token.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,46 @@ module KMIR-SPL-TOKEN
278278
)
279279
=> dynamicSize(82)
280280
[priority(30)]
281+
282+
// Rent data (&mut [u8]) length hints (Rent::LEN)
283+
rule #maybeDynamicSize(
284+
dynamicSize(_),
285+
SPLDataBuffer(
286+
Aggregate(variantIdx(0),
287+
ListItem(Integer(_, 64, false)) // lamports_per_byte_year
288+
ListItem(Float(2.0, 64)) // exemption_threshold
289+
ListItem(Integer(_, 8, false)) // burn_percent
290+
)
291+
)
292+
)
293+
=> dynamicSize(17)
294+
[priority(30)]
295+
296+
rule #maybeDynamicSize(
297+
dynamicSize(_),
298+
SPLDataBorrow(_, SPLDataBuffer(
299+
Aggregate(variantIdx(0),
300+
ListItem(Integer(_, 64, false))
301+
ListItem(Float(2.0, 64))
302+
ListItem(Integer(_, 8, false))
303+
)
304+
))
305+
)
306+
=> dynamicSize(17)
307+
[priority(30)]
308+
309+
rule #maybeDynamicSize(
310+
dynamicSize(_),
311+
SPLDataBorrowMut(_, SPLDataBuffer(
312+
Aggregate(variantIdx(0),
313+
ListItem(Integer(_, 64, false))
314+
ListItem(Float(2.0, 64))
315+
ListItem(Integer(_, 8, false))
316+
)
317+
))
318+
)
319+
=> dynamicSize(17)
320+
[priority(30)]
281321
```
282322

283323
## Cheatcode handling

kmir/src/tests/integration/data/prove-rs/spl_token_domain_data.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ fn test_spl_rent_domain_data(rent: &AccountInfo<'_>) {
225225
assert!(sysrent.burn_percent > 100 || (sys_burnt <= rent_collected && sys_distributed <= rent_collected));
226226

227227
cheatcode_is_spl_rent(rent);
228+
assert_eq!(rent.data_len(), Rent::LEN);
228229
let prent = Rent::from_account_info(rent).unwrap_or(sysrent);
229230
let (acct_burnt, acct_distributed) = prent.calculate_burn(rent_collected);
230231
assert!(prent.burn_percent > 100 || (acct_burnt <= rent_collected && acct_distributed <= rent_collected));

0 commit comments

Comments
 (0)