Skip to content

Commit

Permalink
adds deposit reward
Browse files Browse the repository at this point in the history
  • Loading branch information
claravanstaden committed Oct 23, 2024
1 parent 4b9be93 commit 9d6d13d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
6 changes: 3 additions & 3 deletions bridges/snowbridge/pallets/inbound-queue-v2/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ pub mod pallet {
#[pallet::call_index(0)]
#[pallet::weight(T::WeightInfo::submit())]
pub fn submit(origin: OriginFor<T>, message: Message) -> DispatchResult {
let _who = ensure_signed(origin)?;
let who = ensure_signed(origin)?;
ensure!(!Self::operating_mode().is_halted(), Error::<T>::Halted);

// submit message to verifier for verification
Expand Down Expand Up @@ -228,8 +228,8 @@ pub mod pallet {
Ok(())
})?;

// Todo: Deposit fee(in Ether) to RewardLeger which should cover all of:
// T::RewardLeger::deposit(who, envelope.fee.into())?;
T::RewardLedger::deposit(who, envelope.fee.into())?;
// Fee should cover all of:
// a. The submit extrinsic cost on BH
// b. The delivery cost to AH
// c. The execution cost on AH
Expand Down
10 changes: 6 additions & 4 deletions bridges/snowbridge/pallets/outbound-queue-v2/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@ pub mod pallet {
InvalidGateway,
/// No pending nonce
PendingNonceNotExist,
/// Invalid Relayer Reward Account
InvalidRewardAccount,
}

/// Messages to be committed in the current block. This storage value is killed in
Expand Down Expand Up @@ -311,11 +313,11 @@ pub mod pallet {
ensure!(T::GatewayAddress::get() == envelope.gateway, Error::<T>::InvalidGateway);

let nonce = envelope.nonce;
ensure!(<LockedFee<T>>::contains_key(nonce), Error::<T>::PendingNonceNotExist);

// Todo: Reward relayer
// let locked = <LockedFee<T>>::get(nonce);
// T::RewardLeger::deposit(envelope.reward_address.into(), locked.fee.into())?;
let locked = <LockedFee<T>>::get(nonce).ok_or(Error::<T>::PendingNonceNotExist)?;
let reward_account = T::AccountId::decode(&mut &envelope.reward_address[..]).map_err(|_| Error::<T>::InvalidRewardAccount)?;

T::RewardLedger::deposit(reward_account, locked.fee.into())?;
<LockedFee<T>>::remove(nonce);

Self::deposit_event(Event::MessageDeliveryProofReceived { nonce });
Expand Down

0 comments on commit 9d6d13d

Please sign in to comment.