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

Updates JSON ABI, LDC, BSIZ, BLDD and ED19. #6254

Merged
merged 50 commits into from
Aug 15, 2024
Merged

Conversation

esdrubal
Copy link
Contributor

@esdrubal esdrubal commented Jul 10, 2024

Description

Updates all the dependencies for the current release.

Implements the fuel ABI generation changes proposed in FuelLabs/fuel-specs#599.

Removes the flag --json-abi-with-callpaths and the behavior is as if it were true. We removed the flag because it is unsafe to produce JSON ABIs without callpaths, so we shouldn't allow it.

Includes the LDC, BSIZ, BLDD and ED19 changes from:#6409.

Fixes #5954
Fixes #5151

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 b2276f0

Click to view benchmark
Test Base PR %
code_action 5.3±0.09ms 5.1±0.09ms -3.77%
code_lens 287.8±5.72ns 280.3±4.84ns -2.61%
compile 2.7±0.04s 2.6±0.03s -3.70%
completion 4.7±0.05ms 4.5±0.08ms -4.26%
did_change_with_caching 2.6±0.03s 2.6±0.03s 0.00%
document_symbol 865.4±11.66µs 908.1±39.59µs +4.93%
format 72.9±1.07ms 71.0±1.26ms -2.61%
goto_definition 341.7±5.88µs 336.7±6.34µs -1.46%
highlight 9.0±0.11ms 8.7±0.16ms -3.33%
hover 500.0±5.92µs 487.9±5.30µs -2.42%
idents_at_position 118.7±0.38µs 120.4±1.19µs +1.43%
inlay_hints 640.4±11.88µs 626.7±16.80µs -2.14%
on_enter 465.1±19.92ns 459.1±12.14ns -1.29%
parent_decl_at_position 3.7±0.03ms 3.6±0.06ms -2.70%
prepare_rename 337.2±6.34µs 334.7±5.29µs -0.74%
rename 9.3±0.14ms 9.0±0.11ms -3.23%
semantic_tokens 1170.7±15.69µs 1226.7±12.16µs +4.78%
token_at_position 335.9±2.68µs 336.0±3.52µs +0.03%
tokens_at_position 3.7±0.03ms 3.6±0.03ms -2.70%
tokens_for_file 405.7±12.59µs 402.2±2.91µs -0.86%
traverse 37.9±0.87ms 38.0±0.78ms +0.26%

@esdrubal esdrubal force-pushed the esdrubal/abi_changes branch 2 times, most recently from 37d49ad to c3104e4 Compare July 12, 2024 09:42
Copy link

Benchmark for b05ffbd

Click to view benchmark
Test Base PR %
code_action 5.2±0.06ms 5.4±0.11ms +3.85%
code_lens 288.0±7.42ns 288.9±7.79ns +0.31%
compile 2.7±0.04s 2.7±0.04s 0.00%
completion 4.7±0.09ms 4.7±0.08ms 0.00%
did_change_with_caching 2.6±0.02s 2.6±0.03s 0.00%
document_symbol 840.9±16.87µs 850.4±18.04µs +1.13%
format 72.8±0.64ms 73.3±1.49ms +0.69%
goto_definition 336.5±4.43µs 340.9±3.98µs +1.31%
highlight 9.0±0.12ms 9.1±0.11ms +1.11%
hover 489.0±6.28µs 494.7±24.45µs +1.17%
idents_at_position 118.2±0.46µs 119.0±0.88µs +0.68%
inlay_hints 633.4±20.89µs 643.1±24.93µs +1.53%
on_enter 467.4±47.72ns 464.5±15.63ns -0.62%
parent_decl_at_position 3.7±0.03ms 3.7±0.04ms 0.00%
prepare_rename 333.8±7.38µs 339.7±6.10µs +1.77%
rename 9.4±0.10ms 9.5±0.13ms +1.06%
semantic_tokens 1199.9±18.66µs 1287.1±14.08µs +7.27%
token_at_position 330.8±2.02µs 332.7±2.98µs +0.57%
tokens_at_position 3.7±0.03ms 3.7±0.03ms 0.00%
tokens_for_file 397.8±3.82µs 405.5±3.06µs +1.94%
traverse 37.5±0.85ms 37.8±0.60ms +0.80%

Copy link

Benchmark for 20dd3a4

Click to view benchmark
Test Base PR %
code_action 5.3±0.15ms 5.2±0.26ms -1.89%
code_lens 285.4±7.66ns 289.5±8.33ns +1.44%
compile 2.7±0.04s 2.8±0.03s +3.70%
completion 4.8±0.18ms 4.8±0.43ms 0.00%
did_change_with_caching 2.7±0.03s 2.8±0.03s +3.70%
document_symbol 919.3±50.43µs 854.3±19.20µs -7.07%
format 71.5±0.88ms 71.6±0.77ms +0.14%
goto_definition 346.5±5.98µs 338.7±6.66µs -2.25%
highlight 9.2±0.26ms 8.8±0.24ms -4.35%
hover 502.9±8.09µs 496.7±12.27µs -1.23%
idents_at_position 121.8±0.59µs 120.8±0.79µs -0.82%
inlay_hints 649.1±20.99µs 628.5±24.65µs -3.17%
on_enter 461.5±8.12ns 493.1±13.85ns +6.85%
parent_decl_at_position 3.7±0.05ms 3.6±0.05ms -2.70%
prepare_rename 347.1±7.06µs 340.0±7.90µs -2.05%
rename 9.4±0.19ms 9.1±0.16ms -3.19%
semantic_tokens 1256.9±26.30µs 1267.0±16.86µs +0.80%
token_at_position 346.6±4.02µs 339.2±5.70µs -2.14%
tokens_at_position 3.7±0.03ms 3.6±0.05ms -2.70%
tokens_for_file 408.5±4.38µs 399.3±5.40µs -2.25%
traverse 38.5±0.72ms 38.6±0.82ms +0.26%

Copy link

Benchmark for 0d5b7ff

Click to view benchmark
Test Base PR %
code_action 5.2±0.05ms 5.0±0.15ms -3.85%
code_lens 283.1±10.04ns 287.8±5.78ns +1.66%
compile 2.6±0.04s 2.7±0.03s +3.85%
completion 4.7±0.08ms 4.7±0.15ms 0.00%
did_change_with_caching 2.5±0.02s 2.6±0.03s +4.00%
document_symbol 920.9±26.77µs 929.3±18.40µs +0.91%
format 72.2±1.12ms 69.1±1.51ms -4.29%
goto_definition 337.4±5.54µs 339.5±11.41µs +0.62%
highlight 9.0±0.03ms 8.6±0.04ms -4.44%
hover 487.9±15.00µs 488.9±5.78µs +0.20%
idents_at_position 121.2±0.43µs 119.0±0.74µs -1.82%
inlay_hints 637.5±17.95µs 623.6±26.40µs -2.18%
on_enter 485.8±15.36ns 468.2±12.74ns -3.62%
parent_decl_at_position 3.7±0.03ms 3.6±0.06ms -2.70%
prepare_rename 333.7±5.49µs 335.9±6.31µs +0.66%
rename 9.5±1.58ms 8.9±0.24ms -6.32%
semantic_tokens 1208.3±98.13µs 1270.3±14.95µs +5.13%
token_at_position 330.4±2.32µs 337.7±2.80µs +2.21%
tokens_at_position 3.7±0.05ms 3.6±0.04ms -2.70%
tokens_for_file 399.4±4.67µs 407.3±4.11µs +1.98%
traverse 36.7±0.91ms 37.2±1.03ms +1.36%

Copy link

Benchmark for e6358f9

Click to view benchmark
Test Base PR %
code_action 5.2±0.06ms 5.1±0.12ms -1.92%
code_lens 283.2±13.47ns 289.6±8.24ns +2.26%
compile 2.7±0.04s 2.7±0.04s 0.00%
completion 4.7±0.09ms 4.6±0.06ms -2.13%
did_change_with_caching 2.7±0.06s 2.7±0.03s 0.00%
document_symbol 852.2±43.64µs 851.0±16.72µs -0.14%
format 71.9±1.02ms 69.6±0.71ms -3.20%
goto_definition 335.6±3.72µs 340.4±8.33µs +1.43%
highlight 9.0±0.09ms 8.7±0.04ms -3.33%
hover 491.2±8.33µs 495.5±8.73µs +0.88%
idents_at_position 122.1±0.37µs 121.8±0.44µs -0.25%
inlay_hints 639.7±31.50µs 637.4±26.33µs -0.36%
on_enter 485.9±12.88ns 470.3±14.28ns -3.21%
parent_decl_at_position 3.7±0.03ms 3.6±0.04ms -2.70%
prepare_rename 336.7±6.98µs 342.5±15.74µs +1.72%
rename 9.3±0.14ms 9.1±0.60ms -2.15%
semantic_tokens 1218.0±38.28µs 1222.2±13.54µs +0.34%
token_at_position 331.1±2.95µs 334.1±7.84µs +0.91%
tokens_at_position 3.7±0.03ms 3.6±0.02ms -2.70%
tokens_for_file 396.4±2.27µs 398.7±1.46µs +0.58%
traverse 37.3±0.87ms 37.9±0.54ms +1.61%

@esdrubal esdrubal force-pushed the esdrubal/abi_changes branch from 3ebe4fd to 05c8052 Compare July 15, 2024 11:21
@esdrubal esdrubal self-assigned this Jul 18, 2024
@esdrubal esdrubal force-pushed the esdrubal/abi_changes branch from 98109fa to efc57dc Compare July 19, 2024 12:47
Copy link

Benchmark for fc4da40

Click to view benchmark
Test Base PR %
code_action 5.0±0.03ms 5.2±0.21ms +4.00%
code_lens 292.1±13.60ns 301.6±16.04ns +3.25%
compile 2.6±0.03s 2.7±0.04s +3.85%
completion 4.5±0.11ms 4.7±0.07ms +4.44%
did_change_with_caching 2.6±0.03s 2.6±0.03s 0.00%
document_symbol 885.8±52.76µs 906.2±25.38µs +2.30%
format 67.6±0.84ms 84.9±1.36ms +25.59%
goto_definition 337.4±2.85µs 339.7±6.75µs +0.68%
highlight 8.6±0.12ms 9.0±0.12ms +4.65%
hover 505.9±52.61µs 497.5±5.66µs -1.66%
idents_at_position 121.8±0.20µs 119.9±1.48µs -1.56%
inlay_hints 623.7±15.33µs 643.7±21.67µs +3.21%
on_enter 457.3±23.60ns 491.2±11.18ns +7.41%
parent_decl_at_position 3.6±0.04ms 3.8±0.06ms +5.56%
prepare_rename 362.1±7.92µs 340.0±6.76µs -6.10%
rename 8.9±0.12ms 9.3±0.19ms +4.49%
semantic_tokens 1242.8±14.73µs 1212.7±46.58µs -2.42%
token_at_position 332.8±17.77µs 338.4±3.00µs +1.68%
tokens_at_position 3.5±0.04ms 3.8±0.06ms +8.57%
tokens_for_file 399.8±5.02µs 533.7±2.93µs +33.49%
traverse 38.0±1.16ms 36.5±0.87ms -3.95%

Copy link

Benchmark for 4b43436

Click to view benchmark
Test Base PR %
code_action 5.0±0.05ms 5.2±0.04ms +4.00%
code_lens 286.5±4.40ns 302.3±11.92ns +5.51%
compile 2.6±0.05s 2.6±0.03s 0.00%
completion 4.5±0.01ms 4.7±0.07ms +4.44%
did_change_with_caching 2.6±0.03s 2.6±0.02s 0.00%
document_symbol 882.9±31.76µs 903.4±29.21µs +2.32%
format 68.6±1.07ms 84.9±0.86ms +23.76%
goto_definition 334.0±9.89µs 343.6±7.11µs +2.87%
highlight 8.6±0.15ms 9.1±0.01ms +5.81%
hover 494.9±5.76µs 497.0±6.38µs +0.42%
idents_at_position 121.8±0.43µs 122.1±0.79µs +0.25%
inlay_hints 626.9±24.95µs 643.5±22.54µs +2.65%
on_enter 453.1±15.07ns 479.9±13.99ns +5.91%
parent_decl_at_position 3.6±0.03ms 3.7±0.02ms +2.78%
prepare_rename 334.3±7.48µs 344.2±15.16µs +2.96%
rename 8.9±0.15ms 9.3±0.08ms +4.49%
semantic_tokens 1262.7±8.17µs 1277.3±8.25µs +1.16%
token_at_position 339.8±3.56µs 339.8±4.08µs 0.00%
tokens_at_position 3.5±0.03ms 3.7±0.02ms +5.71%
tokens_for_file 407.4±2.37µs 400.8±2.31µs -1.62%
traverse 37.3±0.53ms 36.9±0.73ms -1.07%

@esdrubal esdrubal force-pushed the esdrubal/abi_changes branch from d1be15d to 637d43a Compare July 22, 2024 15:03
Copy link

Benchmark for 9770299

Click to view benchmark
Test Base PR %
code_action 5.2±0.23ms 5.4±0.48ms +3.85%
code_lens 338.7±15.09ns 287.4±7.73ns -15.15%
compile 2.8±0.06s 2.8±0.06s 0.00%
completion 4.6±0.18ms 4.7±0.29ms +2.17%
did_change_with_caching 2.7±0.04s 2.7±0.07s 0.00%
document_symbol 915.7±39.24µs 863.7±22.61µs -5.68%
format 71.2±3.35ms 82.7±0.98ms +16.15%
goto_definition 336.9±3.72µs 342.0±7.29µs +1.51%
highlight 8.7±0.23ms 9.0±0.43ms +3.45%
hover 492.8±10.86µs 500.9±6.94µs +1.64%
idents_at_position 120.9±0.40µs 119.9±3.56µs -0.83%
inlay_hints 635.1±29.45µs 638.0±27.64µs +0.46%
on_enter 458.6±16.18ns 461.2±25.26ns +0.57%
parent_decl_at_position 3.6±0.13ms 3.6±0.08ms 0.00%
prepare_rename 337.7±7.20µs 340.1±6.30µs +0.71%
rename 9.1±0.28ms 9.1±0.19ms 0.00%
semantic_tokens 1249.3±112.42µs 1289.9±28.83µs +3.25%
token_at_position 333.1±4.11µs 340.5±4.93µs +2.22%
tokens_at_position 3.6±0.17ms 3.6±0.10ms 0.00%
tokens_for_file 400.1±4.69µs 408.0±4.09µs +1.97%
traverse 39.4±1.03ms 39.2±0.62ms -0.51%

@esdrubal esdrubal force-pushed the esdrubal/abi_changes branch from c4f2477 to 8924455 Compare July 23, 2024 08:21
@esdrubal esdrubal added the ABI Everything to do the ABI, especially the JSON representation label Jul 23, 2024
@esdrubal esdrubal force-pushed the esdrubal/abi_changes branch 2 times, most recently from f44e59d to be22465 Compare July 23, 2024 08:54
Copy link

Benchmark for 24146f0

Click to view benchmark
Test Base PR %
code_action 5.0±0.08ms 5.1±0.05ms +2.00%
code_lens 337.7±9.36ns 285.2±9.17ns -15.55%
compile 2.6±0.04s 2.6±0.04s 0.00%
completion 4.5±0.08ms 4.5±0.04ms 0.00%
did_change_with_caching 2.6±0.03s 2.6±0.02s 0.00%
document_symbol 915.1±56.52µs 953.2±50.71µs +4.16%
format 69.9±0.64ms 71.8±0.89ms +2.72%
goto_definition 345.0±6.64µs 369.6±4.09µs +7.13%
highlight 8.7±0.11ms 8.7±0.02ms 0.00%
hover 498.8±11.60µs 583.7±6.95µs +17.02%
idents_at_position 120.5±0.97µs 118.4±0.36µs -1.74%
inlay_hints 630.7±25.30µs 639.0±8.62µs +1.32%
on_enter 460.6±17.95ns 462.7±14.19ns +0.46%
parent_decl_at_position 3.6±0.04ms 3.5±0.02ms -2.78%
prepare_rename 346.3±5.29µs 392.2±10.82µs +13.25%
rename 8.9±0.16ms 8.9±0.06ms 0.00%
semantic_tokens 1202.3±11.77µs 1341.1±12.93µs +11.54%
token_at_position 346.1±5.17µs 341.1±4.21µs -1.44%
tokens_at_position 3.6±0.02ms 3.5±0.04ms -2.78%
tokens_for_file 407.8±5.12µs 411.1±3.32µs +0.81%
traverse 38.8±1.27ms 38.1±1.37ms -1.80%

@esdrubal esdrubal force-pushed the esdrubal/abi_changes branch 2 times, most recently from 3767f17 to 8971ad1 Compare July 23, 2024 10:04
Copy link

Benchmark for 60a1506

Click to view benchmark
Test Base PR %
code_action 5.1±0.13ms 5.2±0.16ms +1.96%
code_lens 337.3±9.45ns 288.6±17.99ns -14.44%
compile 2.7±0.05s 2.8±0.04s +3.70%
completion 4.7±0.19ms 4.7±0.22ms 0.00%
did_change_with_caching 2.7±0.05s 2.7±0.02s 0.00%
document_symbol 858.8±14.85µs 892.1±38.33µs +3.88%
format 69.0±0.59ms 75.7±1.12ms +9.71%
goto_definition 342.0±8.70µs 353.3±12.09µs +3.30%
highlight 8.7±0.16ms 8.7±0.15ms 0.00%
hover 494.4±7.03µs 509.1±11.90µs +2.97%
idents_at_position 119.6±0.48µs 118.3±0.46µs -1.09%
inlay_hints 642.5±23.70µs 639.0±24.54µs -0.54%
on_enter 460.2±13.09ns 483.4±15.23ns +5.04%
parent_decl_at_position 3.6±0.05ms 3.6±0.08ms 0.00%
prepare_rename 340.2±11.58µs 354.3±10.52µs +4.14%
rename 9.1±0.20ms 9.2±0.23ms +1.10%
semantic_tokens 1222.0±17.60µs 1315.5±19.48µs +7.65%
token_at_position 343.0±3.23µs 341.3±3.77µs -0.50%
tokens_at_position 3.6±0.04ms 3.6±0.08ms 0.00%
tokens_for_file 404.1±3.07µs 408.5±3.11µs +1.09%
traverse 38.6±0.70ms 39.0±1.42ms +1.04%

Copy link

Benchmark for b9b2266

Click to view benchmark
Test Base PR %
code_action 5.1±0.12ms 5.0±0.01ms -1.96%
code_lens 338.8±8.93ns 287.2±20.29ns -15.23%
compile 2.7±0.04s 2.7±0.06s 0.00%
completion 4.5±0.02ms 4.5±0.08ms 0.00%
did_change_with_caching 2.6±0.03s 2.6±0.03s 0.00%
document_symbol 853.3±18.41µs 855.0±36.27µs +0.20%
format 69.2±0.80ms 71.7±0.82ms +3.61%
goto_definition 342.5±9.96µs 339.7±3.58µs -0.82%
highlight 8.6±0.06ms 8.7±0.15ms +1.16%
hover 498.8±7.60µs 497.1±5.55µs -0.34%
idents_at_position 119.2±0.47µs 118.6±0.36µs -0.50%
inlay_hints 625.3±12.46µs 632.8±26.40µs +1.20%
on_enter 457.6±13.25ns 471.5±49.15ns +3.04%
parent_decl_at_position 3.6±0.06ms 3.6±0.05ms 0.00%
prepare_rename 342.1±5.91µs 337.9±5.65µs -1.23%
rename 8.9±0.03ms 9.0±0.13ms +1.12%
semantic_tokens 1245.0±14.91µs 1292.8±12.29µs +3.84%
token_at_position 340.2±2.83µs 346.2±2.98µs +1.76%
tokens_at_position 3.5±0.03ms 3.5±0.03ms 0.00%
tokens_for_file 400.6±1.50µs 403.4±3.03µs +0.70%
traverse 38.2±0.63ms 37.8±0.85ms -1.05%

@esdrubal esdrubal force-pushed the esdrubal/abi_changes branch from 53f117e to 2cfcc7e Compare July 23, 2024 11:14
Copy link

Benchmark for f439a33

Click to view benchmark
Test Base PR %
code_action 5.1±0.06ms 5.1±0.10ms 0.00%
code_lens 339.0±9.68ns 284.5±11.37ns -16.08%
compile 2.7±0.03s 2.7±0.06s 0.00%
completion 4.7±0.12ms 4.6±0.06ms -2.13%
did_change_with_caching 2.6±0.02s 2.6±0.03s 0.00%
document_symbol 843.5±12.35µs 872.8±19.14µs +3.47%
format 70.0±0.91ms 72.4±0.74ms +3.43%
goto_definition 337.7±10.17µs 347.7±9.66µs +2.96%
highlight 8.7±0.12ms 8.7±0.15ms 0.00%
hover 497.5±5.77µs 507.1±18.17µs +1.93%
idents_at_position 121.5±0.43µs 118.0±0.46µs -2.88%
inlay_hints 621.8±34.96µs 633.3±29.05µs +1.85%
on_enter 465.1±15.73ns 464.3±16.59ns -0.17%
parent_decl_at_position 3.6±0.04ms 3.6±0.04ms 0.00%
prepare_rename 338.5±7.77µs 345.5±7.09µs +2.07%
rename 9.1±0.13ms 9.2±0.24ms +1.10%
semantic_tokens 1309.2±8.82µs 1259.1±16.51µs -3.83%
token_at_position 340.4±1.85µs 334.0±1.98µs -1.88%
tokens_at_position 3.6±0.03ms 3.6±0.03ms 0.00%
tokens_for_file 405.1±5.62µs 403.0±2.39µs -0.52%
traverse 38.0±0.77ms 37.7±0.98ms -0.79%

Copy link

Benchmark for 8b8c60b

Click to view benchmark
Test Base PR %
code_action 5.8±0.19ms 5.0±0.11ms -13.79%
code_lens 359.3±12.59ns 288.5±16.93ns -19.70%
compile 2.9±0.06s 2.7±0.04s -6.90%
completion 4.5±0.08ms 4.5±0.10ms 0.00%
did_change_with_caching 2.7±0.06s 2.6±0.07s -3.70%
document_symbol 895.3±34.52µs 878.8±44.83µs -1.84%
format 72.5±2.48ms 73.2±1.81ms +0.97%
goto_definition 340.5±16.47µs 337.9±5.80µs -0.76%
highlight 8.7±0.15ms 8.6±0.12ms -1.15%
hover 486.6±6.72µs 502.7±6.44µs +3.31%
idents_at_position 120.3±0.34µs 120.4±0.90µs +0.08%
inlay_hints 625.0±7.72µs 627.9±9.05µs +0.46%
on_enter 459.2±17.29ns 472.6±13.19ns +2.92%
parent_decl_at_position 3.6±0.04ms 3.6±0.20ms 0.00%
prepare_rename 335.1±3.27µs 338.0±6.90µs +0.87%
rename 9.6±1.23ms 8.9±0.17ms -7.29%
semantic_tokens 1162.9±14.65µs 1240.4±13.64µs +6.66%
token_at_position 336.1±2.12µs 336.3±8.75µs +0.06%
tokens_at_position 3.6±0.02ms 3.5±0.04ms -2.78%
tokens_for_file 399.3±2.50µs 398.0±6.55µs -0.33%
traverse 40.9±0.80ms 38.7±1.72ms -5.38%

@esdrubal esdrubal added the breaking May cause existing user code to break. Requires a minor or major release. label Jul 24, 2024
@esdrubal esdrubal marked this pull request as ready for review July 24, 2024 14:49
@esdrubal esdrubal requested a review from a team as a code owner July 24, 2024 14:49
Copy link

Benchmark for 263a088

Click to view benchmark
Test Base PR %
code_action 5.0±0.07ms 5.1±0.06ms +2.00%
code_lens 284.6±4.15ns 341.3±10.75ns +19.92%
compile 2.6±0.06s 2.7±0.05s +3.85%
completion 4.6±0.06ms 4.6±0.06ms 0.00%
did_change_with_caching 2.6±0.03s 2.6±0.03s 0.00%
document_symbol 928.9±20.22µs 904.4±37.66µs -2.64%
format 72.5±0.91ms 68.6±0.58ms -5.38%
goto_definition 346.6±11.20µs 337.1±8.17µs -2.74%
highlight 8.7±0.02ms 8.6±0.12ms -1.15%
hover 502.2±7.32µs 490.8±11.69µs -2.27%
idents_at_position 117.6±0.39µs 121.0±1.14µs +2.89%
inlay_hints 633.0±23.58µs 632.6±20.57µs -0.06%
on_enter 2.0±0.09µs 2.0±0.05µs 0.00%
parent_decl_at_position 3.6±0.04ms 3.6±0.15ms 0.00%
prepare_rename 344.1±3.60µs 342.1±9.26µs -0.58%
rename 9.0±0.11ms 8.9±0.09ms -1.11%
semantic_tokens 1221.9±12.66µs 1244.0±7.77µs +1.81%
token_at_position 336.3±2.86µs 334.5±2.82µs -0.54%
tokens_at_position 3.6±0.02ms 3.5±0.03ms -2.78%
tokens_for_file 397.6±2.40µs 401.6±4.71µs +1.01%
traverse 37.7±0.71ms 38.3±0.83ms +1.59%

@kayagokalp
Copy link
Member

kayagokalp commented Aug 14, 2024

I think we have an issue.

TL DR

The following two implementations before and after #[namespace] is removed, does not yield same storage slot keys. If this is something expected no problems otherwise might be important to look at.

#[namepsace(SRC14)]
storage {
    /// The [ContractId] of the target contract.
    ///
    /// # Additional Information
    ///
    /// `target` is stored at sha256("storage_SRC14_0")
    target: Option<ContractId> = None,
    /// The [State] of the proxy owner.
    ///
    /// # Additional Information
    ///
    // `proxy_owner` is stored at sha256("storage_SRC14_1")
    proxy_owner: State = State::Uninitialized,
}
storage {
    SRC14 {
    /// The [ContractId] of the target contract.
    ///
    /// # Additional Information
    ///
    /// `target` is stored at sha256("storage_SRC14_0")
    target: Option<ContractId> = None,
    /// The [State] of the proxy owner.
    ///
    /// # Additional Information
    ///
    // `proxy_owner` is stored at sha256("storage_SRC14_1")
    proxy_owner: State = State::Uninitialized,
    }
}

We need to have the proxy contract implementation's abi, storage slots, etc built and embedded in the code for tooling purposes. This used to work until now. Problem is:

  1. Due to breaking changes, we need to rebuild the proxy contract (audited one from sway-standard-implementations) but the namespace syntax is removed with the current version.
  2. I don't think it is related to the syntax but something changed about how storage key slots are assigned, the storage slot embedded into the sway-libs project is wrong (we used to get 0x7bb458adc1d118713319a5baa00a2d049dd64d2916477d2688d76970c898cd55 but now we are getting something else in the generated file) while audited proxy contract tries to use a constant from sway-standards that is no longer valid. And built/released contract is using that key to interact with TARGET field of the storage.

Detailed Summary of the problem

  1. Before breaking changes, we had a bin file that was working nicely. Now due to the breaking changes (probably around encoding) we need to rebuilt contract to get the new bin, otherwise we are getting out of bounds panic from sdk while trying to assign configurables. This is expected as change in offsets create a problem while inserting the configurable value into the bytecode.
  2. Once we got the new bin, we are facing with a new issue which is removal of #[namepsace(SRC14)]. This can be fixed by converting the storage declaration from
#[namepsace(SRC14)]
storage {
    /// The [ContractId] of the target contract.
    ///
    /// # Additional Information
    ///
    /// `target` is stored at sha256("storage_SRC14_0")
    target: Option<ContractId> = None,
    /// The [State] of the proxy owner.
    ///
    /// # Additional Information
    ///
    // `proxy_owner` is stored at sha256("storage_SRC14_1")
    proxy_owner: State = State::Uninitialized,
}

to

storage {
    SRC14 {
    /// The [ContractId] of the target contract.
    ///
    /// # Additional Information
    ///
    /// `target` is stored at sha256("storage_SRC14_0")
    target: Option<ContractId> = None,
    /// The [State] of the proxy owner.
    ///
    /// # Additional Information
    ///
    // `proxy_owner` is stored at sha256("storage_SRC14_1")
    proxy_owner: State = State::Uninitialized,
    }
}
  1. Once we do that we come to the last issue, target's storage field is now different instead of the original value (0x7bb458adc1d118713319a5baa00a2d049dd64d2916477d2688d76970c898cd55) and since audited proxy contract takes an harcoded storage key from sway-libs this is not correct and execution fails.

Solution

I also found the solution, basically changing the storage declaration to the following fixes everything:

storage {
    /// The [ContractId] of the target contract.
    ///
    /// # Additional Information
    ///
    /// `target` is stored at sha256("storage_SRC14_0")
    target in 0x7bb458adc1d118713319a5baa00a2d049dd64d2916477d2688d76970c898cd55: Option<ContractId> = None,
    /// The [State] of the proxy owner.
    ///
    /// # Additional Information
    ///
    // `proxy_owner` is stored at sha256("storage_SRC14_1")
    proxy_owner: State = State::Uninitialized,
}

Though with this change I am touching the audited contract, is this ok?

#6416 is a dummy PR I opened to show that pinning the storage slot as i described above fixes the issue.

cc @IGI-111 @esdrubal @Voxelot

@esdrubal
Copy link
Contributor Author

esdrubal commented Aug 14, 2024

@kayagokalp Very nice find.

If I understand it correctly these two should be equal:
https://github.com/FuelLabs/sway-standard-implementations/blob/6c4135593839545a052c6505e9c0adf425069b98/src14/owned_proxy/contract/src/main.sw#L26-L40

https://github.com/FuelLabs/sway-libs/blob/50be622109e3c584efc29edac5390c96f1ccc43a/tests/src/upgradability/src/main.sw#L17-L22

And updated to:

storage {
    SRC14 {
      /// The [ContractId] of the target contract.
      ///
      /// # Additional Information
      ///
      /// `target` is stored at sha256("storage_SRC14_0")
      target in 0x7bb458adc1d118713319a5baa00a2d049dd64d2916477d2688d76970c898cd55: Option<ContractId> = None,
      /// The [State] of the proxy owner.
      ///
      /// # Additional Information
      ///
      // `proxy_owner` is stored at sha256("storage_SRC14_1")
      proxy_owner in 0xbb79927b15d9259ea316f2ecb2297d6cc8851888a98278c0a2e03e1a091ea754: State = State::Uninitialized,
    }
}

With the in keyword so the storage fields are backward compatible.

What you propose sounds like a perfect solution.

Copy link

Benchmark for 0a829eb

Click to view benchmark
Test Base PR %
code_action 5.1±0.22ms 5.2±0.04ms +1.96%
code_lens 283.8±8.60ns 340.7±8.49ns +20.05%
compile 2.7±0.04s 2.7±0.05s 0.00%
completion 4.5±0.08ms 4.6±0.07ms +2.22%
did_change_with_caching 2.7±0.04s 2.6±0.04s -3.70%
document_symbol 913.2±42.67µs 907.3±38.99µs -0.65%
format 84.0±0.82ms 68.2±0.80ms -18.81%
goto_definition 335.0±8.61µs 339.6±4.93µs +1.37%
highlight 8.8±0.79ms 8.9±0.05ms +1.14%
hover 492.8±5.93µs 488.9±7.85µs -0.79%
idents_at_position 120.9±0.47µs 119.5±0.84µs -1.16%
inlay_hints 628.8±11.83µs 651.1±60.38µs +3.55%
on_enter 2.0±0.04µs 1997.5±83.75ns -0.12%
parent_decl_at_position 3.5±0.05ms 3.7±0.03ms +5.71%
prepare_rename 335.7±13.02µs 338.0±7.39µs +0.69%
rename 9.1±0.17ms 9.2±0.03ms +1.10%
semantic_tokens 1186.9±17.43µs 1274.1±13.84µs +7.35%
token_at_position 327.5±3.14µs 337.3±18.60µs +2.99%
tokens_at_position 3.6±0.09ms 3.7±0.03ms +2.78%
tokens_for_file 396.3±3.26µs 398.1±3.34µs +0.45%
traverse 38.9±0.53ms 39.0±1.33ms +0.26%

@IGI-111
Copy link
Contributor

IGI-111 commented Aug 14, 2024

This is expected breakage. Which is why we added that syntax that allows you to pick a specific address.

The proposed upgrade is exactly what I had in mind.

@IGI-111 IGI-111 requested a review from a team August 14, 2024 15:28
Copy link

Benchmark for 1a640cd

Click to view benchmark
Test Base PR %
code_action 5.0±0.01ms 5.2±0.10ms +4.00%
code_lens 293.7±44.82ns 340.2±9.85ns +15.83%
compile 2.6±0.03s 2.6±0.04s 0.00%
completion 4.5±0.11ms 4.7±0.08ms +4.44%
did_change_with_caching 2.5±0.04s 2.6±0.03s +4.00%
document_symbol 906.1±34.96µs 897.0±32.21µs -1.00%
format 85.2±0.67ms 68.3±0.97ms -19.84%
goto_definition 332.8±6.98µs 342.1±4.61µs +2.79%
highlight 8.7±0.16ms 9.0±0.19ms +3.45%
hover 491.3±12.42µs 495.7±4.08µs +0.90%
idents_at_position 121.2±0.41µs 118.5±1.07µs -2.23%
inlay_hints 629.1±31.41µs 690.4±11.18µs +9.74%
on_enter 1994.0±56.06ns 2.1±0.03µs +5.32%
parent_decl_at_position 3.5±0.05ms 3.7±0.04ms +5.71%
prepare_rename 331.0±6.85µs 342.7±7.40µs +3.53%
rename 8.9±0.02ms 9.3±0.24ms +4.49%
semantic_tokens 1236.0±11.76µs 1220.7±16.13µs -1.24%
token_at_position 334.0±3.22µs 327.4±4.89µs -1.98%
tokens_at_position 3.6±0.22ms 3.7±0.03ms +2.78%
tokens_for_file 395.3±2.60µs 403.2±3.60µs +2.00%
traverse 36.8±0.63ms 37.1±1.04ms +0.82%

Copy link

Benchmark for 4b943fb

Click to view benchmark
Test Base PR %
code_action 5.2±0.06ms 5.2±0.10ms 0.00%
code_lens 290.2±5.43ns 359.2±17.11ns +23.78%
compile 2.7±0.04s 2.7±0.04s 0.00%
completion 4.7±0.08ms 4.7±0.06ms 0.00%
did_change_with_caching 2.6±0.03s 2.6±0.02s 0.00%
document_symbol 898.3±55.23µs 908.0±42.86µs +1.08%
format 84.6±1.22ms 68.0±0.90ms -19.62%
goto_definition 333.9±8.87µs 347.7±7.90µs +4.13%
highlight 9.1±0.10ms 9.0±0.11ms -1.10%
hover 493.0±7.08µs 497.4±9.58µs +0.89%
idents_at_position 118.8±0.28µs 118.0±1.49µs -0.67%
inlay_hints 633.4±24.98µs 639.4±29.13µs +0.95%
on_enter 2.0±0.04µs 2.0±0.06µs 0.00%
parent_decl_at_position 3.7±0.02ms 3.7±0.05ms 0.00%
prepare_rename 335.0±10.40µs 344.5±8.22µs +2.84%
rename 9.4±0.35ms 9.3±0.14ms -1.06%
semantic_tokens 1249.2±12.84µs 1258.5±16.73µs +0.74%
token_at_position 335.5±3.76µs 332.0±3.20µs -1.04%
tokens_at_position 3.7±0.15ms 3.7±0.04ms 0.00%
tokens_for_file 398.2±2.79µs 398.7±1.47µs +0.13%
traverse 37.1±0.49ms 37.9±1.67ms +2.16%

@Voxelot
Copy link
Member

Voxelot commented Aug 14, 2024

cc @luizstacio to review this change, as I believe he had hexens audit the pre-existing proxy contract.

@kayagokalp
Copy link
Member

kayagokalp commented Aug 14, 2024

Just to clarify,

I did not pinned owner proxy address like @esdrubal example while building the contract as reading from it is not hardcoded and still works after changing the storage slot keys.

To touch the audited contract in a minimal way that still gets things passing and working, I just pinned target field, like I showed in my Solution section. This can also be seen from the storage slots json file. Just wanted to make it clear.

So only thing changed is:

storage {
    /// The [ContractId] of the target contract.
    ///
    /// # Additional Information
    ///
    /// `target` is stored at sha256("storage_SRC14_0")
    target in 0x7bb458adc1d118713319a5baa00a2d049dd64d2916477d2688d76970c898cd55: Option<ContractId> = None,
    /// The [State] of the proxy owner.
    ///
    /// # Additional Information
    ///
    // `proxy_owner` is stored at sha256("storage_SRC14_1")
    proxy_owner: State = State::Uninitialized,
}

@luizstacio
Copy link
Member

luizstacio commented Aug 14, 2024

@K1-R1 once this PR is merged we need to add these changes on sway-standard-implementations and re-open a PR back to update the binary if they differ.

I understand this needs to be in this way as this is a cycle dependency. As the correct flow would be to update first sway-standard-implementations and then here, but in this case we would also need this version to be released. 🔄

But from a risk management perspective, as we want to incentivize developers to use our audited proxy.
We should add more safe-guards on the tooling side to prevent diffs between the binaries. By fetching them from GitHub using release tags with fixed versions or at least verifying the hash before deploy time.
cc: @kayagokalp

@Voxelot thanks for tagging, we are going to account for the audit diffs.

@K1-R1
Copy link
Member

K1-R1 commented Aug 14, 2024

@K1-R1 once this PR is merged we need to add these changes on sway-standard-implementations and re-open a PR back to update the binary if they differ.

I understand this needs to be in this way as this is a cycle dependency. As the correct flow would be to update first sway-standard-implementations and then here, but in this case we would also need this version to be released. 🔄

But from a risk management perspective, as we want to incentivize developers to use our audited proxy. We should add more safe-guards on the tooling side to prevent diffs between the binaries. By fetching them from GitHub using release tags with fixed versions or at least verifying the hash before deploy time.

@Voxelot thanks for tagging, we are going to account for the audit diffs.

Yh I had already prepared the branch with the new storage layout, but I cannot merge it until forc releases with #6366 as it fixes an issue that broke the configurables, and I believe that I will also need FuelLabs/fuels-rs#1475 to be resolved before I can have the tests working for the contract. Then we can re-audit and use that contract in this repo 👍

@kayagokalp
Copy link
Member

kayagokalp commented Aug 14, 2024

fetching

Just to make sure we are on the same page, forc does not fetch anything online related to the proxy, it is embedded in the code in compile time. So unless we open a pr explicitly changing the file content and cut a new release and users migrate to that new release we cannot alter the proxy contract used we designed this such that the bin does not change at all without explicit changes applied

@luizstacio

@luizstacio
Copy link
Member

fetching

Just to make sure we are on the same page, forc does not fetch anything online related to the proxy, it is embedded in the code in compile time. So unless we open a pr explicitly changing the file content and cut a new release and users migrate to that new release we cannot alter the proxy contract used we designed this such that the bin does not change at all without explicit changes applied

@luizstacio

Yes I'm aware we don't do it right now. The idea is to add such check and use the sway-standard-implementations as the source of true. And remove the manual process for ensuring security.

Copy link

Benchmark for 6afa9d4

Click to view benchmark
Test Base PR %
code_action 5.2±0.04ms 5.2±0.07ms 0.00%
code_lens 293.9±8.67ns 343.9±9.53ns +17.01%
compile 2.6±0.06s 2.7±0.04s +3.85%
completion 4.7±0.04ms 4.7±0.02ms 0.00%
did_change_with_caching 2.6±0.03s 2.6±0.03s 0.00%
document_symbol 921.4±35.35µs 878.3±10.24µs -4.68%
format 82.7±0.83ms 67.1±1.21ms -18.86%
goto_definition 339.8±3.53µs 355.4±11.43µs +4.59%
highlight 9.0±0.01ms 9.1±0.62ms +1.11%
hover 491.2±6.76µs 506.7±5.65µs +3.16%
idents_at_position 119.2±0.27µs 118.5±1.11µs -0.59%
inlay_hints 662.0±96.87µs 648.9±19.10µs -1.98%
on_enter 1896.2±90.60ns 2.1±0.07µs +10.75%
parent_decl_at_position 3.7±0.11ms 3.7±0.02ms 0.00%
prepare_rename 343.0±7.55µs 353.4±6.41µs +3.03%
rename 9.3±0.01ms 9.6±0.29ms +3.23%
semantic_tokens 1155.7±20.82µs 1284.1±16.18µs +11.11%
token_at_position 333.2±1.95µs 338.6±1.90µs +1.62%
tokens_at_position 3.7±0.03ms 3.7±0.03ms 0.00%
tokens_for_file 396.9±2.17µs 403.0±3.21µs +1.54%
traverse 36.5±0.57ms 37.2±0.91ms +1.92%

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ABI Everything to do the ABI, especially the JSON representation breaking May cause existing user code to break. Requires a minor or major release.
Projects
None yet
10 participants