Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to check the db type and VRF library by command or config file #486

Open
2 of 4 tasks
ulbqb opened this issue Nov 8, 2022 · 1 comment
Open
2 of 4 tasks

How to check the db type and VRF library by command or config file #486

ulbqb opened this issue Nov 8, 2022 · 1 comment
Labels
C: enhancement Classification: New feature or its request, or improvement in maintainability of code Stale For github bot

Comments

@ulbqb
Copy link
Member

ulbqb commented Nov 8, 2022

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
@tnasu tnasu added the C: enhancement Classification: New feature or its request, or improvement in maintainability of code label Nov 8, 2022
@torao
Copy link
Contributor

torao commented Nov 8, 2022

Just an idea I came up with, but the first approach is:

  1. For KVS implementation, It probably can obtain from the value of ctx.Config.DBBackend.
  2. For VRF, add a method to vrfEd25519 in crypto/vrf/vrf.go that returns the implementation name. Then each subclass should return a fixed value representing its implementation.
  3. If they should be displayed with version numbers:
    1. Embed the output of the dependent package into a variable with the version by go command in Makefile.
    2. 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.

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/[email protected]
cloud.google.com/go/[email protected]
...

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
}

@ulbqb ulbqb changed the title How to check the db type and vrf library with the version command? How to check the db type and VRF library by command or config file Nov 9, 2022
@github-actions github-actions bot added the Stale For github bot label Nov 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: enhancement Classification: New feature or its request, or improvement in maintainability of code Stale For github bot
Projects
None yet
Development

No branches or pull requests

3 participants