Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for creating confidential assets. #623

Merged
merged 4 commits into from Sep 23, 2020

Conversation

@ParnianAlimi
Copy link

@ParnianAlimi ParnianAlimi commented Sep 21, 2020

Addresses CRYP-153. Adds an extrinsic to register a confidential asset.

pallets/common/src/traits/asset.rs Show resolved Hide resolved
pallets/confidential-asset/src/lib.rs Outdated Show resolved Hide resolved
pallets/confidential-asset/src/lib.rs Outdated Show resolved Hide resolved
pallets/runtime/tests/src/settlement_test.rs Outdated Show resolved Hide resolved
pallets/runtime/tests/src/ext_builder.rs Outdated Show resolved Hide resolved
pallets/runtime/tests/src/statistics_test.rs Outdated Show resolved Hide resolved
pallets/runtime/tests/src/confidential_asset_test.rs Outdated Show resolved Hide resolved
pallets/runtime/tests/src/confidential_asset_test.rs Outdated Show resolved Hide resolved
pallets/common/src/traits/asset.rs Show resolved Hide resolved
pallets/confidential-asset/src/lib.rs Outdated Show resolved Hide resolved
pallets/asset/src/lib.rs Outdated Show resolved Hide resolved
None,
Some(total_supply),
total_supply,
);

This comment has been minimized.

@satyamakgec

satyamakgec Sep 22, 2020
Member

We don't need this at the time of the creation of the confidential asset. We are not minting anything here.

This comment has been minimized.

@ParnianAlimi

ParnianAlimi Sep 22, 2020
Author

Once Arash's code goes in, we will be calling this function with total_supply = 0, so it won't really do anything meaningful, but I'll make it more explicit.

This comment has been minimized.

@ParnianAlimi

ParnianAlimi Sep 22, 2020
Author

Thinking more about this, are you sure we don't need to update stats here? we are still adding a primary issuer for the asset and that should increment the number of investors of the asset.

This comment has been minimized.

@satyamakgec

satyamakgec Sep 23, 2020
Member

We are not really assigning the balance to the primary issuer so it doesn't make sense to call this.

This comment has been minimized.

@satyamakgec

satyamakgec Sep 23, 2020
Member

But we can capture this in another story if you want without delaying this PR approval.

Copy link
Collaborator

@vkomenda vkomenda left a comment

LGTM, just a few suggestions.

pallets/confidential-asset/src/lib.rs Outdated Show resolved Hide resolved
pallets/confidential-asset/src/lib.rs Outdated Show resolved Hide resolved

/// List of Tickers of the type ConfidentialAsset.
/// () -> List of confidential tickers
pub ConfidentialTickers get(fn confidential_tickers): Vec<AssetId>;

This comment has been minimized.

@vkomenda

vkomenda Sep 22, 2020
Collaborator

Any access would require decoding the entire Vec. There is a way around that, just use a characteristic function instead - a map from AssetId to bool.

BTreeSet would be better than Vec: log(n) reads as opposed to n. But again it would require reading the whole BTreeSet from runtime storage, which can be avoided.

This comment has been minimized.

@satyamakgec

satyamakgec Sep 22, 2020
Member

@aafshar-poly & I had a discussion about this couple of weeks ago. Arash do you guys still need the whole vector of asset_ids to validate the proof? I think it was more related to the index of asset_id. we can re-discuss this.

This comment has been minimized.

@ParnianAlimi

ParnianAlimi Sep 22, 2020
Author

Yes, we need the whole AssetID vector. The list of all confidential asset IDs ever created to be exact.

This comment has been minimized.

@vkomenda

vkomenda Sep 23, 2020
Collaborator

OK, got you. The only place I found in in this PR where confidential_tickers is called is an application of AccountCreator::create. It takes a reference to the Vec. I would suggest modifying AccountCreator::create to take &[Scalar] instead for uniformity and also because slices are better as arguments as opposed to &Vec<_>.

This comment has been minimized.

@ParnianAlimi

ParnianAlimi Sep 23, 2020
Author

I'll kindly ask @aafshar-poly to consider making this change in his PR.

Copy link
Collaborator

@vkomenda vkomenda left a comment

LGTM, a few suggestions.

{
type Event: From<Event> + Into<<Self as frame_system::Trait>::Event>;
pub trait Trait: frame_system::Trait + IdentityTrait + BalancesTrait {
type Asset: AssetTrait<Self::Balance, Self::AccountId>;

This comment has been minimized.

@vkomenda

vkomenda Sep 23, 2020
Collaborator

In general it would be good to have doc comments both on type parameters and the trait itself.

valid_asset_ids.clone(),
)
.unwrap();
let valid_asset_ids = ConfidentialAsset::confidential_tickers();

This comment has been minimized.

@vkomenda

vkomenda Sep 23, 2020
Collaborator

Unused variable.

This comment has been minimized.

@ParnianAlimi

ParnianAlimi Sep 23, 2020
Author

it's used on line 242.


/// List of Tickers of the type ConfidentialAsset.
/// () -> List of confidential tickers
pub ConfidentialTickers get(fn confidential_tickers): Vec<AssetId>;

This comment has been minimized.

@vkomenda

vkomenda Sep 23, 2020
Collaborator

OK, got you. The only place I found in in this PR where confidential_tickers is called is an application of AccountCreator::create. It takes a reference to the Vec. I would suggest modifying AccountCreator::create to take &[Scalar] instead for uniformity and also because slices are better as arguments as opposed to &Vec<_>.

Copy link
Member

@satyamakgec satyamakgec left a comment

Some minor nit-picks if you want to taker care before the merge 😉

None,
Some(total_supply),
total_supply,
);

This comment has been minimized.

@satyamakgec

satyamakgec Sep 23, 2020
Member

We are not really assigning the balance to the primary issuer so it doesn't make sense to call this.

None,
Some(total_supply),
total_supply,
);

This comment has been minimized.

@satyamakgec

satyamakgec Sep 23, 2020
Member

But we can capture this in another story if you want without delaying this PR approval.

Self::funding_round(ticker),
total_supply,
Some(did),
));

This comment has been minimized.

@satyamakgec

satyamakgec Sep 23, 2020
Member

Realistically we can cover this in the above if statement

@ParnianAlimi ParnianAlimi merged commit ff5a4c7 into mercat Sep 23, 2020
4 checks passed
4 checks passed
auto-merge Not merging
Details
WIP Ready for review
Details
ci/circleci: lint Your tests passed on CircleCI!
Details
ci/circleci: test Your tests passed on CircleCI!
Details
@aafshar-poly aafshar-poly deleted the CRYP-153/asset_registration_2 branch Sep 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

5 participants
You can’t perform that action at this time.