Bridge Substrate Pallet
Overview
The Bridge Pallet represents the bridge in XP.network blockchain. It is responsible for communicating the bridge-related events and transactions to the bridge relay validators and submitting the transactions on the XP.network blockchain. It uses the ERC-1155 compatible pallet for operating fungible and non-fungible tokens.
Executing transactions in XP.network
The LocalAction
enum contains the definitions for the local transactions.
#[derive(Encode, Decode, RuntimeDebug, Clone, PartialEq)]
pub enum LocalAction<T: Config> {
...
}
Available local transactions
Unfreezing the locked fungible & non-fungible tokens to a designated account in XP.network
Transfering wrapped foreign fungible & non-fungible tokens
Calling the functions of other smart contracts
Validators related actions
1.Checks whether the transaction was signed by a validator and otherwise returns an error.
#[inline]
fn ensure_validator(acc: &T::AccountId) -> Result<(), Error<T>> {
if !Validators::<T>::contains_key(acc.clone()) {
return Err(Error::<T>::Unauthorized)
}
Ok(())
}
2.Collects the validators' signatures
action.validators.insert(validator);
3.Calculates the BFT threshold
let validator_cnt = ValidatorCnt::<T>::get().unwrap();
if action.validators.len() == ((2./3.)*(validator_cnt as f64)) as usize + 1 {
ret = Ok(true);
}
4.Keeps track of executed transactions by assigning them a number incremented by one to the last executed transactions.
fn action_inc() -> ActionId {
let action = <LastActionId<T>>::get().unwrap();
<LastActionId<T>>::put(action+1);
return action;
}
Last updated
Was this helpful?