Skip to content

feat(rs-sdk): fetch document, identity, data contract and list documents - #1451

Merged
lklimek merged 153 commits into
feat/rs-drive-light-clientfrom
rs-sdk/test-fetch-and-list
Oct 25, 2023
Merged

lklimek merged 153 commits into
feat/rs-drive-light-clientfrom
rs-sdk/test-fetch-and-list

Conversation

@lklimek

@lklimek lklimek commented Oct 4, 2023 •

Copy link
Copy Markdown
Contributor

Issue being fixed or feature implemented

rs-sdk is a high-level crate that provides external developers with easy API interface to access the Dash Platform.

Identity, Data Contract and Document objects are base elements of rs-sdk. In this PR, we create initial version of rs-sdk.

What was done?

  1. fetch Document, Data Contract and Identity using Fetch trait
  2. list Documents using List trait
  3. mocking of all above
  4. unit tests

Notes for reviewer:

  1. changes in dapi-client already reviewed in feat(dapi): support mocks in rs-dapi-client #1417

How Has This Been Tested?

  • added tests to rs-sdk/tests/mock_*.rs
  • added tests that run against running platform (need updating some CONSTs before run)

Breaking Changes

None

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have made corresponding changes to the documentation

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

lklimek and others added 30 commits August 24, 2023 16:13
commit 9a0c9fa
Author: Lukasz Klimek <[email protected]>
Date:   Thu Aug 24 14:19:25 2023 +0200

    refactor: FromProof - use type instead of generic for Response

commit 9b35c88
Author: Lukasz Klimek <[email protected]>
Date:   Thu Aug 24 13:55:26 2023 +0200

    chore: remove FromProof for identities_*

commit e1d978f
Author: Lukasz Klimek <[email protected]>
Date:   Thu Aug 24 13:49:30 2023 +0200

    test: proof of identity balance and revision

commit 1ca28ca
Author: Lukasz Klimek <[email protected]>
Date:   Thu Aug 24 12:44:57 2023 +0200

    fix: FromProof for GetIdentityKeysRequest

commit 947d5b4
Author: Quantum Explorer <[email protected]>
Date:   Wed Aug 23 16:03:36 2023 +0200

    more fixes

commit 8de2aea
Merge: dccbad8 61fbb27
Author: Quantum Explorer <[email protected]>
Date:   Wed Aug 23 14:21:18 2023 +0200

    Merge branch 'fix/verifyFixes' of github.com:dashpay/platform into fix/verifyFixes

commit dccbad8
Author: Quantum Explorer <[email protected]>
Date:   Wed Aug 23 14:20:35 2023 +0200

    fix

commit 61fbb27
Author: Lukasz Klimek <[email protected]>
Date:   Tue Aug 22 17:41:04 2023 +0200

    test: proof identity_ok

commit 6b3bed1
Author: Lukasz Klimek <[email protected]>
Date:   Tue Aug 22 17:18:49 2023 +0200

    chore: fix error handling after merge

commit 262604b
Merge: 8829b65 8d648e9
Author: Lukasz Klimek <[email protected]>
Date:   Tue Aug 22 17:15:26 2023 +0200

    Merge branch 'proof-identity-keys' into fix/verifyFixes

commit 8829b65
Merge: e6707bb 76e8365
Author: Lukasz Klimek <[email protected]>
Date:   Tue Aug 22 17:15:13 2023 +0200

    Merge remote-tracking branch 'origin/feat/rs-drive-light-client' into fix/verifyFixes

commit 8d648e9
Author: Lukasz Klimek <[email protected]>
Date:   Tue Aug 22 17:00:09 2023 +0200

    test: identity keys

commit 811177b
Author: Lukasz Klimek <[email protected]>
Date:   Tue Aug 22 16:34:14 2023 +0200

    fix: from_proof for identity_keys

commit 577a15e
Author: Lukasz Klimek <[email protected]>
Date:   Tue Aug 22 16:33:53 2023 +0200

    test: identity

commit e6707bb
Author: Lukasz Klimek <[email protected]>
Date:   Mon Aug 21 16:52:08 2023 +0200

    chore: fix from_proof for IdentityBalanceAndRevision

commit 57b3fa4
Author: Quantum Explorer <[email protected]>
Date:   Fri Aug 18 15:09:51 2023 +0200

    pushed out error

commit e15bb97
Author: Quantum Explorer <[email protected]>
Date:   Fri Aug 18 14:35:00 2023 +0200

    more fixes
Comment thread packages/dapi-grpc/src/lib.rs Resolved
impl Query<GetIdentityRequest> for dpp::prelude::Identifier {
fn query(self) -> Result<GetIdentityRequest, Error> {
let id = self.to_vec();
Ok(GetIdentityRequest { id, prove: true })

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm a little confused because of the prove: true. It might be because I'm not aware about the original task.

Why did we start with querying proofs and not actual platform types? (Identity, Document, and etc)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We query proofs because I believe this is the correct way to do this.

Our implementation:

  • retrieves the proof using dapi
  • verifies grovedb proof
  • verifies tenderdash-generated proof (eg. quorum signatures, etc)
  • extracts the object (like Identity) from the proof and returns it to the user

This way the sdk user receives correct, proved object, without any chance to modify it.

If we were receiving only the objects (that is, prove: false), there is a risk that data can be modified by attacker during transit or on the dapi server. Here, the user can be certain that received info is correct.

Having that said, in future, we might implement "non-proved" version of requests. I'll modify the query trait to support that.

@lklimek lklimek Oct 19, 2023 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated the trait to add support in future in 6d08229a6c898d24bea834e604181aa9b5445d3e .

@QuantumExplorer QuantumExplorer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Very nice work, I do think you might have made your life a little more complicated than it needed to be, but this should work very nicely, and might be the right solution. I think time will tell once we start using it if it flows properly and people like it.

/// queryset limit
pub limit: u32,
/// first object to start with
pub start: Option<Start>,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think you need a start_included bool.

let request = query.query(sdk.prove())?;

let response = request
.clone()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

who do we need to clone the request?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

(not saying that this is a problem, just curious)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

execute() consumes the request, so we need to clone it here in order to log it later and pass to sdk.parse_proof.

Comment thread packages/rs-sdk/src/platform/list.rs Outdated

/// Trait implemented by objects that can be listed or searched.
#[async_trait::async_trait]
pub trait List

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Rename to FetchList or FetchMany (I think FetchMany is better but would be okay with FetchList)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Renamed to FetchMany

Base automatically changed from proof-documents to feat/rs-drive-light-client October 24, 2023 12:49
@lklimek
lklimek merged commit 9532379 into feat/rs-drive-light-client Oct 25, 2023
@lklimek
lklimek deleted the rs-sdk/test-fetch-and-list branch October 25, 2023 06:49
@lklimek lklimek mentioned this pull request Nov 22, 2026
10 of 13 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants