Skip to content
This repository has been archived by the owner on Jan 24, 2022. It is now read-only.

Rename: zos-lib contracts and zos command #1074

Merged
merged 19 commits into from
Jul 11, 2019

Conversation

jbcarpanelli
Copy link
Contributor

@jbcarpanelli jbcarpanelli commented Jul 4, 2019

This PR implements:

  • Renames in zos-lib contract references:
Current New
ZOSLibOwnable OpenZeppelinUpgradesOwnable
ZOSLibECDSA OpenZeppelinUpgradesECDSA
ZOSLibAddress OpenZeppelinUpgradesAddress
  • Renames both implementation & admin slots in contracts and zos-lib contracts, giving support for those proxies already created with the old slot labels references.
  • Rename zos-cli.ts to oz-cli.ts. Also changed references in cli/package.json files
  • Add openzeppelin and oz as valid binaries, and added zos and oz as commander aliases.
  • Rename bin/zos-cli.js references in zepkit integration tests and first-project sample.
  • Add deprecation warning when using zos instead of oz or openzeppelin

Tests are failing but they should be not very difficult to fix, as almost all are throwing the same error.

Copy link
Contributor

@ylv-io ylv-io left a comment

Choose a reason for hiding this comment

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

🚢 🚀
Hey @jcarpanelli! Stellar job!
I'd say we need tests to check that implementation and admin methods of Proxy work for both new and old labels. WDYT?

@@ -40,7 +38,7 @@ contract('ProxyAdmin', function(accounts) {
this.ownable = this.proxyAdmin;
});

shouldBehaveLikeOwnable(proxyAdminOwner, anotherAccount);
// shouldBehaveLikeOwnable(proxyAdminOwner, anotherAccount);
Copy link
Contributor

Choose a reason for hiding this comment

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

👀 Why is that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ha! nice catch. I left it commented while debugging 😢

Copy link
Contributor

@spalladino spalladino left a comment

Choose a reason for hiding this comment

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

Great work Jota! Thanks for taking care of this massive change! I flagged a few changes, mostly around implementing EIP 1967 (as linked in the issue) instead of a custom label for the proxy storage slots. Let me know if you have any questions regarding that EIP!

packages/cli/src/bin/oz-cli.ts Outdated Show resolved Hide resolved
@@ -20,10 +20,10 @@ contract DeprecatedAdminUpgradeabilityProxy is UpgradeabilityProxy {

/**
* @dev Storage slot with the admin of the contract.
* This is the keccak-256 hash of "org.zeppelinos.proxy.admin", and is
* This is the keccak-256 hash of "com.openzeppelinupgrades.proxy.admin", and is
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's make use of the renaming to push EIP 1967 instead. Please double check on your end that the hashes were calculated correctly!

Logic contract address

Storage slot 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc (obtained as bytes32(uint256(keccak256('eip1967.proxy.implementation')) - 1)).

Admin address

Storage slot 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103 (obtained as bytes32(uint256(keccak256('eip1967.proxy.admin')) - 1)).

sinon.restore();
});

it('uses the correct admin storage slot', async function() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Note that this test does not check that the Proxy class falls back to the deprecated label. I'd suggest adding a LegacyProxy contract in the mocks folder, and testing against it to ensure both the storage and admin are correctly retrieved.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeap, I'm working on it. I created a zos folder inside the mock contracts folder and added the Zos prefix to the upgradeability contract names. Is that fine?

@@ -46,6 +54,16 @@ export default function shouldBehaveLikeUpgradeabilityProxy(
it('has expected balance', async function() {
(await ZWeb3.getBalance(this.proxy)).should.eq(balance.toString());
});

it('uses the correct implementation storage slot', async function() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Same for this test

@jbcarpanelli
Copy link
Contributor Author

@spalladino should be ready for another review.

@jbcarpanelli jbcarpanelli force-pushed the rename/commands-and-contracts branch from e8a0dad to 8c6cb04 Compare July 11, 2019 17:37

const DummyImplementation = Contracts.getFromLocal('DummyImplementation');

export function shouldUseEIP1967StorageSlot(createProxy, accounts, labels, fnName) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd say that the tests in this file are already covered by the shouldBehaveLikeProxy tests run on both the new and the legacy implementations, so they should not be needed - but they definitely not hurt, so let's keep them.

@ylv-io ylv-io self-requested a review July 11, 2019 20:12
Copy link
Contributor

@ylv-io ylv-io left a comment

Choose a reason for hiding this comment

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

🚢 🍾

@jbcarpanelli jbcarpanelli merged commit 71c9ad7 into master Jul 11, 2019
@mergify mergify bot deleted the rename/commands-and-contracts branch July 11, 2019 23:04
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants