Skip to content

fix: normalize comma-separated config strings#56

Merged
hominlee-wemade merged 2 commits intodevfrom
fix/systemcontracts-config-trim
Feb 11, 2026
Merged

fix: normalize comma-separated config strings#56
hominlee-wemade merged 2 commits intodevfrom
fix/systemcontracts-config-trim

Conversation

@hominlee-wemade
Copy link
Contributor

Description

Summary

System contract initialization now parses comma-separated config strings (members, validators, blsPublicKeys, blacklist, authorizedAccounts, minters, minterAllowed, etc.) in a normalized way:

  • Split by the delimiter
  • Trim whitespace for each item
  • Drop empty entries
    This ensures that genesis alloc (and therefore hashAlloc / state root) is consistent for the same logical configuration, regardless of formatting differences such as "a, b" vs "a,b".

Background

  • The state root is computed only during hashAlloc.
  • For the same (address, account) set, the trie yields the same root regardless of insertion order.
  • However, the root can differ if the alloc passed into hashAlloc actually differs.
  • One source of this discrepancy was inconsistent parsing of comma-separated config strings, especially when whitespace was present.
  • As a result, logically identical configs could produce different genesis allocs and roots.

Changes

  • gov_base.go
    • Added splitAndTrim(s, sep string) []string utility (split by sep, trim each element, omit empty entries)
    • Applied when building memberAddresses from membersStr
  • gov_validator.go
    • Build memberAddresses, valAddresses, and blsKeyStrings using splitAndTrim(..., ",")
  • gov_council.go
    • Build blacklistAddresses and authorizedAccountAddresses using splitAndTrim(..., ",")
  • coin_adapter.go
    • Build minters and minterAllowed using splitAndTrim(..., ",")
  • gov_master_minter.go
    • Build minterAddressStrs from mintersStr using splitAndTrim(..., ",")

Use split + TrimSpace per item and drop empty entries for all comma-separated
config used in system contract init (members, validators, blsPublicKeys,
blacklist, authorizedAccounts, minters, minterAllowed, etc.) instead of using
the raw strings. Ensures consistent hashAlloc/root for the same config.
@hominlee-wemade hominlee-wemade self-assigned this Feb 11, 2026
@hominlee-wemade hominlee-wemade added the bug Something isn't working label Feb 11, 2026
@hominlee-wemade hominlee-wemade merged commit 2e04694 into dev Feb 11, 2026
3 checks passed
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

Successfully merging this pull request may close these issues.

2 participants