Skip to content
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
8 changes: 4 additions & 4 deletions teerex/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ benchmarks! {
let req = Request { shard:H256::from_slice(&TEST4_SETUP.mrenclave), cyphertext: vec![1u8; 2000]};
}: _(RawOrigin::Signed(accounts[0].clone()), req)

// Benchmark `confirm_processed_parentchainblock` with the worst possible conditions:
// Benchmark `confirm_processed_parentchain_block` with the worst possible conditions:
// * sender enclave is registered
confirm_processed_parentchainblock {
confirm_processed_parentchain_block {
let accounts: Vec<T::AccountId> = generate_accounts::<T>(1);
add_enclaves_to_registry::<T>(&accounts);

Expand All @@ -116,9 +116,9 @@ benchmarks! {

}: _(RawOrigin::Signed(accounts[0].clone()), block_hash, merkle_root)

// Benchmark `confirm_proposed_sidechainblock` with the worst possible conditions:
// Benchmark `confirm_proposed_sidechain_block` with the worst possible conditions:
// * sender enclave is registered
confirm_proposed_sidechainblock {
confirm_proposed_sidechain_block {
let accounts: Vec<T::AccountId> = generate_accounts::<T>(1);
add_enclaves_to_registry::<T>(&accounts);

Expand Down
12 changes: 6 additions & 6 deletions teerex/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,19 +176,19 @@ decl_module! {
Ok(())
}

/// The integritee worker calls this function for every processed parentchainblock to confirm a state update.
#[weight = (<T as Config>::WeightInfo::confirm_processed_parentchainblock(), DispatchClass::Normal, Pays::Yes)]
pub fn confirm_processed_parentchainblock(origin, block_hash: H256, trusted_calls_merkle_root: H256) -> DispatchResult {
/// The integritee worker calls this function for every processed parentchain_block to confirm a state update.
#[weight = (<T as Config>::WeightInfo::confirm_processed_parentchain_block(), DispatchClass::Normal, Pays::Yes)]
pub fn confirm_processed_parentchain_block(origin, block_hash: H256, trusted_calls_merkle_root: H256) -> DispatchResult {
let sender = ensure_signed(origin)?;
Self::is_registered_enclave(&sender)?;
log::debug!("Processed parentchain block confirmed for mrenclave {:?}, block hash {:?}", sender, block_hash);
Self::deposit_event(RawEvent::ProcessedParentchainBlock(sender, block_hash, trusted_calls_merkle_root));
Ok(())
}

/// The integritee worker calls this function for every proposed sidechainblock.
#[weight = (<T as Config>::WeightInfo::confirm_proposed_sidechainblock(), DispatchClass::Normal, Pays::Yes)]
pub fn confirm_proposed_sidechainblock(origin, shard_id: ShardIdentifier, block_hash: H256) -> DispatchResult {
/// The integritee worker calls this function for every proposed sidechain_block.
#[weight = (<T as Config>::WeightInfo::confirm_proposed_sidechain_block(), DispatchClass::Normal, Pays::Yes)]
pub fn confirm_proposed_sidechain_block(origin, shard_id: ShardIdentifier, block_hash: H256) -> DispatchResult {
let sender = ensure_signed(origin)?;
Self::is_registered_enclave(&sender)?;
let sender_index = Self::enclave_index(&sender);
Expand Down
16 changes: 8 additions & 8 deletions teerex/src/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ fn update_ipfs_hash_works() {
URL.to_vec(),
));
assert_eq!(Teerex::enclave_count(), 1);
assert_ok!(Teerex::confirm_processed_parentchainblock(
assert_ok!(Teerex::confirm_processed_parentchain_block(
Origin::signed(signer.clone()),
block_hash.clone(),
merkle_root.clone(),
Expand All @@ -266,7 +266,7 @@ fn ipfs_update_from_unregistered_enclave_fails() {
new_test_ext().execute_with(|| {
let signer = get_signer(TEST4_SIGNER_PUB);
assert_err!(
Teerex::confirm_processed_parentchainblock(
Teerex::confirm_processed_parentchain_block(
Origin::signed(signer),
H256::default(),
H256::default(),
Expand Down Expand Up @@ -619,7 +619,7 @@ fn unshield_funds_from_enclave_neq_bonding_account_errs() {
}

#[test]
fn confirm_processed_parentchainblock_works() {
fn confirm_processed_parentchain_block_works() {
new_test_ext().execute_with(|| {
Timestamp::set_timestamp(TEST7_TIMESTAMP);
let block_hash = H256::default();
Expand All @@ -633,7 +633,7 @@ fn confirm_processed_parentchainblock_works() {
));
assert_eq!(Teerex::enclave_count(), 1);

assert_ok!(Teerex::confirm_processed_parentchainblock(
assert_ok!(Teerex::confirm_processed_parentchain_block(
Origin::signed(signer7.clone()),
block_hash.clone(),
merkle_root.clone(),
Expand All @@ -646,7 +646,7 @@ fn confirm_processed_parentchainblock_works() {
}

#[test]
fn confirm_proposed_sidechainblock_works_for_correct_shard() {
fn confirm_proposed_sidechain_block_works_for_correct_shard() {
new_test_ext().execute_with(|| {
Timestamp::set_timestamp(TEST7_TIMESTAMP);
let block_hash = H256::default();
Expand All @@ -661,7 +661,7 @@ fn confirm_proposed_sidechainblock_works_for_correct_shard() {
));
assert_eq!(Teerex::enclave_count(), 1);

assert_ok!(Teerex::confirm_proposed_sidechainblock(
assert_ok!(Teerex::confirm_proposed_sidechain_block(
Origin::signed(signer7.clone()),
shard7.clone(),
block_hash.clone(),
Expand All @@ -673,7 +673,7 @@ fn confirm_proposed_sidechainblock_works_for_correct_shard() {
}

#[test]
fn confirm_proposed_sidechainblock_from_shard_neq_mrenclave_errs() {
fn confirm_proposed_sidechain_block_from_shard_neq_mrenclave_errs() {
new_test_ext().execute_with(|| {
Timestamp::set_timestamp(TEST7_TIMESTAMP);
let block_hash = H256::default();
Expand All @@ -689,7 +689,7 @@ fn confirm_proposed_sidechainblock_from_shard_neq_mrenclave_errs() {
assert_eq!(Teerex::enclave_count(), 1);

assert_err!(
Teerex::confirm_proposed_sidechainblock(
Teerex::confirm_proposed_sidechain_block(
Origin::signed(signer7.clone()),
shard4.clone(),
block_hash.clone(),
Expand Down
12 changes: 6 additions & 6 deletions teerex/src/weights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ pub trait WeightInfo {
fn register_enclave() -> Weight;
fn unregister_enclave() -> Weight;
fn call_worker() -> Weight;
fn confirm_processed_parentchainblock() -> Weight;
fn confirm_proposed_sidechainblock() -> Weight;
fn confirm_processed_parentchain_block() -> Weight;
fn confirm_proposed_sidechain_block() -> Weight;
}

/// Weights for pallet_teerex using the Integritee parachain node and recommended hardware.
Expand All @@ -73,12 +73,12 @@ impl<T: frame_system::Config> WeightInfo for IntegriteeWeight<T> {
fn call_worker() -> Weight {
(57_200_000 as Weight)
}
fn confirm_processed_parentchainblock() -> Weight {
fn confirm_processed_parentchain_block() -> Weight {
(46_900_000 as Weight)
.saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().writes(2 as Weight))
}
fn confirm_proposed_sidechainblock() -> Weight {
fn confirm_proposed_sidechain_block() -> Weight {
(46_200_000 as Weight)
.saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().writes(2 as Weight))
Expand All @@ -100,12 +100,12 @@ impl WeightInfo for () {
fn call_worker() -> Weight {
(57_200_000 as Weight)
}
fn confirm_processed_parentchainblock() -> Weight {
fn confirm_processed_parentchain_block() -> Weight {
(46_900_000 as Weight)
.saturating_add(RocksDbWeight::get().reads(1 as Weight))
.saturating_add(RocksDbWeight::get().writes(2 as Weight))
}
fn confirm_proposed_sidechainblock() -> Weight {
fn confirm_proposed_sidechain_block() -> Weight {
(46_200_000 as Weight)
.saturating_add(RocksDbWeight::get().reads(1 as Weight))
.saturating_add(RocksDbWeight::get().writes(2 as Weight))
Expand Down