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: create and deploy a reference proxy contract for contracts with [proxy] enabled #6069

Merged
merged 57 commits into from
Aug 7, 2024

Conversation

kayagokalp
Copy link
Member

@kayagokalp kayagokalp commented May 28, 2024

Description

Part of #6068.

This PR adds couple of things:

  1. A default proxy contract implementation taken from sway standards.
  2. Infra for creating, building and deploying the reference implementation for proxy contracts.
  3. Deployment procedure such that proxy contract is deployed while working on a contract which enables the [proxy] in its forc.toml. In a way that it is owned by the deployer and the target initially points to implementation contract.
  4. Infra for making a contract call into the already deployed proxy contracts to update their targets.
  5. Adds a Building text to the all forc build invocations to better inform the user about what forc is doing behind the scenes.
  6. Removes duplicate forc-wallet password prompts which was very frustrating for the users. Now forc-wallet deployment path only asks for password once.
  7. Refactors around how secret_key is selected based on user input
  8. Updated docs around forc-client
  9. Docs around how to use the proxy feature

How this works

If the user does not have a proxy table in their forc.toml, nothing changes, same old deployment procedure is followed. Only difference is that this PR improves the ux by removing the need of providing the password multiple times.

If the user has a contract with a proxy table but without an address like:

[project]
authors = ["kaya"]
entry = "main.sw"
license = "Apache-2.0"
name = "impl-contract"

[dependencies]

[proxy]
enabled = true

Forc automatically creates a proxy contract based on the reference implementation at SRC14. Sets its target to the implementation contract, whichever contract enabled the proxy and the owner to the deployer (signing account of the transaction).

If the user has a contract with a proxy table and an address specified like:

[project]
authors = ["kaya"]
entry = "main.sw"
license = "Apache-2.0"
name = "impl-contract"

[dependencies]

[proxy]
enabled = true
address = "........."

Forc automatically makes a set target conract call to update the proxy contract's target. Pointing it to the newly deployed impl contract which defines the proxy table.

Generated proxy contracts are stored at ~/.forc/.generated_proxy_contracts/project_name for housekeeping.

@kayagokalp kayagokalp added enhancement New feature or request big this task is hard and will take a while P: critical Should be looked at before anything else forc-client Everything related to the `forc-client` crate. forc-deploy Everything to do with forc-deploy labels May 28, 2024
@kayagokalp kayagokalp self-assigned this May 28, 2024
Copy link

Benchmark for 946beec

Click to view benchmark
Test Base PR %
code_action 5.4±0.08ms 5.6±0.09ms +3.70%
code_lens 293.0±13.95ns 293.8±7.41ns +0.27%
compile 3.1±0.06s 3.2±0.04s +3.23%
completion 4.9±0.16ms 4.8±0.08ms -2.04%
did_change_with_caching 3.0±0.04s 3.0±0.07s 0.00%
document_symbol 958.8±26.32µs 971.8±20.63µs +1.36%
format 76.0±0.96ms 74.6±1.08ms -1.84%
goto_definition 368.0±6.55µs 373.1±7.31µs +1.39%
highlight 9.1±0.05ms 9.2±0.11ms +1.10%
hover 493.4±8.98µs 500.5±8.27µs +1.44%
idents_at_position 122.6±0.49µs 123.1±1.51µs +0.41%
inlay_hints 667.5±19.60µs 668.1±8.53µs +0.09%
on_enter 465.3±9.95ns 467.2±20.48ns +0.41%
parent_decl_at_position 3.8±0.05ms 3.8±0.03ms 0.00%
prepare_rename 368.3±5.98µs 371.7±8.25µs +0.92%
rename 9.8±0.17ms 9.8±0.15ms 0.00%
semantic_tokens 977.9±43.61µs 955.9±21.75µs -2.25%
token_at_position 359.7±3.69µs 359.9±2.89µs +0.06%
tokens_at_position 3.8±0.04ms 3.8±0.08ms 0.00%
tokens_for_file 417.7±2.07µs 434.2±4.37µs +3.95%
traverse 42.4±1.16ms 41.5±1.31ms -2.12%

Copy link

Benchmark for 52d495e

Click to view benchmark
Test Base PR %
code_action 5.9±0.09ms 5.2±0.09ms -11.86%
code_lens 288.2±7.07ns 336.9±20.68ns +16.90%
compile 3.3±0.07s 3.1±0.06s -6.06%
completion 5.2±0.13ms 4.6±0.11ms -11.54%
did_change_with_caching 3.2±0.07s 3.2±0.04s 0.00%
document_symbol 979.3±20.40µs 1016.6±39.59µs +3.81%
format 75.6±0.68ms 73.9±1.17ms -2.25%
goto_definition 365.5±6.80µs 362.6±5.96µs -0.79%
highlight 9.5±0.16ms 8.7±0.05ms -8.42%
hover 491.9±8.59µs 487.2±6.58µs -0.96%
idents_at_position 122.0±0.50µs 124.3±0.61µs +1.89%
inlay_hints 656.9±38.17µs 649.2±23.86µs -1.17%
on_enter 487.8±15.12ns 461.1±15.57ns -5.47%
parent_decl_at_position 4.0±0.09ms 3.6±0.06ms -10.00%
prepare_rename 366.2±10.83µs 362.3±6.63µs -1.06%
rename 10.1±0.26ms 9.3±0.16ms -7.92%
semantic_tokens 973.5±11.84µs 987.9±31.67µs +1.48%
token_at_position 354.5±1.86µs 356.1±2.36µs +0.45%
tokens_at_position 4.0±0.13ms 3.6±0.04ms -10.00%
tokens_for_file 416.3±1.88µs 418.4±2.03µs +0.50%
traverse 43.3±1.39ms 44.0±1.51ms +1.62%

Copy link
Member

@sdankel sdankel left a comment

Choose a reason for hiding this comment

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

Looking good! Left a few initial comments/questions

forc-plugins/forc-client/src/util/proxy_contract-abi.json Outdated Show resolved Hide resolved
forc-plugins/forc-client/src/util/pkg.rs Outdated Show resolved Hide resolved
forc-plugins/forc-client/src/util/pkg.rs Show resolved Hide resolved
forc-plugins/forc-client/src/op/deploy.rs Outdated Show resolved Hide resolved
Copy link

Benchmark for 6828faa

Click to view benchmark
Test Base PR %
code_action 5.2±0.10ms 5.2±0.09ms 0.00%
code_lens 289.6±10.50ns 333.3±9.93ns +15.09%
compile 3.1±0.04s 3.0±0.05s -3.23%
completion 4.6±0.10ms 4.6±0.08ms 0.00%
did_change_with_caching 2.9±0.02s 2.9±0.05s 0.00%
document_symbol 1031.5±18.02µs 997.1±33.27µs -3.33%
format 73.7±1.29ms 74.5±0.94ms +1.09%
goto_definition 364.5±6.44µs 361.7±8.55µs -0.77%
highlight 8.8±0.13ms 8.7±0.05ms -1.14%
hover 485.8±7.68µs 483.7±5.30µs -0.43%
idents_at_position 124.4±0.20µs 123.9±1.14µs -0.40%
inlay_hints 638.8±18.70µs 651.2±31.08µs +1.94%
on_enter 489.6±33.45ns 464.2±20.28ns -5.19%
parent_decl_at_position 3.6±0.03ms 3.6±0.02ms 0.00%
prepare_rename 359.0±7.57µs 360.2±3.56µs +0.33%
rename 9.4±0.18ms 9.3±0.17ms -1.06%
semantic_tokens 969.0±11.77µs 977.7±10.31µs +0.90%
token_at_position 358.0±2.02µs 358.9±1.97µs +0.25%
tokens_at_position 3.6±0.03ms 3.6±0.03ms 0.00%
tokens_for_file 419.8±2.06µs 423.8±1.52µs +0.95%
traverse 41.9±1.31ms 41.3±0.79ms -1.43%

Copy link

Benchmark for 82fee6f

Click to view benchmark
Test Base PR %
code_action 5.2±0.06ms 5.3±0.03ms +1.92%
code_lens 288.2±9.93ns 335.7±9.82ns +16.48%
compile 3.0±0.02s 3.0±0.05s 0.00%
completion 4.5±0.02ms 4.6±0.02ms +2.22%
did_change_with_caching 2.9±0.04s 2.9±0.04s 0.00%
document_symbol 948.7±22.76µs 950.3±13.68µs +0.17%
format 73.7±1.23ms 73.4±1.16ms -0.41%
goto_definition 363.8±7.73µs 364.9±8.75µs +0.30%
highlight 8.8±0.18ms 8.8±0.09ms 0.00%
hover 488.2±8.73µs 489.5±8.05µs +0.27%
idents_at_position 123.9±0.41µs 123.9±2.55µs 0.00%
inlay_hints 651.6±29.84µs 657.4±26.93µs +0.89%
on_enter 483.4±8.19ns 461.6±17.51ns -4.51%
parent_decl_at_position 3.6±0.04ms 3.6±0.05ms 0.00%
prepare_rename 357.1±5.05µs 365.0±4.40µs +2.21%
rename 9.3±0.18ms 9.3±0.18ms 0.00%
semantic_tokens 971.9±15.01µs 992.1±18.33µs +2.08%
token_at_position 353.1±3.44µs 362.3±7.73µs +2.61%
tokens_at_position 3.6±0.07ms 3.6±0.02ms 0.00%
tokens_for_file 419.0±2.26µs 421.0±2.66µs +0.48%
traverse 41.2±0.54ms 42.1±0.84ms +2.18%

@kayagokalp kayagokalp marked this pull request as ready for review May 29, 2024 22:32
@kayagokalp kayagokalp requested review from sdankel and a team May 29, 2024 22:32
Copy link

Benchmark for 1101331

Click to view benchmark
Test Base PR %
code_action 5.3±0.12ms 5.3±0.12ms 0.00%
code_lens 287.3±4.49ns 333.9±14.18ns +16.22%
compile 3.1±0.06s 3.0±0.06s -3.23%
completion 4.6±0.39ms 4.6±0.09ms 0.00%
did_change_with_caching 3.0±0.06s 2.9±0.02s -3.33%
document_symbol 951.8±30.65µs 989.7±41.43µs +3.98%
format 74.6±0.69ms 73.7±0.77ms -1.21%
goto_definition 361.6±4.20µs 367.2±4.25µs +1.55%
highlight 8.7±0.03ms 8.8±0.19ms +1.15%
hover 489.3±4.76µs 486.9±6.76µs -0.49%
idents_at_position 124.6±0.78µs 124.3±1.16µs -0.24%
inlay_hints 708.3±16.99µs 685.6±28.42µs -3.20%
on_enter 483.6±14.57ns 467.5±16.97ns -3.33%
parent_decl_at_position 3.6±0.05ms 3.6±0.07ms 0.00%
prepare_rename 359.4±5.69µs 364.5±9.30µs +1.42%
rename 9.4±0.10ms 9.3±0.17ms -1.06%
semantic_tokens 975.5±20.21µs 961.2±21.32µs -1.47%
token_at_position 363.5±3.07µs 357.2±2.08µs -1.73%
tokens_at_position 3.6±0.01ms 3.6±0.05ms 0.00%
tokens_for_file 429.3±5.69µs 422.0±2.56µs -1.70%
traverse 42.5±1.01ms 42.5±0.86ms 0.00%

docs/book/src/forc/plugins/forc_client/index.md Outdated Show resolved Hide resolved
docs/book/src/forc/plugins/forc_client/index.md Outdated Show resolved Hide resolved
forc-plugins/forc-client/src/util/pkg.rs Outdated Show resolved Hide resolved
Copy link

Benchmark for c157f2b

Click to view benchmark
Test Base PR %
code_action 5.6±0.18ms 5.3±0.10ms -5.36%
code_lens 335.5±9.43ns 284.7±8.11ns -15.14%
compile 3.2±0.06s 3.2±0.05s 0.00%
completion 4.6±0.13ms 4.7±0.13ms +2.17%
did_change_with_caching 3.1±0.04s 3.0±0.04s -3.23%
document_symbol 1005.0±49.17µs 956.5±22.53µs -4.83%
format 75.0±0.77ms 73.7±0.90ms -1.73%
goto_definition 494.9±3.76µs 361.6±7.21µs -26.93%
highlight 9.0±0.27ms 8.8±0.06ms -2.22%
hover 511.8±11.43µs 489.9±15.58µs -4.28%
idents_at_position 123.4±0.37µs 124.5±1.08µs +0.89%
inlay_hints 650.2±8.69µs 649.9±23.67µs -0.05%
on_enter 478.7±11.97ns 478.4±16.64ns -0.06%
parent_decl_at_position 3.6±0.02ms 3.6±0.04ms 0.00%
prepare_rename 357.0±3.45µs 359.4±6.67µs +0.67%
rename 9.4±0.19ms 9.5±0.25ms +1.06%
semantic_tokens 995.8±20.54µs 988.1±17.90µs -0.77%
token_at_position 353.1±3.42µs 355.9±2.95µs +0.79%
tokens_at_position 3.6±0.03ms 3.6±0.08ms 0.00%
tokens_for_file 425.6±2.75µs 424.5±4.89µs -0.26%
traverse 43.5±1.13ms 42.9±0.92ms -1.38%

@IGI-111 IGI-111 requested review from a team as code owners May 31, 2024 18:41
Copy link

Benchmark for 126ba37

Click to view benchmark
Test Base PR %
code_action 5.5±0.21ms 5.4±0.07ms -1.82%
code_lens 339.9±26.93ns 291.1±16.71ns -14.36%
compile 3.2±0.07s 3.2±0.06s 0.00%
completion 4.7±0.15ms 4.8±0.10ms +2.13%
did_change_with_caching 3.1±0.06s 3.1±0.05s 0.00%
document_symbol 1014.9±40.47µs 980.3±18.46µs -3.41%
format 75.9±0.98ms 75.1±1.53ms -1.05%
goto_definition 368.9±3.50µs 369.1±10.14µs +0.05%
highlight 8.9±0.20ms 8.9±0.07ms 0.00%
hover 497.4±9.43µs 497.6±7.45µs +0.04%
idents_at_position 123.5±1.08µs 123.5±1.06µs 0.00%
inlay_hints 724.3±16.14µs 665.8±36.54µs -8.08%
on_enter 484.2±11.49ns 480.1±15.19ns -0.85%
parent_decl_at_position 3.6±0.04ms 3.6±0.05ms 0.00%
prepare_rename 370.4±9.60µs 368.6±9.76µs -0.49%
rename 9.6±0.22ms 9.8±0.24ms +2.08%
semantic_tokens 1001.1±23.12µs 986.6±20.43µs -1.45%
token_at_position 363.8±2.08µs 362.2±9.01µs -0.44%
tokens_at_position 3.6±0.03ms 3.6±0.08ms 0.00%
tokens_for_file 430.8±3.03µs 428.5±4.93µs -0.53%
traverse 43.7±0.71ms 43.1±1.04ms -1.37%

Copy link
Member

@K1-R1 K1-R1 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 suggestions for the docs, but this is a great feature. The auto updating of the proxy address in the manifest is great

docs/book/src/forc/plugins/forc_client/index.md Outdated Show resolved Hide resolved
docs/book/src/forc/plugins/forc_client/index.md Outdated Show resolved Hide resolved
docs/book/src/forc/plugins/forc_client/index.md Outdated Show resolved Hide resolved
docs/book/src/forc/plugins/forc_client/index.md Outdated Show resolved Hide resolved
@K1-R1 K1-R1 requested a review from a team June 3, 2024 16:29
@kayagokalp kayagokalp enabled auto-merge (squash) August 6, 2024 13:31
@kayagokalp kayagokalp requested a review from sdankel August 6, 2024 13:31
Copy link

github-actions bot commented Aug 6, 2024

Benchmark for 5318cff

Click to view benchmark
Test Base PR %
code_action 5.2±0.08ms 5.2±0.12ms 0.00%
code_lens 297.7±5.21ns 291.9±13.15ns -1.95%
compile 2.7±0.04s 2.8±0.05s +3.70%
completion 4.7±0.06ms 4.7±0.05ms 0.00%
did_change_with_caching 2.6±0.03s 2.6±0.06s 0.00%
document_symbol 920.1±5.77µs 865.8±9.64µs -5.90%
format 72.4±0.69ms 72.6±1.15ms +0.28%
goto_definition 338.9±6.56µs 340.2±7.58µs +0.38%
highlight 9.1±0.09ms 9.0±0.07ms -1.10%
hover 492.5±4.87µs 495.5±9.12µs +0.61%
idents_at_position 123.9±2.36µs 120.0±0.79µs -3.15%
inlay_hints 634.4±6.07µs 639.1±29.77µs +0.74%
on_enter 2.0±0.08µs 1990.4±87.33ns -0.48%
parent_decl_at_position 3.7±0.03ms 3.7±0.03ms 0.00%
prepare_rename 333.1±8.46µs 337.1±6.76µs +1.20%
rename 9.4±0.14ms 9.4±0.32ms 0.00%
semantic_tokens 1240.9±12.03µs 1195.2±11.04µs -3.68%
token_at_position 330.2±1.77µs 328.6±2.60µs -0.48%
tokens_at_position 3.7±0.02ms 3.7±0.02ms 0.00%
tokens_for_file 395.4±2.79µs 397.7±3.15µs +0.58%
traverse 37.3±0.77ms 38.0±0.92ms +1.88%

Copy link

github-actions bot commented Aug 6, 2024

Benchmark for 0fb629a

Click to view benchmark
Test Base PR %
code_action 5.3±0.42ms 5.5±0.23ms +3.77%
code_lens 332.6±11.21ns 332.8±15.49ns +0.06%
compile 2.8±0.08s 2.8±0.08s 0.00%
completion 5.0±0.21ms 5.1±0.22ms +2.00%
did_change_with_caching 2.8±0.04s 2.7±0.02s -3.57%
document_symbol 893.5±26.78µs 868.6±13.07µs -2.79%
format 73.2±1.02ms 72.5±0.75ms -0.96%
goto_definition 340.5±7.73µs 338.3±9.37µs -0.65%
highlight 9.3±1.09ms 9.2±0.36ms -1.08%
hover 505.0±9.29µs 494.7±6.82µs -2.04%
idents_at_position 119.0±0.90µs 122.1±1.21µs +2.61%
inlay_hints 619.7±21.48µs 631.7±35.11µs +1.94%
on_enter 1949.4±98.19ns 2.0±0.30µs +2.60%
parent_decl_at_position 3.6±0.06ms 3.6±0.09ms 0.00%
prepare_rename 339.8±7.47µs 339.8±8.02µs 0.00%
rename 9.5±0.14ms 9.7±0.17ms +2.11%
semantic_tokens 1322.9±15.03µs 1229.4±20.80µs -7.07%
token_at_position 344.4±2.73µs 335.4±3.52µs -2.61%
tokens_at_position 3.6±0.05ms 3.6±0.07ms 0.00%
tokens_for_file 404.5±3.52µs 399.7±3.51µs -1.19%
traverse 56.7±5.54ms 57.2±2.50ms +0.88%

@kayagokalp kayagokalp requested review from K1-R1 and removed request for rvcas August 6, 2024 18:57
Copy link

github-actions bot commented Aug 6, 2024

Benchmark for 09d598f

Click to view benchmark
Test Base PR %
code_action 5.2±0.15ms 5.2±0.10ms 0.00%
code_lens 335.3±8.74ns 346.4±14.00ns +3.31%
compile 2.8±0.03s 2.8±0.07s 0.00%
completion 4.7±0.16ms 4.8±0.14ms +2.13%
did_change_with_caching 2.7±0.03s 2.8±0.03s +3.70%
document_symbol 908.4±13.57µs 873.7±16.31µs -3.82%
format 73.7±1.94ms 73.2±0.77ms -0.68%
goto_definition 336.9±5.07µs 345.2±7.75µs +2.46%
highlight 8.8±0.19ms 8.7±0.13ms -1.14%
hover 496.3±8.11µs 499.2±10.15µs +0.58%
idents_at_position 119.1±0.46µs 119.4±0.86µs +0.25%
inlay_hints 629.5±31.62µs 634.7±26.96µs +0.83%
on_enter 2.0±0.07µs 1983.9±67.52ns -0.80%
parent_decl_at_position 3.6±0.03ms 3.7±0.09ms +2.78%
prepare_rename 333.8±9.26µs 345.7±8.03µs +3.57%
rename 9.1±0.26ms 9.5±0.25ms +4.40%
semantic_tokens 1315.2±32.04µs 1296.1±19.48µs -1.45%
token_at_position 339.6±4.17µs 340.9±2.23µs +0.38%
tokens_at_position 3.6±0.04ms 3.8±0.16ms +5.56%
tokens_for_file 403.6±3.35µs 404.6±2.11µs +0.25%
traverse 39.5±0.97ms 39.8±0.70ms +0.76%

Copy link

github-actions bot commented Aug 7, 2024

Benchmark for d89ec7f

Click to view benchmark
Test Base PR %
code_action 5.0±0.07ms 5.1±0.07ms +2.00%
code_lens 297.6±12.04ns 292.5±10.47ns -1.71%
compile 2.6±0.05s 2.7±0.04s +3.85%
completion 4.5±0.07ms 4.6±0.07ms +2.22%
did_change_with_caching 2.6±0.02s 2.6±0.02s 0.00%
document_symbol 906.2±32.71µs 895.8±63.11µs -1.15%
format 72.7±1.50ms 74.1±1.11ms +1.93%
goto_definition 335.9±7.45µs 337.6±8.86µs +0.51%
highlight 8.6±0.11ms 8.7±0.11ms +1.16%
hover 492.2±9.53µs 494.3±17.13µs +0.43%
idents_at_position 117.3±0.31µs 119.7±0.69µs +2.05%
inlay_hints 617.2±16.42µs 632.1±23.10µs +2.41%
on_enter 2.1±0.05µs 1995.6±63.89ns -4.97%
parent_decl_at_position 3.6±0.03ms 3.6±0.03ms 0.00%
prepare_rename 333.9±8.36µs 339.1±9.80µs +1.56%
rename 8.9±0.17ms 9.1±0.13ms +2.25%
semantic_tokens 1222.0±12.92µs 1281.5±19.58µs +4.87%
token_at_position 333.7±8.35µs 338.2±2.42µs +1.35%
tokens_at_position 3.6±0.04ms 3.6±0.03ms 0.00%
tokens_for_file 403.7±9.28µs 398.3±3.09µs -1.34%
traverse 37.3±0.99ms 37.0±0.59ms -0.80%

@kayagokalp kayagokalp merged commit 5d796fb into master Aug 7, 2024
40 checks passed
@kayagokalp kayagokalp deleted the kayagokalp/deploy-default-proxy branch August 7, 2024 10:41
Copy link
Member

@bitzoic bitzoic left a comment

Choose a reason for hiding this comment

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

Minor nits 1 min too late


To create a wallet you can use `forc wallet new`. It will ask you to choose a password to encrypt your wallet. After the initialization is done you will have your mnemonic phrase.
The easiest and recommended way to interact with deployed networks such as our testnets is option 1, using `forc-client` to sign your transactions which reads your default `forc-wallet` vault. For interacting with local node, we recommend using the second option, which leads `forc-client` to sign transactions with the a private key that comes pre-funded in local environments.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
The easiest and recommended way to interact with deployed networks such as our testnets is option 1, using `forc-client` to sign your transactions which reads your default `forc-wallet` vault. For interacting with local node, we recommend using the second option, which leads `forc-client` to sign transactions with the a private key that comes pre-funded in local environments.
The easiest and recommended way to interact with deployed networks such as our testnets is option 1, using `forc-client` to sign your transactions which reads your default `forc-wallet` vault. For interacting with local node, we recommend using the second option, which leads `forc-client` to sign transactions with the private key that comes pre-funded in local environments.

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh looks like it got auto merged, I'll address these with the follow-up, thanks!

@@ -1,26 +1,62 @@
# `forc-client`

Forc plugin for interacting with a Fuel node.
Forc plugin for interacting with a Fuel node. Since transactions are going to require some gas, you need to sign them with an account that has enough tokens to pay for them.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Forc plugin for interacting with a Fuel node. Since transactions are going to require some gas, you need to sign them with an account that has enough tokens to pay for them.
The forc plugin for interacting with a Fuel node.
Since transactions are going to require some gas, you need to sign them with an account that has enough coins to pay for them.

Should be assets or coins as there are no tokens on Fuel 🙂
https://docs.fuel.network/docs/sway/blockchain-development/native_assets/#asset-vs-coin-vs-token


To install `forc-wallet` please refer to `forc-wallet`'s [GitHub repo](https://github.com/FuelLabs/forc-wallet#forc-wallet).
If you are not interacting with a deployed network, such as testnets, your local `fuel-core` environment can be structured such that it funds an account by default. Using `--default-signer` flag with `forc-client` binaries (run, deploy) will instruct `forc-client` to sign transactions with this pre-funded account. Which makes it a useful command while working against a local node.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
If you are not interacting with a deployed network, such as testnets, your local `fuel-core` environment can be structured such that it funds an account by default. Using `--default-signer` flag with `forc-client` binaries (run, deploy) will instruct `forc-client` to sign transactions with this pre-funded account. Which makes it a useful command while working against a local node.
If you are not interacting with a deployed network, such as testnets, your local `fuel-core` environment can be structured such that it funds an account by default. Using `--default-signer` flag with `forc-client` binaries (run, deploy) will instruct `forc-client` to sign transactions with this pre-funded account. This makes it a useful command while working against a local node.


## Option 3: Manually signing through forc-wallet (Deprecated)

This option is for creating the transaction first, signing it manually and supplying the signed transaction back to forc-client. Since it requires multiple steps, it is more error-prone and not recommended for general use case. Also this will be deprecated soon.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
This option is for creating the transaction first, signing it manually and supplying the signed transaction back to forc-client. Since it requires multiple steps, it is more error-prone and not recommended for general use case. Also this will be deprecated soon.
This option is for creating the transaction first, signing it manually, and supplying the signed transaction back to forc-client. Since it requires multiple steps, it is more error-prone and not recommended for general use cases. Also this will be deprecated soon.

enabled = true
```

If there is no `address` field present under the proxy table, like the example above, `forc` will automatically create a proxy contract based on the [SRC-14](https://github.com/FuelLabs/sway-standards/blob/master/docs/src/src-14-simple-upgradeable-proxies.md) implementation from [sway-standards](https://github.com/FuelLabs/sway-standards). After generating and deploying the proxy contract, the target is set to the current contract, and owner of the proxy is set to the account that is signing the transaction for deployment.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
If there is no `address` field present under the proxy table, like the example above, `forc` will automatically create a proxy contract based on the [SRC-14](https://github.com/FuelLabs/sway-standards/blob/master/docs/src/src-14-simple-upgradeable-proxies.md) implementation from [sway-standards](https://github.com/FuelLabs/sway-standards). After generating and deploying the proxy contract, the target is set to the current contract, and owner of the proxy is set to the account that is signing the transaction for deployment.
If there is no `address` field present under the proxy table, like the example above, `forc` will automatically create a proxy contract based on the [SRC-14](https://github.com/FuelLabs/sway-standards/blob/master/docs/src/src-14-simple-upgradeable-proxies.md) implementation from [sway-standards](https://github.com/FuelLabs/sway-standards). After generating and deploying the proxy contract, the target is set to the current contract, and the owner of the proxy is set to the account that is signing the transaction for deployment.


If there is no `address` field present under the proxy table, like the example above, `forc` will automatically create a proxy contract based on the [SRC-14](https://github.com/FuelLabs/sway-standards/blob/master/docs/src/src-14-simple-upgradeable-proxies.md) implementation from [sway-standards](https://github.com/FuelLabs/sway-standards). After generating and deploying the proxy contract, the target is set to the current contract, and owner of the proxy is set to the account that is signing the transaction for deployment.

This means that if you simply enable proxy in the `Forc.toml`, forc will automatically deploy a proxy contract for you and you do not need to do anything manually aside from signing the deployment transactions for the proxy contract. After deploying the proxy contract, the its address is added into the `address` field of the proxy table.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
This means that if you simply enable proxy in the `Forc.toml`, forc will automatically deploy a proxy contract for you and you do not need to do anything manually aside from signing the deployment transactions for the proxy contract. After deploying the proxy contract, the its address is added into the `address` field of the proxy table.
This means that if you simply enable proxy in the `Forc.toml`, forc will automatically deploy a proxy contract for you and you do not need to do anything manually aside from signing the deployment transactions for the proxy contract. After deploying the proxy contract, the address is added into the `address` field of the proxy table.

Copy link

github-actions bot commented Aug 7, 2024

Benchmark for 887d855

Click to view benchmark
Test Base PR %
code_action 5.1±0.11ms 5.2±0.16ms +1.96%
code_lens 295.1±7.49ns 287.0±9.36ns -2.74%
compile 2.8±0.04s 2.7±0.05s -3.57%
completion 4.7±0.17ms 4.7±0.13ms 0.00%
did_change_with_caching 2.7±0.04s 2.7±0.03s 0.00%
document_symbol 876.2±16.36µs 925.7±30.73µs +5.65%
format 72.2±0.77ms 73.6±1.11ms +1.94%
goto_definition 336.9±10.52µs 344.5±8.85µs +2.26%
highlight 8.7±0.19ms 9.0±0.87ms +3.45%
hover 496.4±4.83µs 503.0±6.34µs +1.33%
idents_at_position 117.5±0.40µs 119.5±1.39µs +1.70%
inlay_hints 619.8±31.40µs 631.6±30.92µs +1.90%
on_enter 2.0±0.04µs 2.0±0.11µs 0.00%
parent_decl_at_position 3.6±0.03ms 3.6±0.07ms 0.00%
prepare_rename 331.3±9.01µs 347.3±8.97µs +4.83%
rename 9.1±0.19ms 9.1±0.18ms 0.00%
semantic_tokens 1246.6±15.55µs 1247.8±24.02µs +0.10%
token_at_position 340.5±2.95µs 339.5±3.56µs -0.29%
tokens_at_position 3.6±0.06ms 3.6±0.04ms 0.00%
tokens_for_file 401.8±10.00µs 397.7±10.66µs -1.02%
traverse 39.0±1.07ms 38.6±0.57ms -1.03%

@sdankel
Copy link
Member

sdankel commented Aug 7, 2024

Minor nits 1 min too late

#6403

@sdankel sdankel mentioned this pull request Aug 7, 2024
8 tasks
sdankel added a commit that referenced this pull request Aug 7, 2024
## Description

Apply @bitzoic 's comments from
#6069

## 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).
- [ ] If my change requires substantial documentation changes, I have
[requested support from the DevRel
team](https://github.com/FuelLabs/devrel-requests/issues/new/choose)
- [ ] 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](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [ ] I have requested a review from the relevant team or maintainers.
esdrubal pushed a commit that referenced this pull request Aug 13, 2024
… `[proxy]` enabled (#6069)

Part of #6068.

This PR adds couple of things:

1. A default proxy contract implementation taken from [sway
standards](https://github.com/FuelLabs/sway-standards/blob/master/standards/src/src14.sw).
2. Infra for creating, building and deploying the reference
implementation for proxy contracts.
3. Deployment procedure such that proxy contract is deployed while
working on a contract which enables the `[proxy]` in its forc.toml. In a
way that it is owned by the deployer and the target initially points to
implementation contract.
4. Infra for making a contract call into the already deployed proxy
contracts to update their targets.
5. Adds a `Building` text to the all forc build invocations to better
inform the user about what forc is doing behind the scenes.
6. Removes duplicate forc-wallet password prompts which was very
frustrating for the users. Now forc-wallet deployment path only asks for
password once.
7. Refactors around how secret_key is selected based on user input
8. Updated docs around forc-client
9. Docs around how to use the proxy feature

If the user does not have a proxy table in their forc.toml, nothing
changes, same old deployment procedure is followed. Only difference is
that this PR improves the ux by removing the need of providing the
password multiple times.

If the user has a contract with a proxy table but without an address
like:

```TOML
[project]
authors = ["kaya"]
entry = "main.sw"
license = "Apache-2.0"
name = "impl-contract"

[dependencies]

[proxy]
enabled = true
```
Forc automatically creates a proxy contract based on the reference
implementation at
[SRC14](https://github.com/FuelLabs/sway-standard-implementations/tree/61fd4ad8f69d21cec0d5cd8135bdc4495e0c125c). Sets its
target to the implementation contract, whichever contract enabled the
proxy and the owner to the deployer (signing account of the
transaction).

If the user has a contract with a proxy table and an address specified
like:

```TOML
[project]
authors = ["kaya"]
entry = "main.sw"
license = "Apache-2.0"
name = "impl-contract"

[dependencies]

[proxy]
enabled = true
address = "........."
```
Forc automatically makes a set target conract call to update the proxy
contract's target. Pointing it to the newly deployed impl contract which
defines the proxy table.

Generated proxy contract abi and bins are stored at
`~/.forc/.generated_proxy_contracts/project_name` for housekeeping.
esdrubal pushed a commit that referenced this pull request Aug 13, 2024
## Description

Apply @bitzoic 's comments from
#6069

## 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).
- [ ] If my change requires substantial documentation changes, I have
[requested support from the DevRel
team](https://github.com/FuelLabs/devrel-requests/issues/new/choose)
- [ ] 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](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [ ] I have requested a review from the relevant team or maintainers.
esdrubal pushed a commit that referenced this pull request Aug 13, 2024
… `[proxy]` enabled (#6069)

Part of #6068.

This PR adds couple of things:

1. A default proxy contract implementation taken from [sway
standards](https://github.com/FuelLabs/sway-standards/blob/master/standards/src/src14.sw).
2. Infra for creating, building and deploying the reference
implementation for proxy contracts.
3. Deployment procedure such that proxy contract is deployed while
working on a contract which enables the `[proxy]` in its forc.toml. In a
way that it is owned by the deployer and the target initially points to
implementation contract.
4. Infra for making a contract call into the already deployed proxy
contracts to update their targets.
5. Adds a `Building` text to the all forc build invocations to better
inform the user about what forc is doing behind the scenes.
6. Removes duplicate forc-wallet password prompts which was very
frustrating for the users. Now forc-wallet deployment path only asks for
password once.
7. Refactors around how secret_key is selected based on user input
8. Updated docs around forc-client
9. Docs around how to use the proxy feature

If the user does not have a proxy table in their forc.toml, nothing
changes, same old deployment procedure is followed. Only difference is
that this PR improves the ux by removing the need of providing the
password multiple times.

If the user has a contract with a proxy table but without an address
like:

```TOML
[project]
authors = ["kaya"]
entry = "main.sw"
license = "Apache-2.0"
name = "impl-contract"

[dependencies]

[proxy]
enabled = true
```
Forc automatically creates a proxy contract based on the reference
implementation at
[SRC14](https://github.com/FuelLabs/sway-standard-implementations/tree/61fd4ad8f69d21cec0d5cd8135bdc4495e0c125c). Sets its
target to the implementation contract, whichever contract enabled the
proxy and the owner to the deployer (signing account of the
transaction).

If the user has a contract with a proxy table and an address specified
like:

```TOML
[project]
authors = ["kaya"]
entry = "main.sw"
license = "Apache-2.0"
name = "impl-contract"

[dependencies]

[proxy]
enabled = true
address = "........."
```
Forc automatically makes a set target conract call to update the proxy
contract's target. Pointing it to the newly deployed impl contract which
defines the proxy table.

Generated proxy contract abi and bins are stored at
`~/.forc/.generated_proxy_contracts/project_name` for housekeeping.
esdrubal added a commit that referenced this pull request Aug 13, 2024
…cts with `[proxy]` enabled (#6069)"

This reverts commit ebb030b.
kayagokalp added a commit that referenced this pull request Aug 17, 2024
… and loader generation (#6250)

## Description

This PR adds chunk deployment based on LDC. Contracts larger than 100 kb
size, is split into chunks and chunks are deployed as `blobs`. Out of
these blobs we create a loader contract, which loads all the blobs using
`LDC` opcode.

One important thing is that this feature works nicely with the proxy
feature introduced in #6069, so a large contract, with proxy can be
deployed directly. Large contract will be split into chunks, chunks will
get deployed, loader will get get generated and deployed, after all
these a proxy contract is deployed and pointed to the loader contract
deployed.

Simple chunked deploy, chunked deployment re routing the call, chunked
deployment behind a proxy re routes the call is tested.

---------

Co-authored-by: Sophie Dankel <47993817+sdankel@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
big this task is hard and will take a while enhancement New feature or request forc-client Everything related to the `forc-client` crate. forc-deploy Everything to do with forc-deploy P: critical Should be looked at before anything else
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants