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

fix isPaymentDone verification - verify by recovered address not reci… #314

Merged
merged 4 commits into from
Nov 11, 2024

Conversation

volodymyr-basiuk
Copy link
Contributor

@volodymyr-basiuk volodymyr-basiuk commented Nov 8, 2024

No description provided.

@coveralls
Copy link

coveralls commented Nov 8, 2024

Pull Request Test Coverage Report for Build 11778291936

Details

  • 32 of 32 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.01%) to 83.533%

Totals Coverage Status
Change from base Build 11747628628: 0.01%
Covered Lines: 993
Relevant Lines: 1118

💛 - Coveralls

@@ -112,8 +112,8 @@ contract MCPayment is Ownable2StepUpgradeable, EIP712Upgradeable {
Iden3PaymentRailsRequestV1 memory paymentData,
bytes memory signature
) external payable {
verifyIden3PaymentRailsRequestV1Signature(paymentData, signature);
bytes32 paymentId = keccak256(abi.encode(paymentData.recipient, paymentData.nonce));
address recoverd = recoverIden3PaymentRailsRequestV1Signature(paymentData, signature);
Copy link
Collaborator

Choose a reason for hiding this comment

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

recovered, or you can use signer, which has somewhat better readability

Copy link
Contributor Author

@volodymyr-basiuk volodymyr-basiuk Nov 11, 2024

Choose a reason for hiding this comment

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

signer better name, changed

}

function isPaymentDone(address recipient, uint256 nonce) external view returns (bool) {
function isPaymentDone(address signer, uint256 nonce) external view returns (bool) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

IMHO recipient was a better name as for the purpose of this API, and better understood by whoever reads it first time. Signer is related to details of implementation, which are lower than this level.

P.S. After reading the PR till the end I realised that it's not recipient but issuer which is the payment record is accounted under. However can you just replace signer with 'issuer' is a question? If the protocol evolve in a way that it's not only issuer entity, which signs then there should be different name. Anyway, signer doesn't look like the best option. It confuses a new reader. A one can think that signer is the one who pays and signs something. So better to figure out better naming.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

issuer now always sign the message, so we can use issuer

console.log("Verification Gas: " + verifyGas);
await payment
const recovered = await payment
Copy link
Collaborator

Choose a reason for hiding this comment

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

Again signer is better here than recovered, I think

Comment on lines 61 to 64
const verifyGas = await payment
.connect(userSigner)
.verifyIden3PaymentRailsRequestV1Signature.estimateGas(paymentData, signature);
.recoverIden3PaymentRailsRequestV1Signature.estimateGas(paymentData, signature);
console.log("Verification Gas: " + verifyGas);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do you need the gas verification in the tests?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

not really, removed

@AndriianChestnykh
Copy link
Collaborator

@volodymyr-basiuk Additionally, please add NatSpec comments everywhere in the new payment functionality and check if verification will be run in the deploy scripts at deployment time in the same way as it is run for other contracts

@volodymyr-basiuk volodymyr-basiuk merged commit d21320b into master Nov 11, 2024
5 checks passed
@volodymyr-basiuk volodymyr-basiuk deleted the fix/mcpayment-done branch November 11, 2024 17:37
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.

4 participants