Skip to content

Commit

Permalink
Change child predicates deployment (#372)
Browse files Browse the repository at this point in the history
* initial fix

* lint fix

* fixes

* comments fix

* Remove unused parameters

* Make IncrementBy method of Address. Reorganize functions to be grouped by structs

* Introduce slice of internal bridge contract addresses

* Adjust comments

* Minor simplifications (return callContract)

* Fixes in iterating through bridge config map, renames

* Add comments

* Use the proper field to set the internal rpc url

* Rename

* Changes in return value in deployContracts

* Fix internal tx relayer initialization

* Promote getProxyNameForImpl to method

* Minor simplifications

* Remove unused param

* Lint fix

* comments fix

---------

Co-authored-by: Stefan Negovanović <[email protected]>
  • Loading branch information
goran-ethernal and Stefan-Ethernal authored Sep 16, 2024
1 parent f9e724c commit e37c748
Show file tree
Hide file tree
Showing 36 changed files with 1,766 additions and 978 deletions.
47 changes: 47 additions & 0 deletions chain/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"sort"

"github.com/0xPolygon/polygon-edge/contracts"
"github.com/0xPolygon/polygon-edge/forkmanager"
"github.com/0xPolygon/polygon-edge/types"
)
Expand Down Expand Up @@ -81,6 +82,52 @@ func (p *Params) GetEngine() string {
return ""
}

// GetBridgeAllowListAdmin returns admin account for the bridge allow list (first of them in the list)
func (p *Params) GetBridgeAllowListAdmin() types.Address {
if p.BridgeAllowList == nil || len(p.BridgeAllowList.AdminAddresses) == 0 {
return types.ZeroAddress
}

return p.BridgeAllowList.AdminAddresses[0]
}

// GetBridgeBlockListAdmin returns admin account for the bridge block list (first of them in the list)
func (p *Params) GetBridgeBlockListAdmin() types.Address {
if p.BridgeBlockList == nil || len(p.BridgeBlockList.AdminAddresses) == 0 {
return types.ZeroAddress
}

return p.BridgeBlockList.AdminAddresses[0]
}

// GetBridgeOwner returns owner account for bridge.
//
// It is resolved by the given priorities:
// 1. in case bridge allow list admin is configured, return it as an owner
// 2. in case bridge block list admin is configured, return it as an owner
// 3. otherwise return predefined SystemCaller address
func (p *Params) GetBridgeOwner() types.Address {
if owner := p.GetBridgeAllowListAdmin(); owner != types.ZeroAddress {
return owner
}

if owner := p.GetBridgeBlockListAdmin(); owner != types.ZeroAddress {
return owner
}

return contracts.SystemCaller
}

// IsBridgeAllowListEnabled returns true in case bridge allow list is configured, otherwise false.
func (p *Params) IsBridgeAllowListEnabled() bool {
return p.GetBridgeAllowListAdmin() != types.ZeroAddress
}

// IsBridgeBlockListEnabled returns true in case bridge block list is configured, otherwise false.
func (p *Params) IsBridgeBlockListEnabled() bool {
return p.GetBridgeBlockListAdmin() != types.ZeroAddress
}

// predefined forks
const (
Homestead = "homestead"
Expand Down
Loading

0 comments on commit e37c748

Please sign in to comment.