Skip to content

Commit

Permalink
More cleanup around the workers (#2486)
Browse files Browse the repository at this point in the history
* remove more stuff

* remove heartbeats

* remove drop3 integration

* missing impl

* fix test
  • Loading branch information
Kailai-Wang committed Feb 14, 2024
1 parent 9bc0e7e commit 6cfefa1
Show file tree
Hide file tree
Showing 30 changed files with 22 additions and 1,147 deletions.
7 changes: 5 additions & 2 deletions bitacross-worker/app-libs/stf/src/trusted_call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ use sp_core::{
crypto::{AccountId32, UncheckedFrom},
ed25519,
};
use sp_io::hashing::blake2_256;
use sp_runtime::MultiAddress;
use std::{format, prelude::v1::*, sync::Arc};

Expand Down Expand Up @@ -155,7 +156,8 @@ impl TrustedCallSigning<TrustedCallSigned> for TrustedCall {
payload.append(&mut mrenclave.encode());
payload.append(&mut shard.encode());

TrustedCallSigned { call: self.clone(), nonce, signature: pair.sign(payload.as_slice()) }
// use blake2_256 hash to shorten the payload - see `verify_signature` below
TrustedCallSigned { call: self.clone(), nonce, signature: pair.sign(&blake2_256(&payload)) }
}
}

Expand Down Expand Up @@ -208,7 +210,8 @@ impl TrustedCallVerification for TrustedCallSigned {
payload.append(&mut mrenclave.encode());
payload.append(&mut shard.encode());

self.signature.verify(payload.as_slice(), self.call.sender_identity())
self.signature.verify(&blake2_256(&payload), self.call.sender_identity())
|| self.signature.verify(&payload, self.call.sender_identity())
}
}

Expand Down
85 changes: 0 additions & 85 deletions bitacross-worker/cli/lit_set_heartbeat_timeout.sh

This file was deleted.

2 changes: 0 additions & 2 deletions bitacross-worker/cli/src/base_cli/commands/litentry/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,3 @@
//
// You should have received a copy of the GNU General Public License
// along with Litentry. If not, see <https://www.gnu.org/licenses/>.

pub mod set_heartbeat_timeout;

This file was deleted.

5 changes: 0 additions & 5 deletions bitacross-worker/cli/src/base_cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
use crate::{
base_cli::commands::{
balance::BalanceCommand, faucet::FaucetCommand, listen::ListenCommand,
litentry::set_heartbeat_timeout::SetHeartbeatTimeoutCommand,
register_tcb_info::RegisterTcbInfoCommand, shield_funds::ShieldFundsCommand,
transfer::TransferCommand,
},
Expand Down Expand Up @@ -81,9 +80,6 @@ pub enum BaseCommand {
/// we could have added a parameter like `--raw` to `PrintSgxMetadata`, but
/// we want to keep our changes isolated
PrintSgxMetadataRaw,

/// set heartbeat timeout storage
SetHeartbeatTimeout(SetHeartbeatTimeoutCommand),
}

impl BaseCommand {
Expand All @@ -102,7 +98,6 @@ impl BaseCommand {
BaseCommand::ShieldFunds(cmd) => cmd.run(cli),
// Litentry's commands below
BaseCommand::PrintSgxMetadataRaw => print_sgx_metadata_raw(cli),
BaseCommand::SetHeartbeatTimeout(cmd) => cmd.run(cli),
}
}
}
Expand Down

This file was deleted.

21 changes: 0 additions & 21 deletions bitacross-worker/core-primitives/test/src/builders/mod.rs

This file was deleted.

17 changes: 1 addition & 16 deletions bitacross-worker/core-primitives/types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,6 @@ use sp_std::{boxed::Box, fmt::Debug, vec::Vec};
pub mod parentchain;
pub mod storage;

/// Substrate runtimes provide no string type. Hence, for arbitrary data of varying length the
/// `Vec<u8>` is used. In the polkadot-js the typedef `Text` is used to automatically
/// utf8 decode bytes into a string.
#[cfg(not(feature = "std"))]
pub type PalletString = Vec<u8>;

#[cfg(feature = "std")]
pub type PalletString = String;

pub use itp_sgx_runtime_primitives::types::*;
pub use litentry_primitives::{
AttestationType, DecryptableRequest, Enclave, EnclaveFingerprint, MrEnclave, WorkerType,
Expand All @@ -45,13 +36,7 @@ pub use sp_core::{crypto::AccountId32 as AccountId, H256};
pub type IpfsHash = [u8; 46];
pub type CallIndex = [u8; 2];

// pallet teerex
pub type ConfirmCallFn = (CallIndex, ShardIdentifier, H256, Vec<u8>);
pub type ShieldFundsFn = (CallIndex, Vec<u8>, Balance, ShardIdentifier);
pub type CallWorkerFn = (CallIndex, RsaRequest);

pub type SetScheduledEnclaveFn = (CallIndex, SidechainBlockNumber, MrEnclave);
pub type RemoveScheduledEnclaveFn = (CallIndex, SidechainBlockNumber);
pub type PostOpaqueTaskFn = (CallIndex, RsaRequest);

/// Simple blob to hold an encoded call
#[derive(Debug, PartialEq, Eq, Clone, Default)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ mod test {
stf_mock::{GetterMock, TrustedCallSignedMock},
};
use itp_top_pool_author::mocks::AuthorApiMock;
use itp_types::{Block, CallWorkerFn, RsaRequest, ShardIdentifier, ShieldFundsFn};
use itp_types::{Block, PostOpaqueTaskFn, RsaRequest, ShardIdentifier};
use sp_core::{ed25519, Pair};
use sp_runtime::{MultiAddress, MultiSignature, OpaqueExtrinsic};
use std::assert_matches::assert_matches;
Expand Down Expand Up @@ -411,12 +411,12 @@ mod test {
assert_ne!(call.0, zero_root_call);
}

fn invoke_unchecked_extrinsic() -> ParentchainUncheckedExtrinsic<CallWorkerFn> {
fn invoke_unchecked_extrinsic() -> ParentchainUncheckedExtrinsic<PostOpaqueTaskFn> {
let request = RsaRequest::new(shard_id(), vec![1u8, 2u8]);
let dummy_metadata = NodeMetadataMock::new();
let call_worker_indexes = dummy_metadata.post_opaque_task_call_indexes().unwrap();

ParentchainUncheckedExtrinsic::<CallWorkerFn>::new_signed(
ParentchainUncheckedExtrinsic::<PostOpaqueTaskFn>::new_signed(
(call_worker_indexes, request),
MultiAddress::Address32([1u8; 32]),
MultiSignature::Ed25519(default_signature()),
Expand Down
24 changes: 0 additions & 24 deletions bitacross-worker/docker/lit-set-heartbeat-timeout.yml

This file was deleted.

4 changes: 3 additions & 1 deletion bitacross-worker/enclave-runtime/src/test/top_pool_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ use itp_top_pool_author::{
top_filter::{AllowAllTopsFilter, DirectCallsOnlyFilter},
traits::AuthorApi,
};
use itp_types::{parentchain::Address, Block, CallWorkerFn, RsaRequest, ShardIdentifier, H256};
use itp_types::{parentchain::Address, Block, RsaRequest, ShardIdentifier, H256};
use jsonrpc_core::futures::executor;
use litentry_primitives::Identity;
use log::*;
Expand Down Expand Up @@ -190,6 +190,7 @@ fn encrypted_indirect_call<
encrypt_trusted_operation(shielding_key, &trusted_operation)
}

/*
fn create_opaque_call_extrinsic<ShieldingKey: ShieldingCryptoEncrypt>(
_shard: ShardIdentifier,
_shielding_key: &ShieldingKey,
Expand Down Expand Up @@ -224,3 +225,4 @@ fn create_opaque_call_extrinsic<ShieldingKey: ShieldingCryptoEncrypt>(
.with_extrinsics(vec![opaque_extrinsic])
.build()
}
*/

0 comments on commit 6cfefa1

Please sign in to comment.