Skip to content

svm: deregister_transceiver could remove the last transceiver #692

@johnsaigle

Description

@johnsaigle

pub fn deregister_transceiver(ctx: Context<DeregisterTransceiver>) -> Result<()> {
ctx.accounts
.config
.enabled_transceivers
.set(ctx.accounts.registered_transceiver.id, false)?;
// decrement threshold if too high
let num_enabled_transceivers = ctx.accounts.config.enabled_transceivers.len();
if num_enabled_transceivers < ctx.accounts.config.threshold {
// threshold should be at least 1
ctx.accounts.config.threshold = num_enabled_transceivers.max(1);
}
Ok(())
}

deregister_transceiver should revert if there is only one remaining transceiver. Otherwise, an admin could accidentally remove the last one, which would disable the protocol.

See also https://github.com/wormhole-foundation/native-token-transfers/blob/e06ef718b79414b1144ef0ba9d27b73aad9e31c1/docs/INVARIANTS.md#inv-025-minimum-transceiver-requirement

Metadata

Metadata

Assignees

No one assigned

    Labels

    solanaChange to Solana programs

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions