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

Support for string slices in contracts/predicates/scripts #6079

Merged
merged 9 commits into from
Jun 19, 2024

Conversation

xunilrj
Copy link
Contributor

@xunilrj xunilrj commented May 31, 2024

Description

This PR, for encoding v1, allows string slices in inputs and outputs of scripts and contracts; and in inputs of predicates.
For encoding v0, the limitation is kept.

This PR will also land the necessary start of future improvements on "slices" (including string slices).

This PR closes #5145

Checklist

  • I have linked to any relevant issues.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have updated the documentation where relevant (API docs, the reference, and the Sway book).
  • I have added tests that prove my fix is effective or that my feature works.
  • I have added (or requested a maintainer to add) the necessary Breaking* or New Feature labels where relevant.
  • I have done my best to ensure that my PR adheres to the Fuel Labs Code Review Standards.
  • I have requested a review from the relevant team or maintainers.

Copy link

Benchmark for 78edc04

Click to view benchmark
Test Base PR %
code_action 5.2±0.01ms 5.4±0.06ms +3.85%
code_lens 333.0±7.99ns 330.1±9.33ns -0.87%
compile 3.1±0.02s 3.0±0.03s -3.23%
completion 4.5±0.05ms 4.7±0.05ms +4.44%
did_change_with_caching 2.9±0.07s 2.9±0.02s 0.00%
document_symbol 950.9±14.85µs 998.6±46.41µs +5.02%
format 74.2±1.25ms 73.3±1.04ms -1.21%
goto_definition 360.7±2.39µs 368.9±4.61µs +2.27%
highlight 8.8±0.16ms 9.1±0.08ms +3.41%
hover 489.8±6.23µs 496.5±6.32µs +1.37%
idents_at_position 121.3±0.39µs 124.0±1.33µs +2.23%
inlay_hints 657.9±13.53µs 668.8±9.31µs +1.66%
on_enter 480.0±7.76ns 473.7±7.83ns -1.31%
parent_decl_at_position 3.6±0.03ms 3.8±0.03ms +5.56%
prepare_rename 361.1±4.51µs 369.2±7.14µs +2.24%
rename 9.4±0.18ms 9.7±0.11ms +3.19%
semantic_tokens 990.7±9.55µs 986.0±13.50µs -0.47%
token_at_position 355.7±2.38µs 368.0±2.52µs +3.46%
tokens_at_position 3.6±0.03ms 3.7±0.02ms +2.78%
tokens_for_file 420.1±3.05µs 430.5±1.72µs +2.48%
traverse 42.6±2.53ms 41.1±0.59ms -3.52%

Copy link

Benchmark for ba4faf1

Click to view benchmark
Test Base PR %
code_action 5.2±0.12ms 5.4±0.05ms +3.85%
code_lens 334.7±7.89ns 329.3±9.52ns -1.61%
compile 3.1±0.03s 3.1±0.03s 0.00%
completion 4.6±0.14ms 4.7±0.07ms +2.17%
did_change_with_caching 3.0±0.02s 3.0±0.04s 0.00%
document_symbol 989.4±48.69µs 1014.6±40.26µs +2.55%
format 73.9±0.96ms 73.4±1.25ms -0.68%
goto_definition 363.1±5.61µs 365.6±12.51µs +0.69%
highlight 8.7±0.16ms 9.1±0.12ms +4.60%
hover 479.1±9.70µs 491.2±8.49µs +2.53%
idents_at_position 123.1±0.42µs 122.8±0.72µs -0.24%
inlay_hints 648.6±24.51µs 662.8±22.11µs +2.19%
on_enter 475.9±14.34ns 469.4±18.05ns -1.37%
parent_decl_at_position 3.6±0.03ms 3.7±0.04ms +2.78%
prepare_rename 361.5±4.70µs 367.0±6.19µs +1.52%
rename 9.4±0.23ms 9.7±0.19ms +3.19%
semantic_tokens 982.6±26.58µs 966.5±32.62µs -1.64%
token_at_position 357.6±3.02µs 365.5±2.49µs +2.21%
tokens_at_position 3.6±0.03ms 3.7±0.04ms +2.78%
tokens_for_file 432.9±11.90µs 435.9±2.66µs +0.69%
traverse 41.9±0.96ms 41.3±1.46ms -1.43%

Copy link

Benchmark for 18c5b0f

Click to view benchmark
Test Base PR %
code_action 5.2±0.10ms 5.4±0.09ms +3.85%
code_lens 333.5±10.68ns 329.9±10.23ns -1.08%
compile 3.1±0.04s 3.1±0.03s 0.00%
completion 4.6±0.06ms 4.7±0.03ms +2.17%
did_change_with_caching 3.0±0.06s 3.0±0.05s 0.00%
document_symbol 952.1±21.99µs 1027.4±69.48µs +7.91%
format 74.6±1.07ms 74.7±1.06ms +0.13%
goto_definition 370.2±7.16µs 374.5±7.39µs +1.16%
highlight 8.8±0.03ms 9.1±0.16ms +3.41%
hover 488.0±6.62µs 493.1±11.85µs +1.05%
idents_at_position 122.7±0.53µs 124.7±1.77µs +1.63%
inlay_hints 651.5±13.05µs 665.3±20.85µs +2.12%
on_enter 471.2±10.82ns 466.6±7.36ns -0.98%
parent_decl_at_position 3.6±0.03ms 3.8±0.02ms +5.56%
prepare_rename 360.6±2.82µs 367.5±13.11µs +1.91%
rename 9.3±0.03ms 9.7±0.10ms +4.30%
semantic_tokens 963.6±9.80µs 982.3±22.63µs +1.94%
token_at_position 359.2±1.04µs 361.8±2.41µs +0.72%
tokens_at_position 3.6±0.06ms 3.7±0.04ms +2.78%
tokens_for_file 426.9±3.33µs 430.0±2.03µs +0.73%
traverse 42.4±0.80ms 42.3±1.42ms -0.24%

@xunilrj xunilrj requested a review from a team May 31, 2024 13:18
This was referenced Jun 5, 2024
Copy link
Contributor

@IGI-111 IGI-111 left a comment

Choose a reason for hiding this comment

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

A few nits but overall this is cleaner than I would expect.

Can't wait to be able to ditch v0 and simplify this even more.

@IGI-111 IGI-111 requested a review from a team June 10, 2024 07:38
Copy link

Benchmark for e448d1e

Click to view benchmark
Test Base PR %
code_action 5.3±0.10ms 5.4±0.17ms +1.89%
code_lens 285.2±5.08ns 333.6±15.07ns +16.97%
compile 4.0±0.05s 4.1±0.09s +2.50%
completion 4.7±0.13ms 4.7±0.13ms 0.00%
did_change_with_caching 3.6±0.06s 3.7±0.07s +2.78%
document_symbol 1007.4±36.87µs 1015.1±47.25µs +0.76%
format 71.1±1.05ms 73.7±3.95ms +3.66%
goto_definition 366.9±10.61µs 435.3±7.03µs +18.64%
highlight 8.7±0.02ms 8.9±0.34ms +2.30%
hover 543.4±6.83µs 614.1±14.07µs +13.01%
idents_at_position 122.7±0.31µs 123.3±1.64µs +0.49%
inlay_hints 660.7±21.74µs 656.6±15.52µs -0.62%
on_enter 460.4±13.88ns 487.0±24.26ns +5.78%
parent_decl_at_position 3.6±0.03ms 3.6±0.02ms 0.00%
prepare_rename 366.7±4.25µs 437.1±10.19µs +19.20%
rename 9.3±0.02ms 9.4±0.21ms +1.08%
semantic_tokens 974.3±15.11µs 998.7±16.03µs +2.50%
token_at_position 362.0±7.82µs 359.4±3.03µs -0.72%
tokens_at_position 3.6±0.07ms 3.6±0.06ms 0.00%
tokens_for_file 423.3±2.48µs 426.5±4.40µs +0.76%
traverse 40.1±1.71ms 41.1±1.47ms +2.49%

Copy link

Benchmark for 850403c

Click to view benchmark
Test Base PR %
code_action 5.1±0.03ms 5.2±0.17ms +1.96%
code_lens 288.5±9.82ns 327.9±13.41ns +13.66%
compile 3.6±0.08s 3.4±0.11s -5.56%
completion 4.6±0.09ms 4.7±0.02ms +2.17%
did_change_with_caching 3.2±0.08s 3.2±0.05s 0.00%
document_symbol 944.3±17.03µs 1014.5±33.62µs +7.43%
format 72.4±1.31ms 71.7±0.72ms -0.97%
goto_definition 357.6±3.20µs 354.7±4.52µs -0.81%
highlight 8.7±0.17ms 8.7±0.15ms 0.00%
hover 580.2±4.91µs 583.1±4.22µs +0.50%
idents_at_position 120.8±0.44µs 120.3±0.68µs -0.41%
inlay_hints 642.7±10.75µs 643.9±23.70µs +0.19%
on_enter 457.6±10.46ns 487.4±13.11ns +6.51%
parent_decl_at_position 3.6±0.03ms 3.6±0.03ms 0.00%
prepare_rename 364.2±7.44µs 353.4±8.93µs -2.97%
rename 9.0±0.15ms 9.0±0.21ms 0.00%
semantic_tokens 963.4±18.49µs 972.9±31.17µs +0.99%
token_at_position 354.7±2.08µs 345.5±5.81µs -2.59%
tokens_at_position 3.6±0.02ms 3.6±0.03ms 0.00%
tokens_for_file 411.6±3.08µs 418.1±4.04µs +1.58%
traverse 37.9±1.10ms 37.8±1.08ms -0.26%

IGI-111
IGI-111 previously approved these changes Jun 11, 2024
Copy link

Benchmark for 38d2372

Click to view benchmark
Test Base PR %
code_action 5.1±0.18ms 5.2±0.06ms +1.96%
code_lens 339.4±12.82ns 295.5±17.34ns -12.93%
compile 3.6±0.05s 3.6±0.10s 0.00%
completion 4.7±0.12ms 4.8±0.09ms +2.13%
did_change_with_caching 3.3±0.10s 3.3±0.06s 0.00%
document_symbol 949.8±28.04µs 995.5±55.98µs +4.81%
format 90.2±1.80ms 90.3±1.51ms +0.11%
goto_definition 350.3±6.85µs 359.4±11.44µs +2.60%
highlight 8.8±0.23ms 9.0±0.14ms +2.27%
hover 588.1±5.80µs 589.0±6.50µs +0.15%
idents_at_position 120.7±0.47µs 120.2±0.71µs -0.41%
inlay_hints 642.1±28.48µs 662.3±21.17µs +3.15%
on_enter 464.3±5.73ns 463.7±15.03ns -0.13%
parent_decl_at_position 3.6±0.05ms 3.7±0.03ms +2.78%
prepare_rename 345.8±6.63µs 357.6±6.46µs +3.41%
rename 9.1±0.44ms 9.3±0.18ms +2.20%
semantic_tokens 983.5±39.93µs 976.6±22.19µs -0.70%
token_at_position 344.5±6.56µs 346.5±12.49µs +0.58%
tokens_at_position 3.6±0.03ms 3.7±0.03ms +2.78%
tokens_for_file 410.8±2.56µs 426.1±3.61µs +3.72%
traverse 38.2±0.67ms 38.0±0.33ms -0.52%

Copy link

Benchmark for 607dca5

Click to view benchmark
Test Base PR %
code_action 5.1±0.15ms 5.2±0.03ms +1.96%
code_lens 340.9±10.45ns 281.7±10.41ns -17.37%
compile 3.6±0.07s 3.5±0.07s -2.78%
completion 4.7±0.13ms 4.9±0.12ms +4.26%
did_change_with_caching 3.3±0.08s 3.3±0.08s 0.00%
document_symbol 975.2±14.69µs 1011.1±28.12µs +3.68%
format 89.1±1.52ms 88.1±1.42ms -1.12%
goto_definition 348.9±3.73µs 361.1±8.63µs +3.50%
highlight 8.7±0.03ms 9.0±0.07ms +3.45%
hover 577.6±9.59µs 587.4±10.09µs +1.70%
idents_at_position 120.4±1.12µs 122.3±0.77µs +1.58%
inlay_hints 647.8±13.62µs 659.0±13.23µs +1.73%
on_enter 482.1±34.16ns 463.8±7.06ns -3.80%
parent_decl_at_position 3.6±0.07ms 3.7±0.05ms +2.78%
prepare_rename 349.1±4.23µs 360.3±9.82µs +3.21%
rename 8.9±0.18ms 9.4±0.50ms +5.62%
semantic_tokens 970.7±81.85µs 970.6±39.74µs -0.01%
token_at_position 350.2±1.72µs 357.9±3.93µs +2.20%
tokens_at_position 3.6±0.04ms 3.7±0.16ms +2.78%
tokens_for_file 411.7±2.13µs 426.7±6.42µs +3.64%
traverse 37.9±0.79ms 36.7±0.95ms -3.17%

Copy link

Benchmark for f36499a

Click to view benchmark
Test Base PR %
code_action 5.1±0.13ms 5.3±0.33ms +3.92%
code_lens 341.6±12.37ns 291.5±33.01ns -14.67%
compile 3.5±0.06s 3.5±0.09s 0.00%
completion 4.7±0.11ms 5.1±0.40ms +8.51%
did_change_with_caching 3.3±0.10s 3.2±0.07s -3.03%
document_symbol 936.5±28.94µs 1117.3±37.36µs +19.31%
format 90.0±3.43ms 89.2±1.63ms -0.89%
goto_definition 359.0±9.89µs 360.1±6.97µs +0.31%
highlight 8.7±0.14ms 9.2±0.37ms +5.75%
hover 579.3±7.19µs 586.1±9.53µs +1.17%
idents_at_position 120.8±1.03µs 120.4±1.71µs -0.33%
inlay_hints 657.1±26.09µs 662.4±13.33µs +0.81%
on_enter 467.2±15.94ns 456.5±11.22ns -2.29%
parent_decl_at_position 3.6±0.03ms 3.8±0.10ms +5.56%
prepare_rename 360.4±17.05µs 359.4±7.89µs -0.28%
rename 8.9±0.03ms 9.2±0.04ms +3.37%
semantic_tokens 971.9±23.13µs 984.1±30.68µs +1.26%
token_at_position 353.3±2.17µs 354.5±3.97µs +0.34%
tokens_at_position 3.6±0.07ms 3.7±0.06ms +2.78%
tokens_for_file 416.2±9.60µs 425.2±4.47µs +2.16%
traverse 37.5±0.52ms 36.2±0.64ms -3.47%

IGI-111
IGI-111 previously approved these changes Jun 13, 2024
@IGI-111 IGI-111 requested a review from a team June 13, 2024 09:38
Copy link

Benchmark for 26a83ab

Click to view benchmark
Test Base PR %
code_action 5.2±0.13ms 5.2±0.14ms 0.00%
code_lens 342.2±12.22ns 298.5±9.04ns -12.77%
compile 3.4±0.06s 3.5±0.08s +2.94%
completion 5.0±0.18ms 4.7±0.10ms -6.00%
did_change_with_caching 3.3±0.07s 3.2±0.07s -3.03%
document_symbol 983.3±11.98µs 951.3±28.18µs -3.25%
format 88.6±0.73ms 88.8±1.06ms +0.23%
goto_definition 356.6±7.33µs 358.9±5.82µs +0.64%
highlight 9.0±0.16ms 8.7±0.01ms -3.33%
hover 582.9±4.47µs 581.3±14.70µs -0.27%
idents_at_position 119.8±0.40µs 122.0±2.36µs +1.84%
inlay_hints 659.3±19.38µs 652.0±25.24µs -1.11%
on_enter 457.5±14.59ns 486.3±32.41ns +6.30%
parent_decl_at_position 3.7±0.07ms 3.6±0.02ms -2.70%
prepare_rename 356.1±10.11µs 359.5±7.87µs +0.95%
rename 9.2±0.14ms 9.1±0.29ms -1.09%
semantic_tokens 953.5±15.94µs 981.1±15.88µs +2.89%
token_at_position 358.2±3.43µs 354.9±2.57µs -0.92%
tokens_at_position 3.7±0.09ms 3.6±0.04ms -2.70%
tokens_for_file 418.4±10.27µs 418.7±12.99µs +0.07%
traverse 36.9±0.66ms 36.4±0.50ms -1.36%

Copy link

Benchmark for 62d7acd

Click to view benchmark
Test Base PR %
code_action 5.2±0.11ms 5.1±0.21ms -1.92%
code_lens 288.0±5.76ns 334.2±12.03ns +16.04%
compile 3.4±0.07s 3.4±0.06s 0.00%
completion 4.8±0.10ms 4.7±0.07ms -2.08%
did_change_with_caching 3.3±0.09s 3.2±0.05s -3.03%
document_symbol 946.2±7.28µs 1020.7±18.24µs +7.87%
format 90.4±1.28ms 88.8±1.32ms -1.77%
goto_definition 359.9±5.28µs 353.3±8.67µs -1.83%
highlight 9.0±0.17ms 8.6±0.08ms -4.44%
hover 574.6±12.12µs 575.5±8.24µs +0.16%
idents_at_position 119.9±0.37µs 121.0±1.31µs +0.92%
inlay_hints 641.5±4.42µs 644.1±40.61µs +0.41%
on_enter 511.4±7.17ns 487.7±15.37ns -4.63%
parent_decl_at_position 3.7±0.04ms 3.6±0.03ms -2.70%
prepare_rename 352.1±7.21µs 350.1±11.61µs -0.57%
rename 9.3±0.17ms 9.0±0.31ms -3.23%
semantic_tokens 965.8±26.24µs 983.9±23.19µs +1.87%
token_at_position 347.3±3.96µs 345.2±4.24µs -0.60%
tokens_at_position 3.7±0.03ms 3.6±0.03ms -2.70%
tokens_for_file 406.2±2.00µs 405.8±2.75µs -0.10%
traverse 36.8±0.47ms 36.8±0.68ms 0.00%

@IGI-111 IGI-111 requested a review from a team June 17, 2024 14:51
Copy link

Benchmark for 860edff

Click to view benchmark
Test Base PR %
code_action 5.2±0.06ms 5.0±0.13ms -3.85%
code_lens 306.8±8.25ns 312.3±6.94ns +1.79%
compile 3.4±0.07s 3.4±0.07s 0.00%
completion 4.7±0.08ms 5.1±0.16ms +8.51%
did_change_with_caching 3.2±0.08s 3.1±0.07s -3.13%
document_symbol 837.7±12.92µs 878.6±33.11µs +4.88%
format 70.7±0.87ms 70.8±1.04ms +0.14%
goto_definition 337.9±3.32µs 348.5±16.96µs +3.14%
highlight 8.9±0.02ms 8.8±0.09ms -1.12%
hover 563.6±6.64µs 654.0±10.05µs +16.04%
idents_at_position 117.1±0.60µs 121.1±0.90µs +3.42%
inlay_hints 642.4±15.90µs 626.3±20.11µs -2.51%
on_enter 515.2±4.28ns 460.2±6.56ns -10.68%
parent_decl_at_position 3.7±0.04ms 3.5±0.04ms -5.41%
prepare_rename 338.4±6.25µs 345.4±6.91µs +2.07%
rename 9.3±0.17ms 8.9±0.11ms -4.30%
semantic_tokens 1222.3±10.72µs 1242.8±11.59µs +1.68%
token_at_position 330.3±3.29µs 333.3±2.35µs +0.91%
tokens_at_position 3.7±0.04ms 3.5±0.03ms -5.41%
tokens_for_file 398.7±3.26µs 401.7±3.01µs +0.75%
traverse 36.6±0.98ms 36.6±0.19ms 0.00%

@IGI-111 IGI-111 merged commit 7f8f318 into master Jun 19, 2024
38 checks passed
@IGI-111 IGI-111 deleted the xunilrj/str-slice-in-main branch June 19, 2024 08:10
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.

Misleading raw_slice error message
3 participants