Skip to content
This repository has been archived by the owner on Jun 9, 2024. It is now read-only.

Commit

Permalink
Fix: Error Handling for Commit Length in Miner Configuration (#1450)
Browse files Browse the repository at this point in the history
## Bug:
The function incorrectly returns nil when the Git commit length is not
equal to 40, potentially causing unclear failures.

## Fix:
Correct the error handling to return a specific error when the commit
length check fails.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **Bug Fixes**
- Updated configuration validation to ensure the git commit length is
correctly verified.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
  • Loading branch information
kienn6034 authored Jan 21, 2024
1 parent 7a15507 commit c3cf22b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion cosmos/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
package config

import (
"fmt"
"math/big"

"github.com/berachain/polaris/cosmos/config/flags"
Expand Down Expand Up @@ -106,7 +107,7 @@ func readConfigFromAppOptsParser(parser AppOptionsParser) (*Config, error) {
if len(conf.Polar.Miner.ExtraData) == 0 {
commit := version.NewInfo().GitCommit
if len(commit) != 40 { //nolint:gomnd // its okay.
return nil, err
return nil, fmt.Errorf("invalid git commit length: %d", len(commit))
}
conf.Polar.Miner.ExtraData = hexutil.Bytes(
commit[32:40],
Expand Down

0 comments on commit c3cf22b

Please sign in to comment.