How to check the db type and VRF library by command or config file
ulbqb opened this issue · 1 comments
Summary
I want to check the db type and VRF library that the generated binary uses.
Problem Definition
Current version cannot check the db type and VRF library that the generated binary uses.
Proposal
I want version command like this.
$ ostracon version
v1.0.0-0-xxxxxxxxx
db leveldb
vrf r2ishiguro
For Admin Use
- Not duplicate issue
- Appropriate labels applied
- Appropriate contributors tagged
- Contributor assigned/self-assigned
Just an idea I came up with, but the first approach is:
- For KVS implementation, It probably can obtain from the value of ctx.Config.DBBackend.
- For VRF, add a method to
vrfEd25519
incrypto/vrf/vrf.go
that returns the implementation name. Then each subclass should return a fixed value representing its implementation. - If they should be displayed with version numbers:
- Embed the output of the dependent package into a variable with the version by
go
command inMakefile
. - Create a function that returns a version for the argument package name. This function parses the variable embedded in the
Makefile
to find the corresponding package.
- Embed the output of the dependent package into a variable with the version by
There may be a more formal method, but a version-numbered list of the packages on which the project depends can be obtained as follows.
% go mod graph | awk '{print $2}' | sort | uniq
cloud.google.com/go/bigquery@v1.0.1
cloud.google.com/go/bigquery@v1.3.0
...
For dependent libraries that aren't part of the golang package, such as libsodium, a git
commit hash could be used instead.
% cd crypto/vrf/internal/vrf/libsodium
% git rev-parse --short HEAD
004952bb
Modify the Makefile
so that these outputs are set in a variable of Ostracon during make
(the following results are unconfirmed).
LD_FLAGS += -X github.com/line/ostracon/version.DependentPackageVersion=
LD_FLAGS += $(shell go mod graph | awk '{print $2}' | sort | uniq)
LD_FLAGS += libsodium@$(shell cd crypto/vrf/internal/vrf/libsodium & git rev-parse --short HEAD)
... other non-golang libraries
Finally, implement a function that parses the string embedded by Makefile
and returns the version number for the package name:
package version
var DependentPackageVersion string
func GetDependentPackageVersion(pkg string) string {
pkgs := // split DependentPackageVersion by a new line
for _, p := range pkgs {
name, ver := // split @ by an '@'
if name == pkg {
return ver
}
}
return nil
}