Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions solana/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ Transitions to either revoke mutation immediately, including across CPI. Final
writeback can accept a dirty transition without authorizing further writes.

The [account crate](account/README.md) owns those rules and the active/shadow layout.
Dirty markers track data, owner, lamports, slot, mode, and flags; touched flags track
transaction access. Both are caller writeback signals, not persistence operations.
Dirty markers track data, owner, lamports, slot, mode, flags, and commit sequence;
touched flags track transaction access. Both are caller writeback signals, not persistence operations.
Complete-account patches cover non-flag fields, and MagicRoot finalization installs
the complete flags without changing lamports. Source freshness remains the host's
responsibility. `rent_epoch` isn't stored; compatibility APIs return a masked value
Expand Down
2 changes: 1 addition & 1 deletion solana/account/src/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ impl fmt::Debug for AccountSharedData {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
debug_fmt(self, f, |f| {
f.field("slot", &self.slot())
.field("nonce", &self.nonce())
.field("commit_seq", &self.commit_seq())
.field("mode", &self.mode)
.field("flags", self.flags())
.field("dirty", self.markers());
Expand Down
20 changes: 10 additions & 10 deletions solana/account/src/cow/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ pub struct AccountCore {
/// Source slot associated with the latest privileged lifecycle update.
pub(crate) slot: Slot,
/// Number of accepted commit reservations in this delegation session.
pub(crate) nonce: u64,
pub(crate) commit_seq: u32,
/// Classification, ordinary local access, and synchronization policy.
pub(crate) mode: AccountMode,
/// Account state modifier flags.
pub(crate) flags: StateFlags,
/// Reserved bytes that make the serialized representation deterministic.
_padding: [u8; 5],
_padding: [u8; 1],
Comment thread
snawaz marked this conversation as resolved.
Resolved
}

impl Deref for AccountSharedData {
Expand Down Expand Up @@ -124,18 +124,18 @@ impl AccountSharedData {
}

/// Returns the number of accepted commit reservations in this session.
pub fn nonce(&self) -> u64 {
self.nonce
pub fn commit_seq(&self) -> u32 {
self.commit_seq
}

/// Replaces session metadata through the privileged account patch path.
pub(crate) fn set_nonce(&mut self, nonce: u64) {
if self.nonce == nonce {
pub(crate) fn set_commit_seq(&mut self, commit_seq: u32) {
if self.commit_seq == commit_seq {
return;
}
self.translate();
self.dirty.insert(DirtyMarkers::NONCE);
self.nonce = nonce;
self.dirty.insert(DirtyMarkers::COMMIT_SEQ);
self.commit_seq = commit_seq;
}

/// Copies a clean borrowed image into the shadow buffer before mutation.
Expand Down Expand Up @@ -419,8 +419,8 @@ bitflags::bitflags! {
const SLOT = 1 << 4;
/// Data bytes changed.
const DATA = 1 << 5;
/// Commit nonce changed.
const NONCE = 1 << 6;
/// Commit sequence changed.
const COMMIT_SEQ = 1 << 6;
}
}

Expand Down
10 changes: 5 additions & 5 deletions solana/account/src/cow/owned.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ impl OwnedAccount {
}

/// Returns the number of accepted commit reservations in this session.
pub fn nonce(&self) -> u64 {
self.core.nonce
pub fn commit_seq(&self) -> u32 {
self.core.commit_seq
}

/// Returns the account modifier flags.
Expand Down Expand Up @@ -147,10 +147,10 @@ impl AccountBuilder {
self
}

/// Sets the reserved nonce when restoring a delegation session.
/// Sets the reserved commit sequence when restoring a delegation session.
/// Fresh sessions leave this at its default of zero.
pub fn nonce(mut self, nonce: u64) -> Self {
self.0.core.nonce = nonce;
pub fn commit_seq(mut self, commit_seq: u32) -> Self {
self.0.core.commit_seq = commit_seq;
self
}

Expand Down
12 changes: 6 additions & 6 deletions solana/account/src/patch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ pub enum AccountFieldPatch {
},
/// Resizes the data buffer to an exact length, zero-filling when growing.
DataLen(usize),
/// Replaces the session's reserved commit nonce.
/// Replaces the session's reserved commit sequence.
/// Scheduling must check advancement; session synchronization must establish
/// freshness and use a complete-image comparison when replacing live state.
Nonce(u64),
CommitSeq(u32),
}

impl AccountFieldPatch {
Expand All @@ -71,13 +71,13 @@ impl AccountFieldPatch {
Self::Lifecycle { mode, slot } => return account.set_lifecycle(mode, slot),
Self::DataAt { offset, data } => account.set_data_at(offset, &data),
Self::DataLen(len) => account.resize(len, 0),
Self::Nonce(nonce) => account.set_nonce(nonce),
Self::CommitSeq(commit_seq) => account.set_commit_seq(commit_seq),
}
Ok(())
}

/// Decomposes an owned account into the ordered sequence of patches that
/// reconstruct its non-flag fields: lamports, lifecycle, nonce, owner, the exact
/// reconstruct its non-flag fields: lamports, lifecycle, commit sequence, owner, the exact
/// data length, then the data in `MAX_DATA_CHUNK_SIZE`-sized chunks.
pub fn sequence(account: OwnedAccount) -> Vec<Self> {
let chunks = account.data.chunks(MAX_DATA_CHUNK_SIZE);
Expand All @@ -88,7 +88,7 @@ impl AccountFieldPatch {
mode: account.core.mode,
slot: account.core.slot,
},
Self::Nonce(account.core.nonce),
Self::CommitSeq(account.core.commit_seq),
Self::Owner(account.core.owner),
Self::DataLen(account.data.len()),
]);
Expand All @@ -110,7 +110,7 @@ impl fmt::Debug for AccountFieldPatch {
Self::Lifecycle { mode, slot } => write!(f, "lifecycle={mode:?}@{slot}"),
Self::DataAt { offset, data } => write!(f, "data@{offset}+{}", data.len()),
Self::DataLen(len) => write!(f, "data_len={len}"),
Self::Nonce(nonce) => write!(f, "nonce={nonce}"),
Self::CommitSeq(commit_seq) => write!(f, "commit_seq={commit_seq}"),
}
}
}
8 changes: 4 additions & 4 deletions solana/account/src/tests/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,14 +290,14 @@ fn test_mode_layout_and_decoding() {

assert_eq!(size_of::<Mode>(), 2);
assert_eq!(align_of::<Mode>(), 2);
assert_eq!(size_of::<AccountCore>(), 64);
assert_eq!(size_of::<AccountCore>(), 56);
assert_eq!(align_of::<AccountCore>(), 8);
assert_eq!(offset_of!(AccountCore, lamports), 0);
assert_eq!(offset_of!(AccountCore, owner), 8);
assert_eq!(offset_of!(AccountCore, slot), 40);
assert_eq!(offset_of!(AccountCore, nonce), 48);
assert_eq!(offset_of!(AccountCore, mode), 56);
assert_eq!(offset_of!(AccountCore, flags), 58);
assert_eq!(offset_of!(AccountCore, commit_seq), 48);
assert_eq!(offset_of!(AccountCore, mode), 52);
assert_eq!(offset_of!(AccountCore, flags), 54);

let cases = [
(Mode::Missing, [0, 4], None),
Expand Down
Loading