Skip to content

Clean up feature flags#180

Open
SC4RECOIN wants to merge 2 commits into
mainfrom
remove-old-feature-flags
Open

Clean up feature flags#180
SC4RECOIN wants to merge 2 commits into
mainfrom
remove-old-feature-flags

Conversation

@SC4RECOIN

Copy link
Copy Markdown
Contributor

No description provided.

@SC4RECOIN SC4RECOIN requested review from Oighty and Copilot and removed request for Copilot March 3, 2026 13:27
Copilot AI review requested due to automatic review settings March 3, 2026 13:53

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR cleans up feature-flag usage across the Earn program and related tooling, removing migration-specific code paths and aligning build/config defaults.

Changes:

  • Removed the migrate-gated initialize entrypoint and simplified initialize logic to always use the provided current_index.
  • Updated Earn crate features (removed migrate/devnet/mainnet, cleared default features) and adjusted CI build invocation for Earn.
  • Fixed the CLI’s Portal PDA seed for mint authority from token_authority to authority.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
services/cli/main.ts Updates Portal authority PDA seed used for mint authority derivation.
programs/earn/src/lib.rs Removes migrate-only initialize overload; initialize always takes current_index.
programs/earn/src/instructions/admin/initialize.rs Deletes migrate-only accounts/logic and always updates multiplier from _current_index.
programs/earn/Cargo.toml Removes feature flags and clears default features.
.github/setup/action.yml Updates build steps formatting and builds Earn with explicit testing feature + no defaults.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread programs/earn/Cargo.toml
no-idl = []
no-log-ix-name = []
release = []
testing = []

Copilot AI Mar 3, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR removes the migrate, devnet, and mainnet features and also clears the default feature set. However, the repo still references these features in build tooling (e.g., Makefile builds --features migrate,testing and upgrade targets use --features devnet/mainnet), which will fail with "unknown feature" errors. Please update the build scripts/docs/CI to stop using the removed features (or keep the features until those references are removed).

Suggested change
testing = []
testing = []
migrate = []
devnet = []
mainnet = []

Copilot uses AI. Check for mistakes.
Comment thread .github/setup/action.yml
Comment on lines 66 to 68
- name: Build test programs
run: |
make build-test-earn-programs
run: make build-test-earn-programs
shell: bash

Copilot AI Mar 3, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI still runs make build-test-earn-programs, but that Makefile target currently builds an earn variant with --features migrate,testing. Since this PR removes the migrate feature from programs/earn/Cargo.toml, this step will fail unless the Makefile target (and any related tests expecting the migrate build) is updated accordingly.

Copilot uses AI. Check for mistakes.
Comment on lines 110 to +114
// Verify that the new multiplier is less than or equal to the current index (if migrating) or provided index (if not migrating)
// This is required because the call to our update_multiplier fn will fail silently if the multiplier on the mint is greater.
// That behavior is desired except when initializing the program. Therefore, we catch the error here.
let current_multiplier: f64;
let mint_multiplier: f64 = scaled_ui_config.new_multiplier.into();
cfg_if! {
if #[cfg(feature = "migrate")] {
current_multiplier = self.old_global_account.index as f64 / INDEX_SCALE_F64;
let current_multiplier = _current_index as f64 / INDEX_SCALE_F64;

Copilot AI Mar 3, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment above the multiplier check still references migration logic ("if migrating" / "if not migrating"), but migration support has been removed from this instruction. Please update the comment to match the current behavior (it now always compares against the provided current_index).

Copilot uses AI. Check for mistakes.
Comment thread programs/earn/src/lib.rs
}

#[cfg(not(feature = "migrate"))]
pub fn initialize(ctx: Context<Initialize>, current_index: u64) -> Result<()> {

Copilot AI Mar 3, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

initialize now always requires a current_index argument. There are existing TS callers in the repo (e.g. tests/unit/earn.test.ts) that still call .initialize() with no args, which will break builds/tests once the IDL updates. Either update/remove those callers (and any migration-only flows), or reintroduce a backward-compatible instruction interface (e.g., accept Option<u64> and handle None).

Suggested change
pub fn initialize(ctx: Context<Initialize>, current_index: u64) -> Result<()> {
pub fn initialize(ctx: Context<Initialize>, current_index: Option<u64>) -> Result<()> {
let current_index = current_index.unwrap_or(0);

Copilot uses AI. Check for mistakes.
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