From 40663f1fbae33f1f8d130243a63cd6e6b8738ebc Mon Sep 17 00:00:00 2001 From: Marvin Jones Date: Fri, 21 Aug 2026 00:20:04 -0400 Subject: [PATCH] chore(lee): remove AccountPostState and its orphaned unit tests (incremental update PR5) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit AccountPostState was the pre-diff-native representation of a program's account output, superseded by AccountDiffOutput. ProgramOutput.post_states has been Vec for a while now, and nothing outside AccountPostState's own definition and its own dedicated unit tests referenced it anymore — confirmed via a repo-wide grep before removal. Drop the struct, its impl block, and the three tests that only existed to exercise its own constructors/getters. Claim stays: it's shared with AccountDiffOutput. Rebuild every guest artifact and the prebuilt sequencer fixture, since lee_core is a dependency of every guest program and this shifts their compiled bytes even though the removed code was functionally dead. --- lee/state_machine/core/src/program/mod.rs | 82 ++------------------- lee/state_machine/core/src/program/tests.rs | 45 ----------- 2 files changed, 6 insertions(+), 121 deletions(-) diff --git a/lee/state_machine/core/src/program/mod.rs b/lee/state_machine/core/src/program/mod.rs index 05b75cce5..ce71d5ca7 100644 --- a/lee/state_machine/core/src/program/mod.rs +++ b/lee/state_machine/core/src/program/mod.rs @@ -284,18 +284,6 @@ impl ChainedCall { } } -/// Represents the final state of an `Account` after a program execution. -/// -/// A post state may optionally request that the executing program -/// becomes the owner of the account (a "claim"). This is used to signal -/// that the program intends to take ownership of the account. -#[derive(Debug, Clone, Serialize, Deserialize)] -#[cfg_attr(any(feature = "host", test), derive(PartialEq, Eq))] -pub struct AccountPostState { - account: Account, - claim: Option, -} - /// A claim request for an account, indicating that the executing program intends to take ownership /// of the account. #[derive( @@ -304,10 +292,10 @@ pub struct AccountPostState { pub enum Claim { /// The program requests ownership of the account which was authorized by the signer. /// - /// Note that it's possible to successfully execute program outputting [`AccountPostState`] with - /// `is_authorized == false` and `claim == Some(Claim::Authorized)`. - /// This will give no error if program had authorization in pre state and may be useful - /// if program decides to give up authorization for a chained call. + /// Note that it's possible to successfully execute a program with `is_authorized == false` + /// and `claim == Some(Claim::Authorized)`. This will give no error if program had + /// authorization in pre state and may be useful if program decides to give up authorization + /// for a chained call. Authorized, /// The program requests ownership of the account through a PDA. The program emits the /// seed; the `AccountId` is derived from `(program_id, seed)`, regardless of whether the @@ -315,64 +303,6 @@ pub enum Claim { Pda(PdaSeed), } -impl AccountPostState { - /// Creates a post state without a claim request. - /// The executing program is not requesting ownership of the account. - #[must_use] - pub const fn new(account: Account) -> Self { - Self { - account, - claim: None, - } - } - - /// Creates a post state that requests ownership of the account. - /// This indicates that the executing program intends to claim the - /// account as its own and is allowed to mutate it. - #[must_use] - pub const fn new_claimed(account: Account, claim: Claim) -> Self { - Self { - account, - claim: Some(claim), - } - } - - /// Creates a post state that requests ownership of the account - /// if the account's program owner is the default program ID. - #[must_use] - pub fn new_claimed_if_default(account: Account, claim: Claim) -> Self { - let is_default_owner = account.program_owner == DEFAULT_PROGRAM_OWNER; - Self { - account, - claim: is_default_owner.then_some(claim), - } - } - - /// Returns whether this post state requires a claim. - #[must_use] - pub const fn required_claim(&self) -> Option { - self.claim - } - - /// Returns the underlying account. - #[must_use] - pub const fn account(&self) -> &Account { - &self.account - } - - /// Returns the underlying account. - #[must_use] - pub const fn account_mut(&mut self) -> &mut Account { - &mut self.account - } - - /// Consumes the post state and returns the underlying account. - #[must_use] - pub fn into_account(self) -> Account { - self.account - } -} - #[derive(Debug, Clone, Serialize, Deserialize, BorshSerialize, BorshDeserialize)] #[cfg_attr(any(feature = "host", test), derive(PartialEq, Eq))] pub struct AccountDiffOutput { @@ -394,8 +324,8 @@ impl AccountDiffOutput { } } - // `AccountDiff` deliberately carries no ownership info, unlike `Account`, so unlike - // `AccountPostState::new_claimed_if_default` this needs the pre-state's owner passed in. + // `AccountDiff` deliberately carries no ownership info, unlike `Account`, so this needs the + // pre-state's owner passed in explicitly. #[must_use] pub fn new_claimed_if_default( diff: AccountDiff, diff --git a/lee/state_machine/core/src/program/tests.rs b/lee/state_machine/core/src/program/tests.rs index 138545d3f..f55527889 100644 --- a/lee/state_machine/core/src/program/tests.rs +++ b/lee/state_machine/core/src/program/tests.rs @@ -129,51 +129,6 @@ fn program_output_try_with_block_validity_window_empty_range_fails() { assert!(result.is_err()); } -#[test] -fn post_state_new_with_claim_constructor() { - let account = Account { - program_owner: [1, 2, 3, 4, 5, 6, 7, 8].into(), - balance: 1337, - data: vec![0xde, 0xad, 0xbe, 0xef].try_into().unwrap(), - nonce: 10_u128.into(), - }; - - let account_post_state = AccountPostState::new_claimed(account.clone(), Claim::Authorized); - - assert_eq!(account, account_post_state.account); - assert_eq!(account_post_state.required_claim(), Some(Claim::Authorized)); -} - -#[test] -fn post_state_new_without_claim_constructor() { - let account = Account { - program_owner: [1, 2, 3, 4, 5, 6, 7, 8].into(), - balance: 1337, - data: vec![0xde, 0xad, 0xbe, 0xef].try_into().unwrap(), - nonce: 10_u128.into(), - }; - - let account_post_state = AccountPostState::new(account.clone()); - - assert_eq!(account, account_post_state.account); - assert!(account_post_state.required_claim().is_none()); -} - -#[test] -fn post_state_account_getter() { - let mut account = Account { - program_owner: [1, 2, 3, 4, 5, 6, 7, 8].into(), - balance: 1337, - data: vec![0xde, 0xad, 0xbe, 0xef].try_into().unwrap(), - nonce: 10_u128.into(), - }; - - let mut account_post_state = AccountPostState::new(account.clone()); - - assert_eq!(account_post_state.account(), &account); - assert_eq!(account_post_state.account_mut(), &mut account); -} - // ---- AccountId::for_private_pda tests ---- /// Pins `AccountId::for_private_pda` against a hardcoded expected output for a specific