Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
ab37149
enable target_a and _b syncing for sidechain mode and prepare new dem…
brenzi Nov 23, 2023
2ae982d
add shard vault proxy account on target A/B as well. derivation is de…
brenzi Nov 23, 2023
d62b26d
prepare event listener on target A and fix demoscript
brenzi Nov 23, 2023
d9bff04
remove old enclave_bridge unshield call from trusted_call
brenzi Nov 23, 2023
e9c408c
abstracting parentchain effect opaque_calls. stf can send to any pare…
brenzi Nov 23, 2023
ff686b6
sending stf extrinsics to all parentchains now
brenzi Nov 24, 2023
ec5918e
WIP: triggering block import of target_a and b upon sidechain on_slot
brenzi Nov 24, 2023
42b10e7
refactored aura to trigger target_a and target_b import
brenzi Nov 25, 2023
2f12d4b
shielding from target_a worked
brenzi Nov 25, 2023
a62dc20
demo passes first and second rungit add -u!
brenzi Nov 25, 2023
3c5cafc
log cosmetics
brenzi Nov 26, 2023
72f2849
generic event display (fails). log cosmetics
brenzi Nov 27, 2023
30c1ef5
hack the fees. and more pimps
brenzi Nov 27, 2023
c46c67b
recorded demo with this
brenzi Nov 27, 2023
90cb372
fixed cargo test
brenzi Nov 28, 2023
6d97c2a
clippy
brenzi Nov 28, 2023
c47a9c5
fixed enclave tests
brenzi Nov 28, 2023
6eacfd7
cleanup
brenzi Nov 28, 2023
886af3b
Merge branch 'master' into ab/target-a-shielding-unshielding-sidechai…
brenzi Nov 28, 2023
b16439c
fix CI
brenzi Nov 28, 2023
2ea0472
CI: introduce fee tolerance when assering balances
brenzi Nov 28, 2023
13c20f3
fix evm tests
brenzi Nov 28, 2023
20b7468
fix
brenzi Nov 28, 2023
83ee1aa
clippy with test flag
brenzi Nov 28, 2023
39a3147
fix demo_sidechain with fee tolerance
brenzi Nov 28, 2023
a70685d
CI fixes
brenzi Nov 28, 2023
b75036e
review remarks fixed
brenzi Nov 29, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
hack the fees. and more pimps
  • Loading branch information
brenzi committed Nov 27, 2023
commit 30c1ef5073dd7a4a28cb9824491f744a5ddc558c
33 changes: 26 additions & 7 deletions app-libs/stf/src/trusted_call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ use sp_io::hashing::blake2_256;
use sp_runtime::{traits::Verify, MultiAddress, MultiSignature};
use std::{format, prelude::v1::*, sync::Arc};

// fixme: this if a temporary hack only
pub const TX_FEE: Balance = 100000000;

#[derive(Encode, Decode, Clone, Debug, PartialEq, Eq)]
#[allow(non_camel_case_types)]
pub enum TrustedCall {
Expand Down Expand Up @@ -263,12 +266,27 @@ where
TrustedCall::balance_transfer(from, to, value) => {
let origin = ita_sgx_runtime::RuntimeOrigin::signed(from.clone());
std::println!("⣿STF⣿ 🔄 balance_transfer from ⣿⣿⣿ to ⣿⣿⣿ amount ⣿⣿⣿");
let vault_pubkey: [u8; 32] = get_storage_by_key_hash(SHARD_VAULT_KEY.into())
.ok_or_else(|| {
StfError::Dispatch("shard vault key hasn't been set".to_string())
})?;
// fixme: apply fees through standard frame process and tune it
let fee = TX_FEE;
info!(
"from {}, to {}, amount {}",
"from {}, to {}, amount {}, fee {}",
account_id_to_string(&from),
account_id_to_string(&to),
value
value,
fee
);
ita_sgx_runtime::BalancesCall::<Runtime>::transfer {
dest: MultiAddress::Id(vault_pubkey.into()),
value: fee,
}
.dispatch_bypass_filter(origin.clone())
.map_err(|e| {
Self::Error::Dispatch(format!("Balance Transfer error: {:?}", e.error))
})?;
ita_sgx_runtime::BalancesCall::<Runtime>::transfer {
dest: MultiAddress::Id(to),
value,
Expand All @@ -281,11 +299,9 @@ where
},
TrustedCall::balance_unshield(account_incognito, beneficiary, value, shard) => {
std::println!(
"⣿STF⣿ 🛡👐 balance_unshield({}, {}, {}, {})",
account_id_to_string(&account_incognito),
"⣿STF⣿ 🛡👐 balance_unshield to {}, amount {}",
account_id_to_string(&beneficiary),
value,
shard
value
);
info!(
"balance_unshield(from (L2): {}, to (L1): {}, amount {}, shard {})",
Expand Down Expand Up @@ -490,10 +506,13 @@ fn unshield_funds(account: AccountId, amount: u128) -> Result<(), StfError> {
}

fn shield_funds(account: AccountId, amount: u128) -> Result<(), StfError> {
//fixme: make fee configurable and send fee to vault account on L2
let fee = amount / 100;

let account_info = System::account(&account);
ita_sgx_runtime::BalancesCall::<Runtime>::force_set_balance {
who: MultiAddress::Id(account),
new_free: account_info.data.free + amount,
new_free: account_info.data.free + amount - fee,
}
.dispatch_bypass_filter(ita_sgx_runtime::RuntimeOrigin::root())
.map_err(|e| StfError::Dispatch(format!("Shield funds error: {:?}", e.error)))?;
Expand Down
2 changes: 1 addition & 1 deletion core-primitives/utils/src/stringify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ pub fn public_to_string<T: AsBytesRef>(t: &T) -> String {
}

pub fn account_id_to_string<AccountId: Encode>(account: &AccountId) -> String {
format!("{}", HexDisplay::from(&account.encode()))
format!("0x{}", HexDisplay::from(&account.encode()))
}