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

Safe cast stragglers #978

Merged
merged 13 commits into from
Sep 23, 2024
Merged

Safe cast stragglers #978

merged 13 commits into from
Sep 23, 2024

Conversation

EndymionJkb
Copy link
Collaborator

Description

Looking through the issues, was about to close 181 (since the comment it references is long gone), and thought I'd check for any unsafe casts. We'd recently gone through and added SafeCasts as a result of auditor comments. There were a couple very obscure cases still uncovered (outside tests).

Type of change

  • Bug fix
  • New feature
  • Breaking change
  • Dependency changes
  • Code refactor / cleanup
  • Optimization: [ ] gas / [ ] bytecode
  • Documentation or wording changes
  • Other

Checklist:

  • The diff is legible and has no extraneous changes
  • [N/A] Complex code has been commented, including external interfaces
  • Tests have 100% code coverage
  • The base branch is either main, or there's a description of how to merge

Issue Resolution

Closes #181

# Conflicts:
#	pkg/vault/test/.contract-sizes/VaultAdmin
# Conflicts:
#	pkg/pool-weighted/test/gas/.hardhat-snapshots/[WeightedPool - ERC4626 - BatchRouter] swapExactIn - no buffer liquidity - warm slots
#	pkg/pool-weighted/test/gas/.hardhat-snapshots/[WeightedPool - Standard] add liquidity single token exact out - warm slots
#	pkg/pool-weighted/test/gas/.hardhat-snapshots/[WeightedPool - Standard] add liquidity unbalanced - warm slots
#	pkg/vault/test/.contract-sizes/VaultAdmin
Copy link
Contributor

@jubeira jubeira left a comment

Choose a reason for hiding this comment

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

Thanks @EndymionJkb; just one question, otherwise LGTM.

@@ -14,6 +16,8 @@ pragma solidity ^0.8.24;
* When the buffer period expires, it will unpause automatically, and remain permissionless forever after.
*/
contract FactoryWidePauseWindow {
using SafeCast for *;
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm where are we using this?

Copy link
Collaborator Author

@EndymionJkb EndymionJkb Sep 22, 2024

Choose a reason for hiding this comment

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

Removed... it was used to case the timestamp in the getNewPoolPauseWindowEndTime function, but then I realized that would revert when it overflowed (in 2106, but still...), but the inequality would still work, so as it is now it will return 0 after 2106 instead of reverting, as it should. No longer needed the cast, but forgot to remove it.

Truncating is worse - it could re-pause itself after 2106.

Copy link
Contributor

@jubeira jubeira left a comment

Choose a reason for hiding this comment

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

LGTM!

@EndymionJkb EndymionJkb merged commit 783176d into main Sep 23, 2024
12 checks passed
@EndymionJkb EndymionJkb deleted the safe-cast-stragglers branch September 23, 2024 13:02
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.

Review unsafe casts
2 participants