-
Notifications
You must be signed in to change notification settings - Fork 14
Set Rate Limit Admin #1101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set Rate Limit Admin #1101
Conversation
@@ -187,6 +187,25 @@ impl BaseConfig { | |||
self.can_accept_liquidity = allow; | |||
Ok(()) | |||
} | |||
|
|||
pub fn set_rate_limit_admin(&mut self, new_rate_limit_admin: Pubkey) -> Result<()> { | |||
require_keys_neq!( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this expected?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please add a basic integration test for the new method?
], | ||
bump, | ||
)] | ||
pub state: Account<'info, State>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please also check the state version here (same comment applies to other contexts)
seeds = [POOL_STATE_SEED, mint.key().as_ref()], | ||
bump, | ||
)] | ||
pub state: Account<'info, State>, | ||
#[account(mut, constraint = authority.key() == state.config.owner)] | ||
#[account(mut, constraint = authority.key() == state.config.owner @ CcipTokenPoolError::Unauthorized)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick
#[account(mut, constraint = authority.key() == state.config.owner @ CcipTokenPoolError::Unauthorized)] | |
#[account(mut, address = state.config.owner @ CcipTokenPoolError::Unauthorized)] |
Same comment applies to other address checks
@@ -454,6 +454,56 @@ func TestTokenPool(t *testing.T) { | |||
} | |||
}) | |||
|
|||
t.Run("Rate Limit Admin", func(t *testing.T) { | |||
// set invalid rate limit admin |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix comment plz
|
||
testutils.SendAndConfirm(ctx, t, solanaGoClient, []solana.Instruction{ixRatesValid}, user, config.DefaultCommitment) | ||
|
||
// set invalid rate limit admin |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fix comment plz
).ValidateAndBuild() | ||
require.NoError(t, err) | ||
|
||
testutils.SendAndConfirm(ctx, t, solanaGoClient, []solana.Instruction{ixRateAdmin}, anotherAdmin, config.DefaultCommitment) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a suggestion: Consider packing some of these ixs in a single tx, so that it has fewer side-effects that can break other parallel tests. For example, maybe a single tx could do
- Set user as RL admin
- user sets low RL value
- owner sets back original RL value (or slightly different one even)
Thus, as the tx is atomic, no concurrent test will face issues. And you can check in the intermediate events and in the final state that everything worked as expected.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved, though if you have time to improve the test please do so (see comment)
}, poolConfig, p.Chain[config.EvmChainSelector], user.PublicKey(), solana.SystemProgramID).ValidateAndBuild() | ||
require.NoError(t, err) | ||
|
||
testutils.SendAndFailWith(ctx, t, solanaGoClient, []solana.Instruction{ixRateAdmin, ixRatesValid, ixRateAdmin2, ixRates}, user, config.DefaultCommitment, []string{"SetChainRateLimit"}, common.AddSigners(anotherAdmin)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That []string{"SetChainRateLimit"}
only checks that that string is present in the logs, meaning that it will only check that the method was invoked. It won't enforce that that is the method that's failing, nor which of the two invocations you're making to is the one that fails.
I'll approve the PR anyway as I think this is minor compared to other priorities, but if you have the time to improve this check, please do so 🙂. You could check the events to make sure that the first call to that method did work for example.
)] | ||
pub chain_config: Account<'info, ChainConfig>, | ||
|
||
#[account(mut, constraint = authority.key() == state.config.owner @ CcipTokenPoolError::Unauthorized)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick
#[account(mut, constraint = authority.key() == state.config.owner @ CcipTokenPoolError::Unauthorized)] | |
#[account(mut, address = state.config.owner @ CcipTokenPoolError::Unauthorized)] |
@@ -638,7 +673,21 @@ pub struct EditChainConfig<'info> { | |||
)] | |||
pub chain_config: Account<'info, ChainConfig>, | |||
|
|||
#[account(mut, constraint = authority.key() == state.config.owner || authority.key() == state.config.rate_limit_admin)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for finding this and fixing it 🫶
* Set Rate Limit Admin * Add tests for set rate limit admin * Fix comment in test * Send all instructions in the same transaction * Validate State version * Improve validation
Expose a message to modify the Rate Limit Admin in the Token Pool