Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitomir2 committed Dec 2, 2024
1 parent d848d15 commit d05f87d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 11 deletions.
10 changes: 0 additions & 10 deletions command/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"path/filepath"
"strings"

"github.com/0xPolygon/polygon-edge/contracts"
"github.com/0xPolygon/polygon-edge/crypto"
"github.com/0xPolygon/polygon-edge/helper/common"
"github.com/0xPolygon/polygon-edge/secrets"
Expand Down Expand Up @@ -198,14 +197,5 @@ func ValidateAddress(name string, address string) error {
return fmt.Errorf("%s address must be set", name)
}

governanceAddr := types.StringToAddress(address)
if governanceAddr == types.ZeroAddress {
return fmt.Errorf("%s address must not be zero address", name)
}

if governanceAddr == contracts.SystemCaller {
return fmt.Errorf("%s address must not be system caller address", name)
}

return nil
}
29 changes: 28 additions & 1 deletion command/genesis/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/0xPolygon/polygon-edge/consensus/ibft/fork"
"github.com/0xPolygon/polygon-edge/consensus/ibft/signer"
"github.com/0xPolygon/polygon-edge/consensus/polybft"
"github.com/0xPolygon/polygon-edge/contracts"
"github.com/0xPolygon/polygon-edge/contracts/staking"
stakingHelper "github.com/0xPolygon/polygon-edge/helper/staking"
"github.com/0xPolygon/polygon-edge/secrets"
Expand Down Expand Up @@ -169,7 +170,7 @@ func (p *genesisParams) validateFlags() error {
// return err
// }

if err := command.ValidateAddress("proxy contracts admin", p.proxyContractsAdmin); err != nil {
if err := p.validateProxyContractsAdmin(); err != nil {
return err
}

Expand Down Expand Up @@ -564,6 +565,23 @@ func (p *genesisParams) validateGenesisBaseFeeConfig() error {
return nil
}

func (p *genesisParams) validateProxyContractsAdmin() error {
if err := command.ValidateAddress("proxy contracts admin", p.proxyContractsAdmin); err != nil {
return err
}

proxyContractsAdminAddr := types.StringToAddress(p.proxyContractsAdmin)
if proxyContractsAdminAddr == types.ZeroAddress {
return errors.New("proxy contracts admin address must not be zero address")
}

if proxyContractsAdminAddr == contracts.SystemCaller {
return errors.New("proxy contracts admin address must not be system caller address")
}

return nil
}

// isBurnContractEnabled returns true in case burn contract info is provided
func (p *genesisParams) isBurnContractEnabled() bool {
return p.burnContract != ""
Expand Down Expand Up @@ -592,6 +610,15 @@ func (p *genesisParams) validateGovernanceAddress() error {
return err
}

governanceAddr := types.StringToAddress(p.governance)
if governanceAddr == types.ZeroAddress {
return errors.New("governance address must not be zero address")
}

if governanceAddr == contracts.SystemCaller {
return errors.New("governance address must not be system caller address")
}

if p.proxyContractsAdmin == p.governance {
return errors.New("governance address must be different than the proxy contracts admin")
}
Expand Down

0 comments on commit d05f87d

Please sign in to comment.