diff --git a/Cargo.lock b/Cargo.lock index 1164957d2..38a798b57 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1445,16 +1445,16 @@ dependencies = [ [[package]] name = "fil_actor_account" -version = "11.0.0" -source = "git+https://github.com/filecoin-project/builtin-actors?branch=next#421855a7b968114ac59422c1faeca968482eccf4" +version = "12.0.0" dependencies = [ "anyhow", "fil_actors_runtime", "frc42_dispatch", "fvm_actor_utils", - "fvm_ipld_blockstore 0.1.2", - "fvm_ipld_encoding 0.3.3", - "fvm_shared 3.2.0", + "fvm_ipld_blockstore 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "fvm_ipld_encoding 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "fvm_sdk 3.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "fvm_shared 3.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "num-derive", "num-traits", "serde", @@ -1481,13 +1481,12 @@ dependencies = [ [[package]] name = "fil_actor_cron" -version = "11.0.0" -source = "git+https://github.com/filecoin-project/builtin-actors?branch=next#421855a7b968114ac59422c1faeca968482eccf4" +version = "12.0.0" dependencies = [ "fil_actors_runtime", - "fvm_ipld_blockstore 0.1.2", - "fvm_ipld_encoding 0.3.3", - "fvm_shared 3.2.0", + "fvm_ipld_blockstore 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "fvm_ipld_encoding 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "fvm_shared 3.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "log", "num-derive", "num-traits", @@ -1496,18 +1495,17 @@ dependencies = [ [[package]] name = "fil_actor_datacap" -version = "11.0.0" -source = "git+https://github.com/filecoin-project/builtin-actors?branch=next#421855a7b968114ac59422c1faeca968482eccf4" +version = "12.0.0" dependencies = [ - "cid 0.8.6", + "cid 0.10.1", "fil_actors_runtime", "frc42_dispatch", "frc46_token", "fvm_actor_utils", - "fvm_ipld_blockstore 0.1.2", - "fvm_ipld_encoding 0.3.3", - "fvm_ipld_hamt 0.6.1", - "fvm_shared 3.2.0", + "fvm_ipld_blockstore 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "fvm_ipld_encoding 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "fvm_ipld_hamt 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "fvm_shared 3.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static", "log", "num-derive", @@ -1517,19 +1515,18 @@ dependencies = [ [[package]] name = "fil_actor_eam" -version = "11.0.0" -source = "git+https://github.com/filecoin-project/builtin-actors?branch=next#421855a7b968114ac59422c1faeca968482eccf4" +version = "12.0.0" dependencies = [ "anyhow", - "cid 0.8.6", + "cid 0.10.1", "fil_actors_evm_shared", "fil_actors_runtime", - "fvm_ipld_blockstore 0.1.2", - "fvm_ipld_encoding 0.3.3", - "fvm_shared 3.2.0", + "fvm_ipld_blockstore 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "fvm_ipld_encoding 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "fvm_shared 3.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "hex-literal", "log", - "multihash 0.16.3", + "multihash 0.18.1", "num-derive", "num-traits", "rlp", @@ -1539,14 +1536,13 @@ dependencies = [ [[package]] name = "fil_actor_ethaccount" -version = "11.0.0" -source = "git+https://github.com/filecoin-project/builtin-actors?branch=next#421855a7b968114ac59422c1faeca968482eccf4" +version = "12.0.0" dependencies = [ "fil_actors_runtime", "frc42_dispatch", "fvm_actor_utils", - "fvm_ipld_encoding 0.3.3", - "fvm_shared 3.2.0", + "fvm_ipld_encoding 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "fvm_shared 3.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "hex-literal", "num-derive", "num-traits", @@ -1555,22 +1551,21 @@ dependencies = [ [[package]] name = "fil_actor_evm" -version = "11.0.0" -source = "git+https://github.com/filecoin-project/builtin-actors?branch=next#421855a7b968114ac59422c1faeca968482eccf4" +version = "12.0.0" dependencies = [ "anyhow", - "cid 0.8.6", + "cid 0.10.1", "fil_actors_evm_shared", "fil_actors_runtime", "frc42_dispatch", - "fvm_ipld_blockstore 0.1.2", - "fvm_ipld_encoding 0.3.3", - "fvm_ipld_kamt 0.2.0", - "fvm_shared 3.2.0", + "fvm_ipld_blockstore 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "fvm_ipld_encoding 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "fvm_ipld_kamt 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "fvm_shared 3.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "hex", "hex-literal", "log", - "multihash 0.16.3", + "multihash 0.18.1", "num-derive", "num-traits", "serde", @@ -1580,17 +1575,17 @@ dependencies = [ [[package]] name = "fil_actor_init" -version = "11.0.0" -source = "git+https://github.com/filecoin-project/builtin-actors?branch=next#421855a7b968114ac59422c1faeca968482eccf4" +version = "12.0.0" dependencies = [ "anyhow", - "cid 0.8.6", + "cid 0.10.1", "fil_actors_runtime", "frc42_dispatch", - "fvm_ipld_blockstore 0.1.2", - "fvm_ipld_encoding 0.3.3", - "fvm_ipld_hamt 0.6.1", - "fvm_shared 3.2.0", + "fvm_ipld_blockstore 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "fvm_ipld_encoding 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "fvm_ipld_hamt 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "fvm_sdk 3.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "fvm_shared 3.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "log", "num-derive", "num-traits", @@ -1599,19 +1594,18 @@ dependencies = [ [[package]] name = "fil_actor_market" -version = "11.0.0" -source = "git+https://github.com/filecoin-project/builtin-actors?branch=next#421855a7b968114ac59422c1faeca968482eccf4" +version = "12.0.0" dependencies = [ "anyhow", - "cid 0.8.6", + "cid 0.10.1", "fil_actors_runtime", "frc42_dispatch", "frc46_token", "fvm_ipld_bitfield 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", - "fvm_ipld_blockstore 0.1.2", - "fvm_ipld_encoding 0.3.3", - "fvm_ipld_hamt 0.6.1", - "fvm_shared 3.2.0", + "fvm_ipld_blockstore 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "fvm_ipld_encoding 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "fvm_ipld_hamt 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "fvm_shared 3.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "integer-encoding", "libipld-core 0.13.1", "log", @@ -1622,20 +1616,19 @@ dependencies = [ [[package]] name = "fil_actor_miner" -version = "11.0.0" -source = "git+https://github.com/filecoin-project/builtin-actors?branch=next#421855a7b968114ac59422c1faeca968482eccf4" +version = "12.0.0" dependencies = [ "anyhow", "byteorder", - "cid 0.8.6", + "cid 0.10.1", "fil_actors_runtime", "frc42_dispatch", - "fvm_ipld_amt 0.5.1", + "fvm_ipld_amt 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "fvm_ipld_bitfield 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", - "fvm_ipld_blockstore 0.1.2", - "fvm_ipld_encoding 0.3.3", - "fvm_ipld_hamt 0.6.1", - "fvm_shared 3.2.0", + "fvm_ipld_blockstore 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "fvm_ipld_encoding 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "fvm_ipld_hamt 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "fvm_shared 3.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "itertools 0.10.5", "lazy_static", "log", @@ -1647,18 +1640,17 @@ dependencies = [ [[package]] name = "fil_actor_multisig" -version = "11.0.0" -source = "git+https://github.com/filecoin-project/builtin-actors?branch=next#421855a7b968114ac59422c1faeca968482eccf4" +version = "12.0.0" dependencies = [ "anyhow", - "cid 0.8.6", + "cid 0.10.1", "fil_actors_runtime", "frc42_dispatch", "fvm_actor_utils", - "fvm_ipld_blockstore 0.1.2", - "fvm_ipld_encoding 0.3.3", - "fvm_ipld_hamt 0.6.1", - "fvm_shared 3.2.0", + "fvm_ipld_blockstore 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "fvm_ipld_encoding 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "fvm_ipld_hamt 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "fvm_shared 3.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "indexmap", "integer-encoding", "num-derive", @@ -1668,16 +1660,15 @@ dependencies = [ [[package]] name = "fil_actor_paych" -version = "11.0.0" -source = "git+https://github.com/filecoin-project/builtin-actors?branch=next#421855a7b968114ac59422c1faeca968482eccf4" +version = "12.0.0" dependencies = [ "anyhow", - "cid 0.8.6", + "cid 0.10.1", "fil_actors_runtime", "frc42_dispatch", - "fvm_ipld_blockstore 0.1.2", - "fvm_ipld_encoding 0.3.3", - "fvm_shared 3.2.0", + "fvm_ipld_blockstore 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "fvm_ipld_encoding 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "fvm_shared 3.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "num-derive", "num-traits", "serde", @@ -1685,22 +1676,20 @@ dependencies = [ [[package]] name = "fil_actor_placeholder" -version = "11.0.0" -source = "git+https://github.com/filecoin-project/builtin-actors?branch=next#421855a7b968114ac59422c1faeca968482eccf4" +version = "12.0.0" [[package]] name = "fil_actor_power" -version = "11.0.0" -source = "git+https://github.com/filecoin-project/builtin-actors?branch=next#421855a7b968114ac59422c1faeca968482eccf4" +version = "12.0.0" dependencies = [ "anyhow", - "cid 0.8.6", + "cid 0.10.1", "fil_actors_runtime", "frc42_dispatch", - "fvm_ipld_blockstore 0.1.2", - "fvm_ipld_encoding 0.3.3", - "fvm_ipld_hamt 0.6.1", - "fvm_shared 3.2.0", + "fvm_ipld_blockstore 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "fvm_ipld_encoding 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "fvm_ipld_hamt 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "fvm_shared 3.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "indexmap", "integer-encoding", "lazy_static", @@ -1712,13 +1701,12 @@ dependencies = [ [[package]] name = "fil_actor_reward" -version = "11.0.0" -source = "git+https://github.com/filecoin-project/builtin-actors?branch=next#421855a7b968114ac59422c1faeca968482eccf4" +version = "12.0.0" dependencies = [ "fil_actors_runtime", - "fvm_ipld_blockstore 0.1.2", - "fvm_ipld_encoding 0.3.3", - "fvm_shared 3.2.0", + "fvm_ipld_blockstore 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "fvm_ipld_encoding 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "fvm_shared 3.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static", "log", "num-derive", @@ -1728,15 +1716,14 @@ dependencies = [ [[package]] name = "fil_actor_system" -version = "11.0.0" -source = "git+https://github.com/filecoin-project/builtin-actors?branch=next#421855a7b968114ac59422c1faeca968482eccf4" +version = "12.0.0" dependencies = [ "anyhow", - "cid 0.8.6", + "cid 0.10.1", "fil_actors_runtime", - "fvm_ipld_blockstore 0.1.2", - "fvm_ipld_encoding 0.3.3", - "fvm_shared 3.2.0", + "fvm_ipld_blockstore 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "fvm_ipld_encoding 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "fvm_shared 3.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "num-derive", "num-traits", "serde", @@ -1744,19 +1731,18 @@ dependencies = [ [[package]] name = "fil_actor_verifreg" -version = "11.0.0" -source = "git+https://github.com/filecoin-project/builtin-actors?branch=next#421855a7b968114ac59422c1faeca968482eccf4" +version = "12.0.0" dependencies = [ "anyhow", - "cid 0.8.6", + "cid 0.10.1", "fil_actors_runtime", "frc42_dispatch", "frc46_token", "fvm_actor_utils", - "fvm_ipld_blockstore 0.1.2", - "fvm_ipld_encoding 0.3.3", - "fvm_ipld_hamt 0.6.1", - "fvm_shared 3.2.0", + "fvm_ipld_blockstore 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "fvm_ipld_encoding 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "fvm_ipld_hamt 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "fvm_shared 3.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static", "log", "num-derive", @@ -1766,12 +1752,11 @@ dependencies = [ [[package]] name = "fil_actors_evm_shared" -version = "11.0.0" -source = "git+https://github.com/filecoin-project/builtin-actors?branch=next#421855a7b968114ac59422c1faeca968482eccf4" +version = "12.0.0" dependencies = [ "fil_actors_runtime", - "fvm_ipld_encoding 0.3.3", - "fvm_shared 3.2.0", + "fvm_ipld_encoding 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "fvm_shared 3.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "hex", "serde", "uint", @@ -1779,23 +1764,22 @@ dependencies = [ [[package]] name = "fil_actors_runtime" -version = "11.0.0" -source = "git+https://github.com/filecoin-project/builtin-actors?branch=next#421855a7b968114ac59422c1faeca968482eccf4" +version = "12.0.0" dependencies = [ "anyhow", "byteorder", "castaway", - "cid 0.8.6", - "fvm_ipld_amt 0.5.1", + "cid 0.10.1", + "fvm_ipld_amt 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "fvm_ipld_bitfield 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", - "fvm_ipld_blockstore 0.1.2", - "fvm_ipld_encoding 0.3.3", - "fvm_ipld_hamt 0.6.1", - "fvm_sdk 3.2.0", - "fvm_shared 3.2.0", + "fvm_ipld_blockstore 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "fvm_ipld_encoding 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "fvm_ipld_hamt 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "fvm_sdk 3.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "fvm_shared 3.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "itertools 0.10.5", "log", - "multihash 0.16.3", + "multihash 0.18.1", "num", "num-derive", "num-traits", @@ -1819,10 +1803,9 @@ dependencies = [ [[package]] name = "fil_builtin_actors_bundle" -version = "11.0.0" -source = "git+https://github.com/filecoin-project/builtin-actors?branch=next#421855a7b968114ac59422c1faeca968482eccf4" +version = "12.0.0" dependencies = [ - "cid 0.8.6", + "cid 0.10.1", "clap 3.2.25", "fil_actor_account", "fil_actor_bundler", @@ -1850,8 +1833,10 @@ name = "fil_create_actor" version = "0.1.0" dependencies = [ "fil_actors_runtime", + "fvm_ipld_encoding 0.4.0", "fvm_sdk 3.3.0", "fvm_shared 3.4.0", + "serde", ] [[package]] @@ -2141,34 +2126,34 @@ dependencies = [ [[package]] name = "frc42_dispatch" -version = "3.2.0" +version = "3.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6fda233581861602b8c1c0922a44d79977cb0f56cfe1c3b71eafb589d1da749" +checksum = "1b74f15b21f4938a7c160ff18312d284d5eb8c94b95d48e3183cdc3a083c6f96" dependencies = [ "frc42_hasher", "frc42_macros", - "fvm_ipld_encoding 0.3.3", - "fvm_sdk 3.2.0", - "fvm_shared 3.2.0", + "fvm_ipld_encoding 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "fvm_sdk 3.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "fvm_shared 3.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "thiserror", ] [[package]] name = "frc42_hasher" -version = "1.5.0" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad1cf7cebdc57c39906ba8b1148cde4a633cd76614131b983eb4c07f35c735d0" +checksum = "f72dabfe1b958b3588138f9d15ade5f485b79aca6f1e8f307f5dd09d0694d350" dependencies = [ - "fvm_sdk 3.2.0", - "fvm_shared 3.2.0", + "fvm_sdk 3.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "fvm_shared 3.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "thiserror", ] [[package]] name = "frc42_macros" -version = "1.2.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9479347c6b83b53f1c041045e9954e3213bb6d1cfc9d2f2927340765a1aabd58" +checksum = "b9581d30bf75a1e5637a93eaf6605ebcf617f75e882a790248c5cc49d6b6de5b" dependencies = [ "blake2b_simd", "frc42_hasher", @@ -2179,20 +2164,20 @@ dependencies = [ [[package]] name = "frc46_token" -version = "6.0.0" +version = "7.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f03b2e4912228bdb9b6d24e7cea4d2d671ec04a8e55f0edc88540b8ceaeea83a" +checksum = "462ee03466de3e94fda83742df339bbe2acb72847cef40baed4c7a8c92525354" dependencies = [ "anyhow", - "cid 0.8.6", + "cid 0.10.1", "frc42_dispatch", "fvm_actor_utils", - "fvm_ipld_amt 0.5.1", - "fvm_ipld_blockstore 0.1.2", - "fvm_ipld_encoding 0.3.3", - "fvm_ipld_hamt 0.6.1", - "fvm_sdk 3.2.0", - "fvm_shared 3.2.0", + "fvm_ipld_amt 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", + "fvm_ipld_blockstore 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "fvm_ipld_encoding 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "fvm_ipld_hamt 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "fvm_sdk 3.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "fvm_shared 3.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "integer-encoding", "num-traits", "serde", @@ -2383,17 +2368,17 @@ dependencies = [ [[package]] name = "fvm_actor_utils" -version = "6.0.0" +version = "7.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b57882eb67bc56aa67087c584767596c41e54bdd16151a65058177256e860572" +checksum = "cab9226c2760276fab371869a021e0b8b6cf0fd001d1d42321941f0da7dd63d8" dependencies = [ "anyhow", - "cid 0.8.6", + "cid 0.10.1", "frc42_dispatch", - "fvm_ipld_blockstore 0.1.2", - "fvm_ipld_encoding 0.3.3", - "fvm_sdk 3.2.0", - "fvm_shared 3.2.0", + "fvm_ipld_blockstore 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "fvm_ipld_encoding 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "fvm_sdk 3.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "fvm_shared 3.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits", "serde", "serde_tuple", @@ -2481,16 +2466,17 @@ dependencies = [ [[package]] name = "fvm_ipld_amt" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e84f16d6927ce342ef86bd20fcc2d5bd498ed33ae6d7a22fea7a1b453488ec88" +version = "0.6.1" dependencies = [ "anyhow", - "cid 0.8.6", - "fvm_ipld_blockstore 0.1.2", - "fvm_ipld_encoding 0.3.3", - "itertools 0.10.5", + "cid 0.10.1", + "criterion", + "fvm_ipld_blockstore 0.2.0", + "fvm_ipld_encoding 0.4.0", + "itertools 0.11.0", "once_cell", + "quickcheck", + "quickcheck_macros", "serde", "thiserror", ] @@ -2498,16 +2484,15 @@ dependencies = [ [[package]] name = "fvm_ipld_amt" version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c0b0ee51ca8defa9717a72e1d35c8cbb85bd8320a835911410b63b9a63dffec" dependencies = [ "anyhow", "cid 0.10.1", - "criterion", - "fvm_ipld_blockstore 0.2.0", - "fvm_ipld_encoding 0.4.0", + "fvm_ipld_blockstore 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "fvm_ipld_encoding 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "itertools 0.11.0", "once_cell", - "quickcheck", - "quickcheck_macros", "serde", "thiserror", ] @@ -2560,6 +2545,17 @@ dependencies = [ "multihash 0.18.1", ] +[[package]] +name = "fvm_ipld_blockstore" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "417f52f6915b9f9a68de8462e1cf46f14a2c16420f484b8d2066873de2ffe420" +dependencies = [ + "anyhow", + "cid 0.10.1", + "multihash 0.18.1", +] + [[package]] name = "fvm_ipld_car" version = "0.6.0" @@ -2623,22 +2619,19 @@ dependencies = [ ] [[package]] -name = "fvm_ipld_hamt" -version = "0.6.1" +name = "fvm_ipld_encoding" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c942494dde990aeac314311bde34c787be99cab7d0836397a75556cbaa2c3e7" +checksum = "90608092e31d9a06236268c58f7c36668ab4b2a48afafe3a97e08f094ad7ae50" dependencies = [ "anyhow", - "byteorder", - "cid 0.8.6", - "forest_hash_utils", - "fvm_ipld_blockstore 0.1.2", - "fvm_ipld_encoding 0.3.3", - "libipld-core 0.14.0", - "multihash 0.16.3", - "once_cell", + "cid 0.10.1", + "fvm_ipld_blockstore 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "multihash 0.18.1", "serde", - "sha2 0.10.7", + "serde_ipld_dagcbor 0.4.0", + "serde_repr", + "serde_tuple", "thiserror", ] @@ -2667,18 +2660,19 @@ dependencies = [ ] [[package]] -name = "fvm_ipld_kamt" -version = "0.2.0" +name = "fvm_ipld_hamt" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ab54acc8b19c5029ceefb3a1aa5708e1513a6ef7b17cdfeb6674c042b70d163" +checksum = "f01c65915bd7ab95ff973bb0bb7e03e8d43a43642c8f4b15407e42e4ffcc0d98" dependencies = [ "anyhow", "byteorder", - "cid 0.8.6", + "cid 0.10.1", "forest_hash_utils", - "fvm_ipld_blockstore 0.1.2", - "fvm_ipld_encoding 0.3.3", - "multihash 0.16.3", + "fvm_ipld_blockstore 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "fvm_ipld_encoding 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libipld-core 0.16.0", + "multihash 0.18.1", "once_cell", "serde", "sha2 0.10.7", @@ -2708,17 +2702,20 @@ dependencies = [ ] [[package]] -name = "fvm_sdk" -version = "3.2.0" +name = "fvm_ipld_kamt" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db8ac1214ca6c31bcbb4e2e7461cd17af18e0496b9053547d465f15c8d8429a7" +checksum = "ed361b9a0c2fb2b3b3252a7668d1656e83f696787c14ab1a695c0535bf5f8d64" dependencies = [ - "cid 0.8.6", - "fvm_ipld_encoding 0.3.3", - "fvm_shared 3.2.0", - "lazy_static", - "log", - "num-traits", + "anyhow", + "byteorder", + "cid 0.10.1", + "forest_hash_utils", + "fvm_ipld_blockstore 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "fvm_ipld_encoding 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "multihash 0.18.1", + "once_cell", + "serde", "thiserror", ] @@ -2736,28 +2733,18 @@ dependencies = [ ] [[package]] -name = "fvm_shared" -version = "3.2.0" +name = "fvm_sdk" +version = "3.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "674e86afc2ce02808d24f578296f105b13c23300e60e0eac331c4c1575beabb5" +checksum = "6c855aead9219cacd48450a4d9d5f57d13dbe4dbbe2d8538d350212792854f5d" dependencies = [ - "anyhow", - "bitflags 1.3.2", - "blake2b_simd", - "cid 0.8.6", - "data-encoding", - "data-encoding-macro", - "fvm_ipld_encoding 0.3.3", + "cid 0.10.1", + "fvm_ipld_encoding 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "fvm_shared 3.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static", - "multihash 0.16.3", - "num-bigint", - "num-derive", - "num-integer", + "log", "num-traits", - "serde", - "serde_tuple", "thiserror", - "unsigned-varint", ] [[package]] @@ -2793,6 +2780,31 @@ dependencies = [ "unsigned-varint", ] +[[package]] +name = "fvm_shared" +version = "3.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8704b912372b9640f625fef1b8af24873e27feba66dcbae3f2a49f486a26589d" +dependencies = [ + "anyhow", + "bitflags 2.3.3", + "blake2b_simd", + "cid 0.10.1", + "data-encoding", + "data-encoding-macro", + "fvm_ipld_encoding 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static", + "multihash 0.18.1", + "num-bigint", + "num-derive", + "num-integer", + "num-traits", + "serde", + "serde_tuple", + "thiserror", + "unsigned-varint", +] + [[package]] name = "fvm_test_actors" version = "0.1.0" @@ -3210,21 +3222,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "libipld-core" -version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d44790246ec6b7314cba745992c23d479d018073e66d49ae40ae1b64e5dd8eb5" -dependencies = [ - "anyhow", - "cid 0.8.6", - "core2", - "multibase", - "multihash 0.16.3", - "serde", - "thiserror", -] - [[package]] name = "libipld-core" version = "0.16.0" @@ -3449,7 +3446,6 @@ dependencies = [ "core2", "digest 0.10.7", "multihash-derive", - "ripemd", "serde", "serde-big-array", "sha2 0.10.7", diff --git a/fvm/src/call_manager/backtrace.rs b/fvm/src/call_manager/backtrace.rs index 12bf3c425..2f59a2419 100644 --- a/fvm/src/call_manager/backtrace.rs +++ b/fvm/src/call_manager/backtrace.rs @@ -4,10 +4,12 @@ use std::fmt::Display; use fvm_shared::address::Address; use fvm_shared::error::{ErrorNumber, ExitCode}; -use fvm_shared::{ActorID, MethodNum}; +use fvm_shared::ActorID; use crate::kernel::SyscallError; +use super::Entrypoint; + /// A call backtrace records the actors an error was propagated through, from /// the moment it was emitted. The original error is the _cause_. Backtraces are /// useful for identifying the root cause of an error. @@ -76,8 +78,8 @@ impl Backtrace { pub struct Frame { /// The actor that exited with this code. pub source: ActorID, - /// The method that was invoked. - pub method: MethodNum, + /// The entrypoint that was invoked. + pub entrypoint: Entrypoint, /// The exit code. pub code: ExitCode, /// The abort message. @@ -90,7 +92,7 @@ impl Display for Frame { f, "{} (method {}) -- {} ({})", Address::new_id(self.source), - self.method, + self.entrypoint, &self.message, self.code, ) diff --git a/fvm/src/call_manager/default.rs b/fvm/src/call_manager/default.rs index 6004fc4f9..8e06b557d 100644 --- a/fvm/src/call_manager/default.rs +++ b/fvm/src/call_manager/default.rs @@ -7,7 +7,7 @@ use cid::Cid; use derive_more::{Deref, DerefMut}; use fvm_ipld_amt::Amt; use fvm_ipld_encoding::{to_vec, CBOR}; -use fvm_shared::address::{Address, Payload}; +use fvm_shared::address::{Address, MaybeResolvedAddress, Payload}; use fvm_shared::econ::TokenAmount; use fvm_shared::error::{ErrorNumber, ExitCode}; use fvm_shared::event::StampedEvent; @@ -16,13 +16,14 @@ use fvm_shared::{ActorID, MethodNum, METHOD_SEND}; use num_traits::Zero; use super::state_access_tracker::{ActorAccessState, StateAccessTracker}; -use super::{Backtrace, CallManager, InvocationResult, NO_DATA_BLOCK_ID}; +use super::{Backtrace, CallManager, Entrypoint, InvocationResult, NO_DATA_BLOCK_ID}; use crate::blockstore::DiscardBlockstore; use crate::call_manager::backtrace::Frame; use crate::call_manager::FinishRet; use crate::eam_actor::EAM_ACTOR_ID; use crate::engine::Engine; use crate::gas::{Gas, GasTracker}; +use crate::init_actor::INIT_ACTOR_ID; use crate::kernel::{ Block, BlockRegistry, ClassifyResult, ExecutionError, Kernel, Result, SyscallError, }; @@ -179,56 +180,15 @@ where where K: Kernel, { - if self.machine.context().tracing { - self.trace(ExecutionEvent::Call { - from, - to, - method, - params: params.as_ref().map(Into::into), - value: value.clone(), - }); - } - - // If a specific gas limit has been requested, push a new limit into the gas tracker. - if let Some(limit) = gas_limit { - self.gas_tracker.push_limit(limit); - } - - let mut result = self.with_stack_frame(|s| { - s.send_unchecked::(from, to, method, params, value, read_only) - }); - - // If we pushed a limit, pop it. - if gas_limit.is_some() { - self.gas_tracker.pop_limit()?; - } - // If we're not out of gas but the error is "out of gas" (e.g., due to a gas limit), replace - // the error with an explicit exit code. - if !self.gas_tracker.gas_available().is_zero() - && matches!(result, Err(ExecutionError::OutOfGas)) - { - result = Ok(InvocationResult { - exit_code: ExitCode::SYS_OUT_OF_GAS, - value: None, - }) - } - - if self.machine.context().tracing { - self.trace(match &result { - Ok(InvocationResult { exit_code, value }) => { - ExecutionEvent::CallReturn(*exit_code, value.as_ref().map(Into::into)) - } - Err(ExecutionError::OutOfGas) => { - ExecutionEvent::CallReturn(ExitCode::SYS_OUT_OF_GAS, None) - } - Err(ExecutionError::Fatal(_)) => { - ExecutionEvent::CallError(SyscallError::new(ErrorNumber::Forbidden, "fatal")) - } - Err(ExecutionError::Syscall(s)) => ExecutionEvent::CallError(s.clone()), - }); - } - - result + self.send_maybe_resolved::( + from, + to.into(), + Entrypoint::Invoke(method), + params, + value, + gas_limit, + read_only, + ) } fn with_transaction( @@ -338,12 +298,18 @@ where Address::new_actor(&b) } - fn create_actor( + fn create_actor( &mut self, code_id: Cid, actor_id: ActorID, delegated_address: Option
, - ) -> Result<()> { + value: &TokenAmount, + params: Option, + gas_limit: Option, + ) -> Result + where + K: Kernel, + { if self.machine.builtin_actors().is_placeholder_actor(&code_id) { return Err(syscall_error!( Forbidden, @@ -392,7 +358,20 @@ where }; self.set_actor(actor_id, actor)?; self.num_actors_created += 1; - Ok(()) + + // Invoke the constructor and return its result. + self.send_maybe_resolved::( + // TODO For now, this must be the init actor. In the future, this should be the actor + // ID that called the init actor. That ID can be passed as a param to the + // create_actor syscall in the init actor, which should be fairly easy to do. + INIT_ACTOR_ID, + actor_id.into(), + Entrypoint::Create, + params, + value, + gas_limit, + false, + ) } fn append_event(&mut self, evt: StampedEvent) { @@ -499,7 +478,7 @@ where self.set_actor(from, from_actor)?; self.set_actor(to, to_actor)?; - log::trace!("transferred {} from {} to {}", value, from, to); + log::trace!("transferred {value} from {from} to {to}"); Ok(()) } @@ -570,7 +549,7 @@ where self.send_resolved::( system_actor::SYSTEM_ACTOR_ID, id, - fvm_shared::METHOD_CONSTRUCTOR, + Entrypoint::Create, Some(Block::new(CBOR, params)), &TokenAmount::zero(), false, @@ -587,12 +566,77 @@ where self.create_actor_from_send(addr, state) } + fn send_maybe_resolved( + &mut self, + from: ActorID, + to: MaybeResolvedAddress, + entrypoint: Entrypoint, + params: Option, + value: &TokenAmount, + gas_limit: Option, + read_only: bool, + ) -> Result + where + K: Kernel, + { + if self.machine.context().tracing { + self.trace(ExecutionEvent::Call { + from, + to, + entrypoint, + params: params.as_ref().map(Into::into), + value: value.clone(), + }); + } + + // If a specific gas limit has been requested, push a new limit into the gas tracker. + if let Some(limit) = gas_limit { + self.gas_tracker.push_limit(limit); + } + + let mut result = self.with_stack_frame(|s| { + s.send_unchecked::(from, to, entrypoint, params, value, read_only) + }); + + // If we pushed a limit, pop it. + if gas_limit.is_some() { + self.gas_tracker.pop_limit()?; + } + // If we're not out of gas but the error is "out of gas" (e.g., due to a gas limit), replace + // the error with an explicit exit code. + if !self.gas_tracker.gas_available().is_zero() + && matches!(result, Err(ExecutionError::OutOfGas)) + { + result = Ok(InvocationResult { + exit_code: ExitCode::SYS_OUT_OF_GAS, + value: None, + }) + } + + if self.machine.context().tracing { + self.trace(match &result { + Ok(InvocationResult { exit_code, value }) => { + ExecutionEvent::CallReturn(*exit_code, value.as_ref().map(Into::into)) + } + Err(ExecutionError::OutOfGas) => { + ExecutionEvent::CallReturn(ExitCode::SYS_OUT_OF_GAS, None) + } + Err(ExecutionError::Fatal(_)) => { + ExecutionEvent::CallError(SyscallError::new(ErrorNumber::Forbidden, "fatal")) + } + Err(ExecutionError::Syscall(s)) => ExecutionEvent::CallError(s.clone()), + }); + } + + result + } + /// Send without checking the call depth. fn send_unchecked( &mut self, from: ActorID, - to: Address, - method: MethodNum, + to: MaybeResolvedAddress, + entrypoint: Entrypoint, params: Option, value: &TokenAmount, read_only: bool, @@ -600,33 +644,38 @@ where where K: Kernel, { - // Get the receiver; this will resolve the address. - let to = match self.resolve_address(&to)? { - Some(addr) => addr, - None => match to.payload() { - Payload::BLS(_) | Payload::Secp256k1(_) => { - if read_only { - return Err(syscall_error!(ReadOnly; "cannot auto-create account {to} in read-only calls").into()); - } - // Try to create an account actor if the receiver is a key address. - self.create_account_actor_from_send::(&to)? - } - // Validate that there's an actor at the target ID (we don't care what is there, - // just that something is there). - Payload::Delegated(da) if da.namespace() == EAM_ACTOR_ID => { - if read_only { - return Err(syscall_error!(ReadOnly; "cannot auto-create account {to} in read-only calls").into()); - } - self.create_placeholder_actor_from_send(&to)? + let to = match to { + MaybeResolvedAddress::Unresolved(to) => { + // Get the receiver; this will resolve the address. + match self.resolve_address(&to)? { + Some(addr) => addr, + None => match to.payload() { + Payload::BLS(_) | Payload::Secp256k1(_) => { + if read_only { + return Err(syscall_error!(ReadOnly; "cannot auto-create account {to} in read-only calls").into()); + } + // Try to create an account actor if the receiver is a key address. + self.create_account_actor_from_send::(&to)? + } + // Validate that there's an actor at the target ID (we don't care what is there, + // just that something is there). + Payload::Delegated(da) if da.namespace() == EAM_ACTOR_ID => { + if read_only { + return Err(syscall_error!(ReadOnly; "cannot auto-create account {to} in read-only calls").into()); + } + self.create_placeholder_actor_from_send(&to)? + } + _ => return Err( + syscall_error!(NotFound; "actor does not exist or cannot be created: {}", to) + .into(), + ), + }, } - _ => return Err( - syscall_error!(NotFound; "actor does not exist or cannot be created: {}", to) - .into(), - ), - }, + } + MaybeResolvedAddress::Resolved(to) => to, }; - self.send_resolved::(from, to, method, params, value, read_only) + self.send_resolved::(from, to, entrypoint, params, value, read_only) } /// Send with resolved addresses. @@ -634,7 +683,7 @@ where &mut self, from: ActorID, to: ActorID, - method: MethodNum, + entrypoint: Entrypoint, params: Option, value: &TokenAmount, read_only: bool, @@ -655,15 +704,15 @@ where } // Abort early if we have a send. - if method == METHOD_SEND { - log::trace!("sent {} -> {}: {}", from, to, &value); + if let Entrypoint::Invoke(METHOD_SEND) = entrypoint { + log::trace!("sent {from} -> {to}: {value}"); return Ok(InvocationResult::default()); } // Charge the invocation gas. let t = self.charge_gas(self.price_list().on_method_invocation())?; - // Store the parametrs, and initialize the block registry for the target actor. + // Store the parameters, and initialize the block registry for the target actor. let mut block_registry = BlockRegistry::new(); let params_id = if let Some(blk) = params { block_registry.put(blk)? @@ -684,7 +733,7 @@ where |_| syscall_error!(NotFound; "actor code cid does not exist {}", &state.code), )?; - log::trace!("calling {} -> {}::{}", from, to, method); + log::trace!("calling {from} -> {to}::{entrypoint}"); self.map_mut(|cm| { let engine = cm.engine.clone(); // reference the RC. @@ -694,7 +743,7 @@ where block_registry, from, to, - method, + entrypoint.method_num(), value.clone(), read_only, ); @@ -718,10 +767,10 @@ where store.data_mut().memory = memory; - // Lookup the invoke method. - let invoke: wasmtime::TypedFunc<(u32,), u32> = instance - .get_typed_func(&mut store, "invoke") - // All actors will have an invoke method. + // Lookup the entrypoint. + let func: wasmtime::TypedFunc<(u32,), u32> = instance + .get_typed_func(&mut store, entrypoint.func_name()) + // All actors must have the entrypoint functions. .map_err(Abort::Fatal)?; // Set the available gas. @@ -729,7 +778,7 @@ where // Invoke it. let res = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { - invoke.call(&mut store, (params_id,)) + func.call(&mut store, (params_id,)) })) .map_err(|panic| Abort::Fatal(anyhow!("panic within actor: {:?}", panic)))?; @@ -814,7 +863,7 @@ where cm.backtrace.push_frame(Frame { source: to, - method, + entrypoint, message, code, }); @@ -827,14 +876,10 @@ where // Log the results if tracing is enabled. if log::log_enabled!(log::Level::Trace) { match &ret { - Ok(val) => log::trace!( - "returning {}::{} -> {} ({})", - to, - method, - from, - val.exit_code - ), - Err(e) => log::trace!("failing {}::{} -> {} (err:{})", to, method, from, e), + Ok(val) => { + log::trace!("returning {to}::{entrypoint} -> {from} ({})", val.exit_code) + } + Err(e) => log::trace!("failing {to}::{entrypoint} -> {from} (err:{e})"), } } @@ -943,3 +988,19 @@ impl EventsAccumulator { }) } } + +impl Entrypoint { + fn method_num(&self) -> MethodNum { + match self { + Entrypoint::Create => fvm_shared::METHOD_CONSTRUCTOR, + Entrypoint::Invoke(num) => *num, + } + } + + fn func_name(&self) -> &'static str { + match self { + Entrypoint::Create => "create", + Entrypoint::Invoke(_) => "invoke", + } + } +} diff --git a/fvm/src/call_manager/mod.rs b/fvm/src/call_manager/mod.rs index f88a32a5a..9b46fa2a0 100644 --- a/fvm/src/call_manager/mod.rs +++ b/fvm/src/call_manager/mod.rs @@ -74,7 +74,7 @@ pub trait CallManager: 'static { read_only: bool, ) -> Result; - /// Execute some operation (usually a send) within a transaction. + /// Execute some operation (usually a send or an actor creation) within a transaction. fn with_transaction( &mut self, f: impl FnOnce(&mut Self) -> Result, @@ -107,15 +107,21 @@ pub trait CallManager: 'static { fn next_actor_address(&self) -> Address; /// Create a new actor with the given code CID, actor ID, and delegated address. This method - /// does not register the actor with the init actor. It just creates it in the state-tree. + /// does not register the actor with the init actor. It just creates it in the state-tree and + /// calls the method constructor. /// /// It handles all appropriate gas charging for creating new actors. - fn create_actor( + /// + /// Returns the invocation result of the constructor method. + fn create_actor>( &mut self, code_id: Cid, actor_id: ActorID, delegated_address: Option
, - ) -> Result<()>; + value: &TokenAmount, + params: Option, + gas_limit: Option, + ) -> Result; /// Resolve an address into an actor ID, charging gas as appropriate. fn resolve_address(&self, address: &Address) -> Result>; @@ -197,3 +203,21 @@ pub struct FinishRet { pub events: Vec, pub events_root: Option, } + +/// The WASM module entrypoint to call. +#[derive(Debug, Clone, Copy)] +pub enum Entrypoint { + /// Call the create function. The method number will be fixed to 1. + Create, + /// Call the invoke function with the given method number. + Invoke(MethodNum), +} + +impl std::fmt::Display for Entrypoint { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + Entrypoint::Create => write!(f, "create"), + Entrypoint::Invoke(num) => write!(f, "invoke({})", num), + } + } +} diff --git a/fvm/src/kernel/default.rs b/fvm/src/kernel/default.rs index 997334948..0f5f478d7 100644 --- a/fvm/src/kernel/default.rs +++ b/fvm/src/kernel/default.rs @@ -148,6 +148,21 @@ where })?; // Store result and return. + self.store_result(result) + } +} + +impl DefaultKernel +where + C: CallManager, +{ + /// Returns `Some(actor_state)` or `None` if this actor has been deleted. + fn get_self(&self) -> Result> { + self.call_manager.get_actor(self.actor_id) + } + + /// Store the result of an invocation. + fn store_result(&mut self, result: InvocationResult) -> Result { Ok(match result { InvocationResult { exit_code, @@ -177,16 +192,6 @@ where } } -impl DefaultKernel -where - C: CallManager, -{ - /// Returns `Some(actor_state)` or `None` if this actor has been deleted. - fn get_self(&self) -> Result> { - self.call_manager.get_actor(self.actor_id) - } -} - impl SelfOps for DefaultKernel where C: CallManager, @@ -832,7 +837,10 @@ where code_id: Cid, actor_id: ActorID, delegated_address: Option
, - ) -> Result<()> { + value: &TokenAmount, + params_id: BlockId, + gas_limit: Option, + ) -> Result { let is_allowed_to_create_actor = self.actor_id == INIT_ACTOR_ID; #[cfg(feature = "testing")] @@ -854,8 +862,30 @@ where ); } - self.call_manager - .create_actor(code_id, actor_id, delegated_address) + // Load parameters. + let params = if params_id == NO_DATA_BLOCK_ID { + None + } else { + Some(self.blocks.get(params_id)?.clone()) + }; + + // Make sure we can actually store the return block. + if self.blocks.is_full() { + return Err(syscall_error!(LimitExceeded; "cannot store return block").into()); + } + + let result = self.call_manager.with_transaction(|cm| { + cm.create_actor::( + code_id, + actor_id, + delegated_address, + value, + params, + gas_limit, + ) + })?; + + self.store_result(result) } fn get_builtin_actor_type(&self, code_cid: &Cid) -> Result { diff --git a/fvm/src/kernel/mod.rs b/fvm/src/kernel/mod.rs index b094c3dc5..4bf41bd77 100644 --- a/fvm/src/kernel/mod.rs +++ b/fvm/src/kernel/mod.rs @@ -209,7 +209,10 @@ pub trait ActorOps { code_cid: Cid, actor_id: ActorID, delegated_address: Option
, - ) -> Result<()>; + value: &TokenAmount, + params_id: BlockId, + gas_limit: Option, + ) -> Result; /// Installs actor code pointed by cid #[cfg(feature = "m2-native")] diff --git a/fvm/src/syscalls/actor.rs b/fvm/src/syscalls/actor.rs index 7376631e9..4405d2f83 100644 --- a/fvm/src/syscalls/actor.rs +++ b/fvm/src/syscalls/actor.rs @@ -1,10 +1,12 @@ // Copyright 2021-2023 Protocol Labs // SPDX-License-Identifier: Apache-2.0, MIT use anyhow::{anyhow, Context as _}; +use fvm_shared::econ::TokenAmount; use fvm_shared::{sys, ActorID}; use super::Context; -use crate::kernel::{ClassifyResult, Result}; +use crate::gas::Gas; +use crate::kernel::{ClassifyResult, Result, SendResult}; use crate::{syscall_error, Kernel}; pub fn resolve_address( @@ -90,13 +92,18 @@ pub fn next_actor_address( Ok(len as u32) } -pub fn create_actor( - context: Context<'_, impl Kernel>, +#[allow(clippy::too_many_arguments)] +pub fn create_actor( + context: Context<'_, K>, actor_id: u64, // ID typ_off: u32, // Cid delegated_addr_off: u32, delegated_addr_len: u32, -) -> Result<()> { + params_id: u32, + value_hi: u64, + value_lo: u64, + gas_limit: u64, +) -> Result { let typ = context.memory.read_cid(typ_off)?; let addr = (delegated_addr_len > 0) .then(|| { @@ -106,7 +113,26 @@ pub fn create_actor( }) .transpose()?; - context.kernel.create_actor(typ, actor_id, addr) + let value = TokenAmount::from_atto((value_hi as u128) << 64 | value_lo as u128); + + // If the gas is u64::MAX, treat it as "all gas". Although really, this doesn't matter. Any gas + // exceeding the current gas available is treated as "all remaining gas". + let gas_limit = (gas_limit < u64::MAX).then(|| Gas::new(gas_limit)); + + let SendResult { + block_id, + block_stat, + exit_code, + } = context + .kernel + .create_actor(typ, actor_id, addr, &value, params_id, gas_limit)?; + + Ok(sys::out::send::Send { + exit_code: exit_code.value(), + return_id: block_id, + return_codec: block_stat.codec, + return_size: block_stat.size, + }) } pub fn get_builtin_actor_type( diff --git a/fvm/src/syscalls/bind.rs b/fvm/src/syscalls/bind.rs index ec959339d..23a5d29c1 100644 --- a/fvm/src/syscalls/bind.rs +++ b/fvm/src/syscalls/bind.rs @@ -206,3 +206,6 @@ impl_bind_syscalls!(A B C D E); impl_bind_syscalls!(A B C D E F); impl_bind_syscalls!(A B C D E F G); impl_bind_syscalls!(A B C D E F G H); +impl_bind_syscalls!(A B C D E F G H I); +impl_bind_syscalls!(A B C D E F G H I J); +impl_bind_syscalls!(A B C D E F G H I J L); diff --git a/fvm/src/trace/mod.rs b/fvm/src/trace/mod.rs index fcbec8287..8fe5b25e9 100644 --- a/fvm/src/trace/mod.rs +++ b/fvm/src/trace/mod.rs @@ -1,11 +1,12 @@ // Copyright 2021-2023 Protocol Labs // SPDX-License-Identifier: Apache-2.0, MIT use fvm_ipld_encoding::ipld_block::IpldBlock; -use fvm_shared::address::Address; +use fvm_shared::address::MaybeResolvedAddress; use fvm_shared::econ::TokenAmount; use fvm_shared::error::ExitCode; -use fvm_shared::{ActorID, MethodNum}; +use fvm_shared::ActorID; +use crate::call_manager::Entrypoint; use crate::gas::GasCharge; use crate::kernel::SyscallError; @@ -21,8 +22,8 @@ pub enum ExecutionEvent { GasCharge(GasCharge), Call { from: ActorID, - to: Address, - method: MethodNum, + to: MaybeResolvedAddress, + entrypoint: Entrypoint, params: Option, value: TokenAmount, }, diff --git a/fvm/tests/dummy.rs b/fvm/tests/dummy.rs index 26eb8c15e..fc74b4f1c 100644 --- a/fvm/tests/dummy.rs +++ b/fvm/tests/dummy.rs @@ -353,12 +353,15 @@ impl CallManager for DummyCallManager { todo!() } - fn create_actor( + fn create_actor>( &mut self, _code_id: Cid, _actor_id: ActorID, _delegated_address: Option
, - ) -> kernel::Result<()> { + _value: &TokenAmount, + _params: Option, + _gas_limit: Option, + ) -> kernel::Result { todo!() } diff --git a/sdk/src/actor.rs b/sdk/src/actor.rs index 3aa6c283f..155e7d62c 100644 --- a/sdk/src/actor.rs +++ b/sdk/src/actor.rs @@ -4,13 +4,14 @@ use core::option::Option; use std::ptr; // no_std use cid::Cid; +use fvm_ipld_encoding::ipld_block::IpldBlock; use fvm_shared::address::{Address, Payload, MAX_ADDRESS_LEN}; use fvm_shared::econ::TokenAmount; -use fvm_shared::error::ErrorNumber; -use fvm_shared::{ActorID, MAX_CID_LEN}; +use fvm_shared::error::{ErrorNumber, ExitCode}; +use fvm_shared::{ActorID, Response, MAX_CID_LEN}; use log::error; -use crate::{sys, SyscallResult}; +use crate::{sys, SyscallResult, NO_DATA_BLOCK_ID}; /// Resolves the ID address of an actor. Returns `None` if the address cannot be resolved. /// Successfully resolving an address doesn't necessarily mean the actor exists (e.g., if the @@ -95,7 +96,13 @@ pub fn create_actor( actor_id: ActorID, code_cid: &Cid, delegated_address: Option
, -) -> SyscallResult<()> { + params: Option, + value: TokenAmount, + gas_limit: Option, +) -> SyscallResult { + let value: sys::TokenAmount = value + .try_into() + .map_err(|_| ErrorNumber::InsufficientFunds)?; unsafe { let cid = code_cid.to_bytes(); let addr_bytes = delegated_address.map(|addr| addr.to_bytes()); @@ -103,7 +110,51 @@ pub fn create_actor( .as_deref() .map(|v| (v.as_ptr(), v.len())) .unwrap_or((ptr::null(), 0)); - sys::actor::create_actor(actor_id, cid.as_ptr(), addr_off, addr_len as u32) + + // Insert parameters as a block. Missing parameters are represented as the + // NO_DATA_BLOCK_ID block ID in the FFI interface. + let params_id = match params { + Some(p) => sys::ipld::block_create(p.codec, p.data.as_ptr(), p.data.len() as u32)?, + None => NO_DATA_BLOCK_ID, + }; + + let fvm_shared::sys::out::send::Send { + exit_code, + return_id, + return_codec, + return_size, + } = sys::actor::create_actor( + actor_id, + cid.as_ptr(), + addr_off, + addr_len as u32, + params_id, + value.hi, + value.lo, + gas_limit.unwrap_or(u64::MAX), + )?; + + // Process the result. + let exit_code = ExitCode::new(exit_code); + let return_data = if return_id == NO_DATA_BLOCK_ID { + None + } else { + // Allocate a buffer to read the return data. + let mut bytes = vec![0; return_size as usize]; + + // Now read the return data. + let unread = sys::ipld::block_read(return_id, 0, bytes.as_mut_ptr(), return_size)?; + assert_eq!(0, unread); + Some(IpldBlock { + codec: return_codec, + data: bytes.to_vec(), + }) + }; + + Ok(Response { + exit_code, + return_data, + }) } } diff --git a/sdk/src/sys/actor.rs b/sdk/src/sys/actor.rs index af8024729..f8f076444 100644 --- a/sdk/src/sys/actor.rs +++ b/sdk/src/sys/actor.rs @@ -2,6 +2,8 @@ // SPDX-License-Identifier: Apache-2.0, MIT //! Syscalls for creating and resolving actors. +use fvm_shared::sys; + // for documentation links #[cfg(doc)] use crate::sys::ErrorNumber::*; @@ -126,7 +128,11 @@ super::fvm_syscalls! { typ_off: *const u8, delegated_addr_off: *const u8, delegated_addr_len: u32, - ) -> Result<()>; + params_id: u32, + value_hi: u64, + value_lo: u64, + gas_limit: u64, + ) -> Result; /// Installs and ensures actor code is valid and loaded. /// **Privileged:** May only be called by the init actor. diff --git a/shared/src/address/mod.rs b/shared/src/address/mod.rs index c4367ae8b..6601dc7d5 100644 --- a/shared/src/address/mod.rs +++ b/shared/src/address/mod.rs @@ -380,6 +380,33 @@ pub(crate) fn from_leb_bytes(bz: &[u8]) -> Result { Ok(id) } +#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] +pub enum MaybeResolvedAddress { + Unresolved(Address), + Resolved(ActorID), +} + +impl std::fmt::Display for MaybeResolvedAddress { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + MaybeResolvedAddress::Unresolved(addr) => addr.fmt(f), + MaybeResolvedAddress::Resolved(id) => write!(f, "resolved({id})"), + } + } +} + +impl From
for MaybeResolvedAddress { + fn from(value: Address) -> Self { + Self::Unresolved(value) + } +} + +impl From for MaybeResolvedAddress { + fn from(value: ActorID) -> Self { + Self::Resolved(value) + } +} + #[cfg(test)] mod tests { // Test cases for FOR-02: https://github.com/ChainSafe/forest/issues/1134 diff --git a/testing/conformance/src/vm.rs b/testing/conformance/src/vm.rs index 51a9bbc53..c2da436fd 100644 --- a/testing/conformance/src/vm.rs +++ b/testing/conformance/src/vm.rs @@ -274,8 +274,18 @@ where code_id: Cid, actor_id: ActorID, delegated_address: Option
, - ) -> Result<()> { - self.0.create_actor(code_id, actor_id, delegated_address) + value: &TokenAmount, + params_id: BlockId, + gas_limit: Option, + ) -> Result { + self.0.create_actor( + code_id, + actor_id, + delegated_address, + value, + params_id, + gas_limit, + ) } fn get_builtin_actor_type(&self, code_cid: &Cid) -> Result { diff --git a/testing/integration/Cargo.toml b/testing/integration/Cargo.toml index 5bd43b522..7e9484974 100644 --- a/testing/integration/Cargo.toml +++ b/testing/integration/Cargo.toml @@ -33,7 +33,7 @@ default-features = false features = ["cranelift", "parallel-compilation"] [dev-dependencies] -actors-v10 = { package = "fil_builtin_actors_bundle", git = "https://github.com/filecoin-project/builtin-actors", branch = "next" } +actors-v10 = { package = "fil_builtin_actors_bundle", path = "../../../filecoin-builtin-actors" } fvm_test_actors = { path = "../test_actors" } fvm_gas_calibration_shared = { path = "../calibration/shared" } blake2b_simd = "1.0.1" diff --git a/testing/test_actors/actors/fil-address-actor/src/actor.rs b/testing/test_actors/actors/fil-address-actor/src/actor.rs index d7409e24a..43bafa427 100644 --- a/testing/test_actors/actors/fil-address-actor/src/actor.rs +++ b/testing/test_actors/actors/fil-address-actor/src/actor.rs @@ -7,20 +7,24 @@ use fvm_shared::error::ExitCode; use sdk::sys::ErrorNumber; #[no_mangle] -pub fn invoke(params: u32) -> u32 { +pub fn create(params: u32) -> u32 { + sdk::initialize(); + assert_eq!(sdk::message::method_number(), 1); + // Check our address. + let msg_params = sdk::message::params_raw(params).unwrap().unwrap(); + assert_eq!(msg_params.codec, fvm_ipld_encoding::CBOR); + let expected_address: Option
= + fvm_ipld_encoding::from_slice(msg_params.data.as_slice()).unwrap(); + let actual_address = sdk::actor::lookup_delegated_address(sdk::message::receiver()); + assert_eq!(expected_address, actual_address, "addresses did not match"); + 0 +} + +#[no_mangle] +pub fn invoke(_: u32) -> u32 { sdk::initialize(); match sdk::message::method_number() { - // on construction, make sure the address matches the expected one.` - 1 => { - // Check our address. - let msg_params = sdk::message::params_raw(params).unwrap().unwrap(); - assert_eq!(msg_params.codec, fvm_ipld_encoding::CBOR); - let expected_address: Option
= - fvm_ipld_encoding::from_slice(msg_params.data.as_slice()).unwrap(); - let actual_address = sdk::actor::lookup_delegated_address(sdk::message::receiver()); - assert_eq!(expected_address, actual_address, "addresses did not match"); - } // send to an f1, then resolve. 2 => { // Create an account. diff --git a/testing/test_actors/actors/fil-create-actor/Cargo.toml b/testing/test_actors/actors/fil-create-actor/Cargo.toml index c7bedeeea..3ee8699c9 100644 --- a/testing/test_actors/actors/fil-create-actor/Cargo.toml +++ b/testing/test_actors/actors/fil-create-actor/Cargo.toml @@ -7,7 +7,10 @@ publish = false [target.'cfg(target_arch = "wasm32")'.dependencies] fvm_sdk = { version = "3.3.0", path = "../../../../sdk" } fvm_shared = { version = "3.4.0", path = "../../../../shared" } -actors_v10_runtime = { package = "fil_actors_runtime", git = "https://github.com/filecoin-project/builtin-actors", branch = "next" } +fvm_ipld_encoding = { version = "0.4.0", path = "../../../../ipld/encoding" } +#actors_v10_runtime = { package = "fil_actors_runtime", git = "https://github.com/filecoin-project/builtin-actors", branch = "next" } +actors_v10_runtime = { package = "fil_actors_runtime", path = "../../../../../filecoin-builtin-actors/runtime" } +serde = { version = "1.0.136", features = ["derive"] } [lib] crate-type = ["cdylib"] ## cdylib is necessary for Wasm build diff --git a/testing/test_actors/actors/fil-create-actor/src/actor.rs b/testing/test_actors/actors/fil-create-actor/src/actor.rs index 8abd6de74..dc110bee8 100644 --- a/testing/test_actors/actors/fil-create-actor/src/actor.rs +++ b/testing/test_actors/actors/fil-create-actor/src/actor.rs @@ -1,10 +1,19 @@ // Copyright 2021-2023 Protocol Labs // SPDX-License-Identifier: Apache-2.0, MIT use actors_v10_runtime::runtime::builtins::Type; +use fvm_ipld_encoding::ipld_block::IpldBlock; +use fvm_ipld_encoding::tuple::*; +use fvm_ipld_encoding::tuple::{Deserialize_tuple, Serialize_tuple}; use fvm_sdk as sdk; use fvm_shared::address::{Address, SECP_PUB_LEN}; +use fvm_shared::clock::ChainEpoch; use fvm_shared::error::ErrorNumber; +#[no_mangle] +pub fn create(_: u32) -> u32 { + 0 +} + #[no_mangle] pub fn invoke(_: u32) -> u32 { sdk::initialize(); @@ -14,11 +23,36 @@ pub fn invoke(_: u32) -> u32 { match method { // our actor ID is allowed to call create actor 1 => { + #[derive(Serialize_tuple, Deserialize_tuple)] + struct MultisigConstructorParams { + signers: Vec
, + num_approvals_threshold: u64, + unlock_duration: ChainEpoch, + start_epoch: ChainEpoch, + } + // verify we can create a MultiSig actor without "delegated" address // let msig_addr = Address::new_id(1000); let msig_cid = sdk::actor::get_code_cid_for_type(Type::Multisig as i32); - sdk::actor::create_actor(msig_addr.id().unwrap(), &msig_cid, None).unwrap(); + sdk::actor::create_actor( + msig_addr.id().unwrap(), + &msig_cid, + None, + Some( + IpldBlock::serialize_cbor(&MultisigConstructorParams { + signers: vec![msig_addr], + num_approvals_threshold: 1, + unlock_duration: Default::default(), + start_epoch: Default::default(), + }) + .unwrap() + .unwrap(), + ), + Default::default(), + None, + ) + .unwrap(); assert_eq!( None, sdk::actor::lookup_delegated_address(msig_addr.id().unwrap()) @@ -28,19 +62,36 @@ pub fn invoke(_: u32) -> u32 { sdk::actor::get_actor_code_cid(&msig_addr).unwrap() ); - // verify we can create an Account actor with "delegated" address + // verify we can create a MultiSig actor with "delegated" address // - let acct_addr = Address::new_id(1001); - let acct_cid = sdk::actor::get_code_cid_for_type(Type::Account as i32); + let msig_addr = Address::new_id(1001); + let msig_cid = sdk::actor::get_code_cid_for_type(Type::Multisig as i32); let dlg_addr = Address::new_secp256k1(&[0u8; SECP_PUB_LEN]).unwrap(); - sdk::actor::create_actor(acct_addr.id().unwrap(), &acct_cid, Some(dlg_addr)).unwrap(); + sdk::actor::create_actor( + msig_addr.id().unwrap(), + &msig_cid, + Some(dlg_addr), + Some( + IpldBlock::serialize_cbor(&MultisigConstructorParams { + signers: vec![msig_addr], + num_approvals_threshold: 1, + unlock_duration: Default::default(), + start_epoch: Default::default(), + }) + .unwrap() + .unwrap(), + ), + Default::default(), + None, + ) + .unwrap(); assert_eq!( Some(dlg_addr), - sdk::actor::lookup_delegated_address(acct_addr.id().unwrap()) + sdk::actor::lookup_delegated_address(msig_addr.id().unwrap()) ); assert_eq!( - acct_cid, - sdk::actor::get_actor_code_cid(&acct_addr).unwrap() + msig_cid, + sdk::actor::get_actor_code_cid(&msig_addr).unwrap() ); // creating a Placeholder without delegated" address should fail @@ -48,7 +99,14 @@ pub fn invoke(_: u32) -> u32 { let placeholder_cid = sdk::actor::get_code_cid_for_type(Type::Placeholder as i32); assert_eq!( Err(ErrorNumber::Forbidden), - sdk::actor::create_actor(1002, &placeholder_cid, None) + sdk::actor::create_actor( + 1002, + &placeholder_cid, + None, + None, + Default::default(), + None, + ) ); // verify that resolving address returns None if address cannot be resolved @@ -66,14 +124,22 @@ pub fn invoke(_: u32) -> u32 { // verify that creating a MultiSig actor without "delegated" address should fail // let msig_cid = sdk::actor::get_code_cid_for_type(Type::Multisig as i32); - let res = sdk::actor::create_actor(1000, &msig_cid, None); + let res = + sdk::actor::create_actor(1000, &msig_cid, None, None, Default::default(), None); assert_eq!(res, Err(ErrorNumber::Forbidden)); // verify that creating an Account actor with "delegated" address should fail // let acct_cid = sdk::actor::get_code_cid_for_type(Type::Account as i32); let acct_addr = Address::new_secp256k1(&[0u8; SECP_PUB_LEN]).unwrap(); - let res = sdk::actor::create_actor(1001, &acct_cid, Some(acct_addr)); + let res = sdk::actor::create_actor( + 1001, + &acct_cid, + Some(acct_addr), + None, + Default::default(), + None, + ); assert_eq!(res, Err(ErrorNumber::Forbidden)); } _ => { diff --git a/testing/test_actors/actors/fil-events-actor/src/actor.rs b/testing/test_actors/actors/fil-events-actor/src/actor.rs index 32d3705c3..e06193599 100644 --- a/testing/test_actors/actors/fil-events-actor/src/actor.rs +++ b/testing/test_actors/actors/fil-events-actor/src/actor.rs @@ -8,6 +8,11 @@ use fvm_shared::bigint::Zero; use fvm_shared::error::ExitCode; use fvm_shared::event::{Entry, Flags}; +#[no_mangle] +pub fn create(_: u32) -> u32 { + 0 +} + #[no_mangle] pub fn invoke(params: u32) -> u32 { sdk::initialize(); diff --git a/testing/test_actors/actors/fil-syscall-actor/Cargo.toml b/testing/test_actors/actors/fil-syscall-actor/Cargo.toml index 7357715ac..42bf4637b 100644 --- a/testing/test_actors/actors/fil-syscall-actor/Cargo.toml +++ b/testing/test_actors/actors/fil-syscall-actor/Cargo.toml @@ -9,7 +9,8 @@ fvm_ipld_encoding = { version = "0.4.0", path = "../../../../ipld/encoding" } fvm_sdk = { version = "3.3.0", path = "../../../../sdk" } fvm_shared = { version = "3.4.0", path = "../../../../shared" } minicov = {version = "0.3", optional = true} -actors_v10_runtime = { package = "fil_actors_runtime", git = "https://github.com/filecoin-project/builtin-actors", branch = "next" } +#actors_v10_runtime = { package = "fil_actors_runtime", git = "https://github.com/filecoin-project/builtin-actors", branch = "next" } +actors_v10_runtime = { package = "fil_actors_runtime", path = "../../../../../filecoin-builtin-actors/runtime" } multihash = { workspace = true } [lib]