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

[Bug] CLI Validator Stake Command Fails with Base64 Public Key Format #346

Open
Josephtran102 opened this issue Nov 6, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@Josephtran102
Copy link

Josephtran102 commented Nov 6, 2024

Bug Description

The story validator stake command fails when providing a validator public key in Base64 format but works with hex format. The CLI should handle both formats or provide clear documentation about the required format.

Current Behavior

When using a Base64-encoded public key, the command fails with an error:

 ⚡ root@josephtran  ~  story validator stake \
   --validator-pubkey "A9k2hhP1ihByqEPWR1F8Ui3F8+d9uN/6DzP5X7rzXtVa" \
   --stake 17950000000000000000000 \
   --private-key $PRIVATE_KEY
24-11-06 10:51:15.125 ERRO !! Fatal error occurred, app died️ unexpectedly !! err="failed to decode hex-encoded pub key: encoding/hex: invalid byte: U+006B 'k'" stacktrace="[errors.go:39 validator.go:539 validator.go:257 validator.go:389 command.go:985 command.go:1117 command.go:1041 command.go:1034 cmd.go:34 main.go:10 proc.go:271 asm_amd64.s:1695]"

Error message:

24-11-06 10:36:15.210 ERRO !! Fatal error occurred, app died️ unexpectedly !! err="failed to decode hex-encoded pub key: encoding/hex: invalid byte: U+006B 'k'" stacktrace="[errors.go:39 validator.go:539 validator.go:257 validator.go:389 command.go:985 command.go:1117 command.go:1041 command.go:1034 cmd.go:34 main.go:10 proc.go:271 asm_amd64.s:1695]"

Expected Behavior

The CLI should either:

  • Accept Base64 format public keys directly, or
  • Provide clear error messages indicating the required format, or
  • Include a built-in conversion utility

Workaround

Currently, users need to manually convert Base64 to hex format using additional tools. For example, using Python:

import base64

base64_pubkey = "A9k2hhP1ihByqEPWR1F8Ui3F8+d9uN/6DzP5X7rzXtVa"
hex_pubkey = base64.b64decode(base64_pubkey).hex()
print(hex_pubkey)
# Output: 03d9368613f58a1072a843d647517c522dc5f3e77db8dffa0f33f95fbaf35ed55a

After conversion, the command works successfully:

✘ ⚡ root@josephtran  ~  story validator stake \
   --validator-pubkey "03d9368613f58a1072a843d647517c522dc5f3e77db8dffa0f33f95fbaf35ed55a" \
   --stake 17950000000000000000000 \
   --private-key $PRIVATE_KEY
Transaction hash: 0xffa52cedbee5fa5dbe3bd12436430b2b2b733b02d8655c2dbef529d0d650beef
Explorer URL: https://odyssey.storyscan.xyz/tx/0xffa52cedbee5fa5dbe3bd12436430b2b2b733b02d8655c2dbef529d0d650beef
Transaction sent, waiting for confirmation...
Transaction confirmed successfully!
Tokens staked successfully! Extracting delegation ID...
Delegation ID: 0

Suggested Solutions

Add Base64 format support to the CLI
Include a built-in conversion utility in the CLI (e.g., story utils convert-pubkey)
Add format validation and helpful error messages
Update documentation to clearly specify the required public key format

Environment

Story version: v0.12.1
OS: Linux
Architecture: amd64

Additional Context

This issue affects validator setup and might cause confusion for new validators trying to stake tokens.

Screen Shot 2024-11-06 at 17 56 55

@Josephtran102 Josephtran102 added the bug Something isn't working label Nov 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant