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

CIP10 contracts changes #5913

Merged
merged 75 commits into from
May 12, 2021
Merged

CIP10 contracts changes #5913

merged 75 commits into from
May 12, 2021

Conversation

AlexBHarley
Copy link
Contributor

@AlexBHarley AlexBHarley commented Nov 18, 2020

Description

For more context take a look at CIP10. There's so many commits as there was a lot of back and forth on implementation details.

Other changes

N/A.

Tested

Added an extensive matrix of tests to test this for backwards compatibility.

Related issues

Other changes

Accounts.sol is now InitializableV2.

Backwards compatibility

These changes are backwards compatible.

@AlexBHarley AlexBHarley marked this pull request as draft November 18, 2020 16:50
@AlexBHarley AlexBHarley marked this pull request as ready for review April 15, 2021 13:47
@AlexBHarley AlexBHarley requested a review from a team April 15, 2021 13:47
@AlexBHarley AlexBHarley changed the title [WIP]: CIP10 contracts changes CIP10 contracts changes Apr 15, 2021
Copy link
Contributor

@yorhodes yorhodes left a comment

Choose a reason for hiding this comment

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

haven't been able to look at the tests yet but in the spirit of throughput initiatives, lets try and make some gas optimizations first

packages/protocol/contracts/common/Accounts.sol Outdated Show resolved Hide resolved
packages/protocol/contracts/common/Accounts.sol Outdated Show resolved Hide resolved
packages/protocol/contracts/common/Accounts.sol Outdated Show resolved Hide resolved
packages/protocol/contracts/common/Accounts.sol Outdated Show resolved Hide resolved
* @param _account The address of account that authorized signing.
* @param role The role to finish authorizing for.
*/
function completeSignerAuthorization(address _account, string memory role) public {
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe I'm not familiar enough with CIP10 but why separate authorize and complete, and why limit this to only signer == msg.sender?
what is the downside to someone authorizing and completing you as a signer on your behalf?

Copy link
Contributor

Choose a reason for hiding this comment

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

It's a double opt-in. Like we have for our existing roles. You don't really want to allow the "burning" of an address in this scheme without their consent

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agree that it's a little confusing. I guess there's two things at play here

  • the act of proving you own an address
  • setting that address as an authorised signer for an account.

Our system treats those two as one step currently. One question to ask is why have authorizeSignerWithSignature at all? The answer being we want to prove proof of possession before saying XXX was authorised by YYY.

Having completeSignerAuthorization is just the proof of possession for SC addresses.

Account storage account = accounts[_account];

address signer;
if (keccak256(abi.encodePacked(role)) == keccak256(abi.encodePacked(ValidatorSigner))) {
Copy link
Contributor

Choose a reason for hiding this comment

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

there is a lot of redundancy in these if/elses (switch)
can we abstract?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

TBH I don't see how. We have this switch block in four places but I'm not sure what an extracted function would look like as we're doing different things each time.

}

function hasDefaultSigner(address account, string memory role) public view returns (bool) {
require(isAccount(account));
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

Copy link
Contributor

Choose a reason for hiding this comment

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

eth_call reverting isn't super useful imo

Copy link
Contributor

Choose a reason for hiding this comment

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

What if the view is used on a non-view function tho?

packages/protocol/contracts/common/Accounts.sol Outdated Show resolved Hide resolved
Copy link
Contributor

@nambrot nambrot left a comment

Choose a reason for hiding this comment

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

🙏

packages/protocol/test/common/accounts.ts Outdated Show resolved Hide resolved
packages/protocol/contracts/common/Accounts.sol Outdated Show resolved Hide resolved
packages/protocol/contracts/common/Accounts.sol Outdated Show resolved Hide resolved
packages/protocol/contracts/common/Accounts.sol Outdated Show resolved Hide resolved
packages/protocol/contracts/common/Accounts.sol Outdated Show resolved Hide resolved
* @param _account The address of the account.
* @param role The role of the signer.
*/
function getDefaultSigner(address _account, string memory role) public view returns (address) {
Copy link
Contributor

Choose a reason for hiding this comment

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

diito on separating for gas efficiency

}

function hasDefaultSigner(address account, string memory role) public view returns (bool) {
require(isAccount(account));
Copy link
Contributor

Choose a reason for hiding this comment

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

What if the view is used on a non-view function tho?

packages/protocol/test/common/accounts.ts Show resolved Hide resolved
Copy link
Contributor

@nategraf nategraf left a comment

Choose a reason for hiding this comment

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

Stopping in on my way to understand CIP-10 for account recovery purposes 👋 I have some comments as a bit of an outsider to this work and hopefully its helpful.

packages/protocol/contracts/common/Accounts.sol Outdated Show resolved Hide resolved
packages/protocol/contracts/common/Accounts.sol Outdated Show resolved Hide resolved
packages/protocol/contracts/common/Accounts.sol Outdated Show resolved Hide resolved
packages/protocol/contracts/common/Accounts.sol Outdated Show resolved Hide resolved
packages/protocol/contracts/common/Accounts.sol Outdated Show resolved Hide resolved
packages/protocol/contracts/common/Accounts.sol Outdated Show resolved Hide resolved
packages/protocol/contracts/common/Accounts.sol Outdated Show resolved Hide resolved
@yorhodes
Copy link
Contributor

I see that the test-release is still indicating a bump to the storage version
https://app.circleci.com/pipelines/github/celo-org/celo-monorepo/34832/workflows/ca20cd8d-d820-4453-a89f-66d023ec0888/jobs/450663
Any idea why?

@AlexBHarley AlexBHarley changed the base branch from master to yorhodes/library-reuse May 7, 2021 12:06
@yorhodes yorhodes force-pushed the yorhodes/library-reuse branch 2 times, most recently from 9deb46a to b7742f1 Compare May 12, 2021 00:19
@yorhodes yorhodes changed the base branch from yorhodes/library-reuse to master May 12, 2021 00:53
@yorhodes yorhodes added the automerge Have PR merge automatically when checks pass label May 12, 2021
@nambrot nambrot merged commit f64b4c5 into master May 12, 2021
@mergify mergify bot deleted the alexbharley/cip10 branch May 12, 2021 18:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge Have PR merge automatically when checks pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants