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

feat: P-860 add logging support for dynamic contract #2848

Merged
merged 9 commits into from
Jul 5, 2024
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
32 changes: 32 additions & 0 deletions primitives/core/src/assertion/dynamic.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright 2020-2024 Trust Computing GmbH.
// This file is part of Litentry.
//
// Litentry is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Litentry is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Litentry. If not, see <https://www.gnu.org/licenses/>.

use parity_scale_codec::{Decode, Encode, MaxEncodedLen};
use scale_info::TypeInfo;
use sp_core::H160;
use sp_runtime::{traits::ConstU32, BoundedVec};

pub type DynamicContractParams = BoundedVec<u8, ConstU32<1024>>;

#[derive(Encode, Decode, Clone, Debug, PartialEq, Eq, MaxEncodedLen, TypeInfo)]
pub struct DynamicParams {
// smart contract code identifier
pub smart_contract_id: H160,
// abi encoded smart contract params
pub smart_contract_params: Option<DynamicContractParams>,
// true to return contract log
pub return_log: bool,
}
8 changes: 5 additions & 3 deletions primitives/core/src/assertion/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,13 @@ use web3_nft::Web3NftType;
pub mod web3_token;
use web3_token::Web3TokenType;

use crate::{AccountId, DynamicParams, ParameterString};
pub mod dynamic;
use dynamic::DynamicParams;

use crate::{AccountId, ParameterString};

use parity_scale_codec::{Decode, Encode, MaxEncodedLen};
use scale_info::TypeInfo;
use sp_core::H160;
use sp_std::{vec, vec::Vec};

#[rustfmt::skip]
Expand Down Expand Up @@ -138,7 +140,7 @@ pub enum Assertion {
NftHolder(Web3NftType),

#[codec(index = 27)]
Dynamic(H160, DynamicParams) // smart contract code identifier, abi encoded smart contract params
Dynamic(DynamicParams)
}

impl Assertion {
Expand Down
2 changes: 0 additions & 2 deletions primitives/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ pub use types::*;

pub type ParameterString = BoundedVec<u8, ConstU32<64>>;

pub type DynamicParams = BoundedVec<u8, ConstU32<1024>>;

/// Common types of parachains.
mod types {
use sp_runtime::{
Expand Down
110 changes: 79 additions & 31 deletions tee-worker/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions tee-worker/app-libs/stf/src/trusted_call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -876,6 +876,7 @@ where
if let Some(key) = maybe_key {
Ok(TrustedCallResult::RequestVC(RequestVCResult {
vc_payload: aes_encrypt_default(&key, &vc_payload),
vc_logs: None,
pre_mutated_id_graph: aes_encrypt_default(&key, &mutated_id_graph.encode()),
pre_id_graph_hash: id_graph_hash,
}))
Expand Down
2 changes: 2 additions & 0 deletions tee-worker/app-libs/stf/src/trusted_call_result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ pub struct SetIdentityNetworksResult {
#[derive(Encode, Decode, Clone, Debug, PartialEq, Eq)]
pub struct RequestVCResult {
pub vc_payload: AesOutput,
// Mainly used to returning logs in dynamic contract VC.
pub vc_logs: Option<AesOutput>,
// see comments in `lc-vc-task-receiver` why it's prefixed with `pre...`
// they should be referenced/used only when the client's local IDGraph is empty
pub pre_mutated_id_graph: AesOutput,
Expand Down
Loading
Loading