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: flatten asset definitions and assets in data model #4792

Merged
merged 1 commit into from
Jul 9, 2024

Conversation

SamHSmith
Copy link
Contributor

Description

Linked issue

Closes #{issue_number}

Benefits

Checklist

  • I've read CONTRIBUTING.md
  • I've used the standard signed-off commit format (or will squash just before merging)
  • All applicable CI checks pass (or I promised to make them pass later)
  • (optional) I've written unit tests for the code changes
  • I replied to all comments after code review, marking all implemented changes with thumbs up

@SamHSmith SamHSmith self-assigned this Jun 30, 2024
@github-actions github-actions bot added the api-changes Changes in the API for client libraries label Jun 30, 2024
core/src/smartcontracts/isi/account.rs Outdated Show resolved Hide resolved
core/src/smartcontracts/isi/asset.rs Outdated Show resolved Hide resolved
core/src/smartcontracts/isi/domain.rs Outdated Show resolved Hide resolved
core/src/state.rs Outdated Show resolved Hide resolved
core/src/state.rs Outdated Show resolved Hide resolved
core/src/state.rs Outdated Show resolved Hide resolved
core/src/state.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@mversic mversic left a comment

Choose a reason for hiding this comment

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

you have to fix this:

  • on Unregister<Account> remove all entries from World::assets
  • on Unregister<Domain> remove all entries from World::asset_definitions

@SamHSmith SamHSmith force-pushed the full_shallow_domain branch 2 times, most recently from 90ea924 to 682d6f5 Compare July 1, 2024 17:57
nxsaken
nxsaken previously approved these changes Jul 1, 2024
@nxsaken
Copy link
Contributor

nxsaken commented Jul 1, 2024

Torii tests need to be updated, otherwise looks good

data_model/src/domain.rs Outdated Show resolved Hide resolved
@SamHSmith SamHSmith force-pushed the full_shallow_domain branch 2 times, most recently from 2381938 to 0a3f986 Compare July 2, 2024 18:17
@SamHSmith SamHSmith force-pushed the full_shallow_domain branch 2 times, most recently from aefab6d to b83b5b1 Compare July 4, 2024 03:37
mversic
mversic previously approved these changes Jul 4, 2024
@mversic mversic requested a review from Erigara July 4, 2024 06:52
nxsaken
nxsaken previously approved these changes Jul 4, 2024
Erigara
Erigara previously requested changes Jul 4, 2024
Copy link
Contributor

@Erigara Erigara left a comment

Choose a reason for hiding this comment

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

Let me check smt.

EDIT:
As i said in my previous comment AssetIds are ordered by AssetDefinitionId first, so current usage of AssetByAccountBounds is not correct, because all assets for AccountId are not in the same adjacent to each other.

    #[test]
    fn asset_account_range() {
        let domain_id: DomainId = "wonderland".parse().unwrap();

        let account_id = gen_account_in("wonderland").0;

        let accounts = [
            account_id.clone(),
            account_id.clone(),
            gen_account_in("a").0,
            gen_account_in("b").0,
            gen_account_in("z").0,
            gen_account_in("z").0,
        ];
        let asset_definitions = [
            AssetDefinitionId::new(domain_id.clone(), "a".parse().unwrap()),
            AssetDefinitionId::new(domain_id.clone(), "f".parse().unwrap()),
            AssetDefinitionId::new(domain_id.clone(), "b".parse().unwrap()),
            AssetDefinitionId::new(domain_id.clone(), "c".parse().unwrap()),
            AssetDefinitionId::new(domain_id.clone(), "d".parse().unwrap()),
            AssetDefinitionId::new(domain_id.clone(), "e".parse().unwrap()),
        ];

        let assets = accounts
            .into_iter()
            .zip(asset_definitions)
            .map(|(account, asset_definiton)| AssetId::new(asset_definiton, account))
            .map(|asset| (asset, ()));

        let map = Storage::from_iter(assets);

        let view = map.view();
        let range = view.range(AssetByAccountBounds::new(&account_id));
        assert_eq!(range.count(), 2);
    }

core/src/state.rs Outdated Show resolved Hide resolved
core/src/state.rs Outdated Show resolved Hide resolved
core/src/state.rs Show resolved Hide resolved
core/src/smartcontracts/isi/domain.rs Outdated Show resolved Hide resolved
core/src/smartcontracts/isi/domain.rs Outdated Show resolved Hide resolved
core/src/state.rs Outdated Show resolved Hide resolved
@mversic mversic requested review from mversic and Erigara July 4, 2024 07:56
@SamHSmith SamHSmith dismissed stale reviews from nxsaken and mversic via 6a1be72 July 8, 2024 22:27
@SamHSmith
Copy link
Contributor Author

I swapped the internal order of AssetId to make it sort correctly. Api remains the same.

@nxsaken nxsaken dismissed Erigara’s stale review July 9, 2024 06:35

Sorting was fixed

Signed-off-by: Sam H. Smith <sam.henning.smith@protonmail.com>
@nxsaken nxsaken merged commit b415c73 into hyperledger:main Jul 9, 2024
9 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api-changes Changes in the API for client libraries
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants