Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add link_identity_short workaround #2362

Merged
merged 2 commits into from
Dec 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
47 changes: 47 additions & 0 deletions tee-worker/app-libs/stf/src/trusted_call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,19 @@ pub enum TrustedCall {
remove_identity(Identity, Identity, Identity, H256),
request_vc(Identity, Identity, Assertion, H256),
set_identity_networks(Identity, Identity, Identity, Vec<Web3Network>),
// a hotfix to work around the "too long encoded call size" problem
// it's similiar to `link_identity`, but with reduced parameters:
// - the first identity is the prime identity, whose signature is required
// - the second identity is the to-be-linked identity
// in this sense, it can only be called via DI
link_identity_short(
Identity,
Identity,
ValidationData,
Vec<Web3Network>,
UserShieldingKeyNonceType,
H256,
),
set_user_shielding_key_with_networks(
Identity,
Identity,
Expand Down Expand Up @@ -167,6 +180,7 @@ impl TrustedCall {
TrustedCall::set_identity_networks(sender_identity, ..) => sender_identity,
TrustedCall::set_user_shielding_key_with_networks(sender_identity, ..) =>
sender_identity,
TrustedCall::link_identity_short(sender_identity, ..) => sender_identity,
TrustedCall::link_identity_callback(sender_identity, ..) => sender_identity,
TrustedCall::request_vc_callback(sender_identity, ..) => sender_identity,
TrustedCall::handle_imp_error(sender_identity, ..) => sender_identity,
Expand Down Expand Up @@ -564,6 +578,38 @@ where
}
Ok(())
},
TrustedCall::link_identity_short(
signer,
identity,
validation_data,
web3networks,
nonce,
hash,
) => {
debug!("link_identity_short, who: {}", account_id_to_string(&signer));

if let Err(e) = Self::link_identity_internal(
signer.to_account_id().ok_or(Self::Error::InvalidAccount)?,
signer.clone(),
identity,
validation_data,
web3networks,
nonce,
hash,
shard,
) {
add_call_from_imp_error(
calls,
node_metadata_repo,
Some(SgxParentchainTypeConverter::convert(
signer.to_account_id().ok_or(Self::Error::InvalidAccount)?,
)),
e.to_imp_error(),
hash,
);
}
Ok(())
},
TrustedCall::remove_identity(signer, who, identity, hash) => {
debug!("remove_identity, who: {}", account_id_to_string(&who));
let account = SgxParentchainTypeConverter::convert(
Expand Down Expand Up @@ -778,6 +824,7 @@ where
TrustedCall::link_identity_callback(..) => debug!("No storage updates needed..."),
TrustedCall::request_vc_callback(..) => debug!("No storage updates needed..."),
TrustedCall::set_identity_networks(..) => debug!("No storage updates needed..."),
TrustedCall::link_identity_short(..) => debug!("No storage updates needed..."),
TrustedCall::set_user_shielding_key_with_networks(..) =>
debug!("No storage updates needed..."),
TrustedCall::handle_imp_error(..) => debug!("No storage updates needed..."),
Expand Down
1 change: 0 additions & 1 deletion tee-worker/litentry/core/data-providers/src/geniidata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ use itc_rest_client::{
rest_client::RestClient,
RestGet, RestPath,
};
use litentry_primitives::ErrorDetail;
use serde::{Deserialize, Serialize};
use std::{
format, str,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,6 @@ where

Assertion::BRC20AmountHolder =>
lc_assertion_build::brc20::amount_holder::build(&self.req),

_ => unimplemented!(),
}?;

// post-process the credential
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ export default {
request_vc: "(LitentryIdentity, LitentryIdentity, Assertion, H256)",
set_identity_networks:
"(LitentryIdentity, LitentryIdentity, LitentryIdentity, Vec<Web3Network>)",
link_identity_short:
"(LitentryIdentity, LitentryIdentity, LitentryValidationData, Vec<Web3Network>, UserShieldingKeyNonceType, H256)",

},
},
UserShieldingKeyType: "[u8; 32]",
Expand Down