Skip to content

Commit

Permalink
fix(withdrawer): support withdrawer address that differs from bridge …
Browse files Browse the repository at this point in the history
…address (#1262)

## Summary
specify bridge address in withdrawer actions so that the actions will
still be accepted by the sequencer even if the withdrawer address for
the account is different than the bridge address (assuming the
withdrawer signer is the correct key ofc)

## Background
we want to support withdrawer addresses that differ from bridge
addresses

## Changes
- specify bridge address in withdrawer actions

## Testing
unit tests

## Related Issues

closes #1241
  • Loading branch information
noot committed Jul 11, 2024
1 parent 5757558 commit 0684117
Showing 1 changed file with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ pub(crate) fn event_to_action(
event_with_metadata.transaction_hash,
fee_asset,
asset_withdrawal_divisor,
bridge_address,
)
.wrap_err("failed to convert sequencer withdrawal event to action")?,
WithdrawalEvent::Ics20(event) => event_to_ics20_withdrawal(
Expand All @@ -88,6 +89,7 @@ fn event_to_bridge_unlock(
transaction_hash: TxHash,
fee_asset: asset::Denom,
asset_withdrawal_divisor: u128,
bridge_address: Address,
) -> eyre::Result<Action> {
let memo = bridge::UnlockMemo {
// XXX: The documentation mentions that the ethers U64 type will panic if it cannot be
Expand All @@ -110,7 +112,7 @@ fn event_to_bridge_unlock(
))?,
memo: serde_json::to_string(&memo).wrap_err("failed to serialize memo to json")?,
fee_asset,
bridge_address: None,
bridge_address: Some(bridge_address),
};

Ok(Action::BridgeUnlock(action))
Expand Down Expand Up @@ -176,7 +178,7 @@ fn event_to_ics20_withdrawal(
source_channel: channel
.parse()
.wrap_err("failed to parse channel from denom")?,
bridge_address: None,
bridge_address: Some(bridge_address),
};
Ok(Action::Ics20Withdrawal(action))
}
Expand Down Expand Up @@ -212,12 +214,13 @@ mod tests {
block_number: 1.into(),
transaction_hash: [2u8; 32].into(),
};
let bridge_address = crate::astria_address([99u8; 20]);
let action = event_to_action(
event_with_meta,
denom.clone(),
denom.clone(),
1,
crate::astria_address([99u8; 20]),
bridge_address,
crate::ASTRIA_ADDRESS_PREFIX,
)
.unwrap();
Expand All @@ -234,7 +237,7 @@ mod tests {
})
.unwrap(),
fee_asset: denom,
bridge_address: None,
bridge_address: Some(bridge_address),
};

assert_eq!(action, expected_action);
Expand All @@ -253,12 +256,13 @@ mod tests {
transaction_hash: [2u8; 32].into(),
};
let divisor = 10;
let bridge_address = crate::astria_address([99u8; 20]);
let action = event_to_action(
event_with_meta,
denom.clone(),
denom.clone(),
divisor,
crate::astria_address([99u8; 20]),
bridge_address,
crate::ASTRIA_ADDRESS_PREFIX,
)
.unwrap();
Expand All @@ -275,7 +279,7 @@ mod tests {
})
.unwrap(),
fee_asset: denom,
bridge_address: None,
bridge_address: Some(bridge_address),
};

assert_eq!(action, expected_action);
Expand Down Expand Up @@ -330,7 +334,7 @@ mod tests {
timeout_height: IbcHeight::new(u64::MAX, u64::MAX).unwrap(),
timeout_time: 0, // zero this for testing
source_channel: "channel-0".parse().unwrap(),
bridge_address: None,
bridge_address: Some(bridge_address),
};
assert_eq!(action, expected_action);
}
Expand Down

0 comments on commit 0684117

Please sign in to comment.