122: Fix attribute index key collision #123

Merged
telackey merged 3 commits from telackey/122 into main 2023-11-29 00:05:57 +00:00
Member

Fix #122, where the structure of the index key allowed unintended collisions (see below).

This also adds a test cases which fails under the old scheme, but passes now:

Before:

--- FAIL: TestKeeperTestSuite (0.31s)
    --- FAIL: TestKeeperTestSuite/TestGrpcGetRecordLists (0.09s)
        grpc_query_test.go:143:
                Error Trace:    /home/telackey/cerc/laconicd/x/registry/keeper/grpc_query_test.go:143
                                                        /home/telackey/cerc/laconicd/x/registry/keeper/suite.go:91
                Error:          Not equal:
                                expected: 0
                                actual  : 1
                Test:           TestKeeperTestSuite/TestGrpcGetRecordLists
        --- FAIL: TestKeeperTestSuite/TestGrpcGetRecordLists/Case_Filter_with_typ_(https://git.vdb.to/cerc-io/laconicd/issues/122)_ (0.00s)
            testing.go:1490: test executed panic(nil) or runtime.Goexit: subtest may have called FailNow on a parent test
FAIL
FAIL    github.com/cerc-io/laconicd/x/registry/keeper   0.765s
FAIL
make: *** [Makefile:333: run-tests] Error 1

❯ laconic cns record list --all --typ eWebsiteRegistrationRecord
[
  {
    "id": "bafyreies5he2mxyrjso2quewwlmh6cisekkjnf7yijpd2742wrzxgzuazi",
    "names": null,
    "owners": [
      "FC9B9FB065D70DBB10C8F511348421C16669B37D"
    ],
    "bondId": "a9c7161fc154cf44ee61efc699a59c8a27c804bb23ce4c8a7ffa0a39fcc540b1",
    "createTime": "2023-11-28T19:09:03Z",
    "expiryTime": "2024-11-27T19:09:03Z",
    "attributes": {
      "url": "https://hello-urbit.laconic.com",
      "repo_registration_record_cid": "QmTZQ8ZJS6mALjEM2wY71msFno6zzxFftVCiZELj9xREPx",
      "build_artifact_cid": "~lostex-rabdur-labtul-moltev/hello-urbit",
      "tls_cert_cid": "QmR1acEmQt7Tjmhp9cFtymie2eFcrHURQKt9kGto1TQTW1",
      "type": "WebsiteRegistrationRecord",
      "version": "0.2.4"
    }
  }
...

❯ laconic cns record list --all --type WebsiteRegistrationRecord
[
  {
    "id": "bafyreies5he2mxyrjso2quewwlmh6cisekkjnf7yijpd2742wrzxgzuazi",
    "names": null,
    "owners": [
      "FC9B9FB065D70DBB10C8F511348421C16669B37D"
    ],
    "bondId": "a9c7161fc154cf44ee61efc699a59c8a27c804bb23ce4c8a7ffa0a39fcc540b1",
    "createTime": "2023-11-28T19:09:03Z",
    "expiryTime": "2024-11-27T19:09:03Z",
    "attributes": {
      "url": "https://hello-urbit.laconic.com",
      "repo_registration_record_cid": "QmTZQ8ZJS6mALjEM2wY71msFno6zzxFftVCiZELj9xREPx",
      "build_artifact_cid": "~lostex-rabdur-labtul-moltev/hello-urbit",
      "tls_cert_cid": "QmR1acEmQt7Tjmhp9cFtymie2eFcrHURQKt9kGto1TQTW1",
      "type": "WebsiteRegistrationRecord",
      "version": "0.2.4"
    }
  }
...

After:

ok      github.com/cerc-io/laconicd/x/registry/keeper   1.573s

❯ laconic cns record list --all --typ eWebsiteRegistrationRecord
[]

❯ laconic cns record list --all --type WebsiteRegistrationRecord
[
  {
    "id": "bafyreies5he2mxyrjso2quewwlmh6cisekkjnf7yijpd2742wrzxgzuazi",
    "names": null,
    "owners": [
      "FC9B9FB065D70DBB10C8F511348421C16669B37D"
    ],
    "bondId": "a9c7161fc154cf44ee61efc699a59c8a27c804bb23ce4c8a7ffa0a39fcc540b1",
    "createTime": "2023-11-28T19:09:03Z",
    "expiryTime": "2024-11-27T19:09:03Z",
    "attributes": {
      "url": "https://hello-urbit.laconic.com",
      "repo_registration_record_cid": "QmTZQ8ZJS6mALjEM2wY71msFno6zzxFftVCiZELj9xREPx",
      "build_artifact_cid": "~lostex-rabdur-labtul-moltev/hello-urbit",
      "tls_cert_cid": "QmR1acEmQt7Tjmhp9cFtymie2eFcrHURQKt9kGto1TQTW1",
      "type": "WebsiteRegistrationRecord",
      "version": "0.2.4"
    }
  }
...
Fix #122, where the structure of the index key allowed unintended collisions (see below). This also adds a test cases which _fails_ under the old scheme, but passes now: **Before:** ``` --- FAIL: TestKeeperTestSuite (0.31s) --- FAIL: TestKeeperTestSuite/TestGrpcGetRecordLists (0.09s) grpc_query_test.go:143: Error Trace: /home/telackey/cerc/laconicd/x/registry/keeper/grpc_query_test.go:143 /home/telackey/cerc/laconicd/x/registry/keeper/suite.go:91 Error: Not equal: expected: 0 actual : 1 Test: TestKeeperTestSuite/TestGrpcGetRecordLists --- FAIL: TestKeeperTestSuite/TestGrpcGetRecordLists/Case_Filter_with_typ_(https://git.vdb.to/cerc-io/laconicd/issues/122)_ (0.00s) testing.go:1490: test executed panic(nil) or runtime.Goexit: subtest may have called FailNow on a parent test FAIL FAIL github.com/cerc-io/laconicd/x/registry/keeper 0.765s FAIL make: *** [Makefile:333: run-tests] Error 1 ❯ laconic cns record list --all --typ eWebsiteRegistrationRecord [ { "id": "bafyreies5he2mxyrjso2quewwlmh6cisekkjnf7yijpd2742wrzxgzuazi", "names": null, "owners": [ "FC9B9FB065D70DBB10C8F511348421C16669B37D" ], "bondId": "a9c7161fc154cf44ee61efc699a59c8a27c804bb23ce4c8a7ffa0a39fcc540b1", "createTime": "2023-11-28T19:09:03Z", "expiryTime": "2024-11-27T19:09:03Z", "attributes": { "url": "https://hello-urbit.laconic.com", "repo_registration_record_cid": "QmTZQ8ZJS6mALjEM2wY71msFno6zzxFftVCiZELj9xREPx", "build_artifact_cid": "~lostex-rabdur-labtul-moltev/hello-urbit", "tls_cert_cid": "QmR1acEmQt7Tjmhp9cFtymie2eFcrHURQKt9kGto1TQTW1", "type": "WebsiteRegistrationRecord", "version": "0.2.4" } } ... ❯ laconic cns record list --all --type WebsiteRegistrationRecord [ { "id": "bafyreies5he2mxyrjso2quewwlmh6cisekkjnf7yijpd2742wrzxgzuazi", "names": null, "owners": [ "FC9B9FB065D70DBB10C8F511348421C16669B37D" ], "bondId": "a9c7161fc154cf44ee61efc699a59c8a27c804bb23ce4c8a7ffa0a39fcc540b1", "createTime": "2023-11-28T19:09:03Z", "expiryTime": "2024-11-27T19:09:03Z", "attributes": { "url": "https://hello-urbit.laconic.com", "repo_registration_record_cid": "QmTZQ8ZJS6mALjEM2wY71msFno6zzxFftVCiZELj9xREPx", "build_artifact_cid": "~lostex-rabdur-labtul-moltev/hello-urbit", "tls_cert_cid": "QmR1acEmQt7Tjmhp9cFtymie2eFcrHURQKt9kGto1TQTW1", "type": "WebsiteRegistrationRecord", "version": "0.2.4" } } ... ``` **After:** ``` ok github.com/cerc-io/laconicd/x/registry/keeper 1.573s ❯ laconic cns record list --all --typ eWebsiteRegistrationRecord [] ❯ laconic cns record list --all --type WebsiteRegistrationRecord [ { "id": "bafyreies5he2mxyrjso2quewwlmh6cisekkjnf7yijpd2742wrzxgzuazi", "names": null, "owners": [ "FC9B9FB065D70DBB10C8F511348421C16669B37D" ], "bondId": "a9c7161fc154cf44ee61efc699a59c8a27c804bb23ce4c8a7ffa0a39fcc540b1", "createTime": "2023-11-28T19:09:03Z", "expiryTime": "2024-11-27T19:09:03Z", "attributes": { "url": "https://hello-urbit.laconic.com", "repo_registration_record_cid": "QmTZQ8ZJS6mALjEM2wY71msFno6zzxFftVCiZELj9xREPx", "build_artifact_cid": "~lostex-rabdur-labtul-moltev/hello-urbit", "tls_cert_cid": "QmR1acEmQt7Tjmhp9cFtymie2eFcrHURQKt9kGto1TQTW1", "type": "WebsiteRegistrationRecord", "version": "0.2.4" } } ... ```
telackey added 3 commits 2023-11-28 20:48:50 +00:00
118: queryRecords should return [] when no matching records exist, not an error
Some checks failed
Build / cleanup-runs (pull_request) Successful in 5s
Deploy Contract / cleanup-runs (pull_request) Successful in 5s
CodeQL / Analyze (go) (pull_request) Failing after 39s
Deploy Contract / deploy (pull_request) Failing after 36s
Pull Request Labeler / triage (pull_request) Successful in 10s
Build / build (pull_request) Failing after 1m3s
Dependency Review / dependency-review (pull_request) Failing after 1m3s
Run Gosec / Gosec (pull_request) Failing after 13s
Semgrep / Scan (pull_request) Failing after 11s
Tests / cleanup-runs (pull_request) Failing after 5s
Lint / Run flake8 on python integration tests (pull_request) Failing after 34s
Tests / test-unit-cover (pull_request) Failing after 42s
Tests / test-importer (pull_request) Failing after 39s
Lint / Run golangci-lint (pull_request) Failing after 1m27s
Tests / test-rpc (pull_request) Failing after 58s
Tests / sdk_tests (pull_request) Failing after 1m40s
cd144330aa
122: Fix attribute index key collision
Some checks failed
Build / cleanup-runs (pull_request) Failing after 3s
Build / build (pull_request) Failing after 57s
CodeQL / Analyze (go) (pull_request) Failing after 13s
Deploy Contract / cleanup-runs (pull_request) Failing after 2s
Deploy Contract / deploy (pull_request) Failing after 36s
Pull Request Labeler / triage (pull_request) Successful in 4s
Dependency Review / dependency-review (pull_request) Failing after 44s
Lint / Run flake8 on python integration tests (pull_request) Failing after 44s
Semgrep / Scan (pull_request) Failing after 5s
Lint / Run golangci-lint (pull_request) Failing after 47s
Tests / cleanup-runs (pull_request) Failing after 3s
Run Gosec / Gosec (pull_request) Failing after 23s
Tests / test-unit-cover (pull_request) Failing after 1m16s
Tests / test-importer (pull_request) Failing after 1m15s
Tests / test-rpc (pull_request) Failing after 1m24s
Tests / sdk_tests (pull_request) Failing after 1m46s
113c9125e4
telackey changed title from telackey/122 to 122: Fix attribute index key collision 2023-11-28 20:49:16 +00:00
telackey requested review from dboreham 2023-11-28 20:49:19 +00:00
telackey self-assigned this 2023-11-28 20:53:53 +00:00
telackey merged commit 880367d5df into main 2023-11-29 00:05:57 +00:00
telackey deleted branch telackey/122 2023-11-29 00:05:58 +00:00
Sign in to join this conversation.
No reviewers
No Milestone
No project
No Assignees
1 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#123
No description provided.