diff --git a/Cargo.lock b/Cargo.lock index 386b12f633..823f09a899 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -17,7 +17,7 @@ dependencies = [ "actix-rt", "actix_derive", "bitflags", - "bytes 1.4.0", + "bytes 1.6.1", "crossbeam-channel", "futures-core", "futures-sink", @@ -521,7 +521,7 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fb4401f0a3622dad2e0763fa79e0eb328bc70fb7dccfdd645341f00d671247d6" dependencies = [ - "bytes 1.4.0", + "bytes 1.6.1", "futures-sink", "futures-util", "memchr", @@ -534,7 +534,7 @@ version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "06a0daa378f5fd10634e44b0a29b2a87b890657658e072a30d6f26e57ddee182" dependencies = [ - "bytes 1.4.0", + "bytes 1.6.1", "futures-sink", "futures-util", "memchr", @@ -991,7 +991,7 @@ checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" [[package]] name = "bytecode-interpreter-crypto" version = "0.1.0" -source = "git+https://github.com/starcoinorg/move?rev=7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc#7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc" +source = "git+https://github.com/starcoinorg/move?rev=905484b15b2a2218013fdb2c034f1d7898d29a25#905484b15b2a2218013fdb2c034f1d7898d29a25" dependencies = [ "anyhow", "curve25519-dalek-fiat", @@ -1024,9 +1024,9 @@ dependencies = [ [[package]] name = "bytes" -version = "1.4.0" +version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" +checksum = "a12916984aab3fa6e39d655a33e09c0071eb36d6ab3aea5c2d78551f1df6d952" [[package]] name = "bytesize" @@ -1345,7 +1345,7 @@ version = "4.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "35ed6e9d84f0b51a7f52daf1c7d71dd136fd7a3f41a8462b8cdb8c78d920fad4" dependencies = [ - "bytes 1.4.0", + "bytes 1.6.1", "memchr", ] @@ -2327,7 +2327,7 @@ dependencies = [ "anyhow", "bcs", "bindgen 0.59.2", - "bytes 1.4.0", + "bytes 1.6.1", "cc", "curve25519-dalek-fiat", "diem-crypto-derive", @@ -2537,7 +2537,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "40d9bd57d914cc66ce878f098f63ed7b5d5b64c30644a5adb950b008f874a6c6" dependencies = [ "base64 0.11.0", - "bytes 1.4.0", + "bytes 1.6.1", "dyn-clone", "lazy_static 1.4.0", "percent-encoding 2.2.0", @@ -3291,7 +3291,7 @@ version = "0.3.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5f9f29bc9dda355256b2916cf526ab02ce0aeaaaf2bad60d65ef3f12f11dd0f4" dependencies = [ - "bytes 1.4.0", + "bytes 1.6.1", "fnv", "futures-core", "futures-sink", @@ -3453,7 +3453,7 @@ version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "75f43d41e26995c17e71ee126451dd3941010b0514a81a9d11f3b341debc2399" dependencies = [ - "bytes 1.4.0", + "bytes 1.6.1", "fnv", "itoa", ] @@ -3464,7 +3464,7 @@ version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1" dependencies = [ - "bytes 1.4.0", + "bytes 1.6.1", "http", "pin-project-lite 0.2.9", ] @@ -3518,7 +3518,7 @@ version = "0.14.24" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5e011372fa0b68db8350aa7a248930ecc7839bf46d8485577d69f117a75f164c" dependencies = [ - "bytes 1.4.0", + "bytes 1.6.1", "futures-channel", "futures-core", "futures-util", @@ -3542,7 +3542,7 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" dependencies = [ - "bytes 1.4.0", + "bytes 1.6.1", "hyper 0.14.24", "native-tls", "tokio", @@ -3798,7 +3798,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e8a11ae2da61704edada656798b61c94b35ecac2c58eb955156987d5e6be90b" dependencies = [ "async-trait", - "bytes 1.4.0", + "bytes 1.6.1", "log 0.4.17", "rand 0.8.5", "rtcp", @@ -4123,7 +4123,7 @@ version = "18.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fa4fdea130485b572c39a460d50888beb00afb3e35de23ccd7fad8ff19f0e0d4" dependencies = [ - "bytes 1.4.0", + "bytes 1.6.1", "futures 0.3.26", "globset", "jsonrpc-core 18.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4140,7 +4140,7 @@ name = "jsonrpc-server-utils" version = "18.0.0" source = "git+https://github.com/starcoinorg/jsonrpc?rev=e895b6cc5897f3813a953a9a6bb4718b4856ab19#e895b6cc5897f3813a953a9a6bb4718b4856ab19" dependencies = [ - "bytes 1.4.0", + "bytes 1.6.1", "futures 0.3.26", "globset", "jsonrpc-core 18.0.0 (git+https://github.com/starcoinorg/jsonrpc?rev=e895b6cc5897f3813a953a9a6bb4718b4856ab19)", @@ -4291,7 +4291,7 @@ version = "0.50.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2e0a0d2f693675f49ded13c5d510c48b78069e23cbd9108d7ccd59f6dc568819" dependencies = [ - "bytes 1.4.0", + "bytes 1.6.1", "futures 0.3.26", "futures-timer", "getrandom 0.2.8", @@ -4396,7 +4396,7 @@ checksum = "2766dcd2be8c87d5e1f35487deb22d765f49c6ae1251b3633efe3b25698bd3d2" dependencies = [ "arrayvec 0.7.2", "asynchronous-codec 0.6.1", - "bytes 1.4.0", + "bytes 1.6.1", "either", "fnv", "futures 0.3.26", @@ -4457,7 +4457,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "03805b44107aa013e7cbbfa5627b31c36cbedfdfb00603c0311998882bc4bace" dependencies = [ "asynchronous-codec 0.6.1", - "bytes 1.4.0", + "bytes 1.6.1", "futures 0.3.26", "libp2p-core", "log 0.4.17", @@ -4474,7 +4474,7 @@ version = "0.41.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a978cb57efe82e892ec6f348a536bfbd9fee677adbe5689d7a93ad3a9bffbf2e" dependencies = [ - "bytes 1.4.0", + "bytes 1.6.1", "curve25519-dalek 3.2.0", "futures 0.3.26", "libp2p-core", @@ -4513,7 +4513,7 @@ version = "0.7.0-alpha" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "01e7c867e95c8130667b24409d236d37598270e6da69b3baf54213ba31ffca59" dependencies = [ - "bytes 1.4.0", + "bytes 1.6.1", "futures 0.3.26", "futures-timer", "if-watch", @@ -4535,7 +4535,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3236168796727bfcf4927f766393415361e2c644b08bedb6a6b13d957c9a4884" dependencies = [ "async-trait", - "bytes 1.4.0", + "bytes 1.6.1", "futures 0.3.26", "instant", "libp2p-core", @@ -4621,7 +4621,7 @@ checksum = "cdb6cd86dd68cba72308ea05de1cebf3ba0ae6e187c40548167955d4e3970f6a" dependencies = [ "async-trait", "asynchronous-codec 0.6.1", - "bytes 1.4.0", + "bytes 1.6.1", "futures 0.3.26", "futures-timer", "hex", @@ -5126,7 +5126,7 @@ checksum = "c9be0862c1b3f26a88803c4a49de6889c10e608b3ee9344e6ef5b45fb37ad3d1" [[package]] name = "move-abigen" version = "0.1.0" -source = "git+https://github.com/starcoinorg/move?rev=7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc#7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc" +source = "git+https://github.com/starcoinorg/move?rev=905484b15b2a2218013fdb2c034f1d7898d29a25#905484b15b2a2218013fdb2c034f1d7898d29a25" dependencies = [ "anyhow", "bcs", @@ -5143,7 +5143,7 @@ dependencies = [ [[package]] name = "move-binary-format" version = "0.0.3" -source = "git+https://github.com/starcoinorg/move?rev=7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc#7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc" +source = "git+https://github.com/starcoinorg/move?rev=905484b15b2a2218013fdb2c034f1d7898d29a25#905484b15b2a2218013fdb2c034f1d7898d29a25" dependencies = [ "anyhow", "arbitrary", @@ -5159,12 +5159,12 @@ dependencies = [ [[package]] name = "move-borrow-graph" version = "0.0.1" -source = "git+https://github.com/starcoinorg/move?rev=7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc#7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc" +source = "git+https://github.com/starcoinorg/move?rev=905484b15b2a2218013fdb2c034f1d7898d29a25#905484b15b2a2218013fdb2c034f1d7898d29a25" [[package]] name = "move-bytecode-source-map" version = "0.1.0" -source = "git+https://github.com/starcoinorg/move?rev=7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc#7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc" +source = "git+https://github.com/starcoinorg/move?rev=905484b15b2a2218013fdb2c034f1d7898d29a25#905484b15b2a2218013fdb2c034f1d7898d29a25" dependencies = [ "anyhow", "bcs", @@ -5179,7 +5179,7 @@ dependencies = [ [[package]] name = "move-bytecode-utils" version = "0.1.0" -source = "git+https://github.com/starcoinorg/move?rev=7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc#7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc" +source = "git+https://github.com/starcoinorg/move?rev=905484b15b2a2218013fdb2c034f1d7898d29a25#905484b15b2a2218013fdb2c034f1d7898d29a25" dependencies = [ "anyhow", "move-binary-format", @@ -5191,7 +5191,7 @@ dependencies = [ [[package]] name = "move-bytecode-verifier" version = "0.1.0" -source = "git+https://github.com/starcoinorg/move?rev=7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc#7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc" +source = "git+https://github.com/starcoinorg/move?rev=905484b15b2a2218013fdb2c034f1d7898d29a25#905484b15b2a2218013fdb2c034f1d7898d29a25" dependencies = [ "anyhow", "fail", @@ -5204,7 +5204,7 @@ dependencies = [ [[package]] name = "move-bytecode-viewer" version = "0.1.0" -source = "git+https://github.com/starcoinorg/move?rev=7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc#7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc" +source = "git+https://github.com/starcoinorg/move?rev=905484b15b2a2218013fdb2c034f1d7898d29a25#905484b15b2a2218013fdb2c034f1d7898d29a25" dependencies = [ "anyhow", "clap 3.2.23", @@ -5221,7 +5221,7 @@ dependencies = [ [[package]] name = "move-cli" version = "0.1.0" -source = "git+https://github.com/starcoinorg/move?rev=7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc#7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc" +source = "git+https://github.com/starcoinorg/move?rev=905484b15b2a2218013fdb2c034f1d7898d29a25#905484b15b2a2218013fdb2c034f1d7898d29a25" dependencies = [ "anyhow", "bcs", @@ -5267,7 +5267,7 @@ dependencies = [ [[package]] name = "move-command-line-common" version = "0.1.0" -source = "git+https://github.com/starcoinorg/move?rev=7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc#7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc" +source = "git+https://github.com/starcoinorg/move?rev=905484b15b2a2218013fdb2c034f1d7898d29a25#905484b15b2a2218013fdb2c034f1d7898d29a25" dependencies = [ "anyhow", "difference", @@ -5284,7 +5284,7 @@ dependencies = [ [[package]] name = "move-compiler" version = "0.0.1" -source = "git+https://github.com/starcoinorg/move?rev=7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc#7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc" +source = "git+https://github.com/starcoinorg/move?rev=905484b15b2a2218013fdb2c034f1d7898d29a25#905484b15b2a2218013fdb2c034f1d7898d29a25" dependencies = [ "anyhow", "bcs", @@ -5313,7 +5313,7 @@ dependencies = [ [[package]] name = "move-core-types" version = "0.0.4" -source = "git+https://github.com/starcoinorg/move?rev=7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc#7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc" +source = "git+https://github.com/starcoinorg/move?rev=905484b15b2a2218013fdb2c034f1d7898d29a25#905484b15b2a2218013fdb2c034f1d7898d29a25" dependencies = [ "anyhow", "arbitrary", @@ -5337,7 +5337,7 @@ dependencies = [ [[package]] name = "move-coverage" version = "0.1.0" -source = "git+https://github.com/starcoinorg/move?rev=7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc#7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc" +source = "git+https://github.com/starcoinorg/move?rev=905484b15b2a2218013fdb2c034f1d7898d29a25#905484b15b2a2218013fdb2c034f1d7898d29a25" dependencies = [ "anyhow", "bcs", @@ -5374,7 +5374,7 @@ dependencies = [ [[package]] name = "move-disassembler" version = "0.1.0" -source = "git+https://github.com/starcoinorg/move?rev=7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc#7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc" +source = "git+https://github.com/starcoinorg/move?rev=905484b15b2a2218013fdb2c034f1d7898d29a25#905484b15b2a2218013fdb2c034f1d7898d29a25" dependencies = [ "anyhow", "clap 3.2.23", @@ -5392,7 +5392,7 @@ dependencies = [ [[package]] name = "move-docgen" version = "0.1.0" -source = "git+https://github.com/starcoinorg/move?rev=7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc#7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc" +source = "git+https://github.com/starcoinorg/move?rev=905484b15b2a2218013fdb2c034f1d7898d29a25#905484b15b2a2218013fdb2c034f1d7898d29a25" dependencies = [ "anyhow", "codespan 0.11.1", @@ -5410,7 +5410,7 @@ dependencies = [ [[package]] name = "move-errmapgen" version = "0.1.0" -source = "git+https://github.com/starcoinorg/move?rev=7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc#7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc" +source = "git+https://github.com/starcoinorg/move?rev=905484b15b2a2218013fdb2c034f1d7898d29a25#905484b15b2a2218013fdb2c034f1d7898d29a25" dependencies = [ "anyhow", "bcs", @@ -5424,7 +5424,7 @@ dependencies = [ [[package]] name = "move-ir-compiler" version = "0.1.0" -source = "git+https://github.com/starcoinorg/move?rev=7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc#7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc" +source = "git+https://github.com/starcoinorg/move?rev=905484b15b2a2218013fdb2c034f1d7898d29a25#905484b15b2a2218013fdb2c034f1d7898d29a25" dependencies = [ "anyhow", "bcs", @@ -5443,7 +5443,7 @@ dependencies = [ [[package]] name = "move-ir-to-bytecode" version = "0.1.0" -source = "git+https://github.com/starcoinorg/move?rev=7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc#7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc" +source = "git+https://github.com/starcoinorg/move?rev=905484b15b2a2218013fdb2c034f1d7898d29a25#905484b15b2a2218013fdb2c034f1d7898d29a25" dependencies = [ "anyhow", "codespan-reporting", @@ -5462,7 +5462,7 @@ dependencies = [ [[package]] name = "move-ir-to-bytecode-syntax" version = "0.1.0" -source = "git+https://github.com/starcoinorg/move?rev=7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc#7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc" +source = "git+https://github.com/starcoinorg/move?rev=905484b15b2a2218013fdb2c034f1d7898d29a25#905484b15b2a2218013fdb2c034f1d7898d29a25" dependencies = [ "anyhow", "hex", @@ -5475,7 +5475,7 @@ dependencies = [ [[package]] name = "move-ir-types" version = "0.1.0" -source = "git+https://github.com/starcoinorg/move?rev=7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc#7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc" +source = "git+https://github.com/starcoinorg/move?rev=905484b15b2a2218013fdb2c034f1d7898d29a25#905484b15b2a2218013fdb2c034f1d7898d29a25" dependencies = [ "anyhow", "hex", @@ -5489,7 +5489,7 @@ dependencies = [ [[package]] name = "move-model" version = "0.1.0" -source = "git+https://github.com/starcoinorg/move?rev=7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc#7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc" +source = "git+https://github.com/starcoinorg/move?rev=905484b15b2a2218013fdb2c034f1d7898d29a25#905484b15b2a2218013fdb2c034f1d7898d29a25" dependencies = [ "anyhow", "codespan 0.11.1", @@ -5515,7 +5515,7 @@ dependencies = [ [[package]] name = "move-package" version = "0.1.0" -source = "git+https://github.com/starcoinorg/move?rev=7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc#7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc" +source = "git+https://github.com/starcoinorg/move?rev=905484b15b2a2218013fdb2c034f1d7898d29a25#905484b15b2a2218013fdb2c034f1d7898d29a25" dependencies = [ "anyhow", "bcs", @@ -5556,6 +5556,7 @@ dependencies = [ "bcs", "bcs-ext", "clap 3.2.23", + "codespan-reporting", "datatest-stable 0.1.1", "difference", "futures 0.3.26", @@ -5572,6 +5573,7 @@ dependencies = [ "move-coverage 0.1.0", "move-disassembler", "move-errmapgen", + "move-model", "move-package", "move-unit-test", "move-vm-runtime", @@ -5599,7 +5601,7 @@ dependencies = [ [[package]] name = "move-prover" version = "0.1.0" -source = "git+https://github.com/starcoinorg/move?rev=7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc#7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc" +source = "git+https://github.com/starcoinorg/move?rev=905484b15b2a2218013fdb2c034f1d7898d29a25#905484b15b2a2218013fdb2c034f1d7898d29a25" dependencies = [ "anyhow", "async-trait", @@ -5628,7 +5630,7 @@ dependencies = [ "rand 0.8.5", "serde 1.0.152", "serde_json", - "simplelog", + "simplelog 0.12.2", "tokio", "toml", ] @@ -5636,7 +5638,7 @@ dependencies = [ [[package]] name = "move-prover-boogie-backend" version = "0.1.0" -source = "git+https://github.com/starcoinorg/move?rev=7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc#7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc" +source = "git+https://github.com/starcoinorg/move?rev=905484b15b2a2218013fdb2c034f1d7898d29a25#905484b15b2a2218013fdb2c034f1d7898d29a25" dependencies = [ "anyhow", "async-trait", @@ -5664,7 +5666,7 @@ dependencies = [ [[package]] name = "move-prover-test-utils" version = "0.1.0" -source = "git+https://github.com/starcoinorg/move?rev=7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc#7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc" +source = "git+https://github.com/starcoinorg/move?rev=905484b15b2a2218013fdb2c034f1d7898d29a25#905484b15b2a2218013fdb2c034f1d7898d29a25" dependencies = [ "anyhow", "move-command-line-common", @@ -5675,7 +5677,7 @@ dependencies = [ [[package]] name = "move-read-write-set-types" version = "0.0.3" -source = "git+https://github.com/starcoinorg/move?rev=7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc#7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc" +source = "git+https://github.com/starcoinorg/move?rev=905484b15b2a2218013fdb2c034f1d7898d29a25#905484b15b2a2218013fdb2c034f1d7898d29a25" dependencies = [ "anyhow", "move-binary-format", @@ -5686,7 +5688,7 @@ dependencies = [ [[package]] name = "move-resource-viewer" version = "0.1.0" -source = "git+https://github.com/starcoinorg/move?rev=7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc#7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc" +source = "git+https://github.com/starcoinorg/move?rev=905484b15b2a2218013fdb2c034f1d7898d29a25#905484b15b2a2218013fdb2c034f1d7898d29a25" dependencies = [ "anyhow", "bcs", @@ -5701,7 +5703,7 @@ dependencies = [ [[package]] name = "move-stackless-bytecode" version = "0.1.0" -source = "git+https://github.com/starcoinorg/move?rev=7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc#7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc" +source = "git+https://github.com/starcoinorg/move?rev=905484b15b2a2218013fdb2c034f1d7898d29a25#905484b15b2a2218013fdb2c034f1d7898d29a25" dependencies = [ "codespan 0.11.1", "codespan-reporting", @@ -5728,7 +5730,7 @@ dependencies = [ [[package]] name = "move-stackless-bytecode-interpreter" version = "0.1.0" -source = "git+https://github.com/starcoinorg/move?rev=7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc#7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc" +source = "git+https://github.com/starcoinorg/move?rev=905484b15b2a2218013fdb2c034f1d7898d29a25#905484b15b2a2218013fdb2c034f1d7898d29a25" dependencies = [ "anyhow", "bytecode-interpreter-crypto", @@ -5746,7 +5748,7 @@ dependencies = [ [[package]] name = "move-stdlib" version = "0.1.1" -source = "git+https://github.com/starcoinorg/move?rev=7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc#7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc" +source = "git+https://github.com/starcoinorg/move?rev=905484b15b2a2218013fdb2c034f1d7898d29a25#905484b15b2a2218013fdb2c034f1d7898d29a25" dependencies = [ "anyhow", "hex", @@ -5769,7 +5771,7 @@ dependencies = [ [[package]] name = "move-symbol-pool" version = "0.1.0" -source = "git+https://github.com/starcoinorg/move?rev=7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc#7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc" +source = "git+https://github.com/starcoinorg/move?rev=905484b15b2a2218013fdb2c034f1d7898d29a25#905484b15b2a2218013fdb2c034f1d7898d29a25" dependencies = [ "once_cell", "serde 1.0.152", @@ -5778,7 +5780,7 @@ dependencies = [ [[package]] name = "move-table-extension" version = "0.1.0" -source = "git+https://github.com/starcoinorg/move?rev=7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc#7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc" +source = "git+https://github.com/starcoinorg/move?rev=905484b15b2a2218013fdb2c034f1d7898d29a25#905484b15b2a2218013fdb2c034f1d7898d29a25" dependencies = [ "anyhow", "bcs", @@ -5795,7 +5797,7 @@ dependencies = [ [[package]] name = "move-transactional-test-runner" version = "0.1.0" -source = "git+https://github.com/starcoinorg/move?rev=7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc#7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc" +source = "git+https://github.com/starcoinorg/move?rev=905484b15b2a2218013fdb2c034f1d7898d29a25#905484b15b2a2218013fdb2c034f1d7898d29a25" dependencies = [ "anyhow", "clap 3.2.23", @@ -5830,7 +5832,7 @@ dependencies = [ [[package]] name = "move-unit-test" version = "0.1.0" -source = "git+https://github.com/starcoinorg/move?rev=7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc#7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc" +source = "git+https://github.com/starcoinorg/move?rev=905484b15b2a2218013fdb2c034f1d7898d29a25#905484b15b2a2218013fdb2c034f1d7898d29a25" dependencies = [ "anyhow", "better_any", @@ -5861,9 +5863,10 @@ dependencies = [ [[package]] name = "move-vm-runtime" version = "0.1.0" -source = "git+https://github.com/starcoinorg/move?rev=7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc#7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc" +source = "git+https://github.com/starcoinorg/move?rev=905484b15b2a2218013fdb2c034f1d7898d29a25#905484b15b2a2218013fdb2c034f1d7898d29a25" dependencies = [ "better_any", + "bytes 1.6.1", "fail", "move-binary-format", "move-bytecode-verifier", @@ -5873,12 +5876,13 @@ dependencies = [ "parking_lot 0.11.2", "sha3", "tracing", + "typed-arena", ] [[package]] name = "move-vm-test-utils" version = "0.1.0" -source = "git+https://github.com/starcoinorg/move?rev=7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc#7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc" +source = "git+https://github.com/starcoinorg/move?rev=905484b15b2a2218013fdb2c034f1d7898d29a25#905484b15b2a2218013fdb2c034f1d7898d29a25" dependencies = [ "anyhow", "move-binary-format", @@ -5892,7 +5896,7 @@ dependencies = [ [[package]] name = "move-vm-types" version = "0.1.0" -source = "git+https://github.com/starcoinorg/move?rev=7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc#7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc" +source = "git+https://github.com/starcoinorg/move?rev=905484b15b2a2218013fdb2c034f1d7898d29a25#905484b15b2a2218013fdb2c034f1d7898d29a25" dependencies = [ "bcs", "move-binary-format", @@ -5970,7 +5974,7 @@ version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c8552ab875c1313b97b8d20cb857b9fd63e2d1d6a0a1b53ce9821e575405f27a" dependencies = [ - "bytes 1.4.0", + "bytes 1.6.1", "futures 0.3.26", "log 0.4.17", "pin-project 1.0.12", @@ -6074,7 +6078,7 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "65b4b14489ab424703c092062176d52ba55485a89c076b4f9db05092b7223aa6" dependencies = [ - "bytes 1.4.0", + "bytes 1.6.1", "futures 0.3.26", "log 0.4.17", "netlink-packet-core", @@ -6089,7 +6093,7 @@ version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "260e21fbb6f3d253a14df90eb0000a6066780a15dd901a7519ce02d77a94985b" dependencies = [ - "bytes 1.4.0", + "bytes 1.6.1", "futures 0.3.26", "libc", "log 0.4.17", @@ -6130,7 +6134,7 @@ dependencies = [ "bcs-ext", "bitflags", "bs58 0.3.1", - "bytes 1.4.0", + "bytes 1.6.1", "derive_more", "either", "fnv", @@ -6199,7 +6203,7 @@ version = "2.0.1" dependencies = [ "anyhow", "bitflags", - "bytes 1.4.0", + "bytes 1.6.1", "derive_more", "libp2p", "rand 0.8.5", @@ -7448,7 +7452,7 @@ version = "0.11.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "21dc42e00223fc37204bd4aa177e69420c604ca4a183209a8f9de30c6d934698" dependencies = [ - "bytes 1.4.0", + "bytes 1.6.1", "prost-derive", ] @@ -7458,7 +7462,7 @@ version = "0.11.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a3f8ad728fb08fe212df3c05169e940fbb6d9d16a877ddde14644a983ba2012e" dependencies = [ - "bytes 1.4.0", + "bytes 1.6.1", "heck 0.4.1", "itertools", "lazy_static 1.4.0", @@ -7481,7 +7485,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0dc34979ff898b6e141106178981ce2596c387ea6e62533facfc61a37fc879c0" dependencies = [ "asynchronous-codec 0.6.1", - "bytes 1.4.0", + "bytes 1.6.1", "prost", "thiserror", "unsigned-varint 0.7.1", @@ -7506,7 +7510,7 @@ version = "0.11.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a5e0526209433e96d83d750dd81a99118edbc55739e7e61a46764fd2ad537788" dependencies = [ - "bytes 1.4.0", + "bytes 1.6.1", "prost", ] @@ -7601,7 +7605,7 @@ version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72ef4ced82a24bb281af338b9e8f94429b6eca01b4e66d899f40031f074e74c9" dependencies = [ - "bytes 1.4.0", + "bytes 1.6.1", "rand 0.8.5", "ring", "rustc-hash", @@ -7923,7 +7927,7 @@ dependencies = [ [[package]] name = "read-write-set" version = "0.1.0" -source = "git+https://github.com/starcoinorg/move?rev=7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc#7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc" +source = "git+https://github.com/starcoinorg/move?rev=905484b15b2a2218013fdb2c034f1d7898d29a25#905484b15b2a2218013fdb2c034f1d7898d29a25" dependencies = [ "anyhow", "move-binary-format", @@ -7938,7 +7942,7 @@ dependencies = [ [[package]] name = "read-write-set-dynamic" version = "0.1.0" -source = "git+https://github.com/starcoinorg/move?rev=7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc#7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc" +source = "git+https://github.com/starcoinorg/move?rev=905484b15b2a2218013fdb2c034f1d7898d29a25#905484b15b2a2218013fdb2c034f1d7898d29a25" dependencies = [ "anyhow", "move-binary-format", @@ -8044,7 +8048,7 @@ checksum = "21eed90ec8570952d53b772ecf8f206aa1ec9a3d76b2521c56c42973f2d91ee9" dependencies = [ "async-compression", "base64 0.21.0", - "bytes 1.4.0", + "bytes 1.6.1", "encoding_rs", "futures-core", "futures-util", @@ -8198,7 +8202,7 @@ version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1919efd6d4a6a85d13388f9487549bb8e359f17198cc03ffd72f79b553873691" dependencies = [ - "bytes 1.4.0", + "bytes 1.6.1", "thiserror", "webrtc-util", ] @@ -8225,7 +8229,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2a095411ff00eed7b12e4c6a118ba984d113e1079582570d56a5ee723f11f80" dependencies = [ "async-trait", - "bytes 1.4.0", + "bytes 1.6.1", "rand 0.8.5", "serde 1.0.152", "thiserror", @@ -9017,6 +9021,17 @@ dependencies = [ "termcolor", ] +[[package]] +name = "simplelog" +version = "0.12.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16257adbfaef1ee58b1363bdc0664c9b8e1e30aed86049635fb5f147d065a9c0" +dependencies = [ + "log 0.4.17", + "termcolor", + "time 0.3.19", +] + [[package]] name = "siphasher" version = "0.3.10" @@ -9137,7 +9152,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "41d1c5305e39e09653383c2c7244f2f78b3bcae37cf50c64cb4789c9f5096ec2" dependencies = [ "base64 0.13.1", - "bytes 1.4.0", + "bytes 1.6.1", "flate2", "futures 0.3.26", "httparse", @@ -10198,7 +10213,7 @@ dependencies = [ "serde 1.0.152", "serde_json", "shell-words", - "simplelog", + "simplelog 0.9.0", "tempfile", "toml", "walkdir", @@ -10254,7 +10269,7 @@ dependencies = [ "async-trait", "bcs-ext", "bitflags", - "bytes 1.4.0", + "bytes 1.6.1", "derive_more", "fnv", "futures 0.3.26", @@ -10296,7 +10311,7 @@ dependencies = [ "anyhow", "api-limiter", "bcs-ext", - "bytes 1.4.0", + "bytes 1.6.1", "futures 0.3.26", "futures-timer", "hex", @@ -11179,7 +11194,7 @@ dependencies = [ "anyhow", "bcs-ext", "byteorder", - "bytes 1.4.0", + "bytes 1.6.1", "forkable-jellyfish-merkle", "hex", "lazy_static 1.4.0", @@ -11218,10 +11233,12 @@ dependencies = [ "anyhow", "bcs-ext", "hex", + "move-binary-format", "move-core-types", "move-stdlib", "move-table-extension", "move-vm-runtime", + "move-vm-types", "num_cpus", "num_enum", "once_cell", @@ -11300,7 +11317,7 @@ dependencies = [ "once_cell", "serde 1.0.152", "sha2 0.10.6", - "simplelog", + "simplelog 0.9.0", "starcoin-crypto", "starcoin-framework", "starcoin-move-compiler", @@ -11993,7 +12010,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c8e00990ebabbe4c14c08aca901caed183ecd5c09562a12c824bb53d3c3fd3af" dependencies = [ "autocfg 1.1.0", - "bytes 1.4.0", + "bytes 1.6.1", "libc", "memchr", "mio 0.8.6", @@ -12152,7 +12169,7 @@ version = "0.6.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "36943ee01a6d67977dd3f84a5a1d2efeb4ada3a1ae771cadfaa535d9d9fc6507" dependencies = [ - "bytes 1.4.0", + "bytes 1.6.1", "futures-core", "futures-sink", "log 0.4.17", @@ -12166,7 +12183,7 @@ version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5427d89453009325de0d8f342c9490009f76e999cb7672d77e46267448f7e6b2" dependencies = [ - "bytes 1.4.0", + "bytes 1.6.1", "futures-core", "futures-io", "futures-sink", @@ -12590,7 +12607,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "35581ff83d4101e58b582e607120c7f5ffb17e632a980b1f38334d76b36908b2" dependencies = [ "asynchronous-codec 0.5.0", - "bytes 1.4.0", + "bytes 1.6.1", "futures-io", "futures-util", ] @@ -12602,7 +12619,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d86a8dc7f45e4c1b0d30e43038c38f274e77af056aa5f74b93c2cf9eb3c1c836" dependencies = [ "asynchronous-codec 0.6.1", - "bytes 1.4.0", + "bytes 1.6.1", "futures-io", "futures-util", ] @@ -12902,7 +12919,7 @@ checksum = "2d3bc9049bdb2cea52f5fd4f6f728184225bdb867ed0dc2410eab6df5bdd67bb" dependencies = [ "arc-swap", "async-trait", - "bytes 1.4.0", + "bytes 1.6.1", "hex", "interceptor", "lazy_static 1.4.0", @@ -12941,7 +12958,7 @@ version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ef36a4d12baa6e842582fe9ec16a57184ba35e1a09308307b67d43ec8883100" dependencies = [ - "bytes 1.4.0", + "bytes 1.6.1", "derive_builder 0.11.2", "log 0.4.17", "thiserror", @@ -13035,7 +13052,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ee2a3c157a040324e5049bcbd644ffc9079e6738fa2cfab2bcff64e5cc4c00d7" dependencies = [ "byteorder", - "bytes 1.4.0", + "bytes 1.6.1", "derive_builder 0.11.2", "displaydoc", "rand 0.8.5", @@ -13052,7 +13069,7 @@ checksum = "0d47adcd9427eb3ede33d5a7f3424038f63c965491beafcc20bc650a2f6679c0" dependencies = [ "arc-swap", "async-trait", - "bytes 1.4.0", + "bytes 1.6.1", "crc", "log 0.4.17", "rand 0.8.5", @@ -13072,7 +13089,7 @@ dependencies = [ "aes-gcm 0.9.4", "async-trait", "byteorder", - "bytes 1.4.0", + "bytes 1.6.1", "ctr 0.8.0", "hmac 0.11.0", "log 0.4.17", @@ -13093,7 +13110,7 @@ checksum = "93f1db1727772c05cf7a2cfece52c3aca8045ca1e176cd517d323489aa3c6d87" dependencies = [ "async-trait", "bitflags", - "bytes 1.4.0", + "bytes 1.6.1", "cc", "ipnet", "lazy_static 1.4.0", diff --git a/Cargo.toml b/Cargo.toml index a171783d1f..ca5941a55c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -343,31 +343,31 @@ log4rs = { version = "1.2.0", features = ["background_rotation", "gzip"] } lru = "0.7.8" merkletree = { version = "0.22.1" } mirai-annotations = "1.10.1" -move-binary-format = { git = "https://github.com/starcoinorg/move", rev = "7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc" } -move-bytecode-source-map = { git = "https://github.com/starcoinorg/move", rev = "7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc" } -move-bytecode-verifier = { git = "https://github.com/starcoinorg/move", rev = "7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc" } -move-cli = { git = "https://github.com/starcoinorg/move", rev = "7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc" } -move-command-line-common = { git = "https://github.com/starcoinorg/move", rev = "7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc" } -move-compiler = { git = "https://github.com/starcoinorg/move", rev = "7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc" } -move-core-types = { git = "https://github.com/starcoinorg/move", rev = "7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc" } -move-coverage = { git = "https://github.com/starcoinorg/move", rev = "7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc" } -move-disassembler = { git = "https://github.com/starcoinorg/move", rev = "7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc" } -move-docgen = { git = "https://github.com/starcoinorg/move", rev = "7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc" } -move-errmapgen = { git = "https://github.com/starcoinorg/move", rev = "7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc" } -move-ir-compiler = { git = "https://github.com/starcoinorg/move", rev = "7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc" } -move-ir-types = { git = "https://github.com/starcoinorg/move", rev = "7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc" } -move-model = { git = "https://github.com/starcoinorg/move", rev = "7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc" } -move-package = { git = "https://github.com/starcoinorg/move", rev = "7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc" } -move-prover = { git = "https://github.com/starcoinorg/move", rev = "7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc" } -move-prover-test-utils = { git = "https://github.com/starcoinorg/move", rev = "7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc" } -move-resource-viewer = { git = "https://github.com/starcoinorg/move", rev = "7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc" } -move-stdlib = { git = "https://github.com/starcoinorg/move", rev = "7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc" } -move-transactional-test-runner = { git = "https://github.com/starcoinorg/move", rev = "7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc" } -move-unit-test = { git = "https://github.com/starcoinorg/move", rev = "7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc", features = ["table-extension"] } -move-vm-runtime = { git = "https://github.com/starcoinorg/move", rev = "7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc" } -move-vm-types = { git = "https://github.com/starcoinorg/move", rev = "7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc" } -move-table-extension = { git = "https://github.com/starcoinorg/move", rev = "7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc" } -move-vm-test-utils = { git = "https://github.com/starcoinorg/move", rev = "7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc", features = ["table-extension"] } +move-binary-format = { git = "https://github.com/starcoinorg/move", rev = "905484b15b2a2218013fdb2c034f1d7898d29a25" } +move-bytecode-source-map = { git = "https://github.com/starcoinorg/move", rev = "905484b15b2a2218013fdb2c034f1d7898d29a25" } +move-bytecode-verifier = { git = "https://github.com/starcoinorg/move", rev = "905484b15b2a2218013fdb2c034f1d7898d29a25" } +move-cli = { git = "https://github.com/starcoinorg/move", rev = "905484b15b2a2218013fdb2c034f1d7898d29a25" } +move-command-line-common = { git = "https://github.com/starcoinorg/move", rev = "905484b15b2a2218013fdb2c034f1d7898d29a25" } +move-compiler = { git = "https://github.com/starcoinorg/move", rev = "905484b15b2a2218013fdb2c034f1d7898d29a25" } +move-core-types = { git = "https://github.com/starcoinorg/move", rev = "905484b15b2a2218013fdb2c034f1d7898d29a25" } +move-coverage = { git = "https://github.com/starcoinorg/move", rev = "905484b15b2a2218013fdb2c034f1d7898d29a25" } +move-disassembler = { git = "https://github.com/starcoinorg/move", rev = "905484b15b2a2218013fdb2c034f1d7898d29a25" } +move-docgen = { git = "https://github.com/starcoinorg/move", rev = "905484b15b2a2218013fdb2c034f1d7898d29a25" } +move-errmapgen = { git = "https://github.com/starcoinorg/move", rev = "905484b15b2a2218013fdb2c034f1d7898d29a25" } +move-ir-compiler = { git = "https://github.com/starcoinorg/move", rev = "905484b15b2a2218013fdb2c034f1d7898d29a25" } +move-ir-types = { git = "https://github.com/starcoinorg/move", rev = "905484b15b2a2218013fdb2c034f1d7898d29a25" } +move-model = { git = "https://github.com/starcoinorg/move", rev = "905484b15b2a2218013fdb2c034f1d7898d29a25" } +move-package = { git = "https://github.com/starcoinorg/move", rev = "905484b15b2a2218013fdb2c034f1d7898d29a25" } +move-prover = { git = "https://github.com/starcoinorg/move", rev = "905484b15b2a2218013fdb2c034f1d7898d29a25" } +move-prover-test-utils = { git = "https://github.com/starcoinorg/move", rev = "905484b15b2a2218013fdb2c034f1d7898d29a25" } +move-resource-viewer = { git = "https://github.com/starcoinorg/move", rev = "905484b15b2a2218013fdb2c034f1d7898d29a25" } +move-stdlib = { git = "https://github.com/starcoinorg/move", rev = "905484b15b2a2218013fdb2c034f1d7898d29a25" } +move-transactional-test-runner = { git = "https://github.com/starcoinorg/move", rev = "905484b15b2a2218013fdb2c034f1d7898d29a25" } +move-unit-test = { git = "https://github.com/starcoinorg/move", rev = "905484b15b2a2218013fdb2c034f1d7898d29a25", features = ["table-extension"] } +move-vm-runtime = { git = "https://github.com/starcoinorg/move", rev = "905484b15b2a2218013fdb2c034f1d7898d29a25" } +move-vm-types = { git = "https://github.com/starcoinorg/move", rev = "905484b15b2a2218013fdb2c034f1d7898d29a25" } +move-table-extension = { git = "https://github.com/starcoinorg/move", rev = "905484b15b2a2218013fdb2c034f1d7898d29a25" } +move-vm-test-utils = { git = "https://github.com/starcoinorg/move", rev = "905484b15b2a2218013fdb2c034f1d7898d29a25", features = ["table-extension"] } names = { version = "0.14.0", default-features = false } network-api = { path = "network/api", package = "network-api" } @@ -535,9 +535,7 @@ unsigned-varint = { version = "0.6.0", features = [ "futures", "asynchronous_codec", ] } -vm = { package = "move-binary-format", git = "https://github.com/starcoinorg/move", rev = "7b6ac7bb04515ee4ced5b1c1cdafb6ea6cb4eadc", features = [ - "fuzzing", -] } +vm = { package = "move-binary-format", git = "https://github.com/starcoinorg/move", rev = "905484b15b2a2218013fdb2c034f1d7898d29a25", features = ["fuzzing"] } vm-status-translator = { path = "vm/vm-status-translator" } void = "1.0.2" walkdir = "2.3.1" diff --git a/executor/tests/script_function_test.rs b/executor/tests/script_function_test.rs index 3504123fb7..bcb35f5427 100644 --- a/executor/tests/script_function_test.rs +++ b/executor/tests/script_function_test.rs @@ -11,12 +11,15 @@ use starcoin_transaction_builder::{ use starcoin_types::account::Account; use starcoin_types::account_config::association_address; use starcoin_types::transaction::Transaction; +use starcoin_vm_types::account_config::stc_type_tag; use starcoin_vm_types::identifier::Identifier; use starcoin_vm_types::language_storage::ModuleId; +use starcoin_vm_types::state_view::StateReaderExt; use starcoin_vm_types::transaction::{ Package, Script, ScriptFunction, TransactionPayload, TransactionStatus, }; use starcoin_vm_types::vm_status::KeptVMStatus; +use std::ops::Sub; use test_helper::executor::{ compile_ir_script, compile_modules_with_address, compile_script, execute_and_apply, prepare_genesis, @@ -36,10 +39,10 @@ fn prepare_module(chain_state: &ChainStateDB, net: &ChainNetwork) -> ModuleId { public fun fn_public() { } - public(script) fun fn_script() { + public entry fun fn_script() { } - public(script) fun fn_script_with_args(account: signer, i: u64) { + public entry fun fn_script_with_args(account: signer, i: u64) { let r = Self::R { i }; move_to(&account, r); } @@ -201,7 +204,7 @@ fn test_signer_cap_internal_type_error() -> Result<()> { burn_cap:BurnCapability, update_cap:UpdateCapability } - public(script) fun init(sender: signer){ + public entry fun init(sender: signer){ let meta_data = NFT::empty_meta(); NFT::register_v2(&sender, meta_data); let mint_cap = NFT::remove_mint_capability(&sender); @@ -383,3 +386,76 @@ fn test_struct_republish_backward_incompatible() -> Result<()> { Ok(()) } + +#[stest::test] +fn test_transaction_arg_verify() -> Result<()> { + let (initial_amount, gas_amount) = (5_000_000u128, 600u64); + let (chain_state, net) = prepare_genesis(); + let account1 = Account::new(); + let txn1 = Transaction::UserTransaction(create_account_txn_sent_as_association( + &account1, + 0, + initial_amount, + 1, + &net, + )); + let output1 = execute_and_apply(&chain_state, txn1); + assert_eq!(KeptVMStatus::Executed, output1.status().status().unwrap()); + let module_source = r#" + module {{sender}}::test { + use StarcoinFramework::Token::{Token}; + use StarcoinFramework::Account; + + public entry fun deposit_token(account: signer, coin: Token) { + Account::deposit_to_self(&account, coin); + } + } "#; + let module = compile_modules_with_address(*account1.address(), module_source) + .pop() + .unwrap(); + + let package = Package::new_with_module(module)?; + + let txn1 = Transaction::UserTransaction(account1.create_signed_txn_impl( + *account1.address(), + TransactionPayload::Package(package), + 0, + gas_amount, + 1, + 1, + net.chain_id(), + )); + let output = execute_and_apply(&chain_state, txn1); + assert_eq!( + KeptVMStatus::MiscellaneousError, + output.status().status().unwrap() + ); + + let balance = chain_state.get_balance(*account1.address())?; + assert_eq!(balance, Some(initial_amount.sub(u128::from(gas_amount)))); + + let money = 100_000; + let num: u128 = 50_000_000; + let payload = TransactionPayload::ScriptFunction(ScriptFunction::new( + ModuleId::new(*account1.address(), Identifier::new("test").unwrap()), + Identifier::new("deposit_token").unwrap(), + vec![stc_type_tag()], + vec![bcs_ext::to_bytes(&num).unwrap()], + )); + let txn = Transaction::UserTransaction(account1.create_signed_txn_impl( + *account1.address(), + payload, + 1, + money, + 1, + 1, + net.chain_id(), + )); + + let output = execute_and_apply(&chain_state, txn); + assert_eq!( + KeptVMStatus::MiscellaneousError, + output.status().status().unwrap() + ); + Ok(()) +} diff --git a/vm/move-package-manager/Cargo.toml b/vm/move-package-manager/Cargo.toml index f0def8e9cc..4488bf0a78 100644 --- a/vm/move-package-manager/Cargo.toml +++ b/vm/move-package-manager/Cargo.toml @@ -37,6 +37,7 @@ move-core-types = { workspace = true } move-coverage = { workspace = true } move-disassembler = { workspace = true } move-errmapgen = { workspace = true } +move-model = { workspace = true } move-package = { workspace = true } move-unit-test = { workspace = true } move-vm-runtime = { workspace = true } @@ -56,6 +57,10 @@ stdlib = { workspace = true } vm-status-translator = { workspace = true } move-vm-test-utils = { workspace = true } +# extra dependences +codespan-reporting = "0.11.1" + + [dev-dependencies] [package] diff --git a/vm/move-package-manager/src/extended_checks.rs b/vm/move-package-manager/src/extended_checks.rs new file mode 100644 index 0000000000..90a783f0bc --- /dev/null +++ b/vm/move-package-manager/src/extended_checks.rs @@ -0,0 +1,175 @@ +// Copyright (c) The Starcoin Core Contributors +// SPDX-License-Identifier: Apache-2.0 + +use move_core_types::{ + account_address::AccountAddress, identifier::Identifier, language_storage::ModuleId, +}; +use move_model::{ + ast::Attribute, + model::{FunctionEnv, GlobalEnv, Loc, ModuleEnv, QualifiedId, StructId}, + symbol::Symbol, + ty::{PrimitiveType, Type}, +}; +use std::rc::Rc; + +pub(crate) fn run_extended_checks(env: &GlobalEnv) { + let checker = ExtendedChecker::new(env); + checker.run(); +} + +struct ExtendedChecker<'a> { + env: &'a GlobalEnv, + /// The id of the module defining error categories + #[allow(unused)] + error_category_module: ModuleId, +} + +impl<'a> ExtendedChecker<'a> { + fn new(env: &'a GlobalEnv) -> Self { + Self { + env, + error_category_module: ModuleId::new( + AccountAddress::ONE, + Identifier::new("error").unwrap(), + ), + } + } + + // see implementation in `aptos-core` + // https://github.com/aptos-labs/aptos-core/blob/3af88bc872221c4958e6163660c60bc07bf53d38/aptos-move/framework/src/extended_checks.rs#L123 + fn run(&self) { + for ref module in self.env.get_modules() { + if module.is_target() { + self.check_entry_functions(module); + self.check_init_module(module); + self.build_error_map(module); + } + } + } +} + +// ------------------------------------------------------------------------------------------------- +// Helper functions + +impl<'a> ExtendedChecker<'a> { + fn has_attribute(&self, fun: &FunctionEnv, attr_name: &str) -> bool { + self.has_attribute_iter(fun.get_attributes().iter(), attr_name) + } + + fn has_attribute_iter( + &self, + mut attrs: impl Iterator, + attr_name: &str, + ) -> bool { + attrs.any(|attr| { + if let Attribute::Apply(_, name, _) = attr { + self.env.symbol_pool().string(*name).as_str() == attr_name + } else { + false + } + }) + } + + #[allow(unused)] + fn get_runtime_module_id(&self, module: &ModuleEnv<'_>) -> ModuleId { + let name = module.get_name(); + let addr = AccountAddress::from_hex_literal(&format!("0x{:x}", name.addr())).unwrap(); + let name = Identifier::new(self.name_string(name.name()).to_string()).unwrap(); + ModuleId::new(addr, name) + } + + #[allow(unused)] + fn name_string(&self, symbol: Symbol) -> Rc { + self.env.symbol_pool().string(symbol) + } +} + +// ------------------------------------------------------------------------------------------------- +// Module Initialization + +impl<'a> ExtendedChecker<'a> { + fn check_init_module(&self, _module: &ModuleEnv) { + // TODO(simon): implement me. + } +} + +// ------------------------------------------------------------------------------------------------- +// Entry Functions + +impl<'a> ExtendedChecker<'a> { + fn check_entry_functions(&self, module: &ModuleEnv) { + for ref fun in module.get_functions() { + if !fun.is_entry() { + continue; + } + + if self.has_attribute(fun, "legacy_entry_function") { + continue; + } + + self.check_transaction_args(&fun.get_id_loc(), &fun.get_parameter_types()); + if fun.get_return_count() > 0 { + self.env + .error(&fun.get_id_loc(), "entry function cannot return values") + } + } + } + + fn check_transaction_args(&self, loc: &Loc, args: &[Type]) { + for ty in args { + self.check_transaction_input_type(loc, ty); + } + } + + fn check_transaction_input_type(&self, loc: &Loc, ty: &Type) { + use Type::*; + match ty { + Primitive(_) | TypeParameter(_) => { + // Any primitive type allowed, any parameter expected to instantiate with primitive + } + //todo(simon): give it a try to change me to Reference(ReferenceKind::Immutable, bt) + Reference(false, bt) if matches!(bt.as_ref(), Primitive(PrimitiveType::Signer)) => { + // Reference to signer allowed + } + Vector(ety) => { + // Vectors are allowed if element type is allowed + self.check_transaction_input_type(loc, ety) + } + Struct(mid, sid, _) if self.is_allowed_input_struct(mid.qualified(*sid)) => { + // Specific struct types are allowed + } + _ => { + // Everything else is disallowed. + self.env.error( + loc, + &format!( + "type `{}` is not supported as a parameter type", + ty.display(&self.env.get_type_display_ctx()) + ), + ); + } + } + } + + fn is_allowed_input_struct(&self, qid: QualifiedId) -> bool { + let name = self.env.get_struct(qid).get_full_name_with_address(); + // TODO(simon) find a nice way to keep this in sync with allowed_structs in starcoin-vm + matches!( + name.as_str(), + "0x1::string::String" + | "0x1::object::Object" + | "0x1::option::Option" + | "0x1::fixed_point32::FixedPoint32" + | "0x1::fixed_point64::FixedPoint64" + ) + } +} + +// ------------------------------------------------------------------------------------------------- +// Build errors map + +impl<'a> ExtendedChecker<'a> { + fn build_error_map(&self, _module: &ModuleEnv) { + // TODO(simon): implement me. + } +} diff --git a/vm/move-package-manager/src/lib.rs b/vm/move-package-manager/src/lib.rs index e87c1e4824..c49ece8446 100644 --- a/vm/move-package-manager/src/lib.rs +++ b/vm/move-package-manager/src/lib.rs @@ -23,6 +23,7 @@ use std::sync::Mutex; pub mod compatibility_check_cmd; pub mod deployment; +mod extended_checks; pub mod package; pub mod release; diff --git a/vm/move-package-manager/src/release.rs b/vm/move-package-manager/src/release.rs index a1f47792d7..683d5724b3 100644 --- a/vm/move-package-manager/src/release.rs +++ b/vm/move-package-manager/src/release.rs @@ -1,7 +1,10 @@ // Copyright (c) The Starcoin Core Contributors // SPDX-License-Identifier: Apache-2.0 +use crate::extended_checks; use clap::Parser; +use codespan_reporting::diagnostic::Severity; +use codespan_reporting::term::termcolor::{ColorChoice, StandardStream}; use move_binary_format::file_format_common::VERSION_4; use move_binary_format::CompiledModule; use move_cli::sandbox::utils::PackageContext; @@ -9,6 +12,7 @@ use move_cli::Move; use move_compiler::compiled_unit::{CompiledUnit, NamedCompiledModule}; use move_core_types::language_storage::TypeTag; use move_core_types::transaction_argument::{convert_txn_args, TransactionArgument}; +use move_package::ModelConfig; use starcoin_crypto::hash::PlainCryptoHash; use starcoin_move_compiler::bytecode_transpose::ModuleBytecodeDowngrader; use starcoin_types::transaction::parse_transaction_argument; @@ -65,14 +69,33 @@ pub fn handle_release( }; let pkg_ctx = PackageContext::new(&package_path, &move_args.build_config)?; let pkg = pkg_ctx.package(); - let pkg_version = move_args + let resolved_graph = move_args .build_config .clone() .resolution_graph_for_package(package_path.as_ref().unwrap(), &mut std::io::stdout()) - .unwrap() - .root_package - .package - .version; + .unwrap(); + + let model = move_args + .build_config + .clone() + .move_model_for_package( + package_path.as_ref().unwrap(), + ModelConfig { + all_files_as_targets: false, + target_filter: None, + }, + ) + .unwrap(); + extended_checks::run_extended_checks(&model); + if model.diag_count(Severity::Warning) > 0 { + let mut error_writer = StandardStream::stderr(ColorChoice::Auto); + model.report_diag(&mut error_writer, Severity::Warning); + if model.has_errors() { + panic!("extended checks failed"); + } + } + + let pkg_version = resolved_graph.root_package.package.version; let pkg_name = pkg.compiled_package_info.package_name.as_str(); println!("Packaging Modules:"); for m in pkg.root_compiled_units.as_slice() { diff --git a/vm/starcoin-gas/src/gas_meter.rs b/vm/starcoin-gas/src/gas_meter.rs index ff5e99d9d5..811eca846a 100644 --- a/vm/starcoin-gas/src/gas_meter.rs +++ b/vm/starcoin-gas/src/gas_meter.rs @@ -24,6 +24,8 @@ use starcoin_logger::prelude::*; use std::collections::BTreeMap; use move_binary_format::file_format_common::Opcodes; +use move_core_types::account_address::AccountAddress; +use move_core_types::identifier::IdentStr; use starcoin_gas_algebra_ext::InstructionGasParameters; use starcoin_gas_algebra_ext::TransactionGasParameters; @@ -796,4 +798,15 @@ impl GasMeter for StarcoinGasMeter { ) -> PartialVMResult<()> { Ok(()) } + + // see StandardGasMeter in `aptos-core` + fn charge_dependency( + &mut self, + _is_new: bool, + _addr: &AccountAddress, + _name: &IdentStr, + _size: NumBytes, + ) -> PartialVMResult<()> { + Ok(()) + } } diff --git a/vm/vm-runtime/Cargo.toml b/vm/vm-runtime/Cargo.toml index dcbd7d8231..839a245f94 100644 --- a/vm/vm-runtime/Cargo.toml +++ b/vm/vm-runtime/Cargo.toml @@ -27,6 +27,8 @@ starcoin-types = { workspace = true } starcoin-vm-types = { workspace = true } move-stdlib = { workspace = true } move-table-extension = { workspace = true } +move-vm-types = { workspace = true } +move-binary-format = { workspace = true } starcoin-metrics = { optional = true, workspace = true } starcoin-gas = { workspace = true } starcoin-gas-algebra-ext = { workspace = true } diff --git a/vm/vm-runtime/src/lib.rs b/vm/vm-runtime/src/lib.rs index f97498c301..5d047a6df3 100644 --- a/vm/vm-runtime/src/lib.rs +++ b/vm/vm-runtime/src/lib.rs @@ -1,7 +1,6 @@ // Copyright (c) The Starcoin Core Contributors // SPDX-License-Identifier: Apache-2.0 -mod adapter_common; pub mod data_cache; #[cfg(feature = "metrics")] pub mod metrics; @@ -16,6 +15,9 @@ mod errors; pub mod force_upgrade_management; pub mod move_vm_ext; pub mod parallel_executor; +mod verifier; +mod vm_adapter; + use crate::metrics::VMMetrics; use starcoin_vm_types::{ access_path::AccessPath, diff --git a/vm/vm-runtime/src/parallel_executor/mod.rs b/vm/vm-runtime/src/parallel_executor/mod.rs index d63740a717..15005c0844 100644 --- a/vm/vm-runtime/src/parallel_executor/mod.rs +++ b/vm/vm-runtime/src/parallel_executor/mod.rs @@ -6,9 +6,9 @@ mod vm_wrapper; use crate::metrics::VMMetrics; use crate::{ - adapter_common::{preprocess_transaction, PreprocessedTransaction}, parallel_executor::vm_wrapper::StarcoinVMWrapper, starcoin_vm::StarcoinVM, + vm_adapter::{preprocess_transaction, PreprocessedTransaction}, }; use move_core_types::vm_status::{StatusCode, VMStatus}; use rayon::prelude::*; diff --git a/vm/vm-runtime/src/parallel_executor/vm_wrapper.rs b/vm/vm-runtime/src/parallel_executor/vm_wrapper.rs index 0974cc5964..330e95c7d6 100644 --- a/vm/vm-runtime/src/parallel_executor/vm_wrapper.rs +++ b/vm/vm-runtime/src/parallel_executor/vm_wrapper.rs @@ -2,9 +2,9 @@ // SPDX-License-Identifier: Apache-2.0 use crate::{ - adapter_common::{PreprocessedTransaction, VMAdapter}, parallel_executor::{storage_wrapper::VersionedView, StarcoinTransactionOutput}, starcoin_vm::StarcoinVM, + vm_adapter::{PreprocessedTransaction, VMAdapter}, }; use starcoin_parallel_executor::{ diff --git a/vm/vm-runtime/src/starcoin_vm.rs b/vm/vm-runtime/src/starcoin_vm.rs index d6bc95004a..edc45508d4 100644 --- a/vm/vm-runtime/src/starcoin_vm.rs +++ b/vm/vm-runtime/src/starcoin_vm.rs @@ -2,20 +2,21 @@ // SPDX-License-Identifier: Apache-2.0 use crate::access_path_cache::AccessPathCache; -use crate::adapter_common::{ - discard_error_output, discard_error_vm_status, PreprocessedTransaction, VMAdapter, -}; use crate::data_cache::{AsMoveResolver, RemoteStorage, StateViewCache}; use crate::errors::{ convert_normal_success_epilogue_error, convert_prologue_runtime_error, error_split, }; use crate::move_vm_ext::{MoveResolverExt, MoveVmExt, SessionId, SessionOutput}; +use crate::vm_adapter::{ + discard_error_output, discard_error_vm_status, PreprocessedTransaction, + PublishModuleBundleOption, SessionAdapter, VMAdapter, +}; use anyhow::{bail, format_err, Error, Result}; use move_core_types::gas_algebra::{InternalGasPerByte, NumBytes}; use move_core_types::vm_status::StatusCode::VALUE_SERIALIZATION_ERROR; use move_table_extension::NativeTableContext; -use move_vm_runtime::move_vm_adapter::{PublishModuleBundleOption, SessionAdapter}; -use move_vm_runtime::session::Session; +use move_vm_runtime::session::{SerializedReturnValues, Session}; +use move_vm_types::gas::GasMeter; use num_cpus; use once_cell::sync::OnceCell; use starcoin_config::genesis_config::G_LATEST_GAS_PARAMS; @@ -68,6 +69,7 @@ use starcoin_vm_types::{ transaction_metadata::TransactionMetadata, vm_status::{StatusCode, VMStatus}, }; +use std::borrow::Borrow; use std::cmp::min; use std::sync::Arc; @@ -75,7 +77,7 @@ static EXECUTION_CONCURRENCY_LEVEL: OnceCell = OnceCell::new(); #[cfg(feature = "metrics")] use crate::metrics::VMMetrics; -use crate::VMExecutor; +use crate::{verifier, VMExecutor}; #[derive(Clone)] #[allow(clippy::upper_case_acronyms)] @@ -641,16 +643,16 @@ impl StarcoinVM { init_script.function(), sender ); - session - .execute_entry_function( - init_script.module(), - init_script.function(), - init_script.ty_args().to_vec(), - init_script.args().to_vec(), - gas_meter, - sender, - ) - .map_err(|e| e.into_vm_status())?; + Self::validate_execute_entry_function( + &mut session, + init_script.module(), + init_script.function(), + init_script.ty_args().to_vec(), + init_script.args().to_vec(), + gas_meter, + sender, + ) + .map_err(|e| e.into_vm_status())?; } charge_global_write_gas_usage(gas_meter, &session, &txn_data.sender())?; @@ -687,7 +689,8 @@ impl StarcoinVM { self.check_move_version(s.version() as u64)?; }; debug!("TransactionPayload::{:?}", script); - session.execute_script( + Self::validate_execute_script( + &mut session, script.code().to_vec(), script.ty_args().to_vec(), script.args().to_vec(), @@ -697,7 +700,8 @@ impl StarcoinVM { } TransactionPayload::ScriptFunction(script_function) => { debug!("TransactionPayload::{:?}", script_function); - session.execute_entry_function( + Self::validate_execute_entry_function( + &mut session, script_function.module(), script_function.function(), script_function.ty_args().to_vec(), @@ -721,6 +725,66 @@ impl StarcoinVM { } } + fn validate_execute_entry_function( + session: &mut SessionAdapter, + module: &ModuleId, + function_name: &IdentStr, + ty_args: Vec, + args: Vec>, + gas_meter: &mut impl GasMeter, + sender: AccountAddress, + ) -> VMResult { + let (_, func, loaded_func) = + session + .inner + .load_function(module, function_name, &ty_args)?; + + verifier::transaction_arg_validation::validate_combine_singer_and_args( + session, + vec![sender], + &args, + &loaded_func, + )?; + + let final_args = SessionAdapter::::check_and_rearrange_args_by_signer_position( + func, + args.into_iter().map(|b| b.borrow().to_vec()).collect(), + sender, + )?; + session + .inner + .execute_entry_function(module, function_name, ty_args, final_args, gas_meter) + } + + fn validate_execute_script( + session: &mut SessionAdapter, + script: impl Borrow<[u8]>, + ty_args: Vec, + args: Vec>, + gas_meter: &mut impl GasMeter, + sender: AccountAddress, + ) -> VMResult { + let (main, loaded_func) = session + .inner + .load_script(script.borrow(), ty_args.clone())?; + + verifier::transaction_arg_validation::validate_combine_singer_and_args( + session, + vec![sender], + &args, + &loaded_func, + )?; + + let final_args = SessionAdapter::::check_and_rearrange_args_by_signer_position( + main, + args.into_iter().map(|b| b.borrow().to_vec()).collect(), + sender, + )?; + session + .inner + .execute_script(script, ty_args, final_args, gas_meter) + } + /// Run the prologue of a transaction by calling into `PROLOGUE_NAME` function stored /// in the `ACCOUNT_MODULE` on chain. fn run_prologue( diff --git a/vm/vm-runtime/src/verifier/mod.rs b/vm/vm-runtime/src/verifier/mod.rs new file mode 100644 index 0000000000..72dc014925 --- /dev/null +++ b/vm/vm-runtime/src/verifier/mod.rs @@ -0,0 +1,4 @@ +// Copyright (c) The Starcoin Core Contributors +// SPDX-License-Identifier: Apache-2.0 + +pub(crate) mod transaction_arg_validation; diff --git a/vm/vm-runtime/src/verifier/transaction_arg_validation.rs b/vm/vm-runtime/src/verifier/transaction_arg_validation.rs new file mode 100644 index 0000000000..8c46711993 --- /dev/null +++ b/vm/vm-runtime/src/verifier/transaction_arg_validation.rs @@ -0,0 +1,496 @@ +// Copyright (c) The Starcoin Core Contributors +// SPDX-License-Identifier: Apache-2.0 + +// see implementation in `aptos-core` +// https://github.com/aptos-labs/aptos-core/blob/3af88bc872221c4958e6163660c60bc07bf53d38/aptos-move/aptos-vm/src/verifier/transaction_arg_validation.rs#L1 + +use crate::move_vm_ext::MoveResolverExt; +use crate::vm_adapter::SessionAdapter; +use move_binary_format::errors::{Location, PartialVMError, VMError, VMResult}; +use move_binary_format::file_format::FunctionDefinitionIndex; +use move_binary_format::file_format_common::read_uleb128_as_u64; +use move_core_types::vm_status::StatusCode; +use move_core_types::{ + account_address::AccountAddress, ident_str, identifier::Identifier, language_storage::ModuleId, +}; +use move_vm_runtime::session::LoadedFunctionInstantiation; +use move_vm_types::gas::{GasMeter, UnmeteredGasMeter}; +use move_vm_types::loaded_data::runtime_types::Type; +use once_cell::sync::Lazy; +use starcoin_vm_types::language_storage::FunctionId; +use std::borrow::Borrow; +use std::collections::BTreeMap; +use std::io::{Cursor, Read}; + +type ConstructorMap = Lazy>; + +static ALLOWED_STRUCTS: ConstructorMap = Lazy::new(|| { + [ + ( + "0x1::string::String", + FunctionId { + module: ModuleId::new(AccountAddress::ONE, Identifier::from(ident_str!("string"))), + function: Identifier::from(ident_str!("utf8")), + }, + ), + // not implemented in starcoin-framework + ( + "0x1::object::Object", + FunctionId { + module: ModuleId::new(AccountAddress::ONE, Identifier::from(ident_str!("object"))), + function: Identifier::from(ident_str!("address_to_object")), + }, + ), + // not implemented in starcoin-framework + ( + "0x1::option::Option", + FunctionId { + module: ModuleId::new(AccountAddress::ONE, Identifier::from(ident_str!("option"))), + function: Identifier::from(ident_str!("from_vec")), + }, + ), + ( + "0x1::fixed_point32::FixedPoint32", + FunctionId { + module: ModuleId::new( + AccountAddress::ONE, + Identifier::from(ident_str!("fixed_point32")), + ), + function: Identifier::from(ident_str!("create_from_raw_value")), + }, + ), + ( + "0x1::fixed_point64::FixedPoint64", + FunctionId { + module: ModuleId::new( + AccountAddress::ONE, + Identifier::from(ident_str!("fixed_point64")), + ), + function: Identifier::from(ident_str!("create_from_raw_value")), + }, + ), + ] + .into_iter() + .map(|(s, validator)| (s.to_string(), validator)) + .collect() +}); + +fn get_allowed_structs() -> &'static ConstructorMap { + &ALLOWED_STRUCTS +} + +/// Validate and generate args for entry function +/// validation includes: +/// 1. return signature is empty +/// 2. number of signers is same as the number of senders +/// 3. check arg types are allowed after signers +/// +pub(crate) fn validate_combine_singer_and_args( + session: &mut SessionAdapter, + senders: Vec, + args: &[impl Borrow<[u8]>], + func: &LoadedFunctionInstantiation, +) -> VMResult<()> { + SessionAdapter::::check_script_return(func.return_.clone())?; + + let mut signer_param_cnt = 0; + // find all signer params at the beginning + for ty in func.parameters.iter() { + match ty { + Type::Signer => signer_param_cnt += 1, + Type::Reference(inner_type) => { + if matches!(&**inner_type, Type::Signer) { + signer_param_cnt += 1; + } + } + _ => (), + } + } + + let allowed_structs = get_allowed_structs(); + // Need to keep this here to ensure we return the historic correct error code for replay + for ty in func.parameters[signer_param_cnt..].iter() { + let valid = is_valid_txn_arg( + session, + &ty.subst(&func.type_arguments).unwrap(), + allowed_structs, + ); + if !valid { + return Err( + PartialVMError::new(StatusCode::INVALID_MAIN_FUNCTION_SIGNATURE) + .with_message( + "Found un-allowed parameter which is not signer-params".to_string(), + ) + .finish(Location::Script), + ); + } + } + + if (signer_param_cnt + args.len()) != func.parameters.len() { + return Err( + PartialVMError::new(StatusCode::NUMBER_OF_ARGUMENTS_MISMATCH) + .with_message(format!( + "signer params {signer_param_cnt}, args {}, func parameters {}", + args.len(), + func.parameters.len() + )) + .finish(Location::Script), + ); + } + + // If the invoked function expects one or more signers, we need to check that the number of + // signers actually passed is matching first to maintain backward compatibility before + // moving on to the validation of non-signer args. + // the number of txn senders should be the same number of signers + if signer_param_cnt > 0 && senders.len() != signer_param_cnt { + return Err( + PartialVMError::new(StatusCode::NUMBER_OF_SIGNER_ARGUMENTS_MISMATCH) + .finish(Location::Script), + ); + } + + // This also validates that the args are valid. If they are structs, they have to be allowed + // and must be constructed successfully. If construction fails, this would fail with a + // FAILED_TO_DESERIALIZE_ARGUMENT error. + let _ = construct_args( + session, + &func.parameters[signer_param_cnt..], + args, + &func.type_arguments, + allowed_structs, + false, + )?; + + Ok(()) +} + +// Return whether the argument is valid/allowed and whether it needs construction. +pub(crate) fn is_valid_txn_arg( + session: &SessionAdapter, + typ: &Type, + allowed_structs: &ConstructorMap, +) -> bool { + use move_vm_types::loaded_data::runtime_types::Type::*; + + match typ { + Bool | U8 | U16 | U32 | U64 | U128 | U256 | Address => true, + Vector(inner) => is_valid_txn_arg(session, inner, allowed_structs), + Struct(idx) | StructInstantiation(idx, _) => session + .inner + .get_struct_type(*idx) + .map(|st| { + let full_name = format!("{}::{}", st.module.short_str_lossless(), st.name); + allowed_structs.contains_key(&full_name) + }) + .unwrap_or_default(), + Signer | Reference(_) | MutableReference(_) | TyParam(_) => false, + } +} + +// Construct arguments. Walk through the arguments and according to the signature +// construct arguments that require so. +// TODO: This needs a more solid story and a tighter integration with the VM. +pub(crate) fn construct_args( + session: &mut SessionAdapter, + types: &[Type], + args: &[impl Borrow<[u8]>], + ty_args: &[Type], + allowed_structs: &ConstructorMap, + is_view: bool, +) -> VMResult>> { + // Perhaps in a future we should do proper gas metering here + let mut gas_meter = UnmeteredGasMeter; + let mut res_args = vec![]; + if types.len() != args.len() { + return Err(invalid_signature()); + } + for (ty, arg) in types.iter().zip(args) { + let arg = construct_arg( + session, + &ty.subst(ty_args).unwrap(), + allowed_structs, + arg.borrow().to_vec(), + &mut gas_meter, + is_view, + )?; + res_args.push(arg); + } + Ok(res_args) +} + +fn invalid_signature() -> VMError { + PartialVMError::new(StatusCode::INVALID_MAIN_FUNCTION_SIGNATURE).finish(Location::Script) +} + +fn construct_arg( + session: &mut SessionAdapter, + ty: &Type, + allowed_structs: &ConstructorMap, + arg: Vec, + gas_meter: &mut impl GasMeter, + is_view: bool, +) -> VMResult> { + use move_vm_types::loaded_data::runtime_types::Type::*; + match ty { + Bool | U8 | U16 | U32 | U64 | U128 | U256 | Address => Ok(arg), + Vector(_) | Struct { .. } | StructInstantiation { .. } => { + let initial_cursor_len = arg.len(); + let mut cursor = Cursor::new(&arg[..]); + let mut new_arg = vec![]; + let mut max_invocations = 10; // Read from config in the future + recursively_construct_arg( + session, + ty, + allowed_structs, + &mut cursor, + initial_cursor_len, + gas_meter, + &mut max_invocations, + &mut new_arg, + )?; + // Check cursor has parsed everything + // Unfortunately, is_empty is only enabled in nightly, so we check this way. + if cursor.position() != initial_cursor_len as u64 { + return Err( + PartialVMError::new(StatusCode::FAILED_TO_DESERIALIZE_ARGUMENT) + .with_message(String::from( + "The serialized arguments to constructor contained extra data", + )) + .finish(Location::Script), + ); + } + Ok(new_arg) + } + Signer => { + if is_view { + Ok(arg) + } else { + Err(invalid_signature()) + } + } + Reference(_) | MutableReference(_) | TyParam(_) => Err(invalid_signature()), + } +} + +// A Cursor is used to recursively walk the serialized arg manually and correctly. In effect we +// are parsing the BCS serialized implicit constructor invocation tree, while serializing the +// constructed types into the output parameter arg. +pub(crate) fn recursively_construct_arg( + session: &mut SessionAdapter, + ty: &Type, + allowed_structs: &ConstructorMap, + cursor: &mut Cursor<&[u8]>, + initial_cursor_len: usize, + gas_meter: &mut impl GasMeter, + max_invocations: &mut u64, + arg: &mut Vec, +) -> VMResult<()> { + use move_vm_types::loaded_data::runtime_types::Type::*; + + match ty { + Vector(inner) => { + // get the vector length and iterate over each element + let mut len = get_len(cursor)?; + serialize_uleb128(len, arg); + while len > 0 { + recursively_construct_arg( + session, + inner, + allowed_structs, + cursor, + initial_cursor_len, + gas_meter, + max_invocations, + arg, + )?; + len -= 1; + } + } + Struct(idx) | StructInstantiation(idx, _) => { + let st = session + .inner + .get_struct_type(*idx) + .ok_or_else(invalid_signature)?; + + let full_name = format!("{}::{}", st.module.short_str_lossless(), st.name); + let constructor = allowed_structs + .get(&full_name) + .ok_or_else(invalid_signature)?; + // By appending the BCS to the output parameter we construct the correct BCS format + // of the argument. + arg.append(&mut validate_and_construct( + session, + ty, + constructor, + allowed_structs, + cursor, + initial_cursor_len, + gas_meter, + max_invocations, + )?); + } + Bool | U8 => read_n_bytes(1, cursor, arg)?, + U16 => read_n_bytes(2, cursor, arg)?, + U32 => read_n_bytes(4, cursor, arg)?, + U64 => read_n_bytes(8, cursor, arg)?, + // Check the length of Address(aka. AccountAddress), for starcoin case, it's 16-Bytes + U128 | Address => read_n_bytes(16, cursor, arg)?, + U256 => read_n_bytes(32, cursor, arg)?, + Signer | Reference(_) | MutableReference(_) | TyParam(_) => return Err(invalid_signature()), + }; + Ok(()) +} + +// A move function that constructs a type will return the BCS serialized representation of the +// constructed value. This is the correct data to pass as the argument to a function taking +// said struct as a parameter. In this function we execute the constructor constructing the +// value and returning the BCS serialized representation. +fn validate_and_construct( + session: &mut SessionAdapter, + expected_type: &Type, + constructor: &FunctionId, + allowed_structs: &ConstructorMap, + cursor: &mut Cursor<&[u8]>, + initial_cursor_len: usize, + gas_meter: &mut impl GasMeter, + max_invocations: &mut u64, +) -> VMResult> { + if *max_invocations == 0 { + return Err( + PartialVMError::new(StatusCode::FAILED_TO_DESERIALIZE_ARGUMENT) + .finish(Location::Undefined), + ); + } + // HACK mitigation of performance attack + // To maintain compatibility with vector or so on, we need to allow unlimited strings. + // So we do not count the string constructor against the max_invocations, instead we + // shortcut the string case to avoid the performance attack. + if constructor.function.as_str() == "utf8" { + let constructor_error = || { + // A slight hack, to prevent additional piping of the feature flag through all + // function calls. We know the feature is active when more structs then just strings are + // allowed. + let are_struct_constructors_enabled = allowed_structs.len() > 1; + if are_struct_constructors_enabled { + PartialVMError::new(StatusCode::ABORTED) + .with_sub_status(1) + .at_code_offset(FunctionDefinitionIndex::new(0), 0) + .finish(Location::Module(constructor.module.clone())) + } else { + PartialVMError::new(StatusCode::FAILED_TO_DESERIALIZE_ARGUMENT) + .finish(Location::Undefined) + } + }; + // Short cut for the utf8 constructor, which is a special case. + let len = get_len(cursor)?; + if !cursor + .position() + .checked_add(len as u64) + .map(|l| l <= initial_cursor_len as u64) + .unwrap_or_default() + { + // We need to make sure we do not allocate more bytes than + // needed. + return Err( + PartialVMError::new(StatusCode::FAILED_TO_DESERIALIZE_ARGUMENT) + .with_message("String argument is too long".to_string()) + .finish(Location::Undefined), + ); + } + + let mut arg = vec![]; + read_n_bytes(len, cursor, &mut arg)?; + std::str::from_utf8(&arg).map_err(|_| constructor_error())?; + return bcs_ext::to_bytes(&arg).map_err(|_| { + PartialVMError::new(StatusCode::FAILED_TO_DESERIALIZE_ARGUMENT) + .finish(Location::Undefined) + }); + } else { + *max_invocations -= 1; + } + + let (module, function, instantiation) = session.inner.load_function_with_type_arg_inference( + &constructor.module, + constructor.function.as_ref(), + expected_type, + )?; + let mut args = vec![]; + for param_type in &instantiation.parameters { + let mut arg = vec![]; + recursively_construct_arg( + session, + ¶m_type.subst(&instantiation.type_arguments).unwrap(), + allowed_structs, + cursor, + initial_cursor_len, + gas_meter, + max_invocations, + &mut arg, + )?; + args.push(arg); + } + let serialized_result = session.inner.execute_instantiated_function( + module, + function, + instantiation, + args, + gas_meter, + )?; + let mut ret_vals = serialized_result.return_values; + // We know ret_vals.len() == 1 + let deserialize_error = PartialVMError::new(StatusCode::INTERNAL_TYPE_ERROR) + .with_message(String::from("Constructor did not return value")) + .finish(Location::Undefined); + Ok(ret_vals.pop().ok_or(deserialize_error)?.0) +} + +// String is a vector of bytes, so both string and vector carry a length in the serialized format. +// Length of vectors in BCS uses uleb128 as a compression format. +fn get_len(cursor: &mut Cursor<&[u8]>) -> VMResult { + match read_uleb128_as_u64(cursor) { + Err(_) => Err( + PartialVMError::new(StatusCode::FAILED_TO_DESERIALIZE_ARGUMENT) + .finish(Location::Undefined), + ), + Ok(len) => Ok(len as usize), + } +} + +fn serialize_uleb128(mut x: usize, dest: &mut Vec) { + // TODO perhaps reuse the code from move_binary_format::file_format_common if it's public + while x >= 128 { + dest.push((x | 128) as u8); + x >>= 7; + } + dest.push(x as u8); +} + +fn read_n_bytes(n: usize, src: &mut Cursor<&[u8]>, dest: &mut Vec) -> VMResult<()> { + let deserialization_error = |msg: &str| -> VMError { + PartialVMError::new(StatusCode::FAILED_TO_DESERIALIZE_ARGUMENT) + .with_message(msg.to_string()) + .finish(Location::Undefined) + }; + let len = dest.len(); + + // It is safer to limit the length under some big (but still reasonable + // number). + const MAX_NUM_BYTES: usize = 1_000_000; + if !len + .checked_add(n) + .map(|s| s <= MAX_NUM_BYTES) + .unwrap_or_default() + { + return Err(deserialization_error(&format!( + "Couldn't read bytes: maximum limit of {} bytes exceeded", + MAX_NUM_BYTES + ))); + } + + // Ensure we have enough capacity for resizing. + dest.try_reserve(len + n) + .map_err(|e| deserialization_error(&format!("Couldn't read bytes: {}", e)))?; + dest.resize(len + n, 0); + src.read_exact(&mut dest[len..]) + .map_err(|_| deserialization_error("Couldn't read bytes")) +} diff --git a/vm/vm-runtime/src/vm_adapter/adapter.rs b/vm/vm-runtime/src/vm_adapter/adapter.rs new file mode 100644 index 0000000000..8d7a281005 --- /dev/null +++ b/vm/vm-runtime/src/vm_adapter/adapter.rs @@ -0,0 +1,340 @@ +// Copyright (c) The Starcoin Core Contributors +// SPDX-License-Identifier: Apache-2.0 + +use move_binary_format::errors::*; +use move_binary_format::{ + access::ModuleAccess, compatibility::Compatibility, normalized, CompiledModule, IndexKind, +}; +use move_core_types::value::MoveValue; +use move_core_types::vm_status::StatusCode; +use move_core_types::{ + account_address::AccountAddress, + identifier::IdentStr, + language_storage::{ModuleId, TypeTag}, + resolver::*, +}; +use move_vm_runtime::loader::Function; +use move_vm_runtime::session::{LoadedFunctionInstantiation, Session}; +use move_vm_types::gas::GasMeter; +use move_vm_types::loaded_data::runtime_types::Type; +use std::borrow::Borrow; +use std::collections::BTreeSet; +use std::sync::Arc; +use tracing::warn; + +/// Publish module bundle options +/// - force_publish: force publish without compatibility check. +/// - only_new_module: cannot only publish new module, update existing modules is not allowed. +#[derive(Copy, Clone, Eq, PartialEq, Debug, Default)] +pub struct PublishModuleBundleOption { + pub force_publish: bool, + pub only_new_module: bool, +} + +/// An adapter for wrap MoveVM Session +pub struct SessionAdapter<'r, 'l, R> { + pub(crate) inner: Session<'r, 'l, R>, +} + +impl<'r, 'l, R> From> for SessionAdapter<'r, 'l, R> { + fn from(s: Session<'r, 'l, R>) -> Self { + Self { inner: s } + } +} + +#[allow(clippy::from_over_into)] +impl<'r, 'l, R> Into> for SessionAdapter<'r, 'l, R> { + fn into(self) -> Session<'r, 'l, R> { + self.inner + } +} + +impl<'r, 'l, R> AsRef> for SessionAdapter<'r, 'l, R> { + fn as_ref(&self) -> &Session<'r, 'l, R> { + &self.inner + } +} + +impl<'r, 'l, R> AsMut> for SessionAdapter<'r, 'l, R> { + fn as_mut(&mut self) -> &mut Session<'r, 'l, R> { + &mut self.inner + } +} + +impl<'r, 'l, R: MoveResolver> SessionAdapter<'r, 'l, R> { + ///// wrapper of Session, push signer as the first argument of function. + //pub fn execute_entry_function( + // &mut self, + // module: &ModuleId, + // function_name: &IdentStr, + // ty_args: Vec, + // args: Vec>, + // gas_meter: &mut impl GasMeter, + // sender: AccountAddress, + //) -> VMResult { + // let (_, func, _) = self.inner.load_function(module, function_name, &ty_args)?; + // let final_args = Self::check_and_rearrange_args_by_signer_position( + // func, + // args.into_iter().map(|b| b.borrow().to_vec()).collect(), + // sender, + // )?; + // self.inner + // .execute_entry_function(module, function_name, ty_args, final_args, gas_meter) + //} + + ///// wrapper of Session, push signer as the first argument of function. + //pub fn execute_script( + // &mut self, + // script: impl Borrow<[u8]>, + // ty_args: Vec, + // args: Vec>, + // gas_meter: &mut impl GasMeter, + // sender: AccountAddress, + //) -> VMResult { + // let (main, _) = self.inner.load_script(script.borrow(), ty_args.clone())?; + // let final_args = Self::check_and_rearrange_args_by_signer_position( + // main, + // args.into_iter().map(|b| b.borrow().to_vec()).collect(), + // sender, + // )?; + // self.inner + // .execute_script(script, ty_args, final_args, gas_meter) + //} + + pub(crate) fn check_and_rearrange_args_by_signer_position( + func: Arc, + args: Vec>, + sender: AccountAddress, + ) -> VMResult>> { + let has_signer = func + .parameter_types() + .iter() + .position(|i| matches!(i, &Type::Signer)) + .map(|pos| { + if pos != 0 { + Err( + PartialVMError::new(StatusCode::NUMBER_OF_SIGNER_ARGUMENTS_MISMATCH) + .with_message(format!( + "Expected signer arg is this first arg, but got it at {}", + pos + 1 + )) + .finish(Location::Undefined), + ) + } else { + Ok(true) + } + }) + .unwrap_or(Ok(false))?; + + if has_signer { + let signer = MoveValue::Signer(sender); + let mut final_args = vec![signer + .simple_serialize() + .expect("serialize signer should success")]; + final_args.extend(args); + Ok(final_args) + } else { + Ok(args) + } + } + + /// Publish module bundle with custom option. + /// The code is copied from `VMRuntime::publish_module_bundle` with modification to support ModuleBundleVerifyOption. + pub fn publish_module_bundle_with_option( + &mut self, + modules: Vec>, + sender: AccountAddress, + gas_meter: &mut impl GasMeter, + option: PublishModuleBundleOption, + ) -> VMResult<()> { + let compiled_modules = + self.verify_module_bundle(modules.clone(), sender, gas_meter, option)?; + + let mut clean_cache = false; + // All modules verified, publish them to data cache + for (module, blob) in compiled_modules.into_iter().zip(modules.into_iter()) { + let republish = if self.inner.exists_module(&module.self_id())? { + clean_cache = true; + true + } else { + false + }; + self.inner + .publish_module_to_data_cache(&module.self_id(), blob, republish)?; + } + + // Clear vm runtimer loader's cache to reload new modules from state cache + if clean_cache { + self.empty_loader_cache()?; + } + Ok(()) + } + + /// Verify module bundle. + /// The code is copied from `move_vm:::VMRuntime::publish_module_bundle` with modification to support ModuleBundleVerifyOption. + pub fn verify_module_bundle( + &mut self, + modules: Vec>, + sender: AccountAddress, + _gas_meter: &mut impl GasMeter, + option: PublishModuleBundleOption, + ) -> VMResult> { + // deserialize the modules. Perform bounds check. After this indexes can be + // used with the `[]` operator + let compiled_modules = match modules + .iter() + .map(|blob| CompiledModule::deserialize(blob)) + .collect::>>() + { + Ok(modules) => modules, + Err(err) => { + warn!("[VM] module deserialization failed {:?}", err); + return Err(err.finish(Location::Undefined)); + } + }; + + // Make sure all modules' self addresses matches the transaction sender. The self address is + // where the module will actually be published. If we did not check this, the sender could + // publish a module under anyone's account. + for module in &compiled_modules { + if module.address() != &sender { + return Err(verification_error( + StatusCode::MODULE_ADDRESS_DOES_NOT_MATCH_SENDER, + IndexKind::AddressIdentifier, + module.self_handle_idx().0, + ) + .finish(Location::Undefined)); + } + } + + // Collect ids for modules that are published together + let mut bundle_unverified = BTreeSet::new(); + + // For now, we assume that all modules can be republished, as long as the new module is + // backward compatible with the old module. + // + // TODO: in the future, we may want to add restrictions on module republishing, possibly by + // changing the bytecode format to include an `is_upgradable` flag in the CompiledModule. + for module in &compiled_modules { + let module_id = module.self_id(); + if self.inner.exists_module(&module_id)? { + if option.only_new_module { + warn!( + "[VM] module {:?} already exists. Only allow publish new modules", + module_id + ); + return Err(PartialVMError::new(StatusCode::INVALID_MODULE_PUBLISHER) + .at_index(IndexKind::ModuleHandle, module.self_handle_idx().0) + .finish(Location::Undefined)); + } + + let old_module_ref = self.inner.load_module(&module_id)?; + let old_module = old_module_ref.module(); + let old_m = normalized::Module::new(old_module); + let new_m = normalized::Module::new(module); + if Compatibility::new(true, true, false) + .check(&old_m, &new_m) + .is_err() + && !option.force_publish + { + return Err(PartialVMError::new( + StatusCode::BACKWARD_INCOMPATIBLE_MODULE_UPDATE, + ) + .finish(Location::Undefined)); + } + } + if !bundle_unverified.insert(module_id) { + return Err(PartialVMError::new(StatusCode::DUPLICATE_MODULE_NAME) + .finish(Location::Undefined)); + } + } + + // Perform bytecode and loading verification. Modules must be sorted in topological order. + self.inner + .verify_module_bundle_for_publication(&compiled_modules)?; + Ok(compiled_modules) + } + + pub fn verify_script_args( + &mut self, + script: Vec, + ty_args: Vec, + args: Vec>, + sender: AccountAddress, + ) -> VMResult<()> { + //load the script, perform verification + let ( + main, + LoadedFunctionInstantiation { + type_arguments: _, + parameters, + return_, + }, + ) = self.inner.load_script(script.borrow(), ty_args)?; + + Self::check_script_return(return_)?; + + self.check_script_signer_and_build_args(main, parameters, args, sender)?; + + Ok(()) + } + + pub fn verify_script_function_args( + &mut self, + module: &ModuleId, + function_name: &IdentStr, + ty_args: Vec, + args: Vec>, + sender: AccountAddress, + ) -> VMResult<()> { + let ( + _module, + func, + LoadedFunctionInstantiation { + type_arguments: _, + parameters, + return_, + }, + ) = self.inner.load_function(module, function_name, &ty_args)?; + + Self::check_script_return(return_)?; + + self.check_script_signer_and_build_args(func, parameters, args, sender)?; + + Ok(()) + } + + //ensure the script function not return value + pub(crate) fn check_script_return(return_: Vec) -> VMResult<()> { + if !return_.is_empty() { + Err(PartialVMError::new(StatusCode::RET_TYPE_MISMATCH_ERROR) + .with_message(format!( + "Expected script function should not return value, but got {:?}", + return_ + )) + .finish(Location::Undefined)) + } else { + Ok(()) + } + } + + fn check_script_signer_and_build_args( + &self, + func: Arc, + arg_tys: Vec, + args: Vec>, + sender: AccountAddress, + ) -> VMResult<()> { + let final_args = Self::check_and_rearrange_args_by_signer_position(func, args, sender)?; + let (_, _) = self.inner.deserialize_args(arg_tys, final_args)?; + + Ok(()) + } + + /// Clear vm runtimer loader's cache to reload new modules from state cache + fn empty_loader_cache(&self) -> VMResult<()> { + self.inner.mark_loader_cache_as_invaliddated(); + self.inner.flush_loader_cache_if_invalidated(); + Ok(()) + } +} diff --git a/vm/vm-runtime/src/adapter_common.rs b/vm/vm-runtime/src/vm_adapter/adapter_common.rs similarity index 96% rename from vm/vm-runtime/src/adapter_common.rs rename to vm/vm-runtime/src/vm_adapter/adapter_common.rs index 12d7269bb4..4a966bf69d 100644 --- a/vm/vm-runtime/src/adapter_common.rs +++ b/vm/vm-runtime/src/vm_adapter/adapter_common.rs @@ -32,7 +32,7 @@ pub enum PreprocessedTransaction { } #[inline] -pub(crate) fn preprocess_transaction(txn: Transaction) -> PreprocessedTransaction { +pub fn preprocess_transaction(txn: Transaction) -> PreprocessedTransaction { match txn { Transaction::BlockMetadata(b) => PreprocessedTransaction::BlockMetadata(b), Transaction::UserTransaction(txn) => { diff --git a/vm/vm-runtime/src/vm_adapter/mod.rs b/vm/vm-runtime/src/vm_adapter/mod.rs new file mode 100644 index 0000000000..4adba7c36f --- /dev/null +++ b/vm/vm-runtime/src/vm_adapter/mod.rs @@ -0,0 +1,13 @@ +// Copyright (c) The Starcoin Core Contributors +// SPDX-License-Identifier: Apache-2.0 + +mod adapter; +mod adapter_common; + +pub(crate) use { + adapter::{PublishModuleBundleOption, SessionAdapter}, + adapter_common::{ + discard_error_output, discard_error_vm_status, preprocess_transaction, + PreprocessedTransaction, VMAdapter, + }, +};