Skip to content

Conversation

@ebatsell
Copy link
Collaborator

@ebatsell ebatsell commented Nov 5, 2024

  • Write Integration tests
  • Write unit tests for fees

@ebatsell ebatsell marked this pull request as ready for review November 5, 2024 23:39
}

pub fn seeds() -> Vec<Vec<u8>> {
vec![b"config".to_vec()]
Copy link
Collaborator

Choose a reason for hiding this comment

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

My suggestion, PDA this off of the NCN as well

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 idea if we ever need to switch NCNs

Copy link
Collaborator

Choose a reason for hiding this comment

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

still needs to be addressed

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed seeds, was already changed in other places

/// This is important so all operators calculate the same Merkle root regardless of when fee changes take place.
#[derive(Debug, Clone, Copy, Zeroable, ShankType, Pod)]
#[repr(C)]
pub struct Fees {
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: split out Fee/Fees into a separate file

}
}

pub fn set_new_fees(
Copy link
Collaborator

Choose a reason for hiding this comment

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

It seems that we can update the fees multiple times per epoch. Meaning we won't have consistent fees across epochs.

Also, just a thought on design, thoughts on making the Fee/Fees generic and then we have one Fees for each of our fees - so they can be updated independently?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ah good catch, just fixed the logic so current fees are copied over first and then new fees are applied.

I prefer having it as a single Fee, saves the need for additional epochs to be stored. But small difference either way

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

actually maybe I misunderstood, what's wrong with multiple fee changes per epoch?

load_system_program(system_program)?;

Ncn::load(restaking_program_id.key, ncn_account, false)?;

Copy link
Collaborator

Choose a reason for hiding this comment

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

Check the ncn.ncn_admin is the signer

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Was thinking, is this actually important? NCN admin will have the privileges over the config whether it creates the config or not, so no need to have the extra constraint.
Though in a world where multiple configs can exist maybe we want some restriction?

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 it makes sense for all of the config actions to be permissioned, but that's just my nit

@ebatsell
Copy link
Collaborator Author

ebatsell commented Nov 7, 2024

Still to add: set_new_admin ix, and unit tests

Copy link
Collaborator

@coachchucksol coachchucksol left a comment

Choose a reason for hiding this comment

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

2 changes:

  • ncn_admin should be signer to initialize the NCN config since we can set fees there
  • PDA the ncn config off of the NCN

/// Initialize the global configuration for this NCN
#[account(0, writable, name = "config")]
#[account(1, name = "ncn")]
#[account(2, writable, name = "ncn_admin")]
Copy link
Collaborator

Choose a reason for hiding this comment

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

should make this signer - we're setting fees here

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

was already happening in the instruction, now reflected in this file

}

pub fn seeds() -> Vec<Vec<u8>> {
vec![b"config".to_vec()]
Copy link
Collaborator

Choose a reason for hiding this comment

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

still needs to be addressed


const fn current_fee(&self, current_epoch: u64) -> &Fee {
// If either fee is not yet active, return the other one
if self.fee_1.activation_epoch > current_epoch {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there a way to have both fees 'non-active'?

Copy link
Collaborator

@coachchucksol coachchucksol left a comment

Choose a reason for hiding this comment

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

some nits

@coachchucksol coachchucksol merged commit 27be373 into master Nov 7, 2024
5 checks passed
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