Skip to content

Commit

Permalink
#502 Add schema version field to entities
Browse files Browse the repository at this point in the history
- Make 0 as default value for `schemaVersion` field
- Remove `schemaVersion` from Product schema
- Minor refactoring

Signed-off-by: Abdulbois <abdulbois.tursunov@dsr-corporation.com>
Signed-off-by: Abdulbois <abdulbois123@gmail.com>
  • Loading branch information
Abdulbois committed Mar 20, 2024
1 parent 90d5611 commit 1076221
Show file tree
Hide file tree
Showing 39 changed files with 92 additions and 174 deletions.
28 changes: 14 additions & 14 deletions docs/transactions.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ Adds a record about a Vendor.
- companyLegalName: `string` - Legal name of the vendor company
- companyPreferredName: `optional(string)` - Preferred name of the vendor company
- vendorLandingPageURL: `optional(string)` - URL of the vendor's landing page
- schemaVersion: `optional(uint32)` - Schema version to support backward/forward compatability(default 1)
- schemaVersion: `optional(uint32)` - Schema version to support backward/forward compatability(default 0)
- In State: `vendorinfo/VendorInfo/value/<vid>`
- Who can send:
- Account with a vendor role who has the matching Vendor ID
Expand All @@ -148,7 +148,7 @@ Updates a record about a Vendor.
- companyLegalName: `optional(string)` - Legal name of the vendor company
- companyPreferredName: `optional(string)` - Preferred name of the vendor company
- vendorLandingPageURL: `optional(string)` - URL of the vendor's landing page
- schemaVersion: `optional(uint32)` - Schema version to support backward/forward compatability(default 1)
- schemaVersion: `optional(uint32)` - Schema version to support backward/forward compatability(default 0)
- In State: `vendorinfo/VendorInfo/value/<vid>`
- Who can send:
- Account with a vendor role who has the matching Vendor ID
Expand Down Expand Up @@ -211,7 +211,7 @@ Not all fields can be edited (see `EDIT_MODEL`).
- supportURL: `optional(string)` - URL that contains product specific web page that contains support details for the device model.
- productURL: `optional(string)` - URL that contains product specific web page that contains details for the device model.
- lsfURL: `optional(string)` - URL to the Localized String File of this product.
- schemaVersion: `optional(uint32)` - Schema version to support backward/forward compatability(default 1)
- schemaVersion: `optional(uint32)` - Schema version to support backward/forward compatability(default 0)
- In State:
- `model/Model/value/<vid>/<pid>`
- `model/VendorProducts/value/<vid>`
Expand Down Expand Up @@ -257,7 +257,7 @@ All non-edited fields remain the same.
- supportURL: `optional(string)` - URL that contains product specific web page that contains support details for the device model.
- productURL: `optional(string)` - URL that contains product specific web page that contains details for the device model.
- lsfURL: `optional(string)` - URL to the Localized String File of this product.
- schemaVersion: `optional(uint32)` - Schema version to support backward/forward compatability(default 1)
- schemaVersion: `optional(uint32)` - Schema version to support backward/forward compatability(default 0)
- lsfRevision: `optional(uint32)` - LsfRevision is a monotonically increasing positive integer indicating the latest available version of Localized String File.
- In State: `model/Model/value/<vid>/<pid>`
- Who can send:
Expand Down Expand Up @@ -309,7 +309,7 @@ If one of `OTA_URl`, `OTA_checksum` or `OTA_checksum_type` fields is set, then t
- otaChecksum `optional(string)` - Digest of the entire contents of the associated OTA Software Update Image under the OtaUrl attribute, encoded in base64 string representation. The digest SHALL have been computed using the algorithm specified in OtaChecksumType
- otaChecksumType `optional(string)` - Numeric identifier as defined in IANA Named Information Hash Algorithm Registry for the type of otaChecksum. For example, a value of 1 would match the sha-256 identifier, which maps to the SHA-256 digest algorithm
- releaseNotesURL `optional(string)` - URL that contains product specific web page that contains release notes for the device model.
- schemaVersion: `optional(uint32)` - Schema version to support backward/forward compatability(default 1)
- schemaVersion: `optional(uint32)` - Schema version to support backward/forward compatability(default 0)
- In State:
- `model/ModelVersion/value/<vid>/<pid>/<softwareVersion>`
- `model/ModelVersions/value/<vid>/<pid>`
Expand Down Expand Up @@ -356,7 +356,7 @@ All non-edited fields remain the same.
- otaURL `optional(string)` - URL where to obtain the OTA image
- otaFileSize `optional(string)` - OtaFileSize is the total size of the OTA software image in bytes
- otaChecksum `optional(string)` - Digest of the entire contents of the associated OTA Software Update Image under the OtaUrl attribute, encoded in base64 string representation. The digest SHALL have been computed using the algorithm specified in OtaChecksumType
- schemaVersion: `optional(uint32)` - Schema version to support backward/forward compatability(default 1)
- schemaVersion: `optional(uint32)` - Schema version to support backward/forward compatability(default 0)

- In State: `model/ModelVersion/value/<vid>/<pid>/<softwareVersion>`
- Who can send:
Expand Down Expand Up @@ -494,7 +494,7 @@ from the revocation list.
- transport `optional(string)` - optional field describing the transport
- parentChild `optional(string)` - optional field describing the parent/child - Currently 'parent' and 'child' types are supported
- certificationIDOfSoftwareComponent `optional(string)` - optional field describing the certification ID of software component
- schemaVersion: `optional(uint32)` - Schema version to support backward/forward compatability(default 1)
- schemaVersion: `optional(uint32)` - Schema version to support backward/forward compatability(default 0)
- In State:
- `compliance/ComplianceInfo/value/<vid>/<pid>/<softwareVersion>/<certificationType>`
- `compliance/CertifiedModel/value/<vid>/<pid>/<softwareVersion>/<certificationType>`
Expand Down Expand Up @@ -532,7 +532,7 @@ Updates a compliance info by VID, PID, Software Version and Certification Type.
- transport `optional(string)` - optional field describing the transport
- parentChild `optional(string)` - optional field describing the parent/child - Currently 'parent' and 'child' types are supported
- certificationIDOfSoftwareComponent `optional(string)` - optional field describing the certification ID of software component
- schemaVersion: `optional(uint32)` - Schema version to support backward/forward compatability(default 1)
- schemaVersion: `optional(uint32)` - Schema version to support backward/forward compatability(default 0)
- Who can send:
- CertificationCenter
- CLI command:
Expand Down Expand Up @@ -580,7 +580,7 @@ is written on the ledger (`CERTIFY_MODEL` was called), or
- revocationDate: `string` - The date of model revocation (rfc3339 encoded), for example 2019-10-12T07:20:50.52Z
- certificationType: `string` - Certification type - Currently 'zigbee' and 'matter', 'access control', 'product security' types are supported
- reason `optional(string)` - optional comment describing the reason of revocation
- schemaVersion: `optional(uint32)` - Schema version to support backward/forward compatability(default 1)
- schemaVersion: `optional(uint32)` - Schema version to support backward/forward compatability(default 0)
- In State:
- `compliance/ComplianceInfo/value/<vid>/<pid>/<softwareVersion>/<certificationType>`
- `compliance/RevokedModel/value/<vid>/<pid>/<softwareVersion>/<certificationType>`
Expand Down Expand Up @@ -620,7 +620,7 @@ Can not be set if there is already a certification record on the ledger (certifi
- transport `optional(string)` - optional field describing the transport
- parentChild `optional(string)` - optional field describing the parent/child - Currently 'parent' and 'child' types are supported
- certificationIDOfSoftwareComponent `optional(string)` - optional field describing the certification ID of software component
- schemaVersion: `optional(uint32)` - Schema version to support backward/forward compatability(default 1)
- schemaVersion: `optional(uint32)` - Schema version to support backward/forward compatability(default 0)
- In State:
- `compliance/ComplianceInfo/value/<vid>/<pid>/<softwareVersion>/<certificationType>`
- `compliance/ProvisionalModel/value/<vid>/<pid>/<softwareVersion>/<certificationType>`
Expand Down Expand Up @@ -841,7 +841,7 @@ The certificate is immutable. It can only be revoked by either the owner or a qu
- cert: `string` - PEM encoded certificate. The corresponding CLI parameter can contain either a PEM string or a path to a file containing the data.
- info: `optional(string)` - information/notes for the proposal
- time: `optional(int64)` - proposal time (number of nanoseconds elapsed since January 1, 1970 UTC). CLI uses the current time for that field.
- schemaVersion: `optional(uint32)` - Schema version to support backward/forward compatability(default 1)
- schemaVersion: `optional(uint32)` - Schema version to support backward/forward compatability(default 0)
- In State: `pki/ProposedCertificate/value/<Certificate's Subject>/<Certificate's Subject Key ID>`
- Who can send:
- Trustee
Expand Down Expand Up @@ -924,7 +924,7 @@ The certificate is immutable. It can only be revoked by either the owner or a qu
- `vid` field associated with the corresponding PAA on the ledger must be equal to the Vendor account's VID.
- Parameters:
- cert: `string` - PEM encoded certificate. The corresponding CLI parameter can contain either a PEM string or a path to a file containing the data.
- schemaVersion: `optional(uint32)` - Schema version to support backward/forward compatability(default 1)
- schemaVersion: `optional(uint32)` - Schema version to support backward/forward compatability(default 0)
- In State:
- `pki/ApprovedCertificates/value/<Certificate's Subject>/<Certificate's Subject Key ID>`
- `pki/ChildCertificates/value/<Certificate's Subject>/<Certificate's Subject Key ID>`
Expand Down Expand Up @@ -1157,7 +1157,7 @@ This transaction adds a NOC root certificate owned by the Vendor.
- the signature (self-signature) and expiration date must be valid.
- Parameters:
- cert: `string` - The NOC Root Certificate, encoded in X.509v3 PEM format. Can be a PEM string or a file path.
- schemaVersion: `optional(uint32)` - Schema version to support backward/forward compatability(default 1)
- schemaVersion: `optional(uint32)` - Schema version to support backward/forward compatability(default 0)
- In State:
- `pki/ApprovedCertificates/value/<Subject>/<SubjectKeyID>`
- `pki/ApprovedCertificatesBySubject/value/<Subject>`
Expand Down Expand Up @@ -1188,7 +1188,7 @@ already present on the ledger.
- the signature (self-signature) and expiration date must be valid.
- Parameters:
- cert: `string` - The NOC non-root Certificate, encoded in X.509v3 PEM format. Can be a PEM string or a file path.
- schemaVersion: `optional(uint32)` - Schema version to support backward/forward compatability(default 1)
- schemaVersion: `optional(uint32)` - Schema version to support backward/forward compatability(default 0)
- In State:
- `pki/ApprovedCertificates/value/<Subject>/<SubjectKeyID>`
- `pki/ApprovedCertificatesBySubject/value/<Subject>`
Expand Down
4 changes: 2 additions & 2 deletions integration_tests/cli/compliance-demo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ zigbee_certification_type="zigbee"
matter_certification_type="matter"
cd_certificate_id="123"
cd_version_number=1
schema_version_1=1
schema_version_0=0
schema_version_2=2
echo "Certify unknown Model with VID: $vid PID: $pid SV: ${sv} with zigbee certification"
result=$(echo "$passphrase" | dcld tx compliance certify-model --vid=$vid --pid=$pid --softwareVersion=$sv --softwareVersionString=$svs --certificationType="$zigbee_certification_type" --certificationDate="$certification_date" --cdCertificateId="$cd_certificate_id" --from $zb_account --yes)
Expand Down Expand Up @@ -290,7 +290,7 @@ check_response "$result" "\"softwareVersionCertificationStatus\": 2"
check_response "$result" "\"cDCertificateId\": \"$cd_certificate_id\""
check_response "$result" "\"date\": \"$certification_date\""
check_response "$result" "\"certificationType\": \"$matter_certification_type\""
check_response "$result" "\"schemaVersion\": $schema_version_1"
check_response "$result" "\"schemaVersion\": $schema_version_0"
echo "$result"

test_divider
Expand Down
4 changes: 2 additions & 2 deletions integration_tests/cli/compliance-provisioning.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ certification_type_matter="matter"
provision_date="2020-02-02T02:20:20Z"
provision_reason="some reason"
cd_certificate_id="123"
schema_version_1=1
schema_version_0=0
schema_version_2=2

test_divider
Expand Down Expand Up @@ -165,7 +165,7 @@ check_response "$result" "\"date\": \"$provision_date\""
check_response "$result" "\"reason\": \"$provision_reason\""
check_response "$result" "\"certificationType\": \"$certification_type_matter\""
check_response "$result" "\"history\""
check_response "$result" "\"schemaVersion\": $schema_version_1"
check_response "$result" "\"schemaVersion\": $schema_version_0"
echo "$result"

test_divider
Expand Down
4 changes: 2 additions & 2 deletions integration_tests/cli/compliance-revocation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ test_divider
echo "Revoke Certification for uncertificate Model with VID: $vid PID: $pid"
revocation_date="2020-02-02T02:20:20Z"
revocation_reason="some reason"
schema_version_1=1
schema_version_0=0
schema_version_2=2
result=$(echo "$passphrase" | dcld tx compliance revoke-model --vid=$vid --pid=$pid --softwareVersion=$sv --softwareVersionString=$svs --certificationType="$certification_type" --revocationDate="$revocation_date" --reason "$revocation_reason" --cdVersionNumber=1 --schemaVersion=$schema_version_2 --from $zb_account --yes)
check_response "$result" "\"code\": 0"
Expand Down Expand Up @@ -145,7 +145,7 @@ check_response "$result" "\"softwareVersionCertificationStatus\": 3"
check_response "$result" "\"date\": \"$revocation_date\""
check_response "$result" "\"reason\": \"$revocation_reason\""
check_response "$result" "\"certificationType\": \"$certification_type_matter\""
check_response "$result" "\"schemaVersion\": $schema_version_1"
check_response "$result" "\"schemaVersion\": $schema_version_0"
check_response "$result" "\"history\""
echo "$result"

Expand Down
4 changes: 2 additions & 2 deletions integration_tests/cli/model-demo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ echo "$result"
test_divider

productLabel="Device #1"
schema_version_1=1
schema_version_0=0
schema_version_2=2
echo "Add Model with VID: $vid PID: $pid"
result=$(echo "test1234" | dcld tx model add-model --vid=$vid --pid=$pid --deviceTypeID=1 --productName=TestProduct --productLabel="$productLabel" --partNumber=1 --commissioningCustomFlow=0 --schemaVersion=$schema_version_2 --from=$vendor_account --yes)
Expand Down Expand Up @@ -88,7 +88,7 @@ result=$(dcld query model get-model --vid=$vid_with_pids --pid=$pid)
check_response "$result" "\"vid\": $vid_with_pids"
check_response "$result" "\"pid\": $pid"
check_response "$result" "\"productLabel\": \"$productLabel\""
check_response "$result" "\"schemaVersion\": $schema_version_1"
check_response "$result" "\"schemaVersion\": $schema_version_0"
echo "$result"

test_divider
Expand Down
6 changes: 3 additions & 3 deletions integration_tests/cli/pki-demo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ test_divider

echo "$vendor_account add Leaf certificate"
leaf_path="integration_tests/constants/leaf_cert"
schema_version_1=1
schema_version_0=0
result=$(echo "$passphrase" | dcld tx pki add-x509-cert --certificate="$leaf_path" --from $vendor_account --yes)
check_response "$result" "\"code\": 0"

Expand All @@ -467,7 +467,7 @@ check_response "$result" "\"subject\": \"$leaf_cert_subject\""
check_response "$result" "\"subjectKeyId\": \"$leaf_cert_subject_key_id\""
check_response "$result" "\"serialNumber\": \"$leaf_cert_serial_number\""
check_response "$result" "\"subjectAsText\": \"$leaf_cert_subject_as_text\""
check_response "$result" "\"schemaVersion\": $schema_version_1"
check_response "$result" "\"schemaVersion\": $schema_version_0"
check_response "$result" "\"approvals\": \\[\\]"

echo "Request Leaf certificate by subjectKeyId - There is no approvals on leaf certificate"
Expand Down Expand Up @@ -1183,7 +1183,7 @@ check_response "$result" "\"address\": \"$trustee_account_address\""
check_response "$result" "\"subjectKeyId\": \"$google_cert_subject_key_id\""
check_response "$result" "\"serialNumber\": \"$google_cert_serial_number\""
check_response "$result" "\"subjectAsText\": \"$google_cert_subject_as_text\""
check_response "$result" "\"schemaVersion\": $schema_version_1"
check_response "$result" "\"schemaVersion\": $schema_version_0"
check_response "$result" "\"vid\": $google_cert_vid"
echo $result | jq

Expand Down
3 changes: 2 additions & 1 deletion integration_tests/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,8 @@ var (
ValidHTTPURL = "http://valid.url.com"
NotAValidURL = "not a valid url"

SchemaVersion uint32 = 1
// SchemaVersion initial default value.
SchemaVersion uint32
)

/*
Expand Down
1 change: 0 additions & 1 deletion proto/model/product.proto
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,4 @@ message Product {
int32 pid = 1;
string name = 2;
string partNumber = 3;
uint32 schemaVersion = 4;
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ export interface Product {
pid: number
name: string
partNumber: string
schemaVersion: number
}

const baseProduct: object = { pid: 0, name: '', partNumber: '', schemaVersion: 0 }
const baseProduct: object = { pid: 0, name: '', partNumber: '' }

export const Product = {
encode(message: Product, writer: Writer = Writer.create()): Writer {
Expand All @@ -23,9 +22,6 @@ export const Product = {
if (message.partNumber !== '') {
writer.uint32(26).string(message.partNumber)
}
if (message.schemaVersion !== 0) {
writer.uint32(32).uint32(message.schemaVersion)
}
return writer
},

Expand All @@ -45,9 +41,6 @@ export const Product = {
case 3:
message.partNumber = reader.string()
break
case 4:
message.schemaVersion = reader.uint32()
break
default:
reader.skipType(tag & 7)
break
Expand All @@ -73,11 +66,6 @@ export const Product = {
} else {
message.partNumber = ''
}
if (object.schemaVersion !== undefined && object.schemaVersion !== null) {
message.schemaVersion = Number(object.schemaVersion)
} else {
message.schemaVersion = 0
}
return message
},

Expand All @@ -86,7 +74,6 @@ export const Product = {
message.pid !== undefined && (obj.pid = message.pid)
message.name !== undefined && (obj.name = message.name)
message.partNumber !== undefined && (obj.partNumber = message.partNumber)
message.schemaVersion !== undefined && (obj.schemaVersion = message.schemaVersion)
return obj
},

Expand All @@ -107,11 +94,6 @@ export const Product = {
} else {
message.partNumber = ''
}
if (object.schemaVersion !== undefined && object.schemaVersion !== null) {
message.schemaVersion = object.schemaVersion
} else {
message.schemaVersion = 0
}
return message
}
}
Expand Down
14 changes: 0 additions & 14 deletions x/common/schema_version.go

This file was deleted.

2 changes: 1 addition & 1 deletion x/compliance/client/cli/tx_certify_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ func CmdCertifyModel() *cobra.Command {
"Parent or Child of the PFC certification route")
cmd.Flags().StringVar(&certificationIDOfSoftwareComponent, FlagCertificationIDOfSoftwareComponent, "",
"certification ID of software component")
cmd.Flags().Uint32Var(&schemaVersion, common.FlagSchemaVersion, 1, "Schema version")
cmd.Flags().Uint32Var(&schemaVersion, common.FlagSchemaVersion, 0, "Schema version")

_ = cmd.MarkFlagRequired(FlagVID)
_ = cmd.MarkFlagRequired(FlagPID)
Expand Down
2 changes: 1 addition & 1 deletion x/compliance/client/cli/tx_provision_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func CmdProvisionModel() *cobra.Command {
"Parent or Child of the PFC certification route")
cmd.Flags().StringVar(&certificationIDOfSoftwareComponent, FlagCertificationIDOfSoftwareComponent, "",
"certification ID of software component")
cmd.Flags().Uint32Var(&schemaVersion, common.FlagSchemaVersion, 1, "Schema version")
cmd.Flags().Uint32Var(&schemaVersion, common.FlagSchemaVersion, 0, "Schema version")

_ = cmd.MarkFlagRequired(FlagVID)
_ = cmd.MarkFlagRequired(FlagPID)
Expand Down
2 changes: 1 addition & 1 deletion x/compliance/client/cli/tx_revoke_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func CmdRevokeModel() *cobra.Command {
"The date of model revocation (rfc3339 encoded), for example 2019-10-12T07:20:50.52Z")
cmd.Flags().StringVar(&reason, FlagReason, "",
"Optional comment describing the reason of revocation")
cmd.Flags().Uint32Var(&schemaVersion, common.FlagSchemaVersion, 1, "Schema version")
cmd.Flags().Uint32Var(&schemaVersion, common.FlagSchemaVersion, 0, "Schema version")

_ = cmd.MarkFlagRequired(FlagVID)
_ = cmd.MarkFlagRequired(FlagPID)
Expand Down
2 changes: 1 addition & 1 deletion x/compliance/client/cli/tx_update_compliance_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func CmdUpdateComplianceInfo() *cobra.Command {
"Parent or Child of the PFC certification route")
cmd.Flags().StringVar(&certificationIDOfSoftwareComponent, FlagCertificationIDOfSoftwareComponent, "",
"certification ID of software component")
cmd.Flags().Uint32Var(&schemaVersion, common.FlagSchemaVersion, 1, "Schema version")
cmd.Flags().Uint32Var(&schemaVersion, common.FlagSchemaVersion, 0, "Schema version")

_ = cmd.MarkFlagRequired(FlagVID)
_ = cmd.MarkFlagRequired(FlagPID)
Expand Down
Loading

0 comments on commit 1076221

Please sign in to comment.