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

[fix] #2227: Implement Register and Unregister for Asset #2333

Merged

Conversation

QuentinI
Copy link
Contributor

@QuentinI QuentinI commented Jun 8, 2022

Description of the Change

  • Implemented Register and Unregister instructions for Asset
  • Changed minting implementation to require registering the asset first
  • Adjusted public validators accordingly

Issue

Resolves #2227

Benefits

Consistency, no more "unsupported" Register/Unregister instructions

Possible Drawbacks

Register asset and Mint should now be considered together when implementing permission systems.

@github-actions github-actions bot added the iroha2-dev The re-implementation of a BFT hyperledger in RUST label Jun 8, 2022
@codecov
Copy link

codecov bot commented Jun 8, 2022

Codecov Report

Merging #2333 (2172a1e) into iroha2-dev (6973f71) will increase coverage by 4.46%.
The diff coverage is 76.26%.

❗ Current head 2172a1e differs from pull request most recent head 07c2a6f. Consider uploading reports for the commit 07c2a6f to get more accurate results

@@              Coverage Diff               @@
##           iroha2-dev    #2333      +/-   ##
==============================================
+ Coverage       65.50%   69.96%   +4.46%     
==============================================
  Files             133      140       +7     
  Lines           24697    27803    +3106     
==============================================
+ Hits            16177    19452    +3275     
+ Misses           8520     8351     -169     
Impacted Files Coverage Δ
cli/derive/src/lib.rs 74.72% <ø> (ø)
cli/src/torii/mod.rs 28.88% <ø> (ø)
client/src/http.rs 47.82% <ø> (ø)
config/src/lib.rs 15.38% <0.00%> (+1.09%) ⬆️
core/src/lib.rs 100.00% <ø> (ø)
core/src/smartcontracts/isi/account.rs 10.19% <0.00%> (-2.12%) ⬇️
core/src/smartcontracts/isi/block.rs 100.00% <ø> (ø)
core/src/smartcontracts/isi/domain.rs 39.82% <ø> (ø)
core/src/smartcontracts/isi/triggers.rs 0.00% <0.00%> (ø)
core/src/smartcontracts/isi/tx.rs 25.00% <ø> (ø)
... and 107 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 43be45f...07c2a6f. Read the comment docs.

mversic
mversic previously requested changes Jun 8, 2022
cli/src/torii/tests.rs Outdated Show resolved Hide resolved
client/tests/integration/register_asset.rs Outdated Show resolved Hide resolved
configs/peer/genesis.json Outdated Show resolved Hide resolved
tools/kagami/src/main.rs Outdated Show resolved Hide resolved
core/src/smartcontracts/isi/asset.rs Outdated Show resolved Hide resolved
permissions_validators/src/public_blockchain/burn.rs Outdated Show resolved Hide resolved
permissions_validators/src/public_blockchain/mint.rs Outdated Show resolved Hide resolved
core/src/wsv.rs Outdated Show resolved Hide resolved
permissions_validators/src/public_blockchain/burn.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@appetrosyan appetrosyan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is important for SDK developers. Need to update with #api_changes.

@appetrosyan appetrosyan mentioned this pull request Jun 8, 2022
12 tasks
@mversic mversic self-assigned this Jun 8, 2022
client/tests/integration/unstable_network.rs Outdated Show resolved Hide resolved
@@ -355,7 +403,6 @@ pub mod isi {
AssetValueType::BigQuantity,
)?;

wsv.asset_or_insert(&self.destination_id, 0_u128)?;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Erigara Be advised that this PR will conflict with your work.

@Arjentix Arjentix self-assigned this Jun 10, 2022
client/tests/integration/asset.rs Outdated Show resolved Hide resolved
core/src/smartcontracts/isi/account.rs Outdated Show resolved Hide resolved
core/src/smartcontracts/isi/account.rs Outdated Show resolved Hide resolved
core/src/smartcontracts/isi/account.rs Outdated Show resolved Hide resolved
core/src/smartcontracts/isi/mod.rs Show resolved Hide resolved
@Arjentix
Copy link
Contributor

Arjentix commented Jun 10, 2022

I'll approve when all tests will pass

@QuentinI
Copy link
Contributor Author

@Arjentix I don't think it's ready yet. Apart from there not being any consensus on #2339 , this PR as it is now introduces a loophole to mint non-mintable assets twice.

@Arjentix
Copy link
Contributor

Oh, yes, haven't think about it...

core/src/smartcontracts/isi/asset.rs Outdated Show resolved Hide resolved
@pesterev pesterev self-assigned this Jun 19, 2022
@appetrosyan
Copy link
Contributor

I think disallowing minting altogether and leaving registration as the only way to add non-mintable assets to accounts results in more straightforward API. Is there a particular reason you would want to support minting in this case?

The APIs are comparably simple, but in different ways.

If you retained the Mintable::Once variant, you can create an asset and can defer the amount that you wanted to mint. Why is this good? Consider that we made Mint variadic: it accepts multiple (AccountId, Asset, Quantity) tuples, and so if you want to create a non-mintable asset that is split evenly between e.g. shareholders of a company, you can do that in two instructions. If we don't allow it, we increase the load on the network, because to achieve the same result the person doing it has to split the single Mint ISI into a Mint and several transfers.

Moreover, we will need to synchronise the behaviour of Mint with the implementation in Execute for Register<AssetDefinition>, so nominally you have fewer instructions but each of them is more complex.

Both approaches are valid: in the CPU world what you propose is called CISC, while my stance is closer to RISC with SIMD. I personally would prefer that we kept the API changes in this PR to a minimum, but will approve given a good justification.

@QuentinI
Copy link
Contributor Author

Right, my stance on this was the way it was mostly because I confused AssetDefinition and Asset in regards to Mintable.
I reverted to having Mintable::Once and implemented your proposed solution for double-mint loophole:

So if Register has value 0, creates a Mintable::Once asset, while a register with any other non-zero value necessarily a Mintable::Not variant

I have one question in regards to that - in this implementation one can register Mintable::Once asset to any number of accounts as long as Register has value 0. Are we okay with that?

@QuentinI QuentinI force-pushed the 2227-unsupported-register branch 2 times, most recently from 3afc1a6 to f851ef5 Compare June 20, 2022 08:16
SamHSmith
SamHSmith previously approved these changes Jun 20, 2022
Copy link
Contributor

@SamHSmith SamHSmith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. But you should probably address marin's comment.

Copy link
Contributor

@pesterev pesterev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@safinsaf safinsaf deleted the branch hyperledger:iroha2-dev June 22, 2022 11:56
@safinsaf safinsaf closed this Jun 22, 2022
@safinsaf safinsaf reopened this Jun 22, 2022
Artemii Gerasimovich added 6 commits June 22, 2022 16:44
Signed-off-by: Artemii Gerasimovich <gerasimovich@soramitsu.co.jp>
…count for (un)registering an asset

Signed-off-by: Artemii Gerasimovich <gerasimovich@soramitsu.co.jp>
Signed-off-by: Artemii Gerasimovich <gerasimovich@soramitsu.co.jp>
Signed-off-by: Artemii Gerasimovich <gerasimovich@soramitsu.co.jp>
Signed-off-by: Artemii Gerasimovich <gerasimovich@soramitsu.co.jp>
Signed-off-by: Artemii Gerasimovich <gerasimovich@soramitsu.co.jp>
@appetrosyan appetrosyan merged commit 77e6429 into hyperledger:iroha2-dev Jun 22, 2022
BAStos525 pushed a commit to BAStos525/soramitsu-iroha that referenced this pull request Jul 8, 2022
…yperledger#2333)

Signed-off-by: Artemii Gerasimovich <gerasimovich@soramitsu.co.jp>
Signed-off-by: BAStos525 <jungle.vas@yandex.ru>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
iroha2-dev The re-implementation of a BFT hyperledger in RUST
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants