Skip to content

Conversation

@mariuszzak
Copy link
Collaborator

@mariuszzak mariuszzak commented Dec 8, 2025

Description

This PR addresses the issues we discovered during the code walk-through session.


Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.

  • Linked to GitHub issue with discussion and accepted design, OR link to spec that describes this work.
  • Wrote unit and integration tests.
  • Added relevant natspec and godoc comments.
  • Provide a conventional commit message to follow the repository standards.
  • Re-reviewed Files changed in the GitHub PR explorer.
  • Review SonarCloud Report in the comment section below once CI passes.

@mariuszzak mariuszzak self-assigned this Dec 8, 2025
@codecov
Copy link

codecov bot commented Dec 8, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.89%. Comparing base (fa1d3fb) to head (68686a5).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #857   +/-   ##
=======================================
  Coverage   99.89%   99.89%           
=======================================
  Files          22       22           
  Lines         982      982           
=======================================
  Hits          981      981           
  Misses          1        1           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mariuszzak mariuszzak marked this pull request as ready for review December 9, 2025 07:35
@mariuszzak mariuszzak requested a review from srdtrk as a code owner December 9, 2025 07:35
Base automatically changed from feat/solana to main December 19, 2025 18:19
@mariuszzak mariuszzak force-pushed the mariuszzak/action_items_part_4 branch from 3f8b62f to 3a500ef Compare December 22, 2025 10:47
Copy link
Collaborator

@cernicc cernicc left a comment

Choose a reason for hiding this comment

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

Added some comments

///
/// Use this for instructions that can be called both directly by users and via CPI from trusted programs.
pub fn validate_direct_or_whitelisted_cpi(
pub fn require_direct_call_or_whitelisted_caller(
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is a better name 👍

pub rent: Sysvar<'info, Rent>,

/// Required by BPF Loader Upgradeable's upgrade instruction
pub clock: Sysvar<'info, Clock>,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we remove the clock account requirement to be consistent with other implementations?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good catch!

The clock sysvar is required by BPF Loader Upgradeable's upgrade instruction. We cannot use Clock::get()? for cpi call here:

    anchor_lang::solana_program::program::invoke_signed(
        &upgrade_ix,
        &[
            ctx.accounts.program_data.to_account_info(),
            ctx.accounts.program.to_account_info(),
            ctx.accounts.buffer.to_account_info(),
            ctx.accounts.spill.to_account_info(),
            ctx.accounts.rent.to_account_info(),
            ctx.accounts.clock.to_account_info(),
            ctx.accounts.upgrade_authority.to_account_info(),
        ],
        &[&[
            AccessManager::UPGRADE_AUTHORITY_SEED,
            target_program.as_ref(),
            &[bump],
        ]],
    )?;

/// Instructions sysvar for CPI validation
/// CHECK: Address constraint verifies this is the instructions sysvar
#[account(address = anchor_lang::solana_program::sysvar::instructions::ID)]
pub instructions_sysvar: AccountInfo<'info>,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it ok if we remove the cpi validation?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, we agreed that we can drop cpi validation in initialize. It would need to be called just between the program deployment and the initialization so it would be very unlikely.

pub mod utils;

// Re-export events for use by instructions
pub use events::{
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think the usage is better if we don't reexport. That way you know immediately what the struct represents.


// Re-export events for use by instructions
pub use events::{
AccessManagerUpdated, AckPacketEvent, ClientAddedEvent, ClientUpdatedEvent, IBCAppAdded,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Some events have Event in the name and some doesn't. Should we unify that and add the Event to the existing ones? Like AccessManagerUpdated -> AccessManagerUpdatedEvent

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good catch! I see that non-prefix version is dominant in our codebase (and consistent with eth implementation). I made such adjustements:


  ics26-router

  | Old Name                  | New Name               |
  |---------------------------|------------------------|
  | SendPacketEvent           | PacketSent             |
  | WriteAcknowledgementEvent | AcknowledgementWritten |
  | AckPacketEvent            | PacketAcknowledged     |
  | TimeoutPacketEvent        | PacketTimedOut         |
  | ClientAddedEvent          | ClientAdded            |
  | ClientUpdatedEvent        | ClientUpdated          |
  | IBCAppAddedEvent          | IBCAppAdded            |
  | NoopEvent                 | Noop                   |
  | AccessManagerUpdatedEvent | AccessManagerUpdated   |

  access-manager

  | Old Name             | New Name        |
  |----------------------|-----------------|
  | RoleGrantedEvent     | RoleGranted     |
  | RoleRevokedEvent     | RoleRevoked     |
  | ProgramUpgradedEvent | ProgramUpgraded |
  | ProgramExtendedEvent | ProgramExtended |

Used past tense for events that would conflict with Accounts struct names (e.g., SendPacket accounts -> PacketSent event).

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.

3 participants