Skip to content
This repository has been archived by the owner on Nov 5, 2023. It is now read-only.

Use hash to identify the approved proxy admin function rather than storing the whole bytecode #132

Merged
merged 3 commits into from
Feb 8, 2022

Conversation

voltrevo
Copy link
Collaborator

@voltrevo voltrevo commented Feb 7, 2022

What is this PR doing?

Uses hashes for these fields:

-    bytes public approvedProxyAdminFunction;
-    bytes pendingPAFunction;
+    bytes32 public approvedProxyAdminFunctionHash;
+    bytes32 pendingPAFunctionHash;

This saves gas. Then when setting the proxy admin function we can simply check the hash:

-        bool matchesApproved = (encodedFunction.length == approvedFunction.length);
-        for (uint i=0; matchesApproved && i<approvedFunction.length; i++) {
-            matchesApproved = (encodedFunction[i] == approvedFunction[i]);
-        }
+        bool matchesApproved = keccak256(encodedFunction) == approvedFunction;

How can these changes be manually tested?

Run the tests, in particular:
should register with new verification gateway

Does this PR resolve or contribute to any issues?

Resolves #118.

Checklist

  • I have manually tested these changes
  • Post a link to the PR in the group chat

Guidelines

  • If your PR is not ready, mark it as a draft
  • The resolve conversation button is for reviewers, not authors
    • (But add a 'done' comment or similar)

@github-actions github-actions bot added the contracts Smart contract related label Feb 7, 2022
@voltrevo voltrevo changed the title Pending pa function hash Use hash to identify the approved proxy admin function rather than storing the whole bytecode Feb 7, 2022
@voltrevo voltrevo marked this pull request as ready for review February 7, 2022 22:49
@jzaki jzaki merged commit 116c920 into main Feb 8, 2022
@jzaki jzaki deleted the bw-118-pendingPAFunctionHash branch February 8, 2022 05:58
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
contracts Smart contract related
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Save gas by setting a pending function *hash* instead of the full encoded function
2 participants