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

refactor: Use compressed storage #1

Merged
merged 31 commits into from
Feb 14, 2025
Merged

refactor: Use compressed storage #1

merged 31 commits into from
Feb 14, 2025

Conversation

oddaf
Copy link
Member

@oddaf oddaf commented Jan 22, 2025

No description provided.

@oddaf oddaf requested a review from amusingaxl January 22, 2025 00:54
@oddaf oddaf self-assigned this Jan 22, 2025
@oddaf oddaf requested review from 0x3phemeralsoul and removed request for amusingaxl January 22, 2025 00:54
```
- Since rates are stored in 8 bytes, the max BPS that can be used without reimplementing this contract is **7891**.
- EIP-170: Due to contract size limits on Ethereum mainnet, the ceiling for rates is 6k. On L2s that do not enforce the limit this does not apply.
- Gas cost of deployment: With the current 30M block gas ceiling on Ethereum mainnet, up to ~5.5k rates can be stored.
Copy link
Member

@0x3phemeralsoul 0x3phemeralsoul Jan 30, 2025

Choose a reason for hiding this comment

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

does it make sense to translate 5.5K rates into bps? so from 0.01% until approx which bps would be possible, is it 50% approx? This would give a better idea of the technical limitation from a business sense

Copy link
Member

Choose a reason for hiding this comment

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

In the end the limit is set 50% so we don't use the full 30M gas ceiling.
It means that it's every bps from 0 to 50%, a total of 50001 rates.

Copy link
Member Author

Choose a reason for hiding this comment

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

The first ceiling is the block gas limit. It only allows rates until some number around 55%. I went with 50 because it's round (easy to remember) and I think going from it to 54.12 wouldn't make much difference in practice. But we could go there if needed. If the gas limit is raised we could go to the next ceiling (contract size, could go up to 6k rates)

test/Conv.t.sol Outdated
uint256 mappingRate = ratesMapping.rates(bps);
uint256 bytesRate = conv.turn(bps);

assertEq(bytesRate, mappingRate, string.concat("Rate mismatch at bps=", vm.toString(bps)));
Copy link
Member

Choose a reason for hiding this comment

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

how was ratesMapping created? is there a way to validate it fully matches: https://ipfs.io/ipfs/QmVp4mhhbwWGTfbh2BzwQB9eiBrQBKiqcPRZCaAxNUaar6 ?

Copy link
Member Author

Choose a reason for hiding this comment

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

done in 9ce53d5

@oddaf oddaf requested a review from 0xp3th1um January 30, 2025 23:10
Co-authored-by: amusingaxl <[email protected]>
Signed-off-by: oddaf <[email protected]>
amusingaxl
amusingaxl previously approved these changes Feb 3, 2025
Copy link
Member

@amusingaxl amusingaxl left a comment

Choose a reason for hiding this comment

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

LGTM!
:shipit:

@amusingaxl amusingaxl dismissed their stale review February 5, 2025 18:17

Code updated.

Copy link

@0xp3th1um 0xp3th1um left a comment

Choose a reason for hiding this comment

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

great job!

oddaf and others added 2 commits February 7, 2025 17:20
Copy link

@0xp3th1um 0xp3th1um left a comment

Choose a reason for hiding this comment

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

re-approving after new script addition

@oddaf oddaf merged commit bae9648 into master Feb 14, 2025
2 checks passed
@oddaf oddaf deleted the optimized-storage branch February 14, 2025 01:47
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