Skip to content

Commit

Permalink
Code cleanup v2 (#895)
Browse files Browse the repository at this point in the history
* HAL-20 : fix enum comment

* HAL-20 : fix merge_schedules

* HAL-20 : fix setCommission

* HAL-20 : fix erasTotalRewardPoints

* (HAL-13) : remove unit8 return type

* fix transferred

* fix comment

* fix tangle lst comments

* fix comments

* add workspace

* clean todos
  • Loading branch information
1xstj authored Jan 22, 2025
1 parent 819e370 commit 48a8d70
Show file tree
Hide file tree
Showing 24 changed files with 138 additions and 158 deletions.
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ members = [
"precompiles/services",
"precompiles/tangle-lst",
"precompiles/assets",
"precompiles/vesting",
"precompiles/staking",
"tangle-subxt",
"evm-tracer",
]
Expand Down
3 changes: 0 additions & 3 deletions client/rpc/trace/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -689,9 +689,6 @@ where
// In some cases it might be possible to receive traces of a block
// that has no entry in the cache because it was removed of the pool
// and received a permit concurrently. We just ignore it.
//
// TODO : Should we add it back ? Should it have an active_batch_count
// of 1 then ?
if let Some(block_cache) = self.cached_blocks.get_mut(&block_hash) {
if let CacheBlockState::Pooled { ref mut waiting_requests, .. } = block_cache.state {
tracing::trace!(
Expand Down
1 change: 0 additions & 1 deletion frost/frost-secp256k1-tr/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,6 @@ fn negate_nonce(nonce: &frost_core::round1::Nonce<S>) -> frost_core::round1::Non

// Negate a SigningNonces
fn negate_nonces(signing_nonces: &round1::SigningNonces) -> round1::SigningNonces {
// TODO: this recomputes commitments which is expensive, and not needed.
// Create an `internals` SigningNonces::from_nonces_and_commitments or
// something similar.
round1::SigningNonces::from_nonces(
Expand Down
2 changes: 0 additions & 2 deletions frost/src/scalar_mul.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ use crate::{Ciphersuite, Element, Field, Group, Scalar};
///
/// This function is similar to `div_ceil` that is [available on
/// Nightly](https://github.com/rust-lang/rust/issues/88581).
// TODO: remove this function and use `div_ceil()` instead when `int_roundings`
// is stabilized.
const fn div_ceil(lhs: usize, rhs: usize) -> usize {
let d = lhs / rhs;
let r = lhs % rhs;
Expand Down
1 change: 0 additions & 1 deletion pallets/multi-asset-delegation/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ mod tests;
pub mod weights;

// #[cfg(feature = "runtime-benchmarks")]
// TODO(@1xstj): Fix benchmarking and re-enable
// mod benchmarking;

pub mod functions;
Expand Down
2 changes: 1 addition & 1 deletion pallets/multi-asset-delegation/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ impl tangle_primitives::traits::ServiceManager<AccountId, Balance> for MockServi
}

fn get_blueprints_by_operator(_account: &AccountId) -> Vec<u64> {
todo!(); // we don't care
unimplemented!(); // we don't care
}
}

Expand Down
14 changes: 3 additions & 11 deletions pallets/services/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,6 @@ pub mod module {
NextBlueprintId::<T>::set(blueprint_id.saturating_add(1));

Self::deposit_event(Event::BlueprintCreated { owner, blueprint_id });
// TODO: update weight for the creation of the blueprint.
Ok(PostDispatchInfo { actual_weight: None, pays_fee: Pays::Yes })
}

Expand Down Expand Up @@ -853,7 +852,6 @@ pub mod module {
registration_args,
});

// TODO: update weight for the registration.
Ok(PostDispatchInfo { actual_weight: None, pays_fee: Pays::Yes })
}

Expand Down Expand Up @@ -887,10 +885,8 @@ pub mod module {
let (allowed, _weight) =
Self::on_unregister_hook(&blueprint, blueprint_id, &preferences)?;
ensure!(allowed, Error::<T>::NotAllowedToUnregister);
// TODO: check if the caller is not providing any service for the blueprint.
Operators::<T>::remove(blueprint_id, &caller);

// TODO: also remove all the services that uses this blueprint?
let removed = OperatorsProfile::<T>::try_mutate_exists(&caller, |profile| {
profile
.as_mut()
Expand All @@ -900,7 +896,6 @@ pub mod module {

ensure!(removed, Error::<T>::NotRegistered);
Self::deposit_event(Event::Unregistered { operator: caller.clone(), blueprint_id });
// TODO: update weight for the unregistration.
Ok(PostDispatchInfo { actual_weight: None, pays_fee: Pays::Yes })
}

Expand Down Expand Up @@ -1119,7 +1114,6 @@ pub mod module {
assets: assets.to_vec(),
});

// TODO: add weight for the request to the total weight.
Ok(PostDispatchInfo { actual_weight: None, pays_fee: Pays::Yes })
}

Expand Down Expand Up @@ -1405,7 +1399,6 @@ pub mod module {
StagingServicePayments::<T>::remove(request_id);
}

// TODO: make use of the returned weight from the hook.
Ok(PostDispatchInfo { actual_weight: None, pays_fee: Pays::Yes })
}

Expand Down Expand Up @@ -1433,7 +1426,6 @@ pub mod module {
) -> DispatchResultWithPostInfo {
let caller = ensure_signed(origin)?;
let service = Self::services(service_id)?;
// TODO: allow permissioned callers to terminate the service?
ensure!(service.owner == caller, DispatchError::BadOrigin);
let removed = UserServices::<T>::try_mutate(&caller, |service_ids| {
Result::<_, Error<T>>::Ok(service_ids.remove(&service_id))
Expand Down Expand Up @@ -1526,7 +1518,7 @@ pub mod module {
job,
args,
});
// TODO: add weight for the call to the total weight.

Ok(PostDispatchInfo { actual_weight: None, pays_fee: Pays::Yes })
}

Expand Down Expand Up @@ -1600,7 +1592,7 @@ pub mod module {
job: job_call.job,
result,
});
// TODO: add weight for the call to the total weight.

Ok(PostDispatchInfo { actual_weight: None, pays_fee: Pays::Yes })
}

Expand Down Expand Up @@ -1659,7 +1651,7 @@ pub mod module {
.collect::<Vec<_>>();
let total_slash =
others_slash.iter().fold(exposed_stake, |acc, (_, slash)| acc + *slash);
// TODO: take into account the delegators' asset kind.

// for now, we treat all assets equally, which is not the case in reality.
let unapplied_slash = UnappliedSlash {
service_id,
Expand Down
2 changes: 1 addition & 1 deletion precompiles/assets-erc20/ERC20.sol
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ interface IERC20 {
/// @custom:selector ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef
/// @param from address The address sending the tokens
/// @param to address The address receiving the tokens.
/// @param value uint256 The amount of tokens transfered.
/// @param value uint256 The amount of tokens transferred.
event Transfer(address indexed from, address indexed to, uint256 value);

/// @dev Event emited when an approval has been registered.
Expand Down
Loading

0 comments on commit 48a8d70

Please sign in to comment.