profile
viewpoint
Mazdak Farrokhzad Centril @PolymathNetwork Sweden Compiler engineer and former Rust Language and Release team member.

AltSysrq/proptest 910

Hypothesis-like property testing for Rust

AleoHQ/leo 189

The Leo Programming Language. A Functional, Statically-Typed Language for Zero-Knowledge Applications

AleoHQ/community 5

A place for everyone to collaborate and communicate: Agendas and meeting notes.

Centril/dbg 5

Implementation of https://github.com/rust-lang/rfcs/pull/2173 in stable rust

Centril/aTetria 2

Initial push of Framework + Model + input processors.

Centril/android-numberpicker 1

A backport of the Android 4.2 NumberPicker

Centril/bin-util 1

small utility scripts, mostly git related.

Centril/consensusbot 1

Next gen rfcbot

Centril/android-project-template 0

template project for android.

Centril/areweasyncyet.rs 0

Are we async yet?

PullRequestReviewEvent
PullRequestReviewEvent

Pull request review commentAleoHQ/leo

Patch/Add always const annotation for len

 impl Program {         }     } -    pub fn set_core_mapping(&mut self) {-        for (_, circuit) in self.circuits.iter_mut() {-            for member in circuit.members.iter_mut() {+    pub fn handle_internal_annotations(&mut self) {+        self.circuits+            .iter_mut()+            .flat_map(|(_, circuit)| &mut circuit.members)+            .filter_map(|member| {                 if let CircuitMember::CircuitFunction(function) = member {-                    if let Some(core_map) = function.annotations.remove("CoreFunction") {-                        function.core_mapping.replace(-                            core_map-                                .arguments-                                .get(0)-                                .or(Some(&function.identifier.name))-                                .map(|f| f.to_string()),-                        );-                    }+                    Some(function)+                } else {+                    None                 }-            }-        }+            })+            .into_iter()+            .for_each(|function| {+                function.annotations.clone().into_iter().for_each(|(name, _)| {+                    match name.as_str() {+                        "CoreFunction" => {+                            if let Some(core_map) = function.annotations.remove(&name) {

Use .retain instead to avoid the clone and remove.

gluax

comment created time in 8 hours

Pull request review commentAleoHQ/leo

Patch/Add always const annotation for len

+/*+namespace: Compile+expectation: Pass+input_file: input/length.in+*/++function main(arr1: [u8; 2], const arr2: [u8; 2]) -> bool {+    const len1 = arr1.len();+	const len2 = arr2.len();++	return len1 == len2; +}

Remember to set your editor to always insert a newline at EOF (and then there are 3 files that need fixing in this PR).

gluax

comment created time in 9 hours

Pull request review commentAleoHQ/leo

Patch/Add always const annotation for len

 impl Program {         }     } -    pub fn set_core_mapping(&mut self) {-        for (_, circuit) in self.circuits.iter_mut() {-            for member in circuit.members.iter_mut() {+    pub fn handle_internal_annotations(&mut self) {+        self.circuits+            .iter_mut()+            .flat_map(|(_, circuit)| &mut circuit.members)+            .filter_map(|member| {                 if let CircuitMember::CircuitFunction(function) = member {-                    if let Some(core_map) = function.annotations.remove("CoreFunction") {-                        function.core_mapping.replace(-                            core_map-                                .arguments-                                .get(0)-                                .or(Some(&function.identifier.name))-                                .map(|f| f.to_string()),-                        );-                    }+                    Some(function)+                } else {+                    None                 }-            }-        }+            })+            .into_iter()

Redundant call

gluax

comment created time in 9 hours

PullRequestReviewEvent
PullRequestReviewEvent
PullRequestReviewEvent

Pull request review commentPolymathNetwork/Polymesh

MESH-1752 check custom asset type id

 decl_module! {         const AssetNameMaxLength: u32 = T::AssetNameMaxLength::get();         const FundingRoundNameMaxLength: u32 = T::FundingRoundNameMaxLength::get(); +        fn on_runtime_upgrade() -> frame_support::weights::Weight {+            use frame_support::weights::constants::WEIGHT_PER_MICROS;+            // Keep track of upgrade cost.+            let mut weight = 0u64;+            storage_migrate_on!(StorageVersion::get(), 1, {+                let mut total_len = 0u64;+                // Get list of assets with invalid asset_types.+                let fix_list = Tokens::iter()+                    .filter(|(_, token)| {+                        total_len += 1;+                        // Check if the asset_type is invalid.+                        Self::ensure_asset_type_valid(token.asset_type).is_err()+                    }).map(|(ticker, _)| ticker).collect::<Vec<_>>();

Yep, makes sense 👍 -- might be worth getting docs clarification from upstream in the future.

Neopallium

comment created time in 2 days

PullRequestReviewEvent
PullRequestReviewEvent

Pull request review commentPolymathNetwork/Polymesh

MESH-1752 check custom asset type id

 decl_module! {         const AssetNameMaxLength: u32 = T::AssetNameMaxLength::get();         const FundingRoundNameMaxLength: u32 = T::FundingRoundNameMaxLength::get(); +        fn on_runtime_upgrade() -> frame_support::weights::Weight {+            use frame_support::weights::constants::WEIGHT_PER_MICROS;+            // Keep track of upgrade cost.+            let mut weight = 0u64;+            storage_migrate_on!(StorageVersion::get(), 1, {+                let mut total_len = 0u64;+                // Get list of assets with invalid asset_types.+                let fix_list = Tokens::iter()+                    .filter(|(_, token)| {+                        total_len += 1;+                        // Check if the asset_type is invalid.+                        Self::ensure_asset_type_valid(token.asset_type).is_err()+                    }).map(|(ticker, _)| ticker).collect::<Vec<_>>();

Oh yeah, you're right, although I wonder if that's actually true. For example, consider this implementation of translate: https://paritytech.github.io/substrate/latest/src/frame_support/storage/generator/map.rs.html#123-209 -- clearly it's mutating the map during iteration, but it is OK, because there's no change to the keys in the map. So ostensibly, what they really mean by the comment there is "If you change what the keys hash to, you get undefined results."

Neopallium

comment created time in 2 days

PullRequestReviewEvent

Pull request review commentPolymathNetwork/Polymesh

MESH-1752 check custom asset type id

 decl_module! {         const AssetNameMaxLength: u32 = T::AssetNameMaxLength::get();         const FundingRoundNameMaxLength: u32 = T::FundingRoundNameMaxLength::get(); +        fn on_runtime_upgrade() -> frame_support::weights::Weight {+            use frame_support::weights::constants::WEIGHT_PER_MICROS;+            // Keep track of upgrade cost.+            let mut weight = 0u64;+            storage_migrate_on!(StorageVersion::get(), 1, {+                let mut total_len = 0u64;+                // Get list of assets with invalid asset_types.+                let fix_list = Tokens::iter()+                    .filter(|(_, token)| {+                        total_len += 1;+                        // Check if the asset_type is invalid.+                        Self::ensure_asset_type_valid(token.asset_type).is_err()+                    }).map(|(ticker, _)| ticker).collect::<Vec<_>>();

Not sure why this allocation is necessary. You should be able to mutate the asset type on the fly instead. with the mutation in an .inspect(...) and then a .count() at the end to compute fix_len.

Neopallium

comment created time in 2 days

Pull request review commentPolymathNetwork/Polymesh

MESH-1752 check custom asset type id

 fn asset_type_custom_works() {     }); } +#[test]+fn invalid_custom_asset_type_check() {+    ExtBuilder::default().build().execute_with(|| {+        let owner = User::new(AccountKeyring::Dave);++        // Create ticker.+        let (ticker, _) = a_token(owner.did);++        let invalid_id = CustomAssetTypeId(1_000_000);+        assert_noop!(+            Asset::create_asset(+                owner.origin(),+                ticker.as_ref().into(),+                ticker,+                true,+                AssetType::Custom(invalid_id),+                vec![],+                None,+                false,+            ),

Simpler if you bind mut token, modify token.asset_type, and then use basic_asset

Neopallium

comment created time in 2 days

Pull request review commentPolymathNetwork/Polymesh

MESH-1752 check custom asset type id

 decl_module! {         const AssetNameMaxLength: u32 = T::AssetNameMaxLength::get();         const FundingRoundNameMaxLength: u32 = T::FundingRoundNameMaxLength::get(); +        fn on_runtime_upgrade() -> frame_support::weights::Weight {+            use frame_support::weights::constants::WEIGHT_PER_MICROS;+            // Keep track of upgrade cost.+            let mut weight = 0u64;+            storage_migrate_on!(StorageVersion::get(), 1, {+                let mut total_len = 0u64;+                // Get list of assets with invalid asset_types.+                let fix_list = Tokens::iter()+                    .filter(|(_, token)| {+                        total_len += 1;

Nit: There's .inspect(...) for this.

Neopallium

comment created time in 2 days

PullRequestReviewEvent
PullRequestReviewEvent
PullRequestReviewEvent

Pull request review commentPolymathNetwork/Polymesh

MESH-1743 Add rotate_primary_key extrinsic

 benchmarks! {         );     }: _(new_key.origin, owner_auth_id, Some(cdd_auth_id)) +    rotate_primary_key_to_secondary {+        let cdd = cdd_provider::<T>("cdd", 0);+        let target = user::<T>("target", 0);+        let new_key = UserBuilder::<T>::default().build("key");+        let signatory = Signatory::Account(new_key.account());++        let cdd_auth_id =  Module::<T>::add_auth(+            cdd.did(), signatory.clone(),+            AuthorizationData::AttestPrimaryKeyRotation(target.did()),+            None,+        );+        let rotate_auth_id =  Module::<T>::add_auth(+            target.did(), signatory.clone(),+            AuthorizationData::RotatePrimaryKeyToSecondary(Permissions::default()),+            None,+        );+        Module::<T>::change_cdd_requirement_for_mk_rotation(+            RawOrigin::Root.into(),+            true+        ).unwrap();++    }: _(new_key.origin, rotate_auth_id, Some(cdd_auth_id))

There's some deduping potential here

raycar5

comment created time in 2 days

PR merged PolymathNetwork/Polymesh

Bring in some substrate 3.0 changes to staking release-notes

Reviewing notes

  • Make sure to review with whitespace changes hidden and focus on the perf/semantic changes.
  • Many changes here are aimed at minimizing the diff to the tag v3.0.0 in substrate which is really the ultimate goal of this PR.

changelog

modified logic

  • Staking.{bond_extra, rebond} check that the new active amount >= the minimum_balance.
  • Staking.withdraw_unbonded is also updated to use minimum_balance instead of zero.
  • Staking.reap_stash now considers minimum_balance also.
  • Staking.validate can now throw errors StashIdentityDoesNotExist and StashIdentityNotPermissioned.
  • Staking.nominate now throws TooManyTargets on targets.len() <= MAX_NOMINATIONS. It also considers blocked validators.
+731 -864

3 comments

9 changed files

Centril

pr closed time in 2 days

push eventPolymathNetwork/Polymesh

Mazdak Farrokhzad

commit sha 03316682c9c4081f3244d6d593b6658998247b10

Bring in some substrate 3.0 changes to staking (#1156) * wip * wip * wip * wip * wip * wip * wip * wiP * wip * wip * fmt * wip * staking, nominate: enforce CDD * staking: remove noms on no DID Co-authored-by: Adam Dossa <adam.dossa@gmail.com>

view details

push time in 2 days

delete branch PolymathNetwork/Polymesh

delete branch : contracts-substrate-up

delete time in 2 days

push eventPolymathNetwork/Polymesh

raycar5

commit sha 757f7b573b07b6a0c92154843dbae13b84e6b4d2

MESH-1747 Added checks to secondary key limits (#1160) * Added checks to secondary key limits fixed make_multisig_signer and join_identity * Address PR comments * Address PR comments * remove unneeded dependencies Co-authored-by: Adam Dossa <adam.dossa@gmail.com>

view details

Robert Gabriel Jakabosky

commit sha 695bc62610b8fa6ee59c553b7832b9c55ca765fb

MESH-1748 improve default mutisig permissions (#1164) * Remove 'MultiSig' from default permissions of multisig signer. * Update permissions in MultiSig test. * Add permission checks for identity signers.

view details

raycar5

commit sha 5fec16fdfb05dc9022508880503e835ae9c1776c

MESH-1743 Add rotate_primary_key extrinsic (#1163) * Add rotate_primary_key extrinsic * Allow primary key rotations in more cases - accept_primary_key now allows new primary keys which used to be secondary keys. - rotate_primary_key_to_secondary now allows new primary keys which weren't secondary keys * Apply suggestions from code review Co-authored-by: FOB <42175565+F-OBrien@users.noreply.github.com> * Refactor out common code * remove unused functions * link new primary key if it is not a secondary key * Apply suggestions from code review Co-authored-by: Robert Gabriel Jakabosky <rjakabosky+neopallium@neoawareness.com> * refactor all into common function and improve tests * Fix rotate primary key benchmark. * update fees * new CallTypeand modify schema * Update comment Co-authored-by: FOB <42175565+F-OBrien@users.noreply.github.com> Co-authored-by: Robert Gabriel Jakabosky <rjakabosky+neopallium@neoawareness.com> Co-authored-by: Adam Dossa <adam.dossa@gmail.com>

view details

Mazdak Farrokhzad

commit sha 8c9f513574407bcfec9682a8e39833368cb758eb

Merge branch 'develop' into contracts-substrate-up

view details

push time in 2 days

Pull request review commentAleoHQ/leo

[Impl] Adds ir.json

 impl<'a, 'b> Compiler<'a, 'b> {              writer(".leo.ir", compiled.serialize().unwrap());             writer(".leo.ir.fmt", compiled.to_string().as_bytes().to_vec());+            writer(+                ".leo.ir.json",+                serde_json::to_string(&compiled).unwrap().as_bytes().to_vec(),+            );

Consider a helper closure that also does .as_bytes().to_vec()

damirka

comment created time in 2 days

PullRequestReviewEvent
PullRequestReviewEvent
PullRequestReviewEvent

Pull request review commentPolymathNetwork/Polymesh

[WIP] Remove all duplicate calls to ensure_call_permissions

 impl<T: Config> Module<T> {     pub fn ensure_call_permissions(         who: &T::AccountId,     ) -> Result<AccountCallPermissionsData<T::AccountId>, DispatchError> {+        #[cfg(feature = "testing")]

(Let's add some commentary when this is less WIP)

CJP10

comment created time in 9 days

PullRequestReviewEvent
more