Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Non upgradeable TeleporterRegistryApps #458

Merged
merged 25 commits into from
Jul 31, 2024

Conversation

minghinmatthewlam
Copy link

@minghinmatthewlam minghinmatthewlam commented Jul 29, 2024

Why this should be merged

Fixes #416 and #421

How this works

  • Non-upgradeable contracts are separate contracts from their corresponding upgradeable versions, copied over logic from previous audited versions
  • Upgradeable contracts just have a rename

How this was tested

Restructured unit tests so that there are base tests to cover both non-upgradeable and upgradeable versions of the TeleporterRegistryApp contracts.

How is this documented

update README to include upgradeable contracts

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To aid with review, what commit are the non-upgradeable variants sourced from?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

*
* @custom:security-contact https://github.com/ava-labs/teleporter/blob/main/SECURITY.md
*/
abstract contract TeleporterRegistryApp is Context, ITeleporterReceiver, ReentrancyGuard {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to add a ITeleporterRegistryApp interface that both the upgradeable and non-upgradeable versions implement?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To aid in review, I'd suggest we defer this to a separate PR.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may require more changes. Right now most of the functions are public, and for interfaces the visibility would need to be made external. The functions were made public so that inherited contracts can still call these functions internally without doing this.func. To still provide the ability to call internally, we could go through the external calling internal logic pattern.

function _erc7201StorageSlot(bytes memory storageName) private pure returns (bytes32) {
return keccak256(
abi.encode(
uint256(keccak256(abi.encodePacked("avalanche-ictt.storage.", storageName))) - 1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be "teleporter.storage"?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice catch, wasn't sure if this should be icm but will stick with teleporter for now

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nvm in the contract already uses teleporter used the wrong name for test

minghinmatthewlam and others added 2 commits July 30, 2024 10:28
Copy link
Contributor

@cam-schultz cam-schultz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One suggestion to rename a function as well, and it looks like the ABI bindings need to be regenerated. Otherwise, LGTM

*
* Checks that the caller is the owner of the contract for upgrade access.
*/
function _checkTeleporterUpgradeAccess() internal view virtual override {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we rename this function to something like _checkTeleporterRegistryAccess? Don't want to overload the term "upgrade" in a non-upgradeable contract.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed to _changeTeleporterRegistryAppAccess

Copy link
Contributor

@cam-schultz cam-schultz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link
Contributor

@geoff-vball geoff-vball left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@minghinmatthewlam minghinmatthewlam merged commit e63caa7 into main Jul 31, 2024
14 checks passed
@geoff-vball geoff-vball deleted the non-upgradeable-extensions branch August 1, 2024 13:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create non-upgradeable extensions of upgradeable contracts
5 participants