Skip to content

Commit

Permalink
Detect ack_game extrinsic integritee-network#80
Browse files Browse the repository at this point in the history
* Detect ack_game extrinsic #8

* fmt and rename

Co-authored-by: Gaudenz Kessler <[email protected]>
  • Loading branch information
gaudenzkessler and gkessler-scs authored Feb 15, 2022
1 parent ca24498 commit f5c3e43
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
1 change: 1 addition & 0 deletions core-primitives/registry-storage/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ sp-std = { version = "4.0.0-dev", default-features = false, git = "https://githu

#local deps
itp-storage = { path = "../storage", default-features = false }
itp-types = { path = "../types", default-features = false }

# node deps
pallet-ajuna-gameregistry = { default-features = false, git = "https://github.com/ajuna-network/ajuna-node.git", branch = "update-substrate-5" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@
use crate::error::Result;
use codec::{Decode, Encode};
use ita_stf::{AccountId, TrustedCallSigned};
use itp_settings::node::{CALL_WORKER, SHIELD_FUNDS, TEEREX_MODULE};
use itp_settings::node::{
ACK_GAME, CALL_WORKER, GAME_REGISTRY_MODULE, SHIELD_FUNDS, TEEREX_MODULE,
};
use itp_sgx_crypto::ShieldingCrypto;
use itp_stf_executor::traits::{StatePostProcessing, StfExecuteShieldFunds, StfExecuteTrustedCall};
use itp_types::{CallWorkerFn, OpaqueCall, ShardIdentifier, ShieldFundsFn, H256};
use itp_types::{AckGameFn, CallWorkerFn, OpaqueCall, ShardIdentifier, ShieldFundsFn, H256};
use log::*;
use sp_core::blake2_256;
use sp_runtime::traits::{Block as ParentchainBlockTrait, Header};
Expand Down Expand Up @@ -72,6 +74,11 @@ where
Ok(())
}

fn handle_ack_game_xt(&self, xt: &UncheckedExtrinsicV4<AckGameFn>) -> Result<()> {
error!("JUHUUUUUUUUUUUUUUU");
Ok(())
}

fn decrypt_unchecked_extrinsic(
&self,
xt: UncheckedExtrinsicV4<CallWorkerFn>,
Expand Down Expand Up @@ -104,7 +111,7 @@ where
{
debug!("Scanning block {:?} for relevant xt", block.header().number());
let mut opaque_calls = Vec::<OpaqueCall>::new();
let mut executed_shielding_calls = Vec::<H256>::new();
let mut executed_extrinsics = Vec::<H256>::new();
for xt_opaque in block.extrinsics().iter() {
// Found ShieldFunds extrinsic in block.
if let Ok(xt) =
Expand All @@ -115,7 +122,21 @@ where
error!("Error performing shield funds. Error: {:?}", e);
} else {
// Cache successfully executed shielding call.
executed_shielding_calls.push(hash_of(xt))
executed_extrinsics.push(hash_of(xt))
}
}
};

// Found Ack_Game extrinsic in block.
if let Ok(xt) =
UncheckedExtrinsicV4::<AckGameFn>::decode(&mut xt_opaque.encode().as_slice())
{
if xt.function.0 == [GAME_REGISTRY_MODULE, ACK_GAME] {
if let Err(e) = self.handle_ack_game_xt(&xt) {
error!("Error performing acknowledge game. Error: {:?}", e);
} else {
// Cache successfully executed shielding call.
executed_extrinsics.push(hash_of(xt))
}
}
};
Expand All @@ -141,7 +162,7 @@ where
}
}
}
Ok((opaque_calls, executed_shielding_calls))
Ok((opaque_calls, executed_extrinsics))
}
}

Expand Down

0 comments on commit f5c3e43

Please sign in to comment.