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

entrypoint: fix BLS key generate flow and add show BLS secret key option #335

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ ENV ENABLE_FAST_FINALITY_SIGN 'true'
ENV BLS_PRIVATE_KEY ''
ENV BLS_PASSWORD ''
ENV BLS_AUTO_GENERATE 'false'
ENV BLS_SHOW_PRIVATE_KEY 'false'

COPY --from=builder /opt/build/bin/ronin /usr/local/bin/ronin
COPY --from=builder /opt/genesis/ ./
Expand Down
4 changes: 4 additions & 0 deletions core/vote/vote_signer.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ func NewVoteSigner(blsPasswordPath, blsWalletPath string) (*VoteSigner, error) {
return nil, errors.Wrap(err, "could not fetch validating public keys")
}

if len(pubKeys) < 1 {
return nil, errors.New("no BLS key in keystore")
}

return &VoteSigner{
km: km,
pubKey: pubKeys[0],
Expand Down
34 changes: 22 additions & 12 deletions docker/chainnode/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -136,20 +136,20 @@ elif [[ "$mine" = "true" ]]; then
echo "Warning: A mining node is started without private key environment provided"
fi

blsAccountsCount=$(
ronin account listbls \
--finality.blspasswordpath $BLS_PASSWORD_FILE \
--finality.blswalletpath $BLS_PRIVATE_KEY_DIR \
2> /dev/null \
| wc -l
)

if [[ "$ENABLE_FAST_FINALITY" = "true" ]]; then
params="$params --finality.enable"
fi

if [[ "$ENABLE_FAST_FINALITY_SIGN" = "true" ]]; then
mkdir -p $BLS_PRIVATE_KEY_DIR
blsAccountsCount=$(
ronin account listbls \
--finality.blspasswordpath $BLS_PASSWORD_FILE \
--finality.blswalletpath $BLS_PRIVATE_KEY_DIR \
2> /dev/null \
| wc -l
)

if [[ ! -z $BLS_PRIVATE_KEY ]]; then
echo "$BLS_PRIVATE_KEY" > ./bls_private_key
if [[ $blsAccountsCount -le 0 ]]; then
Expand Down Expand Up @@ -189,10 +189,12 @@ if [[ "$ENABLE_FAST_FINALITY_SIGN" = "true" ]]; then

blsParams="--finality.enablesign --finality.blspasswordpath $BLS_PASSWORD_FILE --finality.blswalletpath $BLS_PRIVATE_KEY_DIR"
blsAccount=$(
ronin account list --datadir $datadir --keystore $KEYSTORE_DIR \
2> /dev/null \
| head -n 1 \
| cut -d"{" -f 2 | cut -d"}" -f 1
ronin account listbls \
--finality.blspasswordpath $BLS_PASSWORD_FILE \
--finality.blswalletpath $BLS_PRIVATE_KEY_DIR \
2> /dev/null \
| head -n 1 \
| cut -d"{" -f 2 | cut -d"}" -f 1
)

echo "Using BLS account $blsAccount"
Expand Down Expand Up @@ -297,6 +299,14 @@ echo "dump: $account $BOOTNODES"

set -x

if [[ "$BLS_SHOW_PRIVATE_KEY" = "true" ]]; then
mkdir -p $BLS_PRIVATE_KEY_DIR
exec ronin account listbls \
--finality.blspasswordpath $BLS_PASSWORD_FILE \
--finality.blswalletpath $BLS_PRIVATE_KEY_DIR \
--secret
fi

exec ronin $params \
--syncmode $syncmode \
--verbosity $VERBOSITY \
Expand Down