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

Add selectIssuers Transaction #1327

Merged
merged 40 commits into from
Oct 31, 2019
Merged

Conversation

nambrot
Copy link
Contributor

@nambrot nambrot commented Oct 14, 2019

Description

This PR is the first part for #1314. It adds the commit/reveal transactions, in Attestations speak request/selectIssuers. It does not currently enforce the wait, will be done in a separate pr once #1197 gets merged

  • record block times
  • contractkit mods
  • Store attetation fee token on each attestation

Tested

  • Unit tests

Other changes

Backwards compatibility

  • Once merged, it is not backwards compatible

@codecov
Copy link

codecov bot commented Oct 14, 2019

Codecov Report

Merging #1327 into master will increase coverage by 0.08%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1327      +/-   ##
==========================================
+ Coverage   73.61%   73.69%   +0.08%     
==========================================
  Files         277      277              
  Lines        7443     7432      -11     
  Branches      956      660     -296     
==========================================
- Hits         5479     5477       -2     
+ Misses       1852     1843       -9     
  Partials      112      112
Flag Coverage Δ
#mobile 73.69% <ø> (+0.08%) ⬆️
Impacted Files Coverage Δ
packages/mobile/src/navigator/NavigatorWrapper.tsx 77.77% <0%> (+22.6%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6981eb2...7a3fbcb. Read the comment docs.

packages/protocol/contracts/identity/Attestations.sol Outdated Show resolved Hide resolved
packages/protocol/contracts/identity/Attestations.sol Outdated Show resolved Hide resolved
packages/protocol/contracts/identity/Attestations.sol Outdated Show resolved Hide resolved
packages/protocol/contracts/identity/Attestations.sol Outdated Show resolved Hide resolved
packages/protocol/contracts/identity/Attestations.sol Outdated Show resolved Hide resolved
packages/protocol/contracts/identity/Attestations.sol Outdated Show resolved Hide resolved
packages/protocol/contracts/identity/Attestations.sol Outdated Show resolved Hide resolved
@asaj asaj assigned nambrot and unassigned asaj Oct 14, 2019
@nambrot nambrot assigned asaj and unassigned nambrot Oct 15, 2019
state.issuers.push(issuer);
}
}

function isAttestationTimeValid(uint128 attestationTime) internal view returns (bool) {
function isAttestationRequestBlockTimeValid(
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this function name could be more readable, maybe isAttestationRequestExpired?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Named it to isAttestationExpired following the below conversation on what really constitutes a request

packages/protocol/contracts/identity/Attestations.sol Outdated Show resolved Hide resolved
packages/protocol/contracts/identity/Attestations.sol Outdated Show resolved Hide resolved
require(isAttestationTimeValid(attestation.time), "Attestation request timed out");
require(
isAttestationRequestBlockTimeValid(attestation.blockNumber),
"Attestation request timed out"
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it the request that timed out here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, yeah I just realized that we have two different notions of "request".

First is the request where you commit the attestation fee and one has to call selectIssuers for to set the attestation.

Second is the request for that attestation to be completed to the issuer, either by calling the reveal tx or making a request to the attestation service.

Both represent the notion of a user requesting attestations, albeit at different abstractions.

I'll change it so that only the former is named request, the latter being just attestation, but lmk if that is also confusing

* @param account Address of the account
* @return [Block numbr at which was requested, Number of requests]
*/
function getActiveAttestationRequest(
Copy link
Contributor

Choose a reason for hiding this comment

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

What does active mean in this context? Is an attestation request still active if it has been attestationExpiryBlocks since the request?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Active in this context means that it is a request for attestation for which issuers were not selected yet. Maybe a better word would be getAttestationRequest or getUnselectedAttestationRequest? I'll change it to the former for now.

// solhint-disable-next-line not-rely-on-time
return now < attestationTime.add(attestationExpirySeconds);
return block.number < uint256(attestationRequestBlockTime).add(attestationExpiryBlocks);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are we using time and block numbers? Seems like we should pick one

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's blocks all throughout, somehow I thought using blockTime would indicate this denotes a time in block units, vs. a duration in block units, but see how this is more confusing. Changed it to attestationRequestBlock

@asaj asaj assigned nambrot and unassigned asaj Oct 16, 2019
@nambrot nambrot assigned asaj and unassigned nambrot Oct 16, 2019

import "./SafeCast.sol";

contract MockSafeCast {
Copy link
Contributor

Choose a reason for hiding this comment

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

I wouldn't call this a mock. SafeCastTest would be consistent with the rest of our naming

// The timestamp of the most recent attestation request
uint96 mostRecentAttestationRequest;
// The block number of the most recent attestation request
uint64 mostRecentAttestationRequest;
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: mostRecentAttestationRequestBlockNumber

@@ -203,19 +221,31 @@ contract Attestations is

if (accounts[msg.sender].attestationRequestFeeToken != address(0x0)) {
require(
!isAttestationTimeValid(accounts[msg.sender].mostRecentAttestationRequest) ||
isAttestationExpired(accounts[msg.sender].mostRecentAttestationRequest) ||
accounts[msg.sender].attestationRequestFeeToken == attestationRequestFeeToken,
"A different fee token was previously specified for this account"
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider There exists an unexpired attestation request with a different fee token

@@ -203,19 +221,31 @@ contract Attestations is

if (accounts[msg.sender].attestationRequestFeeToken != address(0x0)) {
require(
!isAttestationTimeValid(accounts[msg.sender].mostRecentAttestationRequest) ||
isAttestationExpired(accounts[msg.sender].mostRecentAttestationRequest) ||
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we have a bug here? Imagine a low attestationExpiryBlocks that would allow us to pass this check and specify a different fee token, but then we increase it so the attestation request we originally thought was expired is now not expired?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure what the technical definition of bug is but I would say in general we have some possibly unintended edge cases when changing parameters by governance. It's hard to anticipate and protect against that, in general and in this specific case I think?

packages/protocol/test/identity/attestations.ts Outdated Show resolved Hide resolved
packages/protocol/test/identity/attestations.ts Outdated Show resolved Hide resolved
packages/contractkit/src/wrappers/Attestations.ts Outdated Show resolved Hide resolved
packages/protocol/test/identity/attestations.ts Outdated Show resolved Hide resolved
@asaj asaj assigned nambrot and unassigned asaj Oct 29, 2019
@nambrot nambrot mentioned this pull request Oct 30, 2019
6 tasks
@nambrot nambrot added the automerge Have PR merge automatically when checks pass label Oct 31, 2019
@celo-ci-bot-user celo-ci-bot-user merged commit 3c86fef into master Oct 31, 2019
@celo-ci-bot-user celo-ci-bot-user deleted the nambrot/attestation-commit branch October 31, 2019 23:07
aaronmgdr added a commit that referenced this pull request Nov 2, 2019
* master: (62 commits)
  Fix e2e on CI (#1537)
  Allow a specified address to disable/enable the Exchange  (#1467)
  Avoid re-encrypting key files with yarn keys:encrypt command (#1560)
  Support protocol hotfixing (#613)
  Point e2e tests back (#1562)
  Refactor to Accounts.sol (#1392)
  Add selectIssuers Transaction (#1327)
  [Wallet] Get React Native Hot Reloading Working (#1551)
  Unify to prefix messages for signing (#1473)
  [Wallet] Improve error handling around account creation and keystore ops (#1497)
  Add CI test for checking licenses and misc package.json cleanup (#1550)
  [Wallet] Implement SMS invite on iOS (#1541)
  CI: brings back to master (#1554)
  Validators: uses Ethereum address for proof of possession (#1494)
  Validate Attestation Requests (#1468)
  Rename hosted node references to forno (#1511)
  Bump rubyzip from 1.2.3 to 1.3.0 in /packages/mobile (#1508)
  Added txpool family to geth apis. Sorted geth cmd options (#1462)
  [Wallet] Fix yarn dev command for running android (#1534)
  [Wallet] iOS info plist changes and version bump (#1539)
  ...

# Conflicts:
#	yarn.lock
aaronmgdr added a commit that referenced this pull request Dec 5, 2019
* master: (73 commits)
  Fix Ethstats Image reference (#1577)
  EU Cookies Behavior Change (#1447)
  [verifier] Upgrade to RN 61 (#1572)
  [Wallet] Update link styles and Implement VerificationEducationScreen (#1565)
  [wallet] Added native phone picker (#1310)
  [Wallet] Set up new verification screen skeletons (#1563)
  Bump e2e test migrate numbers where needed (#1567)
  [Wallet] Create new carousel component (#1555)
  [Wallet] Protect Backup Key and Safeguards with PIN (#1556)
  Increase ganache gas limit (#1569)
  Re-work locked gold requirements for validators and groups (#1474)
  Fix e2e on CI (#1537)
  Allow a specified address to disable/enable the Exchange  (#1467)
  Avoid re-encrypting key files with yarn keys:encrypt command (#1560)
  Support protocol hotfixing (#613)
  Point e2e tests back (#1562)
  Refactor to Accounts.sol (#1392)
  Add selectIssuers Transaction (#1327)
  [Wallet] Get React Native Hot Reloading Working (#1551)
  Unify to prefix messages for signing (#1473)
  ...
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