diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 7fb8f888450..bdb38dc2c31 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1,37 +1,36 @@ -* @Voxelot @mchristopher @luizstacio -# # Everything else -# * @FuelLabs/leads +# Everything else +* @FuelLabs/leads -# # Documentation -# /docs/ @FuelLabs/tooling @FuelLabs/sway-compiler @FuelLabs/swayex @FuelLabs/Devrel +# Documentation +/docs/ @FuelLabs/tooling @FuelLabs/sway-compiler @FuelLabs/swayex @FuelLabs/Devrel -# # Sway files and standard library -# /examples/ @FuelLabs/sway-compiler @FuelLabs/swayex -# /sway-lib-core/ @FuelLabs/sway-compiler @FuelLabs/swayex -# /sway-lib-std/ @FuelLabs/sway-compiler @FuelLabs/swayex +# Sway files and standard library +/examples/ @FuelLabs/sway-compiler @FuelLabs/swayex +/sway-lib-core/ @FuelLabs/sway-compiler @FuelLabs/swayex +/sway-lib-std/ @FuelLabs/sway-compiler @FuelLabs/swayex -# # Tooling -# /forc/ @FuelLabs/tooling -# /forc-pkg/ @FuelLabs/tooling -# /forc-plugins/ @FuelLabs/tooling -# /forc-test/ @FuelLabs/tooling -# /forc-tracing/ @FuelLabs/tooling -# /forc-util/ @FuelLabs/tooling -# /sway-lsp/ @FuelLabs/tooling -# /swayfmt/ @FuelLabs/tooling +# Tooling +/forc/ @FuelLabs/tooling +/forc-pkg/ @FuelLabs/tooling +/forc-plugins/ @FuelLabs/tooling +/forc-test/ @FuelLabs/tooling +/forc-tracing/ @FuelLabs/tooling +/forc-util/ @FuelLabs/tooling +/sway-lsp/ @FuelLabs/tooling +/swayfmt/ @FuelLabs/tooling -# # Compiler -# /sway-ast/ @FuelLabs/sway-compiler -# /sway-core/ @FuelLabs/sway-compiler -# /sway-error/ @FuelLabs/sway-compiler -# /sway-ir/ @FuelLabs/sway-compiler -# /sway-parse/ @FuelLabs/sway-compiler -# /sway-types/ @FuelLabs/sway-compiler -# /sway-utils/ @FuelLabs/sway-compiler -# /templates/ @FuelLabs/sway-compiler -# /test/ @FuelLabs/sway-compiler +# Compiler +/sway-ast/ @FuelLabs/sway-compiler +/sway-core/ @FuelLabs/sway-compiler +/sway-error/ @FuelLabs/sway-compiler +/sway-ir/ @FuelLabs/sway-compiler +/sway-parse/ @FuelLabs/sway-compiler +/sway-types/ @FuelLabs/sway-compiler +/sway-utils/ @FuelLabs/sway-compiler +/templates/ @FuelLabs/sway-compiler +/test/ @FuelLabs/sway-compiler -# # Root lockfile and deployment scripts -# Cargo.lock @FuelLabs/leads -# /deployment/ @FuelLabs/leads +# Root lockfile and deployment scripts +Cargo.lock @FuelLabs/leads +/deployment/ @FuelLabs/leads diff --git a/Cargo.lock b/Cargo.lock index 19d9d013554..0620ca38da1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2520,9 +2520,9 @@ checksum = "b90ca2580b73ab6a1f724b76ca11ab632df820fd6040c336200d2c1df7b3c82c" [[package]] name = "eventsource-client" -version = "0.12.2" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c80c6714d1a380314fcb11a22eeff022e1e1c9642f0bb54e15dc9cb29f37b29" +checksum = "43ddc25e1ad2cc0106d5e2d967397b4fb2068a66677ee9b0eea4600e5cfe8fb4" dependencies = [ "futures", "hyper 0.14.30", @@ -2690,7 +2690,7 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "forc" -version = "0.64.0" +version = "0.65.2" dependencies = [ "annotate-snippets", "ansi_term", @@ -2701,7 +2701,7 @@ dependencies = [ "completest-pty", "forc-pkg", "forc-test", - "forc-tracing 0.64.0", + "forc-tracing 0.65.2", "forc-util", "fs_extra", "fuel-asm", @@ -2727,7 +2727,7 @@ dependencies = [ [[package]] name = "forc-client" -version = "0.64.0" +version = "0.65.2" dependencies = [ "anyhow", "async-trait", @@ -2739,7 +2739,7 @@ dependencies = [ "dialoguer", "forc", "forc-pkg", - "forc-tracing 0.64.0", + "forc-tracing 0.65.2", "forc-tx", "forc-util", "forc-wallet", @@ -2756,6 +2756,7 @@ dependencies = [ "hex", "k256", "portpicker", + "pretty_assertions", "rand", "regex", "rexpect 0.5.0", @@ -2773,13 +2774,13 @@ dependencies = [ [[package]] name = "forc-crypto" -version = "0.64.0" +version = "0.65.2" dependencies = [ "anyhow", "async-trait", "atty", "clap 4.5.16", - "forc-tracing 0.64.0", + "forc-tracing 0.65.2", "forc-util", "fuel-core-types", "fuel-crypto", @@ -2799,7 +2800,7 @@ dependencies = [ [[package]] name = "forc-debug" -version = "0.64.0" +version = "0.65.2" dependencies = [ "anyhow", "clap 4.5.16", @@ -2807,7 +2808,7 @@ dependencies = [ "escargot", "forc-pkg", "forc-test", - "forc-tracing 0.64.0", + "forc-tracing 0.65.2", "fuel-core-client", "fuel-types", "fuel-vm", @@ -2825,7 +2826,7 @@ dependencies = [ [[package]] name = "forc-doc" -version = "0.64.0" +version = "0.65.2" dependencies = [ "anyhow", "clap 4.5.16", @@ -2833,7 +2834,7 @@ dependencies = [ "dir_indexer", "expect-test", "forc-pkg", - "forc-tracing 0.64.0", + "forc-tracing 0.65.2", "forc-util", "horrorshow", "include_dir", @@ -2850,12 +2851,12 @@ dependencies = [ [[package]] name = "forc-fmt" -version = "0.64.0" +version = "0.65.2" dependencies = [ "anyhow", "clap 4.5.16", "forc-pkg", - "forc-tracing 0.64.0", + "forc-tracing 0.65.2", "forc-util", "prettydiff 0.7.0", "sway-core", @@ -2867,7 +2868,7 @@ dependencies = [ [[package]] name = "forc-lsp" -version = "0.64.0" +version = "0.65.2" dependencies = [ "anyhow", "clap 4.5.16", @@ -2878,13 +2879,13 @@ dependencies = [ [[package]] name = "forc-pkg" -version = "0.64.0" +version = "0.65.2" dependencies = [ "ansi_term", "anyhow", "byte-unit", "cid", - "forc-tracing 0.64.0", + "forc-tracing 0.65.2", "forc-util", "fuel-abi-types", "futures", @@ -2915,7 +2916,7 @@ dependencies = [ [[package]] name = "forc-test" -version = "0.64.0" +version = "0.65.2" dependencies = [ "anyhow", "forc-pkg", @@ -2942,7 +2943,7 @@ dependencies = [ [[package]] name = "forc-tracing" -version = "0.64.0" +version = "0.65.2" dependencies = [ "ansi_term", "tracing", @@ -2952,7 +2953,7 @@ dependencies = [ [[package]] name = "forc-tx" -version = "0.64.0" +version = "0.65.2" dependencies = [ "anyhow", "clap 4.5.16", @@ -2967,7 +2968,7 @@ dependencies = [ [[package]] name = "forc-util" -version = "0.64.0" +version = "0.65.2" dependencies = [ "annotate-snippets", "ansi_term", @@ -2975,7 +2976,7 @@ dependencies = [ "clap 4.5.16", "dirs 5.0.1", "fd-lock", - "forc-tracing 0.64.0", + "forc-tracing 0.65.2", "fuel-tx", "hex", "paste", @@ -2994,9 +2995,9 @@ dependencies = [ [[package]] name = "forc-wallet" -version = "0.9.1" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c595f65f380e2f63332ef84c4473ea4418407d32631acc49637f50d5495acb18" +checksum = "1ed8ee5063d7acc9b7dbdc5bdd43171e2bdcee5171b54939d1876f1b4fb01f6b" dependencies = [ "anyhow", "clap 4.5.16", @@ -3076,9 +3077,9 @@ dependencies = [ [[package]] name = "fuel-asm" -version = "0.57.0" +version = "0.58.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b29ea55a794c00d0dfaad06f11720a05fa928603f812dca1c38163f2b240860a" +checksum = "79ca07227658105bdf873556dea09fa7fbfe792fbc084b4b9568f5ba3d64c411" dependencies = [ "bitflags 2.6.0", "fuel-types", @@ -3088,9 +3089,9 @@ dependencies = [ [[package]] name = "fuel-core-chain-config" -version = "0.36.0" +version = "0.37.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a4c5a71702426b8354bff2010131c0abb4a4f0b608cc7a6dfd72f9e785ba478" +checksum = "cd1eca1d12daf8ad0f2479d7fff9405d94b6467496e5319e5f8b99cbdabdd58b" dependencies = [ "anyhow", "bech32", @@ -3108,11 +3109,12 @@ dependencies = [ [[package]] name = "fuel-core-client" -version = "0.36.0" +version = "0.37.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5770dbda6220e641eb57ee204dd5914fa15170afe3009473f57cdf15e2339fd8" +checksum = "9dbd88f285afdf061e409b712ecef49e2fe9ba235288cc76e8de8f05d50b6876" dependencies = [ "anyhow", + "base64 0.22.1", "cynic", "derive_more 0.99.18", "eventsource-client", @@ -3132,9 +3134,9 @@ dependencies = [ [[package]] name = "fuel-core-metrics" -version = "0.36.0" +version = "0.37.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f671e9e813b81873ef07e1cfe8697ba3f9fd0f05313879ed0933446da4c1c14" +checksum = "dfc199e165e600f241cab86129766b26bab78572a701a39bc40a5fdb669961a8" dependencies = [ "parking_lot 0.12.3", "pin-project-lite", @@ -3145,9 +3147,9 @@ dependencies = [ [[package]] name = "fuel-core-poa" -version = "0.36.0" +version = "0.37.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b698e7c184ab4acbaabe7bad73fdc7dfc9ebfc3a6856b1d719a4fd4c1921873" +checksum = "49c4f3e5fa1e916793609bdb9a52142077a84a793272379a04cf24375aa94e6f" dependencies = [ "anyhow", "async-trait", @@ -3164,9 +3166,9 @@ dependencies = [ [[package]] name = "fuel-core-services" -version = "0.36.0" +version = "0.37.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "998a4f9d057bf3efe43be574bd200ef64c3318007fd04523ce6bd51cc7bb963c" +checksum = "739dca83db1eb86651db3833f088f52afcd3f181cfca40e5725074aceb3ea49d" dependencies = [ "anyhow", "async-trait", @@ -3179,9 +3181,9 @@ dependencies = [ [[package]] name = "fuel-core-storage" -version = "0.36.0" +version = "0.37.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1daa7422e48120b1623b53fe1a1152d11314f30fb290a73dc80f7e128c1f9014" +checksum = "6255d852b6866199d103233e1eef2e7ded141019bc782b5b211fcf001727c34b" dependencies = [ "anyhow", "derive_more 0.99.18", @@ -3201,9 +3203,9 @@ dependencies = [ [[package]] name = "fuel-core-types" -version = "0.36.0" +version = "0.37.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7aa1c54f09cc7c29a11ca1129f73105745f8374a192e3e24040c10822871d83f" +checksum = "33a4e9b2de06381e1ad598cd1030344993fee7401331ca9955d0a1860cc0484c" dependencies = [ "anyhow", "bs58", @@ -3219,9 +3221,9 @@ dependencies = [ [[package]] name = "fuel-crypto" -version = "0.57.0" +version = "0.58.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2661b2a6c43e811be4892250513a6f4c46a69cc7092a1e5b240f49697f08292e" +checksum = "f53b06525aa7754bf7c3ef23daf15fd798ae990a82f8b7b813d25cedfeacfe5c" dependencies = [ "coins-bip32", "coins-bip39", @@ -3240,9 +3242,9 @@ dependencies = [ [[package]] name = "fuel-derive" -version = "0.57.0" +version = "0.58.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03509567813a351ca60d8507b2ac476b06c1590f2e9edbe72bc205bb04e0af12" +checksum = "c8e34d6eec30d04506607cc0bc85fc97c57c964580cd233fd557e346c5273535" dependencies = [ "proc-macro2", "quote", @@ -3299,9 +3301,9 @@ dependencies = [ [[package]] name = "fuel-merkle" -version = "0.57.0" +version = "0.58.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24938ee8a5e9efe71994203527dffb4c81872aa2953de0c347ad38696527b58a" +checksum = "7a9fa3708405eba32fd2b947b827dc52484377ba6a238260b03a07b642395e6c" dependencies = [ "derive_more 0.99.18", "digest 0.10.7", @@ -3314,15 +3316,15 @@ dependencies = [ [[package]] name = "fuel-storage" -version = "0.57.0" +version = "0.58.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4283f9cabc26a1154a31268e79de1e0f317d57231b4dc8d7282efb22e49d2ed3" +checksum = "f6f678f1c900d0632d77e15d4a4946048d4d517fefeba72607390c03288ca127" [[package]] name = "fuel-tx" -version = "0.57.0" +version = "0.58.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "572f9e8fdda6abfe83cf1456a11eabf1de66d682176fb097f2f950704cc50c26" +checksum = "1e3065c12eecc9121514694f4b01009c9a83d8842af11c43ec9e2bbc0a7f36cb" dependencies = [ "bitflags 2.6.0", "derivative", @@ -3336,16 +3338,15 @@ dependencies = [ "postcard", "rand", "serde", - "serde_json", "strum 0.24.1", "strum_macros 0.24.3", ] [[package]] name = "fuel-types" -version = "0.57.0" +version = "0.58.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f196060a10db0293cdfca455f7e2f3a7914f46f25e0fbc2d28cf0a11e835a86" +checksum = "a93d5f3fd028d874d8927be439fcdea01cb04499049bc68a874c73dd0c7e32b7" dependencies = [ "fuel-derive", "hex", @@ -3355,9 +3356,9 @@ dependencies = [ [[package]] name = "fuel-vm" -version = "0.57.0" +version = "0.58.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6f4e0cc4ae65d00df6f3dcae90b81dd21135b45b932a79e368f35d255df12a1" +checksum = "cb0562398978e501e8ee2caeb747a2852cc4a8c5fff250eb58e38f1c03217311" dependencies = [ "anyhow", "async-trait", @@ -3389,9 +3390,9 @@ dependencies = [ [[package]] name = "fuels" -version = "0.66.5" +version = "0.66.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aaf7ca0443308f4c3d3e9dd7ed67cb18369ae63d208302056d6d5f3a09efb031" +checksum = "921a8ea521744e600e0a34236adff7524ecf34bd940c2a018315d0212c140d7b" dependencies = [ "fuel-core-client", "fuel-crypto", @@ -3405,9 +3406,9 @@ dependencies = [ [[package]] name = "fuels-accounts" -version = "0.66.5" +version = "0.66.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92ea69afa418ba67b9572a5b4cb612b80ee2113c9f755e93acf7adc9fc1454d1" +checksum = "2da8bad87e947fc448c44c22e4c90a4af49d61de08722b1d1774d977b2071047" dependencies = [ "async-trait", "chrono", @@ -3430,9 +3431,9 @@ dependencies = [ [[package]] name = "fuels-code-gen" -version = "0.66.5" +version = "0.66.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8d1949debe40c9eb731a93b22a50da560007d85f6f7983679d217c01b9dc867" +checksum = "9fdc5f9dcdf330f5ef5f367dbc2334e72151e9ae46a4ee9f21d43a5e859be11b" dependencies = [ "Inflector", "fuel-abi-types", @@ -3446,9 +3447,9 @@ dependencies = [ [[package]] name = "fuels-core" -version = "0.66.5" +version = "0.66.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e720a87a7c99fcc5477cbb251738406de752a10eb237e15c79c1d99b64f4679f" +checksum = "629212e8278d57aa1a6f846ca0ca1e3428fb6da2d43e368931ff1494a0a6b5ce" dependencies = [ "async-trait", "bech32", @@ -3474,9 +3475,9 @@ dependencies = [ [[package]] name = "fuels-macros" -version = "0.66.5" +version = "0.66.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4f7b391259fceb75331bcbde2878cd9765b579e9167abd818641205b4c96b9a" +checksum = "562bf012adedfb492431f4bfd5be4ccbf2171ab7d5247c5953a6be3ea8036072" dependencies = [ "fuels-code-gen", "itertools 0.12.1", @@ -3487,9 +3488,9 @@ dependencies = [ [[package]] name = "fuels-programs" -version = "0.66.5" +version = "0.66.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbf719a68184ad4999c24dd53cf68bdd247d02fe16a9d67ccba177c8e44771b9" +checksum = "30a366e6a78e1c104fe1cb14439199833987fe76ecd46ee2b46fe05868a3366d" dependencies = [ "async-trait", "fuel-abi-types", @@ -3506,9 +3507,9 @@ dependencies = [ [[package]] name = "fuels-test-helpers" -version = "0.66.5" +version = "0.66.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a615a59644d3cfce8dc1089db0764b4cca2bcea42b2a08eca826e2b8f892936" +checksum = "7705708c0fe28a874c44635b77c3e120a3422c8a24fdc45f07dc8c21ee9ca6fb" dependencies = [ "fuel-core-chain-config", "fuel-core-client", @@ -5980,12 +5981,12 @@ dependencies = [ [[package]] name = "pretty_assertions" -version = "1.4.0" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af7cee1a6c8a5b9208b3cb1061f10c0cb689087b3d8ce85fb9d2dd7a29b6ba66" +checksum = "3ae130e2f271fbc2ac3a40fb1d07180839cdbbe443c7a27e1e3c13c5cac0116d" dependencies = [ "diff", - "yansi", + "yansi 1.0.1", ] [[package]] @@ -7388,7 +7389,7 @@ dependencies = [ "thiserror", "tokio", "version_check", - "yansi", + "yansi 0.5.1", ] [[package]] @@ -7680,7 +7681,7 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" [[package]] name = "sway-ast" -version = "0.64.0" +version = "0.65.2" dependencies = [ "extension-trait", "num-bigint", @@ -7692,7 +7693,7 @@ dependencies = [ [[package]] name = "sway-core" -version = "0.64.0" +version = "0.65.2" dependencies = [ "clap 4.5.16", "derivative", @@ -7737,7 +7738,7 @@ dependencies = [ [[package]] name = "sway-error" -version = "0.64.0" +version = "0.65.2" dependencies = [ "either", "in_definite", @@ -7751,7 +7752,7 @@ dependencies = [ [[package]] name = "sway-ir" -version = "0.64.0" +version = "0.65.2" dependencies = [ "anyhow", "downcast-rs", @@ -7770,7 +7771,7 @@ dependencies = [ [[package]] name = "sway-ir-macros" -version = "0.64.0" +version = "0.65.2" dependencies = [ "itertools 0.13.0", "proc-macro2", @@ -7780,7 +7781,7 @@ dependencies = [ [[package]] name = "sway-lsp" -version = "0.64.0" +version = "0.65.2" dependencies = [ "anyhow", "assert-json-diff", @@ -7791,7 +7792,7 @@ dependencies = [ "dirs 4.0.0", "fd-lock", "forc-pkg", - "forc-tracing 0.64.0", + "forc-tracing 0.65.2", "forc-util", "futures", "indexmap 2.5.0", @@ -7830,7 +7831,7 @@ dependencies = [ [[package]] name = "sway-lsp-test-utils" -version = "0.64.0" +version = "0.65.2" dependencies = [ "assert-json-diff", "futures", @@ -7845,7 +7846,7 @@ dependencies = [ [[package]] name = "sway-parse" -version = "0.64.0" +version = "0.65.2" dependencies = [ "assert_matches", "extension-trait", @@ -7863,7 +7864,7 @@ dependencies = [ [[package]] name = "sway-types" -version = "0.64.0" +version = "0.65.2" dependencies = [ "bytecount", "fuel-asm", @@ -7882,7 +7883,7 @@ dependencies = [ [[package]] name = "sway-utils" -version = "0.64.0" +version = "0.65.2" dependencies = [ "serde", "walkdir", @@ -7890,11 +7891,11 @@ dependencies = [ [[package]] name = "swayfmt" -version = "0.64.0" +version = "0.65.2" dependencies = [ "anyhow", "difference", - "forc-tracing 0.64.0", + "forc-tracing 0.65.2", "indoc", "paste", "prettydiff 0.6.4", @@ -8179,7 +8180,7 @@ dependencies = [ "forc-client", "forc-pkg", "forc-test", - "forc-tracing 0.64.0", + "forc-tracing 0.65.2", "fuel-vm", "futures", "gag", @@ -9509,6 +9510,12 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec" +[[package]] +name = "yansi" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfe53a6657fd280eaa890a3bc59152892ffa3e30101319d168b781ed6529b049" + [[package]] name = "zerocopy" version = "0.7.35" diff --git a/Cargo.toml b/Cargo.toml index bf11ce66ef7..69d4008bc12 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -34,7 +34,7 @@ exclude = [ [workspace.package] edition = "2021" -version = "0.64.0" +version = "0.65.2" authors = ["Fuel Labs "] homepage = "https://fuel.network/" license = "Apache-2.0" @@ -45,34 +45,34 @@ repository = "https://github.com/FuelLabs/sway" # Internal dependencies in order to propagate `workspace.version` # -forc = { path = "forc/", version = "0.64.0" } -forc-pkg = { path = "forc-pkg/", version = "0.64.0" } -forc-test = { path = "forc-test/", version = "0.64.0" } -forc-tracing = { path = "forc-tracing/", version = "0.64.0" } -forc-util = { path = "forc-util/", version = "0.64.0" } +forc = { path = "forc/", version = "0.65.2" } +forc-pkg = { path = "forc-pkg/", version = "0.65.2" } +forc-test = { path = "forc-test/", version = "0.65.2" } +forc-tracing = { path = "forc-tracing/", version = "0.65.2" } +forc-util = { path = "forc-util/", version = "0.65.2" } # Forc plugins -forc-plugins = { path = "forc-plugins/", version = "0.64.0" } -forc-client = { path = "forc-plugins/forc-client/", version = "0.64.0" } -forc-crypto = { path = "forc-plugins/forc-crypto/", version = "0.64.0" } -forc-debug = { path = "forc-plugins/forc-debug/", version = "0.64.0" } -forc-doc = { path = "forc-plugins/forc-doc/", version = "0.64.0" } -forc-fmt = { path = "forc-plugins/forc-fmt/", version = "0.64.0" } -forc-lsp = { path = "forc-plugins/forc-lsp/", version = "0.64.0" } -forc-tx = { path = "forc-plugins/forc-tx/", version = "0.64.0" } +forc-plugins = { path = "forc-plugins/", version = "0.65.2" } +forc-client = { path = "forc-plugins/forc-client/", version = "0.65.2" } +forc-crypto = { path = "forc-plugins/forc-crypto/", version = "0.65.2" } +forc-debug = { path = "forc-plugins/forc-debug/", version = "0.65.2" } +forc-doc = { path = "forc-plugins/forc-doc/", version = "0.65.2" } +forc-fmt = { path = "forc-plugins/forc-fmt/", version = "0.65.2" } +forc-lsp = { path = "forc-plugins/forc-lsp/", version = "0.65.2" } +forc-tx = { path = "forc-plugins/forc-tx/", version = "0.65.2" } -sway-ast = { path = "sway-ast/", version = "0.64.0" } -sway-core = { path = "sway-core/", version = "0.64.0" } -sway-error = { path = "sway-error/", version = "0.64.0" } -sway-lsp = { path = "sway-lsp/", version = "0.64.0" } -sway-parse = { path = "sway-parse/", version = "0.64.0" } -sway-types = { path = "sway-types/", version = "0.64.0" } -sway-utils = { path = "sway-utils/", version = "0.64.0" } -swayfmt = { path = "swayfmt/", version = "0.64.0" } +sway-ast = { path = "sway-ast/", version = "0.65.2" } +sway-core = { path = "sway-core/", version = "0.65.2" } +sway-error = { path = "sway-error/", version = "0.65.2" } +sway-lsp = { path = "sway-lsp/", version = "0.65.2" } +sway-parse = { path = "sway-parse/", version = "0.65.2" } +sway-types = { path = "sway-types/", version = "0.65.2" } +sway-utils = { path = "sway-utils/", version = "0.65.2" } +swayfmt = { path = "swayfmt/", version = "0.65.2" } # Sway IR -sway-ir = { path = "sway-ir/", version = "0.64.0" } -sway-ir-macros = { path = "sway-ir/sway-ir-macros", version = "0.64.0" } +sway-ir = { path = "sway-ir/", version = "0.65.2" } +sway-ir-macros = { path = "sway-ir/sway-ir-macros", version = "0.65.2" } # # External Fuel dependencies @@ -86,23 +86,24 @@ fuel-abi-types = "0.7" # Although ALL verions are "X.Y", we need the complete semver for # fuel-core-client as the GitHub Actions workflow parses this value to pull down # the correct tarball -fuel-core-client = { version = "0.36.0", default-features = false } -fuel-core-types = { version = "0.36", default-features = false } +fuel-core-client = { version = "0.37.0", default-features = false } +fuel-core-types = { version = "0.37", default-features = false } # Dependencies from the `fuels-rs` repository: + fuels = "0.66" fuels-core = "0.66" fuels-accounts = "0.66" # Dependencies from the `fuel-vm` repository: -fuel-asm = "0.57" -fuel-crypto = "0.57" -fuel-types = "0.57" -fuel-tx = "0.57" -fuel-vm = "0.57" +fuel-asm = "0.58" +fuel-crypto = "0.58" +fuel-types = "0.58" +fuel-tx = "0.58" +fuel-vm = "0.58" # Dependencies from the `forc-wallet` repository: -forc-wallet = "0.9" +forc-wallet = "0.10" # # External dependencies diff --git a/docs/book/src/forc/plugins/forc_client/index.md b/docs/book/src/forc/plugins/forc_client/index.md index 23c668b18d4..13800088b96 100644 --- a/docs/book/src/forc/plugins/forc_client/index.md +++ b/docs/book/src/forc/plugins/forc_client/index.md @@ -179,4 +179,25 @@ If an `address` is present, `forc` calls into that contract to update its `targe ## Large Contracts -For contracts over 100KB, `forc-deploy` will split the contract into chunks and deploy the contract with multiple transactions using the Rust SDK's [loader contract](https://github.com/FuelLabs/fuels-rs/blob/master/docs/src/deploying/large_contracts.md) functionality. Chunks that have already been deployed will be reused on subsequent deployments. +For contracts over the maximum contract size limit (currently `100kB`) defined by the network, `forc-deploy` will split the contract into chunks and deploy the contract with multiple transactions using the Rust SDK's [loader contract](https://github.com/FuelLabs/fuels-rs/blob/master/docs/src/deploying/large_contracts.md) functionality. Chunks that have already been deployed will be reused on subsequent deployments. + +## Deploying Scripts and Predicates + +`forc deploy` now supports deploying scripts and predicates in addition to contracts. These are deployed as blobs with generated loaders for efficiency. + +Scripts and predicates are deployed automatically when you run `forc deploy` on a project that contains them. The deployment process differs slightly from contract deployment: + +1. For scripts and predicates, the bytecode is uploaded as a blob. +2. A loader is generated that can load and execute the blob. +3. The loader bytecode is saved in the project's output directory. + +After deployment, you'll find new files in your project's output directory: + +- For scripts: `-loader.bin` +- For predicates: `-loader.bin` and `-loader-root` + +The loader files contain the bytecode necessary to load and execute your script or predicate from the deployed blob. + +This new deployment method allows for more efficient storage and execution of scripts and predicates on the Fuel network. + +Note: Contracts are still deployed directly, not as blobs given that the contract size is under the maximum contract size limit defined by network (currently `100kB`). diff --git a/forc-plugins/forc-client/Cargo.toml b/forc-plugins/forc-client/Cargo.toml index f63bb0b99c9..ee1b03ea173 100644 --- a/forc-plugins/forc-client/Cargo.toml +++ b/forc-plugins/forc-client/Cargo.toml @@ -48,6 +48,7 @@ tracing.workspace = true [dev-dependencies] portpicker = "0.1.1" +pretty_assertions = "1.4.1" rexpect = "0.5" tempfile = "3" diff --git a/forc-plugins/forc-client/src/op/deploy.rs b/forc-plugins/forc-client/src/op/deploy.rs index a5c71a41f79..798fd788826 100644 --- a/forc-plugins/forc-client/src/op/deploy.rs +++ b/forc-plugins/forc-client/src/op/deploy.rs @@ -13,20 +13,27 @@ use crate::{ }, }; use anyhow::{bail, Context, Result}; -use forc_pkg::manifest::GenericManifestFile; use forc_pkg::{self as pkg, PackageManifestFile}; +use forc_pkg::{manifest::GenericManifestFile, MemberFilter}; use forc_tracing::{println_action_green, println_warning}; use forc_util::default_output_directory; use forc_wallet::utils::default_wallet_path; +use fuel_abi_types::abi::program::Configurable; use fuel_core_client::client::types::{ChainInfo, TransactionStatus}; use fuel_core_client::client::FuelClient; use fuel_crypto::fuel_types::ChainId; use fuel_tx::{Salt, Transaction}; -use fuel_vm::prelude::*; +use fuel_vm::{consts::WORD_SIZE, fuel_asm::op, prelude::*}; use fuels::{ macros::abigen, - programs::contract::{LoadConfiguration, StorageConfiguration}, - types::{bech32::Bech32ContractId, transaction_builders::Blob}, + programs::{ + contract::{LoadConfiguration, StorageConfiguration}, + executable::Executable, + }, + types::{ + bech32::Bech32ContractId, + transaction_builders::{Blob, BlobId}, + }, }; use fuels_accounts::{provider::Provider, Account, ViewOnlyAccount}; use fuels_core::types::{transaction::TxPolicies, transaction_builders::CreateTransactionBuilder}; @@ -40,15 +47,25 @@ use std::{ sync::Arc, time::Duration, }; -use sway_core::language::parsed::TreeType; use sway_core::BuildTarget; +use sway_core::{asm_generation::ProgramABI, language::parsed::TreeType}; -/// Maximum contract size allowed for a single contract. If the target +/// Default maximum contract size allowed for a single contract. If the target /// contract size is bigger than this amount, forc-deploy will automatically /// starts dividing the contract and deploy them in chunks automatically. -/// The value is in bytes. +/// The value is in bytes const MAX_CONTRACT_SIZE: usize = 100_000; +/// Represents a deployed instance of a forc package. +/// Packages other than libraries are deployable through different mechanisms. +#[derive(Debug, PartialEq, Eq, Clone)] +pub enum DeployedPackage { + Contract(DeployedContract), + Script(DeployedExecutable), + Predicate(DeployedExecutable), +} + +/// Represents a deployed contract on the Fuel network. #[derive(Debug, PartialEq, Eq, Clone, PartialOrd, Ord)] pub struct DeployedContract { pub id: fuel_tx::ContractId, @@ -56,6 +73,13 @@ pub struct DeployedContract { pub chunked: bool, } +/// Represents a deployed executable (script or predicate) on the Fuel network. +/// Executables are deployed as blobs with generated loaders for efficiency. +#[derive(Debug, PartialEq, Eq, Clone, PartialOrd, Ord)] +pub struct DeployedExecutable { + pub bytecode: Vec, +} + #[derive(Debug, Clone, Serialize, Deserialize)] pub struct DeploymentArtifact { transaction_id: String, @@ -153,7 +177,7 @@ fn resolve_storage_slots( } /// Creates blobs from the contract to deploy contracts that are larger than -/// `MAX_CONTRACT_SIZE`. Created blobs are deployed, and a loader contract is +/// maximum contract size. Created blobs are deployed, and a loader contract is /// generated such that it loads all the deployed blobs, and provides the user /// a single contract (loader contract that loads the blobs) to call into. async fn deploy_chunked( @@ -251,27 +275,25 @@ async fn deploy_new_proxy( Ok(proxy_contract_id) } -/// Builds and deploys contract(s). If the given path corresponds to a workspace, all deployable members -/// will be built and deployed. +/// Builds and deploys contracts, scripts, and predicates from the given path or workspace. /// -/// Upon success, returns the ID of each deployed contract in order of deployment. +/// Contracts are deployed directly, while scripts and predicates are deployed as blobs with generated loaders. /// -/// When deploying a single contract, only that contract's ID is returned. -pub async fn deploy(command: cmd::Deploy) -> Result> { +/// Returns a vector of `DeployedPackage` representing all successful deployments. +pub async fn deploy(command: cmd::Deploy) -> Result> { if command.unsigned { println_warning("--unsigned flag is deprecated, please prefer using --default-signer. Assuming `--default-signer` is passed. This means your transaction will be signed by an account that is funded by fuel-core by default for testing purposes."); } - - let mut deployed_contracts = Vec::new(); let curr_dir = if let Some(ref path) = command.pkg.path { PathBuf::from(path) } else { std::env::current_dir()? }; - - let build_opts = build_opts_from_cmd(&command); + let build_opts = build_opts_from_cmd(&command, MemberFilter::default()); let built_pkgs = built_pkgs(&curr_dir, &build_opts)?; - let pkgs_to_deploy = built_pkgs + let mut deployed_packages = Vec::new(); + + let contracts_to_deploy = built_pkgs .iter() .filter(|pkg| { pkg.descriptor @@ -279,20 +301,281 @@ pub async fn deploy(command: cmd::Deploy) -> Result> { .check_program_type(&[TreeType::Contract]) .is_ok() }) + .cloned() .collect::>(); - if pkgs_to_deploy.is_empty() { - println_warning("No deployable contracts found in the current directory."); + let scripts_to_deploy = built_pkgs + .iter() + .filter(|pkg| { + pkg.descriptor + .manifest_file + .check_program_type(&[TreeType::Script]) + .is_ok() + }) + .cloned() + .collect::>(); + + let predicates_to_deploy = built_pkgs + .iter() + .filter(|pkg| { + pkg.descriptor + .manifest_file + .check_program_type(&[TreeType::Predicate]) + .is_ok() + }) + .cloned() + .collect::>(); + + if contracts_to_deploy.is_empty() + && scripts_to_deploy.is_empty() + && predicates_to_deploy.is_empty() + { + println_warning("No deployable package was found in the current directory."); + } else { + deployed_packages.extend( + deploy_contracts(&command, &contracts_to_deploy) + .await? + .into_iter() + .map(DeployedPackage::Contract), + ); + deployed_packages.extend( + deploy_executables(&command, &scripts_to_deploy) + .await? + .into_iter() + .map(DeployedPackage::Script), + ); + deployed_packages.extend( + deploy_executables(&command, &predicates_to_deploy) + .await? + .into_iter() + .map(DeployedPackage::Predicate), + ); + } + + Ok(deployed_packages) +} + +/// Calculates the loader data offset. Returns a `None` if the original `binary` +/// does not have a data section (no configurables and no args). Otherwise +/// returns the new offset of the data section. +fn loader_data_offset(binary: &[u8], blob_id: &BlobId) -> Result> { + // The following code is taken from SDK, and once they expose the offsets + // we will no longer need to maintain this duplicate version here. + + // The final code is going to have this structure (if the data section is non-empty): + // 1. loader instructions + // 2. blob id + // 3. length_of_data_section + // 4. the data_section (updated with configurables as needed) + const BLOB_ID_SIZE: u16 = 32; + const REG_ADDRESS_OF_DATA_AFTER_CODE: u8 = 0x10; + const REG_START_OF_LOADED_CODE: u8 = 0x11; + const REG_GENERAL_USE: u8 = 0x12; + let get_instructions = |num_of_instructions| { + // There are 3 main steps: + // 1. Load the blob content into memory + // 2. Load the data section right after the blob + // 3. Jump to the beginning of the memory where the blob was loaded + [ + // 1. Load the blob content into memory + // Find the start of the hardcoded blob ID, which is located after the loader code ends. + op::move_(REG_ADDRESS_OF_DATA_AFTER_CODE, RegId::PC), + // hold the address of the blob ID. + op::addi( + REG_ADDRESS_OF_DATA_AFTER_CODE, + REG_ADDRESS_OF_DATA_AFTER_CODE, + num_of_instructions * Instruction::SIZE as u16, + ), + // The code is going to be loaded from the current value of SP onwards, save + // the location into REG_START_OF_LOADED_CODE so we can jump into it at the end. + op::move_(REG_START_OF_LOADED_CODE, RegId::SP), + // REG_GENERAL_USE to hold the size of the blob. + op::bsiz(REG_GENERAL_USE, REG_ADDRESS_OF_DATA_AFTER_CODE), + // Push the blob contents onto the stack. + op::ldc(REG_ADDRESS_OF_DATA_AFTER_CODE, 0, REG_GENERAL_USE, 1), + // Move on to the data section length + op::addi( + REG_ADDRESS_OF_DATA_AFTER_CODE, + REG_ADDRESS_OF_DATA_AFTER_CODE, + BLOB_ID_SIZE, + ), + // load the size of the data section into REG_GENERAL_USE + op::lw(REG_GENERAL_USE, REG_ADDRESS_OF_DATA_AFTER_CODE, 0), + // after we have read the length of the data section, we move the pointer to the actual + // data by skipping WORD_SIZE B. + op::addi( + REG_ADDRESS_OF_DATA_AFTER_CODE, + REG_ADDRESS_OF_DATA_AFTER_CODE, + WORD_SIZE as u16, + ), + // load the data section of the executable + op::ldc(REG_ADDRESS_OF_DATA_AFTER_CODE, 0, REG_GENERAL_USE, 2), + // Jump into the memory where the contract is loaded. + // What follows is called _jmp_mem by the sway compiler. + // Subtract the address contained in IS because jmp will add it back. + op::sub( + REG_START_OF_LOADED_CODE, + REG_START_OF_LOADED_CODE, + RegId::IS, + ), + // jmp will multiply by 4, so we need to divide to cancel that out. + op::divi(REG_START_OF_LOADED_CODE, REG_START_OF_LOADED_CODE, 4), + // Jump to the start of the contract we loaded. + op::jmp(REG_START_OF_LOADED_CODE), + ] + }; + + let offset = extract_data_offset(binary)?; + + if binary.len() < offset { + anyhow::bail!("data sectio offset is out of bounds"); + } + + let data_section = binary[offset..].to_vec(); + + if !data_section.is_empty() { + let num_of_instructions = u16::try_from(get_instructions(0).len()) + .expect("to never have more than u16::MAX instructions"); + + let instruction_bytes = get_instructions(num_of_instructions) + .into_iter() + .flat_map(|instruction| instruction.to_bytes()); + + let blob_bytes = blob_id.iter().copied(); + + let loader_offset = + instruction_bytes.count() + blob_bytes.count() + data_section.len().to_be_bytes().len(); + + Ok(Some(loader_offset)) + } else { + Ok(None) + } +} + +/// Builds and deploys executable (script and predicate) package(s) as blobs, +/// and generates a loader for each of them. +pub async fn deploy_executables( + command: &cmd::Deploy, + executables_to_deploy: &[Arc], +) -> Result> { + let mut deployed_executable = vec![]; + if executables_to_deploy.is_empty() { + return Ok(deployed_executable); + } + + let node_url = validate_and_get_node_url(command, executables_to_deploy).await?; + // We will have 1 transaction per executable as each deployment uses a single blob. + let tx_count = executables_to_deploy.len(); + let account = setup_deployment_account(command, &node_url, tx_count).await?; + + for pkg in executables_to_deploy { + let script = Executable::from_bytes(pkg.bytecode.bytes.clone()); + let loader = script.convert_to_loader()?; + println_action_green("Uploading", "blob containing executable bytecode."); + loader.upload_blob(account.clone()).await?; + println_action_green("Generating", "loader bytecode for the uploaded executable."); + let loader_bytecode = loader.code(); + let pkg_name = &pkg.descriptor.name; + let out_dir = pkg.descriptor.manifest_file.dir().join("out"); + let bin_path = out_dir.join(format!("{pkg_name}-loader.bin")); + std::fs::write(&bin_path, &loader_bytecode)?; + println_action_green( + "Saved", + &format!("loader bytecode at {}", bin_path.display()), + ); + if let Some(loader_data_section_offset) = + loader_data_offset(&pkg.bytecode.bytes, &BlobId::default())? + { + if let ProgramABI::Fuel(mut fuel_abi) = pkg.program_abi.clone() { + println_action_green("Generating", "loader abi for the uploaded executable."); + let json_abi_path = out_dir.join(format!("{pkg_name}-loader-abi.json")); + let original_data_section = extract_data_offset(&pkg.bytecode.bytes).unwrap(); + let offset_shift = original_data_section - loader_data_section_offset; + // if there are configurables in the abi we need to shift them by `offset_shift`. + let configurables = fuel_abi.configurables.clone().map(|configs| { + configs + .into_iter() + .map(|config| Configurable { + offset: config.offset - offset_shift as u64, + ..config.clone() + }) + .collect() + }); + fuel_abi.configurables = configurables; + let json_string = serde_json::to_string_pretty(&fuel_abi)?; + std::fs::write(json_abi_path, json_string)?; + } + } + // If the executable is a predicate, we also want to display and save the predicate root. + if pkg + .descriptor + .manifest_file + .program_type() + .with_context(|| { + "error while trying to retrieve program type for executable deployment." + })? + == TreeType::Predicate + { + // Calculate the root. + let root = format!("0x{}", fuel_tx::Input::predicate_owner(&loader_bytecode)); + // Root files are named in `pkg-name-root` format, since this is a + // loader we are also adding an identifier to differentiate it from + // the root of the "original" predicate. + let root_file_name = format!("{}-loader-root", &pkg_name); + let root_path = out_dir.join(root_file_name); + std::fs::write(&root_path, &root)?; + println_action_green( + "Saved", + &format!("loader root ({}) at {}", root, root_path.display()), + ); + } + let deployed = DeployedExecutable { + bytecode: loader_bytecode, + }; + deployed_executable.push(deployed); + println_action_green("Finished", &format!("deploying executable {pkg_name}")); + } + Ok(deployed_executable) +} + +fn extract_data_offset(binary: &[u8]) -> Result { + if binary.len() < 16 { + anyhow::bail!( + "given binary is too short to contain a data offset, len: {}", + binary.len() + ); + } + + let data_offset: [u8; 8] = binary[8..16].try_into().expect("checked above"); + + Ok(u64::from_be_bytes(data_offset) as usize) +} + +/// Builds and deploys contract(s). If the given path corresponds to a workspace, all deployable members +/// will be built and deployed. +/// +/// Upon success, returns the ID of each deployed contract in order of deployment. +/// +/// When deploying a single contract, only that contract's ID is returned. +pub async fn deploy_contracts( + command: &cmd::Deploy, + contracts_to_deploy: &[Arc], +) -> Result> { + let mut deployed_contracts = Vec::new(); + + if contracts_to_deploy.is_empty() { return Ok(deployed_contracts); } let contract_salt_map = if let Some(salt_input) = &command.salt { // If we're building 1 package, we just parse the salt as a string, ie. 0x00... // If we're building >1 package, we must parse the salt as a pair of strings, ie. contract_name:0x00... - if built_pkgs.len() > 1 { + if contracts_to_deploy.len() > 1 { let map = validate_and_parse_salts( salt_input, - built_pkgs.iter().map(|b| &b.descriptor.manifest_file), + contracts_to_deploy + .iter() + .map(|b| &b.descriptor.manifest_file), )?; Some(map) @@ -310,7 +593,7 @@ pub async fn deploy(command: cmd::Deploy) -> Result> { .unwrap(); let mut contract_salt_map = ContractSaltMap::default(); contract_salt_map.insert( - built_pkgs[0] + contracts_to_deploy[0] .descriptor .manifest_file .project_name() @@ -323,23 +606,19 @@ pub async fn deploy(command: cmd::Deploy) -> Result> { None }; - // Ensure that all packages are being deployed to the same node. - let node_url = get_node_url( - &command.node, - &pkgs_to_deploy[0].descriptor.manifest_file.network, - )?; - if !pkgs_to_deploy.iter().all(|pkg| { - get_node_url(&command.node, &pkg.descriptor.manifest_file.network).ok() - == Some(node_url.clone()) - }) { - bail!("All contracts in a deployment should be deployed to the same node. Please ensure that the network specified in the Forc.toml files of all contracts is the same."); - } + let node_url = validate_and_get_node_url(command, contracts_to_deploy).await?; + let provider = Provider::connect(node_url.clone()).await?; // Confirmation step. Summarize the transaction(s) for the deployment. - let (provider, account) = - confirm_transaction_details(&pkgs_to_deploy, &command, node_url.clone()).await?; + let account = confirm_transaction_details( + contracts_to_deploy, + command, + node_url.clone(), + MAX_CONTRACT_SIZE, + ) + .await?; - for pkg in pkgs_to_deploy { + for pkg in contracts_to_deploy { let salt = match (&contract_salt_map, command.default_salt) { (Some(map), false) => { if let Some(salt) = map.get(pkg.descriptor.manifest_file.project_name()) { @@ -361,7 +640,7 @@ pub async fn deploy(command: cmd::Deploy) -> Result> { let provider = Provider::connect(node_url).await?; deploy_chunked( - &command, + command, pkg, salt, &account, @@ -370,7 +649,7 @@ pub async fn deploy(command: cmd::Deploy) -> Result> { ) .await? } else { - deploy_pkg(&command, pkg, salt, &provider, &account).await? + deploy_pkg(command, pkg, salt, &provider, &account).await? }; let proxy_id = match &pkg.descriptor.manifest_file.proxy { @@ -397,7 +676,7 @@ pub async fn deploy(command: cmd::Deploy) -> Result> { let pkg_storage_slots = &pkg.storage_slots; // Deploy a new proxy contract. let deployed_proxy_contract = deploy_new_proxy( - &command, + command, pkg_name, pkg_storage_slots, &deployed_contract_id, @@ -429,10 +708,11 @@ pub async fn deploy(command: cmd::Deploy) -> Result> { /// Prompt the user to confirm the transactions required for deployment, as well as the signing key. async fn confirm_transaction_details( - pkgs_to_deploy: &[&Arc], + pkgs_to_deploy: &[Arc], command: &cmd::Deploy, node_url: String, -) -> Result<(Provider, ForcClientAccount)> { + max_contract_size: usize, +) -> Result { // Confirmation step. Summarize the transaction(s) for the deployment. let mut tx_count = 0; let tx_summary = pkgs_to_deploy @@ -455,8 +735,8 @@ async fn confirm_transaction_details( }; let pkg_bytecode_len = pkg.bytecode.bytes.len(); - let blob_text = if pkg_bytecode_len > MAX_CONTRACT_SIZE { - let number_of_blobs = pkg_bytecode_len.div_ceil(MAX_CONTRACT_SIZE); + let blob_text = if pkg_bytecode_len > max_contract_size { + let number_of_blobs = pkg_bytecode_len.div_ceil(max_contract_size); tx_count += number_of_blobs; &format!(" + {number_of_blobs} blobs") } else { @@ -474,31 +754,12 @@ async fn confirm_transaction_details( println_action_green("Confirming", &format!("transactions [{tx_summary}]")); println_action_green("", &format!("Network: {node_url}")); - let provider = Provider::connect(node_url.clone()).await?; - - let wallet_mode = if command.default_signer || command.signing_key.is_some() { - SignerSelectionMode::Manual - } else if let Some(arn) = &command.aws_kms_signer { - SignerSelectionMode::AwsSigner(arn.clone()) - } else { - println_action_green("", &format!("Wallet: {}", default_wallet_path().display())); - let password = prompt_forc_wallet_password()?; - SignerSelectionMode::ForcWallet(password) - }; + let account = setup_deployment_account(command, &node_url, tx_count).await?; // TODO: Display the estimated gas cost of the transaction(s). // https://github.com/FuelLabs/sway/issues/6277 - let account = select_account( - &wallet_mode, - command.default_signer || command.unsigned, - command.signing_key, - &provider, - tx_count, - ) - .await?; - - Ok((provider.clone(), account)) + Ok(account) } /// Deploy a single pkg given deploy command and the manifest file @@ -632,7 +893,7 @@ fn tx_policies_from_cmd(cmd: &cmd::Deploy) -> TxPolicies { tx_policies } -fn build_opts_from_cmd(cmd: &cmd::Deploy) -> pkg::BuildOpts { +fn build_opts_from_cmd(cmd: &cmd::Deploy, member_filter: pkg::MemberFilter) -> pkg::BuildOpts { pkg::BuildOpts { pkg: pkg::PkgOpts { path: cmd.pkg.path.clone(), @@ -665,7 +926,7 @@ fn build_opts_from_cmd(cmd: &cmd::Deploy) -> pkg::BuildOpts { debug_outfile: cmd.build_output.debug_file.clone(), build_target: BuildTarget::default(), tests: false, - member_filter: pkg::MemberFilter::only_contracts(), + member_filter, experimental: ExperimentalFlags { new_encoding: !cmd.no_encoding_v1, }, @@ -715,6 +976,50 @@ fn create_deployment_artifact( deployment_artifact.to_file(&output_dir, pkg_name, contract_id) } +/// Validates that all packages are being deployed to the same node and returns the node URL. +async fn validate_and_get_node_url( + command: &cmd::Deploy, + packages: &[Arc], +) -> Result { + let node_url = get_node_url(&command.node, &packages[0].descriptor.manifest_file.network)?; + if !packages.iter().all(|pkg| { + get_node_url(&command.node, &pkg.descriptor.manifest_file.network).ok() + == Some(node_url.clone()) + }) { + bail!("All packages in a deployment should be deployed to the same node. Please ensure that the network specified in the Forc.toml files of all packages is the same."); + } + Ok(node_url) +} + +/// Sets up and returns the account for deployment. +async fn setup_deployment_account( + command: &cmd::Deploy, + node_url: &str, + tx_count: usize, +) -> Result { + let provider = Provider::connect(node_url).await?; + + let wallet_mode = if command.default_signer || command.signing_key.is_some() { + SignerSelectionMode::Manual + } else if let Some(arn) = &command.aws_kms_signer { + SignerSelectionMode::AwsSigner(arn.clone()) + } else { + println_action_green("", &format!("Wallet: {}", default_wallet_path().display())); + let password = prompt_forc_wallet_password()?; + SignerSelectionMode::ForcWallet(password) + }; + + let account = select_account( + &wallet_mode, + command.default_signer || command.unsigned, + command.signing_key, + &provider, + tx_count, + ) + .await?; + + Ok(account) +} #[cfg(test)] mod test { use super::*; diff --git a/forc-plugins/forc-client/src/op/mod.rs b/forc-plugins/forc-client/src/op/mod.rs index 44a1b055551..f11f8c63b7c 100644 --- a/forc-plugins/forc-client/src/op/mod.rs +++ b/forc-plugins/forc-client/src/op/mod.rs @@ -2,6 +2,6 @@ mod deploy; mod run; mod submit; -pub use deploy::{deploy, DeployedContract}; +pub use deploy::{deploy, DeployedContract, DeployedExecutable, DeployedPackage}; pub use run::run; pub use submit::submit; diff --git a/forc-plugins/forc-client/test/data/deployed_predicate/.gitignore b/forc-plugins/forc-client/test/data/deployed_predicate/.gitignore new file mode 100644 index 00000000000..77d3844f58c --- /dev/null +++ b/forc-plugins/forc-client/test/data/deployed_predicate/.gitignore @@ -0,0 +1,2 @@ +out +target diff --git a/forc-plugins/forc-client/test/data/deployed_predicate/Forc.lock b/forc-plugins/forc-client/test/data/deployed_predicate/Forc.lock new file mode 100644 index 00000000000..2be3d70a3ca --- /dev/null +++ b/forc-plugins/forc-client/test/data/deployed_predicate/Forc.lock @@ -0,0 +1,13 @@ +[[package]] +name = "core" +source = "path+from-root-661979F06117CBCE" + +[[package]] +name = "deployed_predicate" +source = "member" +dependencies = ["std"] + +[[package]] +name = "std" +source = "path+from-root-661979F06117CBCE" +dependencies = ["core"] diff --git a/forc-plugins/forc-client/test/data/deployed_predicate/Forc.toml b/forc-plugins/forc-client/test/data/deployed_predicate/Forc.toml new file mode 100644 index 00000000000..68b7cb9dff1 --- /dev/null +++ b/forc-plugins/forc-client/test/data/deployed_predicate/Forc.toml @@ -0,0 +1,8 @@ +[project] +authors = ["Fuel Labs "] +entry = "main.sw" +license = "Apache-2.0" +name = "deployed_predicate" + +[dependencies] +std = { path = "../../../../../sway-lib-std/" } diff --git a/forc-plugins/forc-client/test/data/deployed_predicate/deployed_predicate-abi.json b/forc-plugins/forc-client/test/data/deployed_predicate/deployed_predicate-abi.json new file mode 100644 index 00000000000..f38d1dbedd6 --- /dev/null +++ b/forc-plugins/forc-client/test/data/deployed_predicate/deployed_predicate-abi.json @@ -0,0 +1,128 @@ +{ + "programType": "predicate", + "specVersion": "1", + "encodingVersion": "1", + "concreteTypes": [ + { + "type": "bool", + "concreteTypeId": "b760f44fa5965c2474a3b471467a22c43185152129295af588b022ae50b50903" + }, + { + "type": "enum EnumWithGeneric", + "concreteTypeId": "37cd1cba311039a851ac8bfa614cc41359b4ad95c8656fcef2e8f504fe7a1272", + "metadataTypeId": 1, + "typeArguments": [ + "b760f44fa5965c2474a3b471467a22c43185152129295af588b022ae50b50903" + ] + }, + { + "type": "struct StructWithGeneric", + "concreteTypeId": "563310524b4f4447a10d0e50556310253dfb3b5eb4b29c3773222b737c8b7075", + "metadataTypeId": 3, + "typeArguments": [ + "c89951a24c6ca28c13fd1cfdc646b2b656d69e61a92b91023be7eb58eb914b6b" + ] + }, + { + "type": "u8", + "concreteTypeId": "c89951a24c6ca28c13fd1cfdc646b2b656d69e61a92b91023be7eb58eb914b6b" + } + ], + "metadataTypes": [ + { + "type": "()", + "metadataTypeId": 0 + }, + { + "type": "enum EnumWithGeneric", + "metadataTypeId": 1, + "components": [ + { + "name": "VariantOne", + "typeId": 2 + }, + { + "name": "VariantTwo", + "typeId": 0 + } + ], + "typeParameters": [ + 2 + ] + }, + { + "type": "generic D", + "metadataTypeId": 2 + }, + { + "type": "struct StructWithGeneric", + "metadataTypeId": 3, + "components": [ + { + "name": "field_1", + "typeId": 2 + }, + { + "name": "field_2", + "typeId": 4 + } + ], + "typeParameters": [ + 2 + ] + }, + { + "type": "u64", + "metadataTypeId": 4 + } + ], + "functions": [ + { + "inputs": [ + { + "name": "switch", + "concreteTypeId": "b760f44fa5965c2474a3b471467a22c43185152129295af588b022ae50b50903" + }, + { + "name": "u_8", + "concreteTypeId": "c89951a24c6ca28c13fd1cfdc646b2b656d69e61a92b91023be7eb58eb914b6b" + }, + { + "name": "some_struct", + "concreteTypeId": "563310524b4f4447a10d0e50556310253dfb3b5eb4b29c3773222b737c8b7075" + }, + { + "name": "some_enum", + "concreteTypeId": "37cd1cba311039a851ac8bfa614cc41359b4ad95c8656fcef2e8f504fe7a1272" + } + ], + "name": "main", + "output": "b760f44fa5965c2474a3b471467a22c43185152129295af588b022ae50b50903", + "attributes": null + } + ], + "loggedTypes": [], + "messagesTypes": [], + "configurables": [ + { + "name": "BOOL", + "concreteTypeId": "b760f44fa5965c2474a3b471467a22c43185152129295af588b022ae50b50903", + "offset": 1896 + }, + { + "name": "U8", + "concreteTypeId": "c89951a24c6ca28c13fd1cfdc646b2b656d69e61a92b91023be7eb58eb914b6b", + "offset": 1936 + }, + { + "name": "STRUCT", + "concreteTypeId": "563310524b4f4447a10d0e50556310253dfb3b5eb4b29c3773222b737c8b7075", + "offset": 1920 + }, + { + "name": "ENUM", + "concreteTypeId": "37cd1cba311039a851ac8bfa614cc41359b4ad95c8656fcef2e8f504fe7a1272", + "offset": 1904 + } + ] +} \ No newline at end of file diff --git a/forc-plugins/forc-client/test/data/deployed_predicate/src/main.sw b/forc-plugins/forc-client/test/data/deployed_predicate/src/main.sw new file mode 100644 index 00000000000..f33b61faf40 --- /dev/null +++ b/forc-plugins/forc-client/test/data/deployed_predicate/src/main.sw @@ -0,0 +1,53 @@ +predicate; + +#[allow(dead_code)] +enum EnumWithGeneric { + VariantOne: D, + VariantTwo: (), +} + +struct StructWithGeneric { + field_1: D, + field_2: u64, +} + +impl Eq for EnumWithGeneric +where + D: Eq, +{ + fn eq(self, other: Self) -> bool { + match (self, other) { + (EnumWithGeneric::VariantOne(d1), EnumWithGeneric::VariantOne(d2)) => d1 == d2, + (EnumWithGeneric::VariantTwo, EnumWithGeneric::VariantTwo) => true, + _ => false, + } + } +} + +impl Eq for StructWithGeneric +where + D: Eq, +{ + fn eq(self, other: Self) -> bool { + self.field_1 == other.field_1 && self.field_2 == other.field_2 + } +} + +configurable { + BOOL: bool = true, + U8: u8 = 8, + STRUCT: StructWithGeneric = StructWithGeneric { + field_1: 8, + field_2: 16, + }, + ENUM: EnumWithGeneric = EnumWithGeneric::VariantOne(true), +} + +fn main( + switch: bool, + u_8: u8, + some_struct: StructWithGeneric, + some_enum: EnumWithGeneric, +) -> bool { + switch == BOOL && u_8 == U8 && some_struct == STRUCT && some_enum == ENUM +} diff --git a/forc-plugins/forc-client/test/data/deployed_script/.gitignore b/forc-plugins/forc-client/test/data/deployed_script/.gitignore new file mode 100644 index 00000000000..77d3844f58c --- /dev/null +++ b/forc-plugins/forc-client/test/data/deployed_script/.gitignore @@ -0,0 +1,2 @@ +out +target diff --git a/forc-plugins/forc-client/test/data/deployed_script/Forc.toml b/forc-plugins/forc-client/test/data/deployed_script/Forc.toml new file mode 100644 index 00000000000..3eb3cdf653b --- /dev/null +++ b/forc-plugins/forc-client/test/data/deployed_script/Forc.toml @@ -0,0 +1,8 @@ +[project] +authors = ["Fuel Labs "] +entry = "main.sw" +license = "Apache-2.0" +name = "deployed_script" + +[dependencies] +std = { path = "../../../../../sway-lib-std/" } diff --git a/forc-plugins/forc-client/test/data/deployed_script/deployed_script-abi.json b/forc-plugins/forc-client/test/data/deployed_script/deployed_script-abi.json new file mode 100644 index 00000000000..7689a658d2a --- /dev/null +++ b/forc-plugins/forc-client/test/data/deployed_script/deployed_script-abi.json @@ -0,0 +1,312 @@ +{ + "programType": "script", + "specVersion": "1", + "encodingVersion": "1", + "concreteTypes": [ + { + "type": "((bool, u8, u16, u32, u64, u256, b256, str[4], (u8, bool), [u32; 3], struct StructWithGeneric, enum EnumWithGeneric), bool, u64, u8)", + "concreteTypeId": "25fbba860b8a1983ebcfa3f135136266a7edb7ca3a7e1f8ec988135c12a9f873", + "metadataTypeId": 2 + }, + { + "type": "(u8, bool)", + "concreteTypeId": "e0128f7be9902d1fe16326cafe703b52038064a7997b03ebfc1c9dd607e1536c", + "metadataTypeId": 1 + }, + { + "type": "[u32; 3]", + "concreteTypeId": "d9fac01ab38fe10950758ae9604da330d6406a71fda3ef1ea818121261132d56", + "metadataTypeId": 4 + }, + { + "type": "b256", + "concreteTypeId": "7c5ee1cecf5f8eacd1284feb5f0bf2bdea533a51e2f0c9aabe9236d335989f3b" + }, + { + "type": "bool", + "concreteTypeId": "b760f44fa5965c2474a3b471467a22c43185152129295af588b022ae50b50903" + }, + { + "type": "enum EnumWithGeneric", + "concreteTypeId": "37cd1cba311039a851ac8bfa614cc41359b4ad95c8656fcef2e8f504fe7a1272", + "metadataTypeId": 5, + "typeArguments": [ + "b760f44fa5965c2474a3b471467a22c43185152129295af588b022ae50b50903" + ] + }, + { + "type": "str[4]", + "concreteTypeId": "94f0fa95c830be5e4f711963e83259fe7e8bc723278ab6ec34449e791a99b53a" + }, + { + "type": "struct StructWithGeneric", + "concreteTypeId": "563310524b4f4447a10d0e50556310253dfb3b5eb4b29c3773222b737c8b7075", + "metadataTypeId": 7, + "typeArguments": [ + "c89951a24c6ca28c13fd1cfdc646b2b656d69e61a92b91023be7eb58eb914b6b" + ] + }, + { + "type": "u16", + "concreteTypeId": "29881aad8730c5ab11d275376323d8e4ff4179aae8ccb6c13fe4902137e162ef" + }, + { + "type": "u256", + "concreteTypeId": "1b5759d94094368cfd443019e7ca5ec4074300e544e5ea993a979f5da627261e" + }, + { + "type": "u32", + "concreteTypeId": "d7649d428b9ff33d188ecbf38a7e4d8fd167fa01b2e10fe9a8f9308e52f1d7cc" + }, + { + "type": "u64", + "concreteTypeId": "1506e6f44c1d6291cdf46395a8e573276a4fa79e8ace3fc891e092ef32d1b0a0" + }, + { + "type": "u8", + "concreteTypeId": "c89951a24c6ca28c13fd1cfdc646b2b656d69e61a92b91023be7eb58eb914b6b" + } + ], + "metadataTypes": [ + { + "type": "()", + "metadataTypeId": 0 + }, + { + "type": "(_, _)", + "metadataTypeId": 1, + "components": [ + { + "name": "__tuple_element", + "typeId": "c89951a24c6ca28c13fd1cfdc646b2b656d69e61a92b91023be7eb58eb914b6b" + }, + { + "name": "__tuple_element", + "typeId": "b760f44fa5965c2474a3b471467a22c43185152129295af588b022ae50b50903" + } + ] + }, + { + "type": "(_, _, _, _)", + "metadataTypeId": 2, + "components": [ + { + "name": "__tuple_element", + "typeId": 3 + }, + { + "name": "__tuple_element", + "typeId": "b760f44fa5965c2474a3b471467a22c43185152129295af588b022ae50b50903" + }, + { + "name": "__tuple_element", + "typeId": "1506e6f44c1d6291cdf46395a8e573276a4fa79e8ace3fc891e092ef32d1b0a0" + }, + { + "name": "__tuple_element", + "typeId": "c89951a24c6ca28c13fd1cfdc646b2b656d69e61a92b91023be7eb58eb914b6b" + } + ] + }, + { + "type": "(_, _, _, _, _, _, _, _, _, _, _, _)", + "metadataTypeId": 3, + "components": [ + { + "name": "__tuple_element", + "typeId": "b760f44fa5965c2474a3b471467a22c43185152129295af588b022ae50b50903" + }, + { + "name": "__tuple_element", + "typeId": "c89951a24c6ca28c13fd1cfdc646b2b656d69e61a92b91023be7eb58eb914b6b" + }, + { + "name": "__tuple_element", + "typeId": "29881aad8730c5ab11d275376323d8e4ff4179aae8ccb6c13fe4902137e162ef" + }, + { + "name": "__tuple_element", + "typeId": "d7649d428b9ff33d188ecbf38a7e4d8fd167fa01b2e10fe9a8f9308e52f1d7cc" + }, + { + "name": "__tuple_element", + "typeId": "1506e6f44c1d6291cdf46395a8e573276a4fa79e8ace3fc891e092ef32d1b0a0" + }, + { + "name": "__tuple_element", + "typeId": "1b5759d94094368cfd443019e7ca5ec4074300e544e5ea993a979f5da627261e" + }, + { + "name": "__tuple_element", + "typeId": "7c5ee1cecf5f8eacd1284feb5f0bf2bdea533a51e2f0c9aabe9236d335989f3b" + }, + { + "name": "__tuple_element", + "typeId": "94f0fa95c830be5e4f711963e83259fe7e8bc723278ab6ec34449e791a99b53a" + }, + { + "name": "__tuple_element", + "typeId": 1 + }, + { + "name": "__tuple_element", + "typeId": 4 + }, + { + "name": "__tuple_element", + "typeId": 7, + "typeArguments": [ + { + "name": "", + "typeId": "c89951a24c6ca28c13fd1cfdc646b2b656d69e61a92b91023be7eb58eb914b6b" + } + ] + }, + { + "name": "__tuple_element", + "typeId": 5, + "typeArguments": [ + { + "name": "", + "typeId": "b760f44fa5965c2474a3b471467a22c43185152129295af588b022ae50b50903" + } + ] + } + ] + }, + { + "type": "[_; 3]", + "metadataTypeId": 4, + "components": [ + { + "name": "__array_element", + "typeId": "d7649d428b9ff33d188ecbf38a7e4d8fd167fa01b2e10fe9a8f9308e52f1d7cc" + } + ] + }, + { + "type": "enum EnumWithGeneric", + "metadataTypeId": 5, + "components": [ + { + "name": "VariantOne", + "typeId": 6 + }, + { + "name": "VariantTwo", + "typeId": 0 + } + ], + "typeParameters": [ + 6 + ] + }, + { + "type": "generic D", + "metadataTypeId": 6 + }, + { + "type": "struct StructWithGeneric", + "metadataTypeId": 7, + "components": [ + { + "name": "field_1", + "typeId": 6 + }, + { + "name": "field_2", + "typeId": "1506e6f44c1d6291cdf46395a8e573276a4fa79e8ace3fc891e092ef32d1b0a0" + } + ], + "typeParameters": [ + 6 + ] + } + ], + "functions": [ + { + "inputs": [ + { + "name": "a", + "concreteTypeId": "d7649d428b9ff33d188ecbf38a7e4d8fd167fa01b2e10fe9a8f9308e52f1d7cc" + }, + { + "name": "contract_addr", + "concreteTypeId": "7c5ee1cecf5f8eacd1284feb5f0bf2bdea533a51e2f0c9aabe9236d335989f3b" + } + ], + "name": "main", + "output": "25fbba860b8a1983ebcfa3f135136266a7edb7ca3a7e1f8ec988135c12a9f873", + "attributes": null + } + ], + "loggedTypes": [ + { + "logId": "14454674236531057292", + "concreteTypeId": "c89951a24c6ca28c13fd1cfdc646b2b656d69e61a92b91023be7eb58eb914b6b" + } + ], + "messagesTypes": [], + "configurables": [ + { + "name": "BOOL", + "concreteTypeId": "b760f44fa5965c2474a3b471467a22c43185152129295af588b022ae50b50903", + "offset": 8560 + }, + { + "name": "U8", + "concreteTypeId": "c89951a24c6ca28c13fd1cfdc646b2b656d69e61a92b91023be7eb58eb914b6b", + "offset": 8672 + }, + { + "name": "U16", + "concreteTypeId": "29881aad8730c5ab11d275376323d8e4ff4179aae8ccb6c13fe4902137e162ef", + "offset": 8616 + }, + { + "name": "U32", + "concreteTypeId": "d7649d428b9ff33d188ecbf38a7e4d8fd167fa01b2e10fe9a8f9308e52f1d7cc", + "offset": 8656 + }, + { + "name": "U64", + "concreteTypeId": "1506e6f44c1d6291cdf46395a8e573276a4fa79e8ace3fc891e092ef32d1b0a0", + "offset": 8664 + }, + { + "name": "U256", + "concreteTypeId": "1b5759d94094368cfd443019e7ca5ec4074300e544e5ea993a979f5da627261e", + "offset": 8624 + }, + { + "name": "B256", + "concreteTypeId": "7c5ee1cecf5f8eacd1284feb5f0bf2bdea533a51e2f0c9aabe9236d335989f3b", + "offset": 8528 + }, + { + "name": "STR_4", + "concreteTypeId": "94f0fa95c830be5e4f711963e83259fe7e8bc723278ab6ec34449e791a99b53a", + "offset": 8600 + }, + { + "name": "TUPLE", + "concreteTypeId": "e0128f7be9902d1fe16326cafe703b52038064a7997b03ebfc1c9dd607e1536c", + "offset": 8608 + }, + { + "name": "ARRAY", + "concreteTypeId": "d9fac01ab38fe10950758ae9604da330d6406a71fda3ef1ea818121261132d56", + "offset": 8512 + }, + { + "name": "STRUCT", + "concreteTypeId": "563310524b4f4447a10d0e50556310253dfb3b5eb4b29c3773222b737c8b7075", + "offset": 8584 + }, + { + "name": "ENUM", + "concreteTypeId": "37cd1cba311039a851ac8bfa614cc41359b4ad95c8656fcef2e8f504fe7a1272", + "offset": 8568 + } + ] +} \ No newline at end of file diff --git a/forc-plugins/forc-client/test/data/deployed_script/deployed_script-loader-abi.json b/forc-plugins/forc-client/test/data/deployed_script/deployed_script-loader-abi.json new file mode 100644 index 00000000000..81b65c43cd7 --- /dev/null +++ b/forc-plugins/forc-client/test/data/deployed_script/deployed_script-loader-abi.json @@ -0,0 +1,312 @@ +{ + "programType": "script", + "specVersion": "1", + "encodingVersion": "1", + "concreteTypes": [ + { + "type": "((bool, u8, u16, u32, u64, u256, b256, str[4], (u8, bool), [u32; 3], struct StructWithGeneric, enum EnumWithGeneric), bool, u64, u8)", + "concreteTypeId": "25fbba860b8a1983ebcfa3f135136266a7edb7ca3a7e1f8ec988135c12a9f873", + "metadataTypeId": 2 + }, + { + "type": "(u8, bool)", + "concreteTypeId": "e0128f7be9902d1fe16326cafe703b52038064a7997b03ebfc1c9dd607e1536c", + "metadataTypeId": 1 + }, + { + "type": "[u32; 3]", + "concreteTypeId": "d9fac01ab38fe10950758ae9604da330d6406a71fda3ef1ea818121261132d56", + "metadataTypeId": 4 + }, + { + "type": "b256", + "concreteTypeId": "7c5ee1cecf5f8eacd1284feb5f0bf2bdea533a51e2f0c9aabe9236d335989f3b" + }, + { + "type": "bool", + "concreteTypeId": "b760f44fa5965c2474a3b471467a22c43185152129295af588b022ae50b50903" + }, + { + "type": "enum EnumWithGeneric", + "concreteTypeId": "37cd1cba311039a851ac8bfa614cc41359b4ad95c8656fcef2e8f504fe7a1272", + "metadataTypeId": 5, + "typeArguments": [ + "b760f44fa5965c2474a3b471467a22c43185152129295af588b022ae50b50903" + ] + }, + { + "type": "str[4]", + "concreteTypeId": "94f0fa95c830be5e4f711963e83259fe7e8bc723278ab6ec34449e791a99b53a" + }, + { + "type": "struct StructWithGeneric", + "concreteTypeId": "563310524b4f4447a10d0e50556310253dfb3b5eb4b29c3773222b737c8b7075", + "metadataTypeId": 7, + "typeArguments": [ + "c89951a24c6ca28c13fd1cfdc646b2b656d69e61a92b91023be7eb58eb914b6b" + ] + }, + { + "type": "u16", + "concreteTypeId": "29881aad8730c5ab11d275376323d8e4ff4179aae8ccb6c13fe4902137e162ef" + }, + { + "type": "u256", + "concreteTypeId": "1b5759d94094368cfd443019e7ca5ec4074300e544e5ea993a979f5da627261e" + }, + { + "type": "u32", + "concreteTypeId": "d7649d428b9ff33d188ecbf38a7e4d8fd167fa01b2e10fe9a8f9308e52f1d7cc" + }, + { + "type": "u64", + "concreteTypeId": "1506e6f44c1d6291cdf46395a8e573276a4fa79e8ace3fc891e092ef32d1b0a0" + }, + { + "type": "u8", + "concreteTypeId": "c89951a24c6ca28c13fd1cfdc646b2b656d69e61a92b91023be7eb58eb914b6b" + } + ], + "metadataTypes": [ + { + "type": "()", + "metadataTypeId": 0 + }, + { + "type": "(_, _)", + "metadataTypeId": 1, + "components": [ + { + "name": "__tuple_element", + "typeId": "c89951a24c6ca28c13fd1cfdc646b2b656d69e61a92b91023be7eb58eb914b6b" + }, + { + "name": "__tuple_element", + "typeId": "b760f44fa5965c2474a3b471467a22c43185152129295af588b022ae50b50903" + } + ] + }, + { + "type": "(_, _, _, _)", + "metadataTypeId": 2, + "components": [ + { + "name": "__tuple_element", + "typeId": 3 + }, + { + "name": "__tuple_element", + "typeId": "b760f44fa5965c2474a3b471467a22c43185152129295af588b022ae50b50903" + }, + { + "name": "__tuple_element", + "typeId": "1506e6f44c1d6291cdf46395a8e573276a4fa79e8ace3fc891e092ef32d1b0a0" + }, + { + "name": "__tuple_element", + "typeId": "c89951a24c6ca28c13fd1cfdc646b2b656d69e61a92b91023be7eb58eb914b6b" + } + ] + }, + { + "type": "(_, _, _, _, _, _, _, _, _, _, _, _)", + "metadataTypeId": 3, + "components": [ + { + "name": "__tuple_element", + "typeId": "b760f44fa5965c2474a3b471467a22c43185152129295af588b022ae50b50903" + }, + { + "name": "__tuple_element", + "typeId": "c89951a24c6ca28c13fd1cfdc646b2b656d69e61a92b91023be7eb58eb914b6b" + }, + { + "name": "__tuple_element", + "typeId": "29881aad8730c5ab11d275376323d8e4ff4179aae8ccb6c13fe4902137e162ef" + }, + { + "name": "__tuple_element", + "typeId": "d7649d428b9ff33d188ecbf38a7e4d8fd167fa01b2e10fe9a8f9308e52f1d7cc" + }, + { + "name": "__tuple_element", + "typeId": "1506e6f44c1d6291cdf46395a8e573276a4fa79e8ace3fc891e092ef32d1b0a0" + }, + { + "name": "__tuple_element", + "typeId": "1b5759d94094368cfd443019e7ca5ec4074300e544e5ea993a979f5da627261e" + }, + { + "name": "__tuple_element", + "typeId": "7c5ee1cecf5f8eacd1284feb5f0bf2bdea533a51e2f0c9aabe9236d335989f3b" + }, + { + "name": "__tuple_element", + "typeId": "94f0fa95c830be5e4f711963e83259fe7e8bc723278ab6ec34449e791a99b53a" + }, + { + "name": "__tuple_element", + "typeId": 1 + }, + { + "name": "__tuple_element", + "typeId": 4 + }, + { + "name": "__tuple_element", + "typeId": 7, + "typeArguments": [ + { + "name": "", + "typeId": "c89951a24c6ca28c13fd1cfdc646b2b656d69e61a92b91023be7eb58eb914b6b" + } + ] + }, + { + "name": "__tuple_element", + "typeId": 5, + "typeArguments": [ + { + "name": "", + "typeId": "b760f44fa5965c2474a3b471467a22c43185152129295af588b022ae50b50903" + } + ] + } + ] + }, + { + "type": "[_; 3]", + "metadataTypeId": 4, + "components": [ + { + "name": "__array_element", + "typeId": "d7649d428b9ff33d188ecbf38a7e4d8fd167fa01b2e10fe9a8f9308e52f1d7cc" + } + ] + }, + { + "type": "enum EnumWithGeneric", + "metadataTypeId": 5, + "components": [ + { + "name": "VariantOne", + "typeId": 6 + }, + { + "name": "VariantTwo", + "typeId": 0 + } + ], + "typeParameters": [ + 6 + ] + }, + { + "type": "generic D", + "metadataTypeId": 6 + }, + { + "type": "struct StructWithGeneric", + "metadataTypeId": 7, + "components": [ + { + "name": "field_1", + "typeId": 6 + }, + { + "name": "field_2", + "typeId": "1506e6f44c1d6291cdf46395a8e573276a4fa79e8ace3fc891e092ef32d1b0a0" + } + ], + "typeParameters": [ + 6 + ] + } + ], + "functions": [ + { + "inputs": [ + { + "name": "a", + "concreteTypeId": "d7649d428b9ff33d188ecbf38a7e4d8fd167fa01b2e10fe9a8f9308e52f1d7cc" + }, + { + "name": "contract_addr", + "concreteTypeId": "7c5ee1cecf5f8eacd1284feb5f0bf2bdea533a51e2f0c9aabe9236d335989f3b" + } + ], + "name": "main", + "output": "25fbba860b8a1983ebcfa3f135136266a7edb7ca3a7e1f8ec988135c12a9f873", + "attributes": null + } + ], + "loggedTypes": [ + { + "logId": "14454674236531057292", + "concreteTypeId": "c89951a24c6ca28c13fd1cfdc646b2b656d69e61a92b91023be7eb58eb914b6b" + } + ], + "messagesTypes": [], + "configurables": [ + { + "name": "BOOL", + "concreteTypeId": "b760f44fa5965c2474a3b471467a22c43185152129295af588b022ae50b50903", + "offset": 136 + }, + { + "name": "U8", + "concreteTypeId": "c89951a24c6ca28c13fd1cfdc646b2b656d69e61a92b91023be7eb58eb914b6b", + "offset": 248 + }, + { + "name": "U16", + "concreteTypeId": "29881aad8730c5ab11d275376323d8e4ff4179aae8ccb6c13fe4902137e162ef", + "offset": 192 + }, + { + "name": "U32", + "concreteTypeId": "d7649d428b9ff33d188ecbf38a7e4d8fd167fa01b2e10fe9a8f9308e52f1d7cc", + "offset": 232 + }, + { + "name": "U64", + "concreteTypeId": "1506e6f44c1d6291cdf46395a8e573276a4fa79e8ace3fc891e092ef32d1b0a0", + "offset": 240 + }, + { + "name": "U256", + "concreteTypeId": "1b5759d94094368cfd443019e7ca5ec4074300e544e5ea993a979f5da627261e", + "offset": 200 + }, + { + "name": "B256", + "concreteTypeId": "7c5ee1cecf5f8eacd1284feb5f0bf2bdea533a51e2f0c9aabe9236d335989f3b", + "offset": 104 + }, + { + "name": "STR_4", + "concreteTypeId": "94f0fa95c830be5e4f711963e83259fe7e8bc723278ab6ec34449e791a99b53a", + "offset": 176 + }, + { + "name": "TUPLE", + "concreteTypeId": "e0128f7be9902d1fe16326cafe703b52038064a7997b03ebfc1c9dd607e1536c", + "offset": 184 + }, + { + "name": "ARRAY", + "concreteTypeId": "d9fac01ab38fe10950758ae9604da330d6406a71fda3ef1ea818121261132d56", + "offset": 88 + }, + { + "name": "STRUCT", + "concreteTypeId": "563310524b4f4447a10d0e50556310253dfb3b5eb4b29c3773222b737c8b7075", + "offset": 160 + }, + { + "name": "ENUM", + "concreteTypeId": "37cd1cba311039a851ac8bfa614cc41359b4ad95c8656fcef2e8f504fe7a1272", + "offset": 144 + } + ] +} \ No newline at end of file diff --git a/forc-plugins/forc-client/test/data/deployed_script/deployed_script.bin b/forc-plugins/forc-client/test/data/deployed_script/deployed_script.bin new file mode 100644 index 00000000000..0daa7de8f3e Binary files /dev/null and b/forc-plugins/forc-client/test/data/deployed_script/deployed_script.bin differ diff --git a/forc-plugins/forc-client/test/data/deployed_script/src/main.sw b/forc-plugins/forc-client/test/data/deployed_script/src/main.sw new file mode 100644 index 00000000000..c47105d4d74 --- /dev/null +++ b/forc-plugins/forc-client/test/data/deployed_script/src/main.sw @@ -0,0 +1,72 @@ +script; + +use std::logging::log; + +#[allow(dead_code)] +enum EnumWithGeneric { + VariantOne: D, + VariantTwo: (), +} + +struct StructWithGeneric { + field_1: D, + field_2: u64, +} + +abi MyContract { + fn test_function() -> bool; + + #[storage(read)] + fn test_function_read() -> u8; + + #[storage(read, write)] + fn test_function_write(value: u8) -> u8; +} + +configurable { + BOOL: bool = true, + U8: u8 = 8, + U16: u16 = 16, + U32: u32 = 32, + U64: u64 = 63, + U256: u256 = 0x0000000000000000000000000000000000000000000000000000000000000008u256, + B256: b256 = 0x0101010101010101010101010101010101010101010101010101010101010101, + STR_4: str[4] = __to_str_array("fuel"), + TUPLE: (u8, bool) = (8, true), + ARRAY: [u32; 3] = [253, 254, 255], + STRUCT: StructWithGeneric = StructWithGeneric { + field_1: 8, + field_2: 16, + }, + ENUM: EnumWithGeneric = EnumWithGeneric::VariantOne(true), +} + +fn get_configurables() -> (bool, u8, u16, u32, u64, u256, b256, str[4], (u8, bool), [u32; 3], StructWithGeneric, EnumWithGeneric) { + (BOOL, U8, U16, U32, U64, U256, B256, STR_4, TUPLE, ARRAY, STRUCT, ENUM) +} + +fn basic_function_with_input(a: u32) -> bool { + if a % 2 == 0 { + true + }else { + false + } +} + +fn basic_function_without_input() -> u64 { + let a = 100; + let b = 25; + a*b +} + +fn main(a: u32, contract_addr: b256) -> ((bool, u8, u16, u32, u64, u256, b256, str[4], (u8, bool), [u32; 3], StructWithGeneric, EnumWithGeneric), bool, u64, u8) { + log(U8); + let configs = get_configurables(); + let with_in = basic_function_with_input(a); + let without_in = basic_function_without_input(); + + let contract_instance = abi(MyContract, contract_addr); + let from_contract = contract_instance.test_function_read(); + + return (configs, with_in, without_in, from_contract); +} diff --git a/forc-plugins/forc-client/tests/deploy.rs b/forc-plugins/forc-client/tests/deploy.rs index ca43d60e10c..3168fd286ae 100644 --- a/forc-plugins/forc-client/tests/deploy.rs +++ b/forc-plugins/forc-client/tests/deploy.rs @@ -1,7 +1,7 @@ use forc::cli::shared::Pkg; use forc_client::{ cmd, - op::{deploy, DeployedContract}, + op::{deploy, DeployedContract, DeployedExecutable, DeployedPackage}, util::{account::ForcClientAccount, tx::update_proxy_contract_target}, NodeTarget, }; @@ -10,9 +10,9 @@ use fuel_crypto::SecretKey; use fuel_tx::{ContractId, Salt}; use fuels::{ macros::abigen, - types::{transaction::TxPolicies, AsciiString, Bits256}, + types::{transaction::TxPolicies, AsciiString, Bits256, SizedAsciiString}, }; -use fuels_accounts::{provider::Provider, wallet::WalletUnlocked, Account}; +use fuels_accounts::{provider::Provider, wallet::WalletUnlocked, Account, ViewOnlyAccount}; use portpicker::Port; use rand::thread_rng; use rexpect::spawn; @@ -71,6 +71,37 @@ fn copy_dir(source: &Path, dest: &Path) -> anyhow::Result<()> { Ok(()) } +/// Tries to get an `DeployedContract` out of the given `DeployedPackage`. +/// Panics otherwise. +fn expect_deployed_contract(deployed_package: DeployedPackage) -> DeployedContract { + if let DeployedPackage::Contract(contract) = deployed_package { + contract + } else { + println!("{deployed_package:?}"); + panic!("expected deployed package to be a contract") + } +} + +/// Tries to get a script (`DeployedExecutable`) out of given deployed package. +/// Panics otherwise. +fn expect_deployed_script(deployed_package: DeployedPackage) -> DeployedExecutable { + if let DeployedPackage::Script(script) = deployed_package { + script + } else { + panic!("expected deployed package to be a script") + } +} + +/// Tries to get a predicate (`DeployedExecutable`) out of given deployed package. +/// Panics otherwise. +fn expect_deployed_predicate(deployed_package: DeployedPackage) -> DeployedExecutable { + if let DeployedPackage::Predicate(predicate) = deployed_package { + predicate + } else { + panic!("expected deployed package to be a predicate") + } +} + fn patch_manifest_file_with_path_std(manifest_dir: &Path) -> anyhow::Result<()> { let toml_path = manifest_dir.join(sway_utils::constants::MANIFEST_FILE_NAME); let toml_content = fs::read_to_string(&toml_path).unwrap(); @@ -339,14 +370,14 @@ async fn test_simple_deploy() { }; let contract_ids = deploy(cmd).await.unwrap(); node.kill().unwrap(); - let expected = vec![DeployedContract { + let expected = vec![DeployedPackage::Contract(DeployedContract { id: ContractId::from_str( "e50f0b4b396504398c0aff45951b1e44e108399c856cb92257dfa58fe96d53eb", ) .unwrap(), proxy: None, chunked: false, - }]; + })]; assert_eq!(contract_ids, expected) } @@ -381,14 +412,14 @@ async fn test_deploy_submit_only() { }; let contract_ids = deploy(cmd).await.unwrap(); node.kill().unwrap(); - let expected = vec![DeployedContract { + let expected = vec![DeployedPackage::Contract(DeployedContract { id: ContractId::from_str( "e50f0b4b396504398c0aff45951b1e44e108399c856cb92257dfa58fe96d53eb", ) .unwrap(), proxy: None, chunked: false, - }]; + })]; assert_eq!(contract_ids, expected) } @@ -426,7 +457,7 @@ async fn test_deploy_fresh_proxy() { }; let contract_ids = deploy(cmd).await.unwrap(); node.kill().unwrap(); - let impl_contract = DeployedContract { + let impl_contract = DeployedPackage::Contract(DeployedContract { id: ContractId::from_str( "e50f0b4b396504398c0aff45951b1e44e108399c856cb92257dfa58fe96d53eb", ) @@ -438,7 +469,7 @@ async fn test_deploy_fresh_proxy() { .unwrap(), ), chunked: false, - }; + }); let expected = vec![impl_contract]; assert_eq!(contract_ids, expected) @@ -475,10 +506,10 @@ async fn test_proxy_contract_re_routes_call() { default_signer: true, ..Default::default() }; - let contract_ids = deploy(cmd).await.unwrap(); + let deployed_contract = expect_deployed_contract(deploy(cmd).await.unwrap().remove(0)); // At this point we deployed a contract with proxy. - let proxy_contract_id = contract_ids[0].proxy.unwrap(); - let impl_contract_id = contract_ids[0].id; + let proxy_contract_id = deployed_contract.proxy.unwrap(); + let impl_contract_id = deployed_contract.id; // Make a contract call into proxy contract, and check if the initial // contract returns a true. let provider = Provider::connect(&node_url).await.unwrap(); @@ -537,11 +568,11 @@ async fn test_proxy_contract_re_routes_call() { default_signer: true, ..Default::default() }; - let contract_ids = deploy(cmd).await.unwrap(); + let deployed_contract = expect_deployed_contract(deploy(cmd).await.unwrap().remove(0)); // proxy contract id should be the same. - let proxy_contract_after_update = contract_ids[0].proxy.unwrap(); + let proxy_contract_after_update = deployed_contract.proxy.unwrap(); assert_eq!(proxy_contract_id, proxy_contract_after_update); - let impl_contract_id_after_update = contract_ids[0].id; + let impl_contract_id_after_update = deployed_contract.id; assert!(impl_contract_id != impl_contract_id_after_update); let impl_contract_a = ImplementationContract::new(proxy_contract_after_update, wallet_unlocked); @@ -606,9 +637,9 @@ async fn test_non_owner_fails_to_set_target() { default_signer: true, ..Default::default() }; - let contract_id = deploy(cmd).await.unwrap(); + let contract_id = expect_deployed_contract(deploy(cmd).await.unwrap().remove(0)); // Proxy contract's id. - let proxy_id = contract_id.first().and_then(|f| f.proxy).unwrap(); + let proxy_id = contract_id.proxy.unwrap(); // Create and fund an owner account and an attacker account. let provider = Provider::connect(&node_url).await.unwrap(); @@ -709,7 +740,7 @@ async fn chunked_deploy() { default_signer: true, ..Default::default() }; - let deployed_contract = deploy(cmd).await.unwrap().remove(0); + let deployed_contract = expect_deployed_contract(deploy(cmd).await.unwrap().remove(0)); node.kill().unwrap(); assert!(deployed_contract.chunked); @@ -741,7 +772,7 @@ async fn chunked_deploy_re_routes_calls() { default_signer: true, ..Default::default() }; - let deployed_contract = deploy(cmd).await.unwrap().remove(0); + let deployed_contract = expect_deployed_contract(deploy(cmd).await.unwrap().remove(0)); let provider = Provider::connect(&node_url).await.unwrap(); let secret_key = SecretKey::from_str(forc_client::constants::DEFAULT_PRIVATE_KEY).unwrap(); @@ -783,7 +814,7 @@ async fn chunked_deploy_with_proxy_re_routes_call() { default_signer: true, ..Default::default() }; - let deployed_contract = deploy(cmd).await.unwrap().remove(0); + let deployed_contract = expect_deployed_contract(deploy(cmd).await.unwrap().remove(0)); let provider = Provider::connect(&node_url).await.unwrap(); let secret_key = SecretKey::from_str(forc_client::constants::DEFAULT_PRIVATE_KEY).unwrap(); @@ -793,3 +824,474 @@ async fn chunked_deploy_with_proxy_re_routes_call() { node.kill().unwrap(); } + +#[tokio::test] +async fn can_deploy_script() { + let (mut node, port) = run_node(); + let tmp_dir = tempdir().unwrap(); + let project_dir = test_data_path().join("deployed_script"); + copy_dir(&project_dir, tmp_dir.path()).unwrap(); + patch_manifest_file_with_path_std(tmp_dir.path()).unwrap(); + + let node_url = format!("http://127.0.0.1:{}/v1/graphql", port); + let target = NodeTarget { + node_url: Some(node_url.clone()), + target: None, + testnet: false, + }; + let pkg = Pkg { + path: Some(tmp_dir.path().display().to_string()), + ..Default::default() + }; + let cmd = cmd::Deploy { + pkg, + salt: Some(vec![format!("{}", Salt::default())]), + node: target, + default_signer: true, + ..Default::default() + }; + + expect_deployed_script(deploy(cmd).await.unwrap().remove(0)); + node.kill().unwrap(); +} + +#[tokio::test] +async fn deploy_script_calls() { + let (mut node, port) = run_node(); + let tmp_dir = tempdir().unwrap(); + let project_dir = test_data_path().join("deployed_script"); + copy_dir(&project_dir, tmp_dir.path()).unwrap(); + patch_manifest_file_with_path_std(tmp_dir.path()).unwrap(); + + let node_url = format!("http://127.0.0.1:{}/v1/graphql", port); + let target = NodeTarget { + node_url: Some(node_url.clone()), + target: None, + testnet: false, + }; + let pkg = Pkg { + path: Some(tmp_dir.path().display().to_string()), + ..Default::default() + }; + let cmd = cmd::Deploy { + pkg, + salt: Some(vec![format!("{}", Salt::default())]), + node: target, + default_signer: true, + ..Default::default() + }; + + expect_deployed_script(deploy(cmd).await.unwrap().remove(0)); + + // Deploy the contract the script is going to be calling. + let contract_tmp_dir = tempdir().unwrap(); + let project_dir = test_data_path().join("standalone_contract"); + copy_dir(&project_dir, contract_tmp_dir.path()).unwrap(); + patch_manifest_file_with_path_std(contract_tmp_dir.path()).unwrap(); + + let pkg = Pkg { + path: Some(contract_tmp_dir.path().display().to_string()), + ..Default::default() + }; + + let node_url = format!("http://127.0.0.1:{}/v1/graphql", port); + let target = NodeTarget { + node_url: Some(node_url.clone()), + target: None, + testnet: false, + }; + let cmd = cmd::Deploy { + pkg, + salt: Some(vec![format!("{}", Salt::default())]), + node: target, + default_signer: true, + ..Default::default() + }; + let deployed_packages = deploy(cmd).await.unwrap().remove(0); + let contract = expect_deployed_contract(deployed_packages); + let contract_id = contract.id; + + abigen!(Script( + name = "MyScript", + abi = "forc-plugins/forc-client/test/data/deployed_script/deployed_script-abi.json" + )); + + let provider = Provider::connect(&node_url).await.unwrap(); + let secret_key = SecretKey::from_str(forc_client::constants::DEFAULT_PRIVATE_KEY).unwrap(); + let wallet_unlocked = WalletUnlocked::new_from_private_key(secret_key, Some(provider)); + + let loader_path = tmp_dir.path().join("out/deployed_script-loader.bin"); + let instance = MyScript::new(wallet_unlocked, &loader_path.display().to_string()); + + let contract_id_bits256 = Bits256(contract.id.into()); + let call_handler = instance + .main(10, contract_id_bits256) + .with_contract_ids(&[contract_id.into()]) + .call() + .await + .unwrap(); + let (configs, with_input, without_input, from_contract) = call_handler.value; + let receipts = call_handler.receipts; + + assert!(configs.0); // bool + assert_eq!(configs.1, 8); // u8 + assert_eq!(configs.2, 16); // u16 + assert_eq!(configs.3, 32); // u32 + assert_eq!(configs.4, 63); // u64 + assert_eq!(configs.5, 8.into()); // u256 + assert_eq!( + configs.6, + Bits256::from_hex_str("0x0101010101010101010101010101010101010101010101010101010101010101") + .unwrap() + ); // b256 + assert_eq!( + configs.7, + SizedAsciiString::new("fuel".to_string()).unwrap() + ); // str[4] + assert_eq!(configs.8, (8, true)); // tuple + assert_eq!(configs.9, [253, 254, 255]); // array + + let expected_struct = StructWithGeneric { + field_1: 8, + field_2: 16, + }; + assert_eq!(configs.10, expected_struct); // struct + + let expected_enum = EnumWithGeneric::VariantOne(true); + assert_eq!(configs.11, expected_enum); // enum + + assert!(with_input); // 10 % 2 == 0 + assert_eq!(without_input, 2500); // 25 * 100 = 2500 + + assert_eq!(from_contract, 5); + + receipts.iter().find(|receipt| { + if let fuel_tx::Receipt::LogData { data, .. } = receipt { + *data == Some(vec![0x08]) + } else { + false + } + }); + + node.kill().unwrap(); +} + +#[tokio::test] +async fn can_deploy_predicates() { + let (mut node, port) = run_node(); + let tmp_dir = tempdir().unwrap(); + let project_dir = test_data_path().join("deployed_predicate"); + copy_dir(&project_dir, tmp_dir.path()).unwrap(); + patch_manifest_file_with_path_std(tmp_dir.path()).unwrap(); + + let node_url = format!("http://127.0.0.1:{}/v1/graphql", port); + let target = NodeTarget { + node_url: Some(node_url.clone()), + target: None, + testnet: false, + }; + let pkg = Pkg { + path: Some(tmp_dir.path().display().to_string()), + ..Default::default() + }; + let cmd = cmd::Deploy { + pkg, + salt: Some(vec![format!("{}", Salt::default())]), + node: target, + default_signer: true, + ..Default::default() + }; + + expect_deployed_predicate(deploy(cmd).await.unwrap().remove(0)); + node.kill().unwrap(); +} + +#[tokio::test] +async fn deployed_predicate_call() { + let (mut node, port) = run_node(); + let tmp_dir = tempdir().unwrap(); + let project_dir = test_data_path().join("deployed_predicate"); + copy_dir(&project_dir, tmp_dir.path()).unwrap(); + patch_manifest_file_with_path_std(tmp_dir.path()).unwrap(); + + let node_url = format!("http://127.0.0.1:{}/v1/graphql", port); + let target = NodeTarget { + node_url: Some(node_url.clone()), + target: None, + testnet: false, + }; + let pkg = Pkg { + path: Some(tmp_dir.path().display().to_string()), + ..Default::default() + }; + let cmd = cmd::Deploy { + pkg, + salt: Some(vec![format!("{}", Salt::default())]), + node: target, + default_signer: true, + ..Default::default() + }; + expect_deployed_predicate(deploy(cmd).await.unwrap().remove(0)); + + abigen!(Predicate( + name = "MyPredicate", + abi = "forc-plugins/forc-client/test/data/deployed_predicate/deployed_predicate-abi.json" + )); + + let provider = Provider::connect(&node_url).await.unwrap(); + let base_asset_id = *provider.base_asset_id(); + let secret_key = SecretKey::from_str(forc_client::constants::DEFAULT_PRIVATE_KEY).unwrap(); + let wallet_unlocked = WalletUnlocked::new_from_private_key(secret_key, Some(provider.clone())); + let loader_path = tmp_dir.path().join("out/deployed_predicate-loader.bin"); + let strct = StructWithGeneric { + field_1: 8, + field_2: 16, + }; + let enm = EnumWithGeneric::VariantOne(true); + let encoded_data = MyPredicateEncoder::default() + .encode_data(true, 8, strct, enm) + .unwrap(); + let predicate: fuels::prelude::Predicate = + fuels::prelude::Predicate::load_from(&loader_path.display().to_string()) + .unwrap() + .with_data(encoded_data) + .with_provider(provider); + + // lock some amount under the predicate + wallet_unlocked + .transfer( + predicate.address(), + 500, + base_asset_id, + TxPolicies::default(), + ) + .await + .unwrap(); + + // Check predicate balance. + let balance = predicate.get_asset_balance(&base_asset_id).await.unwrap(); + assert_eq!(balance, 500); + + // Try to spend it + let amount_to_unlock = 300; + predicate + .transfer( + wallet_unlocked.address(), + amount_to_unlock, + base_asset_id, + TxPolicies::default(), + ) + .await + .unwrap(); + + // Check predicate balance again. + let balance = predicate.get_asset_balance(&base_asset_id).await.unwrap(); + assert_eq!(balance, 200); + + node.kill().unwrap(); +} + +/// Generates a script instance using SDK, and returns the result as a string. +async fn call_with_sdk_generated_overrides(node_url: &str, contract_id: ContractId) -> String { + let project_dir = test_data_path().join("deployed_script"); + abigen!(Script( + name = "MyScript", + abi = "forc-plugins/forc-client/test/data/deployed_script/deployed_script-abi.json" + )); + let provider = Provider::connect(&node_url).await.unwrap(); + let secret_key = SecretKey::from_str(forc_client::constants::DEFAULT_PRIVATE_KEY).unwrap(); + let wallet_unlocked = WalletUnlocked::new_from_private_key(secret_key, Some(provider.clone())); + let bin_dir = project_dir.join("deployed_script.bin"); + let script_instance = MyScript::new(wallet_unlocked, bin_dir.display().to_string().as_str()); + + let strc = StructWithGeneric { + field_1: 1u8, + field_2: 2, + }; + let encoded = MyScriptConfigurables::default() + .with_BOOL(false) + .unwrap() + .with_U8(1) + .unwrap() + .with_U16(2) + .unwrap() + .with_U32(3) + .unwrap() + .with_U64(4) + .unwrap() + .with_U256(5.into()) + .unwrap() + .with_B256(Bits256::zeroed()) + .unwrap() + .with_ARRAY([1, 2, 3]) + .unwrap() + .with_STRUCT(strc) + .unwrap() + .with_ENUM(EnumWithGeneric::VariantTwo) + .unwrap(); + + let mut script_instance_with_configs = script_instance.with_configurables(encoded); + + let loader_from_sdk = script_instance_with_configs + .convert_into_loader() + .await + .unwrap(); + + let contract_ids_bits256 = Bits256(contract_id.into()); + format!( + "{:?}", + loader_from_sdk + .main(10, contract_ids_bits256) + .with_contract_ids(&[contract_id.into()]) + .call() + .await + .unwrap() + .value + ) +} + +/// Generates a script instance using the shifted abi, and returns the result as a string. +async fn call_with_forc_generated_overrides(node_url: &str, contract_id: ContractId) -> String { + let provider = Provider::connect(&node_url).await.unwrap(); + let secret_key = SecretKey::from_str(forc_client::constants::DEFAULT_PRIVATE_KEY).unwrap(); + let wallet_unlocked = WalletUnlocked::new_from_private_key(secret_key, Some(provider.clone())); + let tmp_dir = tempdir().unwrap(); + let project_dir = test_data_path().join("deployed_script"); + copy_dir(&project_dir, tmp_dir.path()).unwrap(); + patch_manifest_file_with_path_std(tmp_dir.path()).unwrap(); + + let target = NodeTarget { + node_url: Some(node_url.to_string()), + target: None, + testnet: false, + }; + let pkg = Pkg { + path: Some(tmp_dir.path().display().to_string()), + ..Default::default() + }; + let cmd = cmd::Deploy { + pkg, + salt: Some(vec![format!("{}", Salt::default())]), + node: target, + default_signer: true, + ..Default::default() + }; + + expect_deployed_script(deploy(cmd).await.unwrap().remove(0)); + + // Since `abigen!` macro does not allow for dynamic paths, we need to + // pre-generate the loader bin and abi and read them from project dir. Here + // we are ensuring forc-deploy indeed generated the files we are basing our + // tests below. + let generated_loader_abi_path = tmp_dir.path().join("out/deployed_script-loader-abi.json"); + let generated_loader_abi = fs::read_to_string(generated_loader_abi_path).unwrap(); + + // this path is basically, `forc-plugins/forc-client/test/data/deployed_script/deployed_script-loader-abi.json`. + let used_loader_abi_path = project_dir.join("deployed_script-loader-abi.json"); + let used_loader_abi = fs::read_to_string(used_loader_abi_path).unwrap(); + + assert_eq!(generated_loader_abi, used_loader_abi); + + let generated_loader_bin = tmp_dir.path().join("out/deployed_script-loader.bin"); + abigen!(Script( + name = "MyScript", + abi = "forc-plugins/forc-client/test/data/deployed_script/deployed_script-loader-abi.json" + )); + let forc_generated_script_instance = MyScript::new( + wallet_unlocked, + generated_loader_bin.display().to_string().as_str(), + ); + let strc = StructWithGeneric { + field_1: 1u8, + field_2: 2, + }; + let encoded = MyScriptConfigurables::default() + .with_BOOL(false) + .unwrap() + .with_U8(1) + .unwrap() + .with_U16(2) + .unwrap() + .with_U32(3) + .unwrap() + .with_U64(4) + .unwrap() + .with_U256(5.into()) + .unwrap() + .with_B256(Bits256::zeroed()) + .unwrap() + .with_ARRAY([1, 2, 3]) + .unwrap() + .with_STRUCT(strc) + .unwrap() + .with_ENUM(EnumWithGeneric::VariantTwo) + .unwrap(); + + let forc_generated_script_with_configs = + forc_generated_script_instance.with_configurables(encoded); + let contract_ids_bits256 = Bits256(contract_id.into()); + format!( + "{:?}", + forc_generated_script_with_configs + .main(10, contract_ids_bits256) + .with_contract_ids(&[contract_id.into()]) + .call() + .await + .unwrap() + .value + ) +} + +#[tokio::test] +async fn offset_shifted_abi_works() { + // To test if offset shifted abi works or not, we generate a loader + // contract using sdk and give a configurable override, and call the + // main function. + + // We also create the shited abi using forc-deploy and create a script + // instance using this new shifted abi, and generate a normal script out of + // the loader binary generated again by forc-deploy. + + // We then override the configurables with the same values as sdk flow on + // this script, generated with loader abi and bin coming from forc-deploy. + + // If returned value is equal, than the configurables work correctly. + let (mut node, port) = run_node(); + // Deploy the contract the script is going to be calling. + let contract_tmp_dir = tempdir().unwrap(); + let project_dir = test_data_path().join("standalone_contract"); + copy_dir(&project_dir, contract_tmp_dir.path()).unwrap(); + patch_manifest_file_with_path_std(contract_tmp_dir.path()).unwrap(); + + let pkg = Pkg { + path: Some(contract_tmp_dir.path().display().to_string()), + ..Default::default() + }; + + let node_url = format!("http://127.0.0.1:{}/v1/graphql", port); + let target = NodeTarget { + node_url: Some(node_url.clone()), + target: None, + testnet: false, + }; + let cmd = cmd::Deploy { + pkg, + salt: Some(vec![format!("{}", Salt::default())]), + node: target, + default_signer: true, + ..Default::default() + }; + let deployed_packages = deploy(cmd).await.unwrap().remove(0); + let contract = expect_deployed_contract(deployed_packages); + let contract_id = contract.id; + // Generating the sdk loader bytecode with configurables. + let loader_with_configs_from_sdk = + call_with_sdk_generated_overrides(&node_url, contract_id).await; + + // Genearating the forc-deploy loader bytecode and loader abi. + let loader_with_configs_from_forc = + call_with_forc_generated_overrides(&node_url, contract_id).await; + pretty_assertions::assert_eq!(loader_with_configs_from_forc, loader_with_configs_from_sdk); + + node.kill().unwrap() +} diff --git a/forc-plugins/forc-tx/Cargo.toml b/forc-plugins/forc-tx/Cargo.toml index a6a552585a6..91fee672cf3 100644 --- a/forc-plugins/forc-tx/Cargo.toml +++ b/forc-plugins/forc-tx/Cargo.toml @@ -20,7 +20,7 @@ anyhow.workspace = true clap = { workspace = true, features = ["derive", "env"] } devault.workspace = true forc-util.workspace = true -fuel-tx = { workspace = true, features = ["random", "serde", "test-helpers"] } +fuel-tx = { workspace = true, features = ["random", "test-helpers"] } fuel-types = { workspace = true, features = ["serde"] } serde.workspace = true serde_json.workspace = true diff --git a/forc-util/Cargo.toml b/forc-util/Cargo.toml index 47e702cec70..f224c3028cb 100644 --- a/forc-util/Cargo.toml +++ b/forc-util/Cargo.toml @@ -16,7 +16,7 @@ clap = { workspace = true, features = ["cargo", "derive", "env"] } dirs.workspace = true fd-lock.workspace = true forc-tracing.workspace = true -fuel-tx = { workspace = true, features = ["serde"], optional = true } +fuel-tx = { workspace = true, optional = true } hex.workspace = true paste.workspace = true regex.workspace = true diff --git a/test/src/e2e_vm_tests/harness.rs b/test/src/e2e_vm_tests/harness.rs index e2a3236db07..6c3f7c307d9 100644 --- a/test/src/e2e_vm_tests/harness.rs +++ b/test/src/e2e_vm_tests/harness.rs @@ -2,7 +2,7 @@ use anyhow::{anyhow, bail, Result}; use colored::Colorize; use forc_client::{ cmd::{Deploy as DeployCommand, Run as RunCommand}, - op::{deploy, run}, + op::{deploy, run, DeployedPackage}, NodeTarget, }; use forc_pkg::{ @@ -67,7 +67,7 @@ pub(crate) async fn deploy_contract(file_name: &str, run_config: &RunConfig) -> println!(" Deploying {} ...", file_name.bold()); let manifest_dir = env!("CARGO_MANIFEST_DIR"); - deploy(DeployCommand { + let deployed_packages = deploy(DeployCommand { pkg: forc_client::cmd::deploy::Pkg { path: Some(format!( "{manifest_dir}/src/e2e_vm_tests/test_programs/{file_name}" @@ -85,13 +85,20 @@ pub(crate) async fn deploy_contract(file_name: &str, run_config: &RunConfig) -> no_encoding_v1: !run_config.experimental.new_encoding, ..Default::default() }) - .await - .map(|contract_ids| { - contract_ids - .first() - .map(|contract_id| contract_id.id) - .unwrap() - }) + .await?; + + deployed_packages + .into_iter() + .map(|deployed_pkg| { + if let DeployedPackage::Contract(deployed_contract) = deployed_pkg { + Some(deployed_contract.id) + } else { + None + } + }) + .next() + .flatten() + .ok_or_else(|| anyhow!("expected to find at least one deployed contract.")) } /// Run a given project against a node. Assumes the node is running at localhost:4000. diff --git a/test/src/sdk-harness/Cargo.lock b/test/src/sdk-harness/Cargo.lock index 23af427650a..a6bed9abb7b 100644 --- a/test/src/sdk-harness/Cargo.lock +++ b/test/src/sdk-harness/Cargo.lock @@ -236,9 +236,9 @@ checksum = "9b34d609dfbaf33d6889b2b7106d3ca345eacad44200913df5ba02bfd31d2ba9" [[package]] name = "async-graphql" -version = "7.0.6" +version = "7.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf338d20ba5bab309f55ce8df95d65ee19446f7737f06f4a64593ab2c6b546ad" +checksum = "0ba6d24703c5adc5ba9116901b92ee4e4c0643c01a56c4fd303f3818638d7449" dependencies = [ "async-graphql-derive", "async-graphql-parser", @@ -248,6 +248,7 @@ dependencies = [ "base64 0.22.1", "bytes", "fnv", + "futures-timer", "futures-util", "http 1.1.0", "indexmap 2.2.6", @@ -268,13 +269,13 @@ dependencies = [ [[package]] name = "async-graphql-derive" -version = "7.0.6" +version = "7.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc51fd6b7102acda72bc94e8ae1543844d5688ff394a6cf7c21f2a07fe2d64e4" +checksum = "a94c2d176893486bd37cd1b6defadd999f7357bf5804e92f510c08bcf16c538f" dependencies = [ "Inflector", "async-graphql-parser", - "darling 0.20.8", + "darling 0.20.10", "proc-macro-crate", "proc-macro2", "quote", @@ -285,9 +286,9 @@ dependencies = [ [[package]] name = "async-graphql-parser" -version = "7.0.6" +version = "7.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75361eefd64e39f89bead4cb45fddbaf60ddb0e7b15fb7c852b6088bcd63071f" +checksum = "79272bdbf26af97866e149f05b2b546edb5c00e51b5f916289931ed233e208ad" dependencies = [ "async-graphql-value", "pest", @@ -297,9 +298,9 @@ dependencies = [ [[package]] name = "async-graphql-value" -version = "7.0.6" +version = "7.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1f665d2d52b41c4ed1f01c43f3ef27a2fe0af2452ed5c8bc7ac9b1a8719afaa" +checksum = "ef5ec94176a12a8cbe985cd73f2e54dc9c702c88c766bdef12f1f3a67cedbee1" dependencies = [ "bytes", "indexmap 2.2.6", @@ -1191,12 +1192,12 @@ dependencies = [ [[package]] name = "darling" -version = "0.20.8" +version = "0.20.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54e36fcd13ed84ffdfda6f5be89b31287cbb80c439841fe69e04841435464391" +checksum = "6f63b86c8a8826a49b8c21f08a2d07338eec8d900540f8630dc76284be802989" dependencies = [ - "darling_core 0.20.8", - "darling_macro 0.20.8", + "darling_core 0.20.10", + "darling_macro 0.20.10", ] [[package]] @@ -1215,15 +1216,15 @@ dependencies = [ [[package]] name = "darling_core" -version = "0.20.8" +version = "0.20.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c2cf1c23a687a1feeb728783b993c4e1ad83d99f351801977dd809b48d0a70f" +checksum = "95133861a8032aaea082871032f5815eb9e98cef03fa916ab4500513994df9e5" dependencies = [ "fnv", "ident_case", "proc-macro2", "quote", - "strsim 0.10.0", + "strsim 0.11.1", "syn 2.0.63", ] @@ -1240,11 +1241,11 @@ dependencies = [ [[package]] name = "darling_macro" -version = "0.20.8" +version = "0.20.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a668eda54683121533a393014d8692171709ff57a7d61f187b6e782719f8933f" +checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ - "darling_core 0.20.8", + "darling_core 0.20.10", "quote", "syn 2.0.63", ] @@ -1594,9 +1595,9 @@ dependencies = [ [[package]] name = "eventsource-client" -version = "0.12.2" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c80c6714d1a380314fcb11a22eeff022e1e1c9642f0bb54e15dc9cb29f37b29" +checksum = "43ddc25e1ad2cc0106d5e2d967397b4fb2068a66677ee9b0eea4600e5cfe8fb4" dependencies = [ "futures", "hyper", @@ -1706,21 +1707,32 @@ dependencies = [ [[package]] name = "fuel-asm" -version = "0.57.0" +version = "0.58.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b29ea55a794c00d0dfaad06f11720a05fa928603f812dca1c38163f2b240860a" +checksum = "79ca07227658105bdf873556dea09fa7fbfe792fbc084b4b9568f5ba3d64c411" dependencies = [ "bitflags 2.5.0", - "fuel-types 0.57.0", + "fuel-types 0.58.0", "serde", "strum 0.24.1", ] +[[package]] +name = "fuel-compression" +version = "0.58.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3af97bfc2c2b4f0a7f471141663557f13462d7ac278922b01ebaf2127e7515f3" +dependencies = [ + "fuel-derive 0.58.0", + "fuel-types 0.58.0", + "serde", +] + [[package]] name = "fuel-core" -version = "0.36.0" +version = "0.37.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a36ed389d86361845a354d4d0e80620e811c575f937840a11c616e6e409021f8" +checksum = "e8bc5d6df88c21c821bf56dfa0bbd148c18b5153551c4119e5497ab7b90b3d22" dependencies = [ "anyhow", "async-graphql", @@ -1730,6 +1742,7 @@ dependencies = [ "derive_more", "enum-iterator", "fuel-core-chain-config", + "fuel-core-compression", "fuel-core-consensus-module", "fuel-core-database", "fuel-core-executor", @@ -1742,13 +1755,14 @@ dependencies = [ "fuel-core-services", "fuel-core-storage", "fuel-core-txpool", - "fuel-core-types 0.36.0", + "fuel-core-types 0.37.0", "fuel-core-upgradable-executor", "futures", "hex", "hyper", "indicatif", "itertools 0.12.1", + "paste", "rand", "serde", "serde_json", @@ -1766,15 +1780,15 @@ dependencies = [ [[package]] name = "fuel-core-chain-config" -version = "0.36.0" +version = "0.37.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a4c5a71702426b8354bff2010131c0abb4a4f0b608cc7a6dfd72f9e785ba478" +checksum = "cd1eca1d12daf8ad0f2479d7fff9405d94b6467496e5319e5f8b99cbdabdd58b" dependencies = [ "anyhow", "bech32", "derivative", "fuel-core-storage", - "fuel-core-types 0.36.0", + "fuel-core-types 0.37.0", "itertools 0.12.1", "postcard", "rand", @@ -1786,15 +1800,16 @@ dependencies = [ [[package]] name = "fuel-core-client" -version = "0.36.0" +version = "0.37.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5770dbda6220e641eb57ee204dd5914fa15170afe3009473f57cdf15e2339fd8" +checksum = "9dbd88f285afdf061e409b712ecef49e2fe9ba235288cc76e8de8f05d50b6876" dependencies = [ "anyhow", + "base64 0.22.1", "cynic", "derive_more", "eventsource-client", - "fuel-core-types 0.36.0", + "fuel-core-types 0.37.0", "futures", "hex", "hyper-rustls", @@ -1808,40 +1823,55 @@ dependencies = [ "tracing", ] +[[package]] +name = "fuel-core-compression" +version = "0.37.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25fdfc8202216391d0dfc87922eaf2576100c618ed67a8244212ca58dd1b2171" +dependencies = [ + "anyhow", + "fuel-core-types 0.37.0", + "paste", + "rand", + "serde", + "strum 0.25.0", + "strum_macros 0.25.3", +] + [[package]] name = "fuel-core-consensus-module" -version = "0.36.0" +version = "0.37.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f97a3fc636d057db88cf7087aa996de9825335980092c4e894749674d599f7d" +checksum = "a95b4d2df8d8099839f3f3c00429c1af5271783d24007481711c37f579bfd4da" dependencies = [ "anyhow", "fuel-core-chain-config", "fuel-core-poa", "fuel-core-storage", - "fuel-core-types 0.36.0", + "fuel-core-types 0.37.0", ] [[package]] name = "fuel-core-database" -version = "0.36.0" +version = "0.37.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5844c2cf72d4a29d512bcb295f5528c9b8ddbf8ecbf82c3f41001451f5f4ec6f" +checksum = "b466baa45ea41ca9141b3e4ff2b5387f10d274f484561755f9b0d9c953892083" dependencies = [ "anyhow", "derive_more", "fuel-core-storage", - "fuel-core-types 0.36.0", + "fuel-core-types 0.37.0", ] [[package]] name = "fuel-core-executor" -version = "0.36.0" +version = "0.37.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e46400b0e816da2efeee58e5822dfe7ffc1218516456159939968a59417a20af" +checksum = "71858c962367af3c3e5c651c2ea62f1d268d7bc77e6326cd4a206d74a58d0dec" dependencies = [ "anyhow", "fuel-core-storage", - "fuel-core-types 0.36.0", + "fuel-core-types 0.37.0", "hex", "parking_lot", "serde", @@ -1850,16 +1880,16 @@ dependencies = [ [[package]] name = "fuel-core-gas-price-service" -version = "0.36.0" +version = "0.37.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "390c5c33743633c1c70eaa5aaef27f87ad2ab9a79adba7a321c4899fad4c53ee" +checksum = "e33755cb67a3892c5dd058b0f2c022d0f16adebf6bb29a94814794044fbb6a67" dependencies = [ "anyhow", "async-trait", "enum-iterator", "fuel-core-services", "fuel-core-storage", - "fuel-core-types 0.36.0", + "fuel-core-types 0.37.0", "fuel-gas-price-algorithm", "futures", "num_enum", @@ -1875,15 +1905,15 @@ dependencies = [ [[package]] name = "fuel-core-importer" -version = "0.36.0" +version = "0.37.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d6710d343bf04f100f8c3bd4324ce60164e7ca3a8c167915a907180abf23332" +checksum = "7fc8cea1fabe1a51bdabce436d7040d29b3a4d14c0429289060d0a754a1b1a46" dependencies = [ "anyhow", "derive_more", "fuel-core-metrics", "fuel-core-storage", - "fuel-core-types 0.36.0", + "fuel-core-types 0.37.0", "parking_lot", "rayon", "tokio", @@ -1892,9 +1922,9 @@ dependencies = [ [[package]] name = "fuel-core-metrics" -version = "0.36.0" +version = "0.37.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f671e9e813b81873ef07e1cfe8697ba3f9fd0f05313879ed0933446da4c1c14" +checksum = "dfc199e165e600f241cab86129766b26bab78572a701a39bc40a5fdb669961a8" dependencies = [ "parking_lot", "pin-project-lite", @@ -1905,9 +1935,9 @@ dependencies = [ [[package]] name = "fuel-core-p2p" -version = "0.36.0" +version = "0.37.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2453df795ce5e9a22f7ac10bc3436974612d0d698dcb918b2179c5e24b4bfb4a" +checksum = "42ae4fa0826f148c13248db4fe634d2ba7a297bbd424e7288c6e1d881a50f662" dependencies = [ "anyhow", "async-trait", @@ -1915,7 +1945,7 @@ dependencies = [ "fuel-core-metrics", "fuel-core-services", "fuel-core-storage", - "fuel-core-types 0.36.0", + "fuel-core-types 0.37.0", "futures", "hex", "hickory-resolver", @@ -1939,16 +1969,16 @@ dependencies = [ [[package]] name = "fuel-core-poa" -version = "0.36.0" +version = "0.37.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b698e7c184ab4acbaabe7bad73fdc7dfc9ebfc3a6856b1d719a4fd4c1921873" +checksum = "49c4f3e5fa1e916793609bdb9a52142077a84a793272379a04cf24375aa94e6f" dependencies = [ "anyhow", "async-trait", "fuel-core-chain-config", "fuel-core-services", "fuel-core-storage", - "fuel-core-types 0.36.0", + "fuel-core-types 0.37.0", "serde", "serde_json", "tokio", @@ -1958,15 +1988,15 @@ dependencies = [ [[package]] name = "fuel-core-producer" -version = "0.36.0" +version = "0.37.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff23a51239988a9aaf451afa05a1ca7920b4e900319d511bd40bf1e04e414ce1" +checksum = "642d4a10f1df444a09944ae547f1782ca865ac4705ea9cefe0821c5a8e4b3081" dependencies = [ "anyhow", "async-trait", "derive_more", "fuel-core-storage", - "fuel-core-types 0.36.0", + "fuel-core-types 0.37.0", "tokio", "tokio-rayon", "tracing", @@ -1974,9 +2004,9 @@ dependencies = [ [[package]] name = "fuel-core-services" -version = "0.36.0" +version = "0.37.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "998a4f9d057bf3efe43be574bd200ef64c3318007fd04523ce6bd51cc7bb963c" +checksum = "739dca83db1eb86651db3833f088f52afcd3f181cfca40e5725074aceb3ea49d" dependencies = [ "anyhow", "async-trait", @@ -1989,15 +2019,15 @@ dependencies = [ [[package]] name = "fuel-core-storage" -version = "0.36.0" +version = "0.37.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1daa7422e48120b1623b53fe1a1152d11314f30fb290a73dc80f7e128c1f9014" +checksum = "6255d852b6866199d103233e1eef2e7ded141019bc782b5b211fcf001727c34b" dependencies = [ "anyhow", "derive_more", "enum-iterator", - "fuel-core-types 0.36.0", - "fuel-vm 0.57.0", + "fuel-core-types 0.37.0", + "fuel-vm 0.58.0", "impl-tools", "itertools 0.12.1", "mockall", @@ -2013,9 +2043,9 @@ dependencies = [ [[package]] name = "fuel-core-txpool" -version = "0.36.0" +version = "0.37.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc5d2c7d515be53c36070fadbae61a59025ef4a41d20d38e7f2ad71237c4dded" +checksum = "e7b4667213fa8aca461f49c9b305f1f2abda2848a2da5323999d82e3dc76a723" dependencies = [ "anyhow", "async-trait", @@ -2023,10 +2053,12 @@ dependencies = [ "fuel-core-metrics", "fuel-core-services", "fuel-core-storage", - "fuel-core-types 0.36.0", + "fuel-core-types 0.37.0", + "futures", "mockall", "num-rational", "parking_lot", + "rayon", "tokio", "tokio-rayon", "tokio-stream", @@ -2051,15 +2083,15 @@ dependencies = [ [[package]] name = "fuel-core-types" -version = "0.36.0" +version = "0.37.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7aa1c54f09cc7c29a11ca1129f73105745f8374a192e3e24040c10822871d83f" +checksum = "33a4e9b2de06381e1ad598cd1030344993fee7401331ca9955d0a1860cc0484c" dependencies = [ "anyhow", "bs58", "derivative", "derive_more", - "fuel-vm 0.57.0", + "fuel-vm 0.58.0", "rand", "secrecy", "serde", @@ -2069,15 +2101,15 @@ dependencies = [ [[package]] name = "fuel-core-upgradable-executor" -version = "0.36.0" +version = "0.37.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89c636782a522cc49f9e5d43e29b15632a5db930959b8bca9dbf8a6adac76415" +checksum = "768bf8bbb7d27d13b5055ad7b755609e027b5a322b3b21790fac7a478685ba14" dependencies = [ "anyhow", "derive_more", "fuel-core-executor", "fuel-core-storage", - "fuel-core-types 0.36.0", + "fuel-core-types 0.37.0", "fuel-core-wasm-executor", "parking_lot", "postcard", @@ -2087,15 +2119,15 @@ dependencies = [ [[package]] name = "fuel-core-wasm-executor" -version = "0.36.0" +version = "0.37.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52d69a92fba4ccba773b207dd740f04893dbdd0c76dffbebddfebb13c69eea0c" +checksum = "385ce8e704a7370ec5230ba3bd7d986cbe66174f400160b54cf76799a578609e" dependencies = [ "anyhow", "fuel-core-executor", "fuel-core-storage", "fuel-core-types 0.35.0", - "fuel-core-types 0.36.0", + "fuel-core-types 0.37.0", "postcard", "serde", "serde_json", @@ -2119,15 +2151,15 @@ dependencies = [ [[package]] name = "fuel-crypto" -version = "0.57.0" +version = "0.58.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2661b2a6c43e811be4892250513a6f4c46a69cc7092a1e5b240f49697f08292e" +checksum = "f53b06525aa7754bf7c3ef23daf15fd798ae990a82f8b7b813d25cedfeacfe5c" dependencies = [ "coins-bip32", "coins-bip39", "ecdsa", "ed25519-dalek", - "fuel-types 0.57.0", + "fuel-types 0.58.0", "k256", "lazy_static", "p256", @@ -2152,9 +2184,9 @@ dependencies = [ [[package]] name = "fuel-derive" -version = "0.57.0" +version = "0.58.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03509567813a351ca60d8507b2ac476b06c1590f2e9edbe72bc205bb04e0af12" +checksum = "c8e34d6eec30d04506607cc0bc85fc97c57c964580cd233fd557e346c5273535" dependencies = [ "proc-macro2", "quote", @@ -2164,9 +2196,9 @@ dependencies = [ [[package]] name = "fuel-gas-price-algorithm" -version = "0.36.0" +version = "0.37.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a69655b9d140ad98d3e8a333e64814876c63ffe6097fd80e68cdd427514912d" +checksum = "15d4a5847c09db9159ea66bc75bdfe59c4d6139d8b24c1a8026f253f011409bc" dependencies = [ "serde", "thiserror", @@ -2189,13 +2221,13 @@ dependencies = [ [[package]] name = "fuel-merkle" -version = "0.57.0" +version = "0.58.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24938ee8a5e9efe71994203527dffb4c81872aa2953de0c347ad38696527b58a" +checksum = "7a9fa3708405eba32fd2b947b827dc52484377ba6a238260b03a07b642395e6c" dependencies = [ "derive_more", "digest 0.10.7", - "fuel-storage 0.57.0", + "fuel-storage 0.58.0", "hashbrown 0.13.2", "hex", "serde", @@ -2210,9 +2242,9 @@ checksum = "4c1b711f28553ddc5f3546711bd220e144ce4c1af7d9e9a1f70b2f20d9f5b791" [[package]] name = "fuel-storage" -version = "0.57.0" +version = "0.58.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4283f9cabc26a1154a31268e79de1e0f317d57231b4dc8d7282efb22e49d2ed3" +checksum = "f6f678f1c900d0632d77e15d4a4946048d4d517fefeba72607390c03288ca127" [[package]] name = "fuel-tx" @@ -2238,23 +2270,23 @@ dependencies = [ [[package]] name = "fuel-tx" -version = "0.57.0" +version = "0.58.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "572f9e8fdda6abfe83cf1456a11eabf1de66d682176fb097f2f950704cc50c26" +checksum = "1e3065c12eecc9121514694f4b01009c9a83d8842af11c43ec9e2bbc0a7f36cb" dependencies = [ "bitflags 2.5.0", "derivative", "derive_more", - "fuel-asm 0.57.0", - "fuel-crypto 0.57.0", - "fuel-merkle 0.57.0", - "fuel-types 0.57.0", + "fuel-asm 0.58.0", + "fuel-compression", + "fuel-crypto 0.58.0", + "fuel-merkle 0.58.0", + "fuel-types 0.58.0", "hashbrown 0.14.5", "itertools 0.10.5", "postcard", "rand", "serde", - "serde_json", "strum 0.24.1", "strum_macros 0.24.3", ] @@ -2272,11 +2304,11 @@ dependencies = [ [[package]] name = "fuel-types" -version = "0.57.0" +version = "0.58.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f196060a10db0293cdfca455f7e2f3a7914f46f25e0fbc2d28cf0a11e835a86" +checksum = "a93d5f3fd028d874d8927be439fcdea01cb04499049bc68a874c73dd0c7e32b7" dependencies = [ - "fuel-derive 0.57.0", + "fuel-derive 0.58.0", "hex", "rand", "serde", @@ -2315,9 +2347,9 @@ dependencies = [ [[package]] name = "fuel-vm" -version = "0.57.0" +version = "0.58.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6f4e0cc4ae65d00df6f3dcae90b81dd21135b45b932a79e368f35d255df12a1" +checksum = "cb0562398978e501e8ee2caeb747a2852cc4a8c5fff250eb58e38f1c03217311" dependencies = [ "anyhow", "async-trait", @@ -2326,12 +2358,13 @@ dependencies = [ "derivative", "derive_more", "ethnum", - "fuel-asm 0.57.0", - "fuel-crypto 0.57.0", - "fuel-merkle 0.57.0", - "fuel-storage 0.57.0", - "fuel-tx 0.57.0", - "fuel-types 0.57.0", + "fuel-asm 0.58.0", + "fuel-compression", + "fuel-crypto 0.58.0", + "fuel-merkle 0.58.0", + "fuel-storage 0.58.0", + "fuel-tx 0.58.0", + "fuel-types 0.58.0", "hashbrown 0.14.5", "itertools 0.10.5", "libm", @@ -2349,13 +2382,13 @@ dependencies = [ [[package]] name = "fuels" -version = "0.66.5" +version = "0.66.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aaf7ca0443308f4c3d3e9dd7ed67cb18369ae63d208302056d6d5f3a09efb031" +checksum = "921a8ea521744e600e0a34236adff7524ecf34bd940c2a018315d0212c140d7b" dependencies = [ "fuel-core-client", - "fuel-crypto 0.57.0", - "fuel-tx 0.57.0", + "fuel-crypto 0.58.0", + "fuel-tx 0.58.0", "fuels-accounts", "fuels-core", "fuels-macros", @@ -2365,19 +2398,19 @@ dependencies = [ [[package]] name = "fuels-accounts" -version = "0.66.5" +version = "0.66.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92ea69afa418ba67b9572a5b4cb612b80ee2113c9f755e93acf7adc9fc1454d1" +checksum = "2da8bad87e947fc448c44c22e4c90a4af49d61de08722b1d1774d977b2071047" dependencies = [ "async-trait", "chrono", "elliptic-curve", "eth-keystore", "fuel-core-client", - "fuel-core-types 0.36.0", - "fuel-crypto 0.57.0", - "fuel-tx 0.57.0", - "fuel-types 0.57.0", + "fuel-core-types 0.37.0", + "fuel-crypto 0.58.0", + "fuel-tx 0.58.0", + "fuel-types 0.58.0", "fuels-core", "itertools 0.12.1", "rand", @@ -2390,9 +2423,9 @@ dependencies = [ [[package]] name = "fuels-code-gen" -version = "0.66.5" +version = "0.66.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8d1949debe40c9eb731a93b22a50da560007d85f6f7983679d217c01b9dc867" +checksum = "9fdc5f9dcdf330f5ef5f367dbc2334e72151e9ae46a4ee9f21d43a5e859be11b" dependencies = [ "Inflector", "fuel-abi-types", @@ -2406,22 +2439,22 @@ dependencies = [ [[package]] name = "fuels-core" -version = "0.66.5" +version = "0.66.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e720a87a7c99fcc5477cbb251738406de752a10eb237e15c79c1d99b64f4679f" +checksum = "629212e8278d57aa1a6f846ca0ca1e3428fb6da2d43e368931ff1494a0a6b5ce" dependencies = [ "async-trait", "bech32", "chrono", "fuel-abi-types", - "fuel-asm 0.57.0", + "fuel-asm 0.58.0", "fuel-core-chain-config", "fuel-core-client", - "fuel-core-types 0.36.0", - "fuel-crypto 0.57.0", - "fuel-tx 0.57.0", - "fuel-types 0.57.0", - "fuel-vm 0.57.0", + "fuel-core-types 0.37.0", + "fuel-crypto 0.58.0", + "fuel-tx 0.58.0", + "fuel-types 0.58.0", + "fuel-vm 0.58.0", "fuels-macros", "hex", "itertools 0.12.1", @@ -2434,9 +2467,9 @@ dependencies = [ [[package]] name = "fuels-macros" -version = "0.66.5" +version = "0.66.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4f7b391259fceb75331bcbde2878cd9765b579e9167abd818641205b4c96b9a" +checksum = "562bf012adedfb492431f4bfd5be4ccbf2171ab7d5247c5953a6be3ea8036072" dependencies = [ "fuels-code-gen", "itertools 0.12.1", @@ -2447,15 +2480,15 @@ dependencies = [ [[package]] name = "fuels-programs" -version = "0.66.5" +version = "0.66.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbf719a68184ad4999c24dd53cf68bdd247d02fe16a9d67ccba177c8e44771b9" +checksum = "30a366e6a78e1c104fe1cb14439199833987fe76ecd46ee2b46fe05868a3366d" dependencies = [ "async-trait", "fuel-abi-types", - "fuel-asm 0.57.0", - "fuel-tx 0.57.0", - "fuel-types 0.57.0", + "fuel-asm 0.58.0", + "fuel-tx 0.58.0", + "fuel-types 0.58.0", "fuels-accounts", "fuels-core", "itertools 0.12.1", @@ -2466,19 +2499,19 @@ dependencies = [ [[package]] name = "fuels-test-helpers" -version = "0.66.5" +version = "0.66.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a615a59644d3cfce8dc1089db0764b4cca2bcea42b2a08eca826e2b8f892936" +checksum = "7705708c0fe28a874c44635b77c3e120a3422c8a24fdc45f07dc8c21ee9ca6fb" dependencies = [ "fuel-core", "fuel-core-chain-config", "fuel-core-client", "fuel-core-poa", "fuel-core-services", - "fuel-core-types 0.36.0", - "fuel-crypto 0.57.0", - "fuel-tx 0.57.0", - "fuel-types 0.57.0", + "fuel-core-types 0.37.0", + "fuel-crypto 0.58.0", + "fuel-tx 0.58.0", + "fuel-types 0.58.0", "fuels-accounts", "fuels-core", "futures", @@ -4356,9 +4389,9 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pest" -version = "2.7.10" +version = "2.7.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "560131c633294438da9f7c4b08189194b20946c8274c6b9e38881a7874dc8ee8" +checksum = "fdbef9d1d47087a895abd220ed25eb4ad973a5e26f6a4367b038c25e28dfc2d9" dependencies = [ "memchr", "thiserror", @@ -5304,7 +5337,7 @@ version = "3.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "65569b702f41443e8bc8bbb1c5779bd0450bbe723b56198980e80ec45780bce2" dependencies = [ - "darling 0.20.8", + "darling 0.20.10", "proc-macro2", "quote", "syn 2.0.63", @@ -5702,7 +5735,7 @@ dependencies = [ "assert_matches", "fuel-core", "fuel-core-client", - "fuel-vm 0.57.0", + "fuel-vm 0.58.0", "fuels", "hex", "paste", diff --git a/test/src/sdk-harness/Cargo.toml b/test/src/sdk-harness/Cargo.toml index 071e3fe3374..778acf33105 100644 --- a/test/src/sdk-harness/Cargo.toml +++ b/test/src/sdk-harness/Cargo.toml @@ -10,15 +10,15 @@ publish = false assert_matches = "1.5" # Dependencies from the `fuel-core` repository: -fuel-core = { version = "0.36", default-features = false } +fuel-core = { version = "0.37", default-features = false } # Using full semver as the workspace Cargo.toml (see the comment there) -fuel-core-client = { version = "0.36.0", default-features = false } +fuel-core-client = { version = "0.37.0", default-features = false } # Dependencies from the `fuel-vm` repository: -fuel-vm = { version = "0.57", features = ["random"] } +fuel-vm = { version = "0.58", features = ["random"] } # Dependencies from the `fuels-rs` repository: -fuels = { version = "0.66", features = ["fuel-core-lib"] } +fuels = { version = "0.66.6", features = ["fuel-core-lib"] } hex = "0.4" paste = "1.0"