feat: attribute typing #40

Merged
0xmuralik merged 24 commits from murali/attribute-typing into main 2022-11-15 06:21:14 +00:00
0xmuralik commented 2022-10-13 06:27:06 +00:00 (Migrated from github.com)

Fixes part of: #27

Description

type ServiceProviderRecord struct {
    BondID string
    LaconicID string
    X500 struct {
        CommonName stirng
        Etc ....
    }
}

type WebsiteRegistrationRecord struct {
    Url string
    RepoRegistrationRecordCID cid.CID
    BuildArtifactCID cid.CID
    TLSCertCID cid.CID // download cert, store on IPFS
}

// and then
type WatcherRegistrationRecord struct {
    ...
}
  1. Write proto types for the above
  2. Write the logic in the nameservice record registration/put methods to peform type introspection of the record.Attributes (resolve to one of the above protobuf types)
  3. Write the logic in the nameservice record put method (?) to write new secondary mapping between specific fields in the attributes type and the record type on disk
  4. Testing
  5. Modify the get methods in the keeper to leverage these new indexes

For contributor use:

  • Targeted PR against correct branch (see CONTRIBUTING.md)
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
  • Code follows the module structure standards.
  • Wrote unit and integration tests
  • Updated relevant documentation (docs/) or specification (x/<module>/spec/)
  • Added relevant godoc comments.
  • Added a relevant changelog entry to the Unreleased section in CHANGELOG.md
  • Re-reviewed Files changed in the Github PR explorer

For admin use:

  • Added appropriate labels to PR (ex. WIP, R4R, docs, etc)
  • Reviewers assigned
  • Squashed all commits, uses message "Merge pull request #XYZ: [title]" (coding standards)
Fixes part of: #27 ## Description ``` type ServiceProviderRecord struct { BondID string LaconicID string X500 struct { CommonName stirng Etc .... } } type WebsiteRegistrationRecord struct { Url string RepoRegistrationRecordCID cid.CID BuildArtifactCID cid.CID TLSCertCID cid.CID // download cert, store on IPFS } // and then type WatcherRegistrationRecord struct { ... } ``` 1. Write proto types for the above 2. Write the logic in the nameservice record registration/put methods to peform type introspection of the record.Attributes (resolve to one of the above protobuf types) 3. Write the logic in the nameservice record put method (?) to write new secondary mapping between specific fields in the attributes type and the record type on disk 4. Testing 5. Modify the get methods in the keeper to leverage these new indexes ______ For contributor use: - [ ] Targeted PR against correct branch (see [CONTRIBUTING.md](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] Linked to Github issue with discussion and accepted design OR link to spec that describes this work. - [ ] Code follows the [module structure standards](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules/structure.md). - [ ] Wrote unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] Updated relevant documentation (`docs/`) or specification (`x/<module>/spec/`) - [ ] Added relevant `godoc` [comments](https://blog.golang.org/godoc-documenting-go-code). - [ ] Added a relevant changelog entry to the `Unreleased` section in `CHANGELOG.md` - [ ] Re-reviewed `Files changed` in the Github PR explorer ______ For admin use: - [ ] Added appropriate labels to PR (ex. `WIP`, `R4R`, `docs`, etc) - [ ] Reviewers assigned - [ ] Squashed all commits, uses message "Merge pull request #XYZ: [title]" ([coding standards](https://github.com/tendermint/coding/blob/master/README.md#merging-a-pr))
ashwinphatak (Migrated from github.com) reviewed 2022-10-13 06:27:06 +00:00
github-code-scanning[bot] (Migrated from github.com) reviewed 2022-10-25 06:00:03 +00:00
@ -233,1 +289,3 @@
k.InsertRecordExpiryQueue(ctx, record.ToRecordObj())
recordObj, err := record.ToRecordObj()
if err != nil {
return err
github-code-scanning[bot] (Migrated from github.com) commented 2022-10-25 06:00:03 +00:00

the value in the range statement should be _ unless copying a map: want: for key := range m

the value in the range statement should be _ unless copying a map: want: for key := range m

Show more details

## the value in the range statement should be _ unless copying a map: want: for key := range m the value in the range statement should be _ unless copying a map: want: for key := range m [Show more details](https://github.com/cerc-io/laconicd/security/code-scanning/378)
github-code-scanning[bot] (Migrated from github.com) commented 2022-10-25 06:00:03 +00:00

the value in the range statement should be _ unless copying a map: want: for key := range m

expected exactly 1 statement (either append, delete, or copying to another map) in a range with a map, got 2

Show more details

## the value in the range statement should be _ unless copying a map: want: for key := range m expected exactly 1 statement (either append, delete, or copying to another map) in a range with a map, got 2 [Show more details](https://github.com/cerc-io/laconicd/security/code-scanning/382)
github-code-scanning[bot] (Migrated from github.com) commented 2022-10-25 06:00:03 +00:00

the value in the range statement should be _ unless copying a map: want: for key := range m

expected exactly 1 statement (either append, delete, or copying to another map) in a range with a map, got 2

Show more details

## the value in the range statement should be _ unless copying a map: want: for key := range m expected exactly 1 statement (either append, delete, or copying to another map) in a range with a map, got 2 [Show more details](https://github.com/cerc-io/laconicd/security/code-scanning/383)
github-code-scanning[bot] (Migrated from github.com) reviewed 2022-11-03 07:33:04 +00:00
@ -233,1 +289,3 @@
k.InsertRecordExpiryQueue(ctx, record.ToRecordObj())
recordObj, err := record.ToRecordObj()
if err != nil {
return err
github-code-scanning[bot] (Migrated from github.com) commented 2022-11-03 07:33:03 +00:00

got *ast.IfStmt; expected exactly 1 statement (either append or delete) in a range with a map

got *ast.IfStmt; expected exactly 1 statement (either append or delete) in a range with a map

Show more details

## got *ast.IfStmt; expected exactly 1 statement (either append or delete) in a range with a map got *ast.IfStmt; expected exactly 1 statement (either append or delete) in a range with a map [Show more details](https://github.com/cerc-io/laconicd/security/code-scanning/409)
github-code-scanning[bot] (Migrated from github.com) commented 2022-11-03 07:33:03 +00:00

got *ast.IfStmt; expected exactly 1 statement (either append or delete) in a range with a map

expected exactly 1 statement (either append, delete, or copying to another map) in a range with a map, got 2

Show more details

## got *ast.IfStmt; expected exactly 1 statement (either append or delete) in a range with a map expected exactly 1 statement (either append, delete, or copying to another map) in a range with a map, got 2 [Show more details](https://github.com/cerc-io/laconicd/security/code-scanning/410)
codecov-commenter commented 2022-11-08 11:18:06 +00:00 (Migrated from github.com)

Codecov Report

Merging #40 (2014eab) into main (a397ab5) will increase coverage by 0.25%.
The diff coverage is 47.77%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #40      +/-   ##
==========================================
+ Coverage   58.28%   58.53%   +0.25%     
==========================================
  Files         142      142              
  Lines       15561    15615      +54     
==========================================
+ Hits         9069     9141      +72     
+ Misses       6154     6120      -34     
- Partials      338      354      +16     
Impacted Files Coverage Δ
x/auction/module.go 0.00% <0.00%> (ø)
x/nameservice/keeper/msg_server.go 0.80% <0.00%> (ø)
x/bond/module.go 54.54% <11.11%> (-6.86%) ⬇️
x/nameservice/keeper/grpc_query.go 52.77% <40.00%> (+29.59%) ⬆️
x/nameservice/keeper/keeper.go 48.64% <45.11%> (+3.15%) ⬆️
x/bond/client/testutil/grpc.go 93.75% <100.00%> (ø)
x/bond/client/testutil/query.go 97.96% <100.00%> (ø)
x/bond/client/testutil/tx.go 100.00% <100.00%> (ø)
x/bond/keeper/grpc_query.go 100.00% <100.00%> (ø)
x/nameservice/client/testutil/grpc.go 96.21% <100.00%> (ø)
... and 5 more
# [Codecov](https://codecov.io/gh/cerc-io/laconicd/pull/40?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) Report > Merging [#40](https://codecov.io/gh/cerc-io/laconicd/pull/40?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) (2014eab) into [main](https://codecov.io/gh/cerc-io/laconicd/commit/a397ab5c6a96daab974ddddda1fcd40ad179d1e6?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) (a397ab5) will **increase** coverage by `0.25%`. > The diff coverage is `47.77%`. <details><summary>Additional details and impacted files</summary> [![Impacted file tree graph](https://codecov.io/gh/cerc-io/laconicd/pull/40/graphs/tree.svg?width=650&height=150&src=pr&token=5tWmn7LxfO&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None)](https://codecov.io/gh/cerc-io/laconicd/pull/40?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) ```diff @@ Coverage Diff @@ ## main #40 +/- ## ========================================== + Coverage 58.28% 58.53% +0.25% ========================================== Files 142 142 Lines 15561 15615 +54 ========================================== + Hits 9069 9141 +72 + Misses 6154 6120 -34 - Partials 338 354 +16 ``` | [Impacted Files](https://codecov.io/gh/cerc-io/laconicd/pull/40?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) | Coverage Δ | | |---|---|---| | [x/auction/module.go](https://codecov.io/gh/cerc-io/laconicd/pull/40/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-eC9hdWN0aW9uL21vZHVsZS5nbw==) | `0.00% <0.00%> (ø)` | | | [x/nameservice/keeper/msg\_server.go](https://codecov.io/gh/cerc-io/laconicd/pull/40/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-eC9uYW1lc2VydmljZS9rZWVwZXIvbXNnX3NlcnZlci5nbw==) | `0.80% <0.00%> (ø)` | | | [x/bond/module.go](https://codecov.io/gh/cerc-io/laconicd/pull/40/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-eC9ib25kL21vZHVsZS5nbw==) | `54.54% <11.11%> (-6.86%)` | :arrow_down: | | [x/nameservice/keeper/grpc\_query.go](https://codecov.io/gh/cerc-io/laconicd/pull/40/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-eC9uYW1lc2VydmljZS9rZWVwZXIvZ3JwY19xdWVyeS5nbw==) | `52.77% <40.00%> (+29.59%)` | :arrow_up: | | [x/nameservice/keeper/keeper.go](https://codecov.io/gh/cerc-io/laconicd/pull/40/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-eC9uYW1lc2VydmljZS9rZWVwZXIva2VlcGVyLmdv) | `48.64% <45.11%> (+3.15%)` | :arrow_up: | | [x/bond/client/testutil/grpc.go](https://codecov.io/gh/cerc-io/laconicd/pull/40/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-eC9ib25kL2NsaWVudC90ZXN0dXRpbC9ncnBjLmdv) | `93.75% <100.00%> (ø)` | | | [x/bond/client/testutil/query.go](https://codecov.io/gh/cerc-io/laconicd/pull/40/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-eC9ib25kL2NsaWVudC90ZXN0dXRpbC9xdWVyeS5nbw==) | `97.96% <100.00%> (ø)` | | | [x/bond/client/testutil/tx.go](https://codecov.io/gh/cerc-io/laconicd/pull/40/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-eC9ib25kL2NsaWVudC90ZXN0dXRpbC90eC5nbw==) | `100.00% <100.00%> (ø)` | | | [x/bond/keeper/grpc\_query.go](https://codecov.io/gh/cerc-io/laconicd/pull/40/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-eC9ib25kL2tlZXBlci9ncnBjX3F1ZXJ5Lmdv) | `100.00% <100.00%> (ø)` | | | [x/nameservice/client/testutil/grpc.go](https://codecov.io/gh/cerc-io/laconicd/pull/40/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-eC9uYW1lc2VydmljZS9jbGllbnQvdGVzdHV0aWwvZ3JwYy5nbw==) | `96.21% <100.00%> (ø)` | | | ... and [5 more](https://codecov.io/gh/cerc-io/laconicd/pull/40/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) | | </details>
i-norden approved these changes 2022-11-14 16:40:30 +00:00
i-norden left a comment
Member

LGTM just a couple minor questions/comments. Thanks!

LGTM just a couple minor questions/comments. Thanks!
@ -151,1 +148,4 @@
# signingKey: "${{ secrets.CACHIX_SIGNING_KEY }}"
# - name: 'instantiate integration test env'
# run: nix-store -r $(nix-instantiate tests/integration_tests/shell.nix)
Member

Do these tests need to be commented out?

Do these tests need to be commented out?
Member

Let's add a small comment above like the other prefixes e.g. "PrefixAttributesIndex is the prefix for the nameservice Record.Attributes -> Record.ID index".

Let's add a small comment above like the other prefixes e.g. "PrefixAttributesIndex is the prefix for the nameservice Record.Attributes -> Record.ID index".
@ -41,3 +41,3 @@
sdk.NewAttribute(types.AttributeKeyBondID, msg.GetBondId()),
sdk.NewAttribute(types.AttributeKeyPayload, msg.Payload.String()),
sdk.NewAttribute(types.AttributeKeyPayload, msg.Payload.Record.Id),
),
Member

I like this change, seems better to emit only the ID, but want to double-check with Ashwin as to whether or not there was any reason to encode the entire payload into a tendermint event. Was there a specific motivation for this change?

I like this change, seems better to emit only the ID, but want to double-check with Ashwin as to whether or not there was any reason to encode the entire payload into a tendermint event. Was there a specific motivation for this change?
0xmuralik (Migrated from github.com) reviewed 2022-11-15 05:42:20 +00:00
@ -41,3 +41,3 @@
sdk.NewAttribute(types.AttributeKeyBondID, msg.GetBondId()),
sdk.NewAttribute(types.AttributeKeyPayload, msg.Payload.String()),
sdk.NewAttribute(types.AttributeKeyPayload, msg.Payload.Record.Id),
),
0xmuralik (Migrated from github.com) commented 2022-11-15 05:42:20 +00:00

Now that the attributes are of type codectypes.Any, We cant unmarshal PayLoad to a string type. There can be a workaround to convert it to the specific Payload type based on attribute type, If that's necessary.

Now that the attributes are of type codectypes.Any, We cant unmarshal PayLoad to a string type. There can be a workaround to convert it to the specific Payload type based on attribute type, If that's necessary.
0xmuralik (Migrated from github.com) reviewed 2022-11-15 05:54:44 +00:00
@ -151,1 +148,4 @@
# signingKey: "${{ secrets.CACHIX_SIGNING_KEY }}"
# - name: 'instantiate integration test env'
# run: nix-store -r $(nix-instantiate tests/integration_tests/shell.nix)
0xmuralik (Migrated from github.com) commented 2022-11-15 05:54:44 +00:00

The upload-cache test needs the integration test which has an issue with nixOS because of the added gql dependency as stated in a previous PR.
Commented out the upload-cache test as all the tests in test.yml file were being ignored because of this dependency error.

The upload-cache test needs the `integration test` which has an issue with nixOS because of the added gql dependency as stated in a previous PR. Commented out the upload-cache test as all the tests in test.yml file were being ignored because of this dependency error.
Sign in to join this conversation.
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: cerc-io/laconicd-deprecated#40
No description provided.