Skip to content

Commit 034ef55

Browse files
committed
Merge branch 'master' into #303-Upgrade-Cosmos-SDK
Signed-off-by: Abdulbois <abdulbois123@gmail.com> # Conflicts: # integration_tests/cli/compliance-demo.sh # integration_tests/cli/compliance-provisioning.sh # integration_tests/cli/compliance-revocation.sh # integration_tests/cli/model-demo.sh # integration_tests/cli/modelversion-demo.sh # integration_tests/cli/pki-demo.sh # integration_tests/cli/pki-revocation-points.sh # integration_tests/cli/vendorinfo-demo.sh # integration_tests/light_client_proxy/pki.sh # proto/zigbeealliance/distributedcomplianceledger/pki/approved_certificates.proto # proto/zigbeealliance/distributedcomplianceledger/pki/genesis.proto # proto/zigbeealliance/distributedcomplianceledger/pki/noc_certificates.proto # proto/zigbeealliance/distributedcomplianceledger/pki/noc_root_certificates.proto # proto/zigbeealliance/distributedcomplianceledger/pki/query.proto # proto/zigbeealliance/distributedcomplianceledger/pki/revoked_noc_root_certificates.proto # types/pki/errors.go # x/compliance/types/compliance_info.pb.go # x/compliance/types/device_software_compliance.pb.go # x/compliance/types/genesis.pb.go # x/compliance/types/tx.pb.go # x/model/types/model.pb.go # x/model/types/model_version.pb.go # x/model/types/tx.pb.go # x/pki/keeper/msg_server_add_x_509_cert.go # x/pki/keeper/msg_server_propose_add_x_509_root_cert.go # x/pki/keeper/msg_server_revoke_x_509_cert.go # x/pki/types/approved_certificates.pb.go # x/pki/types/certificate.pb.go # x/pki/types/genesis.pb.go # x/pki/types/pki_revocation_distribution_point.pb.go # x/pki/types/proposed_certificate.pb.go # x/pki/types/proposed_certificate_revocation.pb.go # x/pki/types/query.pb.go # x/pki/types/rejected_certificate.pb.go # x/pki/types/revoked_certificates.pb.go # x/pki/types/tx.pb.go # x/vendorinfo/types/tx.pb.go # x/vendorinfo/types/vendor_info.pb.go
2 parents 949ee0f + 7f9ce72 commit 034ef55

File tree

624 files changed

+193376
-6914
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

624 files changed

+193376
-6914
lines changed

.golangci.yml

+4
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ linters:
5555
- godot
5656
- inamedparam
5757
- goconst
58+
- nosnakecase
59+
- perfsprint
60+
- unparam
61+
- revive
5862

5963
issues:
6064
exclude-rules:

config.yml

+4
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,12 @@ faucet:
2222
- 100000stake
2323
host: 0.0.0.0:4500
2424
client:
25+
typescript:
26+
path: ts-client
2527
vuex:
2628
path: vue/src/store
29+
composables:
30+
path: vue/src/composables
2731
validators:
2832
- name: alice
2933
bonded: 100000000stake

docker-compose.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,4 +122,4 @@ networks:
122122
ipam:
123123
driver: default
124124
config:
125-
- subnet: 192.167.10.0/16
125+
- subnet: 192.167.10.0/24

docs/design/noc-root-cert-design.md

+25-12
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ To distinguesh NOC root certificates from others, an `isNOC` boolean field will
2121
This transaction adds a NOC root certificate owned by the Vendor.
2222

2323
- Who can send: Vendor account
24-
- `vid` field in the transaction (`VendorID`) must be equal to the Vendor account's VID
2524
- Validation:
2625
- The provided certificate must be a root certificate:
2726
- `Issuer` == `Subject`
@@ -33,7 +32,6 @@ This transaction adds a NOC root certificate owned by the Vendor.
3332
- The signature (self-signature) and expiration date must be valid.
3433
- Parameters:
3534
- cert: `string` - The NOC Root Certificate, encoded in X.509v3 PEM format. Can be a PEM string or a file path.
36-
- vid: `uint16` - Vendor ID (positive non-zero)
3735
- In State:
3836
- `pki/ApprovedCertificates/value/<Subject>/<SubjectKeyID>`
3937
- `pki/ApprovedCertificatesBySubject/value/<Subject>`
@@ -52,24 +50,35 @@ Revoked NOC root certificates can be re-added using the `ADD_NOC_X509_ROOT_CERTI
5250
- Parameters:
5351
- subject: `string` - Base64 encoded subject DER sequence bytes of the certificate.
5452
- subject_key_id: `string` - Certificate's `Subject Key Id` in hex string format, e.g., `5A:88:0E:6C:36:53:D0:7F:B0:89:71:A3:F4:73:79:09:30:E6:2B:DB`.
53+
- serial_number: `optional(string)` - Certificate's serial number. If not provided, the transaction will revoke all certificates that match the given `subject` and `subject_key_id` combination.
54+
- info: `optional(string)` - Information/notes for the revocation.
55+
- time: `optional(int64)` - Revocation time (number of nanoseconds elapsed since January 1, 1970 UTC). CLI uses the current time for that field.
56+
- revokeChild: `optional(bool)` - If true, then all certificates in the chain signed by the revoked certificate (intermediate, leaf) are revoked as well. If false, only the current root cert is revoked (default: false).
5557
- In State:
5658
- `pki/RevokedCertificates/value/<subject>/<subject_key_id>`
59+
- `pki/RevokedNOCRootCertificates/value/<subject>/<subject_key_id>`
5760
- CLI Command:
58-
- `dcld tx pki revoke-noc-x509-root-cert --subject=<base64 string> --subject-key-id=<hex string> --from=<account>`
61+
- `dcld tx pki revoke-noc-x509-root-cert --subject=<base64 string> --subject-key-id=<hex string> --serial-number=<string> --info=<string> --time=<int64> --revokeChild=<bool> --from=<account>`
5962

6063
### 3. REMOVE_NOC_X509_ROOT_CERTIFICATE
6164
This transaction completely removes a NOC root certificate owned by the Vendor.
6265
Removed NOC root certificates can be re-added using the `ADD_NOC_X509_ROOT_CERTIFICATE` transaction.
6366

67+
Revoked certificates that match the specified parameters will also be removed.
68+
69+
The certificates in the chain signed by the removed certificate (intermediate, leaf) will not be removed.
70+
6471
- Who can send: Vendor account
6572
- Vid field associated with the corresponding NOC root certificate on the ledger must be equal to the Vendor account's VID.
6673
- Validation:
6774
- A NOC root certificate with the provided `subject` and `subject_key_id` must exist in the ledger.
6875
- Parameters:
6976
- subject: `string` - Base64 encoded subject DER sequence bytes of the certificate.
7077
- subject_key_id: `string` - Certificate's `Subject Key Id` in hex string format, e.g., `5A:88:0E:6C:36:53:D0:7F:B0:89:71:A3:F4:73:79:09:30:E6:2B:DB`.
78+
- serial_number: `optional(string)` - Certificate's serial number. If not provided, the transaction will remove all certificates that match the given `subject` and `subject_key_id` combination.
79+
- info: `optional(string)` - Information/notes for the removal.
7180
- CLI Command:
72-
- `dcld tx pki remove-noc-x509-root-cert --subject=<base64 string> --subject-key-id=<hex string> --from=<account>`
81+
- `dcld tx pki remove-noc-x509-root-cert --subject=<base64 string> --subject-key-id=<hex string> --serial-number=<string> --info=<string> --from=<account>`
7382

7483
## Query
7584

@@ -97,14 +106,18 @@ Retrieve a list of all of NOC root certificates
97106
- Parameters:
98107
- Common pagination parameters
99108
- CLI Command:
100-
- `dcld query pki get_all_noc_x509_root_certs
109+
- `dcld query pki get_all_noc_x509_root_certs`
101110
- REST API:
102111
- GET `/dcl/pki/noc-root-certificates`
103112

104-
## Questions
105-
- Should a vendor be able to add multiple NOC root certificates with the same Subject and Subject Key Identifier combinations? If so, the vendor may want to remove a specific certificate from the list of certificates with the same Subject and Subject Key Identifier combinations.
106-
- Should the VID parameter be added to the `ADD_NOC_X509_ROOT_CERTIFICATE` transaction?
107-
- How should NOC root certificate be renewed with a new one?
108-
- Should the `REMOVE_NOC_X509_ROOT_CERTIFICATE` transaction also delete revoked certificates?
109-
- Should a user be able to retrieve all revoked NOC root certificates using the `GET_ALL_REVOKED_X509_NOC_ROOT_CERTS` transaction?
110-
- In the `Joint Fabric Proposal` document, the concept of a `Trust Quotient (TQ)` is introduced as a future consideration. This concept requires adding `Add Trust` and `Revoke Trust` requests for NOCs in the DCL. Should the implementation of these requests be included in the scope of the current task?
113+
### GET_ALL_REVOKED_NOC_X509_ROOT_CERTS
114+
115+
Gets all revoked NOC root certificates.
116+
117+
- Who can send: Any account
118+
- Parameters:
119+
- Common pagination parameters
120+
- CLI command:
121+
- `dcld query pki all-revoked-noc-x509-root-certs`
122+
- REST API:
123+
- GET `/dcl/pki/revoked-noc-root-certificates`

docs/design/schema-compatibility.md

+120
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
# Support for forward and backward compatibility in DCL schemes
2+
3+
Schema changes can cover a wide range of modifications with varying impacts on application compatibility and data integrity. Below are use cases with strategies to manage schema changes and ensure compatibility.
4+
5+
## I. Multiple versions can live in parallel
6+
7+
### 1. Strategy for Compatible Changes
8+
9+
For changes that are backward-compatible, such as adding optional fields or extending enumerations.
10+
11+
#### Option A: Add an optional version field to all DCL schema
12+
13+
**Description:**
14+
Implement an optional version field in all DCL schemas to track the schema version. This approach is simple and quick to execute, suitable primarily for compatible updates.
15+
16+
**Strategy steps:**
17+
18+
- One time actions:
19+
- Add an optional version field to all DCL schema
20+
- For each update:
21+
- Update the schema by introducing compatible changes (such as adding a new optional field).
22+
- Update transactions and queries if needed.
23+
- DCL doesn't fulfill the Schema version automatically
24+
- It will be up to the transaction submitter (Vendor) to specify a correct Schema version
25+
- If Schema Version is not set - then the initial version (version 0 or 1) is assumed
26+
- It will be up to the client application to process the Schema version
27+
28+
### 2. Strategy for Non-Compatible Changes
29+
30+
For significant changes that directly impact compatibility, such as adding mandatory fields or removing fields, splitting or merging schemas, changing enumerations.
31+
32+
#### Option B: Separate Schemas for Each Version
33+
34+
**Description:**
35+
Each version has its distinct schema, state and its own queries/requests. This strategy eliminates the need for data migration and allows different schema versions to coexist seamlessly.
36+
37+
**Strategy steps:**
38+
39+
- For each update:
40+
- Create a new version of a Schema and state (a new .proto file)
41+
- Implement transactions and queries for the new schema version.
42+
43+
#### Option C: Generic Schema Storage (Not Recommended for Production)
44+
45+
**Description:**
46+
Implement a flexible, generic schema structure that can support a wide range of data formats.
47+
48+
While offering a robust solution for handling radical changes, this method requires careful planning and development, which can potentially take a significant amount of time.
49+
50+
**Strategy steps:**
51+
52+
- One time actions:
53+
- Create a more flexible, generic schema structure to hold a wide range of data formats (Can be used [Any](https://github.com/protocolbuffers/protobuf/blob/main/src/google/protobuf/any.proto) as described in [ADR-19](https://docs.cosmos.network/v0.47/build/architecture/adr-019-protobuf-state-encoding#usage-of-any-to-encode-interfaces))
54+
- Migrate old states to the newer, generic schema.
55+
- Remove the states associated with the older schema versions.
56+
- Optioanlly can be implemented queries for requesting schemas with any return type
57+
- For each update:
58+
- Create a new Schema version (a new .proto file)
59+
- Implement transactions and queries that can handle data according to its version, including mechanisms for converting generic values into the corresponding schema version.
60+
61+
## II. New version replaces the legacy one (V2 replaces V1)
62+
63+
### 1. Strategy for Compatible or Convertible changes
64+
65+
For changes that are backward-compatible, such as adding optional or mandatory fields or extending enumerations
66+
67+
#### Option D: Not keeping backward compatibility in API
68+
69+
**Description:**
70+
This strategy focuses on updating the schema without ensuring backward compatibility at the API level. Since the schemas are compatible, there will likely be no need for migration.
71+
72+
**Strategy steps:**
73+
74+
- For each update:
75+
- Update the schema by introducing compatible changes (such as adding a new optional field).
76+
- Migrate old states to the newer if needed.
77+
- Update transactions and queries if needed.
78+
79+
#### Option E: Keeping backward compatibility in API
80+
81+
**Description:**
82+
The main idea of this strategy is the dynamically converting newer schemas into older ones. However, this method is only possible if there is compatibility between the newer and legacy schemas, allowing them to be converted to each other. Due to the on-the-fly data conversion, this approach does not support the Light Client in legacy APIs because the converted data is not stored in the state, preventing the generation of proofs.
83+
84+
**Strategy steps:**
85+
86+
- For each update:
87+
- Create a new version of a Schema and state (a new .proto file)
88+
- Migrate older states to newer schema version.
89+
- Remove the states associated with the older schema versions.
90+
- Implement transactions and queries for the new schema version.
91+
- Update older transactions and queries to converting data between the latest and older schema version, ensuring backward compatibility.
92+
- There will be separated API for each version of the schema, for example::
93+
- models/vid/pid
94+
- modelsV2/vid/pid
95+
- modelsV3/vid/pid
96+
97+
### 2. Strategy for Non-Compatible changes
98+
99+
For significant changes that directly impact compatibility, such as adding mandatory fields or removing fields, splitting or merging schemas, changing enumerations.
100+
101+
#### Optiona F: Not keeping backward compatibility in API
102+
103+
**Description:**
104+
This strategy focuses on updating the schema without ensuring backward compatibility at the API level. Since the schemas are not compatible, migration is carried out manually through a special transaction.
105+
106+
**Strategy steps:**
107+
108+
- For each update:
109+
- Update the schema by introducing changes.
110+
- Update transactions and queries if needed.
111+
- Add a new transaction to fulfill new required fields (essentially this is a manual migration via transactions)
112+
113+
#### Option G: Keeping backward compatibility in API
114+
115+
**Description:**
116+
It's not possible to replace an old version here. [Multiple versions can live in parallel: Strategy for Non-Compatible Changes](#2-strategy-for-non-compatible-changes) options should be used instead.
117+
118+
## Conclusion
119+
120+
To lay the foundation for future compatibility improvements, it's a good idea to start by adding a version field to each schema. For subsequent changes, we will then select the most appropriate strategy based on the nature of these changes.

0 commit comments

Comments
 (0)