Skip to content

Commit

Permalink
test: fix rotate signers tests (#421)
Browse files Browse the repository at this point in the history
* test: re-enabled all rotate-signers tests
  • Loading branch information
roberts-pumpurs authored Sep 4, 2024
1 parent dd37ef2 commit ea9a028
Show file tree
Hide file tree
Showing 5 changed files with 107 additions and 66 deletions.
4 changes: 3 additions & 1 deletion solana/programs/gateway/src/axelar_auth_weighted.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ impl AxelarAuthWeighted {
.ok_or(AxelarAuthWeightedError::EpochCalculationOverflow)?
.into();
if elapsed >= self.previous_signers_retention.into() {
msg!("verifier set is too old");
msg!("signing verifier set is too old");
return Err(AxelarAuthWeightedError::InvalidSignerSet);
}

Expand All @@ -125,10 +125,12 @@ impl AxelarAuthWeighted {
) -> Result<VerifierSetTracker, AxelarAuthWeightedError> {
// signers must be sorted binary or alphabetically in lower case
if new_verifier_set.is_empty() {
msg!("No signers in the new set");
return Err(AxelarAuthWeightedError::InvalidSignerSet);
}

if !matches!(new_verifier_set.sufficient_weight(), Some(true)) {
msg!("insufficient weight for the new verifier set");
return Err(AxelarAuthWeightedError::InvalidWeightThreshold);
}

Expand Down
13 changes: 7 additions & 6 deletions solana/programs/gateway/src/instructions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,15 @@ pub enum GatewayInstruction {

/// Rotate signers for the Gateway Root Config PDA account.
///
/// 1. [] Gateway ExecuteData PDA account
/// 2. [] Verifier Setr Tracker PDA account (the one that signed the
/// 0. [] Gateway ExecuteData PDA account
/// 1. [] Verifier Setr Tracker PDA account (the one that signed the
/// ExecuteData)
/// 3. [WRITE, SIGNER] new uninitialized VerifierSetTracker PDA account (the
/// 2. [WRITE, SIGNER] new uninitialized VerifierSetTracker PDA account (the
/// one that needs to be initialized)
/// 4. [WRITE, SIGNER] Funding account for the new VerifierSetTracker PDA
/// 5. [] System Program account
/// 6. Optional: [SIGNER] `Operator` that's stored in the gateway config PDA.
/// 3. [WRITE, SIGNER] Funding account for the new VerifierSetTracker PDA
/// 4. [] System Program account
/// 5. Optional: [SIGNER] `Operator` that's stored in the gateway config
/// PDA.
RotateSigners,

/// Represents the `CallContract` Axelar event.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ impl Processor {
};

// Check: Execute Data account is not initialized.
execute_data_account.check_uninitialized_pda()?;
if let Err(err) = execute_data_account.check_uninitialized_pda() {
msg!("Execute Datat PDA already initialized");
return Err(err);
}
// Check: Execute Data PDA is correctly derived
crate::assert_valid_execute_data_pda(
&execute_data,
Expand Down
5 changes: 4 additions & 1 deletion solana/programs/gateway/tests/module/approve_messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -569,9 +569,10 @@ async fn fail_if_signer_set_epoch_is_older_than_4() {
.await;

// We generate 4 new unique signer sets (not registered yet)
let new_signer_sets = (1..=MAX_ALLOWED_SIGNERS as u128)
let new_signer_sets = (0..MAX_ALLOWED_SIGNERS as u128)
.map(|weight| make_signers(&[55u128, weight], 55 + weight as u64))
.collect::<Vec<_>>();
assert_eq!(MAX_ALLOWED_SIGNERS, new_signer_sets.len());

// Only the latest signer set is allowed to call "rotate signers" ix
// to register the next latest signer set. We iterate over all signer sets,
Expand All @@ -582,6 +583,7 @@ async fn fail_if_signer_set_epoch_is_older_than_4() {
.tuple_windows::<(_, _)>()
.enumerate()
{
dbg!(idx);
let new_epoch = U256::from((idx + 1) as u128);
let root_pda_data = fixture
.get_account::<gmp_gateway::state::GatewayConfig>(&gateway_root_pda, &gmp_gateway::ID)
Expand All @@ -596,6 +598,7 @@ async fn fail_if_signer_set_epoch_is_older_than_4() {
&domain_separator,
)
.await;
dbg!("rotatetd");
}

// Now we have registered 5 sets in total (1 initial signer set + 4 that we
Expand Down
Loading

0 comments on commit ea9a028

Please sign in to comment.