Skip to content

Commit

Permalink
CR's fixes: rename functions
Browse files Browse the repository at this point in the history
  • Loading branch information
evgeniy-scherbina committed May 3, 2024
1 parent c2e188f commit 27126aa
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 6 additions & 4 deletions x/evm/types/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,18 +209,19 @@ func validateEnabledPrecompiles(enabledPrecompiles []string) error {
addrs[i] = common.HexToAddress(precompile)
}

if err := checkIfSortedInBytesRepr(addrs); err != nil {
if err := validateSortingInBytesRepr(addrs); err != nil {
return fmt.Errorf("enabled precompiles are not sorted: %v", err)
}

if err := checkIfUniqueInBytesRepr(addrs); err != nil {
if err := validateUniquenessInBytesRepr(addrs); err != nil {
return fmt.Errorf("enabled precompiles are not unique: %v", err)
}

return nil
}

func checkIfSortedInBytesRepr(addrs []common.Address) error {
// validateSortingInBytesRepr checks if bytes representation of addresses are sorted in ascending order
func validateSortingInBytesRepr(addrs []common.Address) error {
n := len(addrs)

for i := 0; i < n-1; i++ {
Expand All @@ -233,7 +234,8 @@ func checkIfSortedInBytesRepr(addrs []common.Address) error {
return nil
}

func checkIfUniqueInBytesRepr(addrs []common.Address) error {
// validateUniquenessInBytesRepr checks if bytes representation of addresses are unique
func validateUniquenessInBytesRepr(addrs []common.Address) error {
n := len(addrs)

exists := make(map[common.Address]struct{}, n)
Expand Down
2 changes: 1 addition & 1 deletion x/evm/types/params_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ func TestEnabledPrecompilesAddressCorrectness(t *testing.T) {
}
}

func TestEnabledPrecompilesOrderInBytesRepr(t *testing.T) {
func TestEnabledPrecompilesSortingInBytesRepr(t *testing.T) {
const (
addr1 = "0x1000000000000000000000000000000000000000"
addr2 = "0x2000000000000000000000000000000000000000"
Expand Down

0 comments on commit 27126aa

Please sign in to comment.