anza-xyz / anza-xyz/kit

SIMD 194: Deprecate rent exemption_threshold

Open
#1,490 5 comments 0 reactions 1 assignee Claimed by @holps-7 View on GitHub
Dominant language
TypeScript
Stars
695
Forks
210
Avg merge
21h 33m
Merged PRs (30d)
90

Description

## Motivation

[SIMD-0194](https://github.com/solana-foundation/solana-improvement-documents/blob/main/proposals/0194-deprecate-rent-exemption-threshold.md) is now active on mainnet-beta at epoch 943

The kit SDK currently uses the old terminology (`lamportsPerByteYear`, `exemptionThreshold`) and should be updated.

The key changes proposed are:
- **`lamports_per_byte_year`** → renamed to **`lamports_per_byte`** (rent is no longer time-based)
- **`DEFAULT_LAMPORTS_PER_BYTE`** changed from `3480` to `6960` (doubled to absorb the threshold)
- **`exemption_threshold`** set to `1.0` and deprecated from the protocol
- **Minimum balance formula** simplified to `(ACCOUNT_STORAGE_OVERHEAD + data_len) * lamports_per_byte`

The absolute lamports required for rent exemption does **not** change — `3480 * 2 = 6960 * 1`.

## Example use case

After this change, the `SysvarRent` type uses the updated terminology:

```ts
import { fetchSysvarRent } from '@solana/sysvars';

const rent = await fetchSysvarRent(rpc);

// New field name (SIMD-0194)
console.log(rent.lamportsPerByte); // 6960n (Lamports)

// Deprecated — still available for backward compatibility
console.log(rent.lamportsPerByteYear); // same value, marked @deprecated
console.log(rent.exemptionThreshold); // 1.0, marked @deprecated
```

## Details

### Affected packages and files

| Package | File | Change |
|---|---|---|
| `@solana/sysvars` | `src/rent.ts` | Add `lamportsPerByte` to `SysvarRent` type; deprecate `lamportsPerByteYear` and `exemptionThreshold`; update codec field names |
| `@solana/rpc-parsed-types` | `src/sysvar-accounts.ts` | Add `lamportsPerByte` to `JsonParsedRentAccount`; deprecate old fields |
| `@solana/rpc-graphql` | `src/schema/type-defs/account.ts` | Add `lamportsPerByte` field to `SysvarRentAccount` GraphQL type |
| `@solana/kit` | `src/get-minimum-balance-for-rent-exemption.ts` | Update constants to `DEFAULT_LAMPORTS_PER_BYTE: 6960n`, remove threshold multiplier (already deprecated, produces same result) |

### Important considerations

1. **On-chain binary layout is unchanged (17 bytes)** — The current Rust [Rent struct](https://github.com/anza-xyz/solana-sdk/blob/master/rent/src/lib.rs) still occupies the same byte positions:

```rust
pub struct Rent {
pub lamports_per_byte: u64, // 8 bytes (renamed from lamports_per_byte_year)
#[deprecated]
pub exemption_threshold: [u8; 8], // 8 bytes (was f64, now raw bytes — same size)
#[deprecated]
pub burn_percent: u8, // 1 byte
}
```

The `exemption_threshold` field was changed from `f64` to `[u8; 8]` in the Rust source to avoid floating-point operations, but it still occupies the **exact same 8-byte slot**. The SDK stores the known f64 bit patterns as byte-array constants (`1.0f64` = `[0,0,0,0,0,0,240,63]`). Our kit codec decoding it as `f64` will continue to work correctly since the binary representation is identical.

2. **Backward compatibility** — `lamportsPerByteYear` and `exemptionThreshold` should remain as `@deprecated` aliases so existing code continues to compile. They can be removed in the next major version.

3. **No functional change to lamports amounts** — `128 * 3480 * 2 = 128 * 6960 * 1 = 890,880` lamports for a zero-data account. The local `getMinimumBalanceForRentExemption` function will return the same values.

### Questions -

- Should we rename `lamportsPerByteYear` → `lamportsPerByte` as the primary field immediately, keeping the old name as a `@deprecated` alias or remove the deprecated field entirely?
- Should `exemptionThreshold` be removed entirely now or in the next major version (v7)?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.