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
ecdf920
add design document with some mermaid diagrams
brenzi Oct 11, 2023
347e187
support enclave signing with changing keypairs at runtime
brenzi Oct 11, 2023
81e94dd
tame nervous polling of not yet finalized block
brenzi Oct 11, 2023
6ddd043
shard vault account creation works
brenzi Oct 11, 2023
156aac3
prepare vault account getter. not working yet
brenzi Oct 11, 2023
f1d3d77
fix build and add trusted_call dummy for unshielding
brenzi Oct 12, 2023
9911098
fix transfer call indexes
brenzi Oct 12, 2023
ead3662
unshieldind dummy with real vault account and proxy call
brenzi Oct 12, 2023
b20d978
await vault account creation before registering proxy
brenzi Oct 12, 2023
4524b9f
proxied unshielding call encodes correctly and would be executed if t…
brenzi Oct 12, 2023
6587f1b
start MU_RA doc diagrams and refactor namings for improved readability
brenzi Oct 12, 2023
d5ce0c7
refactoring MU RA functions for better readability. try to extract cl…
brenzi Oct 12, 2023
cd3562d
logging pubkey of counterparty now during MU RA. but seems skip_ra wo…
brenzi Oct 12, 2023
36bdc5c
add client account to MU RA request
brenzi Oct 13, 2023
b5da3a2
starting to modularize vault logic
brenzi Oct 13, 2023
ed26be7
secondary worker is registered as a vault proxy now
brenzi Oct 13, 2023
da6bea0
Merge remote-tracking branch 'origin/master' into ab/proxied-vault-ac…
brenzi Oct 13, 2023
b72c063
cleanup
brenzi Oct 13, 2023
4d2c000
clippy
brenzi Oct 13, 2023
9bc2e60
doc cleanup
brenzi Oct 13, 2023
757c07a
doc pimp
brenzi Oct 13, 2023
2b7ed16
cleanup
brenzi Oct 13, 2023
bb69ebd
reverting polling fix which is solved in another PR
brenzi Oct 24, 2023
42fac49
fix diagram bug
brenzi Oct 24, 2023
f5acb2d
fix mock test
brenzi Oct 24, 2023
6e03fff
avoid panic if add_shard_vault_proxy fails
brenzi Oct 25, 2023
2109bd2
skip shard vault stuff for offchain-worker
brenzi Oct 26, 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
fix transfer call indexes
  • Loading branch information
brenzi committed Oct 12, 2023
commit 9911098ec5bdf366fcbd36ca109d2028cbce956a
13 changes: 6 additions & 7 deletions app-libs/stf/src/trusted_call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,14 @@ use std::vec::Vec;
use crate::{helpers::ensure_enclave_signer_account, StfError, TrustedOperation};
use codec::{Compact, Decode, Encode};
use frame_support::{ensure, traits::UnfilteredDispatchable};
#[cfg(feature = "evm")]
use ita_sgx_runtime::{AddressMapping, HashedAddressMapping};
pub use ita_sgx_runtime::{Balance, Index};
use ita_sgx_runtime::{Runtime, System};
use itp_node_api::metadata::{provider::AccessNodeMetadata, NodeMetadataTrait};
use itp_node_api_metadata::{
pallet_enclave_bridge::EnclaveBridgeCallIndexes, pallet_proxy::ProxyCallIndexes,
pallet_balances::BalancesCallIndexes, pallet_enclave_bridge::EnclaveBridgeCallIndexes,
pallet_proxy::ProxyCallIndexes,
};
use itp_stf_interface::ExecuteCall;
use itp_stf_primitives::types::{AccountId, KeyPair, ShardIdentifier, Signature};
Expand All @@ -39,9 +42,6 @@ use sp_io::hashing::blake2_256;
use sp_runtime::{traits::Verify, MultiAddress};
use std::{format, prelude::v1::*, sync::Arc};

#[cfg(feature = "evm")]
use ita_sgx_runtime::{AddressMapping, HashedAddressMapping};

#[cfg(feature = "evm")]
use crate::evm_helpers::{create_code_hash, evm_create2_address, evm_create_address};

Expand Down Expand Up @@ -256,9 +256,8 @@ where
// todo: insert correct vault accountid here
let vault_address = Address::from(AccountId::from([0u8; 32]));
let vault_transfer_call = OpaqueCall::from_tuple(&(
//node_metadata_repo
// .get_from_metadata(|m| m.transfer_keep_alive_call_indexes())??,
[0u8, 0u8],
node_metadata_repo
.get_from_metadata(|m| m.transfer_keep_alive_call_indexes())??,
Address::from(beneficiary),
Compact(value),
));
Expand Down
6 changes: 3 additions & 3 deletions core-primitives/node-api/metadata/src/metadata_mocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,15 +156,15 @@ impl ProxyCallIndexes for NodeMetadataMock {
}

impl BalancesCallIndexes for NodeMetadataMock {
fn transfer_call_index(&self) -> Result<[u8; 2]> {
fn transfer_call_indexes(&self) -> Result<[u8; 2]> {
Ok([self.balances_module, self.transfer])
}

fn transfer_keep_alive_call_index(&self) -> Result<[u8; 2]> {
fn transfer_keep_alive_call_indexes(&self) -> Result<[u8; 2]> {
Ok([self.balances_module, self.transfer_keep_alive])
}

fn transfer_allow_death_call_index(&self) -> Result<[u8; 2]> {
fn transfer_allow_death_call_indexes(&self) -> Result<[u8; 2]> {
Ok([self.balances_module, self.transfer_allow_death])
}
}
12 changes: 6 additions & 6 deletions core-primitives/node-api/metadata/src/pallet_balances.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,23 @@ use crate::{error::Result, NodeMetadata};
const BALANCES: &str = "Balances";

pub trait BalancesCallIndexes {
fn transfer_call_index(&self) -> Result<[u8; 2]>;
fn transfer_call_indexes(&self) -> Result<[u8; 2]>;

fn transfer_keep_alive_call_index(&self) -> Result<[u8; 2]>;
fn transfer_keep_alive_call_indexes(&self) -> Result<[u8; 2]>;

fn transfer_allow_death_call_index(&self) -> Result<[u8; 2]>;
fn transfer_allow_death_call_indexes(&self) -> Result<[u8; 2]>;
}

impl BalancesCallIndexes for NodeMetadata {
fn transfer_call_index(&self) -> Result<[u8; 2]> {
fn transfer_call_indexes(&self) -> Result<[u8; 2]> {
self.call_indexes(BALANCES, "transfer")
}

fn transfer_keep_alive_call_index(&self) -> Result<[u8; 2]> {
fn transfer_keep_alive_call_indexes(&self) -> Result<[u8; 2]> {
self.call_indexes(BALANCES, "transfer_keep_alive")
}

fn transfer_allow_death_call_index(&self) -> Result<[u8; 2]> {
fn transfer_allow_death_call_indexes(&self) -> Result<[u8; 2]> {
self.call_indexes(BALANCES, "transfer_allow_death")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,13 @@ where
let index = xt.call_index;
let call_args = &mut &xt.call_args[..];
log::trace!("[TransferToAliceShieldsFundsFilter] attempting to execute indirect call with index {:?}", index);
if index == metadata.transfer_call_index().ok()?
|| index == metadata.transfer_allow_death_call_index().ok()?
if index == metadata.transfer_call_indexes().ok()?
|| index == metadata.transfer_keep_alive_call_indexes().ok()?
|| index == metadata.transfer_allow_death_call_indexes().ok()?
{
log::debug!("found `transfer` or `transfer_allow_death` call.");
log::debug!(
"found `transfer` or `transfer_allow_death` or `transfer_keep_alive` call."
);
let args = decode_and_log_error::<TransferToAliceShieldsFundsArgs>(call_args)?;
if args.destination == ALICE_ACCOUNT_ID.into() {
Some(IndirectCall::TransferToAliceShieldsFunds(args))
Expand Down