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

Implement TeleporterOwnerUpgradeable #92

Merged
merged 8 commits into from
Nov 6, 2023
Merged

Conversation

minghinmatthewlam
Copy link

Why this should be merged

Fixes #75

How this works

New abstract contract TeleporterOwnerUpgradeable that inherits TeleporterUpgradeable and implements updateMinTeleporterVersion so that only the owner of the contract can call the function. Replaces the previous cross chain application inheritances to use new contract.

How this was tested

  • new unit tests
  • CI

How is this documented

update README

@@ -637,11 +637,18 @@ contract ERC20BridgeTest is Test {
}

function testUpdateMinTeleporterVersion() public {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Curious if you think it'd make sense to remove this test case from ERC20BridgeTests given that the implementation is tested in TeleporterOwnerUpgradeableTests. I don't think we commonly tests inherited functions in child contract test suites.

Copy link
Author

@minghinmatthewlam minghinmatthewlam Oct 31, 2023

Choose a reason for hiding this comment

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

hmm I'd usually agree, but I wanted at least one cross chain app that inherits TeleporterOwnerUpgradeable to have a unit test for it, and the other cross chain apps don't have their own unit tests. Also just thought extra unit tests don't hurt.

Copy link
Contributor

Choose a reason for hiding this comment

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

A workaround to this issue would be to implement TeleporterOwnerUpgradable in a separate test contract, then move the unit test for testUpdateMinTeleporterVersion there.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, I see such a contract already exists. I agree with Michael that this unit test would make more sense in TeleporterUpgradeableTests.t.sol.

I don't think we sacrifice test coverage in doing so, since ERC20Bridge doesn't override this method. If it did, we'd definitely want to test it separately.

Copy link
Author

Choose a reason for hiding this comment

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

that's true, since ERC20Bridge doesn't add additional override/functionality and just inherits, having the same test in TeleporterOwnerUpgradeableTests is already covering same test coverage. Removed.

Copy link
Author

Choose a reason for hiding this comment

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

Thoughts on the same topic but for Ownable.transferOwnerhip and Ownable.renounceOwnership? I added extra unit tests for those in TeleporterOwnerUpgradeableTests though we just inherit the functions in TeleporterOwnerUpgradeable. Thinking behind it being these are external contracts, and we can have our own unit tests covering the integration with updateMinTeleporterVersion.

Copy link
Collaborator

Choose a reason for hiding this comment

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

👍

Yep that makes sense to me. The unit tests you're talking about that call transferOwnership and renounceOwnership are actually testing the behavior of updateMinTeleporterVersion, given its use of those other methods. Along that line, I would recommend keeping them in place as is, but possibly renaming them to "testCannotUpdateMinVersionAfterOwnershipTransfer", etc (or something along those lines).

app.updateMinTeleporterVersion();
}

function testRenounceOwnership() public {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we have a test case where renounceOwnership is called successfully, and then assert that the previous owner is unable to update the min teleporter version afterwards?

Copy link
Author

Choose a reason for hiding this comment

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

yup the last few lines check this, but lmk if this should be made more clear or separated.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah my bad, I was just reading it wrong before. 👍

One minor nit, can we have a MOCK_OWNER_ADDRESS value that we use for pranking & transferring ownership to in this test suite rather than using the teleporterAddress? I think it would make it slightly more clear and easier to reason about.

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, however I think we should test updateMinTeleporterVersion in TeleporterOwnerUpgradeableTests rather than ERC20BridgeTests

app.updateMinTeleporterVersion();
}

function testRenounceOwnership() public {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah my bad, I was just reading it wrong before. 👍

One minor nit, can we have a MOCK_OWNER_ADDRESS value that we use for pranking & transferring ownership to in this test suite rather than using the teleporterAddress? I think it would make it slightly more clear and easier to reason about.

bernard-avalabs
bernard-avalabs previously approved these changes Nov 2, 2023
Copy link
Contributor

@bernard-avalabs bernard-avalabs left a comment

Choose a reason for hiding this comment

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

LGTM

cam-schultz
cam-schultz previously approved these changes Nov 2, 2023
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

michaelkaplan13
michaelkaplan13 previously approved these changes Nov 2, 2023
cam-schultz
cam-schultz previously approved these changes Nov 3, 2023
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 439c5aa into main Nov 6, 2023
12 checks passed
@michaelkaplan13 michaelkaplan13 deleted the owner-upgrade branch November 15, 2023 16:44
minghinmatthewlam pushed a commit that referenced this pull request Oct 1, 2024
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.

Implement TeleporterOwnerUpgradeable
5 participants