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

[ETHEREUM-CONTRACTS] Fix nfthooks outofgas #1880

Merged
merged 12 commits into from
Mar 19, 2024
Merged

Conversation

d10r
Copy link
Collaborator

@d10r d10r commented Mar 6, 2024

The fuzz test nicely reproduces the issue.
I couldn't fix it with the try/catch in place.
My proposal is to remove the try/catch. The execution is conditional on the FlowNFT addresses being set, so won't be attempted if none is set. As far as I remember, the decision to try/catch those hooks was not taken out of conviction, but more in a "why not" way, assuming it won't cause any issues.

Copy link

github-actions bot commented Mar 6, 2024

Changelog Reminder

Reminder to update the CHANGELOG.md for any of the modified packages in this PR.

  • CHANGELOG.md modified
  • Double check before merge

@d10r d10r linked an issue Mar 6, 2024 that may be closed by this pull request
2 tasks
@d10r d10r marked this pull request as ready for review March 7, 2024 09:26
_warpAndAssertAll(superToken);

_helperCreateFlow(superToken, bob, alice, flowRate);

_warpAndAssertAll(superToken);
}

// there should be no gas limit which causes the NFT hook to fail with the tx succeeding
function testNFTHookOutOfGasRevertsWholeTx(uint256 gasLimit) public {
Copy link
Contributor

Choose a reason for hiding this comment

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

did you observe any failure without the fix with such fuzzing?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes, reliably failed.
Example:

[FAIL. Reason: CFA_NFT_INVALID_TOKEN_ID(); counterexample: calldata=0xa34c991a00000000000000000000000000000000000000000000000000000000000060c4 args=[24772 [2.477e4]]] testNFTHookOutOfGasRevertsWholeTx(uint256) (runs: 27, μ: 415430, ~: 419640)
Logs:
  Bound Result 424774

Test result: FAILED. 0 passed; 1 failed; 0 skipped; finished in 55.35ms

@hellwolf
Copy link
Contributor

Question without reviewing it holistically yet: if it deletes a NFT that didn't exist (minting failed), would this revert? @d10r @0xdavinchee

Copy link
Contributor

@hellwolf hellwolf left a comment

Choose a reason for hiding this comment

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

  1. An ad-hoc fork testing of the case where NFT was missing uploaded as a gist or temp repo.
  2. A code review from protocol engineers.

@d10r
Copy link
Collaborator Author

d10r commented Mar 14, 2024

https://github.com/d10r/sf-flownft-hook-change-test

[⠢] Compiling...
No files changed, compilation skipped

Running 1 test for test/CFAv1MakeFlowNFTHooksMandatoryTest.t.sol:SFAppTest
[PASS] testUpdateDeleteFlowWithMissingNFT() (gas: 5084163)
Logs:
  deploying new CFA
  updateContracts
  curFr 6390128600823050
  curFr 0

Test result: ok. 1 passed; 0 failed; 0 skipped; finished in 6.12s

@d10r d10r enabled auto-merge March 18, 2024 16:40
@d10r d10r added this pull request to the merge queue Mar 19, 2024
@hellwolf hellwolf removed this pull request from the merge queue due to a manual request Mar 19, 2024
@d10r d10r added this pull request to the merge queue Mar 19, 2024
@d10r d10r removed this pull request from the merge queue due to a manual request Mar 19, 2024
@d10r d10r requested review from kasparkallas and a team as code owners March 19, 2024 14:20
@hellwolf hellwolf enabled auto-merge March 19, 2024 14:22
@hellwolf hellwolf added this pull request to the merge queue Mar 19, 2024
Copy link

codecov bot commented Mar 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.42%. Comparing base (bb5ba5e) to head (02fab7b).

Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #1880      +/-   ##
==========================================
+ Coverage   89.35%   89.42%   +0.07%     
==========================================
  Files         110      110              
  Lines        5920     5903      -17     
  Branches      216      216              
==========================================
- Hits         5290     5279      -11     
+ Misses        578      572       -6     
  Partials       52       52              
Flag Coverage Δ
ethereum-contracts 96.97% <100.00%> (+0.19%) ⬆️
sdk-core 82.40% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Merged via the queue into dev with commit 54fd386 Mar 19, 2024
20 checks passed
@hellwolf hellwolf deleted the fix-nfthooks-outofgas branch March 19, 2024 16:28
Copy link

XKCD Comic Relif

Link: https://xkcd.com/1880
https://xkcd.com/1880

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.

[ETHEREUM-CONTRACTS] flow nft hooks can fail with outofgas
2 participants