-
Notifications
You must be signed in to change notification settings - Fork 369
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
Conversation
Codecov Report
@@ 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
Continue to review full report at Codecov.
|
state.issuers.push(issuer); | ||
} | ||
} | ||
|
||
function isAttestationTimeValid(uint128 attestationTime) internal view returns (bool) { | ||
function isAttestationRequestBlockTimeValid( |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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
require(isAttestationTimeValid(attestation.time), "Attestation request timed out"); | ||
require( | ||
isAttestationRequestBlockTimeValid(attestation.blockNumber), | ||
"Attestation request timed out" |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
|
||
import "./SafeCast.sol"; | ||
|
||
contract MockSafeCast { |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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) || |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
* Enforce wait for selectIssuers * Fix lint * PR comments
* 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
* 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) ...
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 mergedTested
Other changes
SafeCast
from Safe Casting Library from uint256 to uintXX OpenZeppelin/openzeppelin-contracts#1926. We should use upstream whenever it gets mergedBackwards compatibility