Skip to content
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
2 changes: 1 addition & 1 deletion consensus/wbft/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ var DefaultConfig = &Config{
func (c *Config) GetSystemContracts(blockNumber *big.Int, chainConfig *params.ChainConfig) params.SystemContracts {
gc := params.SystemContracts{}

if c.SystemContractUpgrades != nil && len(c.SystemContractUpgrades) > 0 {
if len(c.SystemContractUpgrades) > 0 {
c.getSystemContractsValue(blockNumber, func(upgrade params.Upgrade) {
if upgrade.GovValidator != nil {
gc.GovValidator = upgrade.GovValidator
Expand Down
5 changes: 2 additions & 3 deletions systemcontracts/coin_adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"fmt"
"math/big"
"strconv"
"strings"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
Expand Down Expand Up @@ -48,10 +47,10 @@ func initializeCoinAdapter(coinAdapterAddress common.Address, param map[string]s

// SLOT_COIN_ADAPTER_MINTERS, SLOT_COIN_ADAPTER_MINTER_ALLOWED
if mintersStr, ok := param[COIN_ADAPTER_PARAM_MINTERS]; ok && len(mintersStr) > 0 {
minters := strings.Split(mintersStr, ",")
minters := splitAndTrim(mintersStr, ",")
minterAllowedAmounts := make([]*big.Int, len(minters))
if minterAllowedStr, ok := param[COIN_ADAPTER_PARAM_MINTER_ALLOWED]; ok && len(minterAllowedStr) > 0 {
minterAllowed := strings.Split(minterAllowedStr, ",")
minterAllowed := splitAndTrim(minterAllowedStr, ",")
if len(minters) != len(minterAllowed) {
return nil, fmt.Errorf("`systemContracts.nativeCoinAdapter.params`: the number of minters and minterAllowedAmounts must be the same")
}
Expand Down
13 changes: 12 additions & 1 deletion systemcontracts/gov_base.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,17 @@ const (
SLOT_GOV_BASE_maxActiveProposalsPerMember = "0xc"
)

func splitAndTrim(s, sep string) (ret []string) {
l := strings.Split(s, sep)
for _, r := range l {
r = strings.TrimSpace(r)
if len(r) > 0 {
ret = append(ret, r)
}
}
return ret
}

type Member struct {
IsActive bool
JoinedAt uint32
Expand Down Expand Up @@ -161,7 +172,7 @@ func initializeBase(govBaseAddress common.Address, param map[string]string) ([]p
}

if membersStr, ok := param[GOV_BASE_PARAM_MEMBERS]; ok {
memberAddresses := strings.Split(membersStr, ",")
memberAddresses := splitAndTrim(membersStr, ",")

// Pre-validate and deduplicate members
uniqueMembers := make([]common.Address, 0)
Expand Down
4 changes: 2 additions & 2 deletions systemcontracts/gov_council.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func initializeGovCouncil(govCouncilAddress common.Address, param map[string]str

// Initialize blacklist if provided
if blacklistStr, ok := param[GOV_COUNCIL_PARAM_BLACKLIST]; ok && blacklistStr != "" {
blacklistAddresses := strings.Split(blacklistStr, ",")
blacklistAddresses := splitAndTrim(blacklistStr, ",")
blacklistParams, err := initializeAddressSet(
govCouncilAddress,
common.HexToHash(SLOT_GOV_COUNCIL_currentBlacklist_values),
Expand All @@ -84,7 +84,7 @@ func initializeGovCouncil(govCouncilAddress common.Address, param map[string]str

// Initialize authorized accounts if provided
if authorizedAccountsStr, ok := param[GOV_COUNCIL_PARAM_AUTHORIZED_ACCOUNTS]; ok && authorizedAccountsStr != "" {
authorizedAccountAddresses := strings.Split(authorizedAccountsStr, ",")
authorizedAccountAddresses := splitAndTrim(authorizedAccountsStr, ",")
authorizedAccountParams, err := initializeAddressSet(
govCouncilAddress,
common.HexToHash(SLOT_GOV_COUNCIL_currentAuthorizedAccounts_values),
Expand Down
2 changes: 1 addition & 1 deletion systemcontracts/gov_master_minter.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func initializeMasterMinter(govMasterMinterAddress common.Address, param map[str

// Initialize minters (comma-separated addresses)
if mintersStr, ok := param[GOV_MASTER_MINTER_PARAM_MINTERS]; ok {
minterAddressStrs := strings.Split(mintersStr, ",")
minterAddressStrs := splitAndTrim(mintersStr, ",")
if len(minterAddressStrs) == 0 {
return nil, fmt.Errorf("`systemContracts.govMasterMinter.params.minters`: no addresses provided")
}
Expand Down
7 changes: 3 additions & 4 deletions systemcontracts/gov_validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ package systemcontracts
import (
"fmt"
"math/big"
"strings"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/params"
Expand Down Expand Up @@ -89,9 +88,9 @@ func initializeValidator(govValidatorAddress common.Address, param map[string]st
return nil, fmt.Errorf("`systemContracts.govValidator.params`: missing parameter: %s", GOV_VALIDATOR_PARAM_BLS_KEYS)
}

memberAddresses := strings.Split(param[GOV_BASE_PARAM_MEMBERS], ",")
valAddresses := strings.Split(valStr, ",")
blsKeyStrings := strings.Split(param[GOV_VALIDATOR_PARAM_BLS_KEYS], ",")
memberAddresses := splitAndTrim(param[GOV_BASE_PARAM_MEMBERS], ",")
valAddresses := splitAndTrim(valStr, ",")
blsKeyStrings := splitAndTrim(param[GOV_VALIDATOR_PARAM_BLS_KEYS], ",")
if len(memberAddresses) != len(valAddresses) {
return nil, fmt.Errorf("`systemContracts.govValidator.params`: the number of members and validators must be the same")
}
Expand Down