Skip to content

feat[lang]!: add unbounded types#4967

Open
Sporarum wants to merge 38 commits into
vyperlang:masterfrom
Sporarum:unbounded-sequence-types
Open

feat[lang]!: add unbounded types#4967
Sporarum wants to merge 38 commits into
vyperlang:masterfrom
Sporarum:unbounded-sequence-types

Conversation

@Sporarum
Copy link
Copy Markdown
Collaborator

What I did

Implement #4856

Fix interface implementation working backwards for the return type, this is a breaking change !
(text below mentions Bytes, but the logic is the same for String and DynArray)
In interfaces, replace Bytes[1] in return types and variables by Bytes[...] to keep them behaving as previously.
There is no replacement for Bytes[<n>] in return types meaning "can be implemented by Bytes[<k>] where k >= n"
In return types, Bytes[n] now means "can be implemented by Bytes[<k>] where k <= n".
Note that this is required for safety: if a function is guaranteed by its interface to return at most 2 bytes, we shouldn't be able to implement it with one which returns 3 bytes.

How I did it

How to verify it

Commit message

this commit adds two new kinds of lengths for types: wildcards
(Bytes[...]) and infinity (Bytes[INF]). both these lengths are only
allowed inside types where the length is an upper bound: Bytes, String,
DynArray. wildcards are only allowed in interfaces and they represent an
unknown length which is checked implicitly on assignment. infinite
lengths are only allowed on local variables, function parameters, and
return types as storage cannot be allocated for them. this commit also
fixes return types in interfaces being contravariant instead of
covariant, this is a breaking change!

Description for the changelog

add wildcard length for interfaces, for example Bytes[...]
BREAKING fix interface return types, update your interfaces to use a wildcard length to fix it, example: Bytes[1] -> Bytes[...]
add unbounded types, for exampleBytes[INF]

Cute Animal Picture

Put a link to a cute animal picture inside the parenthesis-->

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 12, 2026

Gas Changes

Test Base Gas Head Gas Delta
ERC1155Test:testFuzzSafeBatchTransferFromByApprovedOperator(address,address,address,uint256,uint256,uint256,uint256,bytes) 270939741 189507 🟢-270750234
ERC1155Test:testFuzzSafeBatchTransferFromEOAReceiver(address,address,uint256,uint256,uint256,uint256,bytes) 270905134 154900 🟢-270750234
ERC1155Test:testSafeBatchTransferFromByApprovedOperator() 271050974 300740 🟢-270750234
ERC1155Test:testSafeBatchTransferFromInsufficientBalance() 270981777 231543 🟢-270750234
ERC1155Test:testSafeBatchTransferFromLengthsMismatch() 270778623 28389 🟢-270750234
ERC1155Test:testSafeBatchTransferFromToZeroAddress() 270972540 222306 🟢-270750234
ERC1155Test:testSafeMintBatchLengthsMismatch() 270781827 31593 🟢-270750234
ERC1155Test:testSafeMintBatchOverflow() 270979716 229482 🟢-270750234
ERC1155Test:testSafeBatchTransferFromNoData() 271356235 606659 🟢-270749576
ERC1155Test:testSafeBatchTransferFromReceiverInvalidReturnIdentifier() 271334696 585120 🟢-270749576
ERC1155Test:testSafeBatchTransferFromReceiverReverts() 271328587 579011 🟢-270749576
ERC1155Test:testSafeBatchTransferFromReceiverRevertsOnlySingle() 271356276 606700 🟢-270749576
ERC1155Test:testSafeBatchTransferFromWithData() 271357365 607789 🟢-270749576
ERC1155Test:testFuzzSafeBatchTransferFromNoData(address,uint256,uint256,uint256,uint256) 271250416 500852 🟢-270749564
ERC1155Test:testFuzzSafeBatchTransferFromWithData(address,uint256,uint256,uint256,uint256) 271250486 500922 🟢-270749564
ERC1155Test:testSafeBatchTransferFromEOAReceiver() 271009130 266584 🟢-270742546
ERC1155Test:testSafeBatchTransferFromReceiverFunctionNotImplemented() 270991871 253304 🟢-270738567
TimelockControllerTest:testHandleERC1155() 142878427 7484047 🟢-135394380
ERC1155Test:testExistsAfterBatchMint() 135500687 125570 🟢-135375117
ERC1155Test:testFuzzSafeMintBatchEOAReceiver(address,address,uint256,uint256,uint256,uint256,bytes) 135509771 134654 🟢-135375117
ERC1155Test:testFuzzTotalSupplyAfterBatchMint(address,uint256,uint256,uint256,uint256) 135498623 123506 🟢-135375117
ERC1155Test:testSafeBatchTransferFromByNotApprovedOperator() 135596101 220984 🟢-135375117
ERC1155Test:testSafeMintBatchEOAReceiver() 135603795 228678 🟢-135375117
ERC1155Test:testSafeMintBatchToZeroAddress() 135398367 23250 🟢-135375117
ERC1155Test:testTotalSupplyAfterBatchMint() 135500618 125501 🟢-135375117
ERC1155Test:testSafeMintBatchNoData() 135944055 569596 🟢-135374459
ERC1155Test:testSafeMintBatchReceiverFunctionNotImplemented() 135584638 210179 🟢-135374459
ERC1155Test:testSafeMintBatchReceiverInvalidReturnIdentifier() 135927465 553006 🟢-135374459
ERC1155Test:testSafeMintBatchReceiverReverts() 135921332 546873 🟢-135374459
ERC1155Test:testSafeMintBatchReceiverRevertsOnlySingle() 135944032 569573 🟢-135374459
ERC1155Test:testSafeMintBatchWithData() 135944675 570216 🟢-135374459
ERC1155Test:testFuzzSafeMintBatchNoData(address,uint256,uint256,uint256,uint256) 135848923 474476 🟢-135374447
ERC1155Test:testFuzzSafeMintBatchWithData(address,uint256,uint256,uint256,uint256) 135849126 474679 🟢-135374447
ERC1155Test:testTotalSupplyAfterBatchBurn() 135478597 110412 🟢-135368185
ERC1155Test:testExistsAfterBatchBurn() 135478578 110396 🟢-135368182
ERC1155Test:testBurnBatchAmountExceedsBalance() 135520011 175383 🟢-135344628
ERC1155Test:testFuzzBurnBatchSuccess(address,uint256,uint256,uint256,uint256) 135439908 111023 🟢-135328885
ERC1155Test:testFuzzTotalSupplyAfterBatchBurn(address,uint256,uint256,uint256,uint256) 135432634 105203 🟢-135327431
ERC1155Test:testBurnBatchByApprovedOperator() 135543401 225935 🟢-135317466
ERC1155Test:testBurnBatchSuccess() 135501375 192314 🟢-135309061
ERC1155Test:testUriBaseAndTokenUriNotSet() 2726318 2706384 🟢-19934
ERC1155Test:testUriNoBaseURI() 2778921 2758987 🟢-19934
ERC1155Test:testInitialSetup() 2856276 2836343 🟢-19933

Summary

  • Total tests measured: 815
  • Changed: 43
  • Regressions (gas up): 0
  • Improvements (gas down): 43
  • New tests: 0
  • Deleted tests: 0
  • Newly failing: 0
  • Newly passing: 0
  • Top improvement: ERC1155Test:testFuzzSafeBatchTransferFromByApprovedOperator(address,address,address,uint256,uint256,uint256,uint256,bytes) (-270750234)

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bb4bd59c39

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +294 to +297
if self.length is INF:
# INF >= INF
# INF >= n
return True
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Check element types for unbounded dynamic arrays

When the expected type is DynArray[..., INF], this branch returns True before comparing value_type, so a bounded array with the wrong element type is accepted as long as the length is finite (for example, DynArray[address, 1] type-checks against DynArray[uint256, INF]). This lets semantic validation accept calls or assignments that should be rejected and can defer the mismatch to later compiler stages.

Useful? React with 👍 / 👎.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 12, 2026

📊 Bytecode Size Changes (venom)

Contract legacy-O2 legacy-Os -O2 -O3 -Os
curvefi/gauge/child_gauge/factory/factory_v_201.vy 4844 4547 4327 (🟢-15) 4045 (🟢-15) 3811 (🟢-15)
curvefi/gauge/child_gauge/factory/factory_v_100.vy 4183 3914 3753 (🟢-15) 3457 (🟢-15) 3242 (🟢-15)

Full bytecode sizes

Contract legacy-O2 legacy-Os -O2 -O3 -Os
curvefi/amm/tricryptoswap/implementation/implementation_v_200.vy
curvefi/amm/tricryptoswap/math/math_v_200.vy
curvefi/amm/twocryptoswap/implementation/implementation_v_210.vy
curvefi/amm/twocryptoswap/math/math_v_210.vy
curvefi/legacy/CurveCryptoMathOptimized3.vy
curvefi/amm/stableswap/meta_implementation/meta_implementation_v_700.vy 23610 22805 20884 19821 19383
curvefi/legacy/CurveStableSwapMetaNG.vy 24952 23578 20721 20072 19376
curvefi/amm/stableswap/implementation/implementation_v_700.vy 24962 23769 20546 19645 19097
curvefi/legacy/CurveStableSwapNG.vy 24473 23298 19939 19065 18546
yearnfi/VaultV3.vy 19972 19063 17139 15221 14569
curvefi/legacy/CurveCryptoSwap2.vy 18947 18382 15626 15068 14703
yearnfi/VaultV2.vy 16676 15763 13934 13446 12615
curvefi/amm/stableswap/factory/factory_v_100.vy 14558 13978 13352 11920 11901
curvefi/amm/stableswap/views/views_v_120.vy 12784 12368 10390 9748 9892
curvefi/gauge/child_gauge/implementation/implementation_v_110.vy 12338 11561 10345 9811 9227
curvefi/gauge/child_gauge/implementation/implementation_v_100.vy 12017 11249 10073 9538 8965
curvefi/gauge/child_gauge/implementation/implementation_v_020.vy 10665 9947 9141 8608 8096
curvefi/helpers/router/router_v_110.vy 6717 6717 7068 6407 6642
curvefi/amm/tricryptoswap/views/views_v_200.vy 7821 7776 6780 6498 6567
curvefi/registries/metaregistry/metaregistry_v_110.vy 7590 6732 6716 5923 5762
curvefi/helpers/stable_swap_meta_zap/stable_swap_meta_zap_v_100.vy 7302 7067 6595 6198 6300
curvefi/amm/twocryptoswap/views/views_v_200.vy 6991 6946 6337 6061 6124
curvefi/registries/metaregistry/registry_handlers/stableswap/handler_v_110.vy 6633 6259 5982 5157 5625
curvefi/amm/twocryptoswap/factory/factory_v_200.vy 5540 5252 5931 4654 4825
curvefi/amm/tricryptoswap/factory/factory_v_200.vy 5246 5021 5921 4916 5028
curvefi/gauge/child_gauge/factory/factory_v_201.vy 4844 4547 4327 4045 3811
yearnfi/VaultFactory.vy 3765 3617 4017 2520 2999
curvefi/registries/metaregistry/registry_handlers/tricryptoswap/handler_v_110.vy 4241 3939 3895 3574 3574
curvefi/registries/metaregistry/registry_handlers/twocryptoswap/handler_v_110.vy 4186 3884 3834 3444 3460
curvefi/gauge/child_gauge/factory/factory_v_100.vy 4183 3914 3753 3457 3242
curvefi/helpers/rate_provider/rate_provider_v_101.vy 3260 3260 2862 2490 2503
curvefi/registries/address_provider/address_provider_v_201.vy 2973 2782 2790 2616 2471
curvefi/amm/stableswap/math/math_v_100.vy 3067 3046 2655 2430 2450
curvefi/helpers/rate_provider/rate_provider_v_100.vy 2847 2841 2428 2091 2099
curvefi/helpers/deposit_and_stake_zap/deposit_and_stake_zap_v_100.vy 2322 2316 2184 1920 1952
curvefi/governance/relayer/taiko/relayer_v_001.vy 2068 2064 1712 1567 1600
curvefi/governance/relayer/polygon_cdk/relayer_v_101.vy 1556 1523 1519 1397 1398
curvefi/governance/relayer/arb_orbit/relayer_v_101.vy 1266 1262 1207 1111 1142
curvefi/governance/relayer/op_stack/relayer_v_101.vy 1186 1182 1146 1053 1081
curvefi/governance/relayer/not_rollup/relayer_v_100.vy 1168 1153 1135 1048 1060
curvefi/governance/vault/vault_v_100.vy 964 941 940 891 889
curvefi/governance/agent/agent_v_100.vy 541 541 498 440 444
curvefi/governance/agent/agent_v_101.vy 541 541 498 440 444
curvefi/governance/relayer/relayer_v_100.vy 496 496 467 462 467

@codecov
Copy link
Copy Markdown

codecov Bot commented May 12, 2026

Codecov Report

❌ Patch coverage is 89.61749% with 19 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.69%. Comparing base (96daf69) to head (028eedb).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
vyper/semantics/types/subscriptable.py 72.91% 13 Missing ⚠️
vyper/codegen_venom/context.py 50.00% 1 Missing and 1 partial ⚠️
vyper/semantics/types/bytestrings.py 91.66% 1 Missing and 1 partial ⚠️
vyper/semantics/types/base.py 80.00% 1 Missing ⚠️
vyper/semantics/types/function.py 0.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4967      +/-   ##
==========================================
- Coverage   92.69%   92.69%   -0.01%     
==========================================
  Files         186      187       +1     
  Lines       27405    27461      +56     
  Branches     4725     4733       +8     
==========================================
+ Hits        25404    25454      +50     
- Misses       1358     1368      +10     
+ Partials      643      639       -4     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

1 participant