Skip to content

fix(node): write StakeHistoryEntry activating/deactivating to their own fields - #438

Merged
Aursen merged 1 commit into
LiteSVM:masterfrom
ara-stock:fix-stake-history-setters
Oct 26, 2026
Merged

Aursen merged 1 commit into
LiteSVM:masterfrom
ara-stock:fix-stake-history-setters

Conversation

@ara-stock

Copy link
Copy Markdown
Contributor

Problem

In crates/node-litesvm/src/sysvar/stake_history.rs, the activating and deactivating setters on StakeHistoryEntry both assign to self.0.effective. Setting either property from JS overwrites effective and leaves the property you set unchanged:

import { StakeHistoryEntry } from "litesvm";

const entry = new StakeHistoryEntry(1n, 2n, 3n);
entry.activating = 20n;
console.log(entry.effective, entry.activating); // 20n 2n  (expected 1n 20n)
entry.deactivating = 30n;
console.log(entry.effective, entry.deactivating); // 30n 3n (expected 1n 30n)

Fix

Assign self.0.activating and self.0.deactivating in their setters. The constructor doc also named the third parameter effective; it now says deactivating, in both the Rust source and the generated internal.d.ts.

I checked the setters in the other sysvar wrappers (clock, epoch_rewards, epoch_schedule, rent, slot_hashes, slot_history) and in compute_budget.rs. Each one writes its own field.

Test

Added StakeHistoryEntry setters write their own fields to tests/sysvar.test.ts. It sets each field and checks that the other two stay the same.

  • Before the fix, the new test fails: 20n !== 1n, because effective was overwritten by entry.activating = 20n.
  • After the fix, tests/sysvar.test.ts passes 3/3, and the full node suite (tests/*.test.ts) passes 30/30.
  • cargo fmt --check -p litesvm-node and rome check / rome format on the test file report nothing.

I also added an Unreleased/Fixed entry to crates/node-litesvm/CHANGELOG.md.

This change was prepared with AI assistance (Claude) and reviewed before submission.

🤖 Generated with Claude Code

…wn fields

The `activating` and `deactivating` setters assigned to `effective`, so
setting either one from JS overwrote `effective` and left the field being
set unchanged. Also fix the constructor doc that named the third
parameter `effective`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Aursen
Aursen merged commit d453f3a into LiteSVM:master Oct 26, 2026
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants