### Define Revenue Distribution Instructions Source: https://github.com/doublezerofoundation/doublezero-solana/blob/main/docs/rfc/0003_BAD_DEBT_RECOVERY_AND_ERRONEOUS_DEBT_ACCOUNTING.md Introduces new instructions and resolution types for managing bad Solana validator debt. ```rust pub enum RevenueDistributionInstructionData { .. ResolveBadSolanaValidatorDebt { amount: u64, proof: MerkleProof, resolution: BadSolanaValidatorDebtResolution }, EnableErroneousSolanaValidatorDebt, .. } pub enum BadSolanaValidatorDebtResolution { #[default] Recover, ReclassifyUnpaid, ReclassifyErroneous, } ``` -------------------------------- ### Build and Test Solana BPF Contracts Source: https://github.com/doublezerofoundation/doublezero-solana/blob/main/README.md Execute these commands in the project root to compile the SBF programs and run the associated integration test suite. ```shell make build-sbf make test-sbf ``` -------------------------------- ### Calculate Total SOL Debt Source: https://github.com/doublezerofoundation/doublezero-solana/blob/main/docs/rfc/0003_BAD_DEBT_RECOVERY_AND_ERRONEOUS_DEBT_ACCOUNTING.md Calculates the total SOL debt by incorporating recovered debt and subtracting uncollectible debt. ```rust pub fn checked_total_sol_debt(&self) -> Option { self.total_solana_validator_debt .saturating_add(self.recovered_sol_debt) .checked_sub(self.uncollectible_sol_debt) } ``` -------------------------------- ### Update Distribution Account Schema Source: https://github.com/doublezerofoundation/doublezero-solana/blob/main/docs/rfc/0003_BAD_DEBT_RECOVERY_AND_ERRONEOUS_DEBT_ACCOUNTING.md Adds fields to the Distribution struct to track recovered SOL debt and erroneous validator debt indices. ```rust pub struct Distribution { .. /// The amount of SOL that was accrued from a past distribution, but was /// written off. This amount is added to the total debt for this /// distribution and acts as a windfall for network contributors. pub recovered_sol_debt: u64, pub erroneous_solana_validator_debt_start_index: u32, pub erroneous_solana_validator_debt_end_index: u32, .. } ``` -------------------------------- ### Calculate Recoverable SOL Debt Source: https://github.com/doublezerofoundation/doublezero-solana/blob/main/docs/rfc/0003_BAD_DEBT_RECOVERY_AND_ERRONEOUS_DEBT_ACCOUNTING.md Calculates the recoverable SOL debt by subtracting recovered and erroneous debt from the written-off debt. ```rust pub fn checked_recoverable_sol_debt(&self) -> Option { self.written_off_sol_debt .saturating_sub(self.recovered_sol_debt) .checked_sub(self.erroneous_sol_debt) } ``` -------------------------------- ### Add Rewards Finalization Check for Token Sweep Source: https://github.com/doublezerofoundation/doublezero-solana/blob/main/docs/rfc/0001_ALLOW_WRITING_OFF_DEBT_FOR_SAME_DISTRIBUTION.md Ensures that the distribution rewards calculation is finalized before allowing tokens to be swept in the `try_sweep_distribution_tokens` processor. This check is necessary to allow time for debt write-offs. ```rust // Make sure the distribution rewards calculation is finalized. if !distribution.is_rewards_calculation_finalized() { msg!("Distribution rewards have not been finalized"); return Err(ProgramError::InvalidAccountData); } ``` -------------------------------- ### Access Solana Validator Deposit Account Source: https://github.com/doublezerofoundation/doublezero-solana/blob/main/docs/rfc/0002_IMPROVED_DEBT_WRITE_OFF_TRACKING.md This Rust snippet demonstrates how to access and read data from a Solana validator deposit account within a program. Ensure the account is correctly passed and mutable if modifications are intended. ```rust let solana_validator_deposit = ZeroCopyMutAccount::::try_next_accounts( &mut accounts_iter, Some(&ID), )?; msg!("Node ID: {}", solana_validator_deposit.node_id); ``` -------------------------------- ### Update Solana Validator Deposit Schema Source: https://github.com/doublezerofoundation/doublezero-solana/blob/main/docs/rfc/0003_BAD_DEBT_RECOVERY_AND_ERRONEOUS_DEBT_ACCOUNTING.md Adds fields to the SolanaValidatorDeposit struct to track recovered and erroneous SOL debt separately. ```rust pub struct SolanaValidatorDeposit { .. /// The amount of SOL that was accrued from a past distribution, but was /// written off. recovered_sol_debt: u64, /// The amount of SOL that was erroneously calculated by the protocol. erroneous_sol_debt: u64, .. } ``` -------------------------------- ### Modify Debt Forgiveness Epoch Check Source: https://github.com/doublezerofoundation/doublezero-solana/blob/main/docs/rfc/0001_ALLOW_WRITING_OFF_DEBT_FOR_SAME_DISTRIBUTION.md Adjusts the epoch check in `try_forgive_solana_validator_debt` to allow the next distribution's epoch to be equal to or greater than the current distribution's epoch. ```rust if next_distribution.dz_epoch < distribution.dz_epoch { msg!("Next distribution's epoch must be at least the epoch of the current distribution"); return Err(ProgramError::InvalidAccountData); } ``` -------------------------------- ### Revenue Distribution Instruction Data Enum Source: https://github.com/doublezerofoundation/doublezero-solana/blob/main/docs/rfc/0002_IMPROVED_DEBT_WRITE_OFF_TRACKING.md This Rust enum defines possible data payloads for revenue distribution instructions. It includes variants for writing off Solana validator debt with amount and proof, and for allowing Solana validator debt write-offs. ```rust pub enum RevenueDistributionInstructionData { .. WriteOffSolanaValidatorDebt { amount: u64, proof: MerkleProof, }, .. } ``` ```rust pub enum RevenueDistributionInstructionData { .. AllowSolanaValidatorDebtWriteOff, .. } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.