Skip to content

Commit 82e1878

Browse files
authored
[applicationpb] Update ASN.1 schema with extension marker (#80)
#### Type of change - Bug fix #### Description - Add extensibility markers (...) to all SEQUENCE types for forward compatibility - Remove redundant OPTIONAL keyword (DEFAULT already implies optional) - Fix missing commas and quoted integer default values Sources: - https://www.oss.com/asn1/resources/asn1-faq.html#default - https://pkg.go.dev/encoding/asn1#:~:text=The%20following%20tags%20on%20struct,specifies%20that%20an%20additional%2C%20explicit #### Additional details (Optional) - using asn1c compiler to parse and validate the syntax #### Related issues - resolves #79 Signed-off-by: Senthilnathan <cendhu@gmail.com>
1 parent fd5ebce commit 82e1878

File tree

3 files changed

+26
-9
lines changed

3 files changed

+26
-9
lines changed

Makefile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,17 @@ clean:
7575
-@rm -rf $(BUILD_DIR)
7676

7777
## Run code linter
78-
lint: lint-proto FORCE
78+
lint: lint-proto lint-asn1 FORCE
7979
@echo "Running Go Linters..."
8080
golangci-lint run --color=always --new-from-rev=main --timeout=4m
8181
@echo "Running License Header Linters..."
8282
scripts/license-lint.sh
8383

84+
## Run ASN.1 schema linter
85+
lint-asn1: FORCE
86+
@echo "Running ASN.1 schema linters..."
87+
@asn1c -EP $(shell find ${project_dir}/api -name '*.asn')
88+
8489
# https://www.gnu.org/software/make/manual/html_node/Force-Targets.html
8590
# If a rule has no prerequisites or recipe, and the target of the rule is a nonexistent file,
8691
# then make imagines this target to have been updated whenever its rule is run.

api/applicationpb/asn1_tx_schema.asn

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,29 @@
44
-- Any change to [*protoblocktx.Tx] requires a change to this schema.
55
-- Quick reference: https://www.oss.com/asn1/resources/asn1-made-simple/asn1-quick-reference.html
66

7+
FabricXTxSchema DEFINITIONS AUTOMATIC TAGS ::= BEGIN
8+
79
TxWithNamespace ::= SEQUENCE {
810
txID UTF8String,
911
namespaceID UTF8String,
1012
namespaceVersion INTEGER,
1113
reads SEQUENCE OF SEQUENCE {
1214
key OCTET STRING,
13-
version INTEGER OPTIONAL DEFAULT "-1"
15+
version INTEGER DEFAULT -1,
16+
...
1417
},
1518
readWrites SEQUENCE OF SEQUENCE {
1619
key OCTET STRING,
17-
value OCTET STRING
18-
version INTEGER OPTIONAL DEFAULT "-1",
20+
value OCTET STRING,
21+
version INTEGER DEFAULT -1,
22+
...
1923
},
2024
writes SEQUENCE OF SEQUENCE {
2125
key OCTET STRING,
22-
value OCTET STRING
23-
}
26+
value OCTET STRING,
27+
...
28+
},
29+
...
2430
}
31+
32+
END

scripts/install-dev-dependencies.sh

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,13 @@ echo "Extracting protoc to $HOME/bin"
3939
unzip -jo "${protoc_zip_download_path}" 'bin/*' -d "$HOME/bin"
4040
rm -rf "${download_dir}"
4141

42-
if which apt >/dev/null 2>&1; then
43-
# Required for "duration" protobuf.
44-
sudo apt install -y libprotobuf-dev
42+
# Install platform-specific dependencies.
43+
# asn1c is used to lint ASN.1 schema files.
44+
if [ "$protoc_os" = "linux" ]; then
45+
# libprotobuf-dev is required for "duration" protobuf.
46+
sudo apt install -y libprotobuf-dev asn1c
47+
else
48+
brew install asn1c
4549
fi
4650

4751
echo

0 commit comments

Comments
 (0)