Skip to content

Commit

Permalink
Invoke protectSetupProxy function on genesis post hook
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan-Ethernal committed Sep 26, 2023
1 parent 72b7eec commit 359e2b4
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
1 change: 1 addition & 0 deletions consensus/polybft/contractsapi/bindings-gen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,7 @@ func main() {
gensc.GenesisProxy,
false,
[]string{
"protectSetUpProxy",
"setUpProxy",
},
[]string{},
Expand Down
16 changes: 16 additions & 0 deletions consensus/polybft/contractsapi/contractsapi.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 14 additions & 2 deletions consensus/polybft/polybft.go
Original file line number Diff line number Diff line change
Expand Up @@ -784,20 +784,32 @@ func (p *Polybft) FilterExtra(extra []byte) ([]byte, error) {
func setUpProxies(transition *state.Transition, admin types.Address,
proxyToImplMap map[types.Address]types.Address) error {
for proxyAddress, implAddress := range proxyToImplMap {
protectSetupProxyFn := &contractsapi.ProtectSetUpProxyGenesisProxyFn{Initiator: contracts.SystemCaller}

proxyInput, err := protectSetupProxyFn.EncodeAbi()
if err != nil {
return fmt.Errorf("GenesisProxy.protectSetUpProxy params encoding failed: %w", err)
}

err = callContract(contracts.SystemCaller, proxyAddress, proxyInput, "GenesisProxy.protectSetUpProxy", transition)
if err != nil {
return err
}

setUpproxyFn := &contractsapi.SetUpProxyGenesisProxyFn{
Logic: implAddress,
Admin: admin,
Data: []byte{},
}

proxyInput, err := setUpproxyFn.EncodeAbi()
proxyInput, err = setUpproxyFn.EncodeAbi()
if err != nil {
return fmt.Errorf("GenesisProxy.setUpProxy params encoding failed: %w", err)
}

err = callContract(contracts.SystemCaller, proxyAddress, proxyInput, "GenesisProxy.setUpProxy", transition)
if err != nil {
return fmt.Errorf("GenesisProxy.setUpProxy params encoding failed: %w", err)
return err
}
}

Expand Down

0 comments on commit 359e2b4

Please sign in to comment.