Skip to content

IBC refunds trigger deposit per-epoch limits #4938

@sug0

Description

@sug0

In ibc-rs, this is the logic that handles refunds:

pub fn refund_packet_token_execute(
    ctx_a: &mut impl TokenTransferExecutionContext,
    packet: &Packet,
    data: &PacketData,
) -> Result<(), TokenTransferError> {
    let sender = ctx_a.sender_account(&data.sender)?;

    if is_sender_chain_source(
        packet.port_id_on_a.clone(),
        packet.chan_id_on_a.clone(),
        &data.token.denom,
    ) {
        ctx_a.unescrow_coins_execute(
            &sender,
            &packet.port_id_on_a,
            &packet.chan_id_on_a,
            &data.token,
        )?;
    }
    // mint vouchers back to sender
    else {
        ctx_a.mint_coins_execute(&sender, &data.token)?;
    }

    Ok(())
}

Our unescrow_coins_execute and mint_coins_execute handlers invoke TokenTransferContext::add_deposit, which increments the per-epoch deposit limit. This means that refunds may fail.

We should distinguish between refunds and actual deposits, when updating the per-epoch deposit limits.

Metadata

Metadata

Assignees

Labels

IBCbugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions