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

feat(avm): range checks in vm2 #11433

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

feat(avm): range checks in vm2 #11433

wants to merge 2 commits into from

Conversation

dbanks12
Copy link
Collaborator

@dbanks12 dbanks12 commented Jan 23, 2025

Also sel_range_8/16 and power_of_2 precomputed tables

Copy link
Collaborator Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Copied this file over but renamed some things and removed the selectors specifying which subtrace a range check originated from

@dbanks12 dbanks12 force-pushed the db/range-checks-vm2 branch from 9e6df37 to 834e682 Compare January 23, 2025 02:02
Comment on lines 56 to 57
sel {op1, op2, op3, op4} is sel {op1, op2, op3, op4}; No newline at end of file
sel {op1, op2, op3, op4} is sel {op1, op2, op3, op4};
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't know what's different about our editors, but this happens all the time

Copy link
Contributor

@fcarreiro fcarreiro left a comment

Choose a reason for hiding this comment

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

Looking great from a VM2 perspective!

// Range check selector
pol commit sel_rng_chk;
sel_rng_chk * (1 - sel_rng_chk) = 0;

Copy link
Contributor

Choose a reason for hiding this comment

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

Could you add

// No relations will be checked if this identity is satisfied.
#[skippable_if]
sel = 0;

?

we can discuss skippable in a huddle

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Let's not forget to discuss!

@dbanks12 dbanks12 force-pushed the db/range-checks-vm2 branch from 0baa1f1 to 42cae21 Compare January 24, 2025 02:50
@dbanks12 dbanks12 marked this pull request as ready for review January 24, 2025 02:52
@dbanks12 dbanks12 force-pushed the db/range-checks-vm2 branch from 42cae21 to fb18f3c Compare January 24, 2025 03:08
Copy link
Contributor

Changes to public function bytecode sizes

Generated at commit: 8f6529a003159a5c284bd2077bc24fc884a2a794, compared to commit: 2535425b54751780c65b28c83e630cb5bd7c8a5f

🧾 Summary (100% most significant diffs)

Program Bytecode size in bytes (+/-) %
AuthRegistry::public_dispatch +264 ❌ +3.86%
AppSubscription::public_dispatch +135 ❌ +3.32%
Benchmarking::public_dispatch +90 ❌ +2.61%
Lending::get_position +64 ❌ +1.50%
Lending::_borrow +102 ❌ +1.24%
Lending::_withdraw +102 ❌ +1.21%
AvmTest::public_dispatch +196 ❌ +0.32%
FeeJuice::public_dispatch +8 ❌ +0.17%
TokenBlacklist::mint_public +5 ❌ +0.14%
TokenBlacklist::public_dispatch -14 ✅ -0.06%
Uniswap::public_dispatch -27 ✅ -0.11%
Token::public_dispatch -44 ✅ -0.14%
Lending::public_dispatch -44 ✅ -0.17%
NFT::public_dispatch -96 ✅ -0.42%
Lending::_repay -24 ✅ -0.45%
AppSubscription::constructor -16 ✅ -0.53%
Token::_finalize_transfer_to_private_unsafe -50 ✅ -0.94%
Token::finalize_transfer_to_private -50 ✅ -0.95%
Token::_finalize_mint_to_private_unsafe -55 ✅ -1.11%
Token::finalize_mint_to_private -55 ✅ -1.12%
PriceFeed::set_price -20 ✅ -1.28%
TokenBlacklist::shield -73 ✅ -1.29%
Token::complete_refund -83 ✅ -1.44%
Token::transfer_in_public -65 ✅ -1.49%
Token::mint_to_public -36 ✅ -1.59%
Token::burn_public -86 ✅ -2.00%
Token::_increase_public_balance -45 ✅ -2.08%
TokenBlacklist::mint_private -78 ✅ -2.12%
Lending::_deposit -55 ✅ -2.20%
FeeJuice::_increase_public_balance -50 ✅ -2.62%
TokenBlacklist::_increase_public_balance -68 ✅ -3.00%
TokenBlacklist::balance_of_public -55 ✅ -3.17%
PriceFeed::public_dispatch -91 ✅ -3.39%
Token::balance_of_public -72 ✅ -4.16%
FeeJuice::check_balance -82 ✅ -4.17%
FeeJuice::balance_of_public -72 ✅ -4.30%
PriceFeed::get_price -84 ✅ -5.01%
Spam::public_dispatch -160 ✅ -5.38%
Spam::public_spam -160 ✅ -7.30%
Token::_reduce_total_supply -55 ✅ -12.53%
TokenBlacklist::_reduce_total_supply -78 ✅ -14.50%
TokenBlacklist::total_supply -51 ✅ -14.78%
Token::total_supply -76 ✅ -22.29%

Full diff report 👇
Program Bytecode size in bytes (+/-) %
AuthRegistry::public_dispatch 7,107 (+264) +3.86%
AppSubscription::public_dispatch 4,200 (+135) +3.32%
Benchmarking::public_dispatch 3,534 (+90) +2.61%
Lending::get_position 4,317 (+64) +1.50%
Lending::_borrow 8,356 (+102) +1.24%
Lending::_withdraw 8,522 (+102) +1.21%
AvmTest::public_dispatch 62,140 (+196) +0.32%
FeeJuice::public_dispatch 4,585 (+8) +0.17%
TokenBlacklist::mint_public 3,534 (+5) +0.14%
TokenBlacklist::public_dispatch 23,493 (-14) -0.06%
Uniswap::public_dispatch 24,927 (-27) -0.11%
Token::public_dispatch 31,101 (-44) -0.14%
Lending::public_dispatch 25,936 (-44) -0.17%
NFT::public_dispatch 22,636 (-96) -0.42%
Lending::_repay 5,354 (-24) -0.45%
AppSubscription::constructor 3,007 (-16) -0.53%
Token::_finalize_transfer_to_private_unsafe 5,244 (-50) -0.94%
Token::finalize_transfer_to_private 5,197 (-50) -0.95%
Token::_finalize_mint_to_private_unsafe 4,887 (-55) -1.11%
Token::finalize_mint_to_private 4,840 (-55) -1.12%
PriceFeed::set_price 1,539 (-20) -1.28%
TokenBlacklist::shield 5,569 (-73) -1.29%
Token::complete_refund 5,688 (-83) -1.44%
Token::transfer_in_public 4,309 (-65) -1.49%
Token::mint_to_public 2,227 (-36) -1.59%
Token::burn_public 4,213 (-86) -2.00%
Token::_increase_public_balance 2,121 (-45) -2.08%
TokenBlacklist::mint_private 3,604 (-78) -2.12%
Lending::_deposit 2,440 (-55) -2.20%
FeeJuice::_increase_public_balance 1,857 (-50) -2.62%
TokenBlacklist::_increase_public_balance 2,197 (-68) -3.00%
TokenBlacklist::balance_of_public 1,679 (-55) -3.17%
PriceFeed::public_dispatch 2,597 (-91) -3.39%
Token::balance_of_public 1,658 (-72) -4.16%
FeeJuice::check_balance 1,883 (-82) -4.17%
FeeJuice::balance_of_public 1,604 (-72) -4.30%
PriceFeed::get_price 1,592 (-84) -5.01%
Spam::public_dispatch 2,814 (-160) -5.38%
Spam::public_spam 2,033 (-160) -7.30%
Token::_reduce_total_supply 384 (-55) -12.53%
TokenBlacklist::_reduce_total_supply 460 (-78) -14.50%
TokenBlacklist::total_supply 294 (-51) -14.78%
Token::total_supply 265 (-76) -22.29%

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.

2 participants