diff --git a/.dockerignore b/.dockerignore index 2d1bc8e..2fd069a 100644 --- a/.dockerignore +++ b/.dockerignore @@ -2,7 +2,5 @@ .github .gitignore .tezos-client -.logs target -test *.env \ No newline at end of file diff --git a/.github/workflows/build_sapling.yml b/.github/workflows/build_sapling.yml new file mode 100644 index 0000000..0a59ac7 --- /dev/null +++ b/.github/workflows/build_sapling.yml @@ -0,0 +1,56 @@ +name: Build Sapling operator + +on: + push: + branches: + - 'master' + tags: + - '*.*.*' + pull_request: + branches: + - 'master' + +jobs: + build: + name: Build and push docker images + runs-on: ubuntu-latest + env: + ACTIONS_ALLOW_UNSECURE_COMMANDS: true + DOCKER_REGISTRY: ghcr.io + DOCKER_IMAGE_BASE: ${{ github.repository_owner }} + outputs: + operator: ${{ steps.meta-tezos-operator.outputs.tags }} + steps: + - name: Check out the repo + uses: actions/checkout@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Log in to the registry + uses: docker/login-action@v1 + with: + registry: ${{ env.DOCKER_REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Sapling operator tags & labels + id: meta-sapling-operator + uses: docker/metadata-action@v3 + with: + images: ${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE_BASE }}/sapling-operator + + - name: Sapling operator build & push + uses: docker/build-push-action@v2 + with: + context: . + file: build/operator/Dockerfile + build-args: | + OCTEZ_TAG=v17.1 + OCTEZ_PROTO=PtNairob + PACKAGE=sapling_kernel + push: true + cache-from: type=gha + cache-to: type=gha,mode=max + tags: ${{ steps.meta-sapling-operator.outputs.tags }} + labels: ${{ steps.meta-sapling-operator.outputs.labels }} diff --git a/.github/workflows/build.yml b/.github/workflows/build_tezos.yml similarity index 68% rename from .github/workflows/build.yml rename to .github/workflows/build_tezos.yml index af6e909..a07c295 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build_tezos.yml @@ -1,4 +1,4 @@ -name: Build +name: Build & deploy Tezos operator on: push: @@ -19,7 +19,7 @@ jobs: DOCKER_REGISTRY: ghcr.io DOCKER_IMAGE_BASE: ${{ github.repository_owner }} outputs: - operator: ${{ steps.meta-operator.outputs.tags }} + operator: ${{ steps.meta-tezos-operator.outputs.tags }} steps: - name: Check out the repo uses: actions/checkout@v2 @@ -34,32 +34,34 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Operator tags & labels - id: meta-operator + - name: Tezos operator tags & labels + id: meta-tezos-operator uses: docker/metadata-action@v3 with: - images: ${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE_BASE }}/tz-rollup-operator + images: ${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE_BASE }}/tezos-operator - - name: Operator build & push - if: ${{ !contains(github.event.head_commit.message, '[skip-build-operator]') }} + - name: Tezos operator build & push uses: docker/build-push-action@v2 with: context: . file: build/operator/Dockerfile +# file: build/operator/Dockerfile.debug build-args: | - NETWORK=mumbainet + OCTEZ_TAG=v17.1 + OCTEZ_PROTO=PtNairob + PACKAGE=tezos_kernel # TEZOS_BRANCH=ole@wasmer-instance-leak push: true cache-from: type=gha cache-to: type=gha,mode=max - tags: ${{ steps.meta-operator.outputs.tags }} - labels: ${{ steps.meta-operator.outputs.labels }} + tags: ${{ steps.meta-tezos-operator.outputs.tags }} + labels: ${{ steps.meta-tezos-operator.outputs.labels }} - - name: Facade tags & labels - id: meta-facade + - name: Tezos facade tags & labels + id: meta-tezos-facade uses: docker/metadata-action@v3 with: - images: ${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE_BASE }}/tz-rollup-facade + images: ${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE_BASE }}/tezos-facade - name: Facade build & push if: ${{ !contains(github.event.head_commit.message, '[skip-build-facade]') }} @@ -70,17 +72,19 @@ jobs: push: true cache-from: type=gha cache-to: type=gha,mode=max - tags: ${{ steps.meta-facade.outputs.tags }} - labels: ${{ steps.meta-facade.outputs.labels }} + tags: ${{ steps.meta-tezos-facade.outputs.tags }} + labels: ${{ steps.meta-tezos-facade.outputs.labels }} deploy: - if: ${{ !contains(github.event.head_commit.message, '[skip-deploy]') }} - name: Deploy rollup to testnet + if: (github.event_name == 'pull_request' && github.event.pull_request.draft == false) || (github.event_name == 'push' && github.ref == 'refs/heads/master') + name: Deploy Tezos rollup to testnet needs: build runs-on: ubuntu-latest + env: + NETWORK: nairobinet steps: - name: Deploy rollup - run: docker run -v "/var/run/docker.sock":"/var/run/docker.sock" -e OPERATOR_KEY=${{ secrets.OPERATOR_KEY }} ${{ needs.build.outputs.operator }} originate-rollup | tee originate.out + run: docker run -v "/var/run/docker.sock":"/var/run/docker.sock" -e NETWORK=${{ env.NETWORK }} -e OPERATOR_KEY=${{ secrets.OPERATOR_KEY }} ${{ needs.build.outputs.operator }} deploy_rollup | tee originate.out - name: Extract rollup address run: | @@ -96,7 +100,7 @@ jobs: comment-author: 'github-actions[bot]' body: | - Deployed at [${{ env.ROLLUP_ADDRESS }}](https://mumbainet.tzkt.io/${{ env.ROLLUP_ADDRESS }}) + Deployed at [${{ env.ROLLUP_ADDRESS }}](https://${{ env.NETWORK }}.tzkt.io/${{ env.ROLLUP_ADDRESS }}) edit-mode: replace reactions: rocket @@ -106,7 +110,7 @@ jobs: id: deployment with: token: "${{ github.token }}" - environment: mumbainet + environment: ${{ env.NETWORK }} - name: Update deployment status if: github.event_name == 'push' && github.ref == 'refs/heads/master' @@ -114,5 +118,5 @@ jobs: with: token: "${{ github.token }}" state: "success" - environment_url: https://mumbainet.tzkt.io/${{ env.ROLLUP_ADDRESS }} - deployment_id: ${{ steps.deployment.outputs.deployment_id }} \ No newline at end of file + environment_url: https://${{ env.NETWORK }}.tzkt.io/${{ env.ROLLUP_ADDRESS }} + deployment_id: ${{ steps.deployment.outputs.deployment_id }} diff --git a/.gitignore b/.gitignore index e7e523e..e5adf79 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,9 @@ -.bin .tezos-client .ipynb_checkpoints .python-version .logs +bin target -tez_kernel/target +tezos_kernel/target boot_kernel/target -*.env \ No newline at end of file +.env \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index 3798784..f28fa52 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -198,6 +198,27 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" +[[package]] +name = "aead" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d122413f284cf2d62fb1b7db97e02edb8cda96d769b16e443a4f6195e35662b0" +dependencies = [ + "crypto-common", + "generic-array", +] + +[[package]] +name = "aes" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac1f845298e95f983ff1944b728ae08b8cebab80d684f0a832ed0fc74dfa27e2" +dependencies = [ + "cfg-if", + "cipher", + "cpufeatures", +] + [[package]] name = "ahash" version = "0.7.6" @@ -323,9 +344,9 @@ checksum = "6b4930d2cb77ce62f89ee5d5289b4ac049559b1c45539271f5ed4fdc7db34545" [[package]] name = "arrayvec" -version = "0.5.2" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" +checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" [[package]] name = "async-trait" @@ -377,6 +398,12 @@ version = "0.21.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "604178f6c5c21f02dc555784810edfb88d34ac2c73b2eae109655649ee73ce3d" +[[package]] +name = "base64ct" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a32fd6af2b5827bce66c29053ba0e7c42b9dcab01835835058558c10851a46b" + [[package]] name = "basic-toml" version = "0.1.3" @@ -386,6 +413,42 @@ dependencies = [ "serde", ] +[[package]] +name = "bech32" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d86b93f97252c47b41663388e6d155714a9d0c398b99f1005cbc5f978b29f445" + +[[package]] +name = "bellman" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9afceed28bac7f9f5a508bca8aeeff51cdfa4770c0b967ac55c621e2ddfd6171" +dependencies = [ + "bitvec", + "blake2s_simd", + "byteorder", + "ff 0.13.0", + "group 0.13.0", + "pairing", + "rand_core 0.6.4", + "subtle", +] + +[[package]] +name = "bip0039" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef0f0152ec5cf17f49a5866afaa3439816207fd4f0a224c0211ffaf5e278426" +dependencies = [ + "hmac 0.12.1", + "pbkdf2", + "rand 0.8.5", + "sha2 0.10.7", + "unicode-normalization", + "zeroize", +] + [[package]] name = "bit-vec" version = "0.6.3" @@ -406,9 +469,9 @@ checksum = "630be753d4e58660abd17930c71b647fe46c27ea6b63cc59e1e3851406972e42" [[package]] name = "bitvec" -version = "0.19.6" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55f93d0ef3363c364d5976646a38f04cf67cfe1d4c8d160cdea02cab2c116b33" +checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" dependencies = [ "funty", "radium", @@ -425,6 +488,28 @@ dependencies = [ "digest 0.10.7", ] +[[package]] +name = "blake2b_simd" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c2f0dc9a68c6317d884f97cc36cf5a3d20ba14ce404227df55e1af708ab04bc" +dependencies = [ + "arrayref", + "arrayvec", + "constant_time_eq", +] + +[[package]] +name = "blake2s_simd" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6637f448b9e61dfadbdcbae9a885fadee1f3eaffb1f8d3c1965d3ade8bdfd44f" +dependencies = [ + "arrayref", + "arrayvec", + "constant_time_eq", +] + [[package]] name = "block-buffer" version = "0.9.0" @@ -443,6 +528,32 @@ dependencies = [ "generic-array", ] +[[package]] +name = "bls12_381" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7bc6d6292be3a19e6379786dac800f551e5865a5bb51ebbe3064ab80433f403" +dependencies = [ + "ff 0.13.0", + "group 0.13.0", + "pairing", + "rand_core 0.6.4", + "subtle", +] + +[[package]] +name = "blst" +version = "0.3.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a30d0edd9dd1c60ddb42b80341c7852f6f985279a5c1a83659dcb65899dec99" +dependencies = [ + "cc", + "glob", + "threadpool", + "which", + "zeroize", +] + [[package]] name = "brotli" version = "3.3.4" @@ -470,7 +581,17 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "771fe0050b883fcc3ea2359b1a96bcfbc090b7116eae7c3c512c7a083fdf23d3" dependencies = [ - "sha2", + "sha2 0.9.9", +] + +[[package]] +name = "bs58" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f5353f36341f7451062466f0b755b96ac3a9547e4d7f6b70d603fc721a7d7896" +dependencies = [ + "sha2 0.10.7", + "tinyvec", ] [[package]] @@ -500,6 +621,15 @@ dependencies = [ "bytes", ] +[[package]] +name = "cbc" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26b52a9543ae338f279b96b0b9fed9c8093744685043739079ce85cd58f289a6" +dependencies = [ + "cipher", +] + [[package]] name = "cc" version = "1.0.79" @@ -521,6 +651,30 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e" +[[package]] +name = "chacha20" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3613f74bd2eac03dad61bd53dbe620703d4371614fe0bc3b9f04dd36fe4e818" +dependencies = [ + "cfg-if", + "cipher", + "cpufeatures", +] + +[[package]] +name = "chacha20poly1305" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10cd79432192d1c0f4e1a0fef9527696cc039165d729fb41b3f4f4f354c2dc35" +dependencies = [ + "aead", + "chacha20", + "cipher", + "poly1305", + "zeroize", +] + [[package]] name = "chrono" version = "0.4.26" @@ -534,6 +688,17 @@ dependencies = [ "winapi", ] +[[package]] +name = "cipher" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad" +dependencies = [ + "crypto-common", + "inout", + "zeroize", +] + [[package]] name = "clap" version = "4.3.11" @@ -581,6 +746,12 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" +[[package]] +name = "constant_time_eq" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21a53c0a4d288377e7415b53dcfc3c04da5cdc2cc95c8d5ac178b58f0b861ad6" + [[package]] name = "convert_case" version = "0.4.0" @@ -638,27 +809,6 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" -[[package]] -name = "crypto" -version = "3.1.1" -source = "git+https://github.com/emturner/tezedge.git?branch=master#a372a9a975d3a04205a8d5e74e2e5224f4e3a1db" -dependencies = [ - "anyhow", - "base58", - "byteorder", - "cryptoxide", - "hex", - "libsecp256k1", - "num-bigint", - "num-traits", - "p256", - "serde", - "strum", - "strum_macros", - "thiserror", - "zeroize", -] - [[package]] name = "crypto-bigint" version = "0.2.5" @@ -711,15 +861,30 @@ dependencies = [ ] [[package]] -name = "dac_codec" +name = "curve25519-dalek" +version = "4.0.0-rc.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "436ace70fc06e06f7f689d2624dc4e2f0ea666efb5aa704215f7249ae6e047a7" +dependencies = [ + "cfg-if", + "cpufeatures", + "curve25519-dalek-derive", + "digest 0.10.7", + "fiat-crypto", + "platforms", + "rustc_version", + "subtle", +] + +[[package]] +name = "curve25519-dalek-derive" version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83fdaf97f4804dcebfa5862639bc9ce4121e82140bec2a987ac5140294865b5b" dependencies = [ - "clap", - "hex", - "once_cell", - "tezos-core", - "tezos_encoding", - "tezos_rollup_encoding", + "proc-macro2", + "quote", + "syn 2.0.25", ] [[package]] @@ -741,6 +906,12 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "difflib" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6184e33543162437515c2e2b48714794e37845ec9851711914eec9d308f6ebe8" + [[package]] name = "digest" version = "0.9.0" @@ -761,6 +932,21 @@ dependencies = [ "subtle", ] +[[package]] +name = "dlmalloc" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "203540e710bfadb90e5e29930baf5d10270cec1f43ab34f46f78b147b2de715a" +dependencies = [ + "libc", +] + +[[package]] +name = "downcast" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1435fa1053d8b2fbbe9be7e97eca7f33d37b28409959813daefc1446a14247f1" + [[package]] name = "ecdsa" version = "0.12.4" @@ -769,8 +955,8 @@ checksum = "43ee23aa5b4f68c7a092b5c3beb25f50c406adc75e2363634f242f28ab255372" dependencies = [ "der", "elliptic-curve", - "hmac", - "signature", + "hmac 0.11.0", + "signature 1.3.2", ] [[package]] @@ -779,7 +965,16 @@ version = "1.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "91cff35c70bba8a626e3185d8cd48cc11b5437e1a5bcd15b9b5fa3c64b6dfee7" dependencies = [ - "signature", + "signature 1.3.2", +] + +[[package]] +name = "ed25519" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5fb04eee5d9d907f29e80ee6b0e78f7e2c82342c63e3580d8c4f69d9d5aad963" +dependencies = [ + "signature 2.1.0", ] [[package]] @@ -788,14 +983,31 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c762bae6dcaf24c4c84667b8579785430908723d5c889f469d76a41d59cc7a9d" dependencies = [ - "curve25519-dalek", - "ed25519", + "curve25519-dalek 3.2.0", + "ed25519 1.5.3", "rand 0.7.3", "serde", - "sha2", + "sha2 0.9.9", "zeroize", ] +[[package]] +name = "ed25519-dalek" +version = "2.0.0-rc.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "faa8e9049d5d72bfc12acbc05914731b5322f79b5e2f195e9f2d705fca22ab4c" +dependencies = [ + "curve25519-dalek 4.0.0-rc.3", + "ed25519 2.2.1", + "sha2 0.10.7", +] + +[[package]] +name = "either" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" + [[package]] name = "elliptic-curve" version = "0.10.4" @@ -803,9 +1015,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "83e5c176479da93a0983f0a6fdc3c1b8e7d5be0d7fe3fe05a99f15b96582b9a8" dependencies = [ "crypto-bigint", - "ff", + "ff 0.10.1", "generic-array", - "group", + "group 0.10.0", "rand_core 0.6.4", "subtle", "zeroize", @@ -833,6 +1045,16 @@ dependencies = [ "termcolor", ] +[[package]] +name = "equihash" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab579d7cf78477773b03e80bc2f89702ef02d7112c711d54ca93dcdce68533d5" +dependencies = [ + "blake2b_simd", + "byteorder", +] + [[package]] name = "errno" version = "0.3.1" @@ -854,6 +1076,15 @@ dependencies = [ "libc", ] +[[package]] +name = "f4jumble" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a83e8d7fd0c526af4aad893b7c9fe41e2699ed8a776a6c74aecdeafe05afc75" +dependencies = [ + "blake2b_simd", +] + [[package]] name = "fastrand" version = "1.9.0" @@ -873,6 +1104,23 @@ dependencies = [ "subtle", ] +[[package]] +name = "ff" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" +dependencies = [ + "bitvec", + "rand_core 0.6.4", + "subtle", +] + +[[package]] +name = "fiat-crypto" +version = "0.1.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e825f6987101665dea6ec934c09ec6d721de7bc1bf92248e1d5810c8cd636b77" + [[package]] name = "find-crate" version = "0.6.3" @@ -892,6 +1140,15 @@ dependencies = [ "miniz_oxide", ] +[[package]] +name = "float-cmp" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98de4bbd547a563b716d8dfa9aad1cb19bfab00f4fa09a6a4ed21dbcf44ce9c4" +dependencies = [ + "num-traits", +] + [[package]] name = "fnv" version = "1.0.7" @@ -922,11 +1179,31 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "fpe" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26c4b37de5ae15812a764c958297cfc50f5c010438f60c6ce75d11b802abd404" +dependencies = [ + "cbc", + "cipher", + "libm", + "num-bigint 0.4.3", + "num-integer", + "num-traits", +] + +[[package]] +name = "fragile" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c2141d6d6c8512188a7891b4b01590a45f6dac67afb4f255c4124dbb86d4eaa" + [[package]] name = "funty" -version = "1.1.0" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fed34cd105917e91daa4da6b3728c47b068749d6a62c59811f06ed2ac71d9da7" +checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" [[package]] name = "futures-channel" @@ -1000,12 +1277,11 @@ dependencies = [ [[package]] name = "getrandom" version = "0.2.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" +source = "git+https://github.com/baking-bad/getrandom?branch=patch/0.2#d543bafa73e9884a06c475ee978bb040a6c46d9e" dependencies = [ "cfg-if", "libc", - "wasi 0.11.0+wasi-snapshot-preview1", + "wasi 0.9.0+wasi-snapshot-preview1", ] [[package]] @@ -1026,7 +1302,19 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1c363a5301b8f153d80747126a04b3c82073b9fe3130571a9d170cacdeaf7912" dependencies = [ - "ff", + "ff 0.10.1", + "rand_core 0.6.4", + "subtle", +] + +[[package]] +name = "group" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" +dependencies = [ + "ff 0.13.0", + "memuse", "rand_core 0.6.4", "subtle", ] @@ -1050,6 +1338,46 @@ dependencies = [ "tracing", ] +[[package]] +name = "halo2_gadgets" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "126a150072b0c38c7b573fe3eaf0af944a7fed09e154071bf2436d3f016f7230" +dependencies = [ + "arrayvec", + "bitvec", + "ff 0.13.0", + "group 0.13.0", + "halo2_proofs", + "lazy_static", + "pasta_curves", + "rand 0.8.5", + "subtle", + "uint", +] + +[[package]] +name = "halo2_legacy_pdqsort" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47716fe1ae67969c5e0b2ef826f32db8c3be72be325e1aa3c1951d06b5575ec5" + +[[package]] +name = "halo2_proofs" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b867a8d9bbb85fca76fff60652b5cd19b853a1c4d0665cb89bee68b18d2caf0" +dependencies = [ + "blake2b_simd", + "ff 0.13.0", + "group 0.13.0", + "halo2_legacy_pdqsort", + "maybe-rayon", + "pasta_curves", + "rand_core 0.6.4", + "tracing", +] + [[package]] name = "hashbrown" version = "0.12.3" @@ -1089,16 +1417,26 @@ version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2a2a2320eb7ec0ebe8da8f744d7812d9fc4cb4d09344ac01898dbcb6a20ae69b" dependencies = [ - "crypto-mac", - "digest 0.9.0", + "crypto-mac", + "digest 0.9.0", +] + +[[package]] +name = "hmac" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" +dependencies = [ + "digest 0.10.7", ] [[package]] -name = "host" -version = "0.1.0" -source = "git+https://gitlab.com/tezos/kernel?rev=417cdfbac778e96e1b9061b9f3b4517a6f1fa433#417cdfbac778e96e1b9061b9f3b4517a6f1fa433" +name = "home" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5444c27eef6923071f7ebcc33e3444508466a76f7a2b93da00ed6e19f30c1ddb" dependencies = [ - "crypto", + "windows-sys", ] [[package]] @@ -1223,6 +1561,15 @@ dependencies = [ "unicode-normalization", ] +[[package]] +name = "incrementalmerkletree" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2eb91780c91bfc79769006a55c49127b83e1c1a6cf2b3b149ce3f247cbe342f0" +dependencies = [ + "either", +] + [[package]] name = "indexmap" version = "1.9.3" @@ -1234,16 +1581,12 @@ dependencies = [ ] [[package]] -name = "installer" -version = "0.1.0" +name = "inout" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0c10553d664a4d0bcff9f4215d0aac67a639cc68ef660840afe309b807bc9f5" dependencies = [ - "hex", - "host", - "mock_runtime", - "once_cell", - "tezos-core", - "tezos_encoding", - "tezos_rollup_encoding", + "generic-array", ] [[package]] @@ -1283,6 +1626,15 @@ dependencies = [ "windows-sys", ] +[[package]] +name = "itertools" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" +dependencies = [ + "either", +] + [[package]] name = "itoa" version = "1.0.8" @@ -1307,29 +1659,63 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "jubjub" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8499f7a74008aafbecb2a2e608a3e13e4dd3e84df198b604451efe93f2de6e61" +dependencies = [ + "bitvec", + "bls12_381", + "ff 0.13.0", + "group 0.13.0", + "rand_core 0.6.4", + "subtle", +] + +[[package]] +name = "kernel_io" +version = "0.1.0" +dependencies = [ + "derive_more", + "layered_store", + "tezos-core", + "tezos-smart-rollup-core", + "tezos-smart-rollup-host", + "tezos-smart-rollup-mock", +] + +[[package]] +name = "known-folders" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b6f1427d9c43b1cce87434c4d9eca33f43bdbb6246a762aa823a582f74c1684" +dependencies = [ + "windows-sys", +] + [[package]] name = "language-tags" version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d4345964bb142484797b161f473a503a434de77149dd8c7427788c6e13379388" +[[package]] +name = "layered_store" +version = "0.1.0" +dependencies = [ + "derive_more", + "tezos-core", + "tezos-michelson", +] + [[package]] name = "lazy_static" version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" - -[[package]] -name = "lexical-core" -version = "0.7.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6607c62aa161d23d17a9072cc5da0be67cdfc89d3afb1e8d9c842bebc2525ffe" dependencies = [ - "arrayvec", - "bitflags 1.3.2", - "cfg-if", - "ryu", - "static_assertions", + "spin", ] [[package]] @@ -1338,6 +1724,12 @@ version = "0.2.147" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" +[[package]] +name = "libm" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7012b1bbb0719e1097c47611d3898568c546d597c2e74d66f6087edd5233ff4" + [[package]] name = "libsecp256k1" version = "0.7.1" @@ -1429,12 +1821,30 @@ version = "0.4.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b06a4cde4c0f271a446782e3eff8de789548ce57dbc8eca9292c27f4a42004b4" +[[package]] +name = "maybe-rayon" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ea1f30cedd69f0a2954655f7188c6a834246d2bcf1e315e2ac40c4b24dc9519" +dependencies = [ + "cfg-if", +] + [[package]] name = "memchr" version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" +[[package]] +name = "memuse" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2145869435ace5ea6ea3d35f59be559317ec9a0d04e1812d5f185a87b6d36f1a" +dependencies = [ + "nonempty", +] + [[package]] name = "michelson_derive" version = "0.1.0" @@ -1442,12 +1852,12 @@ dependencies = [ "find-crate", "heck 0.3.3", "michelson_interop", + "michelson_vm", "proc-macro2", "quote", "syn 2.0.25", "tezos-core", "tezos-michelson", - "tezos_vm", "trybuild", ] @@ -1464,12 +1874,34 @@ dependencies = [ "tezos-michelson", ] +[[package]] +name = "michelson_vm" +version = "0.1.0" +dependencies = [ + "blake2", + "chrono", + "derive_more", + "hex", + "ibig", + "layered_store", + "once_cell", + "serde-json-wasm", + "tezos-core", + "tezos-michelson", +] + [[package]] name = "mime" version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + [[package]] name = "miniz_oxide" version = "0.7.1" @@ -1479,6 +1911,19 @@ dependencies = [ "adler", ] +[[package]] +name = "minreq" +version = "2.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3de406eeb24aba36ed3829532fa01649129677186b44a49debec0ec574ca7da7" +dependencies = [ + "log", + "once_cell", + "rustls", + "webpki", + "webpki-roots", +] + [[package]] name = "mio" version = "0.8.8" @@ -1492,13 +1937,30 @@ dependencies = [ ] [[package]] -name = "mock_runtime" -version = "0.1.0" -source = "git+https://gitlab.com/tezos/kernel?rev=417cdfbac778e96e1b9061b9f3b4517a6f1fa433#417cdfbac778e96e1b9061b9f3b4517a6f1fa433" +name = "mockall" +version = "0.11.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c84490118f2ee2d74570d114f3d0493cbf02790df303d2707606c3e14e07c96" +dependencies = [ + "cfg-if", + "downcast", + "fragile", + "lazy_static", + "mockall_derive", + "predicates", + "predicates-tree", +] + +[[package]] +name = "mockall_derive" +version = "0.11.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22ce75669015c4f47b289fd4d4f56e894e4c96003ffdf3ac51313126f94c6cbb" dependencies = [ - "crypto", - "host", - "tezos_rollup_encoding", + "cfg-if", + "proc-macro2", + "quote", + "syn 1.0.109", ] [[package]] @@ -1521,17 +1983,26 @@ dependencies = [ [[package]] name = "nom" -version = "6.1.2" +version = "7.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7413f999671bd4745a7b624bd370a569fb6bc574b23c83a3c5ed2e453f3d5e2" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" dependencies = [ - "bitvec", - "funty", - "lexical-core", "memchr", - "version_check", + "minimal-lexical", ] +[[package]] +name = "nonempty" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9e591e719385e6ebaeb5ce5d3887f7d5676fceca6411d1925ccc95745f3d6f7" + +[[package]] +name = "normalize-line-endings" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61807f77802ff30975e01f4f071c8ba10c022052f98b3294119f3e615d13e5be" + [[package]] name = "num-bigint" version = "0.3.3" @@ -1544,6 +2015,17 @@ dependencies = [ "serde", ] +[[package]] +name = "num-bigint" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f93ab6289c7b344a8a9f60f88d80aa20032336fe78da341afc91c8a2341fc75f" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + [[package]] name = "num-derive" version = "0.3.3" @@ -1649,6 +2131,34 @@ dependencies = [ "vcpkg", ] +[[package]] +name = "orchard" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f4e7a52f510cb8c39e639e662a353adbaf86025478af89ae54a0551f8ca35e2" +dependencies = [ + "aes", + "bitvec", + "blake2b_simd", + "ff 0.13.0", + "fpe", + "group 0.13.0", + "halo2_gadgets", + "halo2_proofs", + "hex", + "incrementalmerkletree", + "lazy_static", + "memuse", + "nonempty", + "pasta_curves", + "rand 0.8.5", + "reddsa", + "serde", + "subtle", + "tracing", + "zcash_note_encryption", +] + [[package]] name = "p256" version = "0.9.0" @@ -1657,7 +2167,16 @@ checksum = "d053368e1bae4c8a672953397bd1bd7183dde1c72b0b7612a15719173148d186" dependencies = [ "ecdsa", "elliptic-curve", - "sha2", + "sha2 0.9.9", +] + +[[package]] +name = "pairing" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81fec4625e73cf41ef4bb6846cafa6d44736525f442ba45e407c4a000a13996f" +dependencies = [ + "group 0.13.0", ] [[package]] @@ -1733,12 +2252,48 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "password-hash" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d791538a6dcc1e7cb7fe6f6b58aca40e7f79403c45b2bc274008b5e647af1d8" +dependencies = [ + "base64ct", + "rand_core 0.6.4", + "subtle", +] + +[[package]] +name = "pasta_curves" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3e57598f73cc7e1b2ac63c79c517b31a0877cd7c402cdcaa311b5208de7a095" +dependencies = [ + "blake2b_simd", + "ff 0.13.0", + "group 0.13.0", + "lazy_static", + "rand 0.8.5", + "static_assertions", + "subtle", +] + [[package]] name = "paste" version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4b27ab7be369122c218afc2079489cdcb4b517c0a3fc386ff11e1fedfcc2b35" +[[package]] +name = "pbkdf2" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "271779f35b581956db91a3e55737327a03aa051e90b1c47aeb189508533adfd7" +dependencies = [ + "digest 0.10.7", + "password-hash", +] + [[package]] name = "percent-encoding" version = "2.3.0" @@ -1763,12 +2318,59 @@ version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964" +[[package]] +name = "platforms" +version = "3.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3d7ddaed09e0eb771a79ab0fd64609ba0afb0a8366421957936ad14cbd13630" + +[[package]] +name = "poly1305" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8159bd90725d2df49889a078b54f4f79e87f1f8a8444194cdca81d38f5393abf" +dependencies = [ + "cpufeatures", + "opaque-debug", + "universal-hash", +] + [[package]] name = "ppv-lite86" version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" +[[package]] +name = "predicates" +version = "2.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59230a63c37f3e18569bdb90e4a89cbf5bf8b06fea0b84e65ea10cc4df47addd" +dependencies = [ + "difflib", + "float-cmp", + "itertools", + "normalize-line-endings", + "predicates-core", + "regex", +] + +[[package]] +name = "predicates-core" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b794032607612e7abeb4db69adb4e33590fa6cf1149e95fd7cb00e634b92f174" + +[[package]] +name = "predicates-tree" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "368ba315fb8c5052ab692e68a0eefec6ec57b23a36959c14496f0b0df2c0cecf" +dependencies = [ + "predicates-core", + "termtree", +] + [[package]] name = "proc-macro2" version = "1.0.64" @@ -1789,9 +2391,9 @@ dependencies = [ [[package]] name = "radium" -version = "0.5.3" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "941ba9d78d8e2f7ce474c015eea4d9c6d25b6a3327f9832ee29a4de27f91bbb8" +checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" [[package]] name = "rand" @@ -1864,6 +2466,37 @@ dependencies = [ "rand_core 0.5.1", ] +[[package]] +name = "reddsa" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "54b34d2c0df43159d2ff79d3cf929c9f11415529127344edb8160ad2be499fcd" +dependencies = [ + "blake2b_simd", + "byteorder", + "group 0.13.0", + "hex", + "jubjub", + "pasta_curves", + "rand_core 0.6.4", + "serde", + "thiserror", + "zeroize", +] + +[[package]] +name = "redjubjub" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a60db2c3bc9c6fd1e8631fee75abc008841d27144be744951d6b9b75f9b569c" +dependencies = [ + "rand_core 0.6.4", + "reddsa", + "serde", + "thiserror", + "zeroize", +] + [[package]] name = "redox_syscall" version = "0.2.16" @@ -1954,6 +2587,21 @@ dependencies = [ "winreg", ] +[[package]] +name = "ring" +version = "0.16.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3053cf52e236a3ed746dfc745aa9cacf1b791d846bdaf412f60a8d7d6e17c8fc" +dependencies = [ + "cc", + "libc", + "once_cell", + "spin", + "untrusted", + "web-sys", + "winapi", +] + [[package]] name = "rustc-demangle" version = "0.1.23" @@ -1996,12 +2644,60 @@ dependencies = [ "windows-sys", ] +[[package]] +name = "rustls" +version = "0.20.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fff78fc74d175294f4e83b28343315ffcfb114b156f0185e9741cb5570f50e2f" +dependencies = [ + "log", + "ring", + "sct", + "webpki", +] + [[package]] name = "ryu" version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fe232bdf6be8c8de797b22184ee71118d63780ea42ac85b61d1baa6d3b782ae9" +[[package]] +name = "sapling_kernel" +version = "0.1.0" +dependencies = [ + "anyhow", + "derive_more", + "hex", + "kernel_io", + "sapling_proto", + "tezos-smart-rollup", + "tezos-smart-rollup-core", + "tezos-smart-rollup-entrypoint", + "tezos-smart-rollup-host", + "tezos-smart-rollup-mock", + "tezos_data_encoding", +] + +[[package]] +name = "sapling_proto" +version = "0.1.0" +dependencies = [ + "anyhow", + "bellman", + "blake2b_simd", + "bls12_381", + "derive_more", + "hex", + "incrementalmerkletree", + "layered_store", + "lazy_static", + "mockall", + "zcash_note_encryption", + "zcash_primitives", + "zcash_proofs", +] + [[package]] name = "schannel" version = "0.1.22" @@ -2017,6 +2713,16 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" +[[package]] +name = "sct" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d53dcdb7c9f8158937a7981b48accfd39a43af418591a5d008c7b22b5e1b7ca4" +dependencies = [ + "ring", + "untrusted", +] + [[package]] name = "security-framework" version = "2.9.1" @@ -2076,9 +2782,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.100" +version = "1.0.102" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f1e14e89be7aa4c4b78bdbdc9eb5bf8517829a600ae8eaa39a6e1d960b5185c" +checksum = "b5062a995d481b2308b6064e9af76011f2921c35f97b0468811ed9f6cd91dfed" dependencies = [ "itoa", "ryu", @@ -2121,6 +2827,17 @@ dependencies = [ "opaque-debug", ] +[[package]] +name = "sha2" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "479fb9d862239e610720565ca91403019f2f00410f1864c5aa7479b950a76ed8" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest 0.10.7", +] + [[package]] name = "signal-hook-registry" version = "1.4.1" @@ -2140,6 +2857,12 @@ dependencies = [ "rand_core 0.6.4", ] +[[package]] +name = "signature" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e1788eed21689f9cf370582dfc467ef36ed9c707f073528ddafa8d83e3b8500" + [[package]] name = "slab" version = "0.4.8" @@ -2165,6 +2888,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "spin" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" + [[package]] name = "static_assertions" version = "1.1.0" @@ -2281,19 +3010,10 @@ dependencies = [ ] [[package]] -name = "tez_kernel" -version = "0.1.0" -dependencies = [ - "derive_more", - "hex", - "host", - "mock_runtime", - "tezos-core", - "tezos-operation", - "tezos-rpc", - "tezos_ctx", - "tezos_l2", -] +name = "termtree" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3369f5ac52d5eb6ab48c6b4ffdc8efbcad6b89c765749064ba298f2c68a16a76" [[package]] name = "tezos-contract" @@ -2314,10 +3034,10 @@ version = "0.1.3" source = "git+https://github.com/baking-bad/tezos-rust-sdk?branch=develop#ecb380b8887e94b01837da905f962aeb12dd904d" dependencies = [ "blake2", - "bs58", + "bs58 0.4.0", "cfg-if", "derive_more", - "ed25519-dalek", + "ed25519-dalek 1.0.1", "hex", "ibig", "lazy_static", @@ -2373,40 +3093,167 @@ dependencies = [ ] [[package]] -name = "tezos_ctx" -version = "0.1.0" +name = "tezos-smart-rollup" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f497c89d8a143f20004142f9a0fa9232598ceaf438581b82a029cbc709decf9" dependencies = [ - "chrono", - "derive_more", + "tezos-smart-rollup-core", + "tezos-smart-rollup-debug", + "tezos-smart-rollup-encoding", + "tezos-smart-rollup-entrypoint", + "tezos-smart-rollup-host", + "tezos-smart-rollup-mock", + "tezos-smart-rollup-storage", + "tezos_crypto_rs", + "tezos_data_encoding", +] + +[[package]] +name = "tezos-smart-rollup-core" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01b2d125ad921cde4c586427bdfd25350568e652f0b1b5050745fecb3f4f2a91" + +[[package]] +name = "tezos-smart-rollup-debug" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0108861f0710f4b10917917cfdc92fa320e991790fde5dd0a1851954bb01cec0" +dependencies = [ + "tezos-smart-rollup-core", + "tezos-smart-rollup-host", +] + +[[package]] +name = "tezos-smart-rollup-encoding" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a23e2fc8261bb77a0bd0dec5350b0688dc4e45f6a2ad5227f24b8d17dd589cf" +dependencies = [ + "hex", + "nom", + "num-bigint 0.3.3", + "num-traits", + "tezos-smart-rollup-core", + "tezos-smart-rollup-host", + "tezos_crypto_rs", + "tezos_data_encoding", + "tezos_data_encoding_derive", + "thiserror", + "time", +] + +[[package]] +name = "tezos-smart-rollup-entrypoint" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07168b649bb867967cec5f14e942292af98b237b45c897a9aa57a86ff4c1d210" +dependencies = [ + "dlmalloc", + "tezos-smart-rollup-core", + "tezos-smart-rollup-debug", + "tezos-smart-rollup-host", + "tezos-smart-rollup-panic-hook", +] + +[[package]] +name = "tezos-smart-rollup-host" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25ef490a027929034fda6e56d185d89ef70149c5818d5fa7a03f348d6ba985a1" +dependencies = [ + "tezos-smart-rollup-core", + "tezos_crypto_rs", + "tezos_data_encoding", + "thiserror", +] + +[[package]] +name = "tezos-smart-rollup-mock" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e09f8b60f4b8b3a126ad8f4e8b54c4045637a535fd2848e0d6c173736bb568c2" +dependencies = [ + "hex", + "tezos-smart-rollup-core", + "tezos-smart-rollup-encoding", + "tezos-smart-rollup-host", + "tezos_crypto_rs", + "tezos_data_encoding", +] + +[[package]] +name = "tezos-smart-rollup-panic-hook" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b878d9d2b185f01656efb5a313aa99abb334025adc146b09f21390fa523c1b30" +dependencies = [ + "tezos-smart-rollup-core", +] + +[[package]] +name = "tezos-smart-rollup-storage" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1da8c5742aaad5aa439d25db85045f350b130b2309c8b3de762a221aba13af1" +dependencies = [ + "tezos-smart-rollup-core", + "tezos-smart-rollup-debug", + "tezos-smart-rollup-encoding", + "tezos-smart-rollup-host", + "thiserror", +] + +[[package]] +name = "tezos_crypto_rs" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0477184152625d323522934c7282b75f3b4d8233820688c58ec571058cd0854e" +dependencies = [ + "anyhow", + "base58", + "blst", + "byteorder", + "cryptoxide", + "ed25519-dalek 2.0.0-rc.3", + "hex", + "libsecp256k1", + "num-bigint 0.3.3", + "num-traits", + "p256", + "rand 0.7.3", "serde", - "serde-json-wasm", - "tezos-core", - "tezos-michelson", - "tezos-operation", - "tezos-rpc", + "strum", + "strum_macros", + "thiserror", + "zeroize", ] [[package]] -name = "tezos_encoding" -version = "3.1.1" -source = "git+https://github.com/emturner/tezedge.git?branch=master#a372a9a975d3a04205a8d5e74e2e5224f4e3a1db" +name = "tezos_data_encoding" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbd4b9308fd63d0e5afad1bba42870d002f5f8f6a4d1f82b02096bed5ffedb17" dependencies = [ "bit-vec", - "crypto", + "bitvec", "hex", "lazy_static", "nom", - "num-bigint", + "num-bigint 0.3.3", "num-traits", "serde", - "tezos_encoding_derive", + "tezos_crypto_rs", + "tezos_data_encoding_derive", "thiserror", ] [[package]] -name = "tezos_encoding_derive" -version = "3.1.1" -source = "git+https://github.com/emturner/tezedge.git?branch=master#a372a9a975d3a04205a8d5e74e2e5224f4e3a1db" +name = "tezos_data_encoding_derive" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d871b43682e070674b04d3a96e7b9ae692139f777fa366bad71085834b949d0a" dependencies = [ "lazy_static", "once_cell", @@ -2417,23 +3264,22 @@ dependencies = [ ] [[package]] -name = "tezos_l2" +name = "tezos_kernel" version = "0.1.0" dependencies = [ - "blake2", - "chrono", "derive_more", - "ed25519-dalek", - "ibig", - "serde", - "serde-json-wasm", - "serde_json", + "hex", + "kernel_io", "tezos-core", - "tezos-michelson", "tezos-operation", "tezos-rpc", - "tezos_ctx", - "tezos_vm", + "tezos-smart-rollup", + "tezos-smart-rollup-core", + "tezos-smart-rollup-entrypoint", + "tezos-smart-rollup-host", + "tezos-smart-rollup-mock", + "tezos_data_encoding", + "tezos_proto", ] [[package]] @@ -2447,7 +3293,9 @@ dependencies = [ "env_logger", "hex", "ibig", + "layered_store", "log", + "michelson_vm", "reqwest", "serde", "serde_json", @@ -2457,42 +3305,28 @@ dependencies = [ "tezos-michelson", "tezos-operation", "tezos-rpc", - "tezos_ctx", - "tezos_l2", - "tezos_vm", + "tezos_proto", "tokio", ] [[package]] -name = "tezos_rollup_encoding" -version = "0.1.0" -source = "git+https://gitlab.com/tezos/kernel?rev=417cdfbac778e96e1b9061b9f3b4517a6f1fa433#417cdfbac778e96e1b9061b9f3b4517a6f1fa433" -dependencies = [ - "crypto", - "host", - "nom", - "num-bigint", - "num-traits", - "tezos_encoding", - "tezos_encoding_derive", - "time", -] - -[[package]] -name = "tezos_vm" +name = "tezos_proto" version = "0.1.0" dependencies = [ "blake2", "chrono", "derive_more", - "hex", + "ed25519-dalek 1.0.1", "ibig", - "once_cell", + "layered_store", + "michelson_vm", "serde", "serde-json-wasm", + "serde_json", "tezos-core", "tezos-michelson", - "tezos_ctx", + "tezos-operation", + "tezos-rpc", ] [[package]] @@ -2515,6 +3349,15 @@ dependencies = [ "syn 2.0.25", ] +[[package]] +name = "threadpool" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d050e60b33d41c19108b32cea32164033a9013fe3b46cbd4457559bfbf77afaa" +dependencies = [ + "num_cpus", +] + [[package]] name = "time" version = "0.3.23" @@ -2636,9 +3479,21 @@ dependencies = [ "cfg-if", "log", "pin-project-lite", + "tracing-attributes", "tracing-core", ] +[[package]] +name = "tracing-attributes" +version = "0.1.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.25", +] + [[package]] name = "tracing-core" version = "0.1.31" @@ -2675,6 +3530,18 @@ version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" +[[package]] +name = "uint" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76f64bba2c53b04fcab63c01a7d7427eadc821e3bc48c34dc9ba29c501164b52" +dependencies = [ + "byteorder", + "crunchy", + "hex", + "static_assertions", +] + [[package]] name = "unicode-bidi" version = "0.3.13" @@ -2702,6 +3569,22 @@ version = "1.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" +[[package]] +name = "universal-hash" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc1de2c688dc15305988b563c3854064043356019f97a4b46276fe734c4f07ea" +dependencies = [ + "crypto-common", + "subtle", +] + +[[package]] +name = "untrusted" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" + [[package]] name = "url" version = "2.4.0" @@ -2828,6 +3711,36 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "webpki" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f095d78192e208183081cc07bc5515ef55216397af48b873e5edcd72637fa1bd" +dependencies = [ + "ring", + "untrusted", +] + +[[package]] +name = "webpki-roots" +version = "0.22.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c71e40d7d2c34a5106301fb632274ca37242cd0c9d3e64dbece371a40a2d87" +dependencies = [ + "webpki", +] + +[[package]] +name = "which" +version = "4.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2441c784c52b289a054b7201fc93253e288f094e2f4be9058343127c4226a269" +dependencies = [ + "either", + "libc", + "once_cell", +] + [[package]] name = "winapi" version = "0.3.9" @@ -2945,9 +3858,121 @@ dependencies = [ [[package]] name = "wyz" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" +dependencies = [ + "tap", +] + +[[package]] +name = "xdg" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "688597db5a750e9cad4511cb94729a078e274308099a0382b5b8203bbc767fee" +dependencies = [ + "home", +] + +[[package]] +name = "zcash_address" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8944af5c206cf2e37020ad54618e1825501b98548d35a638b73e0ec5762df8d5" +dependencies = [ + "bech32", + "bs58 0.5.0", + "f4jumble", + "zcash_encoding", +] + +[[package]] +name = "zcash_encoding" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85e60b0d1b5f99db2556934e21937020776a5d31520bf169e851ac44e6420214" +checksum = "f03391b81727875efa6ac0661a20883022b6fba92365dc121c48fa9b00c5aac0" +dependencies = [ + "byteorder", + "nonempty", +] + +[[package]] +name = "zcash_note_encryption" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b4580cd6cee12e44421dac43169be8d23791650816bdb34e6ddfa70ac89c1c5" +dependencies = [ + "chacha20", + "chacha20poly1305", + "cipher", + "rand_core 0.6.4", + "subtle", +] + +[[package]] +name = "zcash_params" +version = "0.1.0" +dependencies = [ + "bellman", + "bls12_381", + "zcash_proofs", +] + +[[package]] +name = "zcash_primitives" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de1a231e6a58d3dcdd6e21d229db33d7c10f9b54d8c170e122b267f6826bb48f" +dependencies = [ + "aes", + "bip0039", + "bitvec", + "blake2b_simd", + "blake2s_simd", + "bls12_381", + "byteorder", + "equihash", + "ff 0.13.0", + "fpe", + "group 0.13.0", + "hex", + "incrementalmerkletree", + "jubjub", + "lazy_static", + "memuse", + "nonempty", + "orchard", + "rand 0.8.5", + "rand_core 0.6.4", + "sha2 0.10.7", + "subtle", + "zcash_address", + "zcash_encoding", + "zcash_note_encryption", +] + +[[package]] +name = "zcash_proofs" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59d2e066a717f28451a081f2ebd483ddda896cf00d572972c10979d645ffa6c4" +dependencies = [ + "bellman", + "blake2b_simd", + "bls12_381", + "group 0.13.0", + "home", + "incrementalmerkletree", + "jubjub", + "known-folders", + "lazy_static", + "minreq", + "rand_core 0.6.4", + "redjubjub", + "tracing", + "xdg", + "zcash_primitives", +] [[package]] name = "zeroize" diff --git a/Cargo.toml b/Cargo.toml index 06d1b6e..dcd96f8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,16 +1,26 @@ +# SPDX-FileCopyrightText: 2023 Baking Bad +# +# SPDX-License-Identifier: MIT + [workspace] members = [ - "kernel", - "installer", - "dac_codec", - "tezos_l2", - "tezos_vm", + "tezos_proto", + "tezos_kernel", "tezos_node", - "tezos_ctx", + "michelson_vm", "michelson_derive", - "michelson_interop" + "michelson_interop", + "layered_store", + "sapling_proto", + "sapling_kernel", + "zcash_params", + "kernel_io" ] +[patch.crates-io] +# FIXME: use "custom" feature to avoid unexpected behavior +getrandom = { git = "https://github.com/baking-bad/getrandom", branch = "patch/0.2" } + [profile.release] lto = true opt-level = 'z' diff --git a/LICENSE b/LICENSE index dc9c4f1..33de5bb 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2023 PK Lab +Copyright (c) 2023 Baking Bad Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/Makefile b/Makefile index f5ad215..3af35e0 100644 --- a/Makefile +++ b/Makefile @@ -1,73 +1,68 @@ -.PHONY: build test - -TAG:= -OCTEZ_TAG:= -OCTEZ_PROTO:= -NETWORK:= - -env-mumbainet: -ifeq ($(NETWORK), mumbainet) - @echo "NETWORK is already set to 'mumbainet'" -else -# $(eval OCTEZ_TAG := $(shell curl -s https://teztnets.xyz/teztnets.json | jq -r ".mumbainet.git_ref")) - $(eval OCTEZ_TAG := v17.0) - $(eval OCTEZ_PROTO := $(shell curl -s https://teztnets.xyz/teztnets.json | jq -r ".mumbainet.last_baking_daemon")) - $(eval NETWORK := mumbainet) - $(eval TAG := mumbai) - @echo "OCTEZ_TAG is now set to: $(OCTEZ_TAG)" - @echo "OCTEZ_PROTO is now set to: $(OCTEZ_PROTO)" - @echo "NETWORK is now set to: $(NETWORK)" - @echo "TAG is now set to: $(TAG)" -endif - -env-mondaynet: -ifeq ($(NETWORK), mondaynet) - @echo "NETWORK is already set to 'mondaynet'" -else - $(eval OCTEZ_TAG := $(shell curl -s https://teztnets.xyz/teztnets.json | jq -r '. | to_entries | map(select(.key | startswith("monday"))) | map(.value.docker_build)[0]')) - $(eval OCTEZ_PROTO := $(shell curl -s https://teztnets.xyz/teztnets.json | jq -r '. | to_entries | map(select(.key | startswith("monday"))) | map(.value.last_baking_daemon)[0]') - $(eval NETWORK := mondaynet) - $(eval TAG := monday) - @echo "OCTEZ_TAG is now set to: $(OCTEZ_TAG)" - @echo "OCTEZ_PROTO is now set to: $(OCTEZ_PROTO)" - @echo "NETWORK is now set to: $(NETWORK)" - @echo "TAG is now set to: $(TAG)" -endif +# SPDX-FileCopyrightText: 2023 Baking Bad +# +# SPDX-License-Identifier: MIT + +.PHONY: test + +-include nairobi.env + +BIN_DIR:=$$PWD/bin +TARGET_DIR=$$PWD/target +CARGO_BIN_PATH:=$$HOME/.cargo/bin install: - cd ~/.cargo/bin \ + cargo install tezos-smart-rollup-installer + cd $(CARGO_BIN_PATH) \ && wget -c https://github.com/WebAssembly/binaryen/releases/download/version_111/binaryen-version_111-x86_64-linux.tar.gz -O - | tar -xzv binaryen-version_111/bin/wasm-opt --strip-components 2 \ && wget -c https://github.com/WebAssembly/wabt/releases/download/1.0.31/wabt-1.0.31-ubuntu.tar.gz -O - | tar -xzv wabt-1.0.31/bin/wasm-strip wabt-1.0.31/bin/wasm2wat --strip-components 2 build-kernel: - RUSTC_BOOTSTRAP=1 cargo build --package tez_kernel --target wasm32-unknown-unknown --release -Z sparse-registry - wasm-strip -o ./.bin/tez_kernel.wasm ./target/wasm32-unknown-unknown/release/tez_kernel.wasm - # wasm-opt -Oz -o ./.bin/tez_kernel.wasm ./target/wasm32-unknown-unknown/release/tez_kernel.wasm + RUSTC_BOOTSTRAP=1 cargo build --package $(PACKAGE) \ + --target wasm32-unknown-unknown \ + --release \ + -Z sparse-registry \ + -Z avoid-dev-deps + wasm-strip -o $(BIN_DIR)/$(PACKAGE).wasm $(TARGET_DIR)/wasm32-unknown-unknown/release/$(PACKAGE).wasm + +check-kernel: + RUSTC_BOOTSTRAP=1 cargo build --package $(PACKAGE) \ + --no-default-features \ + --target wasm32-unknown-unknown \ + -Z avoid-dev-deps + wasm2wat -o $(BIN_DIR)/$(PACKAGE).wat $(TARGET_DIR)/wasm32-unknown-unknown/debug/$(PACKAGE).wasm + grep -nE 'f(32|64)\.' $(BIN_DIR)/$(PACKAGE).wat || true + +debug-kernel: + cargo build --package $(PACKAGE) \ + --target wasm32-unknown-unknown \ + --profile release \ + --target-dir $(TARGET_DIR)/repl + wasm-strip -o $(BIN_DIR)/$(PACKAGE)_debug.wasm $(TARGET_DIR)/repl/wasm32-unknown-unknown/release/$(PACKAGE).wasm + docker run --rm -it \ + --name wasm-repl \ + --entrypoint=/usr/local/bin/octez-smart-rollup-wasm-debugger \ + -v $(BIN_DIR):/home/bin \ + tezos/tezos:$(OCTEZ_TAG) \ + /home/bin/$(PACKAGE)_debug.wasm --inputs /home/bin/inputs.json build-installer: - RUSTC_BOOTSTRAP=1 cargo build --package installer --target wasm32-unknown-unknown --release -Z sparse-registry - wasm-strip -o ./.bin/installer.wasm ./target/wasm32-unknown-unknown/release/installer.wasm - # wasm-opt -Oz -o ./.bin/installer.wasm ./target/wasm32-unknown-unknown/release/installer.wasm + smart-rollup-installer get-reveal-installer \ + --upgrade-to $(BIN_DIR)/$(PACKAGE).wasm \ + --output $(BIN_DIR)/$(PACKAGE)_installer.wasm \ + --preimages-dir $(BIN_DIR)/wasm_2_0_0 -build-dac-codec: - RUSTC_BOOTSTRAP=1 cargo build --package dac_codec --release -Z sparse-registry - cp ./target/release/dac-codec ./.bin/dac-codec +build-operator: + mkdir $(BIN_DIR) || true + $(MAKE) build-kernel PACKAGE=$(PACKAGE) + $(MAKE) build-installer PACKAGE=$(PACKAGE) build-facade: - mkdir .bin || true - RUSTC_BOOTSTRAP=1 cargo build --package tezos_node --release -Z sparse-registry - cp ./target/release/tezos-node ./.bin/tezos-node - -pages: - rm -rf ./.bin/wasm_2_0_0 - ./.bin/dac-codec -o ./.bin/wasm_2_0_0 ./.bin/tez_kernel.wasm - -build-operator: - mkdir .bin || true - $(MAKE) build-kernel - $(MAKE) build-dac-codec - $(MAKE) pages - $(MAKE) build-installer + mkdir $(BIN_DIR) || true + RUSTC_BOOTSTRAP=1 cargo build --package tezos_node \ + --release \ + -Z sparse-registry \ + -Z avoid-dev-deps + cp $(TARGET_DIR)/release/tezos-node $(BIN_DIR)/tezos-node test: RUSTC_BOOTSTRAP=1 RUST_BACKTRACE=1 cargo test -Z sparse-registry --no-fail-fast --tests -- --nocapture @@ -75,71 +70,35 @@ test: nextest: RUST_LIB_BACKTRACE=1 cargo nextest run --tests -trace: -# TODO: pass test suite name - RUST_LIB_BACKTRACE=1 cargo test --jobs 1 --no-fail-fast --test e2e --features trace -- --nocapture --test-threads=1 e2e_abs_00 - image-facade: - docker build -t ghcr.io/baking-bad/tz-rollup-facade:latest --file ./build/facade/Dockerfile.local . + docker build -t tot/facade:latest --file ./build/facade/Dockerfile . image-operator: - docker build -t ghcr.io/baking-bad/tz-rollup-operator:$(TAG) --build-arg OCTEZ_TAG=$(OCTEZ_TAG) --build-arg OCTEZ_PROTO=$(OCTEZ_PROTO) --build-arg NETWORK=$(NETWORK) --file ./build/operator/Dockerfile.local . - -generate-keypair: - docker run --rm -v $$PWD/.tezos-client:/root/.tezos-client/ -v rollup-node-$(TAG):/root/.tezos-smart-rollup-node ghcr.io/baking-bad/tz-rollup-operator:$(TAG) generate-keypair - -originate-rollup: - docker stop tz-rollup-operator || true - docker rm tz-rollup-operator || true - docker volume rm rollup-node-$(TAG) || true - docker run --rm -v $$PWD/.tezos-client:/root/.tezos-client/ -v rollup-node-$(TAG):/root/.tezos-smart-rollup-node ghcr.io/baking-bad/tz-rollup-operator:$(TAG) originate-rollup - -rollup-node: - docker stop tz-rollup-operator || true - docker run --rm --name tz-rollup-operator -d -v $$PWD/.tezos-client:/root/.tezos-client/ -v $$PWD/.logs:/root/logs/ -v rollup-node-$(TAG):/root/.tezos-smart-rollup-node -p 127.0.0.1:8932:8932 ghcr.io/baking-bad/tz-rollup-operator:$(TAG) rollup-node --debug - docker logs tz-rollup-operator -f 2>&1 | grep smart_rollup_node - -populate-inbox: - docker run --rm -v $$PWD/.tezos-client:/root/.tezos-client/ -v $$PWD/.bin:/root/.bin ghcr.io/baking-bad/tz-rollup-operator:$(TAG) populate-inbox /root/.bin/messages.json - -operator-shell: - docker run --rm -it --entrypoint=/bin/sh -v $$PWD/.tezos-client:/root/.tezos-client/ -v rollup-node-$(TAG):/root/.tezos-smart-rollup-node ghcr.io/baking-bad/tz-rollup-operator:$(TAG) - -wat: - cargo build --package tez_kernel --target wasm32-unknown-unknown - wasm2wat -o ./.bin/kernel.wat ./target/wasm32-unknown-unknown/debug/tez_kernel.wasm - # check if there's no floating point calc - grep -nE 'f(32|64)\.' ./.bin/kernel.wat || true - -debug: env-mondaynet - cargo build --package tez_kernel --target wasm32-unknown-unknown --profile release --target-dir ./target/repl - wasm-strip -o ./.bin/debug_kernel.wasm ./target/repl/wasm32-unknown-unknown/release/tez_kernel.wasm - docker run --rm -it --entrypoint=/usr/local/bin/octez-smart-rollup-wasm-debugger --name wasm-repl -v $$PWD/.bin:/home/.bin tezos/tezos:$(TAG) /home/.bin/debug_kernel.wasm --inputs /home/.bin/inputs.json - -shell-monday: env-mondaynet - $(MAKE) operator-shell TAG=$(TAG) - -shell-mumbai: env-mumbainet - $(MAKE) operator-shell TAG=$(TAG) - -image-operator-monday: env-mondaynet - $(MAKE) image-operator TAG=$(TAG) OCTEZ_TAG=$(OCTEZ_TAG) OCTEZ_PROTO=$(OCTEZ_PROTO) NETWORK=$(NETWORK) - -image-operator-mumbai: env-mumbainet - $(MAKE) image-operator TAG=$(TAG) OCTEZ_TAG=$(OCTEZ_TAG) OCTEZ_PROTO=$(OCTEZ_PROTO) NETWORK=$(NETWORK) - -operator-monday: env-mondaynet - $(MAKE) build-operator - $(MAKE) image-operator TAG=$(TAG) OCTEZ_TAG=$(OCTEZ_TAG) OCTEZ_PROTO=$(OCTEZ_PROTO) NETWORK=$(NETWORK) - $(MAKE) originate-rollup TAG=$(TAG) - $(MAKE) rollup-node TAG=$(TAG) - -operator-mumbai: env-mumbainet - $(MAKE) build-operator - $(MAKE) image-operator TAG=$(TAG) OCTEZ_TAG=$(OCTEZ_TAG) OCTEZ_PROTO=$(OCTEZ_PROTO) NETWORK=$(NETWORK) - $(MAKE) originate-rollup TAG=$(TAG) - $(MAKE) rollup-node TAG=$(TAG) - -facade: + docker build -t tot/operator:${PACKAGE}_$(OCTEZ_TAG) --file ./build/operator/Dockerfile.local \ + --build-arg OCTEZ_TAG=$(OCTEZ_TAG) \ + --build-arg OCTEZ_PROTO=$(OCTEZ_PROTO) \ + --build-arg PACKAGE=$(PACKAGE) \ + . + +run-operator: + $(MAKE) build-operator PACKAGE=$(PACKAGE) + $(MAKE) image-operator OCTEZ_TAG=$(OCTEZ_TAG) OCTEZ_PROTO=$(OCTEZ_PROTO) PACKAGE=$(PACKAGE) + docker stop operator || true + docker run --rm -it \ + --name operator \ + --entrypoint=/bin/sh \ + -v $$PWD/.tezos-client:/root/.tezos-client/ \ + -v ${PACKAGE}_operator:/root/.tezos-smart-rollup-node \ + -v $(BIN_DIR):/root/bin -p 127.0.0.1:8932:8932 \ + -e NETWORK=$(NETWORK) \ + tot/operator:${PACKAGE}_$(OCTEZ_TAG) + +run-tezos-operator: + $(MAKE) run-operator PACKAGE=tezos_kernel + +run-sapling-operator: + $(MAKE) run-operator PACKAGE=sapling_kernel + +run-facade: $(MAKE) build-facade - RUST_BACKTRACE=1 RUST_LOG=debug ./.bin/tezos-node + RUST_BACKTRACE=1 RUST_LOG=debug $(BIN_DIR)/tezos-node diff --git a/README.md b/README.md index ad38df8..aaa2315 100644 --- a/README.md +++ b/README.md @@ -2,14 +2,13 @@ Optimistic rollup enabled with Tezos VM running on top of Tezos L1. -**IMPORTANT: THIS IS AN EARLY BETA, DO NOT RUN THIS CODE IN THE MAINNET** +**IMPORTANT: NOT STABLE YET, DO NOT RUN THIS CODE IN PRODUCTION** ## About -The goal of this project is to create PoC of a permissioned application-specific rollup enabled with Tezos (Michelson) VM. -Aside from the pure research interest there might be long-term advantages of such solution: +The goal of this project is to create permissioned application-specific Tezos-compatible rollup that has: * Reduced operational costs (contract automation, oracles) -* Custom MEV-resistant techniques +* Custom MEV-resistant solution * Chain-native tokenomics * Feeless experience * Contract wallets as first-class citizens (account abstraction) @@ -53,43 +52,6 @@ Your feedback is extremely valuable, and we also expect lots of bugs at early st * [Telegram](https://t.me/baking_bad_chat) chat * [Slack](https://tezos-dev.slack.com/archives/CV5NX7F2L) channel -## Roadmap - -- [x] MVP Tezos-compatible kernel supporting plain transactions and public key reveals -- [x] Installer kernel -- [x] DAC encoding tool -- [x] Docker image with SCORU node, installer, and encoded Tez kernel -- [x] Run TZ rollup in Mondaynet, prepare setup scripts -- [x] Troubleshoot kernel using REPL, get rid of `f64` -- [x] Implement internal batch workflow -- [x] Support origination operation kind -- [x] Implement a minimal viable Michelson interpreter -- [x] Interact with the kernel via inbox and access rollup state via RPC -- [x] Support contract calls and internal transactions -- [x] Tezos RPC facade node -- [x] Deploy a periodic testnet -- [x] Add support to BCD -- [x] Permanent testnet -- [ ] Add missing Michelson features necessary to onboard first dapps -- [ ] Increase test coverage -- [ ] Spam-prevention mechanism -- [ ] Configurable gas/storage metering -- [ ] Sequencer fees -- [ ] Micheline (de)serialization derive macros -- [ ] WASM smart contracts -## Limitations - -Current design is intentionally simplified to speed up development while having a minimal necessary functional to operate. -* No gas/storage metering (although it can be incorporated rather easily) -* No money burning -* Non-sequential account counters -* Only 3 manager operations supported: transaction, reveal, origination -* Branch is currently not validated (infinite TTL) -* BigMaps cannot be copied/removed, but can be moved (Rust-like semantics) -* No temporary BigMap allocations -* Several Michelson features are not supported -* Only wallet/indexer RPC endpoints are exposed - ## Installation Install Rust toolchain: @@ -107,68 +69,127 @@ Install build dependencies: make install ``` -## Build +## How to build + +### Binaries + +#### Kernel + +Create wasm file for the payload kernel: -To build the kernel and its installer: ``` -make build-operator +make build-kernel PACKAGE=tezos_kernel ``` -Then you can create a local docker image, depending on target network: -- `make image-operator-monday` -- `make image-operator-mumbai` +#### Installer -Other options are not in the Makefile, but you can add them yourself, the difference is mainly in Octez binaries shipped together with the kernel. +Convert payload kernel into 4kb pages and create a boot wasm file: + +``` +make build-installer PACKAGE=tezos_kernel +``` + +#### Facade node + +Create a binary for the facade node: -To build a facade node and its docker image: ``` make build-facade +``` + +### Docker images + +Creates local images out of the pre-built artifacts. + +### Rollup node + +Requires installer kernel and generated pages. +Note the environment file included in the Makefile, that exposes `OCTEZ_TAG`, `OCTEZ_PROTO`. + +``` +make image-operator PACKAGE=tezos_kernel +``` + +### Facade node + +``` make image-facade ``` ## How to run -Run `make generate-keypair` to initialize a Tezos L1 account, and top it up using https://teztnets.xyz faucet, depending on the network you are going to use. +Note the environment file included in the Makefile, that exposes target `NETWORK`. ### Operator -Build kernel and its installer, then originate a new rollup, and run a rollup node. -Depending on the target L1 network run one of: -- `make operator-monday` -- `make operator-mumbai` +Depending on the target package run: -Other options are not in the Makefile, but you can add them yourself based on the existing ones. +``` +make run-tezos-operator +``` + +You will end up inside the docker container shell. +Every time you call this target, kernel and docker image will be rebuilt. + +#### Generate new keys + +For convenience, your local .tezos-client folder is mapped into the container in order to preserve the keys. Upon the first launch you need to create new keypair, in order to do that inside the operator shell: + +``` +$ operator generate_key +``` + +#### Check account info + +If you already have a key, check it's balance: it should be at least 10k tez to operate a rollup, otherwise top up the balance from the faucet. To get your account address: + +``` +$ operator account_info +``` + +#### Originate rollup + +``` +$ operator deploy_rollup +``` -Note that every time you run this target a new rollup will be deployed, so make sure you have enough funds for a 10k bond. Use [faucet](https://teztnets.xyz/) to top up your account. +Rollup data is persisted meaning that you can restart the container without data loss. If you try to call this command again it will tell you that there's an existing rollup configuration. Use `--force` flag to remove all data and originate a new one. -In order to just run operator with an existing rollup: +#### Run rollup node ``` -make rollup-node TAG=monday +$ operator run_node ``` -### Facade +Runs rollup node in synchronous mode, with logs being printed to stdout. +Also RPC is available at `127.0.0.1:8932` on your host machine. + +## Facade -The following target will build the facade node and run it with default arguments: +Run tezos node binary with debug logs enabled: ``` -make facade +$ make run-facade ``` -### Docker compose +Every time you call this target tezos node binary will be rebuilt. + +## Docker compose Once you have both operator and facade images built, you can run them together with compose. -First, create a `local.env` file with two environment variables: +First, create a `.env` file with four environment variables: ``` +TAG= +NETWORK= ROLLUP_ADDRESS= OPERATOR_KEY=unencrypted: ``` -Then run docker-compose specifying the image tag, e.g.: +Then run docker-compose: ``` -TAG=monday docker-compose up -d +docker-compose up -d ``` ## How to test @@ -195,7 +216,7 @@ jupyter notebook Build kernel in debug mode, create docker image, and run REPL: ``` -make debug +make debug-kernel PACKAGE=tezos_kernel ``` Populate rollup inbox: @@ -215,6 +236,15 @@ Make sure kernel state is updated: ## Troubleshooting +### Unsupported target `wasm32-unknown-unknown` + +Known issues: +- `getrandom` (does not compile since version 0.2.10) => use patched version + ```toml + [patch.crates-io] + getrandom = { git = "https://github.com/baking-bad/getrandom", branch = "patch/0.2" } + ``` + ### `float instructions are forbidden` SCORU host does not support operations with floating point thus one need to make sure none of the dependencies introduces them. diff --git a/build/facade/Dockerfile b/build/facade/Dockerfile index 06c030f..eef04f7 100644 --- a/build/facade/Dockerfile +++ b/build/facade/Dockerfile @@ -1,3 +1,7 @@ +# SPDX-FileCopyrightText: 2023 Baking Bad +# +# SPDX-License-Identifier: MIT + FROM rust:alpine3.16 AS builder RUN apk add --no-cache musl-dev openssl-dev WORKDIR /build diff --git a/build/facade/Dockerfile.local b/build/facade/Dockerfile.local deleted file mode 100644 index f6f2b15..0000000 --- a/build/facade/Dockerfile.local +++ /dev/null @@ -1,5 +0,0 @@ -FROM rust:slim-buster -COPY ./.bin/tezos-node /usr/bin/tezos-node -ENV RUST_BACKTRACE=1 -ENV RUST_LOG=debug -ENTRYPOINT [ "/usr/bin/tezos-node" ] \ No newline at end of file diff --git a/build/operator/Dockerfile b/build/operator/Dockerfile index c2d00ad..0820770 100644 --- a/build/operator/Dockerfile +++ b/build/operator/Dockerfile @@ -1,19 +1,23 @@ -ARG OCTEZ_TAG=v17.0-rc1 +# SPDX-FileCopyrightText: 2023 Baking Bad +# +# SPDX-License-Identifier: MIT + +ARG OCTEZ_TAG FROM tezos/tezos:${OCTEZ_TAG} AS octez FROM rust:slim-buster AS builder RUN apt update && apt install -y wget make libc-dev RUN rustup target add wasm32-unknown-unknown -WORKDIR /usr/bin -RUN wget -c https://github.com/WebAssembly/binaryen/releases/download/version_111/binaryen-version_111-x86_64-linux.tar.gz -O - | tar -xzv binaryen-version_111/bin/wasm-opt --strip-components 2 -RUN wget -c https://github.com/WebAssembly/wabt/releases/download/1.0.31/wabt-1.0.31-ubuntu.tar.gz -O - | tar -xzv wabt-1.0.31/bin/wasm-strip --strip-components 2 WORKDIR /build +COPY Makefile ./ +RUN make install CARGO_BIN_PATH=/usr/local/cargo/bin COPY . . -RUN make build-operator +ARG PACKAGE +RUN make build-operator PACKAGE=${PACKAGE} FROM alpine:3.15 AS rollup RUN apk --no-cache add binutils gcc gmp libgmpxx hidapi libc-dev libev libffi sudo -ARG OCTEZ_PROTO="PtMumbai" +ARG OCTEZ_PROTO #ARG RELEASE="auto-release" #RUN wget "https://github.com/serokell/tezos-packaging/releases/download/$RELEASE/octez-smart-rollup-node-$OCTEZ_PROTO" -O "/usr/bin/octez-smart-rollup-node" \ # && chmod +x /usr/bin/octez-smart-rollup-node @@ -21,10 +25,9 @@ ARG OCTEZ_PROTO="PtMumbai" # && chmod +x /usr/bin/octez-client COPY --from=octez /usr/local/bin/octez-smart-rollup-node-${OCTEZ_PROTO} /usr/bin/octez-smart-rollup-node COPY --from=octez /usr/local/bin/octez-client /usr/bin/octez-client -COPY --from=builder /build/.bin/wasm_2_0_0/ /root/wasm_2_0_0/ -COPY --from=builder /build/.bin/installer.wasm /root/kernel.wasm +COPY --from=builder /build/bin/wasm_2_0_0/ /root/wasm_2_0_0/ +ARG PACKAGE +COPY --from=builder /build/bin/${PACKAGE}_installer.wasm /root/kernel.wasm COPY ./build/operator/entrypoint.sh . -RUN chmod +x entrypoint.sh -ARG NETWORK="ghostnet" -ENV NETWORK=${NETWORK} +RUN chmod +x entrypoint.sh && ln ./entrypoint.sh /usr/bin/operator ENTRYPOINT [ "./entrypoint.sh" ] \ No newline at end of file diff --git a/build/operator/Dockerfile.debug b/build/operator/Dockerfile.debug index cabab0e..da0ef31 100644 --- a/build/operator/Dockerfile.debug +++ b/build/operator/Dockerfile.debug @@ -1,3 +1,7 @@ +# SPDX-FileCopyrightText: 2023 Baking Bad +# +# SPDX-License-Identifier: MIT + # https://gitlab.com/tezos/tezos/-/blob/master/.gitlab-ci.yml#L38 ARG BASE_IMAGE=registry.gitlab.com/tezos/opam-repository ARG BASE_IMAGE_VERSION=runtime-build-dependencies--205530c16047066997bf2b210542ceeef8fb96d1 @@ -12,21 +16,20 @@ RUN git clone --single-branch --branch "$TEZOS_BRANCH" https://gitlab.com/tezos/ FROM rust:slim-buster AS builder RUN apt update && apt install -y wget make libc-dev RUN rustup target add wasm32-unknown-unknown -WORKDIR /usr/bin -RUN wget -c https://github.com/WebAssembly/binaryen/releases/download/version_111/binaryen-version_111-x86_64-linux.tar.gz -O - | tar -xzv binaryen-version_111/bin/wasm-opt --strip-components 2 -RUN wget -c https://github.com/WebAssembly/wabt/releases/download/1.0.31/wabt-1.0.31-ubuntu.tar.gz -O - | tar -xzv wabt-1.0.31/bin/wasm-strip --strip-components 2 WORKDIR /build +COPY Makefile ./ +RUN make install CARGO_BIN_PATH=/usr/local/cargo/bin COPY . . -RUN make build-operator +ARG PACKAGE +RUN make build-operator PACKAGE=${PACKAGE} FROM alpine:3.15 AS rollup ARG OCTEZ_PROTO="PtMumbai" COPY --from=octez /home/tezos/tezos/octez-smart-rollup-node-${OCTEZ_PROTO} /usr/bin/octez-smart-rollup-node COPY --from=octez /home/tezos/tezos/octez-client /usr/bin/octez-client -COPY --from=builder /build/.bin/wasm_2_0_0/ /root/wasm_2_0_0/ -COPY --from=builder /build/.bin/installer.wasm /root/kernel.wasm +COPY --from=builder /build/bin/wasm_2_0_0/ /root/wasm_2_0_0/ +ARG PACKAGE +COPY --from=builder /build/bin/${PACKAGE}_installer.wasm /root/kernel.wasm COPY ./build/operator/entrypoint.sh . -RUN chmod +x entrypoint.sh -ARG NETWORK="mumbainet" -ENV NETWORK=${NETWORK} +RUN chmod +x entrypoint.sh && ln ./entrypoint.sh /usr/bin/operator ENTRYPOINT [ "./entrypoint.sh" ] \ No newline at end of file diff --git a/build/operator/Dockerfile.local b/build/operator/Dockerfile.local index a6933f2..bb5db34 100644 --- a/build/operator/Dockerfile.local +++ b/build/operator/Dockerfile.local @@ -1,3 +1,7 @@ +# SPDX-FileCopyrightText: 2023 Baking Bad +# +# SPDX-License-Identifier: MIT + ARG OCTEZ_TAG FROM tezos/tezos:${OCTEZ_TAG} AS octez @@ -6,10 +10,9 @@ RUN apk --no-cache add binutils gcc gmp libgmpxx hidapi libc-dev libev libffi su ARG OCTEZ_PROTO COPY --from=octez /usr/local/bin/octez-smart-rollup-node-${OCTEZ_PROTO} /usr/bin/octez-smart-rollup-node COPY --from=octez /usr/local/bin/octez-client /usr/bin/octez-client -COPY ./.bin/wasm_2_0_0/ /root/wasm_2_0_0/ -COPY ./.bin/installer.wasm /root/kernel.wasm +COPY ./bin/wasm_2_0_0/ /root/wasm_2_0_0/ +ARG PACKAGE +COPY ./bin/${PACKAGE}_installer.wasm /root/kernel.wasm COPY ./build/operator/entrypoint.sh . -RUN chmod +x entrypoint.sh -ARG NETWORK -ENV NETWORK=${NETWORK} +RUN chmod +x entrypoint.sh && ln ./entrypoint.sh /usr/bin/operator ENTRYPOINT [ "./entrypoint.sh" ] \ No newline at end of file diff --git a/build/operator/entrypoint.sh b/build/operator/entrypoint.sh index 7f2f180..50f27cf 100644 --- a/build/operator/entrypoint.sh +++ b/build/operator/entrypoint.sh @@ -1,5 +1,9 @@ #!/bin/sh +# SPDX-FileCopyrightText: 2023 Baking Bad +# +# SPDX-License-Identifier: MIT + set -e client_dir="/root/.tezos-client" @@ -29,7 +33,7 @@ import_key() { fi } -launch_rollup() { +run_node() { import_key if [ ! -f "$rollup_dir/config.json" ]; then @@ -52,12 +56,18 @@ launch_rollup() { TEZOS_LOG='* -> info' TEZOS_EVENTS_CONFIG=$LOG_CONFIG exec octez-smart-rollup-node --endpoint "$endpoint" -d "$client_dir" run --data-dir "$rollup_dir" --rpc-addr "0.0.0.0" } -originate_rollup() { +deploy_rollup() { import_key if [ -f "$rollup_dir/config.json" ]; then echo "Found existing rollup config" - exit 0 + if [ "$1" == "--force" ]; then + echo "Overriding with new kernel" + rm -rf "$rollup_dir/*" + octez-client --endpoint "$endpoint" forget all smart rollups --force + else + exit 0 + fi fi if [ ! -f "/root/kernel.wasm" ]; then @@ -66,49 +76,55 @@ originate_rollup() { fi kernel="$(xxd -p "/root/kernel.wasm" | tr -d '\n')" - octez-client --endpoint "$endpoint" originate smart rollup tot from operator of kind wasm_2_0_0 of type bytes with kernel "$kernel" --burn-cap 999 --force | tee originate.out + octez-client --endpoint "$endpoint" originate smart rollup "rollup" from operator of kind wasm_2_0_0 of type bytes with kernel "$kernel" --burn-cap 999 --force | tee originate.out operator_address=$(octez-client --endpoint "$endpoint" show address "operator" 2>&1 | grep Hash | grep -oE "tz.*") - octez-smart-rollup-node --base-dir "$client_dir" init operator config for tot with operators "$operator_address" --data-dir "$rollup_dir" + octez-smart-rollup-node --base-dir "$client_dir" init operator config for "rollup" with operators "$operator_address" --data-dir "$rollup_dir" } -generate_keypair() { +generate_key() { octez-client --endpoint "$endpoint" gen keys "operator" operator_address=$(octez-client --endpoint "$endpoint" show address "operator" 2>&1 | grep Hash | grep -oE "tz.*") echo "Top up the balance for $operator_address on $faucet" } -populate_inbox() { - octez-client --endpoint "$endpoint" send smart rollup message "file:$@" from operator +account_info() { + octez-client --endpoint "$endpoint" show address "operator" + octez-client --endpoint "$endpoint" get balance for "operator" + echo "Top up the balance on $faucet" +} + +send_message() { + octez-client --endpoint "$endpoint" send smart rollup message hex:"[\"$1\"]" from operator } case $command in - rollup-node) - launch_rollup + run_node) + run_node ;; - originate-rollup) - originate_rollup + deploy_rollup) + deploy_rollup $@ ;; - generate-keypair) - generate_keypair + generate_key) + generate_key ;; - wasm-repl) - octez-wasm-repl $@ + account_info) + account_info ;; - populate-inbox) - populate_inbox $@ + send_message) + send_message $@ ;; *) cat < = Lazy::new(|| Crypto::new(None, None, None)); - -fn hash_digest(preimage: &[u8]) -> [u8; PREIMAGE_HASH_SIZE] { - let digest_256 = CRYPTO - .blake2b(preimage, 32) - .expect("Failed to calculate hash"); - let mut hash_with_prefix = [0; PREIMAGE_HASH_SIZE]; - hash_with_prefix[1..].copy_from_slice(&digest_256); - hash_with_prefix -} - -fn get_filename(payload: &[u8]) -> String { - // ScRollupRevealHash::from_bytes(&payload[1..]).unwrap().into_string() - hex::encode(payload) -} - -fn write_page(page: &Page, output_path: &PathBuf) -> [u8; PREIMAGE_HASH_SIZE] { - let mut data = Vec::with_capacity(MAX_PAGE_SIZE); - page.bin_write(&mut data) - .expect("Failed to serialize content page"); - - let hash = hash_digest(data.as_slice()); - let filename = get_filename(&hash); - let path = output_path.join(filename); - - let mut output_file = File::create(path).expect("Failed to open file for writing"); - output_file - .write(data.as_slice()) - .expect("Failed to write file"); - hash -} - -fn write_root(root_hash: &[u8; PREIMAGE_HASH_SIZE], output_path: &PathBuf) -> String { - let path = output_path.join(ROOT_HASH_FILE); - let mut output_file = File::create(path).expect("Failed to open file for writing"); - output_file.write(root_hash).expect("Failed to write file"); - get_filename(root_hash) -} - -fn ensure_dir_exists(output_path: &PathBuf) { - if output_path.exists() { - if !output_path.is_dir() { - panic!("{:?} is not a directory", output_path); - } - } else { - create_dir_all(output_path).expect("Failed to create output directory"); - } -} - -fn read_source_file(source_path: &PathBuf) -> Vec { - let file_size = std::fs::metadata(source_path) - .expect("Failed to find source") - .len(); - if file_size > MAX_FILE_SIZE { - panic!("Source file is too large"); - } - - let mut source_file = File::open(source_path).expect("Failed to open source file for reading"); - let mut buffer: Vec = Vec::with_capacity(file_size.try_into().unwrap()); - - if let Err(error) = source_file.read_to_end(&mut buffer) { - panic!("Failed to read source file: {:?}", error); - } - - buffer -} - -fn hash_loop( - level: usize, - pages: &Vec, - hashes: &mut Vec<[u8; PREIMAGE_HASH_SIZE]>, - output_path: &PathBuf, -) -> String { - if level >= MAX_DAC_LEVELS { - panic!("DAC preimage tree contains too many levels: {}", level); - } - - hashes.clear(); - - for page in pages { - let hash = write_page(&page, &output_path); - hashes.push(hash); - } - - if hashes.len() == 1 { - write_root(&hashes[0], output_path) - } else { - let hashes_pages: Vec = V0HashPage::new_pages(hashes.as_slice()) - .map(|c| Page::V0HashPage(c)) - .collect(); - hash_loop(level + 1, &hashes_pages, hashes, output_path) - } -} - -fn generate_pages_v0(source_path: &PathBuf, output_path: &PathBuf) -> String { - ensure_dir_exists(output_path); - - let input = read_source_file(source_path); - let mut hashes: Vec<[u8; PREIMAGE_HASH_SIZE]> = - Vec::with_capacity(input.len() / V0ContentPage::MAX_CONTENT_SIZE + 1); - let pages: Vec<_> = V0ContentPage::new_pages(input.as_slice()) - .map(|p| Page::V0ContentPage(p)) - .collect(); - - return hash_loop(0, &pages, &mut hashes, output_path); -} - -#[derive(Parser, Debug)] -struct Args { - /// Path to the file that is to be DAC encoded - source_file: PathBuf, - - /// Output directory to save hash/content pages - #[arg(short, long)] - output_dir: Option, -} - -fn main() { - let args = Args::parse(); - - let output_path = args.output_dir.unwrap_or(PathBuf::from(".")); - let root_hash = generate_pages_v0(&args.source_file, &output_path); - - print!("{}", root_hash); -} diff --git a/docker-compose.yml b/docker-compose.yml index bbaa1c4..ee96f2c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,11 +1,17 @@ +# SPDX-FileCopyrightText: 2023 Baking Bad +# +# SPDX-License-Identifier: MIT + version: "3.8" services: operator: - image: ghcr.io/baking-bad/tz-rollup-operator:${TAG} - command: rollup-node + image: tot/operator:${TAG} + command: run_node restart: "no" env_file: - - local.env + - .env + # TAG e.g. tezos_kernel_v17.1 + # NETWORK e.g. nairobinet # ROLLUP_ADDRESS e.g. sr1... # OPERATOR_KEY e.g. unencrypted:edsk... ports: @@ -14,7 +20,7 @@ services: - internal facade: - image: ghcr.io/baking-bad/tz-rollup-facade:latest + image: tot/facade:latest command: --endpoint http://operator:8932 --rpc-addr "0.0.0.0" restart: always ports: diff --git a/installer/Cargo.toml b/installer/Cargo.toml deleted file mode 100644 index cb0fb49..0000000 --- a/installer/Cargo.toml +++ /dev/null @@ -1,20 +0,0 @@ -[package] -name = "installer" -version = "0.1.0" -edition = "2021" - -[lib] -crate-type = ["cdylib", "rlib"] - -[dev-dependencies] -host = { git = "https://gitlab.com/tezos/kernel", rev = "417cdfbac778e96e1b9061b9f3b4517a6f1fa433" } -mock_runtime = { git = "https://gitlab.com/tezos/kernel", rev = "417cdfbac778e96e1b9061b9f3b4517a6f1fa433" } -tezos_encoding = { git = "https://github.com/emturner/tezedge.git", branch = "master", default-features = false } -tezos_rollup_encoding = { git = "https://gitlab.com/tezos/kernel", rev = "417cdfbac778e96e1b9061b9f3b4517a6f1fa433" } -tezos_core = { git = "https://github.com/baking-bad/tezos-rust-sdk", branch = "develop", package = "tezos-core" } -hex = { version = "0.4.3" } -once_cell = "1.16.0" - -[features] -default = [] -std = [] diff --git a/installer/src/installer.rs b/installer/src/installer.rs deleted file mode 100644 index f0e4f9f..0000000 --- a/installer/src/installer.rs +++ /dev/null @@ -1,298 +0,0 @@ -// SPDX-FileCopyrightText: 2022 TriliTech -// SPDX-FileCopyrightText: 2022 PK Lab -// SPDX-License-Identifier: MIT - -//! The *Preimage Installer* installs a kernel, that is too large to be originated directly. -//! -//! It does so leveraging both *DAC* and the [reveal preimage] mechanism. -//! -//! At its limit, 3 levels of DAC pages gives us enough content for >7GB, which is already -//! far in excess of the likely max limit on WASM modules that the PVM can support. -//! Store values alone are limited to ~2GB. -//! -//! [reveal preimage]: host::rollup_core::reveal_preimage -//! -const PREIMAGE_HASH_SIZE: usize = 33; -const MAX_PAGE_SIZE: usize = 4096; -const MAX_FILE_CHUNK_SIZE: usize = 2048; -const MAX_DAC_LEVELS: usize = 4; -const KERNEL_PATH: &[u8] = b"/kernel/boot.wasm"; -const PREPARE_KERNEL_PATH: &[u8] = b"/installer/kernel/boot.wasm"; -const REBOOT_PATH: &[u8] = b"/kernel/env/reboot"; - -#[cfg(not(test))] -pub mod host { - #[link(wasm_import_module = "smart_rollup_core")] - extern "C" { - pub fn store_write( - path: *const u8, - path_len: usize, - offset: usize, - src: *const u8, - num_bytes: usize, - ) -> i32; - - pub fn store_move( - from_path: *const u8, - from_path_len: usize, - to_path: *const u8, - to_path_len: usize, - ) -> i32; - - pub fn reveal_preimage( - hash_addr: *const u8, - hash_len: usize, - destination_addr: *mut u8, - max_bytes: usize, - ) -> i32; - - pub fn write_debug(src: *const u8, num_bytes: usize); - } -} - -#[macro_export] -macro_rules! debug_str { - ($msg: expr) => { - unsafe { - crate::installer::host::write_debug(($msg as &str).as_ptr(), ($msg as &str).len()); - } - }; -} - -fn fetch_page<'a>( - hash: &[u8; PREIMAGE_HASH_SIZE], - buffer: &'a mut [u8], -) -> (u8, &'a mut [u8], &'a mut [u8]) { - let page_size = unsafe { - host::reveal_preimage(hash.as_ptr(), hash.len(), buffer.as_mut_ptr(), buffer.len()) - }; - if page_size < 0 { - panic!("Fetch page: failed to reveal preimage {}", page_size); - } else if page_size < 5 { - // tag + prefix - panic!("Fetch page: too small {}", page_size); - } - - let (page, rest) = buffer.split_at_mut(MAX_PAGE_SIZE); - if page[0] > 1 { - panic!("Fetch page: invalid tag {}", page[0]); - } - - let data_size = u32::from_be_bytes([page[1], page[2], page[3], page[4]]) as usize; - let end_offset = 5 + data_size; - - if page_size < end_offset.try_into().unwrap() - || (page[0] == 1 && data_size % PREIMAGE_HASH_SIZE != 0) - { - panic!("Fetch page: invalid size prefix"); - } - (page[0], &mut page[5..end_offset], rest) -} - -fn write_content(kernel_size: &mut usize, content: &[u8]) { - use core::ops::AddAssign; - let size = unsafe { - host::store_write( - PREPARE_KERNEL_PATH.as_ptr(), - PREPARE_KERNEL_PATH.len(), - *kernel_size, - content.as_ptr(), - content.len(), - ) - }; - if size < 0 { - panic!("Write content: failed {}", size); - } - kernel_size.add_assign(content.len()); -} - -fn reveal_loop( - level: usize, - hash: &[u8; PREIMAGE_HASH_SIZE], - rest: &mut [u8], - kernel_size: &mut usize, -) { - if level >= MAX_DAC_LEVELS { - panic!("Reveal loop: DAC preimage tree contains too many levels"); - } - match fetch_page(hash, rest) { - (0, content, _) => { - for chunk in content.chunks(MAX_FILE_CHUNK_SIZE).into_iter() { - write_content(kernel_size, chunk) - } - } - (1, hashes, rest) => { - for hash in hashes.chunks_exact(PREIMAGE_HASH_SIZE).into_iter() { - reveal_loop( - level + 1, - hash.try_into().expect("Invalid preimage hash"), - rest, - kernel_size, - ); - } - } - _ => panic!("Reveal loop: unexpected data"), - } -} - -pub fn install_kernel(root_hash: &[u8; PREIMAGE_HASH_SIZE]) { - let mut buffer = [0; MAX_PAGE_SIZE * MAX_DAC_LEVELS]; - let mut kernel_size = 0; - reveal_loop(0, root_hash, buffer.as_mut_slice(), &mut kernel_size); - - let size = unsafe { - host::store_move( - PREPARE_KERNEL_PATH.as_ptr(), - PREPARE_KERNEL_PATH.len(), - KERNEL_PATH.as_ptr(), - KERNEL_PATH.len(), - ) - }; - if size < 0 { - panic!("Install kernel: failed to swap {}", size); - } - - // TODO: root_hash is protocol hash - // TODO: rollup address is chain id - - debug_str!("Kernel successfully installed, rebooting"); - unsafe { - host::store_write( - REBOOT_PATH.as_ptr(), - REBOOT_PATH.len(), - 0, - [0_u8].as_ptr(), - 1, - ); - } -} - -#[cfg(test)] -pub mod host { - use super::PREIMAGE_HASH_SIZE; - use core::slice::{from_raw_parts, from_raw_parts_mut}; - use mock_runtime::host::MockHost; - use once_cell::sync::Lazy; - pub static mut HOST: Lazy = Lazy::new(|| MockHost::default()); - - pub unsafe fn store_write( - path: *const u8, - path_len: usize, - offset: usize, - src: *const u8, - num_bytes: usize, - ) -> i32 { - let path = from_raw_parts(path, path_len); - let bytes = from_raw_parts(src, num_bytes); - HOST.as_mut().handle_store_write(path, offset, bytes) - } - - pub unsafe fn store_move( - from_path: *const u8, - from_path_len: usize, - to_path: *const u8, - to_path_len: usize, - ) -> i32 { - let from_path = from_raw_parts(from_path, from_path_len); - let to_path = from_raw_parts(to_path, to_path_len); - HOST.as_mut().handle_store_move(from_path, to_path); - 0 - } - - pub unsafe fn reveal_preimage( - hash_addr: *const u8, - hash_len: usize, - destination_addr: *mut u8, - max_bytes: usize, - ) -> i32 { - let hash = from_raw_parts(hash_addr, hash_len) - .try_into() - .unwrap_or_else(|_| panic!("Hash is not {} bytes", PREIMAGE_HASH_SIZE)); - - let preimage = HOST.as_mut().store.retrieve_preimage(hash); - let bytes = if preimage.len() < max_bytes { - &preimage - } else { - &preimage[0..max_bytes] - }; - - let slice = from_raw_parts_mut(destination_addr, bytes.len()); - slice.copy_from_slice(bytes); - - bytes.len().try_into().unwrap() - } - - pub unsafe fn write_debug(src: *const u8, num_bytes: usize) { - let msg = from_raw_parts(src, num_bytes).to_vec(); - eprintln!("[DEBUG] {}", String::from_utf8(msg).unwrap()); - } -} - -#[cfg(test)] -mod tests { - use super::*; - use hex; - use mock_runtime::state::HostState; - use tezos_encoding::enc::BinWriter; - use tezos_rollup_encoding::dac::{Page, V0ContentPage, V0HashPage, MAX_PAGE_SIZE}; - - fn prepare_preimages(state: &mut HostState, input: &[u8]) -> [u8; PREIMAGE_HASH_SIZE] { - let content_pages = V0ContentPage::new_pages(input) - .map(Page::V0ContentPage) - .map(|page| { - let mut buffer = Vec::with_capacity(MAX_PAGE_SIZE); - page.bin_write(&mut buffer).expect("can serialize"); - buffer - }); - - let mut hashes = Vec::with_capacity(input.len() / V0ContentPage::MAX_CONTENT_SIZE + 1); - - for page in content_pages { - assert!(page.len() <= 4096); - let hash = state.set_preimage(page); - hashes.push(hash); - } - - let mut hash_pages: Vec<_> = V0HashPage::new_pages(&hashes).collect(); - assert_eq!(1, hash_pages.len(), "expected single hash page"); - - let hash_page = hash_pages.remove(0); - - let mut root_page = Vec::with_capacity(MAX_PAGE_SIZE); - Page::V0HashPage(hash_page) - .bin_write(&mut root_page) - .expect("cannot serialize hash page"); - - let root_hash = state.set_preimage(root_page); - root_hash - } - - #[test] - pub fn installer_sets_correct_kernel() { - let mut kernel: Vec = Vec::with_capacity(40_000); - for i in 0..10000 { - kernel.extend_from_slice(u16::to_le_bytes(i).as_slice()); - } - - let root_hash = unsafe { prepare_preimages(host::HOST.as_mut(), &kernel) }; - - let mut root_hex_hash = [0; PREIMAGE_HASH_SIZE * 2]; - hex::encode_to_slice(&root_hash, root_hex_hash.as_mut_slice()) - .expect("hex encoding should work"); - - install_kernel(&root_hash); - - let installed_kernel: Vec = unsafe { - host::HOST - .as_mut() - .store - .get_value("/durable/kernel/boot.wasm") - }; - assert_eq!( - installed_kernel.len(), - kernel.len(), - "Expected same kernel size." - ); - assert_eq!(installed_kernel, kernel, "Expected kernel to be installed."); - } -} diff --git a/installer/src/lib.rs b/installer/src/lib.rs deleted file mode 100644 index 4591526..0000000 --- a/installer/src/lib.rs +++ /dev/null @@ -1,19 +0,0 @@ -#![cfg_attr(all(not(test), not(feature = "std")), no_std)] - -pub mod installer; - -#[cfg(target_arch = "wasm32")] -#[no_mangle] -pub extern "C" fn kernel_run() { - debug_str!("Installer kernel invoked"); - crate::installer::install_kernel(include_bytes!("../../.bin/wasm_2_0_0/root_hash.bin")); -} - -#[cfg_attr(all(target_arch = "wasm32", not(feature = "std")), panic_handler)] -#[no_mangle] -fn panic(info: &core::panic::PanicInfo) -> ! { - if let Some(msg) = info.payload().downcast_ref::<&str>() { - debug_str!(msg); - } - panic!() -} diff --git a/kernel/Cargo.toml b/kernel/Cargo.toml deleted file mode 100644 index 1c9fa21..0000000 --- a/kernel/Cargo.toml +++ /dev/null @@ -1,22 +0,0 @@ -[package] -name = "tez_kernel" -version = "0.1.0" -edition = "2021" - -[lib] -crate-type = ["cdylib", "rlib"] - -[dependencies] -tezos_ctx = { path = "../tezos_ctx" } -tezos_l2 = { path = "../tezos_l2" } -host = { git = "https://gitlab.com/tezos/kernel", rev = "417cdfbac778e96e1b9061b9f3b4517a6f1fa433" } -tezos_core = { git = "https://github.com/baking-bad/tezos-rust-sdk", branch = "develop", package = "tezos-core", default-features = false } -tezos_operation = { git = "https://github.com/baking-bad/tezos-rust-sdk", branch = "develop", package = "tezos-operation", default-features = false } - -derive_more = "0.99" -hex = "*" - -[dev-dependencies] -tezos_rpc = { git = "https://github.com/baking-bad/tezos-rust-sdk", branch = "develop", package = "tezos-rpc", default-features = false } -mock_runtime = { git = "https://gitlab.com/tezos/kernel", rev = "417cdfbac778e96e1b9061b9f3b4517a6f1fa433" } -hex = "*" \ No newline at end of file diff --git a/kernel/src/context.rs b/kernel/src/context.rs deleted file mode 100644 index 7f95a92..0000000 --- a/kernel/src/context.rs +++ /dev/null @@ -1,177 +0,0 @@ -use host::{rollup_core::RawRollupCore, runtime::Runtime}; -use std::collections::{HashMap, HashSet}; -use tezos_ctx::{ContextNode, GenericContext, Result}; - -use crate::store::{store_delete, store_has, store_move, store_read, store_write}; - -const TMP_PREFIX: &str = "/tmp"; - -pub struct PVMContext -where - Host: RawRollupCore, -{ - host: Host, - state: HashMap>, - modified_keys: HashSet, - saved_state: HashMap, -} - -impl AsMut for PVMContext -where - Host: RawRollupCore, -{ - fn as_mut(&mut self) -> &mut Host { - &mut self.host - } -} - -impl PVMContext -where - Host: RawRollupCore, -{ - pub fn new(host: Host) -> Self { - PVMContext { - host, - state: HashMap::new(), - saved_state: HashMap::new(), - modified_keys: HashSet::new(), - } - } -} - -impl PVMContext { - pub fn persist(&mut self) -> Result<()> { - for (key, exists) in self.saved_state.drain() { - if exists { - store_move(&mut self.host, [TMP_PREFIX, &key].concat().as_str(), &key)?; - } else { - store_delete(&mut self.host, &key)?; - } - } - Ok(()) - } -} - -impl GenericContext for PVMContext -where - Host: RawRollupCore, -{ - fn log(&self, msg: String) { - self.host.write_debug(msg.as_str()) - } - - fn has(&self, key: String) -> Result { - if self.state.contains_key(&key) { - return Ok(true); - } - - if let Some(has) = self.saved_state.get(&key) { - return Ok(*has); - } - - store_has(&self.host, &key) - } - - fn get(&mut self, key: String) -> Result> { - if let Some(val) = self.state.get(&key) { - return Ok(val.clone()); - } - - let store_key = match self.saved_state.get(&key) { - Some(false) => return Ok(None), - Some(true) => [TMP_PREFIX, &key].concat(), - None => key.clone(), - }; - - match store_read(&self.host, &store_key) { - Ok(Some(bytes)) => { - let val = ContextNode::from_vec(bytes)?; - self.state.insert(key, Some(val.clone())); - Ok(Some(val)) - } - Ok(None) => Ok(None), - Err(err) => Err(err), - } - } - - fn set(&mut self, key: String, val: Option) -> Result<()> { - self.state.insert(key.clone(), val); - self.modified_keys.insert(key); - Ok(()) - } - - fn has_pending_changes(&self) -> bool { - !self.modified_keys.is_empty() - } - - fn commit(&mut self) -> Result<()> { - let modified_keys: Vec = self.modified_keys.drain().collect(); - for key in modified_keys { - let val = self - .state - .remove(&key) - .expect("Modified key must be in the pending state"); - - let exists = match val { - Some(val) => { - store_write( - &mut self.host, - [TMP_PREFIX, &key].concat().as_str(), - val.to_vec()?, - )?; - true - } - None => false, - }; - self.saved_state.insert(key, exists); - } - Ok(()) - } - - fn rollback(&mut self) { - for key in self.modified_keys.drain().into_iter() { - self.state.remove(&key); - } - } - - fn clear(&mut self) { - self.state.clear(); - self.saved_state.clear(); - self.modified_keys.clear(); - store_delete(&mut self.host, TMP_PREFIX).expect("Failed to remove tmp files") - } -} - -#[cfg(test)] -mod test { - use mock_runtime::host::MockHost; - use tezos_core::types::mutez::Mutez; - use tezos_ctx::{ExecutorContext, GenericContext, Result}; - - use crate::context::PVMContext; - - #[test] - fn store_balance() -> Result<()> { - let mut context = PVMContext::new(MockHost::default()); - - let address = "tz1Mj7RzPmMAqDUNFBn5t5VbXmWW4cSUAdtT"; - let balance: Mutez = 1000u32.into(); - - assert!(context.get_balance(&address)?.is_none()); // both host and cache accessed - - context.set_balance(&address, balance.clone())?; // cached - context.commit()?; // write to tmp folder - context.persist()?; // move/delete permanently - context.clear(); // clean up - - assert!(context.get_balance(&address)?.is_some()); // cached again - assert_eq!( - context - .get_balance(&address)? - .expect("Balance must not be null"), - balance - ); // served from the cache - - Ok(()) - } -} diff --git a/kernel/src/inbox.rs b/kernel/src/inbox.rs deleted file mode 100644 index f99d7a0..0000000 --- a/kernel/src/inbox.rs +++ /dev/null @@ -1,87 +0,0 @@ -use host::{ - input::Input, - rollup_core::{RawRollupCore, MAX_INPUT_MESSAGE_SIZE}, - runtime::Runtime, -}; -use tezos_core::types::encoded::{BlockHash, Encoded, OperationHash, Signature}; -use tezos_operation::operations::{SignedOperation, UnsignedOperation}; - -use crate::error::{Error, Result}; - -const CHAIN_ID_SIZE: usize = 4; -const SIGNATURE_SIZE: usize = 64; - -#[derive(Debug, Clone)] -pub struct LevelInfo { - pub predecessor_timestamp: i64, - pub predecessor: BlockHash, -} - -impl TryFrom<&[u8]> for LevelInfo { - type Error = Error; - - fn try_from(value: &[u8]) -> Result { - if value.len() != 8 + 32 { - return Err(Error::UnexpectedLevelInfoLength { - length: value.len(), - }); - } - let predecessor_timestamp = i64::from_be_bytes([ - value[0], value[1], value[2], value[3], value[4], value[5], value[6], value[7], - ]); - let predecessor = BlockHash::from_bytes(&value[8..])?; - Ok(Self { - predecessor_timestamp, - predecessor, - }) - } -} - -pub enum InboxMessage { - BeginBlock(i32), - EndBlock(i32), - LevelInfo(LevelInfo), - L2Operation { - hash: OperationHash, - opg: SignedOperation, - }, - NoMoreData, - Unknown(i32), -} - -pub fn parse_l2_operation<'a>(payload: &'a [u8], chain_prefix: &[u8]) -> Result { - if payload.len() <= CHAIN_ID_SIZE + SIGNATURE_SIZE { - return Err(Error::UnexpectedL2OperationLength { - length: payload.len(), - }); - } - - if payload[..CHAIN_ID_SIZE] != *chain_prefix { - return Err(Error::UnexpectedL2OperationPrefix); - } - - let unsigned_op = UnsignedOperation::from_forged_bytes( - &payload[CHAIN_ID_SIZE..payload.len() - SIGNATURE_SIZE], - )?; - let signature = Signature::from_bytes(&payload[payload.len() - SIGNATURE_SIZE..])?; - let hash = SignedOperation::operation_hash(payload)?; - Ok(InboxMessage::L2Operation { - hash, - opg: SignedOperation::from(unsigned_op, signature), - }) -} - -pub fn read_inbox(host: &mut impl RawRollupCore, chain_prefix: &[u8]) -> Result { - match host.read_input(MAX_INPUT_MESSAGE_SIZE) { - Ok(Some(Input::Message(message))) => match message.as_ref() { - b"\x00\x01" => Ok(InboxMessage::BeginBlock(message.level)), - b"\x00\x02" => Ok(InboxMessage::EndBlock(message.level)), - [b'\x00', b'\x03', info @ ..] => Ok(InboxMessage::LevelInfo(info.try_into()?)), - [b'\x01', payload @ ..] => parse_l2_operation(payload, chain_prefix), - _ => Ok(InboxMessage::Unknown(message.id)), - }, - Ok(Some(Input::Slot(_message))) => todo!("handle slot message"), - Ok(None) => Ok(InboxMessage::NoMoreData), - Err(err) => Err(err.into()), - } -} diff --git a/kernel/src/lib.rs b/kernel/src/lib.rs deleted file mode 100644 index 760ba3c..0000000 --- a/kernel/src/lib.rs +++ /dev/null @@ -1,31 +0,0 @@ -pub mod context; -pub mod error; -pub mod inbox; -pub mod kernel; -pub mod store; - -pub use error::{Error, Result}; - -#[cfg(target_arch = "wasm32")] -fn panic_hook(info: &core::panic::PanicInfo) { - let message = if let Some(message) = info.payload().downcast_ref::() { - format!("Kernel panic {:?} at {:?}", message, info.location()) - } else { - let message = info.payload().downcast_ref::<&str>(); - format!("Kernel panic {:?} at {:?}", message, info.location()) - }; - - unsafe { - host::rollup_core::write_debug(message.as_ptr(), message.len()); - } - - std::process::abort(); -} - -#[cfg(target_arch = "wasm32")] -#[no_mangle] -pub extern "C" fn kernel_run() { - std::panic::set_hook(Box::new(panic_hook)); - let mut context = crate::context::PVMContext::new(unsafe { host::wasm_host::WasmHost::new() }); - crate::kernel::kernel_run(&mut context); -} diff --git a/kernel/src/store.rs b/kernel/src/store.rs deleted file mode 100644 index bbac381..0000000 --- a/kernel/src/store.rs +++ /dev/null @@ -1,59 +0,0 @@ -use host::{ - path::RefPath, - rollup_core::RawRollupCore, - runtime::{load_value_sized, save_value_sized, Runtime, RuntimeError, ValueType}, -}; - -fn err_into(e: impl std::fmt::Debug) -> tezos_ctx::Error { - tezos_ctx::Error::Internal(tezos_ctx::error::InternalError::new( - tezos_ctx::error::InternalKind::Store, - format!("PVM context error: {:?}", e), - )) -} - -macro_rules! str_to_path { - ($key: expr) => { - RefPath::assert_from($key.as_bytes()) - }; -} - -pub fn store_has(host: &impl RawRollupCore, key: &str) -> tezos_ctx::Result { - match Runtime::store_has(host, &str_to_path!(key)) { - Ok(Some(ValueType::Value)) => Ok(true), - Err(err) => Err(err_into(err)), - _ => Ok(false), - } -} - -pub fn store_read(host: &impl RawRollupCore, key: &str) -> tezos_ctx::Result>> { - match load_value_sized(host, &str_to_path!(key)) { - Ok(val) => Ok(Some(val)), - Err(RuntimeError::PathNotFound) => Ok(None), - Err(err) => Err(err_into(err)), - } -} - -pub fn store_write( - host: &mut impl RawRollupCore, - key: &str, - val: Vec, -) -> tezos_ctx::Result<()> { - save_value_sized(host, &str_to_path!(key), val.as_slice()); // TODO(kernel): expose error instead of panic? - Ok(()) -} - -pub fn store_delete(host: &mut impl RawRollupCore, key: &str) -> tezos_ctx::Result<()> { - match Runtime::store_delete(host, &str_to_path!(key)) { - Ok(()) => Ok(()), - Err(RuntimeError::PathNotFound) => Ok(()), - Err(err) => Err(err_into(err)), - } -} - -pub fn store_move( - host: &mut impl RawRollupCore, - from_key: &str, - to_key: &str, -) -> tezos_ctx::Result<()> { - Runtime::store_move(host, &str_to_path!(from_key), &str_to_path!(to_key)).map_err(err_into) -} diff --git a/kernel_io/Cargo.toml b/kernel_io/Cargo.toml new file mode 100644 index 0000000..9599bfd --- /dev/null +++ b/kernel_io/Cargo.toml @@ -0,0 +1,22 @@ +# SPDX-FileCopyrightText: 2023 Baking Bad +# +# SPDX-License-Identifier: MIT + +[package] +name = "kernel_io" +version = "0.1.0" +edition = "2021" + +[lib] +crate-type = ["cdylib", "rlib"] + +[dependencies] +derive_more = "0.99" +layered_store = { path = "../layered_store", features = ["tezos"], default-features = false } +tezos-smart-rollup-host = { version = "0.2.0", features = ["proto-nairobi"], default-features = false } +tezos-smart-rollup-core = { version = "0.2.0", default-features = false } +tezos_core = { git = "https://github.com/baking-bad/tezos-rust-sdk", branch = "develop", package = "tezos-core", default-features = false } + +[dev-dependencies] +tezos-smart-rollup-host = { version = "0.2.0", features = ["proto-nairobi", "crypto"], default-features = false } +tezos-smart-rollup-mock = { version = "0.2.0", features = ["proto-nairobi"], default-features = false } diff --git a/kernel_io/README.md b/kernel_io/README.md new file mode 100644 index 0000000..d52ac57 --- /dev/null +++ b/kernel_io/README.md @@ -0,0 +1,12 @@ +# Kernel IO + +An utility crate providing generic abstraction over the raw rollup core. + +## Store + +`KernelStore` is an alias for `LayeredStore>`. +Kernel backend introduces another transactional layer: data is first stored under the `/tmp` root and then you can either discard changes by calling `clear` or save them with `persist`. A typical workflow is when you use `commit/rollback` for handling individual transactions, and `persist/clear` for batches. + +## Inbox + +Introduces `read_inbox()` method for dispatching both system and protocol-specific messages. You need to implement `PayloadType` trait in order to add protocol-specific parsing. You also need to provide a message prefix (typically raw rollup address) to identify messages related to your rollup in the shared inbox. diff --git a/kernel_io/src/error.rs b/kernel_io/src/error.rs new file mode 100644 index 0000000..498ea64 --- /dev/null +++ b/kernel_io/src/error.rs @@ -0,0 +1,91 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + +use derive_more::{Display, Error}; +use std::backtrace::Backtrace; + +#[derive(Debug)] +pub struct InternalError { + pub message: String, + pub backtrace: Backtrace, +} + +impl InternalError { + pub fn new(message: String) -> Self { + Self { + message, + backtrace: Backtrace::capture(), + } + } + + pub fn format(&self) -> String { + format!( + "Kernel IO error\n{}\nStacktrace:\n{}", + self.message, self.backtrace + ) + } +} + +impl std::fmt::Display for InternalError { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.write_fmt(format_args!( + "Kernel IO error, {}", + self.message.replace("\n", " ") + )) + } +} + +impl std::error::Error for InternalError { + fn description(&self) -> &str { + &self.message + } +} + +#[derive(Debug, Display, Error)] +pub enum Error { + Internal(InternalError), + #[display(fmt = "UnexpectedLevelInfoLength")] + UnexpectedLevelInfoLength { + length: usize, + }, +} + +pub type Result = std::result::Result; + +#[macro_export] +macro_rules! internal_error { + ($($arg:tt)*) => { + $crate::Error::Internal( + $crate::error::InternalError::new( format!($($arg)*)) + ) + }; +} + +macro_rules! impl_from_error { + ($inner_err_ty: ty) => { + impl From<$inner_err_ty> for Error { + fn from(error: $inner_err_ty) -> Self { + $crate::internal_error!("{:?}", error) + } + } + }; +} + +impl_from_error!(&str); +impl_from_error!(tezos_core::Error); +impl_from_error!(layered_store::Error); +impl_from_error!(tezos_smart_rollup_host::runtime::RuntimeError); + +impl Error { + pub fn format(&self) -> String { + match self { + Self::Internal(internal) => internal.format(), + err => format!("{:#?}", err), + } + } +} + +pub fn err_into(e: impl std::fmt::Debug) -> Error { + Error::Internal(InternalError::new(format!("{:?}", e))) +} diff --git a/kernel_io/src/inbox.rs b/kernel_io/src/inbox.rs new file mode 100644 index 0000000..2bb7e97 --- /dev/null +++ b/kernel_io/src/inbox.rs @@ -0,0 +1,124 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + +use tezos_core::types::encoded::{BlockHash, Encoded}; +use tezos_smart_rollup_core::{smart_rollup_core::ReadInputMessageInfo, SmartRollupCore}; +use tezos_smart_rollup_host::runtime::RuntimeError; + +use crate::error::{Error, Result}; + +#[derive(Debug, Clone)] +pub struct LevelInfo { + pub predecessor_timestamp: i64, + pub predecessor: BlockHash, +} + +impl TryFrom<&[u8]> for LevelInfo { + type Error = Error; + + fn try_from(value: &[u8]) -> Result { + if value.len() != 8 + 32 { + return Err(Error::UnexpectedLevelInfoLength { + length: value.len(), + }); + } + let predecessor_timestamp = i64::from_be_bytes([ + value[0], value[1], value[2], value[3], value[4], value[5], value[6], value[7], + ]); + let predecessor = BlockHash::from_bytes(&value[8..])?; + Ok(Self { + predecessor_timestamp, + predecessor, + }) + } +} + +pub trait PayloadType: Sized { + fn from_external_message(message: &[u8]) -> Result; +} + +pub enum InboxMessage { + BeginBlock(i32), + EndBlock(i32), + LevelInfo(LevelInfo), + Payload(Payload), + NoMoreData, + Foreign(i32), + Unknown(i32), +} + +#[derive(Clone, Debug)] +pub struct Message { + pub level: i32, + pub id: i32, + pub payload: Vec, +} + +impl AsRef<[u8]> for Message { + fn as_ref(&self) -> &[u8] { + self.payload.as_slice() + } +} + +pub fn read_input( + host: &mut Host, +) -> std::result::Result, RuntimeError> { + use core::mem::MaybeUninit; + use tezos_smart_rollup_core::MAX_INPUT_MESSAGE_SIZE; + + let mut buffer = Vec::with_capacity(MAX_INPUT_MESSAGE_SIZE); + + let mut message_info = MaybeUninit::::uninit(); + + let bytes_read = unsafe { + SmartRollupCore::read_input( + host, + message_info.as_mut_ptr(), + buffer.as_mut_ptr(), + MAX_INPUT_MESSAGE_SIZE, + ) + }; + + let bytes_read = match tezos_smart_rollup_host::Error::wrap(bytes_read) { + Ok(0) => return Ok(None), + Ok(size) => size, + Err(e) => return Err(RuntimeError::HostErr(e)), + }; + + let ReadInputMessageInfo { level, id } = unsafe { + buffer.set_len(bytes_read); + message_info.assume_init() + }; + + let input = Message { + level, + id, + payload: buffer, + }; + + Ok(Some(input)) +} + +pub fn read_inbox( + host: &mut Host, + prefix: &[u8], +) -> Result> { + match read_input(host) { + Ok(Some(message)) => match message.as_ref() { + b"\x00\x01" => Ok(InboxMessage::BeginBlock(message.level)), + b"\x00\x02" => Ok(InboxMessage::EndBlock(message.level)), + [b'\x00', b'\x03', info @ ..] => Ok(InboxMessage::LevelInfo(info.try_into()?)), + [b'\x01', data @ ..] => match data.strip_prefix(prefix) { + Some(payload) => { + let payload = Payload::from_external_message(payload)?; + Ok(InboxMessage::Payload(payload)) + } + None => Ok(InboxMessage::Foreign(message.id)), + }, + _ => Ok(InboxMessage::Unknown(message.id)), + }, + Ok(None) => Ok(InboxMessage::NoMoreData), + Err(err) => Err(err.into()), + } +} diff --git a/kernel_io/src/lib.rs b/kernel_io/src/lib.rs new file mode 100644 index 0000000..c0372e8 --- /dev/null +++ b/kernel_io/src/lib.rs @@ -0,0 +1,12 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + +pub mod error; +pub mod inbox; +pub mod store; + +pub use crate::error::{Error, Result}; + +pub use store::KernelBackendAsHost as KernelStoreAsHost; +pub type KernelStore<'rt, Host> = layered_store::LayeredStore>; diff --git a/kernel_io/src/store.rs b/kernel_io/src/store.rs new file mode 100644 index 0000000..98c18bd --- /dev/null +++ b/kernel_io/src/store.rs @@ -0,0 +1,212 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + +use layered_store::{error::err_into, LayeredStore, Result, StoreBackend}; +use std::collections::HashMap; +use tezos_smart_rollup_core::SmartRollupCore; +use tezos_smart_rollup_host::{ + path::{Path, RefPath}, + runtime::{Runtime, RuntimeError}, +}; + +const TMP_PREFIX: &str = "/tmp"; +const MAX_FILE_CHUNK_SIZE: usize = 2048; + +macro_rules! str_to_path { + ($key: expr) => { + RefPath::assert_from($key.as_bytes()) + }; +} + +pub struct KernelBackend<'rt, Host: SmartRollupCore> { + host: &'rt mut Host, + saved_state: HashMap, +} + +pub trait KernelBackendAsHost<'rt, Host: SmartRollupCore> { + fn attach(host: &'rt mut Host) -> Self; + fn as_host(&mut self) -> &mut Host; +} + +impl<'rt, Host: SmartRollupCore> KernelBackend<'rt, Host> { + pub fn new(host: &'rt mut Host) -> Self { + KernelBackend { + host, + saved_state: HashMap::new(), + } + } + + pub fn persist(&mut self) -> Result<()> { + for (key, exists) in self.saved_state.drain() { + if exists { + self.host + .store_move( + &str_to_path!([TMP_PREFIX, &key].concat().as_str()), + &str_to_path!(&key), + ) + .map_err(err_into)?; + } else { + self.host + .store_delete(&str_to_path!(&key)) + .map_err(err_into)?; + } + } + Ok(()) + } +} + +impl<'rt, Host: SmartRollupCore> KernelBackendAsHost<'rt, Host> + for LayeredStore> +{ + fn attach(host: &'rt mut Host) -> Self { + Self::new(KernelBackend::new(host)) + } + + fn as_host(&mut self) -> &mut Host { + self.as_mut().host + } +} + +// Runtime::store_read_all is available with [alloc] feature enabled, +// and it depends on the [crypto] feature we need to avoid +// because of the deps bloat and issues with building blst crate +fn store_read_all( + host: &impl Runtime, + path: &impl Path, +) -> std::result::Result, RuntimeError> { + let length = Runtime::store_value_size(host, path)?; + + let mut buffer: Vec = Vec::with_capacity(length); + let mut offset: usize = 0; + + while offset < length { + unsafe { + let buf_len = usize::min(offset + MAX_FILE_CHUNK_SIZE, length); + buffer.set_len(buf_len); + } + + let slice = &mut buffer[offset..]; + let chunk_size = host.store_read_slice(path, offset, slice)?; + + offset += chunk_size; + } + + if offset != length { + return Err(RuntimeError::DecodingError); + } + + Ok(buffer) +} + +impl<'rt, Host: SmartRollupCore> StoreBackend for KernelBackend<'rt, Host> { + fn default() -> Self { + unimplemented!() + } + + fn log(&self, msg: &str) { + Runtime::write_debug(self.host, msg) + } + + fn has(&self, key: &str) -> Result { + if let Some(has) = self.saved_state.get(key) { + return Ok(*has); + } + + match Runtime::store_has(self.host, &str_to_path!(&key)).map_err(err_into)? { + Some(_) => Ok(true), + None => Ok(false), + } + } + + fn read(&self, key: &str) -> Result>> { + let store_key = match self.saved_state.get(key) { + Some(false) => return Ok(None), + Some(true) => [TMP_PREFIX, &key].concat(), + None => key.into(), + }; + + match store_read_all(self.host, &str_to_path!(&store_key)) { + Ok(bytes) => Ok(Some(bytes)), + Err(RuntimeError::PathNotFound) => Ok(None), + Err(err) => Err(err_into(err)), + } + } + + fn write(&mut self, key: &str, val: &[u8]) -> Result<()> { + self.host + .store_write_all(&str_to_path!([TMP_PREFIX, key].concat().as_str()), val) + .map_err(err_into)?; + self.saved_state.insert(key.into(), true); + Ok(()) + } + + fn delete(&mut self, key: &str) -> Result<()> { + self.host + .store_delete(&str_to_path!([TMP_PREFIX, key].concat().as_str())) + .map_err(err_into)?; + self.saved_state.insert(key.into(), false); + Ok(()) + } + + fn clear(&mut self) { + self.saved_state.clear(); + + match self.host.store_delete(&str_to_path!(TMP_PREFIX)) { + Ok(()) => {} + Err(RuntimeError::PathNotFound) => {} + Err(err) => panic!("Failed to clear kernel storage: {}", err), + } + } +} + +#[cfg(test)] +mod test { + use super::*; + use crate::Result; + + use tezos_smart_rollup_mock::MockHost; + + #[test] + fn test_kernel_store() -> Result<()> { + let mut host = MockHost::default(); + let mut store: KernelBackend = KernelBackend::new(&mut host); + + assert!(!store.has("/test")?); + + store.write("/test", b"deadbeef")?; + store.persist()?; + store.clear(); + + assert!(store.has("/test")?); + assert_eq!(b"deadbeef".to_vec(), store.read("/test")?.unwrap()); + + Ok(()) + } + + #[test] + fn store_read_all_above_max_file_chunk_size() -> Result<()> { + // The value read is formed of 3 chunks, two of the max chunk value and + // the last one being less than the max size. + const PATH: RefPath<'static> = RefPath::assert_from("/a/simple/path".as_bytes()); + const VALUE_FIRST_CHUNK: [u8; MAX_FILE_CHUNK_SIZE] = [b'a'; MAX_FILE_CHUNK_SIZE]; + const VALUE_SECOND_CHUNK: [u8; MAX_FILE_CHUNK_SIZE] = [b'b'; MAX_FILE_CHUNK_SIZE]; + const VALUE_LAST_CHUNK: [u8; MAX_FILE_CHUNK_SIZE / 2] = [b'c'; MAX_FILE_CHUNK_SIZE / 2]; + + let mut host = MockHost::default(); + + Runtime::store_write(&mut host, &PATH, &VALUE_FIRST_CHUNK, 0)?; + Runtime::store_write(&mut host, &PATH, &VALUE_SECOND_CHUNK, MAX_FILE_CHUNK_SIZE)?; + Runtime::store_write(&mut host, &PATH, &VALUE_LAST_CHUNK, 2 * MAX_FILE_CHUNK_SIZE)?; + + let result = store_read_all(&host, &PATH)?; + + let mut expected: Vec = Vec::new(); + expected.extend_from_slice(&VALUE_FIRST_CHUNK); + expected.extend_from_slice(&VALUE_SECOND_CHUNK); + expected.extend_from_slice(&VALUE_LAST_CHUNK); + + assert_eq!(expected, result); + Ok(()) + } +} diff --git a/layered_store/Cargo.toml b/layered_store/Cargo.toml new file mode 100644 index 0000000..2c5224a --- /dev/null +++ b/layered_store/Cargo.toml @@ -0,0 +1,21 @@ +# SPDX-FileCopyrightText: 2023 Baking Bad +# +# SPDX-License-Identifier: MIT + +[package] +name = "layered_store" +version = "0.1.0" +edition = "2021" + +[lib] +crate-type = ["cdylib", "rlib"] + +[dependencies] +derive_more = "0.99" +tezos_core = { git = "https://github.com/baking-bad/tezos-rust-sdk", optional = true, branch = "develop", package = "tezos-core", default-features = false, features = ["ed25519"] } +tezos_michelson = { git = "https://github.com/baking-bad/tezos-rust-sdk", optional = true, branch = "develop", package = "tezos-michelson", default-features = false } + +[features] +default = [] +testing = ["tezos"] +tezos = ["dep:tezos_core", "dep:tezos_michelson"] \ No newline at end of file diff --git a/layered_store/README.md b/layered_store/README.md new file mode 100644 index 0000000..d93cf5a --- /dev/null +++ b/layered_store/README.md @@ -0,0 +1,24 @@ +# Layered Store +This is a generic type providing a transactional storage interface, i.e. you can do multiple read/write operations and then either commit or revert changes. +Layered store is implemented as a dynamically typed cache (via `Box`) plus a generic backend implementing `StoreBackend` trait. + +## About +This storage abstraction is intended for use in kernel protocol implementations as well as their dependent crates: this way one can enable interoperability/composability while keeping the implementation details within the according crates. This also resolves the "foreign traits / foreign types" problem which often occurs in a codebase split into many crates. + +### Store type +The cache value type is restricted by the `StoreType` trait requiring you to implement serialization/deserialization for every stored type. There are builtin implementations for some basic types (`i64`, `[u8; 32]`, to be extended) and also for several Tezos-specific types (enabled by `tezos` feature) provided by `tezos_core` and `tezos_michelson` crates. + +### Store backend +Layered store supports multiple backends, in order to add new one you need to implement the `StoreBackend` trait. There is a builtin `EphemeralBackend` (and `EphemeralStore` alias for `LayeredStore`) for testing and stateless modes. + +## Usage +When you need a persistent storage in your kernel protocol: +* Abstract all I/O via some "context" trait and use it everywhere in your protocol (`&mut impl YourContext`); +* Implement `LayeredStore` for `YourContext`; +* Implement `StoreType` for all the types you are storing (see implementation guide below); +* Use `EphemeralStore::default()` for testing. + +When implementing `StoreType` trait for your type you can use the following rule: +* If it's a not foreign type — implement the trait in your own crate; +* If it's a foreign type and there's no heavy dependencies (like `serde`), and this type is used frequently across many crates, add the implementation to the `layered_store` itself, possibly behind a feature switch if it's not a generic type; +* Otherwise use the "newtype" pattern and implement `StoreType` trait for the wrapped type `WrappedType(pub YourType)`. diff --git a/layered_store/src/ephemeral.rs b/layered_store/src/ephemeral.rs new file mode 100644 index 0000000..56dac39 --- /dev/null +++ b/layered_store/src/ephemeral.rs @@ -0,0 +1,102 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + +use std::collections::HashMap; + +use crate::{store::StoreBackend, LayeredStore, Result}; + +pub struct EphemeralBackend { + pub(super) state: HashMap>, +} + +impl EphemeralBackend { + pub fn new() -> Self { + Self { + state: HashMap::new(), + } + } + + pub fn spawn(&self) -> Self { + Self { + state: self.state.clone(), + } + } +} + +impl StoreBackend for EphemeralBackend { + fn default() -> Self { + Self::new() + } + + fn log(&self, msg: &str) { + eprintln!("[DEBUG] {}", msg); + } + + fn has(&self, key: &str) -> Result { + Ok(self.state.contains_key(key)) + } + + fn read(&self, key: &str) -> Result>> { + Ok(self.state.get(key).cloned()) + } + + fn write(&mut self, key: &str, val: &[u8]) -> Result<()> { + self.state.insert(key.into(), val.to_vec()); + Ok(()) + } + + fn delete(&mut self, key: &str) -> Result<()> { + self.state.remove(key); + Ok(()) + } + + fn clear(&mut self) {} +} + +pub trait EphemeralCopy { + fn spawn(&self) -> Self; +} + +impl EphemeralCopy for LayeredStore { + fn spawn(&self) -> Self { + Self::new(self.as_ref().spawn()) + } +} + +#[cfg(test)] +mod test { + use crate::{ephemeral::EphemeralBackend, LayeredStore, Result, StoreType}; + + #[derive(Clone, Debug)] + pub struct TestType { + pub value: i32, + } + + impl StoreType for TestType { + fn from_bytes(bytes: &[u8]) -> Result { + let value = i32::from_be_bytes(bytes.try_into().unwrap()); + Ok(Self { value }) + } + + fn to_bytes(&self) -> Result> { + Ok(self.value.to_be_bytes().to_vec()) + } + } + + #[test] + fn test_mock_store() -> Result<()> { + let mut store = LayeredStore::::default(); + + assert!(!store.has("/test".into())?); + + store.set("/test".into(), Some(TestType { value: 42 }))?; // cached + store.commit()?; // write to tmp folder + store.clear(); // clean up + + assert!(store.get::("/test".into())?.is_some()); // cached again + assert_eq!(42, store.get::("/test".into())?.unwrap().value); // served from the cache + + Ok(()) + } +} diff --git a/tezos_ctx/src/error.rs b/layered_store/src/error.rs similarity index 53% rename from tezos_ctx/src/error.rs rename to layered_store/src/error.rs index 3d3b726..997d111 100644 --- a/tezos_ctx/src/error.rs +++ b/layered_store/src/error.rs @@ -1,30 +1,19 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + use derive_more::{Display, Error}; use std::backtrace::Backtrace; -pub use serde_json_wasm::de::Error as DeserializationError; -pub use serde_json_wasm::ser::Error as SerializationError; -pub use tezos_core::Error as TezosCoreError; -pub use tezos_michelson::Error as TezosMichelsonError; -pub use tezos_rpc::Error as TezosRpcError; - -#[derive(Debug, Display)] -pub enum InternalKind { - Store, - Encoding, - TezosEncoding, -} - #[derive(Debug)] pub struct InternalError { - pub kind: InternalKind, pub message: String, pub backtrace: Backtrace, } impl InternalError { - pub fn new(kind: InternalKind, message: String) -> Self { + pub fn new(message: String) -> Self { Self { - kind, message, backtrace: Backtrace::capture(), } @@ -32,8 +21,8 @@ impl InternalError { pub fn format(&self) -> String { format!( - "{} error\n{}\nStacktrace:\n{}", - self.kind, self.message, self.backtrace + "Layered storage error\n{}\nStacktrace:\n{}", + self.message, self.backtrace ) } } @@ -41,8 +30,7 @@ impl InternalError { impl std::fmt::Display for InternalError { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { f.write_fmt(format_args!( - "{} error, {}", - self.kind, + "Layered storage error, {}", self.message.replace("\n", " ") )) } @@ -58,37 +46,32 @@ impl std::error::Error for InternalError { pub enum Error { Internal(InternalError), ContextUnstagedError, + DowncastingError, } pub type Result = std::result::Result; #[macro_export] macro_rules! internal_error { - ($kind: ident, $($arg:tt)*) => { + ($($arg:tt)*) => { $crate::Error::Internal( - $crate::error::InternalError::new( - $crate::error::InternalKind::$kind, - format!($($arg)*) - ) + $crate::error::InternalError::new( format!($($arg)*)) ) }; } macro_rules! impl_from_error { - ($inner_err_ty: ty, $kind: ident) => { + ($inner_err_ty: ty) => { impl From<$inner_err_ty> for Error { fn from(error: $inner_err_ty) -> Self { - $crate::internal_error!($kind, "{:?}", error) + $crate::internal_error!("{:?}", error) } } }; } -impl_from_error!(TezosCoreError, TezosEncoding); -impl_from_error!(TezosMichelsonError, TezosEncoding); -impl_from_error!(SerializationError, Encoding); -impl_from_error!(DeserializationError, Encoding); -impl_from_error!(&str, Encoding); +impl_from_error!(&str); +impl_from_error!(std::io::Error); impl Error { pub fn format(&self) -> String { @@ -98,3 +81,7 @@ impl Error { } } } + +pub fn err_into(e: impl std::fmt::Debug) -> Error { + Error::Internal(InternalError::new(format!("{:?}", e))) +} diff --git a/layered_store/src/lib.rs b/layered_store/src/lib.rs new file mode 100644 index 0000000..0318615 --- /dev/null +++ b/layered_store/src/lib.rs @@ -0,0 +1,15 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + +pub mod ephemeral; +pub mod error; +pub mod store; +pub mod types; + +pub use crate::{ + error::{Error, Result}, + store::{LayeredStore, StoreBackend, StoreType}, +}; + +pub type EphemeralStore = LayeredStore; diff --git a/layered_store/src/store.rs b/layered_store/src/store.rs new file mode 100644 index 0000000..25764b7 --- /dev/null +++ b/layered_store/src/store.rs @@ -0,0 +1,153 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + +use crate::{Error, Result}; +use std::{ + any::Any, + collections::{HashMap, HashSet}, +}; + +pub type DynStoreType = Box; +pub type StoreTypeSer = Box Result> + Send>; + +pub trait StoreType: Sized + Clone + Send + 'static { + fn from_bytes(bytes: &[u8]) -> Result; + fn to_bytes(&self) -> Result>; + + fn downcast_ref(value: &DynStoreType) -> Result<&Self> { + let res = value + .downcast_ref::() + .ok_or(Error::DowncastingError)?; + Ok(res) + } + + fn serialize(value: &DynStoreType) -> Result> { + let val = Self::downcast_ref(value)?; + val.to_bytes() + } +} + +pub trait StoreBackend { + fn default() -> Self; + fn log(&self, msg: &str); + fn has(&self, key: &str) -> Result; + fn read(&self, key: &str) -> Result>>; + fn write(&mut self, key: &str, val: &[u8]) -> Result<()>; + fn delete(&mut self, key: &str) -> Result<()>; + fn clear(&mut self); +} + +pub struct LayeredStore { + backend: Backend, + pending_state: HashMap>, + modified_keys: HashSet, +} + +impl LayeredStore { + pub fn new(backend: Backend) -> Self { + Self { + backend, + pending_state: HashMap::new(), + modified_keys: HashSet::new(), + } + } + + pub fn default() -> Self { + Self::new(Backend::default()) + } + + pub fn log(&self, msg: String) { + self.backend.log(&msg); + } + + pub fn has(&self, key: String) -> Result { + if self.pending_state.contains_key(&key) { + return Ok(true); + } + self.backend.has(&key) + } + + pub fn has_pending_changes(&self) -> bool { + !self.modified_keys.is_empty() + } + + pub fn pending_removed(&self, key: &String) -> bool { + match self.pending_state.get(key) { + Some(None) => true, + _ => false, + } + } + + pub fn get(&mut self, key: String) -> Result> { + match self.pending_state.get(&key) { + Some(Some((dyn_value, _))) => Ok(Some(T::downcast_ref(dyn_value)?.clone())), + Some(None) => Ok(None), + None => match self.backend.read(&key)? { + Some(bytes) => { + let value = T::from_bytes(&bytes)?; + self.pending_state + .insert(key, Some((Box::new(value.clone()), Box::new(T::serialize)))); + Ok(Some(value)) + } + None => Ok(None), + }, + } + } + + pub fn set(&mut self, key: String, val: Option) -> Result<()> { + match val { + Some(value) => self + .pending_state + .insert(key.clone(), Some((Box::new(value), Box::new(T::serialize)))), + None => self.pending_state.insert(key.clone(), None), + }; + self.modified_keys.insert(key); + Ok(()) + } + + pub fn commit(&mut self) -> Result<()> { + let modified_keys: Vec = self.modified_keys.drain().collect(); + for key in modified_keys { + let val = self + .pending_state + .get(&key) + .expect("Modified key must be in the pending state"); + + match val { + Some((dyn_value, ser)) => { + let bytes = ser(dyn_value)?; + self.backend.write(&key, bytes.as_slice())?; + } + None => { + self.backend.delete(&key)?; + } + }; + } + Ok(()) + } + + pub fn rollback(&mut self) { + for key in self.modified_keys.drain().into_iter() { + self.pending_state.remove(&key); + } + } + + pub fn clear(&mut self) { + self.pending_state.clear(); + self.modified_keys.clear(); + self.backend.clear(); + } +} + +impl AsMut for LayeredStore { + fn as_mut(&mut self) -> &mut Backend { + &mut self.backend + } +} + +impl AsRef for LayeredStore { + fn as_ref(&self) -> &Backend { + &self.backend + } +} diff --git a/layered_store/src/types/generic.rs b/layered_store/src/types/generic.rs new file mode 100644 index 0000000..5c94d82 --- /dev/null +++ b/layered_store/src/types/generic.rs @@ -0,0 +1,54 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + +use crate::{error::err_into, internal_error, Result, StoreType}; + +impl StoreType for i64 { + fn from_bytes(bytes: &[u8]) -> Result { + if bytes.len() == 8 { + Ok(i64::from_be_bytes([ + bytes[0], bytes[1], bytes[2], bytes[3], bytes[4], bytes[5], bytes[6], bytes[7], + ])) + } else { + Err(internal_error!("Invalid byte length")) + } + } + + fn to_bytes(&self) -> Result> { + Ok(self.to_be_bytes().to_vec()) + } +} + +impl StoreType for u64 { + fn from_bytes(bytes: &[u8]) -> Result { + if bytes.len() == 8 { + Ok(u64::from_be_bytes([ + bytes[0], bytes[1], bytes[2], bytes[3], bytes[4], bytes[5], bytes[6], bytes[7], + ])) + } else { + Err(internal_error!("Invalid byte length")) + } + } + + fn to_bytes(&self) -> Result> { + Ok(self.to_be_bytes().to_vec()) + } +} + +impl StoreType for [u8; 32] { + fn from_bytes(bytes: &[u8]) -> Result { + if bytes.len() == 32 { + Self::try_from(bytes).map_err(err_into) + } else { + Err(internal_error!( + "Invalid byte length: {} (expected 32)", + bytes.len() + )) + } + } + + fn to_bytes(&self) -> Result> { + Ok(self.to_vec()) + } +} diff --git a/layered_store/src/types/mod.rs b/layered_store/src/types/mod.rs new file mode 100644 index 0000000..724d074 --- /dev/null +++ b/layered_store/src/types/mod.rs @@ -0,0 +1,8 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + +pub mod generic; + +#[cfg(any(test, feature = "tezos"))] +pub mod tezos; diff --git a/layered_store/src/types/tezos.rs b/layered_store/src/types/tezos.rs new file mode 100644 index 0000000..c5953bb --- /dev/null +++ b/layered_store/src/types/tezos.rs @@ -0,0 +1,33 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + +use tezos_core::types::{ + encoded::{ContractAddress, Encoded, OperationHash, PublicKey}, + mutez::Mutez, + number::Nat, +}; +use tezos_michelson::micheline::Micheline; + +use crate::{internal_error, Result, StoreType}; + +macro_rules! impl_for_core { + ($cls: ident, $ty: ty) => { + impl StoreType for $ty { + fn from_bytes(bytes: &[u8]) -> Result { + $cls::from_bytes(bytes).map_err(|e| internal_error!("{:?}", e)) + } + + fn to_bytes(&self) -> Result> { + $cls::to_bytes(self).map_err(|e| internal_error!("{:?}", e)) + } + } + }; +} + +impl_for_core!(Encoded, PublicKey); +impl_for_core!(Encoded, OperationHash); +impl_for_core!(Encoded, ContractAddress); +impl_for_core!(Micheline, Micheline); +impl_for_core!(Mutez, Mutez); +impl_for_core!(Nat, Nat); diff --git a/michelson_derive/Cargo.toml b/michelson_derive/Cargo.toml index b729089..03eeda1 100644 --- a/michelson_derive/Cargo.toml +++ b/michelson_derive/Cargo.toml @@ -22,4 +22,4 @@ heck = "0.3" [dev-dependencies] trybuild = "1.0.42" michelson_interop = { path = "../michelson_interop" } -tezos_vm = { path = "../tezos_vm" } \ No newline at end of file +michelson_vm = { path = "../michelson_vm" } \ No newline at end of file diff --git a/michelson_derive/README.md b/michelson_derive/README.md index dd1e8e1..b883a20 100644 --- a/michelson_derive/README.md +++ b/michelson_derive/README.md @@ -21,10 +21,11 @@ Currently up to 6 fields, extend if you need more: #### Structs -Structs vave to have 0 (Unit) or at least 2 fields: +Structs are allowed to have no fields (Unit), single unnamed field, or two and more named/unnamed fields. - `struct S {}` -> `unit` - `struct S ()` -> `unit` +- `struct (A)` -> `a` - `struct (A, B)` -> `pair a b` - `struct { a: A, b: B }` -> `pair (a %a) (b %b)` (named tuple) @@ -32,7 +33,7 @@ Nested pairs are always expanded to right combs. #### Enums -Unit, newtype, and struct variants are supported (but only with >2 fields). +Unit, newtype (one and more unnamed fields), and struct variants are supported (two and more named fields). ```rust enum E { diff --git a/michelson_derive/tests/test.rs b/michelson_derive/tests/test.rs index b7f53f4..346c6b8 100644 --- a/michelson_derive/tests/test.rs +++ b/michelson_derive/tests/test.rs @@ -3,13 +3,13 @@ // SPDX-License-Identifier: MIT use michelson_interop::{hashmap, hashset, MichelsonInterop, Ticket}; +use michelson_vm::formatter::Formatter; use std::collections::{HashMap, HashSet}; use tezos_core::types::{ encoded::{Address, ChainId}, mutez::Mutez, number::Nat, }; -use tezos_vm::formatter::Formatter; #[derive(Debug, PartialEq, Eq, Hash, MichelsonInterop)] struct InnerType { diff --git a/tezos_vm/Cargo.toml b/michelson_vm/Cargo.toml similarity index 73% rename from tezos_vm/Cargo.toml rename to michelson_vm/Cargo.toml index fbfb8b5..b931509 100644 --- a/tezos_vm/Cargo.toml +++ b/michelson_vm/Cargo.toml @@ -1,5 +1,9 @@ +# SPDX-FileCopyrightText: 2023 Baking Bad +# +# SPDX-License-Identifier: MIT + [package] -name = "tezos_vm" +name = "michelson_vm" version = "0.1.0" edition = "2021" @@ -7,18 +11,18 @@ edition = "2021" crate-type = ["cdylib", "rlib"] [dependencies] -tezos_ctx = { path = "../tezos_ctx" } tezos_core = { git = "https://github.com/baking-bad/tezos-rust-sdk", branch = "develop", package = "tezos-core", default-features = false, features = ["ed25519"] } tezos_michelson = { git = "https://github.com/baking-bad/tezos-rust-sdk", branch = "develop", package = "tezos-michelson", default-features = false } serde-json-wasm = { git = "https://github.com/CosmWasm/serde-json-wasm", branch = "main" } -serde = { version = "1.0", features = ["derive"] } derive_more = "0.99" blake2 = "0.10" chrono = { version = "0.4", default-features = false } hex = "*" ibig = { version = "0.3", features = ["std", "num-traits"], default-features = false } once_cell = "*" +layered_store = { path = "../layered_store", features = ["tezos"], default-features = false } [features] -default = [] -trace = [] \ No newline at end of file +default = ["mock", "trace"] +trace = [] +mock = [] \ No newline at end of file diff --git a/michelson_vm/Makefile b/michelson_vm/Makefile new file mode 100644 index 0000000..6d3c7ae --- /dev/null +++ b/michelson_vm/Makefile @@ -0,0 +1,6 @@ +# SPDX-FileCopyrightText: 2023 Baking Bad +# +# SPDX-License-Identifier: MIT + +trace-e2e: + RUST_LIB_BACKTRACE=1 cargo test --jobs 1 --no-fail-fast --test e2e --features trace -- --nocapture --test-threads=1 $(NAME) diff --git a/tezos_vm/README.md b/michelson_vm/README.md similarity index 89% rename from tezos_vm/README.md rename to michelson_vm/README.md index 10ea649..8015d03 100644 --- a/tezos_vm/README.md +++ b/michelson_vm/README.md @@ -1,6 +1,6 @@ # Michelson VM -This is the MVP of a Michelson interpreter written in Rust. +This is a Michelson interpreter written in Rust. ## About The purpose of this crate is to provide a standalone, lightweight, and WASM-friendly implementation of the Michelson VM. The applications can vary including educational projects, developer tools, but the initial goal is to use it in a Tezos L2 solution. @@ -12,13 +12,8 @@ The purpose of this crate is to provide a standalone, lightweight, and WASM-frie - [ ] Tickets - [ ] Missing hash functions (`SHA3`, `KECCAK`) - [ ] Internal originations - -### Not implemented -Non-supported Michelson features: -* Sapling -* Global constants -* Chest -* Rollups :D +- [ ] Sapling +- [ ] Global constants? ### Known differences Although the intention is to be as close to the reference implementation as possible, there are still edge cases where Rust-based interpreter behaves differently. In particular: @@ -41,7 +36,7 @@ Both suites were converted to an intermediary Micheline representation: Michelson is a stack-based language, thus in order to run Michelson code you will need a stack: ```rust -use tezos_vm::stack::Stack; +use michelson_vm::Stack; let mut stack = Stack::new(); ``` @@ -53,7 +48,7 @@ Depending on the instruction kind, you might need some additional information: Operation scope is a struct you need to fill: ```rust -pub struct tezos_vm::interpreter::OperationScope { +pub struct michelson_vm::OperationScope { pub chain_id: ChainId, pub source: ImplicitAddress, pub sender: Address, @@ -70,7 +65,7 @@ pub struct tezos_vm::interpreter::OperationScope { InterpreterContext is a public trait you need to implement: ```rust -pub trait tezos_ctx::InterpreterContext { +pub trait michelson_vm::InterpreterContext { fn get_contract_type(&self, address: &ContractAddress) -> Result>; fn set_contract_type(&mut self, address: ContractAddress, value: Micheline) -> Result<()>; fn allocate_big_map(&mut self, owner: ContractAddress) -> Result; @@ -102,7 +97,7 @@ let code: Instruction = micheline.try_into()?; For all instructions supported a special `Interpreter` trait is implemented so that you can run it: ```rust -use tezos_vm::interpreter::Interpreter; +use michelson_vm::interpreter::Interpreter; code.execute(&mut stack, &scope, &mut context)?; ``` @@ -113,7 +108,7 @@ Another case is when you have a fully-fledged Michelson script with parameter/st Michelson script is also constructed out of a Micheline expression: ```rust -use tezos_vm::script::MichelsonScript; +use michelson_vm::MichelsonScript; let micheline: Micheline = serde_json_wasm::from_slice(data.as_slice())?; let script = MichelsonScript::try_from(micheline)?; @@ -126,7 +121,7 @@ let result = script.execute(&scope, &mut context)?; In the result you will get a structure containing new storage, BigMap diffs, and a list of internal operations: ```rust -pub struct tezos_vm::script::ScriptReturn { +pub struct michelson_vm::ScriptReturn { pub storage: Micheline, pub operations: Vec, pub big_map_diff: Vec, @@ -138,7 +133,7 @@ pub struct tezos_vm::script::ScriptReturn { It can be hard to spot a typechecking/parsing/runtime error when executing Michelson code, that's when tracer comes in handy! In order to enable traces add `trace` feature to the crate import in your Cargo file: ```toml -tezos_vm = { git = "https://github.com/baking-bad/tezos-on-tezos, package = "vm", features = ["trace"] } +michelson_vm = { git = "https://github.com/baking-bad/tezos-on-tezos", features = ["trace"] } ``` Or if you troubleshoot this crate, you can run any test with trace feature enabled and `RUST_LIB_BACKTRACE` flag set: @@ -150,4 +145,4 @@ You will see a beautiful output: ![trace](https://i.imgur.com/EGew4G1.png?) -Also note, that `vm::Error` has a special method `print` that will write to stdout all the error details plus backtrace if it exists. \ No newline at end of file +Also note, that `michelson_vm::Error` has a special method `print` that will write to stdout all the error details plus backtrace if it exists. \ No newline at end of file diff --git a/tezos_vm/src/entrypoints.rs b/michelson_vm/src/entrypoints.rs similarity index 96% rename from tezos_vm/src/entrypoints.rs rename to michelson_vm/src/entrypoints.rs index b107a75..8bd54a4 100644 --- a/tezos_vm/src/entrypoints.rs +++ b/michelson_vm/src/entrypoints.rs @@ -1,3 +1,7 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + use std::collections::HashMap; use tezos_michelson::micheline::{primitive_application::PrimitiveApplication, Micheline}; use tezos_michelson::michelson::types::Type; diff --git a/tezos_vm/src/error.rs b/michelson_vm/src/error.rs similarity index 78% rename from tezos_vm/src/error.rs rename to michelson_vm/src/error.rs index 095219a..f86b245 100644 --- a/tezos_vm/src/error.rs +++ b/michelson_vm/src/error.rs @@ -1,24 +1,20 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + use derive_more::{Display, Error}; use std::{backtrace::Backtrace, fmt::Display}; use tezos_michelson::micheline::Micheline; -#[derive(Debug, Display)] -pub enum InternalKind { - Parsing, - Typechecking, -} - #[derive(Debug)] pub struct InternalError { - pub kind: InternalKind, pub message: String, pub backtrace: Backtrace, } impl InternalError { - pub fn new(kind: InternalKind, message: String) -> Self { + pub fn new(message: String) -> Self { Self { - kind, message, backtrace: Backtrace::capture(), } @@ -26,8 +22,8 @@ impl InternalError { pub fn format(&self) -> String { format!( - "{} error\n{}\nStacktrace:\n{}", - self.kind, self.message, self.backtrace + "Interpreter error\n{}\nStacktrace:\n{}", + self.message, self.backtrace ) } } @@ -35,8 +31,7 @@ impl InternalError { impl Display for InternalError { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { f.write_fmt(format_args!( - "{} error, {}", - self.kind, + "Interpreter error, {}", self.message.replace("\n", " ") )) } @@ -99,12 +94,9 @@ pub type Result = std::result::Result; #[macro_export] macro_rules! internal_error { - ($kind: ident, $($arg:tt)*) => { + ($($arg:tt)*) => { $crate::Error::Internal( - $crate::error::InternalError::new( - $crate::error::InternalKind::$kind, - format!($($arg)*) - ) + $crate::error::InternalError::new(format!($($arg)*)) ) }; } @@ -113,7 +105,6 @@ macro_rules! internal_error { macro_rules! err_mismatch { ($expected: expr, $found: expr) => { Err($crate::internal_error!( - Typechecking, "Expected: {}\nFound: {}", $expected, $found @@ -124,16 +115,15 @@ macro_rules! err_mismatch { #[macro_export] macro_rules! err_unsupported { ($prim: expr) => { - Err($crate::internal_error!(Parsing, "`{}` unsupported", $prim)) + Err($crate::internal_error!("`{}` unsupported", $prim)) }; } -macro_rules! impl_parsing_error { +macro_rules! impl_error { ($inner_err_ty: ty) => { impl From<$inner_err_ty> for Error { fn from(error: $inner_err_ty) -> Self { $crate::internal_error!( - Parsing, "{} (caused by {})", error.to_string(), stringify!($inner_err_ty) @@ -143,12 +133,12 @@ macro_rules! impl_parsing_error { }; } -impl_parsing_error!(tezos_core::Error); -impl_parsing_error!(tezos_michelson::Error); -impl_parsing_error!(ibig::error::ParseError); -impl_parsing_error!(chrono::ParseError); -impl_parsing_error!(serde_json_wasm::de::Error); -impl_parsing_error!(tezos_ctx::Error); +impl_error!(tezos_core::Error); +impl_error!(tezos_michelson::Error); +impl_error!(ibig::error::ParseError); +impl_error!(chrono::ParseError); +impl_error!(serde_json_wasm::de::Error); +impl_error!(&str); impl From for Error { fn from(_: ibig::error::OutOfBoundsError) -> Self { @@ -171,3 +161,7 @@ impl Error { } } } + +pub fn err_into(e: impl std::fmt::Debug) -> Error { + Error::Internal(InternalError::new(format!("{:?}", e))) +} diff --git a/tezos_vm/src/formatter.rs b/michelson_vm/src/formatter.rs similarity index 98% rename from tezos_vm/src/formatter.rs rename to michelson_vm/src/formatter.rs index d90c3c2..f25c4c1 100644 --- a/tezos_vm/src/formatter.rs +++ b/michelson_vm/src/formatter.rs @@ -1,3 +1,7 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + use tezos_core::types::number::Nat; use tezos_michelson::michelson::{ annotations::Annotation, diff --git a/tezos_vm/src/instructions/algebraic.rs b/michelson_vm/src/instructions/algebraic.rs similarity index 96% rename from tezos_vm/src/instructions/algebraic.rs rename to michelson_vm/src/instructions/algebraic.rs index 9b1e770..11de26f 100644 --- a/tezos_vm/src/instructions/algebraic.rs +++ b/michelson_vm/src/instructions/algebraic.rs @@ -1,3 +1,7 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + use tezos_michelson::michelson::{ data::instructions::{Car, Cdr, Left, None, Pair, Right, Some, Unit, Unpair}, data::Nat, diff --git a/tezos_vm/src/instructions/collections.rs b/michelson_vm/src/instructions/collections.rs similarity index 98% rename from tezos_vm/src/instructions/collections.rs rename to michelson_vm/src/instructions/collections.rs index ea6cf2d..e2b6368 100644 --- a/tezos_vm/src/instructions/collections.rs +++ b/michelson_vm/src/instructions/collections.rs @@ -1,3 +1,7 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + use tezos_michelson::michelson::data::instructions::{ Cons, EmptyBigMap, EmptyMap, EmptySet, Get, GetAndUpdate, Mem, Nil, Update, }; diff --git a/tezos_vm/src/instructions/contract.rs b/michelson_vm/src/instructions/contract.rs similarity index 98% rename from tezos_vm/src/instructions/contract.rs rename to michelson_vm/src/instructions/contract.rs index ca1f97a..8fe2fc2 100644 --- a/tezos_vm/src/instructions/contract.rs +++ b/michelson_vm/src/instructions/contract.rs @@ -1,3 +1,7 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + use tezos_core::types::{encoded, encoded::Encoded}; use tezos_michelson::michelson::data::instructions::{ Address, Contract, ImplicitAccount, Self_, TransferTokens, diff --git a/tezos_vm/src/instructions/control.rs b/michelson_vm/src/instructions/control.rs similarity index 98% rename from tezos_vm/src/instructions/control.rs rename to michelson_vm/src/instructions/control.rs index 6a32aa3..14e0261 100644 --- a/tezos_vm/src/instructions/control.rs +++ b/michelson_vm/src/instructions/control.rs @@ -1,3 +1,7 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + use tezos_michelson::michelson::data::instructions::{ Cast, Dip, FailWith, If, IfCons, IfLeft, IfNone, Iter, Loop, LoopLeft, Map, Sequence, }; diff --git a/tezos_vm/src/instructions/crypto.rs b/michelson_vm/src/instructions/crypto.rs similarity index 95% rename from tezos_vm/src/instructions/crypto.rs rename to michelson_vm/src/instructions/crypto.rs index 84b40d1..ac9cc54 100644 --- a/tezos_vm/src/instructions/crypto.rs +++ b/michelson_vm/src/instructions/crypto.rs @@ -1,3 +1,7 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + use tezos_core::{ internal::crypto::blake2b, types::encoded::{Encoded, ImplicitAddress, PublicKey}, diff --git a/tezos_vm/src/instructions/generic.rs b/michelson_vm/src/instructions/generic.rs similarity index 98% rename from tezos_vm/src/instructions/generic.rs rename to michelson_vm/src/instructions/generic.rs index 18981f3..33c6bed 100644 --- a/tezos_vm/src/instructions/generic.rs +++ b/michelson_vm/src/instructions/generic.rs @@ -1,3 +1,7 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + use ibig::{IBig, UBig}; use tezos_michelson::micheline::Micheline; use tezos_michelson::michelson::data::instructions::{ diff --git a/tezos_vm/src/instructions/lambda.rs b/michelson_vm/src/instructions/lambda.rs similarity index 95% rename from tezos_vm/src/instructions/lambda.rs rename to michelson_vm/src/instructions/lambda.rs index bea89fa..8b959a7 100644 --- a/tezos_vm/src/instructions/lambda.rs +++ b/michelson_vm/src/instructions/lambda.rs @@ -1,3 +1,7 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + use tezos_michelson::michelson::data::instructions::{ pair, push, Apply, Exec, Instruction, Lambda, Sequence, }; diff --git a/tezos_vm/src/instructions/math.rs b/michelson_vm/src/instructions/math.rs similarity index 98% rename from tezos_vm/src/instructions/math.rs rename to michelson_vm/src/instructions/math.rs index 4d4592d..a2db6eb 100644 --- a/tezos_vm/src/instructions/math.rs +++ b/michelson_vm/src/instructions/math.rs @@ -1,3 +1,7 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + use tezos_michelson::michelson::data::instructions::{ Abs, Add, And, Ediv, Int, IsNat, Lsl, Lsr, Mul, Neg, Not, Or, Sub, SubMutez, Xor, }; diff --git a/tezos_vm/src/instructions/mod.rs b/michelson_vm/src/instructions/mod.rs similarity index 55% rename from tezos_vm/src/instructions/mod.rs rename to michelson_vm/src/instructions/mod.rs index b71a21b..4b03101 100644 --- a/tezos_vm/src/instructions/mod.rs +++ b/michelson_vm/src/instructions/mod.rs @@ -1,3 +1,7 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + mod algebraic; mod collections; mod contract; diff --git a/tezos_vm/src/instructions/scope.rs b/michelson_vm/src/instructions/scope.rs similarity index 95% rename from tezos_vm/src/instructions/scope.rs rename to michelson_vm/src/instructions/scope.rs index 8fb1cff..024f876 100644 --- a/tezos_vm/src/instructions/scope.rs +++ b/michelson_vm/src/instructions/scope.rs @@ -1,3 +1,7 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + use tezos_core::types::encoded; use tezos_michelson::michelson::data::instructions::{ Amount, Balance, ChainId, Level, Now, SelfAddress, Sender, Source, diff --git a/tezos_vm/src/instructions/stack.rs b/michelson_vm/src/instructions/stack.rs similarity index 94% rename from tezos_vm/src/instructions/stack.rs rename to michelson_vm/src/instructions/stack.rs index 339ff8b..51bb766 100644 --- a/tezos_vm/src/instructions/stack.rs +++ b/michelson_vm/src/instructions/stack.rs @@ -1,3 +1,7 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + use std::borrow::Borrow; use tezos_michelson::michelson::data::instructions::{Dig, Drop, Dug, Dup, Push, Swap}; diff --git a/tezos_vm/src/interpreter.rs b/michelson_vm/src/interpreter.rs similarity index 90% rename from tezos_vm/src/interpreter.rs rename to michelson_vm/src/interpreter.rs index c194dfc..a15c76c 100644 --- a/tezos_vm/src/interpreter.rs +++ b/michelson_vm/src/interpreter.rs @@ -1,12 +1,14 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + use tezos_core::types::{ - encoded::{Address, ChainId, ContractAddress, ImplicitAddress}, + encoded::{Address, ChainId, ContractAddress, ImplicitAddress, ScriptExprHash}, mutez::Mutez, }; use tezos_michelson::micheline::Micheline; use tezos_michelson::michelson::{data::Instruction, types::Type}; -pub use tezos_ctx::InterpreterContext; - use crate::{ err_unsupported, formatter::Formatter, @@ -16,6 +18,26 @@ use crate::{ Result, }; +pub trait InterpreterContext { + fn get_contract_type(&mut self, address: &ContractAddress) -> Result>; + fn set_contract_type(&mut self, address: ContractAddress, value: Micheline) -> Result<()>; + fn allocate_big_map(&mut self, owner: ContractAddress) -> Result; + // TODO: transfer_big_map + fn get_big_map_owner(&mut self, ptr: i64) -> Result>; + fn has_big_map_value(&mut self, ptr: i64, key_hash: &ScriptExprHash) -> Result; + fn get_big_map_value( + &mut self, + ptr: i64, + key_hash: &ScriptExprHash, + ) -> Result>; + fn set_big_map_value( + &mut self, + ptr: i64, + key_hash: ScriptExprHash, + value: Option, + ) -> Result<()>; +} + pub struct OperationScope { pub chain_id: ChainId, pub source: ImplicitAddress, diff --git a/tezos_vm/src/lib.rs b/michelson_vm/src/lib.rs similarity index 84% rename from tezos_vm/src/lib.rs rename to michelson_vm/src/lib.rs index 63ee7e2..0781938 100644 --- a/tezos_vm/src/lib.rs +++ b/michelson_vm/src/lib.rs @@ -1,3 +1,7 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + pub mod entrypoints; pub mod error; pub mod formatter; @@ -5,11 +9,20 @@ pub mod instructions; pub mod interpreter; pub mod script; pub mod stack; +pub mod store; pub mod tracer; pub mod typechecker; pub mod types; -pub use error::{Error, Result}; +#[cfg(any(test, feature = "mock"))] +pub mod mock; + +pub use { + error::{Error, Result}, + interpreter::{InterpreterContext, OperationScope}, + script::{MichelsonScript, ScriptReturn}, + stack::Stack, +}; #[cfg(feature = "trace")] pub use tracer::{trace_err, trace_init, trace_into, trace_log, trace_ret, trace_stack}; diff --git a/tezos_vm/tests/runner/mock.rs b/michelson_vm/src/mock.rs similarity index 87% rename from tezos_vm/tests/runner/mock.rs rename to michelson_vm/src/mock.rs index 9e24686..976079a 100644 --- a/tezos_vm/tests/runner/mock.rs +++ b/michelson_vm/src/mock.rs @@ -1,3 +1,7 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + use std::collections::HashMap; use tezos_core::types::{ encoded::{self, Encoded}, @@ -5,9 +9,10 @@ use tezos_core::types::{ }; use tezos_michelson::micheline::{primitive_application, Micheline}; use tezos_michelson::michelson::types::unit; -use tezos_vm::{ + +use crate::{ interpreter::{InterpreterContext, OperationScope}, - trace_log, + trace_log, Result, }; pub const CHAIN_ID: &str = "NetXP2FfcNxFANL"; @@ -30,6 +35,7 @@ pub fn default_scope() -> OperationScope { } } +// TODO: use layered_store::EphemeralStore instead pub struct MockContext { pub big_map_counter: i64, pub big_maps: HashMap, @@ -70,7 +76,7 @@ impl InterpreterContext for MockContext { &mut self, address: encoded::ContractAddress, value: Micheline, - ) -> tezos_ctx::Result<()> { + ) -> Result<()> { let key = address.into_string(); self.contracts.insert(key, value); Ok(()) @@ -79,7 +85,7 @@ impl InterpreterContext for MockContext { fn get_contract_type( &mut self, address: &encoded::ContractAddress, - ) -> tezos_ctx::Result> { + ) -> Result> { let key = address.into_string(); match self.contracts.get(&key) { Some(ty) => Ok(Some(ty.clone())), @@ -87,7 +93,7 @@ impl InterpreterContext for MockContext { } } - fn allocate_big_map(&mut self, owner: encoded::ContractAddress) -> tezos_ctx::Result { + fn allocate_big_map(&mut self, owner: encoded::ContractAddress) -> Result { let counter = self.big_map_counter; self.big_map_counter += 1; trace_log!("Alloc", counter); @@ -95,21 +101,14 @@ impl InterpreterContext for MockContext { Ok(counter) } - fn get_big_map_owner( - &mut self, - ptr: i64, - ) -> tezos_ctx::Result> { + fn get_big_map_owner(&mut self, ptr: i64) -> Result> { match self.big_maps.get(&ptr) { Some(owner) => Ok(Some(owner.clone())), None => Ok(None), } } - fn has_big_map_value( - &mut self, - ptr: i64, - key_hash: &encoded::ScriptExprHash, - ) -> tezos_ctx::Result { + fn has_big_map_value(&mut self, ptr: i64, key_hash: &encoded::ScriptExprHash) -> Result { trace_log!("Has", key_hash.value()); Ok(self .big_map_values @@ -120,7 +119,7 @@ impl InterpreterContext for MockContext { &mut self, ptr: i64, key_hash: &encoded::ScriptExprHash, - ) -> tezos_ctx::Result> { + ) -> Result> { trace_log!("Get", key_hash.value()); Ok(self .big_map_values @@ -133,7 +132,7 @@ impl InterpreterContext for MockContext { ptr: i64, key_hash: encoded::ScriptExprHash, value: Option, - ) -> tezos_ctx::Result<()> { + ) -> Result<()> { trace_log!("Update", key_hash.value()); let k = (ptr, key_hash.into_string()); match value { diff --git a/tezos_vm/src/script.rs b/michelson_vm/src/script.rs similarity index 94% rename from tezos_vm/src/script.rs rename to michelson_vm/src/script.rs index 60ac119..33bcd24 100644 --- a/tezos_vm/src/script.rs +++ b/michelson_vm/src/script.rs @@ -1,3 +1,7 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + use tezos_michelson::micheline::{primitive_application, sequence, sequence::Sequence, Micheline}; use tezos_michelson::michelson::{ data::Instruction, @@ -192,11 +196,9 @@ impl TryFrom for MichelsonScript { // - check if all types in storage are storable // - check if all types in parameter are passable Ok(Self { - parameter_type: param_ty - .ok_or(internal_error!(Parsing, "Missing section:\tparameter"))?, - storage_type: storage_ty - .ok_or(internal_error!(Parsing, "Missing section:\tstorage"))?, - code: code_ty.ok_or(internal_error!(Parsing, "Missing section:\tcode"))?, + parameter_type: param_ty.ok_or(internal_error!("Missing section:\tparameter"))?, + storage_type: storage_ty.ok_or(internal_error!("Missing section:\tstorage"))?, + code: code_ty.ok_or(internal_error!("Missing section:\tcode"))?, }) } } diff --git a/tezos_vm/src/stack.rs b/michelson_vm/src/stack.rs similarity index 96% rename from tezos_vm/src/stack.rs rename to michelson_vm/src/stack.rs index 6ae6d49..0527baf 100644 --- a/tezos_vm/src/stack.rs +++ b/michelson_vm/src/stack.rs @@ -1,3 +1,7 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + use std::collections::VecDeque; use crate::{trace_log, trace_stack, types::StackItem, Error, Result}; diff --git a/tezos_ctx/src/context/interpreter.rs b/michelson_vm/src/store.rs similarity index 53% rename from tezos_ctx/src/context/interpreter.rs rename to michelson_vm/src/store.rs index 71dfeb9..92cb197 100644 --- a/tezos_ctx/src/context/interpreter.rs +++ b/michelson_vm/src/store.rs @@ -1,36 +1,46 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + +use layered_store::{LayeredStore, StoreBackend}; use tezos_core::types::encoded::{ContractAddress, Encoded, ScriptExprHash}; use tezos_michelson::micheline::Micheline; -use crate::{context_get_opt, GenericContext, InterpreterContext, Result}; +use crate::{error::err_into, InterpreterContext, Result}; -impl InterpreterContext for T { +impl InterpreterContext for LayeredStore { fn set_contract_type(&mut self, address: ContractAddress, value: Micheline) -> Result<()> { self.set( format!("/context/contracts/{}/entrypoints", address.value()), - Some(value.into()), + Some(value), ) + .map_err(err_into) } fn get_contract_type(&mut self, address: &ContractAddress) -> Result> { - context_get_opt!(self, "/context/contracts/{}/entrypoints", address.value()) + self.get(format!( + "/context/contracts/{}/entrypoints", + address.value() + )) + .map_err(err_into) } fn allocate_big_map(&mut self, owner: ContractAddress) -> Result { - let ptr = match self.get("/context/ptr".into()) { - Ok(Some(val)) => i64::try_from(val)? + 1, + let ptr = match self.get::("/context/ptr".into()) { + Ok(Some(val)) => val + 1, Ok(None) => 0i64, - Err(err) => return Err(err), + Err(err) => return Err(err_into(err)), }; - self.set("/context/ptr".into(), Some(ptr.into()))?; - self.set( - format!("/context/bigmaps/{}/owner", ptr), - Some(owner.into()), - )?; + self.set("/context/ptr".into(), Some(ptr)) + .map_err(err_into)?; + self.set(format!("/context/bigmaps/{}/owner", ptr), Some(owner)) + .map_err(err_into)?; Ok(ptr) } fn get_big_map_owner(&mut self, ptr: i64) -> Result> { - context_get_opt!(self, "/context/bigmaps/{}/owner", ptr) + self.get(format!("/context/bigmaps/{}/owner", ptr)) + .map_err(err_into) } fn has_big_map_value(&mut self, ptr: i64, key_hash: &ScriptExprHash) -> Result { @@ -39,6 +49,7 @@ impl InterpreterContext for T { ptr, key_hash.value() )) + .map_err(err_into) } fn get_big_map_value( @@ -46,7 +57,12 @@ impl InterpreterContext for T { ptr: i64, key_hash: &ScriptExprHash, ) -> Result> { - context_get_opt!(self, "/context/bigmaps/{}/values/{}", ptr, key_hash.value()) + self.get(format!( + "/context/bigmaps/{}/values/{}", + ptr, + key_hash.value() + )) + .map_err(err_into) } fn set_big_map_value( @@ -57,7 +73,8 @@ impl InterpreterContext for T { ) -> Result<()> { self.set( format!("/context/bigmaps/{}/values/{}", ptr, key_hash.value()), - value.map(|v| v.into()), + value, ) + .map_err(err_into) } } diff --git a/tezos_vm/src/tracer.rs b/michelson_vm/src/tracer.rs similarity index 96% rename from tezos_vm/src/tracer.rs rename to michelson_vm/src/tracer.rs index 4cb7f26..0c6e21d 100644 --- a/tezos_vm/src/tracer.rs +++ b/michelson_vm/src/tracer.rs @@ -1,3 +1,7 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + use once_cell::sync::Lazy; use tezos_michelson::michelson::data::Instruction; diff --git a/tezos_vm/src/typechecker.rs b/michelson_vm/src/typechecker.rs similarity index 99% rename from tezos_vm/src/typechecker.rs rename to michelson_vm/src/typechecker.rs index e234248..d7c5311 100644 --- a/tezos_vm/src/typechecker.rs +++ b/michelson_vm/src/typechecker.rs @@ -1,3 +1,7 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + use tezos_michelson::micheline::Micheline; use tezos_michelson::michelson::{ data::Data, diff --git a/tezos_vm/src/types.rs b/michelson_vm/src/types.rs similarity index 97% rename from tezos_vm/src/types.rs rename to michelson_vm/src/types.rs index 7bc90e3..03d58aa 100644 --- a/tezos_vm/src/types.rs +++ b/michelson_vm/src/types.rs @@ -1,3 +1,7 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + pub mod big_map; pub mod contract; pub mod core; diff --git a/tezos_vm/src/types/big_map.rs b/michelson_vm/src/types/big_map.rs similarity index 99% rename from tezos_vm/src/types/big_map.rs rename to michelson_vm/src/types/big_map.rs index dd691d2..d62d2fd 100644 --- a/tezos_vm/src/types/big_map.rs +++ b/michelson_vm/src/types/big_map.rs @@ -1,3 +1,7 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + use std::collections::BTreeMap; use std::fmt::Display; use tezos_core::{ diff --git a/tezos_vm/src/types/contract.rs b/michelson_vm/src/types/contract.rs similarity index 94% rename from tezos_vm/src/types/contract.rs rename to michelson_vm/src/types/contract.rs index 002d915..342b17d 100644 --- a/tezos_vm/src/types/contract.rs +++ b/michelson_vm/src/types/contract.rs @@ -1,3 +1,7 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + use std::fmt::Display; use tezos_core::types::encoded::{Address, Encoded}; use tezos_michelson::michelson::{data, data::Data, types, types::Type}; diff --git a/tezos_vm/src/types/core.rs b/michelson_vm/src/types/core.rs similarity index 97% rename from tezos_vm/src/types/core.rs rename to michelson_vm/src/types/core.rs index 0fb1018..1e7a9b1 100644 --- a/tezos_vm/src/types/core.rs +++ b/michelson_vm/src/types/core.rs @@ -1,3 +1,7 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + use hex; use std::fmt::Display; use std::ops::{Add, BitAnd, BitOr, BitXor, Not}; diff --git a/tezos_vm/src/types/encoded.rs b/michelson_vm/src/types/encoded.rs similarity index 97% rename from tezos_vm/src/types/encoded.rs rename to michelson_vm/src/types/encoded.rs index 2a1d4c1..94a2bc9 100644 --- a/tezos_vm/src/types/encoded.rs +++ b/michelson_vm/src/types/encoded.rs @@ -1,3 +1,7 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + use std::fmt::Display; use tezos_core::types::encoded::{ Address, ChainId, Encoded, ImplicitAddress, PublicKey, Signature, diff --git a/tezos_vm/src/types/int.rs b/michelson_vm/src/types/int.rs similarity index 96% rename from tezos_vm/src/types/int.rs rename to michelson_vm/src/types/int.rs index 8450d01..69dd5f6 100644 --- a/tezos_vm/src/types/int.rs +++ b/michelson_vm/src/types/int.rs @@ -1,3 +1,7 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + use ibig::ops::{Abs, UnsignedAbs}; use ibig::{IBig, UBig}; use std::fmt::Display; diff --git a/tezos_vm/src/types/lambda.rs b/michelson_vm/src/types/lambda.rs similarity index 95% rename from tezos_vm/src/types/lambda.rs rename to michelson_vm/src/types/lambda.rs index d42ebc7..b88f304 100644 --- a/tezos_vm/src/types/lambda.rs +++ b/michelson_vm/src/types/lambda.rs @@ -1,3 +1,7 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + use std::fmt::Display; use tezos_michelson::michelson::{ data::{Data, Instruction}, diff --git a/tezos_vm/src/types/list.rs b/michelson_vm/src/types/list.rs similarity index 96% rename from tezos_vm/src/types/list.rs rename to michelson_vm/src/types/list.rs index b954388..3747a70 100644 --- a/tezos_vm/src/types/list.rs +++ b/michelson_vm/src/types/list.rs @@ -1,3 +1,7 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + use std::fmt::Display; use tezos_michelson::michelson::{data, data::Data, types, types::Type}; diff --git a/tezos_vm/src/types/map.rs b/michelson_vm/src/types/map.rs similarity index 98% rename from tezos_vm/src/types/map.rs rename to michelson_vm/src/types/map.rs index 2fa3bda..1644c50 100644 --- a/tezos_vm/src/types/map.rs +++ b/michelson_vm/src/types/map.rs @@ -1,3 +1,7 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + use std::fmt::Display; use tezos_michelson::michelson::{ data, diff --git a/tezos_vm/src/types/mutez.rs b/michelson_vm/src/types/mutez.rs similarity index 97% rename from tezos_vm/src/types/mutez.rs rename to michelson_vm/src/types/mutez.rs index ee3aa8b..d4818dd 100644 --- a/tezos_vm/src/types/mutez.rs +++ b/michelson_vm/src/types/mutez.rs @@ -1,3 +1,7 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + use ibig::ops::Abs; use ibig::{IBig, UBig}; use std::fmt::Display; diff --git a/tezos_vm/src/types/nat.rs b/michelson_vm/src/types/nat.rs similarity index 97% rename from tezos_vm/src/types/nat.rs rename to michelson_vm/src/types/nat.rs index ccea707..e919954 100644 --- a/tezos_vm/src/types/nat.rs +++ b/michelson_vm/src/types/nat.rs @@ -1,3 +1,7 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + use ibig::{IBig, UBig}; use std::fmt::Display; use std::ops::{Add, BitAnd, BitOr, BitXor, Div, Mul, Neg, Not, Shl, Shr, Sub}; diff --git a/tezos_vm/src/types/operation.rs b/michelson_vm/src/types/operation.rs similarity index 88% rename from tezos_vm/src/types/operation.rs rename to michelson_vm/src/types/operation.rs index 411fcf2..022de68 100644 --- a/tezos_vm/src/types/operation.rs +++ b/michelson_vm/src/types/operation.rs @@ -1,3 +1,7 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + use std::fmt::Display; use crate::types::{BigMapDiff, InternalContent, OperationItem}; diff --git a/tezos_vm/src/types/option.rs b/michelson_vm/src/types/option.rs similarity index 96% rename from tezos_vm/src/types/option.rs rename to michelson_vm/src/types/option.rs index fdef6b1..c467c46 100644 --- a/tezos_vm/src/types/option.rs +++ b/michelson_vm/src/types/option.rs @@ -1,3 +1,7 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + use std::fmt::Display; use tezos_michelson::michelson::{data, data::Data, types, types::Type}; diff --git a/tezos_vm/src/types/or.rs b/michelson_vm/src/types/or.rs similarity index 96% rename from tezos_vm/src/types/or.rs rename to michelson_vm/src/types/or.rs index 4ee86bc..7e6b409 100644 --- a/tezos_vm/src/types/or.rs +++ b/michelson_vm/src/types/or.rs @@ -1,3 +1,7 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + use std::fmt::Display; use tezos_michelson::michelson::{data, data::Data, types, types::Type}; diff --git a/tezos_vm/src/types/pair.rs b/michelson_vm/src/types/pair.rs similarity index 97% rename from tezos_vm/src/types/pair.rs rename to michelson_vm/src/types/pair.rs index cfeca4b..2899a29 100644 --- a/tezos_vm/src/types/pair.rs +++ b/michelson_vm/src/types/pair.rs @@ -1,3 +1,7 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + use std::fmt::Display; use tezos_michelson::michelson::{data, data::Data, types, types::Type}; diff --git a/tezos_vm/src/types/set.rs b/michelson_vm/src/types/set.rs similarity index 96% rename from tezos_vm/src/types/set.rs rename to michelson_vm/src/types/set.rs index 0b466f6..8b9043f 100644 --- a/tezos_vm/src/types/set.rs +++ b/michelson_vm/src/types/set.rs @@ -1,3 +1,7 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + use std::fmt::Display; use tezos_michelson::michelson::{data::Data, types, types::Type}; diff --git a/tezos_vm/src/types/timestamp.rs b/michelson_vm/src/types/timestamp.rs similarity index 95% rename from tezos_vm/src/types/timestamp.rs rename to michelson_vm/src/types/timestamp.rs index 0d48de4..253287c 100644 --- a/tezos_vm/src/types/timestamp.rs +++ b/michelson_vm/src/types/timestamp.rs @@ -1,3 +1,7 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + use chrono::{DateTime, NaiveDateTime, SecondsFormat, Utc}; use ibig::IBig; use std::fmt::Display; diff --git a/tezos_vm/tests/data/e2e/e2e_abs_00.json b/michelson_vm/tests/data/e2e/e2e_abs_00.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_abs_00.json rename to michelson_vm/tests/data/e2e/e2e_abs_00.json diff --git a/tezos_vm/tests/data/e2e/e2e_abs_01.json b/michelson_vm/tests/data/e2e/e2e_abs_01.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_abs_01.json rename to michelson_vm/tests/data/e2e/e2e_abs_01.json diff --git a/tezos_vm/tests/data/e2e/e2e_abs_02.json b/michelson_vm/tests/data/e2e/e2e_abs_02.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_abs_02.json rename to michelson_vm/tests/data/e2e/e2e_abs_02.json diff --git a/tezos_vm/tests/data/e2e/e2e_add_00.json b/michelson_vm/tests/data/e2e/e2e_add_00.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_add_00.json rename to michelson_vm/tests/data/e2e/e2e_add_00.json diff --git a/tezos_vm/tests/data/e2e/e2e_add_delta_timestamp_00.json b/michelson_vm/tests/data/e2e/e2e_add_delta_timestamp_00.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_add_delta_timestamp_00.json rename to michelson_vm/tests/data/e2e/e2e_add_delta_timestamp_00.json diff --git a/tezos_vm/tests/data/e2e/e2e_add_delta_timestamp_01.json b/michelson_vm/tests/data/e2e/e2e_add_delta_timestamp_01.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_add_delta_timestamp_01.json rename to michelson_vm/tests/data/e2e/e2e_add_delta_timestamp_01.json diff --git a/tezos_vm/tests/data/e2e/e2e_add_delta_timestamp_02.json b/michelson_vm/tests/data/e2e/e2e_add_delta_timestamp_02.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_add_delta_timestamp_02.json rename to michelson_vm/tests/data/e2e/e2e_add_delta_timestamp_02.json diff --git a/tezos_vm/tests/data/e2e/e2e_add_timestamp_delta_00.json b/michelson_vm/tests/data/e2e/e2e_add_timestamp_delta_00.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_add_timestamp_delta_00.json rename to michelson_vm/tests/data/e2e/e2e_add_timestamp_delta_00.json diff --git a/tezos_vm/tests/data/e2e/e2e_add_timestamp_delta_01.json b/michelson_vm/tests/data/e2e/e2e_add_timestamp_delta_01.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_add_timestamp_delta_01.json rename to michelson_vm/tests/data/e2e/e2e_add_timestamp_delta_01.json diff --git a/tezos_vm/tests/data/e2e/e2e_add_timestamp_delta_02.json b/michelson_vm/tests/data/e2e/e2e_add_timestamp_delta_02.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_add_timestamp_delta_02.json rename to michelson_vm/tests/data/e2e/e2e_add_timestamp_delta_02.json diff --git a/tezos_vm/tests/data/e2e/e2e_address_00.json b/michelson_vm/tests/data/e2e/e2e_address_00.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_address_00.json rename to michelson_vm/tests/data/e2e/e2e_address_00.json diff --git a/tezos_vm/tests/data/e2e/e2e_and_00.json b/michelson_vm/tests/data/e2e/e2e_and_00.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_and_00.json rename to michelson_vm/tests/data/e2e/e2e_and_00.json diff --git a/tezos_vm/tests/data/e2e/e2e_and_01.json b/michelson_vm/tests/data/e2e/e2e_and_01.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_and_01.json rename to michelson_vm/tests/data/e2e/e2e_and_01.json diff --git a/tezos_vm/tests/data/e2e/e2e_and_02.json b/michelson_vm/tests/data/e2e/e2e_and_02.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_and_02.json rename to michelson_vm/tests/data/e2e/e2e_and_02.json diff --git a/tezos_vm/tests/data/e2e/e2e_and_03.json b/michelson_vm/tests/data/e2e/e2e_and_03.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_and_03.json rename to michelson_vm/tests/data/e2e/e2e_and_03.json diff --git a/tezos_vm/tests/data/e2e/e2e_and_binary_00.json b/michelson_vm/tests/data/e2e/e2e_and_binary_00.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_and_binary_00.json rename to michelson_vm/tests/data/e2e/e2e_and_binary_00.json diff --git a/tezos_vm/tests/data/e2e/e2e_and_logical_1_00.json b/michelson_vm/tests/data/e2e/e2e_and_logical_1_00.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_and_logical_1_00.json rename to michelson_vm/tests/data/e2e/e2e_and_logical_1_00.json diff --git a/tezos_vm/tests/data/e2e/e2e_and_logical_1_01.json b/michelson_vm/tests/data/e2e/e2e_and_logical_1_01.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_and_logical_1_01.json rename to michelson_vm/tests/data/e2e/e2e_and_logical_1_01.json diff --git a/tezos_vm/tests/data/e2e/e2e_and_logical_1_02.json b/michelson_vm/tests/data/e2e/e2e_and_logical_1_02.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_and_logical_1_02.json rename to michelson_vm/tests/data/e2e/e2e_and_logical_1_02.json diff --git a/tezos_vm/tests/data/e2e/e2e_and_logical_1_03.json b/michelson_vm/tests/data/e2e/e2e_and_logical_1_03.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_and_logical_1_03.json rename to michelson_vm/tests/data/e2e/e2e_and_logical_1_03.json diff --git a/tezos_vm/tests/data/e2e/e2e_balance_00.json b/michelson_vm/tests/data/e2e/e2e_balance_00.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_balance_00.json rename to michelson_vm/tests/data/e2e/e2e_balance_00.json diff --git a/tezos_vm/tests/data/e2e/e2e_big_map_mem_nat_00.json b/michelson_vm/tests/data/e2e/e2e_big_map_mem_nat_00.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_big_map_mem_nat_00.json rename to michelson_vm/tests/data/e2e/e2e_big_map_mem_nat_00.json diff --git a/tezos_vm/tests/data/e2e/e2e_big_map_mem_nat_01.json b/michelson_vm/tests/data/e2e/e2e_big_map_mem_nat_01.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_big_map_mem_nat_01.json rename to michelson_vm/tests/data/e2e/e2e_big_map_mem_nat_01.json diff --git a/tezos_vm/tests/data/e2e/e2e_big_map_mem_nat_02.json b/michelson_vm/tests/data/e2e/e2e_big_map_mem_nat_02.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_big_map_mem_nat_02.json rename to michelson_vm/tests/data/e2e/e2e_big_map_mem_nat_02.json diff --git a/tezos_vm/tests/data/e2e/e2e_big_map_mem_nat_03.json b/michelson_vm/tests/data/e2e/e2e_big_map_mem_nat_03.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_big_map_mem_nat_03.json rename to michelson_vm/tests/data/e2e/e2e_big_map_mem_nat_03.json diff --git a/tezos_vm/tests/data/e2e/e2e_big_map_mem_nat_04.json b/michelson_vm/tests/data/e2e/e2e_big_map_mem_nat_04.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_big_map_mem_nat_04.json rename to michelson_vm/tests/data/e2e/e2e_big_map_mem_nat_04.json diff --git a/tezos_vm/tests/data/e2e/e2e_big_map_mem_nat_05.json b/michelson_vm/tests/data/e2e/e2e_big_map_mem_nat_05.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_big_map_mem_nat_05.json rename to michelson_vm/tests/data/e2e/e2e_big_map_mem_nat_05.json diff --git a/tezos_vm/tests/data/e2e/e2e_big_map_mem_nat_06.json b/michelson_vm/tests/data/e2e/e2e_big_map_mem_nat_06.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_big_map_mem_nat_06.json rename to michelson_vm/tests/data/e2e/e2e_big_map_mem_nat_06.json diff --git a/tezos_vm/tests/data/e2e/e2e_big_map_mem_nat_07.json b/michelson_vm/tests/data/e2e/e2e_big_map_mem_nat_07.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_big_map_mem_nat_07.json rename to michelson_vm/tests/data/e2e/e2e_big_map_mem_nat_07.json diff --git a/tezos_vm/tests/data/e2e/e2e_big_map_mem_nat_08.json b/michelson_vm/tests/data/e2e/e2e_big_map_mem_nat_08.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_big_map_mem_nat_08.json rename to michelson_vm/tests/data/e2e/e2e_big_map_mem_nat_08.json diff --git a/tezos_vm/tests/data/e2e/e2e_big_map_mem_nat_09.json b/michelson_vm/tests/data/e2e/e2e_big_map_mem_nat_09.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_big_map_mem_nat_09.json rename to michelson_vm/tests/data/e2e/e2e_big_map_mem_nat_09.json diff --git a/tezos_vm/tests/data/e2e/e2e_big_map_mem_nat_10.json b/michelson_vm/tests/data/e2e/e2e_big_map_mem_nat_10.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_big_map_mem_nat_10.json rename to michelson_vm/tests/data/e2e/e2e_big_map_mem_nat_10.json diff --git a/tezos_vm/tests/data/e2e/e2e_big_map_mem_nat_11.json b/michelson_vm/tests/data/e2e/e2e_big_map_mem_nat_11.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_big_map_mem_nat_11.json rename to michelson_vm/tests/data/e2e/e2e_big_map_mem_nat_11.json diff --git a/tezos_vm/tests/data/e2e/e2e_big_map_mem_string_00.json b/michelson_vm/tests/data/e2e/e2e_big_map_mem_string_00.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_big_map_mem_string_00.json rename to michelson_vm/tests/data/e2e/e2e_big_map_mem_string_00.json diff --git a/tezos_vm/tests/data/e2e/e2e_big_map_mem_string_01.json b/michelson_vm/tests/data/e2e/e2e_big_map_mem_string_01.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_big_map_mem_string_01.json rename to michelson_vm/tests/data/e2e/e2e_big_map_mem_string_01.json diff --git a/tezos_vm/tests/data/e2e/e2e_big_map_mem_string_02.json b/michelson_vm/tests/data/e2e/e2e_big_map_mem_string_02.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_big_map_mem_string_02.json rename to michelson_vm/tests/data/e2e/e2e_big_map_mem_string_02.json diff --git a/tezos_vm/tests/data/e2e/e2e_big_map_mem_string_03.json b/michelson_vm/tests/data/e2e/e2e_big_map_mem_string_03.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_big_map_mem_string_03.json rename to michelson_vm/tests/data/e2e/e2e_big_map_mem_string_03.json diff --git a/tezos_vm/tests/data/e2e/e2e_big_map_mem_string_04.json b/michelson_vm/tests/data/e2e/e2e_big_map_mem_string_04.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_big_map_mem_string_04.json rename to michelson_vm/tests/data/e2e/e2e_big_map_mem_string_04.json diff --git a/tezos_vm/tests/data/e2e/e2e_big_map_mem_string_05.json b/michelson_vm/tests/data/e2e/e2e_big_map_mem_string_05.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_big_map_mem_string_05.json rename to michelson_vm/tests/data/e2e/e2e_big_map_mem_string_05.json diff --git a/tezos_vm/tests/data/e2e/e2e_car_00.json b/michelson_vm/tests/data/e2e/e2e_car_00.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_car_00.json rename to michelson_vm/tests/data/e2e/e2e_car_00.json diff --git a/tezos_vm/tests/data/e2e/e2e_cdr_00.json b/michelson_vm/tests/data/e2e/e2e_cdr_00.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_cdr_00.json rename to michelson_vm/tests/data/e2e/e2e_cdr_00.json diff --git a/tezos_vm/tests/data/e2e/e2e_chain_id_store_00.json b/michelson_vm/tests/data/e2e/e2e_chain_id_store_00.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_chain_id_store_00.json rename to michelson_vm/tests/data/e2e/e2e_chain_id_store_00.json diff --git a/tezos_vm/tests/data/e2e/e2e_chain_id_store_01.json b/michelson_vm/tests/data/e2e/e2e_chain_id_store_01.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_chain_id_store_01.json rename to michelson_vm/tests/data/e2e/e2e_chain_id_store_01.json diff --git a/tezos_vm/tests/data/e2e/e2e_chain_id_store_02.json b/michelson_vm/tests/data/e2e/e2e_chain_id_store_02.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_chain_id_store_02.json rename to michelson_vm/tests/data/e2e/e2e_chain_id_store_02.json diff --git a/tezos_vm/tests/data/e2e/e2e_check_signature_00.json b/michelson_vm/tests/data/e2e/e2e_check_signature_00.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_check_signature_00.json rename to michelson_vm/tests/data/e2e/e2e_check_signature_00.json diff --git a/tezos_vm/tests/data/e2e/e2e_comb_00.json b/michelson_vm/tests/data/e2e/e2e_comb_00.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_comb_00.json rename to michelson_vm/tests/data/e2e/e2e_comb_00.json diff --git a/tezos_vm/tests/data/e2e/e2e_comb_get_00.json b/michelson_vm/tests/data/e2e/e2e_comb_get_00.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_comb_get_00.json rename to michelson_vm/tests/data/e2e/e2e_comb_get_00.json diff --git a/tezos_vm/tests/data/e2e/e2e_comb_set_00.json b/michelson_vm/tests/data/e2e/e2e_comb_set_00.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_comb_set_00.json rename to michelson_vm/tests/data/e2e/e2e_comb_set_00.json diff --git a/tezos_vm/tests/data/e2e/e2e_comb_set_2_00.json b/michelson_vm/tests/data/e2e/e2e_comb_set_2_00.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_comb_set_2_00.json rename to michelson_vm/tests/data/e2e/e2e_comb_set_2_00.json diff --git a/tezos_vm/tests/data/e2e/e2e_compare_00.json b/michelson_vm/tests/data/e2e/e2e_compare_00.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_compare_00.json rename to michelson_vm/tests/data/e2e/e2e_compare_00.json diff --git a/tezos_vm/tests/data/e2e/e2e_comparisons_00.json b/michelson_vm/tests/data/e2e/e2e_comparisons_00.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_comparisons_00.json rename to michelson_vm/tests/data/e2e/e2e_comparisons_00.json diff --git a/tezos_vm/tests/data/e2e/e2e_concat_hello_00.json b/michelson_vm/tests/data/e2e/e2e_concat_hello_00.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_concat_hello_00.json rename to michelson_vm/tests/data/e2e/e2e_concat_hello_00.json diff --git a/tezos_vm/tests/data/e2e/e2e_concat_hello_01.json b/michelson_vm/tests/data/e2e/e2e_concat_hello_01.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_concat_hello_01.json rename to michelson_vm/tests/data/e2e/e2e_concat_hello_01.json diff --git a/tezos_vm/tests/data/e2e/e2e_concat_hello_02.json b/michelson_vm/tests/data/e2e/e2e_concat_hello_02.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_concat_hello_02.json rename to michelson_vm/tests/data/e2e/e2e_concat_hello_02.json diff --git a/tezos_vm/tests/data/e2e/e2e_concat_hello_bytes_00.json b/michelson_vm/tests/data/e2e/e2e_concat_hello_bytes_00.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_concat_hello_bytes_00.json rename to michelson_vm/tests/data/e2e/e2e_concat_hello_bytes_00.json diff --git a/tezos_vm/tests/data/e2e/e2e_concat_hello_bytes_01.json b/michelson_vm/tests/data/e2e/e2e_concat_hello_bytes_01.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_concat_hello_bytes_01.json rename to michelson_vm/tests/data/e2e/e2e_concat_hello_bytes_01.json diff --git a/tezos_vm/tests/data/e2e/e2e_concat_hello_bytes_02.json b/michelson_vm/tests/data/e2e/e2e_concat_hello_bytes_02.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_concat_hello_bytes_02.json rename to michelson_vm/tests/data/e2e/e2e_concat_hello_bytes_02.json diff --git a/tezos_vm/tests/data/e2e/e2e_concat_list_00.json b/michelson_vm/tests/data/e2e/e2e_concat_list_00.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_concat_list_00.json rename to michelson_vm/tests/data/e2e/e2e_concat_list_00.json diff --git a/tezos_vm/tests/data/e2e/e2e_concat_list_01.json b/michelson_vm/tests/data/e2e/e2e_concat_list_01.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_concat_list_01.json rename to michelson_vm/tests/data/e2e/e2e_concat_list_01.json diff --git a/tezos_vm/tests/data/e2e/e2e_concat_list_02.json b/michelson_vm/tests/data/e2e/e2e_concat_list_02.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_concat_list_02.json rename to michelson_vm/tests/data/e2e/e2e_concat_list_02.json diff --git a/tezos_vm/tests/data/e2e/e2e_cons_00.json b/michelson_vm/tests/data/e2e/e2e_cons_00.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_cons_00.json rename to michelson_vm/tests/data/e2e/e2e_cons_00.json diff --git a/tezos_vm/tests/data/e2e/e2e_cons_01.json b/michelson_vm/tests/data/e2e/e2e_cons_01.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_cons_01.json rename to michelson_vm/tests/data/e2e/e2e_cons_01.json diff --git a/tezos_vm/tests/data/e2e/e2e_cons_02.json b/michelson_vm/tests/data/e2e/e2e_cons_02.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_cons_02.json rename to michelson_vm/tests/data/e2e/e2e_cons_02.json diff --git a/tezos_vm/tests/data/e2e/e2e_contains_all_00.json b/michelson_vm/tests/data/e2e/e2e_contains_all_00.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_contains_all_00.json rename to michelson_vm/tests/data/e2e/e2e_contains_all_00.json diff --git a/tezos_vm/tests/data/e2e/e2e_contains_all_01.json b/michelson_vm/tests/data/e2e/e2e_contains_all_01.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_contains_all_01.json rename to michelson_vm/tests/data/e2e/e2e_contains_all_01.json diff --git a/tezos_vm/tests/data/e2e/e2e_contains_all_02.json b/michelson_vm/tests/data/e2e/e2e_contains_all_02.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_contains_all_02.json rename to michelson_vm/tests/data/e2e/e2e_contains_all_02.json diff --git a/tezos_vm/tests/data/e2e/e2e_contains_all_03.json b/michelson_vm/tests/data/e2e/e2e_contains_all_03.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_contains_all_03.json rename to michelson_vm/tests/data/e2e/e2e_contains_all_03.json diff --git a/tezos_vm/tests/data/e2e/e2e_contains_all_04.json b/michelson_vm/tests/data/e2e/e2e_contains_all_04.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_contains_all_04.json rename to michelson_vm/tests/data/e2e/e2e_contains_all_04.json diff --git a/tezos_vm/tests/data/e2e/e2e_contains_all_05.json b/michelson_vm/tests/data/e2e/e2e_contains_all_05.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_contains_all_05.json rename to michelson_vm/tests/data/e2e/e2e_contains_all_05.json diff --git a/tezos_vm/tests/data/e2e/e2e_contract_00.json b/michelson_vm/tests/data/e2e/e2e_contract_00.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_contract_00.json rename to michelson_vm/tests/data/e2e/e2e_contract_00.json diff --git a/tezos_vm/tests/data/e2e/e2e_diff_timestamps_00.json b/michelson_vm/tests/data/e2e/e2e_diff_timestamps_00.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_diff_timestamps_00.json rename to michelson_vm/tests/data/e2e/e2e_diff_timestamps_00.json diff --git a/tezos_vm/tests/data/e2e/e2e_diff_timestamps_01.json b/michelson_vm/tests/data/e2e/e2e_diff_timestamps_01.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_diff_timestamps_01.json rename to michelson_vm/tests/data/e2e/e2e_diff_timestamps_01.json diff --git a/tezos_vm/tests/data/e2e/e2e_diff_timestamps_02.json b/michelson_vm/tests/data/e2e/e2e_diff_timestamps_02.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_diff_timestamps_02.json rename to michelson_vm/tests/data/e2e/e2e_diff_timestamps_02.json diff --git a/tezos_vm/tests/data/e2e/e2e_diff_timestamps_03.json b/michelson_vm/tests/data/e2e/e2e_diff_timestamps_03.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_diff_timestamps_03.json rename to michelson_vm/tests/data/e2e/e2e_diff_timestamps_03.json diff --git a/tezos_vm/tests/data/e2e/e2e_dig_eq_00.json b/michelson_vm/tests/data/e2e/e2e_dig_eq_00.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_dig_eq_00.json rename to michelson_vm/tests/data/e2e/e2e_dig_eq_00.json diff --git a/tezos_vm/tests/data/e2e/e2e_dig_eq_01.json b/michelson_vm/tests/data/e2e/e2e_dig_eq_01.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_dig_eq_01.json rename to michelson_vm/tests/data/e2e/e2e_dig_eq_01.json diff --git a/tezos_vm/tests/data/e2e/e2e_dign_00.json b/michelson_vm/tests/data/e2e/e2e_dign_00.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_dign_00.json rename to michelson_vm/tests/data/e2e/e2e_dign_00.json diff --git a/tezos_vm/tests/data/e2e/e2e_dip_00.json b/michelson_vm/tests/data/e2e/e2e_dip_00.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_dip_00.json rename to michelson_vm/tests/data/e2e/e2e_dip_00.json diff --git a/tezos_vm/tests/data/e2e/e2e_dip_01.json b/michelson_vm/tests/data/e2e/e2e_dip_01.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_dip_01.json rename to michelson_vm/tests/data/e2e/e2e_dip_01.json diff --git a/tezos_vm/tests/data/e2e/e2e_dipn_00.json b/michelson_vm/tests/data/e2e/e2e_dipn_00.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_dipn_00.json rename to michelson_vm/tests/data/e2e/e2e_dipn_00.json diff --git a/tezos_vm/tests/data/e2e/e2e_dropn_00.json b/michelson_vm/tests/data/e2e/e2e_dropn_00.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_dropn_00.json rename to michelson_vm/tests/data/e2e/e2e_dropn_00.json diff --git a/tezos_vm/tests/data/e2e/e2e_dugn_00.json b/michelson_vm/tests/data/e2e/e2e_dugn_00.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_dugn_00.json rename to michelson_vm/tests/data/e2e/e2e_dugn_00.json diff --git a/tezos_vm/tests/data/e2e/e2e_dup_n_00.json b/michelson_vm/tests/data/e2e/e2e_dup_n_00.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_dup_n_00.json rename to michelson_vm/tests/data/e2e/e2e_dup_n_00.json diff --git a/tezos_vm/tests/data/e2e/e2e_ediv_00.json b/michelson_vm/tests/data/e2e/e2e_ediv_00.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_ediv_00.json rename to michelson_vm/tests/data/e2e/e2e_ediv_00.json diff --git a/tezos_vm/tests/data/e2e/e2e_ediv_01.json b/michelson_vm/tests/data/e2e/e2e_ediv_01.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_ediv_01.json rename to michelson_vm/tests/data/e2e/e2e_ediv_01.json diff --git a/tezos_vm/tests/data/e2e/e2e_ediv_02.json b/michelson_vm/tests/data/e2e/e2e_ediv_02.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_ediv_02.json rename to michelson_vm/tests/data/e2e/e2e_ediv_02.json diff --git a/tezos_vm/tests/data/e2e/e2e_ediv_mutez_00.json b/michelson_vm/tests/data/e2e/e2e_ediv_mutez_00.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_ediv_mutez_00.json rename to michelson_vm/tests/data/e2e/e2e_ediv_mutez_00.json diff --git a/tezos_vm/tests/data/e2e/e2e_ediv_mutez_01.json b/michelson_vm/tests/data/e2e/e2e_ediv_mutez_01.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_ediv_mutez_01.json rename to michelson_vm/tests/data/e2e/e2e_ediv_mutez_01.json diff --git a/tezos_vm/tests/data/e2e/e2e_ediv_mutez_02.json b/michelson_vm/tests/data/e2e/e2e_ediv_mutez_02.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_ediv_mutez_02.json rename to michelson_vm/tests/data/e2e/e2e_ediv_mutez_02.json diff --git a/tezos_vm/tests/data/e2e/e2e_ediv_mutez_03.json b/michelson_vm/tests/data/e2e/e2e_ediv_mutez_03.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_ediv_mutez_03.json rename to michelson_vm/tests/data/e2e/e2e_ediv_mutez_03.json diff --git a/tezos_vm/tests/data/e2e/e2e_ediv_mutez_04.json b/michelson_vm/tests/data/e2e/e2e_ediv_mutez_04.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_ediv_mutez_04.json rename to michelson_vm/tests/data/e2e/e2e_ediv_mutez_04.json diff --git a/tezos_vm/tests/data/e2e/e2e_ediv_mutez_05.json b/michelson_vm/tests/data/e2e/e2e_ediv_mutez_05.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_ediv_mutez_05.json rename to michelson_vm/tests/data/e2e/e2e_ediv_mutez_05.json diff --git a/tezos_vm/tests/data/e2e/e2e_ediv_mutez_06.json b/michelson_vm/tests/data/e2e/e2e_ediv_mutez_06.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_ediv_mutez_06.json rename to michelson_vm/tests/data/e2e/e2e_ediv_mutez_06.json diff --git a/tezos_vm/tests/data/e2e/e2e_empty_map_00.json b/michelson_vm/tests/data/e2e/e2e_empty_map_00.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_empty_map_00.json rename to michelson_vm/tests/data/e2e/e2e_empty_map_00.json diff --git a/tezos_vm/tests/data/e2e/e2e_exec_concat_00.json b/michelson_vm/tests/data/e2e/e2e_exec_concat_00.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_exec_concat_00.json rename to michelson_vm/tests/data/e2e/e2e_exec_concat_00.json diff --git a/tezos_vm/tests/data/e2e/e2e_exec_concat_01.json b/michelson_vm/tests/data/e2e/e2e_exec_concat_01.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_exec_concat_01.json rename to michelson_vm/tests/data/e2e/e2e_exec_concat_01.json diff --git a/tezos_vm/tests/data/e2e/e2e_first_00.json b/michelson_vm/tests/data/e2e/e2e_first_00.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_first_00.json rename to michelson_vm/tests/data/e2e/e2e_first_00.json diff --git a/tezos_vm/tests/data/e2e/e2e_first_01.json b/michelson_vm/tests/data/e2e/e2e_first_01.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_first_01.json rename to michelson_vm/tests/data/e2e/e2e_first_01.json diff --git a/tezos_vm/tests/data/e2e/e2e_get_and_update_map_00.json b/michelson_vm/tests/data/e2e/e2e_get_and_update_map_00.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_get_and_update_map_00.json rename to michelson_vm/tests/data/e2e/e2e_get_and_update_map_00.json diff --git a/tezos_vm/tests/data/e2e/e2e_get_and_update_map_01.json b/michelson_vm/tests/data/e2e/e2e_get_and_update_map_01.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_get_and_update_map_01.json rename to michelson_vm/tests/data/e2e/e2e_get_and_update_map_01.json diff --git a/tezos_vm/tests/data/e2e/e2e_get_and_update_map_02.json b/michelson_vm/tests/data/e2e/e2e_get_and_update_map_02.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_get_and_update_map_02.json rename to michelson_vm/tests/data/e2e/e2e_get_and_update_map_02.json diff --git a/tezos_vm/tests/data/e2e/e2e_get_and_update_map_03.json b/michelson_vm/tests/data/e2e/e2e_get_and_update_map_03.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_get_and_update_map_03.json rename to michelson_vm/tests/data/e2e/e2e_get_and_update_map_03.json diff --git a/tezos_vm/tests/data/e2e/e2e_get_and_update_map_04.json b/michelson_vm/tests/data/e2e/e2e_get_and_update_map_04.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_get_and_update_map_04.json rename to michelson_vm/tests/data/e2e/e2e_get_and_update_map_04.json diff --git a/tezos_vm/tests/data/e2e/e2e_get_and_update_map_05.json b/michelson_vm/tests/data/e2e/e2e_get_and_update_map_05.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_get_and_update_map_05.json rename to michelson_vm/tests/data/e2e/e2e_get_and_update_map_05.json diff --git a/tezos_vm/tests/data/e2e/e2e_get_and_update_map_06.json b/michelson_vm/tests/data/e2e/e2e_get_and_update_map_06.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_get_and_update_map_06.json rename to michelson_vm/tests/data/e2e/e2e_get_and_update_map_06.json diff --git a/tezos_vm/tests/data/e2e/e2e_get_map_value_00.json b/michelson_vm/tests/data/e2e/e2e_get_map_value_00.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_get_map_value_00.json rename to michelson_vm/tests/data/e2e/e2e_get_map_value_00.json diff --git a/tezos_vm/tests/data/e2e/e2e_get_map_value_01.json b/michelson_vm/tests/data/e2e/e2e_get_map_value_01.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_get_map_value_01.json rename to michelson_vm/tests/data/e2e/e2e_get_map_value_01.json diff --git a/tezos_vm/tests/data/e2e/e2e_get_map_value_02.json b/michelson_vm/tests/data/e2e/e2e_get_map_value_02.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_get_map_value_02.json rename to michelson_vm/tests/data/e2e/e2e_get_map_value_02.json diff --git a/tezos_vm/tests/data/e2e/e2e_hash_key_00.json b/michelson_vm/tests/data/e2e/e2e_hash_key_00.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_hash_key_00.json rename to michelson_vm/tests/data/e2e/e2e_hash_key_00.json diff --git a/tezos_vm/tests/data/e2e/e2e_hash_key_01.json b/michelson_vm/tests/data/e2e/e2e_hash_key_01.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_hash_key_01.json rename to michelson_vm/tests/data/e2e/e2e_hash_key_01.json diff --git a/tezos_vm/tests/data/e2e/e2e_hash_string_00.json b/michelson_vm/tests/data/e2e/e2e_hash_string_00.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_hash_string_00.json rename to michelson_vm/tests/data/e2e/e2e_hash_string_00.json diff --git a/tezos_vm/tests/data/e2e/e2e_hash_string_01.json b/michelson_vm/tests/data/e2e/e2e_hash_string_01.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_hash_string_01.json rename to michelson_vm/tests/data/e2e/e2e_hash_string_01.json diff --git a/tezos_vm/tests/data/e2e/e2e_if_00.json b/michelson_vm/tests/data/e2e/e2e_if_00.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_if_00.json rename to michelson_vm/tests/data/e2e/e2e_if_00.json diff --git a/tezos_vm/tests/data/e2e/e2e_if_01.json b/michelson_vm/tests/data/e2e/e2e_if_01.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_if_01.json rename to michelson_vm/tests/data/e2e/e2e_if_01.json diff --git a/tezos_vm/tests/data/e2e/e2e_if_some_00.json b/michelson_vm/tests/data/e2e/e2e_if_some_00.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_if_some_00.json rename to michelson_vm/tests/data/e2e/e2e_if_some_00.json diff --git a/tezos_vm/tests/data/e2e/e2e_if_some_01.json b/michelson_vm/tests/data/e2e/e2e_if_some_01.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_if_some_01.json rename to michelson_vm/tests/data/e2e/e2e_if_some_01.json diff --git a/tezos_vm/tests/data/e2e/e2e_int_00.json b/michelson_vm/tests/data/e2e/e2e_int_00.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_int_00.json rename to michelson_vm/tests/data/e2e/e2e_int_00.json diff --git a/tezos_vm/tests/data/e2e/e2e_int_01.json b/michelson_vm/tests/data/e2e/e2e_int_01.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_int_01.json rename to michelson_vm/tests/data/e2e/e2e_int_01.json diff --git a/tezos_vm/tests/data/e2e/e2e_int_02.json b/michelson_vm/tests/data/e2e/e2e_int_02.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_int_02.json rename to michelson_vm/tests/data/e2e/e2e_int_02.json diff --git a/tezos_vm/tests/data/e2e/e2e_left_right_00.json b/michelson_vm/tests/data/e2e/e2e_left_right_00.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_left_right_00.json rename to michelson_vm/tests/data/e2e/e2e_left_right_00.json diff --git a/tezos_vm/tests/data/e2e/e2e_left_right_01.json b/michelson_vm/tests/data/e2e/e2e_left_right_01.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_left_right_01.json rename to michelson_vm/tests/data/e2e/e2e_left_right_01.json diff --git a/tezos_vm/tests/data/e2e/e2e_level_00.json b/michelson_vm/tests/data/e2e/e2e_level_00.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_level_00.json rename to michelson_vm/tests/data/e2e/e2e_level_00.json diff --git a/tezos_vm/tests/data/e2e/e2e_list_concat_00.json b/michelson_vm/tests/data/e2e/e2e_list_concat_00.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_list_concat_00.json rename to michelson_vm/tests/data/e2e/e2e_list_concat_00.json diff --git a/tezos_vm/tests/data/e2e/e2e_list_concat_01.json b/michelson_vm/tests/data/e2e/e2e_list_concat_01.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_list_concat_01.json rename to michelson_vm/tests/data/e2e/e2e_list_concat_01.json diff --git a/tezos_vm/tests/data/e2e/e2e_list_concat_bytes_00.json b/michelson_vm/tests/data/e2e/e2e_list_concat_bytes_00.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_list_concat_bytes_00.json rename to michelson_vm/tests/data/e2e/e2e_list_concat_bytes_00.json diff --git a/tezos_vm/tests/data/e2e/e2e_list_concat_bytes_01.json b/michelson_vm/tests/data/e2e/e2e_list_concat_bytes_01.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_list_concat_bytes_01.json rename to michelson_vm/tests/data/e2e/e2e_list_concat_bytes_01.json diff --git a/tezos_vm/tests/data/e2e/e2e_list_concat_bytes_02.json b/michelson_vm/tests/data/e2e/e2e_list_concat_bytes_02.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_list_concat_bytes_02.json rename to michelson_vm/tests/data/e2e/e2e_list_concat_bytes_02.json diff --git a/tezos_vm/tests/data/e2e/e2e_list_concat_bytes_03.json b/michelson_vm/tests/data/e2e/e2e_list_concat_bytes_03.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_list_concat_bytes_03.json rename to michelson_vm/tests/data/e2e/e2e_list_concat_bytes_03.json diff --git a/tezos_vm/tests/data/e2e/e2e_list_id_00.json b/michelson_vm/tests/data/e2e/e2e_list_id_00.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_list_id_00.json rename to michelson_vm/tests/data/e2e/e2e_list_id_00.json diff --git a/tezos_vm/tests/data/e2e/e2e_list_id_01.json b/michelson_vm/tests/data/e2e/e2e_list_id_01.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_list_id_01.json rename to michelson_vm/tests/data/e2e/e2e_list_id_01.json diff --git a/tezos_vm/tests/data/e2e/e2e_list_id_02.json b/michelson_vm/tests/data/e2e/e2e_list_id_02.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_list_id_02.json rename to michelson_vm/tests/data/e2e/e2e_list_id_02.json diff --git a/tezos_vm/tests/data/e2e/e2e_list_id_map_00.json b/michelson_vm/tests/data/e2e/e2e_list_id_map_00.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_list_id_map_00.json rename to michelson_vm/tests/data/e2e/e2e_list_id_map_00.json diff --git a/tezos_vm/tests/data/e2e/e2e_list_id_map_01.json b/michelson_vm/tests/data/e2e/e2e_list_id_map_01.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_list_id_map_01.json rename to michelson_vm/tests/data/e2e/e2e_list_id_map_01.json diff --git a/tezos_vm/tests/data/e2e/e2e_list_id_map_02.json b/michelson_vm/tests/data/e2e/e2e_list_id_map_02.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_list_id_map_02.json rename to michelson_vm/tests/data/e2e/e2e_list_id_map_02.json diff --git a/tezos_vm/tests/data/e2e/e2e_list_iter_00.json b/michelson_vm/tests/data/e2e/e2e_list_iter_00.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_list_iter_00.json rename to michelson_vm/tests/data/e2e/e2e_list_iter_00.json diff --git a/tezos_vm/tests/data/e2e/e2e_list_iter_01.json b/michelson_vm/tests/data/e2e/e2e_list_iter_01.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_list_iter_01.json rename to michelson_vm/tests/data/e2e/e2e_list_iter_01.json diff --git a/tezos_vm/tests/data/e2e/e2e_list_map_block_00.json b/michelson_vm/tests/data/e2e/e2e_list_map_block_00.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_list_map_block_00.json rename to michelson_vm/tests/data/e2e/e2e_list_map_block_00.json diff --git a/tezos_vm/tests/data/e2e/e2e_list_map_block_01.json b/michelson_vm/tests/data/e2e/e2e_list_map_block_01.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_list_map_block_01.json rename to michelson_vm/tests/data/e2e/e2e_list_map_block_01.json diff --git a/tezos_vm/tests/data/e2e/e2e_list_map_block_02.json b/michelson_vm/tests/data/e2e/e2e_list_map_block_02.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_list_map_block_02.json rename to michelson_vm/tests/data/e2e/e2e_list_map_block_02.json diff --git a/tezos_vm/tests/data/e2e/e2e_list_size_00.json b/michelson_vm/tests/data/e2e/e2e_list_size_00.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_list_size_00.json rename to michelson_vm/tests/data/e2e/e2e_list_size_00.json diff --git a/tezos_vm/tests/data/e2e/e2e_list_size_01.json b/michelson_vm/tests/data/e2e/e2e_list_size_01.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_list_size_01.json rename to michelson_vm/tests/data/e2e/e2e_list_size_01.json diff --git a/tezos_vm/tests/data/e2e/e2e_list_size_02.json b/michelson_vm/tests/data/e2e/e2e_list_size_02.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_list_size_02.json rename to michelson_vm/tests/data/e2e/e2e_list_size_02.json diff --git a/tezos_vm/tests/data/e2e/e2e_list_size_03.json b/michelson_vm/tests/data/e2e/e2e_list_size_03.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_list_size_03.json rename to michelson_vm/tests/data/e2e/e2e_list_size_03.json diff --git a/tezos_vm/tests/data/e2e/e2e_loop_left_00.json b/michelson_vm/tests/data/e2e/e2e_loop_left_00.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_loop_left_00.json rename to michelson_vm/tests/data/e2e/e2e_loop_left_00.json diff --git a/tezos_vm/tests/data/e2e/e2e_loop_left_01.json b/michelson_vm/tests/data/e2e/e2e_loop_left_01.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_loop_left_01.json rename to michelson_vm/tests/data/e2e/e2e_loop_left_01.json diff --git a/tezos_vm/tests/data/e2e/e2e_map_id_00.json b/michelson_vm/tests/data/e2e/e2e_map_id_00.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_map_id_00.json rename to michelson_vm/tests/data/e2e/e2e_map_id_00.json diff --git a/tezos_vm/tests/data/e2e/e2e_map_id_01.json b/michelson_vm/tests/data/e2e/e2e_map_id_01.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_map_id_01.json rename to michelson_vm/tests/data/e2e/e2e_map_id_01.json diff --git a/tezos_vm/tests/data/e2e/e2e_map_id_02.json b/michelson_vm/tests/data/e2e/e2e_map_id_02.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_map_id_02.json rename to michelson_vm/tests/data/e2e/e2e_map_id_02.json diff --git a/tezos_vm/tests/data/e2e/e2e_map_iter_00.json b/michelson_vm/tests/data/e2e/e2e_map_iter_00.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_map_iter_00.json rename to michelson_vm/tests/data/e2e/e2e_map_iter_00.json diff --git a/tezos_vm/tests/data/e2e/e2e_map_iter_01.json b/michelson_vm/tests/data/e2e/e2e_map_iter_01.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_map_iter_01.json rename to michelson_vm/tests/data/e2e/e2e_map_iter_01.json diff --git a/tezos_vm/tests/data/e2e/e2e_map_map_00.json b/michelson_vm/tests/data/e2e/e2e_map_map_00.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_map_map_00.json rename to michelson_vm/tests/data/e2e/e2e_map_map_00.json diff --git a/tezos_vm/tests/data/e2e/e2e_map_map_01.json b/michelson_vm/tests/data/e2e/e2e_map_map_01.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_map_map_01.json rename to michelson_vm/tests/data/e2e/e2e_map_map_01.json diff --git a/tezos_vm/tests/data/e2e/e2e_map_map_02.json b/michelson_vm/tests/data/e2e/e2e_map_map_02.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_map_map_02.json rename to michelson_vm/tests/data/e2e/e2e_map_map_02.json diff --git a/tezos_vm/tests/data/e2e/e2e_map_map_sideeffect_00.json b/michelson_vm/tests/data/e2e/e2e_map_map_sideeffect_00.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_map_map_sideeffect_00.json rename to michelson_vm/tests/data/e2e/e2e_map_map_sideeffect_00.json diff --git a/tezos_vm/tests/data/e2e/e2e_map_map_sideeffect_01.json b/michelson_vm/tests/data/e2e/e2e_map_map_sideeffect_01.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_map_map_sideeffect_01.json rename to michelson_vm/tests/data/e2e/e2e_map_map_sideeffect_01.json diff --git a/tezos_vm/tests/data/e2e/e2e_map_map_sideeffect_02.json b/michelson_vm/tests/data/e2e/e2e_map_map_sideeffect_02.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_map_map_sideeffect_02.json rename to michelson_vm/tests/data/e2e/e2e_map_map_sideeffect_02.json diff --git a/tezos_vm/tests/data/e2e/e2e_map_mem_nat_00.json b/michelson_vm/tests/data/e2e/e2e_map_mem_nat_00.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_map_mem_nat_00.json rename to michelson_vm/tests/data/e2e/e2e_map_mem_nat_00.json diff --git a/tezos_vm/tests/data/e2e/e2e_map_mem_nat_01.json b/michelson_vm/tests/data/e2e/e2e_map_mem_nat_01.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_map_mem_nat_01.json rename to michelson_vm/tests/data/e2e/e2e_map_mem_nat_01.json diff --git a/tezos_vm/tests/data/e2e/e2e_map_mem_nat_02.json b/michelson_vm/tests/data/e2e/e2e_map_mem_nat_02.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_map_mem_nat_02.json rename to michelson_vm/tests/data/e2e/e2e_map_mem_nat_02.json diff --git a/tezos_vm/tests/data/e2e/e2e_map_mem_nat_03.json b/michelson_vm/tests/data/e2e/e2e_map_mem_nat_03.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_map_mem_nat_03.json rename to michelson_vm/tests/data/e2e/e2e_map_mem_nat_03.json diff --git a/tezos_vm/tests/data/e2e/e2e_map_mem_nat_04.json b/michelson_vm/tests/data/e2e/e2e_map_mem_nat_04.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_map_mem_nat_04.json rename to michelson_vm/tests/data/e2e/e2e_map_mem_nat_04.json diff --git a/tezos_vm/tests/data/e2e/e2e_map_mem_nat_05.json b/michelson_vm/tests/data/e2e/e2e_map_mem_nat_05.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_map_mem_nat_05.json rename to michelson_vm/tests/data/e2e/e2e_map_mem_nat_05.json diff --git a/tezos_vm/tests/data/e2e/e2e_map_mem_string_00.json b/michelson_vm/tests/data/e2e/e2e_map_mem_string_00.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_map_mem_string_00.json rename to michelson_vm/tests/data/e2e/e2e_map_mem_string_00.json diff --git a/tezos_vm/tests/data/e2e/e2e_map_mem_string_01.json b/michelson_vm/tests/data/e2e/e2e_map_mem_string_01.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_map_mem_string_01.json rename to michelson_vm/tests/data/e2e/e2e_map_mem_string_01.json diff --git a/tezos_vm/tests/data/e2e/e2e_map_mem_string_02.json b/michelson_vm/tests/data/e2e/e2e_map_mem_string_02.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_map_mem_string_02.json rename to michelson_vm/tests/data/e2e/e2e_map_mem_string_02.json diff --git a/tezos_vm/tests/data/e2e/e2e_map_mem_string_03.json b/michelson_vm/tests/data/e2e/e2e_map_mem_string_03.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_map_mem_string_03.json rename to michelson_vm/tests/data/e2e/e2e_map_mem_string_03.json diff --git a/tezos_vm/tests/data/e2e/e2e_map_mem_string_04.json b/michelson_vm/tests/data/e2e/e2e_map_mem_string_04.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_map_mem_string_04.json rename to michelson_vm/tests/data/e2e/e2e_map_mem_string_04.json diff --git a/tezos_vm/tests/data/e2e/e2e_map_mem_string_05.json b/michelson_vm/tests/data/e2e/e2e_map_mem_string_05.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_map_mem_string_05.json rename to michelson_vm/tests/data/e2e/e2e_map_mem_string_05.json diff --git a/tezos_vm/tests/data/e2e/e2e_map_size_00.json b/michelson_vm/tests/data/e2e/e2e_map_size_00.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_map_size_00.json rename to michelson_vm/tests/data/e2e/e2e_map_size_00.json diff --git a/tezos_vm/tests/data/e2e/e2e_map_size_01.json b/michelson_vm/tests/data/e2e/e2e_map_size_01.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_map_size_01.json rename to michelson_vm/tests/data/e2e/e2e_map_size_01.json diff --git a/tezos_vm/tests/data/e2e/e2e_map_size_02.json b/michelson_vm/tests/data/e2e/e2e_map_size_02.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_map_size_02.json rename to michelson_vm/tests/data/e2e/e2e_map_size_02.json diff --git a/tezos_vm/tests/data/e2e/e2e_map_size_03.json b/michelson_vm/tests/data/e2e/e2e_map_size_03.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_map_size_03.json rename to michelson_vm/tests/data/e2e/e2e_map_size_03.json diff --git a/tezos_vm/tests/data/e2e/e2e_mul_00.json b/michelson_vm/tests/data/e2e/e2e_mul_00.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_mul_00.json rename to michelson_vm/tests/data/e2e/e2e_mul_00.json diff --git a/tezos_vm/tests/data/e2e/e2e_neg_00.json b/michelson_vm/tests/data/e2e/e2e_neg_00.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_neg_00.json rename to michelson_vm/tests/data/e2e/e2e_neg_00.json diff --git a/tezos_vm/tests/data/e2e/e2e_neg_01.json b/michelson_vm/tests/data/e2e/e2e_neg_01.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_neg_01.json rename to michelson_vm/tests/data/e2e/e2e_neg_01.json diff --git a/tezos_vm/tests/data/e2e/e2e_neg_02.json b/michelson_vm/tests/data/e2e/e2e_neg_02.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_neg_02.json rename to michelson_vm/tests/data/e2e/e2e_neg_02.json diff --git a/tezos_vm/tests/data/e2e/e2e_neg_03.json b/michelson_vm/tests/data/e2e/e2e_neg_03.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_neg_03.json rename to michelson_vm/tests/data/e2e/e2e_neg_03.json diff --git a/tezos_vm/tests/data/e2e/e2e_neg_04.json b/michelson_vm/tests/data/e2e/e2e_neg_04.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_neg_04.json rename to michelson_vm/tests/data/e2e/e2e_neg_04.json diff --git a/tezos_vm/tests/data/e2e/e2e_none_00.json b/michelson_vm/tests/data/e2e/e2e_none_00.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_none_00.json rename to michelson_vm/tests/data/e2e/e2e_none_00.json diff --git a/tezos_vm/tests/data/e2e/e2e_not_00.json b/michelson_vm/tests/data/e2e/e2e_not_00.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_not_00.json rename to michelson_vm/tests/data/e2e/e2e_not_00.json diff --git a/tezos_vm/tests/data/e2e/e2e_not_01.json b/michelson_vm/tests/data/e2e/e2e_not_01.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_not_01.json rename to michelson_vm/tests/data/e2e/e2e_not_01.json diff --git a/tezos_vm/tests/data/e2e/e2e_not_binary_00.json b/michelson_vm/tests/data/e2e/e2e_not_binary_00.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_not_binary_00.json rename to michelson_vm/tests/data/e2e/e2e_not_binary_00.json diff --git a/tezos_vm/tests/data/e2e/e2e_not_binary_01.json b/michelson_vm/tests/data/e2e/e2e_not_binary_01.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_not_binary_01.json rename to michelson_vm/tests/data/e2e/e2e_not_binary_01.json diff --git a/tezos_vm/tests/data/e2e/e2e_not_binary_02.json b/michelson_vm/tests/data/e2e/e2e_not_binary_02.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_not_binary_02.json rename to michelson_vm/tests/data/e2e/e2e_not_binary_02.json diff --git a/tezos_vm/tests/data/e2e/e2e_not_binary_03.json b/michelson_vm/tests/data/e2e/e2e_not_binary_03.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_not_binary_03.json rename to michelson_vm/tests/data/e2e/e2e_not_binary_03.json diff --git a/tezos_vm/tests/data/e2e/e2e_not_binary_04.json b/michelson_vm/tests/data/e2e/e2e_not_binary_04.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_not_binary_04.json rename to michelson_vm/tests/data/e2e/e2e_not_binary_04.json diff --git a/tezos_vm/tests/data/e2e/e2e_not_binary_05.json b/michelson_vm/tests/data/e2e/e2e_not_binary_05.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_not_binary_05.json rename to michelson_vm/tests/data/e2e/e2e_not_binary_05.json diff --git a/tezos_vm/tests/data/e2e/e2e_not_binary_06.json b/michelson_vm/tests/data/e2e/e2e_not_binary_06.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_not_binary_06.json rename to michelson_vm/tests/data/e2e/e2e_not_binary_06.json diff --git a/tezos_vm/tests/data/e2e/e2e_not_binary_07.json b/michelson_vm/tests/data/e2e/e2e_not_binary_07.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_not_binary_07.json rename to michelson_vm/tests/data/e2e/e2e_not_binary_07.json diff --git a/tezos_vm/tests/data/e2e/e2e_or_00.json b/michelson_vm/tests/data/e2e/e2e_or_00.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_or_00.json rename to michelson_vm/tests/data/e2e/e2e_or_00.json diff --git a/tezos_vm/tests/data/e2e/e2e_or_01.json b/michelson_vm/tests/data/e2e/e2e_or_01.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_or_01.json rename to michelson_vm/tests/data/e2e/e2e_or_01.json diff --git a/tezos_vm/tests/data/e2e/e2e_or_02.json b/michelson_vm/tests/data/e2e/e2e_or_02.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_or_02.json rename to michelson_vm/tests/data/e2e/e2e_or_02.json diff --git a/tezos_vm/tests/data/e2e/e2e_or_03.json b/michelson_vm/tests/data/e2e/e2e_or_03.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_or_03.json rename to michelson_vm/tests/data/e2e/e2e_or_03.json diff --git a/tezos_vm/tests/data/e2e/e2e_or_binary_00.json b/michelson_vm/tests/data/e2e/e2e_or_binary_00.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_or_binary_00.json rename to michelson_vm/tests/data/e2e/e2e_or_binary_00.json diff --git a/tezos_vm/tests/data/e2e/e2e_or_binary_01.json b/michelson_vm/tests/data/e2e/e2e_or_binary_01.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_or_binary_01.json rename to michelson_vm/tests/data/e2e/e2e_or_binary_01.json diff --git a/tezos_vm/tests/data/e2e/e2e_or_binary_02.json b/michelson_vm/tests/data/e2e/e2e_or_binary_02.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_or_binary_02.json rename to michelson_vm/tests/data/e2e/e2e_or_binary_02.json diff --git a/tezos_vm/tests/data/e2e/e2e_or_binary_03.json b/michelson_vm/tests/data/e2e/e2e_or_binary_03.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_or_binary_03.json rename to michelson_vm/tests/data/e2e/e2e_or_binary_03.json diff --git a/tezos_vm/tests/data/e2e/e2e_or_binary_04.json b/michelson_vm/tests/data/e2e/e2e_or_binary_04.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_or_binary_04.json rename to michelson_vm/tests/data/e2e/e2e_or_binary_04.json diff --git a/tezos_vm/tests/data/e2e/e2e_or_binary_05.json b/michelson_vm/tests/data/e2e/e2e_or_binary_05.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_or_binary_05.json rename to michelson_vm/tests/data/e2e/e2e_or_binary_05.json diff --git a/tezos_vm/tests/data/e2e/e2e_packunpack_00.json b/michelson_vm/tests/data/e2e/e2e_packunpack_00.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_packunpack_00.json rename to michelson_vm/tests/data/e2e/e2e_packunpack_00.json diff --git a/tezos_vm/tests/data/e2e/e2e_packunpack_rev_00.json b/michelson_vm/tests/data/e2e/e2e_packunpack_rev_00.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_packunpack_rev_00.json rename to michelson_vm/tests/data/e2e/e2e_packunpack_rev_00.json diff --git a/tezos_vm/tests/data/e2e/e2e_packunpack_rev_01.json b/michelson_vm/tests/data/e2e/e2e_packunpack_rev_01.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_packunpack_rev_01.json rename to michelson_vm/tests/data/e2e/e2e_packunpack_rev_01.json diff --git a/tezos_vm/tests/data/e2e/e2e_packunpack_rev_cty_00.json b/michelson_vm/tests/data/e2e/e2e_packunpack_rev_cty_00.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_packunpack_rev_cty_00.json rename to michelson_vm/tests/data/e2e/e2e_packunpack_rev_cty_00.json diff --git a/tezos_vm/tests/data/e2e/e2e_packunpack_rev_cty_01.json b/michelson_vm/tests/data/e2e/e2e_packunpack_rev_cty_01.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_packunpack_rev_cty_01.json rename to michelson_vm/tests/data/e2e/e2e_packunpack_rev_cty_01.json diff --git a/tezos_vm/tests/data/e2e/e2e_pair_id_00.json b/michelson_vm/tests/data/e2e/e2e_pair_id_00.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_pair_id_00.json rename to michelson_vm/tests/data/e2e/e2e_pair_id_00.json diff --git a/tezos_vm/tests/data/e2e/e2e_pair_id_01.json b/michelson_vm/tests/data/e2e/e2e_pair_id_01.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_pair_id_01.json rename to michelson_vm/tests/data/e2e/e2e_pair_id_01.json diff --git a/tezos_vm/tests/data/e2e/e2e_pair_id_02.json b/michelson_vm/tests/data/e2e/e2e_pair_id_02.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_pair_id_02.json rename to michelson_vm/tests/data/e2e/e2e_pair_id_02.json diff --git a/tezos_vm/tests/data/e2e/e2e_pair_id_03.json b/michelson_vm/tests/data/e2e/e2e_pair_id_03.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_pair_id_03.json rename to michelson_vm/tests/data/e2e/e2e_pair_id_03.json diff --git a/tezos_vm/tests/data/e2e/e2e_pexec_00.json b/michelson_vm/tests/data/e2e/e2e_pexec_00.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_pexec_00.json rename to michelson_vm/tests/data/e2e/e2e_pexec_00.json diff --git a/tezos_vm/tests/data/e2e/e2e_pexec_2_00.json b/michelson_vm/tests/data/e2e/e2e_pexec_2_00.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_pexec_2_00.json rename to michelson_vm/tests/data/e2e/e2e_pexec_2_00.json diff --git a/tezos_vm/tests/data/e2e/e2e_ret_int_00.json b/michelson_vm/tests/data/e2e/e2e_ret_int_00.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_ret_int_00.json rename to michelson_vm/tests/data/e2e/e2e_ret_int_00.json diff --git a/tezos_vm/tests/data/e2e/e2e_reverse_00.json b/michelson_vm/tests/data/e2e/e2e_reverse_00.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_reverse_00.json rename to michelson_vm/tests/data/e2e/e2e_reverse_00.json diff --git a/tezos_vm/tests/data/e2e/e2e_reverse_01.json b/michelson_vm/tests/data/e2e/e2e_reverse_01.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_reverse_01.json rename to michelson_vm/tests/data/e2e/e2e_reverse_01.json diff --git a/tezos_vm/tests/data/e2e/e2e_reverse_loop_00.json b/michelson_vm/tests/data/e2e/e2e_reverse_loop_00.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_reverse_loop_00.json rename to michelson_vm/tests/data/e2e/e2e_reverse_loop_00.json diff --git a/tezos_vm/tests/data/e2e/e2e_reverse_loop_01.json b/michelson_vm/tests/data/e2e/e2e_reverse_loop_01.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_reverse_loop_01.json rename to michelson_vm/tests/data/e2e/e2e_reverse_loop_01.json diff --git a/tezos_vm/tests/data/e2e/e2e_self_address_00.json b/michelson_vm/tests/data/e2e/e2e_self_address_00.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_self_address_00.json rename to michelson_vm/tests/data/e2e/e2e_self_address_00.json diff --git a/tezos_vm/tests/data/e2e/e2e_self_with_default_entrypoint_00.json b/michelson_vm/tests/data/e2e/e2e_self_with_default_entrypoint_00.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_self_with_default_entrypoint_00.json rename to michelson_vm/tests/data/e2e/e2e_self_with_default_entrypoint_00.json diff --git a/tezos_vm/tests/data/e2e/e2e_self_with_entrypoint_00.json b/michelson_vm/tests/data/e2e/e2e_self_with_entrypoint_00.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_self_with_entrypoint_00.json rename to michelson_vm/tests/data/e2e/e2e_self_with_entrypoint_00.json diff --git a/tezos_vm/tests/data/e2e/e2e_set_car_00.json b/michelson_vm/tests/data/e2e/e2e_set_car_00.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_set_car_00.json rename to michelson_vm/tests/data/e2e/e2e_set_car_00.json diff --git a/tezos_vm/tests/data/e2e/e2e_set_car_01.json b/michelson_vm/tests/data/e2e/e2e_set_car_01.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_set_car_01.json rename to michelson_vm/tests/data/e2e/e2e_set_car_01.json diff --git a/tezos_vm/tests/data/e2e/e2e_set_car_02.json b/michelson_vm/tests/data/e2e/e2e_set_car_02.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_set_car_02.json rename to michelson_vm/tests/data/e2e/e2e_set_car_02.json diff --git a/tezos_vm/tests/data/e2e/e2e_set_cdr_00.json b/michelson_vm/tests/data/e2e/e2e_set_cdr_00.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_set_cdr_00.json rename to michelson_vm/tests/data/e2e/e2e_set_cdr_00.json diff --git a/tezos_vm/tests/data/e2e/e2e_set_cdr_01.json b/michelson_vm/tests/data/e2e/e2e_set_cdr_01.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_set_cdr_01.json rename to michelson_vm/tests/data/e2e/e2e_set_cdr_01.json diff --git a/tezos_vm/tests/data/e2e/e2e_set_cdr_02.json b/michelson_vm/tests/data/e2e/e2e_set_cdr_02.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_set_cdr_02.json rename to michelson_vm/tests/data/e2e/e2e_set_cdr_02.json diff --git a/tezos_vm/tests/data/e2e/e2e_set_id_00.json b/michelson_vm/tests/data/e2e/e2e_set_id_00.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_set_id_00.json rename to michelson_vm/tests/data/e2e/e2e_set_id_00.json diff --git a/tezos_vm/tests/data/e2e/e2e_set_id_01.json b/michelson_vm/tests/data/e2e/e2e_set_id_01.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_set_id_01.json rename to michelson_vm/tests/data/e2e/e2e_set_id_01.json diff --git a/tezos_vm/tests/data/e2e/e2e_set_id_02.json b/michelson_vm/tests/data/e2e/e2e_set_id_02.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_set_id_02.json rename to michelson_vm/tests/data/e2e/e2e_set_id_02.json diff --git a/tezos_vm/tests/data/e2e/e2e_set_iter_00.json b/michelson_vm/tests/data/e2e/e2e_set_iter_00.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_set_iter_00.json rename to michelson_vm/tests/data/e2e/e2e_set_iter_00.json diff --git a/tezos_vm/tests/data/e2e/e2e_set_iter_01.json b/michelson_vm/tests/data/e2e/e2e_set_iter_01.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_set_iter_01.json rename to michelson_vm/tests/data/e2e/e2e_set_iter_01.json diff --git a/tezos_vm/tests/data/e2e/e2e_set_iter_02.json b/michelson_vm/tests/data/e2e/e2e_set_iter_02.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_set_iter_02.json rename to michelson_vm/tests/data/e2e/e2e_set_iter_02.json diff --git a/tezos_vm/tests/data/e2e/e2e_set_member_00.json b/michelson_vm/tests/data/e2e/e2e_set_member_00.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_set_member_00.json rename to michelson_vm/tests/data/e2e/e2e_set_member_00.json diff --git a/tezos_vm/tests/data/e2e/e2e_set_member_01.json b/michelson_vm/tests/data/e2e/e2e_set_member_01.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_set_member_01.json rename to michelson_vm/tests/data/e2e/e2e_set_member_01.json diff --git a/tezos_vm/tests/data/e2e/e2e_set_member_02.json b/michelson_vm/tests/data/e2e/e2e_set_member_02.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_set_member_02.json rename to michelson_vm/tests/data/e2e/e2e_set_member_02.json diff --git a/tezos_vm/tests/data/e2e/e2e_set_size_00.json b/michelson_vm/tests/data/e2e/e2e_set_size_00.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_set_size_00.json rename to michelson_vm/tests/data/e2e/e2e_set_size_00.json diff --git a/tezos_vm/tests/data/e2e/e2e_set_size_01.json b/michelson_vm/tests/data/e2e/e2e_set_size_01.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_set_size_01.json rename to michelson_vm/tests/data/e2e/e2e_set_size_01.json diff --git a/tezos_vm/tests/data/e2e/e2e_set_size_02.json b/michelson_vm/tests/data/e2e/e2e_set_size_02.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_set_size_02.json rename to michelson_vm/tests/data/e2e/e2e_set_size_02.json diff --git a/tezos_vm/tests/data/e2e/e2e_set_size_03.json b/michelson_vm/tests/data/e2e/e2e_set_size_03.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_set_size_03.json rename to michelson_vm/tests/data/e2e/e2e_set_size_03.json diff --git a/tezos_vm/tests/data/e2e/e2e_shifts_00.json b/michelson_vm/tests/data/e2e/e2e_shifts_00.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_shifts_00.json rename to michelson_vm/tests/data/e2e/e2e_shifts_00.json diff --git a/tezos_vm/tests/data/e2e/e2e_shifts_01.json b/michelson_vm/tests/data/e2e/e2e_shifts_01.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_shifts_01.json rename to michelson_vm/tests/data/e2e/e2e_shifts_01.json diff --git a/tezos_vm/tests/data/e2e/e2e_shifts_02.json b/michelson_vm/tests/data/e2e/e2e_shifts_02.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_shifts_02.json rename to michelson_vm/tests/data/e2e/e2e_shifts_02.json diff --git a/tezos_vm/tests/data/e2e/e2e_shifts_03.json b/michelson_vm/tests/data/e2e/e2e_shifts_03.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_shifts_03.json rename to michelson_vm/tests/data/e2e/e2e_shifts_03.json diff --git a/tezos_vm/tests/data/e2e/e2e_shifts_04.json b/michelson_vm/tests/data/e2e/e2e_shifts_04.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_shifts_04.json rename to michelson_vm/tests/data/e2e/e2e_shifts_04.json diff --git a/tezos_vm/tests/data/e2e/e2e_shifts_05.json b/michelson_vm/tests/data/e2e/e2e_shifts_05.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_shifts_05.json rename to michelson_vm/tests/data/e2e/e2e_shifts_05.json diff --git a/tezos_vm/tests/data/e2e/e2e_shifts_06.json b/michelson_vm/tests/data/e2e/e2e_shifts_06.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_shifts_06.json rename to michelson_vm/tests/data/e2e/e2e_shifts_06.json diff --git a/tezos_vm/tests/data/e2e/e2e_shifts_07.json b/michelson_vm/tests/data/e2e/e2e_shifts_07.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_shifts_07.json rename to michelson_vm/tests/data/e2e/e2e_shifts_07.json diff --git a/tezos_vm/tests/data/e2e/e2e_shifts_08.json b/michelson_vm/tests/data/e2e/e2e_shifts_08.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_shifts_08.json rename to michelson_vm/tests/data/e2e/e2e_shifts_08.json diff --git a/tezos_vm/tests/data/e2e/e2e_shifts_09.json b/michelson_vm/tests/data/e2e/e2e_shifts_09.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_shifts_09.json rename to michelson_vm/tests/data/e2e/e2e_shifts_09.json diff --git a/tezos_vm/tests/data/e2e/e2e_slice_00.json b/michelson_vm/tests/data/e2e/e2e_slice_00.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_slice_00.json rename to michelson_vm/tests/data/e2e/e2e_slice_00.json diff --git a/tezos_vm/tests/data/e2e/e2e_slice_01.json b/michelson_vm/tests/data/e2e/e2e_slice_01.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_slice_01.json rename to michelson_vm/tests/data/e2e/e2e_slice_01.json diff --git a/tezos_vm/tests/data/e2e/e2e_slice_02.json b/michelson_vm/tests/data/e2e/e2e_slice_02.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_slice_02.json rename to michelson_vm/tests/data/e2e/e2e_slice_02.json diff --git a/tezos_vm/tests/data/e2e/e2e_slice_03.json b/michelson_vm/tests/data/e2e/e2e_slice_03.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_slice_03.json rename to michelson_vm/tests/data/e2e/e2e_slice_03.json diff --git a/tezos_vm/tests/data/e2e/e2e_slice_04.json b/michelson_vm/tests/data/e2e/e2e_slice_04.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_slice_04.json rename to michelson_vm/tests/data/e2e/e2e_slice_04.json diff --git a/tezos_vm/tests/data/e2e/e2e_slice_05.json b/michelson_vm/tests/data/e2e/e2e_slice_05.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_slice_05.json rename to michelson_vm/tests/data/e2e/e2e_slice_05.json diff --git a/tezos_vm/tests/data/e2e/e2e_slice_06.json b/michelson_vm/tests/data/e2e/e2e_slice_06.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_slice_06.json rename to michelson_vm/tests/data/e2e/e2e_slice_06.json diff --git a/tezos_vm/tests/data/e2e/e2e_slice_07.json b/michelson_vm/tests/data/e2e/e2e_slice_07.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_slice_07.json rename to michelson_vm/tests/data/e2e/e2e_slice_07.json diff --git a/tezos_vm/tests/data/e2e/e2e_slice_bytes_00.json b/michelson_vm/tests/data/e2e/e2e_slice_bytes_00.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_slice_bytes_00.json rename to michelson_vm/tests/data/e2e/e2e_slice_bytes_00.json diff --git a/tezos_vm/tests/data/e2e/e2e_slice_bytes_01.json b/michelson_vm/tests/data/e2e/e2e_slice_bytes_01.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_slice_bytes_01.json rename to michelson_vm/tests/data/e2e/e2e_slice_bytes_01.json diff --git a/tezos_vm/tests/data/e2e/e2e_slice_bytes_02.json b/michelson_vm/tests/data/e2e/e2e_slice_bytes_02.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_slice_bytes_02.json rename to michelson_vm/tests/data/e2e/e2e_slice_bytes_02.json diff --git a/tezos_vm/tests/data/e2e/e2e_slice_bytes_03.json b/michelson_vm/tests/data/e2e/e2e_slice_bytes_03.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_slice_bytes_03.json rename to michelson_vm/tests/data/e2e/e2e_slice_bytes_03.json diff --git a/tezos_vm/tests/data/e2e/e2e_slice_bytes_04.json b/michelson_vm/tests/data/e2e/e2e_slice_bytes_04.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_slice_bytes_04.json rename to michelson_vm/tests/data/e2e/e2e_slice_bytes_04.json diff --git a/tezos_vm/tests/data/e2e/e2e_slice_bytes_05.json b/michelson_vm/tests/data/e2e/e2e_slice_bytes_05.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_slice_bytes_05.json rename to michelson_vm/tests/data/e2e/e2e_slice_bytes_05.json diff --git a/tezos_vm/tests/data/e2e/e2e_slice_bytes_06.json b/michelson_vm/tests/data/e2e/e2e_slice_bytes_06.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_slice_bytes_06.json rename to michelson_vm/tests/data/e2e/e2e_slice_bytes_06.json diff --git a/tezos_vm/tests/data/e2e/e2e_slice_bytes_07.json b/michelson_vm/tests/data/e2e/e2e_slice_bytes_07.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_slice_bytes_07.json rename to michelson_vm/tests/data/e2e/e2e_slice_bytes_07.json diff --git a/tezos_vm/tests/data/e2e/e2e_str_id_00.json b/michelson_vm/tests/data/e2e/e2e_str_id_00.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_str_id_00.json rename to michelson_vm/tests/data/e2e/e2e_str_id_00.json diff --git a/tezos_vm/tests/data/e2e/e2e_str_id_01.json b/michelson_vm/tests/data/e2e/e2e_str_id_01.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_str_id_01.json rename to michelson_vm/tests/data/e2e/e2e_str_id_01.json diff --git a/tezos_vm/tests/data/e2e/e2e_sub_timestamp_delta_00.json b/michelson_vm/tests/data/e2e/e2e_sub_timestamp_delta_00.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_sub_timestamp_delta_00.json rename to michelson_vm/tests/data/e2e/e2e_sub_timestamp_delta_00.json diff --git a/tezos_vm/tests/data/e2e/e2e_sub_timestamp_delta_01.json b/michelson_vm/tests/data/e2e/e2e_sub_timestamp_delta_01.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_sub_timestamp_delta_01.json rename to michelson_vm/tests/data/e2e/e2e_sub_timestamp_delta_01.json diff --git a/tezos_vm/tests/data/e2e/e2e_sub_timestamp_delta_02.json b/michelson_vm/tests/data/e2e/e2e_sub_timestamp_delta_02.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_sub_timestamp_delta_02.json rename to michelson_vm/tests/data/e2e/e2e_sub_timestamp_delta_02.json diff --git a/tezos_vm/tests/data/e2e/e2e_tez_add_sub_00.json b/michelson_vm/tests/data/e2e/e2e_tez_add_sub_00.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_tez_add_sub_00.json rename to michelson_vm/tests/data/e2e/e2e_tez_add_sub_00.json diff --git a/tezos_vm/tests/data/e2e/e2e_tez_add_sub_01.json b/michelson_vm/tests/data/e2e/e2e_tez_add_sub_01.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_tez_add_sub_01.json rename to michelson_vm/tests/data/e2e/e2e_tez_add_sub_01.json diff --git a/tezos_vm/tests/data/e2e/e2e_tez_add_sub_02.json b/michelson_vm/tests/data/e2e/e2e_tez_add_sub_02.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_tez_add_sub_02.json rename to michelson_vm/tests/data/e2e/e2e_tez_add_sub_02.json diff --git a/tezos_vm/tests/data/e2e/e2e_tez_add_sub_03.json b/michelson_vm/tests/data/e2e/e2e_tez_add_sub_03.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_tez_add_sub_03.json rename to michelson_vm/tests/data/e2e/e2e_tez_add_sub_03.json diff --git a/tezos_vm/tests/data/e2e/e2e_uncomb_00.json b/michelson_vm/tests/data/e2e/e2e_uncomb_00.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_uncomb_00.json rename to michelson_vm/tests/data/e2e/e2e_uncomb_00.json diff --git a/tezos_vm/tests/data/e2e/e2e_unpair_00.json b/michelson_vm/tests/data/e2e/e2e_unpair_00.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_unpair_00.json rename to michelson_vm/tests/data/e2e/e2e_unpair_00.json diff --git a/tezos_vm/tests/data/e2e/e2e_xor_00.json b/michelson_vm/tests/data/e2e/e2e_xor_00.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_xor_00.json rename to michelson_vm/tests/data/e2e/e2e_xor_00.json diff --git a/tezos_vm/tests/data/e2e/e2e_xor_01.json b/michelson_vm/tests/data/e2e/e2e_xor_01.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_xor_01.json rename to michelson_vm/tests/data/e2e/e2e_xor_01.json diff --git a/tezos_vm/tests/data/e2e/e2e_xor_02.json b/michelson_vm/tests/data/e2e/e2e_xor_02.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_xor_02.json rename to michelson_vm/tests/data/e2e/e2e_xor_02.json diff --git a/tezos_vm/tests/data/e2e/e2e_xor_03.json b/michelson_vm/tests/data/e2e/e2e_xor_03.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_xor_03.json rename to michelson_vm/tests/data/e2e/e2e_xor_03.json diff --git a/tezos_vm/tests/data/e2e/e2e_xor_04.json b/michelson_vm/tests/data/e2e/e2e_xor_04.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_xor_04.json rename to michelson_vm/tests/data/e2e/e2e_xor_04.json diff --git a/tezos_vm/tests/data/e2e/e2e_xor_05.json b/michelson_vm/tests/data/e2e/e2e_xor_05.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_xor_05.json rename to michelson_vm/tests/data/e2e/e2e_xor_05.json diff --git a/tezos_vm/tests/data/e2e/e2e_xor_06.json b/michelson_vm/tests/data/e2e/e2e_xor_06.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_xor_06.json rename to michelson_vm/tests/data/e2e/e2e_xor_06.json diff --git a/tezos_vm/tests/data/e2e/e2e_xor_07.json b/michelson_vm/tests/data/e2e/e2e_xor_07.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_xor_07.json rename to michelson_vm/tests/data/e2e/e2e_xor_07.json diff --git a/tezos_vm/tests/data/e2e/e2e_xor_08.json b/michelson_vm/tests/data/e2e/e2e_xor_08.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_xor_08.json rename to michelson_vm/tests/data/e2e/e2e_xor_08.json diff --git a/tezos_vm/tests/data/e2e/e2e_xor_09.json b/michelson_vm/tests/data/e2e/e2e_xor_09.json similarity index 100% rename from tezos_vm/tests/data/e2e/e2e_xor_09.json rename to michelson_vm/tests/data/e2e/e2e_xor_09.json diff --git a/tezos_vm/tests/data/scripts/abs.json b/michelson_vm/tests/data/scripts/abs.json similarity index 100% rename from tezos_vm/tests/data/scripts/abs.json rename to michelson_vm/tests/data/scripts/abs.json diff --git a/tezos_vm/tests/data/scripts/add.json b/michelson_vm/tests/data/scripts/add.json similarity index 100% rename from tezos_vm/tests/data/scripts/add.json rename to michelson_vm/tests/data/scripts/add.json diff --git a/tezos_vm/tests/data/scripts/add_bls12_381_fr.json b/michelson_vm/tests/data/scripts/add_bls12_381_fr.json similarity index 100% rename from tezos_vm/tests/data/scripts/add_bls12_381_fr.json rename to michelson_vm/tests/data/scripts/add_bls12_381_fr.json diff --git a/tezos_vm/tests/data/scripts/add_bls12_381_g1.json b/michelson_vm/tests/data/scripts/add_bls12_381_g1.json similarity index 100% rename from tezos_vm/tests/data/scripts/add_bls12_381_g1.json rename to michelson_vm/tests/data/scripts/add_bls12_381_g1.json diff --git a/tezos_vm/tests/data/scripts/add_bls12_381_g2.json b/michelson_vm/tests/data/scripts/add_bls12_381_g2.json similarity index 100% rename from tezos_vm/tests/data/scripts/add_bls12_381_g2.json rename to michelson_vm/tests/data/scripts/add_bls12_381_g2.json diff --git a/tezos_vm/tests/data/scripts/add_delta_timestamp.json b/michelson_vm/tests/data/scripts/add_delta_timestamp.json similarity index 100% rename from tezos_vm/tests/data/scripts/add_delta_timestamp.json rename to michelson_vm/tests/data/scripts/add_delta_timestamp.json diff --git a/tezos_vm/tests/data/scripts/add_timestamp_delta.json b/michelson_vm/tests/data/scripts/add_timestamp_delta.json similarity index 100% rename from tezos_vm/tests/data/scripts/add_timestamp_delta.json rename to michelson_vm/tests/data/scripts/add_timestamp_delta.json diff --git a/tezos_vm/tests/data/scripts/address.json b/michelson_vm/tests/data/scripts/address.json similarity index 100% rename from tezos_vm/tests/data/scripts/address.json rename to michelson_vm/tests/data/scripts/address.json diff --git a/tezos_vm/tests/data/scripts/amount_after_fib_view.json b/michelson_vm/tests/data/scripts/amount_after_fib_view.json similarity index 100% rename from tezos_vm/tests/data/scripts/amount_after_fib_view.json rename to michelson_vm/tests/data/scripts/amount_after_fib_view.json diff --git a/tezos_vm/tests/data/scripts/amount_after_nonexistent_view.json b/michelson_vm/tests/data/scripts/amount_after_nonexistent_view.json similarity index 100% rename from tezos_vm/tests/data/scripts/amount_after_nonexistent_view.json rename to michelson_vm/tests/data/scripts/amount_after_nonexistent_view.json diff --git a/tezos_vm/tests/data/scripts/amount_after_view.json b/michelson_vm/tests/data/scripts/amount_after_view.json similarity index 100% rename from tezos_vm/tests/data/scripts/amount_after_view.json rename to michelson_vm/tests/data/scripts/amount_after_view.json diff --git a/tezos_vm/tests/data/scripts/and.json b/michelson_vm/tests/data/scripts/and.json similarity index 100% rename from tezos_vm/tests/data/scripts/and.json rename to michelson_vm/tests/data/scripts/and.json diff --git a/tezos_vm/tests/data/scripts/and_binary.json b/michelson_vm/tests/data/scripts/and_binary.json similarity index 100% rename from tezos_vm/tests/data/scripts/and_binary.json rename to michelson_vm/tests/data/scripts/and_binary.json diff --git a/tezos_vm/tests/data/scripts/and_logical_1.json b/michelson_vm/tests/data/scripts/and_logical_1.json similarity index 100% rename from tezos_vm/tests/data/scripts/and_logical_1.json rename to michelson_vm/tests/data/scripts/and_logical_1.json diff --git a/tezos_vm/tests/data/scripts/balance.json b/michelson_vm/tests/data/scripts/balance.json similarity index 100% rename from tezos_vm/tests/data/scripts/balance.json rename to michelson_vm/tests/data/scripts/balance.json diff --git a/tezos_vm/tests/data/scripts/balance_after_fib_view.json b/michelson_vm/tests/data/scripts/balance_after_fib_view.json similarity index 100% rename from tezos_vm/tests/data/scripts/balance_after_fib_view.json rename to michelson_vm/tests/data/scripts/balance_after_fib_view.json diff --git a/tezos_vm/tests/data/scripts/balance_after_nonexistent_view.json b/michelson_vm/tests/data/scripts/balance_after_nonexistent_view.json similarity index 100% rename from tezos_vm/tests/data/scripts/balance_after_nonexistent_view.json rename to michelson_vm/tests/data/scripts/balance_after_nonexistent_view.json diff --git a/tezos_vm/tests/data/scripts/balance_after_view.json b/michelson_vm/tests/data/scripts/balance_after_view.json similarity index 100% rename from tezos_vm/tests/data/scripts/balance_after_view.json rename to michelson_vm/tests/data/scripts/balance_after_view.json diff --git a/tezos_vm/tests/data/scripts/big_map_mem_nat.json b/michelson_vm/tests/data/scripts/big_map_mem_nat.json similarity index 100% rename from tezos_vm/tests/data/scripts/big_map_mem_nat.json rename to michelson_vm/tests/data/scripts/big_map_mem_nat.json diff --git a/tezos_vm/tests/data/scripts/big_map_mem_string.json b/michelson_vm/tests/data/scripts/big_map_mem_string.json similarity index 100% rename from tezos_vm/tests/data/scripts/big_map_mem_string.json rename to michelson_vm/tests/data/scripts/big_map_mem_string.json diff --git a/tezos_l2/tests/data/scripts/big_map_to_self.json b/michelson_vm/tests/data/scripts/big_map_to_self.json similarity index 100% rename from tezos_l2/tests/data/scripts/big_map_to_self.json rename to michelson_vm/tests/data/scripts/big_map_to_self.json diff --git a/tezos_vm/tests/data/scripts/bls12_381_fr_push_bytes_not_padded.json b/michelson_vm/tests/data/scripts/bls12_381_fr_push_bytes_not_padded.json similarity index 100% rename from tezos_vm/tests/data/scripts/bls12_381_fr_push_bytes_not_padded.json rename to michelson_vm/tests/data/scripts/bls12_381_fr_push_bytes_not_padded.json diff --git a/tezos_vm/tests/data/scripts/bls12_381_fr_push_nat.json b/michelson_vm/tests/data/scripts/bls12_381_fr_push_nat.json similarity index 100% rename from tezos_vm/tests/data/scripts/bls12_381_fr_push_nat.json rename to michelson_vm/tests/data/scripts/bls12_381_fr_push_nat.json diff --git a/tezos_vm/tests/data/scripts/bls12_381_fr_to_int.json b/michelson_vm/tests/data/scripts/bls12_381_fr_to_int.json similarity index 100% rename from tezos_vm/tests/data/scripts/bls12_381_fr_to_int.json rename to michelson_vm/tests/data/scripts/bls12_381_fr_to_int.json diff --git a/tezos_vm/tests/data/scripts/bls12_381_fr_to_mutez.json b/michelson_vm/tests/data/scripts/bls12_381_fr_to_mutez.json similarity index 100% rename from tezos_vm/tests/data/scripts/bls12_381_fr_to_mutez.json rename to michelson_vm/tests/data/scripts/bls12_381_fr_to_mutez.json diff --git a/tezos_vm/tests/data/scripts/bls12_381_fr_z_int.json b/michelson_vm/tests/data/scripts/bls12_381_fr_z_int.json similarity index 100% rename from tezos_vm/tests/data/scripts/bls12_381_fr_z_int.json rename to michelson_vm/tests/data/scripts/bls12_381_fr_z_int.json diff --git a/tezos_vm/tests/data/scripts/bls12_381_fr_z_nat.json b/michelson_vm/tests/data/scripts/bls12_381_fr_z_nat.json similarity index 100% rename from tezos_vm/tests/data/scripts/bls12_381_fr_z_nat.json rename to michelson_vm/tests/data/scripts/bls12_381_fr_z_nat.json diff --git a/tezos_vm/tests/data/scripts/bls12_381_z_fr_int.json b/michelson_vm/tests/data/scripts/bls12_381_z_fr_int.json similarity index 100% rename from tezos_vm/tests/data/scripts/bls12_381_z_fr_int.json rename to michelson_vm/tests/data/scripts/bls12_381_z_fr_int.json diff --git a/tezos_vm/tests/data/scripts/bls12_381_z_fr_nat.json b/michelson_vm/tests/data/scripts/bls12_381_z_fr_nat.json similarity index 100% rename from tezos_vm/tests/data/scripts/bls12_381_z_fr_nat.json rename to michelson_vm/tests/data/scripts/bls12_381_z_fr_nat.json diff --git a/tezos_vm/tests/data/scripts/bytes.json b/michelson_vm/tests/data/scripts/bytes.json similarity index 100% rename from tezos_vm/tests/data/scripts/bytes.json rename to michelson_vm/tests/data/scripts/bytes.json diff --git a/tezos_vm/tests/data/scripts/car.json b/michelson_vm/tests/data/scripts/car.json similarity index 100% rename from tezos_vm/tests/data/scripts/car.json rename to michelson_vm/tests/data/scripts/car.json diff --git a/tezos_vm/tests/data/scripts/cdr.json b/michelson_vm/tests/data/scripts/cdr.json similarity index 100% rename from tezos_vm/tests/data/scripts/cdr.json rename to michelson_vm/tests/data/scripts/cdr.json diff --git a/tezos_vm/tests/data/scripts/chain_id.json b/michelson_vm/tests/data/scripts/chain_id.json similarity index 100% rename from tezos_vm/tests/data/scripts/chain_id.json rename to michelson_vm/tests/data/scripts/chain_id.json diff --git a/tezos_vm/tests/data/scripts/chain_id_store.json b/michelson_vm/tests/data/scripts/chain_id_store.json similarity index 100% rename from tezos_vm/tests/data/scripts/chain_id_store.json rename to michelson_vm/tests/data/scripts/chain_id_store.json diff --git a/tezos_vm/tests/data/scripts/check_signature.json b/michelson_vm/tests/data/scripts/check_signature.json similarity index 100% rename from tezos_vm/tests/data/scripts/check_signature.json rename to michelson_vm/tests/data/scripts/check_signature.json diff --git a/tezos_vm/tests/data/scripts/comb-get.json b/michelson_vm/tests/data/scripts/comb-get.json similarity index 100% rename from tezos_vm/tests/data/scripts/comb-get.json rename to michelson_vm/tests/data/scripts/comb-get.json diff --git a/tezos_vm/tests/data/scripts/comb-literals.json b/michelson_vm/tests/data/scripts/comb-literals.json similarity index 100% rename from tezos_vm/tests/data/scripts/comb-literals.json rename to michelson_vm/tests/data/scripts/comb-literals.json diff --git a/tezos_vm/tests/data/scripts/comb-set-2.json b/michelson_vm/tests/data/scripts/comb-set-2.json similarity index 100% rename from tezos_vm/tests/data/scripts/comb-set-2.json rename to michelson_vm/tests/data/scripts/comb-set-2.json diff --git a/tezos_vm/tests/data/scripts/comb-set.json b/michelson_vm/tests/data/scripts/comb-set.json similarity index 100% rename from tezos_vm/tests/data/scripts/comb-set.json rename to michelson_vm/tests/data/scripts/comb-set.json diff --git a/tezos_vm/tests/data/scripts/comb.json b/michelson_vm/tests/data/scripts/comb.json similarity index 100% rename from tezos_vm/tests/data/scripts/comb.json rename to michelson_vm/tests/data/scripts/comb.json diff --git a/tezos_vm/tests/data/scripts/compare.json b/michelson_vm/tests/data/scripts/compare.json similarity index 100% rename from tezos_vm/tests/data/scripts/compare.json rename to michelson_vm/tests/data/scripts/compare.json diff --git a/tezos_vm/tests/data/scripts/compare_big_type.json b/michelson_vm/tests/data/scripts/compare_big_type.json similarity index 100% rename from tezos_vm/tests/data/scripts/compare_big_type.json rename to michelson_vm/tests/data/scripts/compare_big_type.json diff --git a/tezos_vm/tests/data/scripts/compare_big_type2.json b/michelson_vm/tests/data/scripts/compare_big_type2.json similarity index 100% rename from tezos_vm/tests/data/scripts/compare_big_type2.json rename to michelson_vm/tests/data/scripts/compare_big_type2.json diff --git a/tezos_vm/tests/data/scripts/comparisons.json b/michelson_vm/tests/data/scripts/comparisons.json similarity index 100% rename from tezos_vm/tests/data/scripts/comparisons.json rename to michelson_vm/tests/data/scripts/comparisons.json diff --git a/tezos_vm/tests/data/scripts/concat_hello.json b/michelson_vm/tests/data/scripts/concat_hello.json similarity index 100% rename from tezos_vm/tests/data/scripts/concat_hello.json rename to michelson_vm/tests/data/scripts/concat_hello.json diff --git a/tezos_vm/tests/data/scripts/concat_hello_bytes.json b/michelson_vm/tests/data/scripts/concat_hello_bytes.json similarity index 100% rename from tezos_vm/tests/data/scripts/concat_hello_bytes.json rename to michelson_vm/tests/data/scripts/concat_hello_bytes.json diff --git a/tezos_vm/tests/data/scripts/concat_list.json b/michelson_vm/tests/data/scripts/concat_list.json similarity index 100% rename from tezos_vm/tests/data/scripts/concat_list.json rename to michelson_vm/tests/data/scripts/concat_list.json diff --git a/tezos_vm/tests/data/scripts/cons.json b/michelson_vm/tests/data/scripts/cons.json similarity index 100% rename from tezos_vm/tests/data/scripts/cons.json rename to michelson_vm/tests/data/scripts/cons.json diff --git a/tezos_vm/tests/data/scripts/contains_all.json b/michelson_vm/tests/data/scripts/contains_all.json similarity index 100% rename from tezos_vm/tests/data/scripts/contains_all.json rename to michelson_vm/tests/data/scripts/contains_all.json diff --git a/tezos_l2/tests/data/scripts/contract.json b/michelson_vm/tests/data/scripts/contract.json similarity index 100% rename from tezos_l2/tests/data/scripts/contract.json rename to michelson_vm/tests/data/scripts/contract.json diff --git a/tezos_vm/tests/data/scripts/create_contract.json b/michelson_vm/tests/data/scripts/create_contract.json similarity index 100% rename from tezos_vm/tests/data/scripts/create_contract.json rename to michelson_vm/tests/data/scripts/create_contract.json diff --git a/tezos_vm/tests/data/scripts/create_contract_rootname.json b/michelson_vm/tests/data/scripts/create_contract_rootname.json similarity index 100% rename from tezos_vm/tests/data/scripts/create_contract_rootname.json rename to michelson_vm/tests/data/scripts/create_contract_rootname.json diff --git a/tezos_vm/tests/data/scripts/create_contract_rootname_alt.json b/michelson_vm/tests/data/scripts/create_contract_rootname_alt.json similarity index 100% rename from tezos_vm/tests/data/scripts/create_contract_rootname_alt.json rename to michelson_vm/tests/data/scripts/create_contract_rootname_alt.json diff --git a/tezos_vm/tests/data/scripts/create_contract_with_view.json b/michelson_vm/tests/data/scripts/create_contract_with_view.json similarity index 100% rename from tezos_vm/tests/data/scripts/create_contract_with_view.json rename to michelson_vm/tests/data/scripts/create_contract_with_view.json diff --git a/tezos_vm/tests/data/scripts/diff_timestamps.json b/michelson_vm/tests/data/scripts/diff_timestamps.json similarity index 100% rename from tezos_vm/tests/data/scripts/diff_timestamps.json rename to michelson_vm/tests/data/scripts/diff_timestamps.json diff --git a/tezos_vm/tests/data/scripts/dig_eq.json b/michelson_vm/tests/data/scripts/dig_eq.json similarity index 100% rename from tezos_vm/tests/data/scripts/dig_eq.json rename to michelson_vm/tests/data/scripts/dig_eq.json diff --git a/tezos_vm/tests/data/scripts/dign.json b/michelson_vm/tests/data/scripts/dign.json similarity index 100% rename from tezos_vm/tests/data/scripts/dign.json rename to michelson_vm/tests/data/scripts/dign.json diff --git a/tezos_vm/tests/data/scripts/dip.json b/michelson_vm/tests/data/scripts/dip.json similarity index 100% rename from tezos_vm/tests/data/scripts/dip.json rename to michelson_vm/tests/data/scripts/dip.json diff --git a/tezos_vm/tests/data/scripts/dipn.json b/michelson_vm/tests/data/scripts/dipn.json similarity index 100% rename from tezos_vm/tests/data/scripts/dipn.json rename to michelson_vm/tests/data/scripts/dipn.json diff --git a/tezos_vm/tests/data/scripts/dropn.json b/michelson_vm/tests/data/scripts/dropn.json similarity index 100% rename from tezos_vm/tests/data/scripts/dropn.json rename to michelson_vm/tests/data/scripts/dropn.json diff --git a/tezos_vm/tests/data/scripts/dugn.json b/michelson_vm/tests/data/scripts/dugn.json similarity index 100% rename from tezos_vm/tests/data/scripts/dugn.json rename to michelson_vm/tests/data/scripts/dugn.json diff --git a/tezos_vm/tests/data/scripts/dup-n.json b/michelson_vm/tests/data/scripts/dup-n.json similarity index 100% rename from tezos_vm/tests/data/scripts/dup-n.json rename to michelson_vm/tests/data/scripts/dup-n.json diff --git a/tezos_vm/tests/data/scripts/ediv.json b/michelson_vm/tests/data/scripts/ediv.json similarity index 100% rename from tezos_vm/tests/data/scripts/ediv.json rename to michelson_vm/tests/data/scripts/ediv.json diff --git a/tezos_vm/tests/data/scripts/ediv_mutez.json b/michelson_vm/tests/data/scripts/ediv_mutez.json similarity index 100% rename from tezos_vm/tests/data/scripts/ediv_mutez.json rename to michelson_vm/tests/data/scripts/ediv_mutez.json diff --git a/tezos_vm/tests/data/scripts/emit.json b/michelson_vm/tests/data/scripts/emit.json similarity index 100% rename from tezos_vm/tests/data/scripts/emit.json rename to michelson_vm/tests/data/scripts/emit.json diff --git a/tezos_vm/tests/data/scripts/empty_map.json b/michelson_vm/tests/data/scripts/empty_map.json similarity index 100% rename from tezos_vm/tests/data/scripts/empty_map.json rename to michelson_vm/tests/data/scripts/empty_map.json diff --git a/tezos_vm/tests/data/scripts/exec_concat.json b/michelson_vm/tests/data/scripts/exec_concat.json similarity index 100% rename from tezos_vm/tests/data/scripts/exec_concat.json rename to michelson_vm/tests/data/scripts/exec_concat.json diff --git a/tezos_vm/tests/data/scripts/fact.json b/michelson_vm/tests/data/scripts/fact.json similarity index 100% rename from tezos_vm/tests/data/scripts/fact.json rename to michelson_vm/tests/data/scripts/fact.json diff --git a/tezos_vm/tests/data/scripts/first.json b/michelson_vm/tests/data/scripts/first.json similarity index 100% rename from tezos_vm/tests/data/scripts/first.json rename to michelson_vm/tests/data/scripts/first.json diff --git a/tezos_vm/tests/data/scripts/get_and_update_big_map.json b/michelson_vm/tests/data/scripts/get_and_update_big_map.json similarity index 100% rename from tezos_vm/tests/data/scripts/get_and_update_big_map.json rename to michelson_vm/tests/data/scripts/get_and_update_big_map.json diff --git a/tezos_vm/tests/data/scripts/get_and_update_map.json b/michelson_vm/tests/data/scripts/get_and_update_map.json similarity index 100% rename from tezos_vm/tests/data/scripts/get_and_update_map.json rename to michelson_vm/tests/data/scripts/get_and_update_map.json diff --git a/tezos_vm/tests/data/scripts/get_big_map_value.json b/michelson_vm/tests/data/scripts/get_big_map_value.json similarity index 100% rename from tezos_vm/tests/data/scripts/get_big_map_value.json rename to michelson_vm/tests/data/scripts/get_big_map_value.json diff --git a/tezos_vm/tests/data/scripts/get_map_value.json b/michelson_vm/tests/data/scripts/get_map_value.json similarity index 100% rename from tezos_vm/tests/data/scripts/get_map_value.json rename to michelson_vm/tests/data/scripts/get_map_value.json diff --git a/tezos_vm/tests/data/scripts/hash_consistency_checker.json b/michelson_vm/tests/data/scripts/hash_consistency_checker.json similarity index 100% rename from tezos_vm/tests/data/scripts/hash_consistency_checker.json rename to michelson_vm/tests/data/scripts/hash_consistency_checker.json diff --git a/tezos_vm/tests/data/scripts/hash_key.json b/michelson_vm/tests/data/scripts/hash_key.json similarity index 100% rename from tezos_vm/tests/data/scripts/hash_key.json rename to michelson_vm/tests/data/scripts/hash_key.json diff --git a/tezos_vm/tests/data/scripts/hash_string.json b/michelson_vm/tests/data/scripts/hash_string.json similarity index 100% rename from tezos_vm/tests/data/scripts/hash_string.json rename to michelson_vm/tests/data/scripts/hash_string.json diff --git a/tezos_vm/tests/data/scripts/if.json b/michelson_vm/tests/data/scripts/if.json similarity index 100% rename from tezos_vm/tests/data/scripts/if.json rename to michelson_vm/tests/data/scripts/if.json diff --git a/tezos_vm/tests/data/scripts/if_some.json b/michelson_vm/tests/data/scripts/if_some.json similarity index 100% rename from tezos_vm/tests/data/scripts/if_some.json rename to michelson_vm/tests/data/scripts/if_some.json diff --git a/tezos_vm/tests/data/scripts/int.json b/michelson_vm/tests/data/scripts/int.json similarity index 100% rename from tezos_vm/tests/data/scripts/int.json rename to michelson_vm/tests/data/scripts/int.json diff --git a/tezos_vm/tests/data/scripts/iter_fail.json b/michelson_vm/tests/data/scripts/iter_fail.json similarity index 100% rename from tezos_vm/tests/data/scripts/iter_fail.json rename to michelson_vm/tests/data/scripts/iter_fail.json diff --git a/tezos_vm/tests/data/scripts/keccak.json b/michelson_vm/tests/data/scripts/keccak.json similarity index 100% rename from tezos_vm/tests/data/scripts/keccak.json rename to michelson_vm/tests/data/scripts/keccak.json diff --git a/tezos_vm/tests/data/scripts/left_right.json b/michelson_vm/tests/data/scripts/left_right.json similarity index 100% rename from tezos_vm/tests/data/scripts/left_right.json rename to michelson_vm/tests/data/scripts/left_right.json diff --git a/tezos_vm/tests/data/scripts/level.json b/michelson_vm/tests/data/scripts/level.json similarity index 100% rename from tezos_vm/tests/data/scripts/level.json rename to michelson_vm/tests/data/scripts/level.json diff --git a/tezos_vm/tests/data/scripts/list_concat.json b/michelson_vm/tests/data/scripts/list_concat.json similarity index 100% rename from tezos_vm/tests/data/scripts/list_concat.json rename to michelson_vm/tests/data/scripts/list_concat.json diff --git a/tezos_vm/tests/data/scripts/list_concat_bytes.json b/michelson_vm/tests/data/scripts/list_concat_bytes.json similarity index 100% rename from tezos_vm/tests/data/scripts/list_concat_bytes.json rename to michelson_vm/tests/data/scripts/list_concat_bytes.json diff --git a/tezos_vm/tests/data/scripts/list_id.json b/michelson_vm/tests/data/scripts/list_id.json similarity index 100% rename from tezos_vm/tests/data/scripts/list_id.json rename to michelson_vm/tests/data/scripts/list_id.json diff --git a/tezos_vm/tests/data/scripts/list_id_map.json b/michelson_vm/tests/data/scripts/list_id_map.json similarity index 100% rename from tezos_vm/tests/data/scripts/list_id_map.json rename to michelson_vm/tests/data/scripts/list_id_map.json diff --git a/tezos_vm/tests/data/scripts/list_iter.json b/michelson_vm/tests/data/scripts/list_iter.json similarity index 100% rename from tezos_vm/tests/data/scripts/list_iter.json rename to michelson_vm/tests/data/scripts/list_iter.json diff --git a/tezos_vm/tests/data/scripts/list_map_block.json b/michelson_vm/tests/data/scripts/list_map_block.json similarity index 100% rename from tezos_vm/tests/data/scripts/list_map_block.json rename to michelson_vm/tests/data/scripts/list_map_block.json diff --git a/tezos_vm/tests/data/scripts/list_size.json b/michelson_vm/tests/data/scripts/list_size.json similarity index 100% rename from tezos_vm/tests/data/scripts/list_size.json rename to michelson_vm/tests/data/scripts/list_size.json diff --git a/tezos_vm/tests/data/scripts/loop_failwith.json b/michelson_vm/tests/data/scripts/loop_failwith.json similarity index 100% rename from tezos_vm/tests/data/scripts/loop_failwith.json rename to michelson_vm/tests/data/scripts/loop_failwith.json diff --git a/tezos_vm/tests/data/scripts/loop_left.json b/michelson_vm/tests/data/scripts/loop_left.json similarity index 100% rename from tezos_vm/tests/data/scripts/loop_left.json rename to michelson_vm/tests/data/scripts/loop_left.json diff --git a/tezos_vm/tests/data/scripts/loop_left_failwith.json b/michelson_vm/tests/data/scripts/loop_left_failwith.json similarity index 100% rename from tezos_vm/tests/data/scripts/loop_left_failwith.json rename to michelson_vm/tests/data/scripts/loop_left_failwith.json diff --git a/tezos_vm/tests/data/scripts/map_car.json b/michelson_vm/tests/data/scripts/map_car.json similarity index 100% rename from tezos_vm/tests/data/scripts/map_car.json rename to michelson_vm/tests/data/scripts/map_car.json diff --git a/tezos_vm/tests/data/scripts/map_id.json b/michelson_vm/tests/data/scripts/map_id.json similarity index 100% rename from tezos_vm/tests/data/scripts/map_id.json rename to michelson_vm/tests/data/scripts/map_id.json diff --git a/tezos_vm/tests/data/scripts/map_iter.json b/michelson_vm/tests/data/scripts/map_iter.json similarity index 100% rename from tezos_vm/tests/data/scripts/map_iter.json rename to michelson_vm/tests/data/scripts/map_iter.json diff --git a/tezos_vm/tests/data/scripts/map_map.json b/michelson_vm/tests/data/scripts/map_map.json similarity index 100% rename from tezos_vm/tests/data/scripts/map_map.json rename to michelson_vm/tests/data/scripts/map_map.json diff --git a/tezos_vm/tests/data/scripts/map_map_sideeffect.json b/michelson_vm/tests/data/scripts/map_map_sideeffect.json similarity index 100% rename from tezos_vm/tests/data/scripts/map_map_sideeffect.json rename to michelson_vm/tests/data/scripts/map_map_sideeffect.json diff --git a/tezos_vm/tests/data/scripts/map_mem_nat.json b/michelson_vm/tests/data/scripts/map_mem_nat.json similarity index 100% rename from tezos_vm/tests/data/scripts/map_mem_nat.json rename to michelson_vm/tests/data/scripts/map_mem_nat.json diff --git a/tezos_vm/tests/data/scripts/map_mem_string.json b/michelson_vm/tests/data/scripts/map_mem_string.json similarity index 100% rename from tezos_vm/tests/data/scripts/map_mem_string.json rename to michelson_vm/tests/data/scripts/map_mem_string.json diff --git a/tezos_vm/tests/data/scripts/map_size.json b/michelson_vm/tests/data/scripts/map_size.json similarity index 100% rename from tezos_vm/tests/data/scripts/map_size.json rename to michelson_vm/tests/data/scripts/map_size.json diff --git a/tezos_vm/tests/data/scripts/merge_comparable_pairs.json b/michelson_vm/tests/data/scripts/merge_comparable_pairs.json similarity index 100% rename from tezos_vm/tests/data/scripts/merge_comparable_pairs.json rename to michelson_vm/tests/data/scripts/merge_comparable_pairs.json diff --git a/tezos_vm/tests/data/scripts/mul.json b/michelson_vm/tests/data/scripts/mul.json similarity index 100% rename from tezos_vm/tests/data/scripts/mul.json rename to michelson_vm/tests/data/scripts/mul.json diff --git a/tezos_vm/tests/data/scripts/mul_bls12_381_fr.json b/michelson_vm/tests/data/scripts/mul_bls12_381_fr.json similarity index 100% rename from tezos_vm/tests/data/scripts/mul_bls12_381_fr.json rename to michelson_vm/tests/data/scripts/mul_bls12_381_fr.json diff --git a/tezos_vm/tests/data/scripts/mul_bls12_381_g1.json b/michelson_vm/tests/data/scripts/mul_bls12_381_g1.json similarity index 100% rename from tezos_vm/tests/data/scripts/mul_bls12_381_g1.json rename to michelson_vm/tests/data/scripts/mul_bls12_381_g1.json diff --git a/tezos_vm/tests/data/scripts/mul_bls12_381_g2.json b/michelson_vm/tests/data/scripts/mul_bls12_381_g2.json similarity index 100% rename from tezos_vm/tests/data/scripts/mul_bls12_381_g2.json rename to michelson_vm/tests/data/scripts/mul_bls12_381_g2.json diff --git a/tezos_vm/tests/data/scripts/mul_overflow.json b/michelson_vm/tests/data/scripts/mul_overflow.json similarity index 100% rename from tezos_vm/tests/data/scripts/mul_overflow.json rename to michelson_vm/tests/data/scripts/mul_overflow.json diff --git a/tezos_vm/tests/data/scripts/munch.json b/michelson_vm/tests/data/scripts/munch.json similarity index 100% rename from tezos_vm/tests/data/scripts/munch.json rename to michelson_vm/tests/data/scripts/munch.json diff --git a/tezos_vm/tests/data/scripts/mutez_to_bls12_381_fr.json b/michelson_vm/tests/data/scripts/mutez_to_bls12_381_fr.json similarity index 100% rename from tezos_vm/tests/data/scripts/mutez_to_bls12_381_fr.json rename to michelson_vm/tests/data/scripts/mutez_to_bls12_381_fr.json diff --git a/tezos_vm/tests/data/scripts/neg.json b/michelson_vm/tests/data/scripts/neg.json similarity index 100% rename from tezos_vm/tests/data/scripts/neg.json rename to michelson_vm/tests/data/scripts/neg.json diff --git a/tezos_vm/tests/data/scripts/neg_bls12_381_fr.json b/michelson_vm/tests/data/scripts/neg_bls12_381_fr.json similarity index 100% rename from tezos_vm/tests/data/scripts/neg_bls12_381_fr.json rename to michelson_vm/tests/data/scripts/neg_bls12_381_fr.json diff --git a/tezos_vm/tests/data/scripts/neg_bls12_381_g1.json b/michelson_vm/tests/data/scripts/neg_bls12_381_g1.json similarity index 100% rename from tezos_vm/tests/data/scripts/neg_bls12_381_g1.json rename to michelson_vm/tests/data/scripts/neg_bls12_381_g1.json diff --git a/tezos_vm/tests/data/scripts/neg_bls12_381_g2.json b/michelson_vm/tests/data/scripts/neg_bls12_381_g2.json similarity index 100% rename from tezos_vm/tests/data/scripts/neg_bls12_381_g2.json rename to michelson_vm/tests/data/scripts/neg_bls12_381_g2.json diff --git a/tezos_vm/tests/data/scripts/none.json b/michelson_vm/tests/data/scripts/none.json similarity index 100% rename from tezos_vm/tests/data/scripts/none.json rename to michelson_vm/tests/data/scripts/none.json diff --git a/tezos_l2/tests/data/scripts/noop.json b/michelson_vm/tests/data/scripts/noop.json similarity index 100% rename from tezos_l2/tests/data/scripts/noop.json rename to michelson_vm/tests/data/scripts/noop.json diff --git a/tezos_vm/tests/data/scripts/not.json b/michelson_vm/tests/data/scripts/not.json similarity index 100% rename from tezos_vm/tests/data/scripts/not.json rename to michelson_vm/tests/data/scripts/not.json diff --git a/tezos_vm/tests/data/scripts/not_binary.json b/michelson_vm/tests/data/scripts/not_binary.json similarity index 100% rename from tezos_vm/tests/data/scripts/not_binary.json rename to michelson_vm/tests/data/scripts/not_binary.json diff --git a/tezos_vm/tests/data/scripts/or.json b/michelson_vm/tests/data/scripts/or.json similarity index 100% rename from tezos_vm/tests/data/scripts/or.json rename to michelson_vm/tests/data/scripts/or.json diff --git a/tezos_vm/tests/data/scripts/or_binary.json b/michelson_vm/tests/data/scripts/or_binary.json similarity index 100% rename from tezos_vm/tests/data/scripts/or_binary.json rename to michelson_vm/tests/data/scripts/or_binary.json diff --git a/tezos_vm/tests/data/scripts/originate_big_map.json b/michelson_vm/tests/data/scripts/originate_big_map.json similarity index 100% rename from tezos_vm/tests/data/scripts/originate_big_map.json rename to michelson_vm/tests/data/scripts/originate_big_map.json diff --git a/tezos_vm/tests/data/scripts/packunpack.json b/michelson_vm/tests/data/scripts/packunpack.json similarity index 100% rename from tezos_vm/tests/data/scripts/packunpack.json rename to michelson_vm/tests/data/scripts/packunpack.json diff --git a/tezos_vm/tests/data/scripts/packunpack_rev.json b/michelson_vm/tests/data/scripts/packunpack_rev.json similarity index 100% rename from tezos_vm/tests/data/scripts/packunpack_rev.json rename to michelson_vm/tests/data/scripts/packunpack_rev.json diff --git a/tezos_vm/tests/data/scripts/packunpack_rev_cty.json b/michelson_vm/tests/data/scripts/packunpack_rev_cty.json similarity index 100% rename from tezos_vm/tests/data/scripts/packunpack_rev_cty.json rename to michelson_vm/tests/data/scripts/packunpack_rev_cty.json diff --git a/tezos_vm/tests/data/scripts/pair_id.json b/michelson_vm/tests/data/scripts/pair_id.json similarity index 100% rename from tezos_vm/tests/data/scripts/pair_id.json rename to michelson_vm/tests/data/scripts/pair_id.json diff --git a/tezos_vm/tests/data/scripts/pairing_check.json b/michelson_vm/tests/data/scripts/pairing_check.json similarity index 100% rename from tezos_vm/tests/data/scripts/pairing_check.json rename to michelson_vm/tests/data/scripts/pairing_check.json diff --git a/tezos_vm/tests/data/scripts/pexec.json b/michelson_vm/tests/data/scripts/pexec.json similarity index 100% rename from tezos_vm/tests/data/scripts/pexec.json rename to michelson_vm/tests/data/scripts/pexec.json diff --git a/tezos_vm/tests/data/scripts/pexec_2.json b/michelson_vm/tests/data/scripts/pexec_2.json similarity index 100% rename from tezos_vm/tests/data/scripts/pexec_2.json rename to michelson_vm/tests/data/scripts/pexec_2.json diff --git a/tezos_l2/tests/data/scripts/proxy.json b/michelson_vm/tests/data/scripts/proxy.json similarity index 100% rename from tezos_l2/tests/data/scripts/proxy.json rename to michelson_vm/tests/data/scripts/proxy.json diff --git a/tezos_vm/tests/data/scripts/ret_int.json b/michelson_vm/tests/data/scripts/ret_int.json similarity index 100% rename from tezos_vm/tests/data/scripts/ret_int.json rename to michelson_vm/tests/data/scripts/ret_int.json diff --git a/tezos_vm/tests/data/scripts/reverse.json b/michelson_vm/tests/data/scripts/reverse.json similarity index 100% rename from tezos_vm/tests/data/scripts/reverse.json rename to michelson_vm/tests/data/scripts/reverse.json diff --git a/tezos_vm/tests/data/scripts/reverse_loop.json b/michelson_vm/tests/data/scripts/reverse_loop.json similarity index 100% rename from tezos_vm/tests/data/scripts/reverse_loop.json rename to michelson_vm/tests/data/scripts/reverse_loop.json diff --git a/tezos_vm/tests/data/scripts/sapling_empty_state.json b/michelson_vm/tests/data/scripts/sapling_empty_state.json similarity index 100% rename from tezos_vm/tests/data/scripts/sapling_empty_state.json rename to michelson_vm/tests/data/scripts/sapling_empty_state.json diff --git a/tezos_l2/tests/data/scripts/self.json b/michelson_vm/tests/data/scripts/self.json similarity index 100% rename from tezos_l2/tests/data/scripts/self.json rename to michelson_vm/tests/data/scripts/self.json diff --git a/tezos_vm/tests/data/scripts/self_address.json b/michelson_vm/tests/data/scripts/self_address.json similarity index 100% rename from tezos_vm/tests/data/scripts/self_address.json rename to michelson_vm/tests/data/scripts/self_address.json diff --git a/tezos_vm/tests/data/scripts/self_address_after_fib_view.json b/michelson_vm/tests/data/scripts/self_address_after_fib_view.json similarity index 100% rename from tezos_vm/tests/data/scripts/self_address_after_fib_view.json rename to michelson_vm/tests/data/scripts/self_address_after_fib_view.json diff --git a/tezos_vm/tests/data/scripts/self_address_after_nonexistent_view.json b/michelson_vm/tests/data/scripts/self_address_after_nonexistent_view.json similarity index 100% rename from tezos_vm/tests/data/scripts/self_address_after_nonexistent_view.json rename to michelson_vm/tests/data/scripts/self_address_after_nonexistent_view.json diff --git a/tezos_vm/tests/data/scripts/self_address_after_view.json b/michelson_vm/tests/data/scripts/self_address_after_view.json similarity index 100% rename from tezos_vm/tests/data/scripts/self_address_after_view.json rename to michelson_vm/tests/data/scripts/self_address_after_view.json diff --git a/tezos_vm/tests/data/scripts/self_after_fib_view.json b/michelson_vm/tests/data/scripts/self_after_fib_view.json similarity index 100% rename from tezos_vm/tests/data/scripts/self_after_fib_view.json rename to michelson_vm/tests/data/scripts/self_after_fib_view.json diff --git a/tezos_vm/tests/data/scripts/self_after_nonexistent_view.json b/michelson_vm/tests/data/scripts/self_after_nonexistent_view.json similarity index 100% rename from tezos_vm/tests/data/scripts/self_after_nonexistent_view.json rename to michelson_vm/tests/data/scripts/self_after_nonexistent_view.json diff --git a/tezos_vm/tests/data/scripts/self_after_view.json b/michelson_vm/tests/data/scripts/self_after_view.json similarity index 100% rename from tezos_vm/tests/data/scripts/self_after_view.json rename to michelson_vm/tests/data/scripts/self_after_view.json diff --git a/tezos_vm/tests/data/scripts/self_with_default_entrypoint.json b/michelson_vm/tests/data/scripts/self_with_default_entrypoint.json similarity index 100% rename from tezos_vm/tests/data/scripts/self_with_default_entrypoint.json rename to michelson_vm/tests/data/scripts/self_with_default_entrypoint.json diff --git a/tezos_vm/tests/data/scripts/self_with_entrypoint.json b/michelson_vm/tests/data/scripts/self_with_entrypoint.json similarity index 100% rename from tezos_vm/tests/data/scripts/self_with_entrypoint.json rename to michelson_vm/tests/data/scripts/self_with_entrypoint.json diff --git a/tezos_l2/tests/data/scripts/sender.json b/michelson_vm/tests/data/scripts/sender.json similarity index 100% rename from tezos_l2/tests/data/scripts/sender.json rename to michelson_vm/tests/data/scripts/sender.json diff --git a/tezos_vm/tests/data/scripts/sender_after_fib_view.json b/michelson_vm/tests/data/scripts/sender_after_fib_view.json similarity index 100% rename from tezos_vm/tests/data/scripts/sender_after_fib_view.json rename to michelson_vm/tests/data/scripts/sender_after_fib_view.json diff --git a/tezos_vm/tests/data/scripts/sender_after_nonexistent_view.json b/michelson_vm/tests/data/scripts/sender_after_nonexistent_view.json similarity index 100% rename from tezos_vm/tests/data/scripts/sender_after_nonexistent_view.json rename to michelson_vm/tests/data/scripts/sender_after_nonexistent_view.json diff --git a/tezos_vm/tests/data/scripts/sender_after_view.json b/michelson_vm/tests/data/scripts/sender_after_view.json similarity index 100% rename from tezos_vm/tests/data/scripts/sender_after_view.json rename to michelson_vm/tests/data/scripts/sender_after_view.json diff --git a/tezos_vm/tests/data/scripts/set_car.json b/michelson_vm/tests/data/scripts/set_car.json similarity index 100% rename from tezos_vm/tests/data/scripts/set_car.json rename to michelson_vm/tests/data/scripts/set_car.json diff --git a/tezos_vm/tests/data/scripts/set_cdr.json b/michelson_vm/tests/data/scripts/set_cdr.json similarity index 100% rename from tezos_vm/tests/data/scripts/set_cdr.json rename to michelson_vm/tests/data/scripts/set_cdr.json diff --git a/tezos_vm/tests/data/scripts/set_delegate.json b/michelson_vm/tests/data/scripts/set_delegate.json similarity index 100% rename from tezos_vm/tests/data/scripts/set_delegate.json rename to michelson_vm/tests/data/scripts/set_delegate.json diff --git a/tezos_vm/tests/data/scripts/set_id.json b/michelson_vm/tests/data/scripts/set_id.json similarity index 100% rename from tezos_vm/tests/data/scripts/set_id.json rename to michelson_vm/tests/data/scripts/set_id.json diff --git a/tezos_vm/tests/data/scripts/set_iter.json b/michelson_vm/tests/data/scripts/set_iter.json similarity index 100% rename from tezos_vm/tests/data/scripts/set_iter.json rename to michelson_vm/tests/data/scripts/set_iter.json diff --git a/tezos_vm/tests/data/scripts/set_member.json b/michelson_vm/tests/data/scripts/set_member.json similarity index 100% rename from tezos_vm/tests/data/scripts/set_member.json rename to michelson_vm/tests/data/scripts/set_member.json diff --git a/tezos_vm/tests/data/scripts/set_size.json b/michelson_vm/tests/data/scripts/set_size.json similarity index 100% rename from tezos_vm/tests/data/scripts/set_size.json rename to michelson_vm/tests/data/scripts/set_size.json diff --git a/tezos_vm/tests/data/scripts/sets.json b/michelson_vm/tests/data/scripts/sets.json similarity index 100% rename from tezos_vm/tests/data/scripts/sets.json rename to michelson_vm/tests/data/scripts/sets.json diff --git a/tezos_vm/tests/data/scripts/sha3.json b/michelson_vm/tests/data/scripts/sha3.json similarity index 100% rename from tezos_vm/tests/data/scripts/sha3.json rename to michelson_vm/tests/data/scripts/sha3.json diff --git a/tezos_vm/tests/data/scripts/shifts.json b/michelson_vm/tests/data/scripts/shifts.json similarity index 100% rename from tezos_vm/tests/data/scripts/shifts.json rename to michelson_vm/tests/data/scripts/shifts.json diff --git a/tezos_vm/tests/data/scripts/slice.json b/michelson_vm/tests/data/scripts/slice.json similarity index 100% rename from tezos_vm/tests/data/scripts/slice.json rename to michelson_vm/tests/data/scripts/slice.json diff --git a/tezos_vm/tests/data/scripts/slice_bytes.json b/michelson_vm/tests/data/scripts/slice_bytes.json similarity index 100% rename from tezos_vm/tests/data/scripts/slice_bytes.json rename to michelson_vm/tests/data/scripts/slice_bytes.json diff --git a/tezos_vm/tests/data/scripts/slices.json b/michelson_vm/tests/data/scripts/slices.json similarity index 100% rename from tezos_vm/tests/data/scripts/slices.json rename to michelson_vm/tests/data/scripts/slices.json diff --git a/tezos_l2/tests/data/scripts/source.json b/michelson_vm/tests/data/scripts/source.json similarity index 100% rename from tezos_l2/tests/data/scripts/source.json rename to michelson_vm/tests/data/scripts/source.json diff --git a/tezos_vm/tests/data/scripts/split_bytes.json b/michelson_vm/tests/data/scripts/split_bytes.json similarity index 100% rename from tezos_vm/tests/data/scripts/split_bytes.json rename to michelson_vm/tests/data/scripts/split_bytes.json diff --git a/tezos_vm/tests/data/scripts/split_string.json b/michelson_vm/tests/data/scripts/split_string.json similarity index 100% rename from tezos_vm/tests/data/scripts/split_string.json rename to michelson_vm/tests/data/scripts/split_string.json diff --git a/tezos_vm/tests/data/scripts/store_bls12_381_fr.json b/michelson_vm/tests/data/scripts/store_bls12_381_fr.json similarity index 100% rename from tezos_vm/tests/data/scripts/store_bls12_381_fr.json rename to michelson_vm/tests/data/scripts/store_bls12_381_fr.json diff --git a/tezos_vm/tests/data/scripts/store_bls12_381_g1.json b/michelson_vm/tests/data/scripts/store_bls12_381_g1.json similarity index 100% rename from tezos_vm/tests/data/scripts/store_bls12_381_g1.json rename to michelson_vm/tests/data/scripts/store_bls12_381_g1.json diff --git a/tezos_vm/tests/data/scripts/store_bls12_381_g2.json b/michelson_vm/tests/data/scripts/store_bls12_381_g2.json similarity index 100% rename from tezos_vm/tests/data/scripts/store_bls12_381_g2.json rename to michelson_vm/tests/data/scripts/store_bls12_381_g2.json diff --git a/tezos_l2/tests/data/scripts/store_input.json b/michelson_vm/tests/data/scripts/store_input.json similarity index 100% rename from tezos_l2/tests/data/scripts/store_input.json rename to michelson_vm/tests/data/scripts/store_input.json diff --git a/tezos_l2/tests/data/scripts/store_now.json b/michelson_vm/tests/data/scripts/store_now.json similarity index 100% rename from tezos_l2/tests/data/scripts/store_now.json rename to michelson_vm/tests/data/scripts/store_now.json diff --git a/tezos_vm/tests/data/scripts/str_id.json b/michelson_vm/tests/data/scripts/str_id.json similarity index 100% rename from tezos_vm/tests/data/scripts/str_id.json rename to michelson_vm/tests/data/scripts/str_id.json diff --git a/tezos_vm/tests/data/scripts/sub_timestamp_delta.json b/michelson_vm/tests/data/scripts/sub_timestamp_delta.json similarity index 100% rename from tezos_vm/tests/data/scripts/sub_timestamp_delta.json rename to michelson_vm/tests/data/scripts/sub_timestamp_delta.json diff --git a/tezos_vm/tests/data/scripts/subset.json b/michelson_vm/tests/data/scripts/subset.json similarity index 100% rename from tezos_vm/tests/data/scripts/subset.json rename to michelson_vm/tests/data/scripts/subset.json diff --git a/tezos_vm/tests/data/scripts/tez_add_sub.json b/michelson_vm/tests/data/scripts/tez_add_sub.json similarity index 100% rename from tezos_vm/tests/data/scripts/tez_add_sub.json rename to michelson_vm/tests/data/scripts/tez_add_sub.json diff --git a/tezos_vm/tests/data/scripts/ticket_bad.json b/michelson_vm/tests/data/scripts/ticket_bad.json similarity index 100% rename from tezos_vm/tests/data/scripts/ticket_bad.json rename to michelson_vm/tests/data/scripts/ticket_bad.json diff --git a/tezos_vm/tests/data/scripts/ticket_big_store.json b/michelson_vm/tests/data/scripts/ticket_big_store.json similarity index 100% rename from tezos_vm/tests/data/scripts/ticket_big_store.json rename to michelson_vm/tests/data/scripts/ticket_big_store.json diff --git a/tezos_vm/tests/data/scripts/ticket_join.json b/michelson_vm/tests/data/scripts/ticket_join.json similarity index 100% rename from tezos_vm/tests/data/scripts/ticket_join.json rename to michelson_vm/tests/data/scripts/ticket_join.json diff --git a/tezos_vm/tests/data/scripts/ticket_read.json b/michelson_vm/tests/data/scripts/ticket_read.json similarity index 100% rename from tezos_vm/tests/data/scripts/ticket_read.json rename to michelson_vm/tests/data/scripts/ticket_read.json diff --git a/tezos_vm/tests/data/scripts/ticket_split.json b/michelson_vm/tests/data/scripts/ticket_split.json similarity index 100% rename from tezos_vm/tests/data/scripts/ticket_split.json rename to michelson_vm/tests/data/scripts/ticket_split.json diff --git a/tezos_vm/tests/data/scripts/ticket_store-2.json b/michelson_vm/tests/data/scripts/ticket_store-2.json similarity index 100% rename from tezos_vm/tests/data/scripts/ticket_store-2.json rename to michelson_vm/tests/data/scripts/ticket_store-2.json diff --git a/tezos_vm/tests/data/scripts/ticket_store.json b/michelson_vm/tests/data/scripts/ticket_store.json similarity index 100% rename from tezos_vm/tests/data/scripts/ticket_store.json rename to michelson_vm/tests/data/scripts/ticket_store.json diff --git a/tezos_vm/tests/data/scripts/ticketer-2.json b/michelson_vm/tests/data/scripts/ticketer-2.json similarity index 100% rename from tezos_vm/tests/data/scripts/ticketer-2.json rename to michelson_vm/tests/data/scripts/ticketer-2.json diff --git a/tezos_vm/tests/data/scripts/ticketer.json b/michelson_vm/tests/data/scripts/ticketer.json similarity index 100% rename from tezos_vm/tests/data/scripts/ticketer.json rename to michelson_vm/tests/data/scripts/ticketer.json diff --git a/tezos_l2/tests/data/scripts/transfer_amount.json b/michelson_vm/tests/data/scripts/transfer_amount.json similarity index 100% rename from tezos_l2/tests/data/scripts/transfer_amount.json rename to michelson_vm/tests/data/scripts/transfer_amount.json diff --git a/tezos_l2/tests/data/scripts/transfer_tokens.json b/michelson_vm/tests/data/scripts/transfer_tokens.json similarity index 100% rename from tezos_l2/tests/data/scripts/transfer_tokens.json rename to michelson_vm/tests/data/scripts/transfer_tokens.json diff --git a/tezos_vm/tests/data/scripts/uncomb.json b/michelson_vm/tests/data/scripts/uncomb.json similarity index 100% rename from tezos_vm/tests/data/scripts/uncomb.json rename to michelson_vm/tests/data/scripts/uncomb.json diff --git a/tezos_vm/tests/data/scripts/unpair.json b/michelson_vm/tests/data/scripts/unpair.json similarity index 100% rename from tezos_vm/tests/data/scripts/unpair.json rename to michelson_vm/tests/data/scripts/unpair.json diff --git a/tezos_vm/tests/data/scripts/unpair_field_annotation_mismatch.json b/michelson_vm/tests/data/scripts/unpair_field_annotation_mismatch.json similarity index 100% rename from tezos_vm/tests/data/scripts/unpair_field_annotation_mismatch.json rename to michelson_vm/tests/data/scripts/unpair_field_annotation_mismatch.json diff --git a/tezos_vm/tests/data/scripts/update_big_map.json b/michelson_vm/tests/data/scripts/update_big_map.json similarity index 100% rename from tezos_vm/tests/data/scripts/update_big_map.json rename to michelson_vm/tests/data/scripts/update_big_map.json diff --git a/tezos_vm/tests/data/scripts/utxo_read.json b/michelson_vm/tests/data/scripts/utxo_read.json similarity index 100% rename from tezos_vm/tests/data/scripts/utxo_read.json rename to michelson_vm/tests/data/scripts/utxo_read.json diff --git a/tezos_vm/tests/data/scripts/utxor.json b/michelson_vm/tests/data/scripts/utxor.json similarity index 100% rename from tezos_vm/tests/data/scripts/utxor.json rename to michelson_vm/tests/data/scripts/utxor.json diff --git a/tezos_vm/tests/data/scripts/view_fib.json b/michelson_vm/tests/data/scripts/view_fib.json similarity index 100% rename from tezos_vm/tests/data/scripts/view_fib.json rename to michelson_vm/tests/data/scripts/view_fib.json diff --git a/tezos_vm/tests/data/scripts/view_mutual_recursion.json b/michelson_vm/tests/data/scripts/view_mutual_recursion.json similarity index 100% rename from tezos_vm/tests/data/scripts/view_mutual_recursion.json rename to michelson_vm/tests/data/scripts/view_mutual_recursion.json diff --git a/tezos_vm/tests/data/scripts/view_op_add.json b/michelson_vm/tests/data/scripts/view_op_add.json similarity index 100% rename from tezos_vm/tests/data/scripts/view_op_add.json rename to michelson_vm/tests/data/scripts/view_op_add.json diff --git a/tezos_vm/tests/data/scripts/view_op_constant.json b/michelson_vm/tests/data/scripts/view_op_constant.json similarity index 100% rename from tezos_vm/tests/data/scripts/view_op_constant.json rename to michelson_vm/tests/data/scripts/view_op_constant.json diff --git a/tezos_vm/tests/data/scripts/view_op_id.json b/michelson_vm/tests/data/scripts/view_op_id.json similarity index 100% rename from tezos_vm/tests/data/scripts/view_op_id.json rename to michelson_vm/tests/data/scripts/view_op_id.json diff --git a/tezos_vm/tests/data/scripts/view_op_nonexistent_addr.json b/michelson_vm/tests/data/scripts/view_op_nonexistent_addr.json similarity index 100% rename from tezos_vm/tests/data/scripts/view_op_nonexistent_addr.json rename to michelson_vm/tests/data/scripts/view_op_nonexistent_addr.json diff --git a/tezos_vm/tests/data/scripts/view_op_nonexistent_func.json b/michelson_vm/tests/data/scripts/view_op_nonexistent_func.json similarity index 100% rename from tezos_vm/tests/data/scripts/view_op_nonexistent_func.json rename to michelson_vm/tests/data/scripts/view_op_nonexistent_func.json diff --git a/tezos_vm/tests/data/scripts/view_op_test_step_contants.json b/michelson_vm/tests/data/scripts/view_op_test_step_contants.json similarity index 100% rename from tezos_vm/tests/data/scripts/view_op_test_step_contants.json rename to michelson_vm/tests/data/scripts/view_op_test_step_contants.json diff --git a/tezos_vm/tests/data/scripts/view_op_toplevel_inconsistent_input_type.json b/michelson_vm/tests/data/scripts/view_op_toplevel_inconsistent_input_type.json similarity index 100% rename from tezos_vm/tests/data/scripts/view_op_toplevel_inconsistent_input_type.json rename to michelson_vm/tests/data/scripts/view_op_toplevel_inconsistent_input_type.json diff --git a/tezos_vm/tests/data/scripts/view_op_toplevel_inconsistent_output_type.json b/michelson_vm/tests/data/scripts/view_op_toplevel_inconsistent_output_type.json similarity index 100% rename from tezos_vm/tests/data/scripts/view_op_toplevel_inconsistent_output_type.json rename to michelson_vm/tests/data/scripts/view_op_toplevel_inconsistent_output_type.json diff --git a/tezos_vm/tests/data/scripts/view_rec.json b/michelson_vm/tests/data/scripts/view_rec.json similarity index 100% rename from tezos_vm/tests/data/scripts/view_rec.json rename to michelson_vm/tests/data/scripts/view_rec.json diff --git a/tezos_vm/tests/data/scripts/view_toplevel_lib.json b/michelson_vm/tests/data/scripts/view_toplevel_lib.json similarity index 100% rename from tezos_vm/tests/data/scripts/view_toplevel_lib.json rename to michelson_vm/tests/data/scripts/view_toplevel_lib.json diff --git a/tezos_vm/tests/data/scripts/voting_power.json b/michelson_vm/tests/data/scripts/voting_power.json similarity index 100% rename from tezos_vm/tests/data/scripts/voting_power.json rename to michelson_vm/tests/data/scripts/voting_power.json diff --git a/tezos_vm/tests/data/scripts/xor.json b/michelson_vm/tests/data/scripts/xor.json similarity index 100% rename from tezos_vm/tests/data/scripts/xor.json rename to michelson_vm/tests/data/scripts/xor.json diff --git a/tezos_vm/tests/data/tzt/tzt_abs_00.json b/michelson_vm/tests/data/tzt/tzt_abs_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_abs_00.json rename to michelson_vm/tests/data/tzt/tzt_abs_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_abs_01.json b/michelson_vm/tests/data/tzt/tzt_abs_01.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_abs_01.json rename to michelson_vm/tests/data/tzt/tzt_abs_01.json diff --git a/tezos_vm/tests/data/tzt/tzt_abs_02.json b/michelson_vm/tests/data/tzt/tzt_abs_02.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_abs_02.json rename to michelson_vm/tests/data/tzt/tzt_abs_02.json diff --git a/tezos_vm/tests/data/tzt/tzt_add_int_int_00.json b/michelson_vm/tests/data/tzt/tzt_add_int_int_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_add_int_int_00.json rename to michelson_vm/tests/data/tzt/tzt_add_int_int_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_add_int_nat_00.json b/michelson_vm/tests/data/tzt/tzt_add_int_nat_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_add_int_nat_00.json rename to michelson_vm/tests/data/tzt/tzt_add_int_nat_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_add_int_nat_01.json b/michelson_vm/tests/data/tzt/tzt_add_int_nat_01.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_add_int_nat_01.json rename to michelson_vm/tests/data/tzt/tzt_add_int_nat_01.json diff --git a/tezos_vm/tests/data/tzt/tzt_add_int_timestamp_00.json b/michelson_vm/tests/data/tzt/tzt_add_int_timestamp_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_add_int_timestamp_00.json rename to michelson_vm/tests/data/tzt/tzt_add_int_timestamp_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_add_mutez_mutez_00.json b/michelson_vm/tests/data/tzt/tzt_add_mutez_mutez_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_add_mutez_mutez_00.json rename to michelson_vm/tests/data/tzt/tzt_add_mutez_mutez_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_add_mutez_mutez_01.json b/michelson_vm/tests/data/tzt/tzt_add_mutez_mutez_01.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_add_mutez_mutez_01.json rename to michelson_vm/tests/data/tzt/tzt_add_mutez_mutez_01.json diff --git a/tezos_vm/tests/data/tzt/tzt_add_nat_int_00.json b/michelson_vm/tests/data/tzt/tzt_add_nat_int_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_add_nat_int_00.json rename to michelson_vm/tests/data/tzt/tzt_add_nat_int_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_add_nat_nat_00.json b/michelson_vm/tests/data/tzt/tzt_add_nat_nat_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_add_nat_nat_00.json rename to michelson_vm/tests/data/tzt/tzt_add_nat_nat_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_add_timestamp_int_00.json b/michelson_vm/tests/data/tzt/tzt_add_timestamp_int_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_add_timestamp_int_00.json rename to michelson_vm/tests/data/tzt/tzt_add_timestamp_int_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_add_timestamp_int_01.json b/michelson_vm/tests/data/tzt/tzt_add_timestamp_int_01.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_add_timestamp_int_01.json rename to michelson_vm/tests/data/tzt/tzt_add_timestamp_int_01.json diff --git a/tezos_vm/tests/data/tzt/tzt_add_timestamp_int_02.json b/michelson_vm/tests/data/tzt/tzt_add_timestamp_int_02.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_add_timestamp_int_02.json rename to michelson_vm/tests/data/tzt/tzt_add_timestamp_int_02.json diff --git a/tezos_vm/tests/data/tzt/tzt_add_timestamp_int_03.json b/michelson_vm/tests/data/tzt/tzt_add_timestamp_int_03.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_add_timestamp_int_03.json rename to michelson_vm/tests/data/tzt/tzt_add_timestamp_int_03.json diff --git a/tezos_vm/tests/data/tzt/tzt_address_00.json b/michelson_vm/tests/data/tzt/tzt_address_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_address_00.json rename to michelson_vm/tests/data/tzt/tzt_address_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_address_01.json b/michelson_vm/tests/data/tzt/tzt_address_01.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_address_01.json rename to michelson_vm/tests/data/tzt/tzt_address_01.json diff --git a/tezos_vm/tests/data/tzt/tzt_address_02.json b/michelson_vm/tests/data/tzt/tzt_address_02.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_address_02.json rename to michelson_vm/tests/data/tzt/tzt_address_02.json diff --git a/tezos_vm/tests/data/tzt/tzt_amount_00.json b/michelson_vm/tests/data/tzt/tzt_amount_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_amount_00.json rename to michelson_vm/tests/data/tzt/tzt_amount_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_and_bool_bool_00.json b/michelson_vm/tests/data/tzt/tzt_and_bool_bool_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_and_bool_bool_00.json rename to michelson_vm/tests/data/tzt/tzt_and_bool_bool_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_and_bool_bool_01.json b/michelson_vm/tests/data/tzt/tzt_and_bool_bool_01.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_and_bool_bool_01.json rename to michelson_vm/tests/data/tzt/tzt_and_bool_bool_01.json diff --git a/tezos_vm/tests/data/tzt/tzt_and_bool_bool_02.json b/michelson_vm/tests/data/tzt/tzt_and_bool_bool_02.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_and_bool_bool_02.json rename to michelson_vm/tests/data/tzt/tzt_and_bool_bool_02.json diff --git a/tezos_vm/tests/data/tzt/tzt_and_bool_bool_03.json b/michelson_vm/tests/data/tzt/tzt_and_bool_bool_03.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_and_bool_bool_03.json rename to michelson_vm/tests/data/tzt/tzt_and_bool_bool_03.json diff --git a/tezos_vm/tests/data/tzt/tzt_and_nat_nat_00.json b/michelson_vm/tests/data/tzt/tzt_and_nat_nat_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_and_nat_nat_00.json rename to michelson_vm/tests/data/tzt/tzt_and_nat_nat_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_and_nat_nat_01.json b/michelson_vm/tests/data/tzt/tzt_and_nat_nat_01.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_and_nat_nat_01.json rename to michelson_vm/tests/data/tzt/tzt_and_nat_nat_01.json diff --git a/tezos_vm/tests/data/tzt/tzt_and_nat_nat_02.json b/michelson_vm/tests/data/tzt/tzt_and_nat_nat_02.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_and_nat_nat_02.json rename to michelson_vm/tests/data/tzt/tzt_and_nat_nat_02.json diff --git a/tezos_vm/tests/data/tzt/tzt_and_nat_nat_03.json b/michelson_vm/tests/data/tzt/tzt_and_nat_nat_03.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_and_nat_nat_03.json rename to michelson_vm/tests/data/tzt/tzt_and_nat_nat_03.json diff --git a/tezos_vm/tests/data/tzt/tzt_and_nat_nat_04.json b/michelson_vm/tests/data/tzt/tzt_and_nat_nat_04.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_and_nat_nat_04.json rename to michelson_vm/tests/data/tzt/tzt_and_nat_nat_04.json diff --git a/tezos_vm/tests/data/tzt/tzt_apply_00.json b/michelson_vm/tests/data/tzt/tzt_apply_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_apply_00.json rename to michelson_vm/tests/data/tzt/tzt_apply_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_balance_00.json b/michelson_vm/tests/data/tzt/tzt_balance_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_balance_00.json rename to michelson_vm/tests/data/tzt/tzt_balance_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_car_00.json b/michelson_vm/tests/data/tzt/tzt_car_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_car_00.json rename to michelson_vm/tests/data/tzt/tzt_car_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_car_01.json b/michelson_vm/tests/data/tzt/tzt_car_01.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_car_01.json rename to michelson_vm/tests/data/tzt/tzt_car_01.json diff --git a/tezos_vm/tests/data/tzt/tzt_cdr_00.json b/michelson_vm/tests/data/tzt/tzt_cdr_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_cdr_00.json rename to michelson_vm/tests/data/tzt/tzt_cdr_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_cdr_01.json b/michelson_vm/tests/data/tzt/tzt_cdr_01.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_cdr_01.json rename to michelson_vm/tests/data/tzt/tzt_cdr_01.json diff --git a/tezos_vm/tests/data/tzt/tzt_chain_id_00.json b/michelson_vm/tests/data/tzt/tzt_chain_id_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_chain_id_00.json rename to michelson_vm/tests/data/tzt/tzt_chain_id_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_chain_id_01.json b/michelson_vm/tests/data/tzt/tzt_chain_id_01.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_chain_id_01.json rename to michelson_vm/tests/data/tzt/tzt_chain_id_01.json diff --git a/tezos_vm/tests/data/tzt/tzt_compare_bool_00.json b/michelson_vm/tests/data/tzt/tzt_compare_bool_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_compare_bool_00.json rename to michelson_vm/tests/data/tzt/tzt_compare_bool_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_compare_bool_01.json b/michelson_vm/tests/data/tzt/tzt_compare_bool_01.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_compare_bool_01.json rename to michelson_vm/tests/data/tzt/tzt_compare_bool_01.json diff --git a/tezos_vm/tests/data/tzt/tzt_compare_bool_02.json b/michelson_vm/tests/data/tzt/tzt_compare_bool_02.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_compare_bool_02.json rename to michelson_vm/tests/data/tzt/tzt_compare_bool_02.json diff --git a/tezos_vm/tests/data/tzt/tzt_compare_bool_03.json b/michelson_vm/tests/data/tzt/tzt_compare_bool_03.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_compare_bool_03.json rename to michelson_vm/tests/data/tzt/tzt_compare_bool_03.json diff --git a/tezos_vm/tests/data/tzt/tzt_compare_bytes_00.json b/michelson_vm/tests/data/tzt/tzt_compare_bytes_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_compare_bytes_00.json rename to michelson_vm/tests/data/tzt/tzt_compare_bytes_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_compare_bytes_01.json b/michelson_vm/tests/data/tzt/tzt_compare_bytes_01.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_compare_bytes_01.json rename to michelson_vm/tests/data/tzt/tzt_compare_bytes_01.json diff --git a/tezos_vm/tests/data/tzt/tzt_compare_bytes_02.json b/michelson_vm/tests/data/tzt/tzt_compare_bytes_02.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_compare_bytes_02.json rename to michelson_vm/tests/data/tzt/tzt_compare_bytes_02.json diff --git a/tezos_vm/tests/data/tzt/tzt_compare_bytes_03.json b/michelson_vm/tests/data/tzt/tzt_compare_bytes_03.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_compare_bytes_03.json rename to michelson_vm/tests/data/tzt/tzt_compare_bytes_03.json diff --git a/tezos_vm/tests/data/tzt/tzt_compare_bytes_04.json b/michelson_vm/tests/data/tzt/tzt_compare_bytes_04.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_compare_bytes_04.json rename to michelson_vm/tests/data/tzt/tzt_compare_bytes_04.json diff --git a/tezos_vm/tests/data/tzt/tzt_compare_int_00.json b/michelson_vm/tests/data/tzt/tzt_compare_int_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_compare_int_00.json rename to michelson_vm/tests/data/tzt/tzt_compare_int_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_compare_int_01.json b/michelson_vm/tests/data/tzt/tzt_compare_int_01.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_compare_int_01.json rename to michelson_vm/tests/data/tzt/tzt_compare_int_01.json diff --git a/tezos_vm/tests/data/tzt/tzt_compare_int_02.json b/michelson_vm/tests/data/tzt/tzt_compare_int_02.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_compare_int_02.json rename to michelson_vm/tests/data/tzt/tzt_compare_int_02.json diff --git a/tezos_vm/tests/data/tzt/tzt_compare_int_03.json b/michelson_vm/tests/data/tzt/tzt_compare_int_03.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_compare_int_03.json rename to michelson_vm/tests/data/tzt/tzt_compare_int_03.json diff --git a/tezos_vm/tests/data/tzt/tzt_compare_int_04.json b/michelson_vm/tests/data/tzt/tzt_compare_int_04.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_compare_int_04.json rename to michelson_vm/tests/data/tzt/tzt_compare_int_04.json diff --git a/tezos_vm/tests/data/tzt/tzt_compare_keyhash_00.json b/michelson_vm/tests/data/tzt/tzt_compare_keyhash_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_compare_keyhash_00.json rename to michelson_vm/tests/data/tzt/tzt_compare_keyhash_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_compare_keyhash_01.json b/michelson_vm/tests/data/tzt/tzt_compare_keyhash_01.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_compare_keyhash_01.json rename to michelson_vm/tests/data/tzt/tzt_compare_keyhash_01.json diff --git a/tezos_vm/tests/data/tzt/tzt_compare_keyhash_02.json b/michelson_vm/tests/data/tzt/tzt_compare_keyhash_02.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_compare_keyhash_02.json rename to michelson_vm/tests/data/tzt/tzt_compare_keyhash_02.json diff --git a/tezos_vm/tests/data/tzt/tzt_compare_mutez_00.json b/michelson_vm/tests/data/tzt/tzt_compare_mutez_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_compare_mutez_00.json rename to michelson_vm/tests/data/tzt/tzt_compare_mutez_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_compare_mutez_01.json b/michelson_vm/tests/data/tzt/tzt_compare_mutez_01.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_compare_mutez_01.json rename to michelson_vm/tests/data/tzt/tzt_compare_mutez_01.json diff --git a/tezos_vm/tests/data/tzt/tzt_compare_mutez_02.json b/michelson_vm/tests/data/tzt/tzt_compare_mutez_02.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_compare_mutez_02.json rename to michelson_vm/tests/data/tzt/tzt_compare_mutez_02.json diff --git a/tezos_vm/tests/data/tzt/tzt_compare_mutez_03.json b/michelson_vm/tests/data/tzt/tzt_compare_mutez_03.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_compare_mutez_03.json rename to michelson_vm/tests/data/tzt/tzt_compare_mutez_03.json diff --git a/tezos_vm/tests/data/tzt/tzt_compare_mutez_04.json b/michelson_vm/tests/data/tzt/tzt_compare_mutez_04.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_compare_mutez_04.json rename to michelson_vm/tests/data/tzt/tzt_compare_mutez_04.json diff --git a/tezos_vm/tests/data/tzt/tzt_compare_mutez_05.json b/michelson_vm/tests/data/tzt/tzt_compare_mutez_05.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_compare_mutez_05.json rename to michelson_vm/tests/data/tzt/tzt_compare_mutez_05.json diff --git a/tezos_vm/tests/data/tzt/tzt_compare_nat_00.json b/michelson_vm/tests/data/tzt/tzt_compare_nat_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_compare_nat_00.json rename to michelson_vm/tests/data/tzt/tzt_compare_nat_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_compare_nat_01.json b/michelson_vm/tests/data/tzt/tzt_compare_nat_01.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_compare_nat_01.json rename to michelson_vm/tests/data/tzt/tzt_compare_nat_01.json diff --git a/tezos_vm/tests/data/tzt/tzt_compare_nat_02.json b/michelson_vm/tests/data/tzt/tzt_compare_nat_02.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_compare_nat_02.json rename to michelson_vm/tests/data/tzt/tzt_compare_nat_02.json diff --git a/tezos_vm/tests/data/tzt/tzt_compare_nat_03.json b/michelson_vm/tests/data/tzt/tzt_compare_nat_03.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_compare_nat_03.json rename to michelson_vm/tests/data/tzt/tzt_compare_nat_03.json diff --git a/tezos_vm/tests/data/tzt/tzt_compare_nat_04.json b/michelson_vm/tests/data/tzt/tzt_compare_nat_04.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_compare_nat_04.json rename to michelson_vm/tests/data/tzt/tzt_compare_nat_04.json diff --git a/tezos_vm/tests/data/tzt/tzt_compare_nat_05.json b/michelson_vm/tests/data/tzt/tzt_compare_nat_05.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_compare_nat_05.json rename to michelson_vm/tests/data/tzt/tzt_compare_nat_05.json diff --git a/tezos_vm/tests/data/tzt/tzt_compare_pairintint_00.json b/michelson_vm/tests/data/tzt/tzt_compare_pairintint_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_compare_pairintint_00.json rename to michelson_vm/tests/data/tzt/tzt_compare_pairintint_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_compare_pairintint_01.json b/michelson_vm/tests/data/tzt/tzt_compare_pairintint_01.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_compare_pairintint_01.json rename to michelson_vm/tests/data/tzt/tzt_compare_pairintint_01.json diff --git a/tezos_vm/tests/data/tzt/tzt_compare_pairintint_02.json b/michelson_vm/tests/data/tzt/tzt_compare_pairintint_02.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_compare_pairintint_02.json rename to michelson_vm/tests/data/tzt/tzt_compare_pairintint_02.json diff --git a/tezos_vm/tests/data/tzt/tzt_compare_pairintint_03.json b/michelson_vm/tests/data/tzt/tzt_compare_pairintint_03.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_compare_pairintint_03.json rename to michelson_vm/tests/data/tzt/tzt_compare_pairintint_03.json diff --git a/tezos_vm/tests/data/tzt/tzt_compare_string_00.json b/michelson_vm/tests/data/tzt/tzt_compare_string_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_compare_string_00.json rename to michelson_vm/tests/data/tzt/tzt_compare_string_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_compare_string_01.json b/michelson_vm/tests/data/tzt/tzt_compare_string_01.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_compare_string_01.json rename to michelson_vm/tests/data/tzt/tzt_compare_string_01.json diff --git a/tezos_vm/tests/data/tzt/tzt_compare_string_02.json b/michelson_vm/tests/data/tzt/tzt_compare_string_02.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_compare_string_02.json rename to michelson_vm/tests/data/tzt/tzt_compare_string_02.json diff --git a/tezos_vm/tests/data/tzt/tzt_compare_string_03.json b/michelson_vm/tests/data/tzt/tzt_compare_string_03.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_compare_string_03.json rename to michelson_vm/tests/data/tzt/tzt_compare_string_03.json diff --git a/tezos_vm/tests/data/tzt/tzt_compare_string_04.json b/michelson_vm/tests/data/tzt/tzt_compare_string_04.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_compare_string_04.json rename to michelson_vm/tests/data/tzt/tzt_compare_string_04.json diff --git a/tezos_vm/tests/data/tzt/tzt_compare_timestamp_00.json b/michelson_vm/tests/data/tzt/tzt_compare_timestamp_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_compare_timestamp_00.json rename to michelson_vm/tests/data/tzt/tzt_compare_timestamp_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_compare_timestamp_01.json b/michelson_vm/tests/data/tzt/tzt_compare_timestamp_01.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_compare_timestamp_01.json rename to michelson_vm/tests/data/tzt/tzt_compare_timestamp_01.json diff --git a/tezos_vm/tests/data/tzt/tzt_compare_timestamp_02.json b/michelson_vm/tests/data/tzt/tzt_compare_timestamp_02.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_compare_timestamp_02.json rename to michelson_vm/tests/data/tzt/tzt_compare_timestamp_02.json diff --git a/tezos_vm/tests/data/tzt/tzt_compare_timestamp_03.json b/michelson_vm/tests/data/tzt/tzt_compare_timestamp_03.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_compare_timestamp_03.json rename to michelson_vm/tests/data/tzt/tzt_compare_timestamp_03.json diff --git a/tezos_vm/tests/data/tzt/tzt_compare_timestamp_04.json b/michelson_vm/tests/data/tzt/tzt_compare_timestamp_04.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_compare_timestamp_04.json rename to michelson_vm/tests/data/tzt/tzt_compare_timestamp_04.json diff --git a/tezos_vm/tests/data/tzt/tzt_compare_timestamp_05.json b/michelson_vm/tests/data/tzt/tzt_compare_timestamp_05.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_compare_timestamp_05.json rename to michelson_vm/tests/data/tzt/tzt_compare_timestamp_05.json diff --git a/tezos_vm/tests/data/tzt/tzt_concat_bytes_00.json b/michelson_vm/tests/data/tzt/tzt_concat_bytes_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_concat_bytes_00.json rename to michelson_vm/tests/data/tzt/tzt_concat_bytes_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_concat_bytes_01.json b/michelson_vm/tests/data/tzt/tzt_concat_bytes_01.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_concat_bytes_01.json rename to michelson_vm/tests/data/tzt/tzt_concat_bytes_01.json diff --git a/tezos_vm/tests/data/tzt/tzt_concat_listbytes_00.json b/michelson_vm/tests/data/tzt/tzt_concat_listbytes_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_concat_listbytes_00.json rename to michelson_vm/tests/data/tzt/tzt_concat_listbytes_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_concat_listbytes_01.json b/michelson_vm/tests/data/tzt/tzt_concat_listbytes_01.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_concat_listbytes_01.json rename to michelson_vm/tests/data/tzt/tzt_concat_listbytes_01.json diff --git a/tezos_vm/tests/data/tzt/tzt_concat_listbytes_02.json b/michelson_vm/tests/data/tzt/tzt_concat_listbytes_02.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_concat_listbytes_02.json rename to michelson_vm/tests/data/tzt/tzt_concat_listbytes_02.json diff --git a/tezos_vm/tests/data/tzt/tzt_concat_liststring_00.json b/michelson_vm/tests/data/tzt/tzt_concat_liststring_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_concat_liststring_00.json rename to michelson_vm/tests/data/tzt/tzt_concat_liststring_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_concat_liststring_01.json b/michelson_vm/tests/data/tzt/tzt_concat_liststring_01.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_concat_liststring_01.json rename to michelson_vm/tests/data/tzt/tzt_concat_liststring_01.json diff --git a/tezos_vm/tests/data/tzt/tzt_concat_liststring_02.json b/michelson_vm/tests/data/tzt/tzt_concat_liststring_02.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_concat_liststring_02.json rename to michelson_vm/tests/data/tzt/tzt_concat_liststring_02.json diff --git a/tezos_vm/tests/data/tzt/tzt_concat_liststring_03.json b/michelson_vm/tests/data/tzt/tzt_concat_liststring_03.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_concat_liststring_03.json rename to michelson_vm/tests/data/tzt/tzt_concat_liststring_03.json diff --git a/tezos_vm/tests/data/tzt/tzt_concat_liststring_04.json b/michelson_vm/tests/data/tzt/tzt_concat_liststring_04.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_concat_liststring_04.json rename to michelson_vm/tests/data/tzt/tzt_concat_liststring_04.json diff --git a/tezos_vm/tests/data/tzt/tzt_concat_string_00.json b/michelson_vm/tests/data/tzt/tzt_concat_string_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_concat_string_00.json rename to michelson_vm/tests/data/tzt/tzt_concat_string_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_concat_string_01.json b/michelson_vm/tests/data/tzt/tzt_concat_string_01.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_concat_string_01.json rename to michelson_vm/tests/data/tzt/tzt_concat_string_01.json diff --git a/tezos_vm/tests/data/tzt/tzt_concat_string_02.json b/michelson_vm/tests/data/tzt/tzt_concat_string_02.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_concat_string_02.json rename to michelson_vm/tests/data/tzt/tzt_concat_string_02.json diff --git a/tezos_vm/tests/data/tzt/tzt_cons_int_00.json b/michelson_vm/tests/data/tzt/tzt_cons_int_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_cons_int_00.json rename to michelson_vm/tests/data/tzt/tzt_cons_int_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_cons_int_01.json b/michelson_vm/tests/data/tzt/tzt_cons_int_01.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_cons_int_01.json rename to michelson_vm/tests/data/tzt/tzt_cons_int_01.json diff --git a/tezos_vm/tests/data/tzt/tzt_cons_int_02.json b/michelson_vm/tests/data/tzt/tzt_cons_int_02.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_cons_int_02.json rename to michelson_vm/tests/data/tzt/tzt_cons_int_02.json diff --git a/tezos_vm/tests/data/tzt/tzt_cons_string_00.json b/michelson_vm/tests/data/tzt/tzt_cons_string_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_cons_string_00.json rename to michelson_vm/tests/data/tzt/tzt_cons_string_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_contract_00.json b/michelson_vm/tests/data/tzt/tzt_contract_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_contract_00.json rename to michelson_vm/tests/data/tzt/tzt_contract_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_contract_01.json b/michelson_vm/tests/data/tzt/tzt_contract_01.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_contract_01.json rename to michelson_vm/tests/data/tzt/tzt_contract_01.json diff --git a/tezos_vm/tests/data/tzt/tzt_contract_02.json b/michelson_vm/tests/data/tzt/tzt_contract_02.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_contract_02.json rename to michelson_vm/tests/data/tzt/tzt_contract_02.json diff --git a/tezos_vm/tests/data/tzt/tzt_contract_03.json b/michelson_vm/tests/data/tzt/tzt_contract_03.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_contract_03.json rename to michelson_vm/tests/data/tzt/tzt_contract_03.json diff --git a/tezos_vm/tests/data/tzt/tzt_contract_04.json b/michelson_vm/tests/data/tzt/tzt_contract_04.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_contract_04.json rename to michelson_vm/tests/data/tzt/tzt_contract_04.json diff --git a/tezos_vm/tests/data/tzt/tzt_contract_05.json b/michelson_vm/tests/data/tzt/tzt_contract_05.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_contract_05.json rename to michelson_vm/tests/data/tzt/tzt_contract_05.json diff --git a/tezos_vm/tests/data/tzt/tzt_dig_00.json b/michelson_vm/tests/data/tzt/tzt_dig_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_dig_00.json rename to michelson_vm/tests/data/tzt/tzt_dig_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_dig_01.json b/michelson_vm/tests/data/tzt/tzt_dig_01.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_dig_01.json rename to michelson_vm/tests/data/tzt/tzt_dig_01.json diff --git a/tezos_vm/tests/data/tzt/tzt_dig_02.json b/michelson_vm/tests/data/tzt/tzt_dig_02.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_dig_02.json rename to michelson_vm/tests/data/tzt/tzt_dig_02.json diff --git a/tezos_vm/tests/data/tzt/tzt_dig_03.json b/michelson_vm/tests/data/tzt/tzt_dig_03.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_dig_03.json rename to michelson_vm/tests/data/tzt/tzt_dig_03.json diff --git a/tezos_vm/tests/data/tzt/tzt_dig_04.json b/michelson_vm/tests/data/tzt/tzt_dig_04.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_dig_04.json rename to michelson_vm/tests/data/tzt/tzt_dig_04.json diff --git a/tezos_vm/tests/data/tzt/tzt_dip_00.json b/michelson_vm/tests/data/tzt/tzt_dip_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_dip_00.json rename to michelson_vm/tests/data/tzt/tzt_dip_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_dip_01.json b/michelson_vm/tests/data/tzt/tzt_dip_01.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_dip_01.json rename to michelson_vm/tests/data/tzt/tzt_dip_01.json diff --git a/tezos_vm/tests/data/tzt/tzt_dip_02.json b/michelson_vm/tests/data/tzt/tzt_dip_02.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_dip_02.json rename to michelson_vm/tests/data/tzt/tzt_dip_02.json diff --git a/tezos_vm/tests/data/tzt/tzt_dipn_00.json b/michelson_vm/tests/data/tzt/tzt_dipn_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_dipn_00.json rename to michelson_vm/tests/data/tzt/tzt_dipn_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_drop_00.json b/michelson_vm/tests/data/tzt/tzt_drop_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_drop_00.json rename to michelson_vm/tests/data/tzt/tzt_drop_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_dropn_00.json b/michelson_vm/tests/data/tzt/tzt_dropn_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_dropn_00.json rename to michelson_vm/tests/data/tzt/tzt_dropn_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_dropn_01.json b/michelson_vm/tests/data/tzt/tzt_dropn_01.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_dropn_01.json rename to michelson_vm/tests/data/tzt/tzt_dropn_01.json diff --git a/tezos_vm/tests/data/tzt/tzt_dugn_00.json b/michelson_vm/tests/data/tzt/tzt_dugn_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_dugn_00.json rename to michelson_vm/tests/data/tzt/tzt_dugn_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_ediv_int_int_00.json b/michelson_vm/tests/data/tzt/tzt_ediv_int_int_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_ediv_int_int_00.json rename to michelson_vm/tests/data/tzt/tzt_ediv_int_int_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_ediv_int_int_01.json b/michelson_vm/tests/data/tzt/tzt_ediv_int_int_01.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_ediv_int_int_01.json rename to michelson_vm/tests/data/tzt/tzt_ediv_int_int_01.json diff --git a/tezos_vm/tests/data/tzt/tzt_ediv_int_int_02.json b/michelson_vm/tests/data/tzt/tzt_ediv_int_int_02.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_ediv_int_int_02.json rename to michelson_vm/tests/data/tzt/tzt_ediv_int_int_02.json diff --git a/tezos_vm/tests/data/tzt/tzt_ediv_int_int_03.json b/michelson_vm/tests/data/tzt/tzt_ediv_int_int_03.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_ediv_int_int_03.json rename to michelson_vm/tests/data/tzt/tzt_ediv_int_int_03.json diff --git a/tezos_vm/tests/data/tzt/tzt_ediv_mutez_mutez_00.json b/michelson_vm/tests/data/tzt/tzt_ediv_mutez_mutez_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_ediv_mutez_mutez_00.json rename to michelson_vm/tests/data/tzt/tzt_ediv_mutez_mutez_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_ediv_mutez_mutez_01.json b/michelson_vm/tests/data/tzt/tzt_ediv_mutez_mutez_01.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_ediv_mutez_mutez_01.json rename to michelson_vm/tests/data/tzt/tzt_ediv_mutez_mutez_01.json diff --git a/tezos_vm/tests/data/tzt/tzt_ediv_mutez_mutez_02.json b/michelson_vm/tests/data/tzt/tzt_ediv_mutez_mutez_02.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_ediv_mutez_mutez_02.json rename to michelson_vm/tests/data/tzt/tzt_ediv_mutez_mutez_02.json diff --git a/tezos_vm/tests/data/tzt/tzt_ediv_mutez_mutez_03.json b/michelson_vm/tests/data/tzt/tzt_ediv_mutez_mutez_03.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_ediv_mutez_mutez_03.json rename to michelson_vm/tests/data/tzt/tzt_ediv_mutez_mutez_03.json diff --git a/tezos_vm/tests/data/tzt/tzt_ediv_mutez_nat_00.json b/michelson_vm/tests/data/tzt/tzt_ediv_mutez_nat_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_ediv_mutez_nat_00.json rename to michelson_vm/tests/data/tzt/tzt_ediv_mutez_nat_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_ediv_mutez_nat_01.json b/michelson_vm/tests/data/tzt/tzt_ediv_mutez_nat_01.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_ediv_mutez_nat_01.json rename to michelson_vm/tests/data/tzt/tzt_ediv_mutez_nat_01.json diff --git a/tezos_vm/tests/data/tzt/tzt_ediv_mutez_nat_02.json b/michelson_vm/tests/data/tzt/tzt_ediv_mutez_nat_02.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_ediv_mutez_nat_02.json rename to michelson_vm/tests/data/tzt/tzt_ediv_mutez_nat_02.json diff --git a/tezos_vm/tests/data/tzt/tzt_ediv_mutez_nat_03.json b/michelson_vm/tests/data/tzt/tzt_ediv_mutez_nat_03.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_ediv_mutez_nat_03.json rename to michelson_vm/tests/data/tzt/tzt_ediv_mutez_nat_03.json diff --git a/tezos_vm/tests/data/tzt/tzt_ediv_mutez_nat_04.json b/michelson_vm/tests/data/tzt/tzt_ediv_mutez_nat_04.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_ediv_mutez_nat_04.json rename to michelson_vm/tests/data/tzt/tzt_ediv_mutez_nat_04.json diff --git a/tezos_vm/tests/data/tzt/tzt_ediv_mutez_nat_05.json b/michelson_vm/tests/data/tzt/tzt_ediv_mutez_nat_05.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_ediv_mutez_nat_05.json rename to michelson_vm/tests/data/tzt/tzt_ediv_mutez_nat_05.json diff --git a/tezos_vm/tests/data/tzt/tzt_ediv_mutez_nat_06.json b/michelson_vm/tests/data/tzt/tzt_ediv_mutez_nat_06.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_ediv_mutez_nat_06.json rename to michelson_vm/tests/data/tzt/tzt_ediv_mutez_nat_06.json diff --git a/tezos_vm/tests/data/tzt/tzt_emptybigmap_nat_nat_00.json b/michelson_vm/tests/data/tzt/tzt_emptybigmap_nat_nat_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_emptybigmap_nat_nat_00.json rename to michelson_vm/tests/data/tzt/tzt_emptybigmap_nat_nat_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_emptymap_nat_nat_00.json b/michelson_vm/tests/data/tzt/tzt_emptymap_nat_nat_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_emptymap_nat_nat_00.json rename to michelson_vm/tests/data/tzt/tzt_emptymap_nat_nat_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_emptymap_string_string_00.json b/michelson_vm/tests/data/tzt/tzt_emptymap_string_string_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_emptymap_string_string_00.json rename to michelson_vm/tests/data/tzt/tzt_emptymap_string_string_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_emptyset_nat_00.json b/michelson_vm/tests/data/tzt/tzt_emptyset_nat_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_emptyset_nat_00.json rename to michelson_vm/tests/data/tzt/tzt_emptyset_nat_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_eq_00.json b/michelson_vm/tests/data/tzt/tzt_eq_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_eq_00.json rename to michelson_vm/tests/data/tzt/tzt_eq_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_eq_01.json b/michelson_vm/tests/data/tzt/tzt_eq_01.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_eq_01.json rename to michelson_vm/tests/data/tzt/tzt_eq_01.json diff --git a/tezos_vm/tests/data/tzt/tzt_eq_02.json b/michelson_vm/tests/data/tzt/tzt_eq_02.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_eq_02.json rename to michelson_vm/tests/data/tzt/tzt_eq_02.json diff --git a/tezos_vm/tests/data/tzt/tzt_eq_03.json b/michelson_vm/tests/data/tzt/tzt_eq_03.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_eq_03.json rename to michelson_vm/tests/data/tzt/tzt_eq_03.json diff --git a/tezos_vm/tests/data/tzt/tzt_eq_04.json b/michelson_vm/tests/data/tzt/tzt_eq_04.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_eq_04.json rename to michelson_vm/tests/data/tzt/tzt_eq_04.json diff --git a/tezos_vm/tests/data/tzt/tzt_exec_00.json b/michelson_vm/tests/data/tzt/tzt_exec_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_exec_00.json rename to michelson_vm/tests/data/tzt/tzt_exec_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_exec_01.json b/michelson_vm/tests/data/tzt/tzt_exec_01.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_exec_01.json rename to michelson_vm/tests/data/tzt/tzt_exec_01.json diff --git a/tezos_vm/tests/data/tzt/tzt_exec_02.json b/michelson_vm/tests/data/tzt/tzt_exec_02.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_exec_02.json rename to michelson_vm/tests/data/tzt/tzt_exec_02.json diff --git a/tezos_vm/tests/data/tzt/tzt_exec_03.json b/michelson_vm/tests/data/tzt/tzt_exec_03.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_exec_03.json rename to michelson_vm/tests/data/tzt/tzt_exec_03.json diff --git a/tezos_vm/tests/data/tzt/tzt_failwith_00.json b/michelson_vm/tests/data/tzt/tzt_failwith_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_failwith_00.json rename to michelson_vm/tests/data/tzt/tzt_failwith_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_ge_00.json b/michelson_vm/tests/data/tzt/tzt_ge_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_ge_00.json rename to michelson_vm/tests/data/tzt/tzt_ge_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_ge_01.json b/michelson_vm/tests/data/tzt/tzt_ge_01.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_ge_01.json rename to michelson_vm/tests/data/tzt/tzt_ge_01.json diff --git a/tezos_vm/tests/data/tzt/tzt_ge_02.json b/michelson_vm/tests/data/tzt/tzt_ge_02.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_ge_02.json rename to michelson_vm/tests/data/tzt/tzt_ge_02.json diff --git a/tezos_vm/tests/data/tzt/tzt_ge_03.json b/michelson_vm/tests/data/tzt/tzt_ge_03.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_ge_03.json rename to michelson_vm/tests/data/tzt/tzt_ge_03.json diff --git a/tezos_vm/tests/data/tzt/tzt_ge_04.json b/michelson_vm/tests/data/tzt/tzt_ge_04.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_ge_04.json rename to michelson_vm/tests/data/tzt/tzt_ge_04.json diff --git a/tezos_vm/tests/data/tzt/tzt_get_bigmapstringstring_00.json b/michelson_vm/tests/data/tzt/tzt_get_bigmapstringstring_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_get_bigmapstringstring_00.json rename to michelson_vm/tests/data/tzt/tzt_get_bigmapstringstring_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_get_bigmapstringstring_01.json b/michelson_vm/tests/data/tzt/tzt_get_bigmapstringstring_01.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_get_bigmapstringstring_01.json rename to michelson_vm/tests/data/tzt/tzt_get_bigmapstringstring_01.json diff --git a/tezos_vm/tests/data/tzt/tzt_get_bigmapstringstring_02.json b/michelson_vm/tests/data/tzt/tzt_get_bigmapstringstring_02.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_get_bigmapstringstring_02.json rename to michelson_vm/tests/data/tzt/tzt_get_bigmapstringstring_02.json diff --git a/tezos_vm/tests/data/tzt/tzt_get_mapintint_00.json b/michelson_vm/tests/data/tzt/tzt_get_mapintint_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_get_mapintint_00.json rename to michelson_vm/tests/data/tzt/tzt_get_mapintint_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_get_mapintint_01.json b/michelson_vm/tests/data/tzt/tzt_get_mapintint_01.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_get_mapintint_01.json rename to michelson_vm/tests/data/tzt/tzt_get_mapintint_01.json diff --git a/tezos_vm/tests/data/tzt/tzt_get_mapstringstring_00.json b/michelson_vm/tests/data/tzt/tzt_get_mapstringstring_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_get_mapstringstring_00.json rename to michelson_vm/tests/data/tzt/tzt_get_mapstringstring_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_get_mapstringstring_01.json b/michelson_vm/tests/data/tzt/tzt_get_mapstringstring_01.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_get_mapstringstring_01.json rename to michelson_vm/tests/data/tzt/tzt_get_mapstringstring_01.json diff --git a/tezos_vm/tests/data/tzt/tzt_get_mapstringstring_02.json b/michelson_vm/tests/data/tzt/tzt_get_mapstringstring_02.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_get_mapstringstring_02.json rename to michelson_vm/tests/data/tzt/tzt_get_mapstringstring_02.json diff --git a/tezos_vm/tests/data/tzt/tzt_gt_00.json b/michelson_vm/tests/data/tzt/tzt_gt_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_gt_00.json rename to michelson_vm/tests/data/tzt/tzt_gt_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_gt_01.json b/michelson_vm/tests/data/tzt/tzt_gt_01.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_gt_01.json rename to michelson_vm/tests/data/tzt/tzt_gt_01.json diff --git a/tezos_vm/tests/data/tzt/tzt_gt_02.json b/michelson_vm/tests/data/tzt/tzt_gt_02.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_gt_02.json rename to michelson_vm/tests/data/tzt/tzt_gt_02.json diff --git a/tezos_vm/tests/data/tzt/tzt_gt_03.json b/michelson_vm/tests/data/tzt/tzt_gt_03.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_gt_03.json rename to michelson_vm/tests/data/tzt/tzt_gt_03.json diff --git a/tezos_vm/tests/data/tzt/tzt_gt_04.json b/michelson_vm/tests/data/tzt/tzt_gt_04.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_gt_04.json rename to michelson_vm/tests/data/tzt/tzt_gt_04.json diff --git a/tezos_vm/tests/data/tzt/tzt_if_00.json b/michelson_vm/tests/data/tzt/tzt_if_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_if_00.json rename to michelson_vm/tests/data/tzt/tzt_if_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_if_01.json b/michelson_vm/tests/data/tzt/tzt_if_01.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_if_01.json rename to michelson_vm/tests/data/tzt/tzt_if_01.json diff --git a/tezos_vm/tests/data/tzt/tzt_ifcons_listint_00.json b/michelson_vm/tests/data/tzt/tzt_ifcons_listint_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_ifcons_listint_00.json rename to michelson_vm/tests/data/tzt/tzt_ifcons_listint_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_ifcons_listint_01.json b/michelson_vm/tests/data/tzt/tzt_ifcons_listint_01.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_ifcons_listint_01.json rename to michelson_vm/tests/data/tzt/tzt_ifcons_listint_01.json diff --git a/tezos_vm/tests/data/tzt/tzt_ifcons_listnat_00.json b/michelson_vm/tests/data/tzt/tzt_ifcons_listnat_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_ifcons_listnat_00.json rename to michelson_vm/tests/data/tzt/tzt_ifcons_listnat_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_ifcons_listnat_01.json b/michelson_vm/tests/data/tzt/tzt_ifcons_listnat_01.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_ifcons_listnat_01.json rename to michelson_vm/tests/data/tzt/tzt_ifcons_listnat_01.json diff --git a/tezos_vm/tests/data/tzt/tzt_ifleft_orintstring_00.json b/michelson_vm/tests/data/tzt/tzt_ifleft_orintstring_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_ifleft_orintstring_00.json rename to michelson_vm/tests/data/tzt/tzt_ifleft_orintstring_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_ifleft_orstringint_00.json b/michelson_vm/tests/data/tzt/tzt_ifleft_orstringint_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_ifleft_orstringint_00.json rename to michelson_vm/tests/data/tzt/tzt_ifleft_orstringint_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_ifnone_optionint_00.json b/michelson_vm/tests/data/tzt/tzt_ifnone_optionint_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_ifnone_optionint_00.json rename to michelson_vm/tests/data/tzt/tzt_ifnone_optionint_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_ifnone_optionnat_00.json b/michelson_vm/tests/data/tzt/tzt_ifnone_optionnat_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_ifnone_optionnat_00.json rename to michelson_vm/tests/data/tzt/tzt_ifnone_optionnat_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_implicitaccount_00.json b/michelson_vm/tests/data/tzt/tzt_implicitaccount_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_implicitaccount_00.json rename to michelson_vm/tests/data/tzt/tzt_implicitaccount_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_int_nat_00.json b/michelson_vm/tests/data/tzt/tzt_int_nat_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_int_nat_00.json rename to michelson_vm/tests/data/tzt/tzt_int_nat_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_int_nat_01.json b/michelson_vm/tests/data/tzt/tzt_int_nat_01.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_int_nat_01.json rename to michelson_vm/tests/data/tzt/tzt_int_nat_01.json diff --git a/tezos_vm/tests/data/tzt/tzt_isnat_00.json b/michelson_vm/tests/data/tzt/tzt_isnat_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_isnat_00.json rename to michelson_vm/tests/data/tzt/tzt_isnat_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_isnat_01.json b/michelson_vm/tests/data/tzt/tzt_isnat_01.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_isnat_01.json rename to michelson_vm/tests/data/tzt/tzt_isnat_01.json diff --git a/tezos_vm/tests/data/tzt/tzt_iter_listint_00.json b/michelson_vm/tests/data/tzt/tzt_iter_listint_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_iter_listint_00.json rename to michelson_vm/tests/data/tzt/tzt_iter_listint_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_iter_listint_01.json b/michelson_vm/tests/data/tzt/tzt_iter_listint_01.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_iter_listint_01.json rename to michelson_vm/tests/data/tzt/tzt_iter_listint_01.json diff --git a/tezos_vm/tests/data/tzt/tzt_iter_listint_02.json b/michelson_vm/tests/data/tzt/tzt_iter_listint_02.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_iter_listint_02.json rename to michelson_vm/tests/data/tzt/tzt_iter_listint_02.json diff --git a/tezos_vm/tests/data/tzt/tzt_iter_listint_03.json b/michelson_vm/tests/data/tzt/tzt_iter_listint_03.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_iter_listint_03.json rename to michelson_vm/tests/data/tzt/tzt_iter_listint_03.json diff --git a/tezos_vm/tests/data/tzt/tzt_iter_liststring_00.json b/michelson_vm/tests/data/tzt/tzt_iter_liststring_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_iter_liststring_00.json rename to michelson_vm/tests/data/tzt/tzt_iter_liststring_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_iter_liststring_01.json b/michelson_vm/tests/data/tzt/tzt_iter_liststring_01.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_iter_liststring_01.json rename to michelson_vm/tests/data/tzt/tzt_iter_liststring_01.json diff --git a/tezos_vm/tests/data/tzt/tzt_iter_mapintint_00.json b/michelson_vm/tests/data/tzt/tzt_iter_mapintint_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_iter_mapintint_00.json rename to michelson_vm/tests/data/tzt/tzt_iter_mapintint_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_iter_mapintint_01.json b/michelson_vm/tests/data/tzt/tzt_iter_mapintint_01.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_iter_mapintint_01.json rename to michelson_vm/tests/data/tzt/tzt_iter_mapintint_01.json diff --git a/tezos_vm/tests/data/tzt/tzt_iter_mapintint_02.json b/michelson_vm/tests/data/tzt/tzt_iter_mapintint_02.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_iter_mapintint_02.json rename to michelson_vm/tests/data/tzt/tzt_iter_mapintint_02.json diff --git a/tezos_vm/tests/data/tzt/tzt_iter_mapintint_03.json b/michelson_vm/tests/data/tzt/tzt_iter_mapintint_03.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_iter_mapintint_03.json rename to michelson_vm/tests/data/tzt/tzt_iter_mapintint_03.json diff --git a/tezos_vm/tests/data/tzt/tzt_iter_mapintint_04.json b/michelson_vm/tests/data/tzt/tzt_iter_mapintint_04.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_iter_mapintint_04.json rename to michelson_vm/tests/data/tzt/tzt_iter_mapintint_04.json diff --git a/tezos_vm/tests/data/tzt/tzt_iter_mapstringstring_00.json b/michelson_vm/tests/data/tzt/tzt_iter_mapstringstring_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_iter_mapstringstring_00.json rename to michelson_vm/tests/data/tzt/tzt_iter_mapstringstring_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_iter_setint_00.json b/michelson_vm/tests/data/tzt/tzt_iter_setint_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_iter_setint_00.json rename to michelson_vm/tests/data/tzt/tzt_iter_setint_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_iter_setint_01.json b/michelson_vm/tests/data/tzt/tzt_iter_setint_01.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_iter_setint_01.json rename to michelson_vm/tests/data/tzt/tzt_iter_setint_01.json diff --git a/tezos_vm/tests/data/tzt/tzt_iter_setint_02.json b/michelson_vm/tests/data/tzt/tzt_iter_setint_02.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_iter_setint_02.json rename to michelson_vm/tests/data/tzt/tzt_iter_setint_02.json diff --git a/tezos_vm/tests/data/tzt/tzt_iter_setstring_00.json b/michelson_vm/tests/data/tzt/tzt_iter_setstring_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_iter_setstring_00.json rename to michelson_vm/tests/data/tzt/tzt_iter_setstring_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_iter_setstring_01.json b/michelson_vm/tests/data/tzt/tzt_iter_setstring_01.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_iter_setstring_01.json rename to michelson_vm/tests/data/tzt/tzt_iter_setstring_01.json diff --git a/tezos_vm/tests/data/tzt/tzt_iter_setstring_02.json b/michelson_vm/tests/data/tzt/tzt_iter_setstring_02.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_iter_setstring_02.json rename to michelson_vm/tests/data/tzt/tzt_iter_setstring_02.json diff --git a/tezos_vm/tests/data/tzt/tzt_le_00.json b/michelson_vm/tests/data/tzt/tzt_le_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_le_00.json rename to michelson_vm/tests/data/tzt/tzt_le_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_le_01.json b/michelson_vm/tests/data/tzt/tzt_le_01.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_le_01.json rename to michelson_vm/tests/data/tzt/tzt_le_01.json diff --git a/tezos_vm/tests/data/tzt/tzt_le_02.json b/michelson_vm/tests/data/tzt/tzt_le_02.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_le_02.json rename to michelson_vm/tests/data/tzt/tzt_le_02.json diff --git a/tezos_vm/tests/data/tzt/tzt_le_03.json b/michelson_vm/tests/data/tzt/tzt_le_03.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_le_03.json rename to michelson_vm/tests/data/tzt/tzt_le_03.json diff --git a/tezos_vm/tests/data/tzt/tzt_le_04.json b/michelson_vm/tests/data/tzt/tzt_le_04.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_le_04.json rename to michelson_vm/tests/data/tzt/tzt_le_04.json diff --git a/tezos_vm/tests/data/tzt/tzt_left_int_nat_00.json b/michelson_vm/tests/data/tzt/tzt_left_int_nat_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_left_int_nat_00.json rename to michelson_vm/tests/data/tzt/tzt_left_int_nat_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_loop_00.json b/michelson_vm/tests/data/tzt/tzt_loop_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_loop_00.json rename to michelson_vm/tests/data/tzt/tzt_loop_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_loop_01.json b/michelson_vm/tests/data/tzt/tzt_loop_01.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_loop_01.json rename to michelson_vm/tests/data/tzt/tzt_loop_01.json diff --git a/tezos_vm/tests/data/tzt/tzt_loop_02.json b/michelson_vm/tests/data/tzt/tzt_loop_02.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_loop_02.json rename to michelson_vm/tests/data/tzt/tzt_loop_02.json diff --git a/tezos_vm/tests/data/tzt/tzt_loopleft_00.json b/michelson_vm/tests/data/tzt/tzt_loopleft_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_loopleft_00.json rename to michelson_vm/tests/data/tzt/tzt_loopleft_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_loopleft_01.json b/michelson_vm/tests/data/tzt/tzt_loopleft_01.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_loopleft_01.json rename to michelson_vm/tests/data/tzt/tzt_loopleft_01.json diff --git a/tezos_vm/tests/data/tzt/tzt_loopleft_02.json b/michelson_vm/tests/data/tzt/tzt_loopleft_02.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_loopleft_02.json rename to michelson_vm/tests/data/tzt/tzt_loopleft_02.json diff --git a/tezos_vm/tests/data/tzt/tzt_loopleft_03.json b/michelson_vm/tests/data/tzt/tzt_loopleft_03.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_loopleft_03.json rename to michelson_vm/tests/data/tzt/tzt_loopleft_03.json diff --git a/tezos_vm/tests/data/tzt/tzt_loopleft_04.json b/michelson_vm/tests/data/tzt/tzt_loopleft_04.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_loopleft_04.json rename to michelson_vm/tests/data/tzt/tzt_loopleft_04.json diff --git a/tezos_vm/tests/data/tzt/tzt_lsl_00.json b/michelson_vm/tests/data/tzt/tzt_lsl_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_lsl_00.json rename to michelson_vm/tests/data/tzt/tzt_lsl_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_lsl_01.json b/michelson_vm/tests/data/tzt/tzt_lsl_01.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_lsl_01.json rename to michelson_vm/tests/data/tzt/tzt_lsl_01.json diff --git a/tezos_vm/tests/data/tzt/tzt_lsl_02.json b/michelson_vm/tests/data/tzt/tzt_lsl_02.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_lsl_02.json rename to michelson_vm/tests/data/tzt/tzt_lsl_02.json diff --git a/tezos_vm/tests/data/tzt/tzt_lsl_03.json b/michelson_vm/tests/data/tzt/tzt_lsl_03.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_lsl_03.json rename to michelson_vm/tests/data/tzt/tzt_lsl_03.json diff --git a/tezos_vm/tests/data/tzt/tzt_lsl_04.json b/michelson_vm/tests/data/tzt/tzt_lsl_04.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_lsl_04.json rename to michelson_vm/tests/data/tzt/tzt_lsl_04.json diff --git a/tezos_vm/tests/data/tzt/tzt_lsl_05.json b/michelson_vm/tests/data/tzt/tzt_lsl_05.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_lsl_05.json rename to michelson_vm/tests/data/tzt/tzt_lsl_05.json diff --git a/tezos_vm/tests/data/tzt/tzt_lsl_06.json b/michelson_vm/tests/data/tzt/tzt_lsl_06.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_lsl_06.json rename to michelson_vm/tests/data/tzt/tzt_lsl_06.json diff --git a/tezos_vm/tests/data/tzt/tzt_lsr_00.json b/michelson_vm/tests/data/tzt/tzt_lsr_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_lsr_00.json rename to michelson_vm/tests/data/tzt/tzt_lsr_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_lsr_01.json b/michelson_vm/tests/data/tzt/tzt_lsr_01.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_lsr_01.json rename to michelson_vm/tests/data/tzt/tzt_lsr_01.json diff --git a/tezos_vm/tests/data/tzt/tzt_lsr_02.json b/michelson_vm/tests/data/tzt/tzt_lsr_02.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_lsr_02.json rename to michelson_vm/tests/data/tzt/tzt_lsr_02.json diff --git a/tezos_vm/tests/data/tzt/tzt_lsr_03.json b/michelson_vm/tests/data/tzt/tzt_lsr_03.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_lsr_03.json rename to michelson_vm/tests/data/tzt/tzt_lsr_03.json diff --git a/tezos_vm/tests/data/tzt/tzt_lsr_04.json b/michelson_vm/tests/data/tzt/tzt_lsr_04.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_lsr_04.json rename to michelson_vm/tests/data/tzt/tzt_lsr_04.json diff --git a/tezos_vm/tests/data/tzt/tzt_lsr_05.json b/michelson_vm/tests/data/tzt/tzt_lsr_05.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_lsr_05.json rename to michelson_vm/tests/data/tzt/tzt_lsr_05.json diff --git a/tezos_vm/tests/data/tzt/tzt_lt_00.json b/michelson_vm/tests/data/tzt/tzt_lt_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_lt_00.json rename to michelson_vm/tests/data/tzt/tzt_lt_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_lt_01.json b/michelson_vm/tests/data/tzt/tzt_lt_01.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_lt_01.json rename to michelson_vm/tests/data/tzt/tzt_lt_01.json diff --git a/tezos_vm/tests/data/tzt/tzt_lt_02.json b/michelson_vm/tests/data/tzt/tzt_lt_02.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_lt_02.json rename to michelson_vm/tests/data/tzt/tzt_lt_02.json diff --git a/tezos_vm/tests/data/tzt/tzt_lt_03.json b/michelson_vm/tests/data/tzt/tzt_lt_03.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_lt_03.json rename to michelson_vm/tests/data/tzt/tzt_lt_03.json diff --git a/tezos_vm/tests/data/tzt/tzt_lt_04.json b/michelson_vm/tests/data/tzt/tzt_lt_04.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_lt_04.json rename to michelson_vm/tests/data/tzt/tzt_lt_04.json diff --git a/tezos_vm/tests/data/tzt/tzt_map_listint_00.json b/michelson_vm/tests/data/tzt/tzt_map_listint_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_map_listint_00.json rename to michelson_vm/tests/data/tzt/tzt_map_listint_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_map_listint_01.json b/michelson_vm/tests/data/tzt/tzt_map_listint_01.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_map_listint_01.json rename to michelson_vm/tests/data/tzt/tzt_map_listint_01.json diff --git a/tezos_vm/tests/data/tzt/tzt_map_listint_02.json b/michelson_vm/tests/data/tzt/tzt_map_listint_02.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_map_listint_02.json rename to michelson_vm/tests/data/tzt/tzt_map_listint_02.json diff --git a/tezos_vm/tests/data/tzt/tzt_map_listint_03.json b/michelson_vm/tests/data/tzt/tzt_map_listint_03.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_map_listint_03.json rename to michelson_vm/tests/data/tzt/tzt_map_listint_03.json diff --git a/tezos_vm/tests/data/tzt/tzt_map_listint_04.json b/michelson_vm/tests/data/tzt/tzt_map_listint_04.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_map_listint_04.json rename to michelson_vm/tests/data/tzt/tzt_map_listint_04.json diff --git a/tezos_vm/tests/data/tzt/tzt_map_listint_05.json b/michelson_vm/tests/data/tzt/tzt_map_listint_05.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_map_listint_05.json rename to michelson_vm/tests/data/tzt/tzt_map_listint_05.json diff --git a/tezos_vm/tests/data/tzt/tzt_map_listint_06.json b/michelson_vm/tests/data/tzt/tzt_map_listint_06.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_map_listint_06.json rename to michelson_vm/tests/data/tzt/tzt_map_listint_06.json diff --git a/tezos_vm/tests/data/tzt/tzt_map_liststring_00.json b/michelson_vm/tests/data/tzt/tzt_map_liststring_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_map_liststring_00.json rename to michelson_vm/tests/data/tzt/tzt_map_liststring_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_map_liststring_01.json b/michelson_vm/tests/data/tzt/tzt_map_liststring_01.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_map_liststring_01.json rename to michelson_vm/tests/data/tzt/tzt_map_liststring_01.json diff --git a/tezos_vm/tests/data/tzt/tzt_map_liststring_02.json b/michelson_vm/tests/data/tzt/tzt_map_liststring_02.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_map_liststring_02.json rename to michelson_vm/tests/data/tzt/tzt_map_liststring_02.json diff --git a/tezos_vm/tests/data/tzt/tzt_map_liststring_04.json b/michelson_vm/tests/data/tzt/tzt_map_liststring_04.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_map_liststring_04.json rename to michelson_vm/tests/data/tzt/tzt_map_liststring_04.json diff --git a/tezos_vm/tests/data/tzt/tzt_map_liststring_05.json b/michelson_vm/tests/data/tzt/tzt_map_liststring_05.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_map_liststring_05.json rename to michelson_vm/tests/data/tzt/tzt_map_liststring_05.json diff --git a/tezos_vm/tests/data/tzt/tzt_map_liststring_06.json b/michelson_vm/tests/data/tzt/tzt_map_liststring_06.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_map_liststring_06.json rename to michelson_vm/tests/data/tzt/tzt_map_liststring_06.json diff --git a/tezos_vm/tests/data/tzt/tzt_map_liststring_07.json b/michelson_vm/tests/data/tzt/tzt_map_liststring_07.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_map_liststring_07.json rename to michelson_vm/tests/data/tzt/tzt_map_liststring_07.json diff --git a/tezos_vm/tests/data/tzt/tzt_map_liststring_08.json b/michelson_vm/tests/data/tzt/tzt_map_liststring_08.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_map_liststring_08.json rename to michelson_vm/tests/data/tzt/tzt_map_liststring_08.json diff --git a/tezos_vm/tests/data/tzt/tzt_map_mapintint_00.json b/michelson_vm/tests/data/tzt/tzt_map_mapintint_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_map_mapintint_00.json rename to michelson_vm/tests/data/tzt/tzt_map_mapintint_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_map_mapintint_01.json b/michelson_vm/tests/data/tzt/tzt_map_mapintint_01.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_map_mapintint_01.json rename to michelson_vm/tests/data/tzt/tzt_map_mapintint_01.json diff --git a/tezos_vm/tests/data/tzt/tzt_map_mapintstring_00.json b/michelson_vm/tests/data/tzt/tzt_map_mapintstring_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_map_mapintstring_00.json rename to michelson_vm/tests/data/tzt/tzt_map_mapintstring_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_map_mapintstring_01.json b/michelson_vm/tests/data/tzt/tzt_map_mapintstring_01.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_map_mapintstring_01.json rename to michelson_vm/tests/data/tzt/tzt_map_mapintstring_01.json diff --git a/tezos_vm/tests/data/tzt/tzt_map_mapstringnat_00.json b/michelson_vm/tests/data/tzt/tzt_map_mapstringnat_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_map_mapstringnat_00.json rename to michelson_vm/tests/data/tzt/tzt_map_mapstringnat_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_map_mapstringnat_01.json b/michelson_vm/tests/data/tzt/tzt_map_mapstringnat_01.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_map_mapstringnat_01.json rename to michelson_vm/tests/data/tzt/tzt_map_mapstringnat_01.json diff --git a/tezos_vm/tests/data/tzt/tzt_map_mapstringnat_02.json b/michelson_vm/tests/data/tzt/tzt_map_mapstringnat_02.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_map_mapstringnat_02.json rename to michelson_vm/tests/data/tzt/tzt_map_mapstringnat_02.json diff --git a/tezos_vm/tests/data/tzt/tzt_mem_bigmapnatnat_00.json b/michelson_vm/tests/data/tzt/tzt_mem_bigmapnatnat_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_mem_bigmapnatnat_00.json rename to michelson_vm/tests/data/tzt/tzt_mem_bigmapnatnat_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_mem_bigmapnatnat_01.json b/michelson_vm/tests/data/tzt/tzt_mem_bigmapnatnat_01.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_mem_bigmapnatnat_01.json rename to michelson_vm/tests/data/tzt/tzt_mem_bigmapnatnat_01.json diff --git a/tezos_vm/tests/data/tzt/tzt_mem_bigmapnatnat_02.json b/michelson_vm/tests/data/tzt/tzt_mem_bigmapnatnat_02.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_mem_bigmapnatnat_02.json rename to michelson_vm/tests/data/tzt/tzt_mem_bigmapnatnat_02.json diff --git a/tezos_vm/tests/data/tzt/tzt_mem_bigmapnatnat_03.json b/michelson_vm/tests/data/tzt/tzt_mem_bigmapnatnat_03.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_mem_bigmapnatnat_03.json rename to michelson_vm/tests/data/tzt/tzt_mem_bigmapnatnat_03.json diff --git a/tezos_vm/tests/data/tzt/tzt_mem_bigmapnatnat_04.json b/michelson_vm/tests/data/tzt/tzt_mem_bigmapnatnat_04.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_mem_bigmapnatnat_04.json rename to michelson_vm/tests/data/tzt/tzt_mem_bigmapnatnat_04.json diff --git a/tezos_vm/tests/data/tzt/tzt_mem_bigmapnatnat_05.json b/michelson_vm/tests/data/tzt/tzt_mem_bigmapnatnat_05.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_mem_bigmapnatnat_05.json rename to michelson_vm/tests/data/tzt/tzt_mem_bigmapnatnat_05.json diff --git a/tezos_vm/tests/data/tzt/tzt_mem_bigmapstringnat_00.json b/michelson_vm/tests/data/tzt/tzt_mem_bigmapstringnat_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_mem_bigmapstringnat_00.json rename to michelson_vm/tests/data/tzt/tzt_mem_bigmapstringnat_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_mem_bigmapstringnat_01.json b/michelson_vm/tests/data/tzt/tzt_mem_bigmapstringnat_01.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_mem_bigmapstringnat_01.json rename to michelson_vm/tests/data/tzt/tzt_mem_bigmapstringnat_01.json diff --git a/tezos_vm/tests/data/tzt/tzt_mem_bigmapstringnat_02.json b/michelson_vm/tests/data/tzt/tzt_mem_bigmapstringnat_02.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_mem_bigmapstringnat_02.json rename to michelson_vm/tests/data/tzt/tzt_mem_bigmapstringnat_02.json diff --git a/tezos_vm/tests/data/tzt/tzt_mem_bigmapstringnat_03.json b/michelson_vm/tests/data/tzt/tzt_mem_bigmapstringnat_03.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_mem_bigmapstringnat_03.json rename to michelson_vm/tests/data/tzt/tzt_mem_bigmapstringnat_03.json diff --git a/tezos_vm/tests/data/tzt/tzt_mem_bigmapstringnat_04.json b/michelson_vm/tests/data/tzt/tzt_mem_bigmapstringnat_04.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_mem_bigmapstringnat_04.json rename to michelson_vm/tests/data/tzt/tzt_mem_bigmapstringnat_04.json diff --git a/tezos_vm/tests/data/tzt/tzt_mem_bigmapstringnat_05.json b/michelson_vm/tests/data/tzt/tzt_mem_bigmapstringnat_05.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_mem_bigmapstringnat_05.json rename to michelson_vm/tests/data/tzt/tzt_mem_bigmapstringnat_05.json diff --git a/tezos_vm/tests/data/tzt/tzt_mem_mapintint_00.json b/michelson_vm/tests/data/tzt/tzt_mem_mapintint_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_mem_mapintint_00.json rename to michelson_vm/tests/data/tzt/tzt_mem_mapintint_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_mem_mapnatnat_00.json b/michelson_vm/tests/data/tzt/tzt_mem_mapnatnat_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_mem_mapnatnat_00.json rename to michelson_vm/tests/data/tzt/tzt_mem_mapnatnat_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_mem_mapnatnat_01.json b/michelson_vm/tests/data/tzt/tzt_mem_mapnatnat_01.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_mem_mapnatnat_01.json rename to michelson_vm/tests/data/tzt/tzt_mem_mapnatnat_01.json diff --git a/tezos_vm/tests/data/tzt/tzt_mem_mapnatnat_02.json b/michelson_vm/tests/data/tzt/tzt_mem_mapnatnat_02.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_mem_mapnatnat_02.json rename to michelson_vm/tests/data/tzt/tzt_mem_mapnatnat_02.json diff --git a/tezos_vm/tests/data/tzt/tzt_mem_mapnatnat_03.json b/michelson_vm/tests/data/tzt/tzt_mem_mapnatnat_03.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_mem_mapnatnat_03.json rename to michelson_vm/tests/data/tzt/tzt_mem_mapnatnat_03.json diff --git a/tezos_vm/tests/data/tzt/tzt_mem_mapnatnat_04.json b/michelson_vm/tests/data/tzt/tzt_mem_mapnatnat_04.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_mem_mapnatnat_04.json rename to michelson_vm/tests/data/tzt/tzt_mem_mapnatnat_04.json diff --git a/tezos_vm/tests/data/tzt/tzt_mem_mapnatnat_05.json b/michelson_vm/tests/data/tzt/tzt_mem_mapnatnat_05.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_mem_mapnatnat_05.json rename to michelson_vm/tests/data/tzt/tzt_mem_mapnatnat_05.json diff --git a/tezos_vm/tests/data/tzt/tzt_mem_mapstringnat_00.json b/michelson_vm/tests/data/tzt/tzt_mem_mapstringnat_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_mem_mapstringnat_00.json rename to michelson_vm/tests/data/tzt/tzt_mem_mapstringnat_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_mem_mapstringnat_01.json b/michelson_vm/tests/data/tzt/tzt_mem_mapstringnat_01.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_mem_mapstringnat_01.json rename to michelson_vm/tests/data/tzt/tzt_mem_mapstringnat_01.json diff --git a/tezos_vm/tests/data/tzt/tzt_mem_mapstringnat_02.json b/michelson_vm/tests/data/tzt/tzt_mem_mapstringnat_02.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_mem_mapstringnat_02.json rename to michelson_vm/tests/data/tzt/tzt_mem_mapstringnat_02.json diff --git a/tezos_vm/tests/data/tzt/tzt_mem_mapstringnat_03.json b/michelson_vm/tests/data/tzt/tzt_mem_mapstringnat_03.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_mem_mapstringnat_03.json rename to michelson_vm/tests/data/tzt/tzt_mem_mapstringnat_03.json diff --git a/tezos_vm/tests/data/tzt/tzt_mem_mapstringnat_04.json b/michelson_vm/tests/data/tzt/tzt_mem_mapstringnat_04.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_mem_mapstringnat_04.json rename to michelson_vm/tests/data/tzt/tzt_mem_mapstringnat_04.json diff --git a/tezos_vm/tests/data/tzt/tzt_mem_mapstringnat_05.json b/michelson_vm/tests/data/tzt/tzt_mem_mapstringnat_05.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_mem_mapstringnat_05.json rename to michelson_vm/tests/data/tzt/tzt_mem_mapstringnat_05.json diff --git a/tezos_vm/tests/data/tzt/tzt_mem_setint_00.json b/michelson_vm/tests/data/tzt/tzt_mem_setint_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_mem_setint_00.json rename to michelson_vm/tests/data/tzt/tzt_mem_setint_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_mem_setint_01.json b/michelson_vm/tests/data/tzt/tzt_mem_setint_01.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_mem_setint_01.json rename to michelson_vm/tests/data/tzt/tzt_mem_setint_01.json diff --git a/tezos_vm/tests/data/tzt/tzt_mem_setstring_00.json b/michelson_vm/tests/data/tzt/tzt_mem_setstring_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_mem_setstring_00.json rename to michelson_vm/tests/data/tzt/tzt_mem_setstring_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_mem_setstring_01.json b/michelson_vm/tests/data/tzt/tzt_mem_setstring_01.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_mem_setstring_01.json rename to michelson_vm/tests/data/tzt/tzt_mem_setstring_01.json diff --git a/tezos_vm/tests/data/tzt/tzt_mem_setstring_02.json b/michelson_vm/tests/data/tzt/tzt_mem_setstring_02.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_mem_setstring_02.json rename to michelson_vm/tests/data/tzt/tzt_mem_setstring_02.json diff --git a/tezos_vm/tests/data/tzt/tzt_mul_int_int_00.json b/michelson_vm/tests/data/tzt/tzt_mul_int_int_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_mul_int_int_00.json rename to michelson_vm/tests/data/tzt/tzt_mul_int_int_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_mul_int_nat_00.json b/michelson_vm/tests/data/tzt/tzt_mul_int_nat_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_mul_int_nat_00.json rename to michelson_vm/tests/data/tzt/tzt_mul_int_nat_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_mul_mutez_nat_00.json b/michelson_vm/tests/data/tzt/tzt_mul_mutez_nat_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_mul_mutez_nat_00.json rename to michelson_vm/tests/data/tzt/tzt_mul_mutez_nat_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_mul_mutez_nat_01.json b/michelson_vm/tests/data/tzt/tzt_mul_mutez_nat_01.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_mul_mutez_nat_01.json rename to michelson_vm/tests/data/tzt/tzt_mul_mutez_nat_01.json diff --git a/tezos_vm/tests/data/tzt/tzt_mul_nat_int_00.json b/michelson_vm/tests/data/tzt/tzt_mul_nat_int_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_mul_nat_int_00.json rename to michelson_vm/tests/data/tzt/tzt_mul_nat_int_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_mul_nat_mutez_00.json b/michelson_vm/tests/data/tzt/tzt_mul_nat_mutez_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_mul_nat_mutez_00.json rename to michelson_vm/tests/data/tzt/tzt_mul_nat_mutez_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_mul_nat_mutez_01.json b/michelson_vm/tests/data/tzt/tzt_mul_nat_mutez_01.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_mul_nat_mutez_01.json rename to michelson_vm/tests/data/tzt/tzt_mul_nat_mutez_01.json diff --git a/tezos_vm/tests/data/tzt/tzt_mul_nat_nat_00.json b/michelson_vm/tests/data/tzt/tzt_mul_nat_nat_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_mul_nat_nat_00.json rename to michelson_vm/tests/data/tzt/tzt_mul_nat_nat_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_neg_int_00.json b/michelson_vm/tests/data/tzt/tzt_neg_int_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_neg_int_00.json rename to michelson_vm/tests/data/tzt/tzt_neg_int_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_neg_int_01.json b/michelson_vm/tests/data/tzt/tzt_neg_int_01.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_neg_int_01.json rename to michelson_vm/tests/data/tzt/tzt_neg_int_01.json diff --git a/tezos_vm/tests/data/tzt/tzt_neg_int_02.json b/michelson_vm/tests/data/tzt/tzt_neg_int_02.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_neg_int_02.json rename to michelson_vm/tests/data/tzt/tzt_neg_int_02.json diff --git a/tezos_vm/tests/data/tzt/tzt_neg_nat_00.json b/michelson_vm/tests/data/tzt/tzt_neg_nat_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_neg_nat_00.json rename to michelson_vm/tests/data/tzt/tzt_neg_nat_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_neg_nat_01.json b/michelson_vm/tests/data/tzt/tzt_neg_nat_01.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_neg_nat_01.json rename to michelson_vm/tests/data/tzt/tzt_neg_nat_01.json diff --git a/tezos_vm/tests/data/tzt/tzt_neq_00.json b/michelson_vm/tests/data/tzt/tzt_neq_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_neq_00.json rename to michelson_vm/tests/data/tzt/tzt_neq_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_neq_01.json b/michelson_vm/tests/data/tzt/tzt_neq_01.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_neq_01.json rename to michelson_vm/tests/data/tzt/tzt_neq_01.json diff --git a/tezos_vm/tests/data/tzt/tzt_neq_02.json b/michelson_vm/tests/data/tzt/tzt_neq_02.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_neq_02.json rename to michelson_vm/tests/data/tzt/tzt_neq_02.json diff --git a/tezos_vm/tests/data/tzt/tzt_neq_03.json b/michelson_vm/tests/data/tzt/tzt_neq_03.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_neq_03.json rename to michelson_vm/tests/data/tzt/tzt_neq_03.json diff --git a/tezos_vm/tests/data/tzt/tzt_neq_04.json b/michelson_vm/tests/data/tzt/tzt_neq_04.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_neq_04.json rename to michelson_vm/tests/data/tzt/tzt_neq_04.json diff --git a/tezos_vm/tests/data/tzt/tzt_nil_nat_00.json b/michelson_vm/tests/data/tzt/tzt_nil_nat_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_nil_nat_00.json rename to michelson_vm/tests/data/tzt/tzt_nil_nat_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_none_int_00.json b/michelson_vm/tests/data/tzt/tzt_none_int_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_none_int_00.json rename to michelson_vm/tests/data/tzt/tzt_none_int_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_none_pair_nat_string.json b/michelson_vm/tests/data/tzt/tzt_none_pair_nat_string.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_none_pair_nat_string.json rename to michelson_vm/tests/data/tzt/tzt_none_pair_nat_string.json diff --git a/tezos_vm/tests/data/tzt/tzt_not_bool_00.json b/michelson_vm/tests/data/tzt/tzt_not_bool_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_not_bool_00.json rename to michelson_vm/tests/data/tzt/tzt_not_bool_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_not_bool_01.json b/michelson_vm/tests/data/tzt/tzt_not_bool_01.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_not_bool_01.json rename to michelson_vm/tests/data/tzt/tzt_not_bool_01.json diff --git a/tezos_vm/tests/data/tzt/tzt_not_int_00.json b/michelson_vm/tests/data/tzt/tzt_not_int_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_not_int_00.json rename to michelson_vm/tests/data/tzt/tzt_not_int_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_not_nat_00.json b/michelson_vm/tests/data/tzt/tzt_not_nat_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_not_nat_00.json rename to michelson_vm/tests/data/tzt/tzt_not_nat_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_not_nat_01.json b/michelson_vm/tests/data/tzt/tzt_not_nat_01.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_not_nat_01.json rename to michelson_vm/tests/data/tzt/tzt_not_nat_01.json diff --git a/tezos_vm/tests/data/tzt/tzt_not_nat_02.json b/michelson_vm/tests/data/tzt/tzt_not_nat_02.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_not_nat_02.json rename to michelson_vm/tests/data/tzt/tzt_not_nat_02.json diff --git a/tezos_vm/tests/data/tzt/tzt_not_nat_03.json b/michelson_vm/tests/data/tzt/tzt_not_nat_03.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_not_nat_03.json rename to michelson_vm/tests/data/tzt/tzt_not_nat_03.json diff --git a/tezos_vm/tests/data/tzt/tzt_not_nat_04.json b/michelson_vm/tests/data/tzt/tzt_not_nat_04.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_not_nat_04.json rename to michelson_vm/tests/data/tzt/tzt_not_nat_04.json diff --git a/tezos_vm/tests/data/tzt/tzt_not_nat_05.json b/michelson_vm/tests/data/tzt/tzt_not_nat_05.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_not_nat_05.json rename to michelson_vm/tests/data/tzt/tzt_not_nat_05.json diff --git a/tezos_vm/tests/data/tzt/tzt_not_nat_06.json b/michelson_vm/tests/data/tzt/tzt_not_nat_06.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_not_nat_06.json rename to michelson_vm/tests/data/tzt/tzt_not_nat_06.json diff --git a/tezos_vm/tests/data/tzt/tzt_not_nat_07.json b/michelson_vm/tests/data/tzt/tzt_not_nat_07.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_not_nat_07.json rename to michelson_vm/tests/data/tzt/tzt_not_nat_07.json diff --git a/tezos_vm/tests/data/tzt/tzt_now_00.json b/michelson_vm/tests/data/tzt/tzt_now_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_now_00.json rename to michelson_vm/tests/data/tzt/tzt_now_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_or_bool_bool_00.json b/michelson_vm/tests/data/tzt/tzt_or_bool_bool_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_or_bool_bool_00.json rename to michelson_vm/tests/data/tzt/tzt_or_bool_bool_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_or_bool_bool_01.json b/michelson_vm/tests/data/tzt/tzt_or_bool_bool_01.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_or_bool_bool_01.json rename to michelson_vm/tests/data/tzt/tzt_or_bool_bool_01.json diff --git a/tezos_vm/tests/data/tzt/tzt_or_bool_bool_02.json b/michelson_vm/tests/data/tzt/tzt_or_bool_bool_02.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_or_bool_bool_02.json rename to michelson_vm/tests/data/tzt/tzt_or_bool_bool_02.json diff --git a/tezos_vm/tests/data/tzt/tzt_or_bool_bool_03.json b/michelson_vm/tests/data/tzt/tzt_or_bool_bool_03.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_or_bool_bool_03.json rename to michelson_vm/tests/data/tzt/tzt_or_bool_bool_03.json diff --git a/tezos_vm/tests/data/tzt/tzt_or_nat_nat_00.json b/michelson_vm/tests/data/tzt/tzt_or_nat_nat_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_or_nat_nat_00.json rename to michelson_vm/tests/data/tzt/tzt_or_nat_nat_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_or_nat_nat_01.json b/michelson_vm/tests/data/tzt/tzt_or_nat_nat_01.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_or_nat_nat_01.json rename to michelson_vm/tests/data/tzt/tzt_or_nat_nat_01.json diff --git a/tezos_vm/tests/data/tzt/tzt_or_nat_nat_02.json b/michelson_vm/tests/data/tzt/tzt_or_nat_nat_02.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_or_nat_nat_02.json rename to michelson_vm/tests/data/tzt/tzt_or_nat_nat_02.json diff --git a/tezos_vm/tests/data/tzt/tzt_or_nat_nat_03.json b/michelson_vm/tests/data/tzt/tzt_or_nat_nat_03.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_or_nat_nat_03.json rename to michelson_vm/tests/data/tzt/tzt_or_nat_nat_03.json diff --git a/tezos_vm/tests/data/tzt/tzt_or_nat_nat_04.json b/michelson_vm/tests/data/tzt/tzt_or_nat_nat_04.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_or_nat_nat_04.json rename to michelson_vm/tests/data/tzt/tzt_or_nat_nat_04.json diff --git a/tezos_vm/tests/data/tzt/tzt_or_nat_nat_05.json b/michelson_vm/tests/data/tzt/tzt_or_nat_nat_05.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_or_nat_nat_05.json rename to michelson_vm/tests/data/tzt/tzt_or_nat_nat_05.json diff --git a/tezos_vm/tests/data/tzt/tzt_or_nat_nat_06.json b/michelson_vm/tests/data/tzt/tzt_or_nat_nat_06.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_or_nat_nat_06.json rename to michelson_vm/tests/data/tzt/tzt_or_nat_nat_06.json diff --git a/tezos_vm/tests/data/tzt/tzt_packunpack_address_00.json b/michelson_vm/tests/data/tzt/tzt_packunpack_address_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_packunpack_address_00.json rename to michelson_vm/tests/data/tzt/tzt_packunpack_address_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_packunpack_bool_00.json b/michelson_vm/tests/data/tzt/tzt_packunpack_bool_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_packunpack_bool_00.json rename to michelson_vm/tests/data/tzt/tzt_packunpack_bool_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_packunpack_bytes_00.json b/michelson_vm/tests/data/tzt/tzt_packunpack_bytes_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_packunpack_bytes_00.json rename to michelson_vm/tests/data/tzt/tzt_packunpack_bytes_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_packunpack_int_00.json b/michelson_vm/tests/data/tzt/tzt_packunpack_int_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_packunpack_int_00.json rename to michelson_vm/tests/data/tzt/tzt_packunpack_int_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_packunpack_keyhash_00.json b/michelson_vm/tests/data/tzt/tzt_packunpack_keyhash_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_packunpack_keyhash_00.json rename to michelson_vm/tests/data/tzt/tzt_packunpack_keyhash_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_packunpack_mutez_00.json b/michelson_vm/tests/data/tzt/tzt_packunpack_mutez_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_packunpack_mutez_00.json rename to michelson_vm/tests/data/tzt/tzt_packunpack_mutez_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_packunpack_nat_00.json b/michelson_vm/tests/data/tzt/tzt_packunpack_nat_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_packunpack_nat_00.json rename to michelson_vm/tests/data/tzt/tzt_packunpack_nat_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_packunpack_string_00.json b/michelson_vm/tests/data/tzt/tzt_packunpack_string_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_packunpack_string_00.json rename to michelson_vm/tests/data/tzt/tzt_packunpack_string_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_packunpack_timestamp_00.json b/michelson_vm/tests/data/tzt/tzt_packunpack_timestamp_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_packunpack_timestamp_00.json rename to michelson_vm/tests/data/tzt/tzt_packunpack_timestamp_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_pair_int_int_00.json b/michelson_vm/tests/data/tzt/tzt_pair_int_int_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_pair_int_int_00.json rename to michelson_vm/tests/data/tzt/tzt_pair_int_int_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_pair_nat_string_00.json b/michelson_vm/tests/data/tzt/tzt_pair_nat_string_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_pair_nat_string_00.json rename to michelson_vm/tests/data/tzt/tzt_pair_nat_string_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_pair_pair_nat_string_pair_string_nat_00.json b/michelson_vm/tests/data/tzt/tzt_pair_pair_nat_string_pair_string_nat_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_pair_pair_nat_string_pair_string_nat_00.json rename to michelson_vm/tests/data/tzt/tzt_pair_pair_nat_string_pair_string_nat_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_push_int_00.json b/michelson_vm/tests/data/tzt/tzt_push_int_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_push_int_00.json rename to michelson_vm/tests/data/tzt/tzt_push_int_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_push_string_00.json b/michelson_vm/tests/data/tzt/tzt_push_string_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_push_string_00.json rename to michelson_vm/tests/data/tzt/tzt_push_string_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_right_nat_int_00.json b/michelson_vm/tests/data/tzt/tzt_right_nat_int_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_right_nat_int_00.json rename to michelson_vm/tests/data/tzt/tzt_right_nat_int_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_self_00.json b/michelson_vm/tests/data/tzt/tzt_self_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_self_00.json rename to michelson_vm/tests/data/tzt/tzt_self_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_sender_00.json b/michelson_vm/tests/data/tzt/tzt_sender_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_sender_00.json rename to michelson_vm/tests/data/tzt/tzt_sender_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_size_bytes_00.json b/michelson_vm/tests/data/tzt/tzt_size_bytes_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_size_bytes_00.json rename to michelson_vm/tests/data/tzt/tzt_size_bytes_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_size_listint_00.json b/michelson_vm/tests/data/tzt/tzt_size_listint_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_size_listint_00.json rename to michelson_vm/tests/data/tzt/tzt_size_listint_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_size_listint_01.json b/michelson_vm/tests/data/tzt/tzt_size_listint_01.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_size_listint_01.json rename to michelson_vm/tests/data/tzt/tzt_size_listint_01.json diff --git a/tezos_vm/tests/data/tzt/tzt_size_listint_02.json b/michelson_vm/tests/data/tzt/tzt_size_listint_02.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_size_listint_02.json rename to michelson_vm/tests/data/tzt/tzt_size_listint_02.json diff --git a/tezos_vm/tests/data/tzt/tzt_size_listint_03.json b/michelson_vm/tests/data/tzt/tzt_size_listint_03.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_size_listint_03.json rename to michelson_vm/tests/data/tzt/tzt_size_listint_03.json diff --git a/tezos_vm/tests/data/tzt/tzt_size_mapintint_00.json b/michelson_vm/tests/data/tzt/tzt_size_mapintint_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_size_mapintint_00.json rename to michelson_vm/tests/data/tzt/tzt_size_mapintint_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_size_mapstringnat_00.json b/michelson_vm/tests/data/tzt/tzt_size_mapstringnat_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_size_mapstringnat_00.json rename to michelson_vm/tests/data/tzt/tzt_size_mapstringnat_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_size_mapstringnat_01.json b/michelson_vm/tests/data/tzt/tzt_size_mapstringnat_01.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_size_mapstringnat_01.json rename to michelson_vm/tests/data/tzt/tzt_size_mapstringnat_01.json diff --git a/tezos_vm/tests/data/tzt/tzt_size_mapstringnat_02.json b/michelson_vm/tests/data/tzt/tzt_size_mapstringnat_02.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_size_mapstringnat_02.json rename to michelson_vm/tests/data/tzt/tzt_size_mapstringnat_02.json diff --git a/tezos_vm/tests/data/tzt/tzt_size_mapstringnat_03.json b/michelson_vm/tests/data/tzt/tzt_size_mapstringnat_03.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_size_mapstringnat_03.json rename to michelson_vm/tests/data/tzt/tzt_size_mapstringnat_03.json diff --git a/tezos_vm/tests/data/tzt/tzt_size_setint_00.json b/michelson_vm/tests/data/tzt/tzt_size_setint_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_size_setint_00.json rename to michelson_vm/tests/data/tzt/tzt_size_setint_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_size_setint_01.json b/michelson_vm/tests/data/tzt/tzt_size_setint_01.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_size_setint_01.json rename to michelson_vm/tests/data/tzt/tzt_size_setint_01.json diff --git a/tezos_vm/tests/data/tzt/tzt_size_setint_02.json b/michelson_vm/tests/data/tzt/tzt_size_setint_02.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_size_setint_02.json rename to michelson_vm/tests/data/tzt/tzt_size_setint_02.json diff --git a/tezos_vm/tests/data/tzt/tzt_size_setint_03.json b/michelson_vm/tests/data/tzt/tzt_size_setint_03.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_size_setint_03.json rename to michelson_vm/tests/data/tzt/tzt_size_setint_03.json diff --git a/tezos_vm/tests/data/tzt/tzt_size_setstring_00.json b/michelson_vm/tests/data/tzt/tzt_size_setstring_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_size_setstring_00.json rename to michelson_vm/tests/data/tzt/tzt_size_setstring_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_size_string_00.json b/michelson_vm/tests/data/tzt/tzt_size_string_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_size_string_00.json rename to michelson_vm/tests/data/tzt/tzt_size_string_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_slice_bytes_00.json b/michelson_vm/tests/data/tzt/tzt_slice_bytes_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_slice_bytes_00.json rename to michelson_vm/tests/data/tzt/tzt_slice_bytes_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_slice_bytes_01.json b/michelson_vm/tests/data/tzt/tzt_slice_bytes_01.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_slice_bytes_01.json rename to michelson_vm/tests/data/tzt/tzt_slice_bytes_01.json diff --git a/tezos_vm/tests/data/tzt/tzt_slice_bytes_02.json b/michelson_vm/tests/data/tzt/tzt_slice_bytes_02.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_slice_bytes_02.json rename to michelson_vm/tests/data/tzt/tzt_slice_bytes_02.json diff --git a/tezos_vm/tests/data/tzt/tzt_slice_bytes_03.json b/michelson_vm/tests/data/tzt/tzt_slice_bytes_03.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_slice_bytes_03.json rename to michelson_vm/tests/data/tzt/tzt_slice_bytes_03.json diff --git a/tezos_vm/tests/data/tzt/tzt_slice_bytes_04.json b/michelson_vm/tests/data/tzt/tzt_slice_bytes_04.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_slice_bytes_04.json rename to michelson_vm/tests/data/tzt/tzt_slice_bytes_04.json diff --git a/tezos_vm/tests/data/tzt/tzt_slice_string_00.json b/michelson_vm/tests/data/tzt/tzt_slice_string_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_slice_string_00.json rename to michelson_vm/tests/data/tzt/tzt_slice_string_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_slice_string_01.json b/michelson_vm/tests/data/tzt/tzt_slice_string_01.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_slice_string_01.json rename to michelson_vm/tests/data/tzt/tzt_slice_string_01.json diff --git a/tezos_vm/tests/data/tzt/tzt_slice_string_02.json b/michelson_vm/tests/data/tzt/tzt_slice_string_02.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_slice_string_02.json rename to michelson_vm/tests/data/tzt/tzt_slice_string_02.json diff --git a/tezos_vm/tests/data/tzt/tzt_slice_string_03.json b/michelson_vm/tests/data/tzt/tzt_slice_string_03.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_slice_string_03.json rename to michelson_vm/tests/data/tzt/tzt_slice_string_03.json diff --git a/tezos_vm/tests/data/tzt/tzt_slice_string_04.json b/michelson_vm/tests/data/tzt/tzt_slice_string_04.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_slice_string_04.json rename to michelson_vm/tests/data/tzt/tzt_slice_string_04.json diff --git a/tezos_vm/tests/data/tzt/tzt_slice_string_05.json b/michelson_vm/tests/data/tzt/tzt_slice_string_05.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_slice_string_05.json rename to michelson_vm/tests/data/tzt/tzt_slice_string_05.json diff --git a/tezos_vm/tests/data/tzt/tzt_some_int_00.json b/michelson_vm/tests/data/tzt/tzt_some_int_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_some_int_00.json rename to michelson_vm/tests/data/tzt/tzt_some_int_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_some_pairintint_00.json b/michelson_vm/tests/data/tzt/tzt_some_pairintint_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_some_pairintint_00.json rename to michelson_vm/tests/data/tzt/tzt_some_pairintint_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_some_string_00.json b/michelson_vm/tests/data/tzt/tzt_some_string_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_some_string_00.json rename to michelson_vm/tests/data/tzt/tzt_some_string_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_source_00.json b/michelson_vm/tests/data/tzt/tzt_source_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_source_00.json rename to michelson_vm/tests/data/tzt/tzt_source_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_sub_int_int_00.json b/michelson_vm/tests/data/tzt/tzt_sub_int_int_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_sub_int_int_00.json rename to michelson_vm/tests/data/tzt/tzt_sub_int_int_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_sub_int_int_01.json b/michelson_vm/tests/data/tzt/tzt_sub_int_int_01.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_sub_int_int_01.json rename to michelson_vm/tests/data/tzt/tzt_sub_int_int_01.json diff --git a/tezos_vm/tests/data/tzt/tzt_sub_mutez_mutez_00.json b/michelson_vm/tests/data/tzt/tzt_sub_mutez_mutez_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_sub_mutez_mutez_00.json rename to michelson_vm/tests/data/tzt/tzt_sub_mutez_mutez_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_sub_mutez_mutez_01.json b/michelson_vm/tests/data/tzt/tzt_sub_mutez_mutez_01.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_sub_mutez_mutez_01.json rename to michelson_vm/tests/data/tzt/tzt_sub_mutez_mutez_01.json diff --git a/tezos_vm/tests/data/tzt/tzt_sub_timestamp_int_00.json b/michelson_vm/tests/data/tzt/tzt_sub_timestamp_int_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_sub_timestamp_int_00.json rename to michelson_vm/tests/data/tzt/tzt_sub_timestamp_int_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_sub_timestamp_int_01.json b/michelson_vm/tests/data/tzt/tzt_sub_timestamp_int_01.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_sub_timestamp_int_01.json rename to michelson_vm/tests/data/tzt/tzt_sub_timestamp_int_01.json diff --git a/tezos_vm/tests/data/tzt/tzt_sub_timestamp_int_02.json b/michelson_vm/tests/data/tzt/tzt_sub_timestamp_int_02.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_sub_timestamp_int_02.json rename to michelson_vm/tests/data/tzt/tzt_sub_timestamp_int_02.json diff --git a/tezos_vm/tests/data/tzt/tzt_sub_timestamp_int_03.json b/michelson_vm/tests/data/tzt/tzt_sub_timestamp_int_03.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_sub_timestamp_int_03.json rename to michelson_vm/tests/data/tzt/tzt_sub_timestamp_int_03.json diff --git a/tezos_vm/tests/data/tzt/tzt_sub_timestamp_int_04.json b/michelson_vm/tests/data/tzt/tzt_sub_timestamp_int_04.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_sub_timestamp_int_04.json rename to michelson_vm/tests/data/tzt/tzt_sub_timestamp_int_04.json diff --git a/tezos_vm/tests/data/tzt/tzt_sub_timestamp_timestamp_00.json b/michelson_vm/tests/data/tzt/tzt_sub_timestamp_timestamp_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_sub_timestamp_timestamp_00.json rename to michelson_vm/tests/data/tzt/tzt_sub_timestamp_timestamp_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_sub_timestamp_timestamp_01.json b/michelson_vm/tests/data/tzt/tzt_sub_timestamp_timestamp_01.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_sub_timestamp_timestamp_01.json rename to michelson_vm/tests/data/tzt/tzt_sub_timestamp_timestamp_01.json diff --git a/tezos_vm/tests/data/tzt/tzt_sub_timestamp_timestamp_02.json b/michelson_vm/tests/data/tzt/tzt_sub_timestamp_timestamp_02.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_sub_timestamp_timestamp_02.json rename to michelson_vm/tests/data/tzt/tzt_sub_timestamp_timestamp_02.json diff --git a/tezos_vm/tests/data/tzt/tzt_sub_timestamp_timestamp_03.json b/michelson_vm/tests/data/tzt/tzt_sub_timestamp_timestamp_03.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_sub_timestamp_timestamp_03.json rename to michelson_vm/tests/data/tzt/tzt_sub_timestamp_timestamp_03.json diff --git a/tezos_vm/tests/data/tzt/tzt_unit_00.json b/michelson_vm/tests/data/tzt/tzt_unit_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_unit_00.json rename to michelson_vm/tests/data/tzt/tzt_unit_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_unpair_pairstringstring_00.json b/michelson_vm/tests/data/tzt/tzt_unpair_pairstringstring_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_unpair_pairstringstring_00.json rename to michelson_vm/tests/data/tzt/tzt_unpair_pairstringstring_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_update_bigmapstringstring_00.json b/michelson_vm/tests/data/tzt/tzt_update_bigmapstringstring_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_update_bigmapstringstring_00.json rename to michelson_vm/tests/data/tzt/tzt_update_bigmapstringstring_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_update_bigmapstringstring_01.json b/michelson_vm/tests/data/tzt/tzt_update_bigmapstringstring_01.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_update_bigmapstringstring_01.json rename to michelson_vm/tests/data/tzt/tzt_update_bigmapstringstring_01.json diff --git a/tezos_vm/tests/data/tzt/tzt_update_bigmapstringstring_02.json b/michelson_vm/tests/data/tzt/tzt_update_bigmapstringstring_02.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_update_bigmapstringstring_02.json rename to michelson_vm/tests/data/tzt/tzt_update_bigmapstringstring_02.json diff --git a/tezos_vm/tests/data/tzt/tzt_update_bigmapstringstring_03.json b/michelson_vm/tests/data/tzt/tzt_update_bigmapstringstring_03.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_update_bigmapstringstring_03.json rename to michelson_vm/tests/data/tzt/tzt_update_bigmapstringstring_03.json diff --git a/tezos_vm/tests/data/tzt/tzt_update_bigmapstringstring_04.json b/michelson_vm/tests/data/tzt/tzt_update_bigmapstringstring_04.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_update_bigmapstringstring_04.json rename to michelson_vm/tests/data/tzt/tzt_update_bigmapstringstring_04.json diff --git a/tezos_vm/tests/data/tzt/tzt_update_bigmapstringstring_05.json b/michelson_vm/tests/data/tzt/tzt_update_bigmapstringstring_05.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_update_bigmapstringstring_05.json rename to michelson_vm/tests/data/tzt/tzt_update_bigmapstringstring_05.json diff --git a/tezos_vm/tests/data/tzt/tzt_update_bigmapstringstring_06.json b/michelson_vm/tests/data/tzt/tzt_update_bigmapstringstring_06.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_update_bigmapstringstring_06.json rename to michelson_vm/tests/data/tzt/tzt_update_bigmapstringstring_06.json diff --git a/tezos_vm/tests/data/tzt/tzt_update_bigmapstringstring_07.json b/michelson_vm/tests/data/tzt/tzt_update_bigmapstringstring_07.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_update_bigmapstringstring_07.json rename to michelson_vm/tests/data/tzt/tzt_update_bigmapstringstring_07.json diff --git a/tezos_vm/tests/data/tzt/tzt_update_mapintint_00.json b/michelson_vm/tests/data/tzt/tzt_update_mapintint_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_update_mapintint_00.json rename to michelson_vm/tests/data/tzt/tzt_update_mapintint_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_update_mapintint_01.json b/michelson_vm/tests/data/tzt/tzt_update_mapintint_01.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_update_mapintint_01.json rename to michelson_vm/tests/data/tzt/tzt_update_mapintint_01.json diff --git a/tezos_vm/tests/data/tzt/tzt_update_setint_00.json b/michelson_vm/tests/data/tzt/tzt_update_setint_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_update_setint_00.json rename to michelson_vm/tests/data/tzt/tzt_update_setint_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_update_setint_01.json b/michelson_vm/tests/data/tzt/tzt_update_setint_01.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_update_setint_01.json rename to michelson_vm/tests/data/tzt/tzt_update_setint_01.json diff --git a/tezos_vm/tests/data/tzt/tzt_update_setint_02.json b/michelson_vm/tests/data/tzt/tzt_update_setint_02.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_update_setint_02.json rename to michelson_vm/tests/data/tzt/tzt_update_setint_02.json diff --git a/tezos_vm/tests/data/tzt/tzt_xor_bool_bool_00.json b/michelson_vm/tests/data/tzt/tzt_xor_bool_bool_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_xor_bool_bool_00.json rename to michelson_vm/tests/data/tzt/tzt_xor_bool_bool_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_xor_bool_bool_01.json b/michelson_vm/tests/data/tzt/tzt_xor_bool_bool_01.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_xor_bool_bool_01.json rename to michelson_vm/tests/data/tzt/tzt_xor_bool_bool_01.json diff --git a/tezos_vm/tests/data/tzt/tzt_xor_bool_bool_02.json b/michelson_vm/tests/data/tzt/tzt_xor_bool_bool_02.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_xor_bool_bool_02.json rename to michelson_vm/tests/data/tzt/tzt_xor_bool_bool_02.json diff --git a/tezos_vm/tests/data/tzt/tzt_xor_bool_bool_03.json b/michelson_vm/tests/data/tzt/tzt_xor_bool_bool_03.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_xor_bool_bool_03.json rename to michelson_vm/tests/data/tzt/tzt_xor_bool_bool_03.json diff --git a/tezos_vm/tests/data/tzt/tzt_xor_nat_nat_00.json b/michelson_vm/tests/data/tzt/tzt_xor_nat_nat_00.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_xor_nat_nat_00.json rename to michelson_vm/tests/data/tzt/tzt_xor_nat_nat_00.json diff --git a/tezos_vm/tests/data/tzt/tzt_xor_nat_nat_01.json b/michelson_vm/tests/data/tzt/tzt_xor_nat_nat_01.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_xor_nat_nat_01.json rename to michelson_vm/tests/data/tzt/tzt_xor_nat_nat_01.json diff --git a/tezos_vm/tests/data/tzt/tzt_xor_nat_nat_02.json b/michelson_vm/tests/data/tzt/tzt_xor_nat_nat_02.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_xor_nat_nat_02.json rename to michelson_vm/tests/data/tzt/tzt_xor_nat_nat_02.json diff --git a/tezos_vm/tests/data/tzt/tzt_xor_nat_nat_03.json b/michelson_vm/tests/data/tzt/tzt_xor_nat_nat_03.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_xor_nat_nat_03.json rename to michelson_vm/tests/data/tzt/tzt_xor_nat_nat_03.json diff --git a/tezos_vm/tests/data/tzt/tzt_xor_nat_nat_04.json b/michelson_vm/tests/data/tzt/tzt_xor_nat_nat_04.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_xor_nat_nat_04.json rename to michelson_vm/tests/data/tzt/tzt_xor_nat_nat_04.json diff --git a/tezos_vm/tests/data/tzt/tzt_xor_nat_nat_05.json b/michelson_vm/tests/data/tzt/tzt_xor_nat_nat_05.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_xor_nat_nat_05.json rename to michelson_vm/tests/data/tzt/tzt_xor_nat_nat_05.json diff --git a/tezos_vm/tests/data/tzt/tzt_xor_nat_nat_06.json b/michelson_vm/tests/data/tzt/tzt_xor_nat_nat_06.json similarity index 100% rename from tezos_vm/tests/data/tzt/tzt_xor_nat_nat_06.json rename to michelson_vm/tests/data/tzt/tzt_xor_nat_nat_06.json diff --git a/tezos_vm/tests/opcodes.rs b/michelson_vm/tests/opcodes.rs similarity index 99% rename from tezos_vm/tests/opcodes.rs rename to michelson_vm/tests/opcodes.rs index 66afaeb..e5c6305 100644 --- a/tezos_vm/tests/opcodes.rs +++ b/michelson_vm/tests/opcodes.rs @@ -1,7 +1,11 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + mod runner; +use michelson_vm::Result; use runner::e2e::E2E; -use tezos_vm::Result; #[test] fn e2e_cons_00() -> Result<()> { diff --git a/tezos_vm/tests/runner/e2e.rs b/michelson_vm/tests/runner/e2e.rs similarity index 91% rename from tezos_vm/tests/runner/e2e.rs rename to michelson_vm/tests/runner/e2e.rs index 60debcf..7f02f79 100644 --- a/tezos_vm/tests/runner/e2e.rs +++ b/michelson_vm/tests/runner/e2e.rs @@ -1,12 +1,18 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + +use michelson_vm::{ + interpreter::OperationScope, + mock::{default_scope, MockContext}, + script::MichelsonScript, + Error, Result, +}; use tezos_michelson::micheline::{ primitive_application::PrimitiveApplication, sequence::Sequence, Micheline, }; -use tezos_vm::{interpreter::OperationScope, script::MichelsonScript, Error, Result}; -use crate::runner::{ - micheline::{parse_literal, read_from_file}, - mock::{default_scope, MockContext}, -}; +use crate::runner::micheline::{parse_literal, read_from_file}; pub enum Expectation { Storage(Micheline), diff --git a/tezos_vm/tests/runner/micheline.rs b/michelson_vm/tests/runner/micheline.rs similarity index 90% rename from tezos_vm/tests/runner/micheline.rs rename to michelson_vm/tests/runner/micheline.rs index ad28716..a63bc63 100644 --- a/tezos_vm/tests/runner/micheline.rs +++ b/michelson_vm/tests/runner/micheline.rs @@ -1,3 +1,7 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + use serde_json_wasm; use std::fs::File; use std::io::Read; @@ -7,7 +11,7 @@ use tezos_michelson::micheline::{ literals::Literal, primitive_application::PrimitiveApplication, Micheline, }; -use tezos_vm::Result; +use michelson_vm::Result; pub fn read_from_file(category: &str, filename: &str) -> Result { let mut path = PathBuf::from(env!("CARGO_MANIFEST_DIR")); diff --git a/michelson_vm/tests/runner/mod.rs b/michelson_vm/tests/runner/mod.rs new file mode 100644 index 0000000..9ec518d --- /dev/null +++ b/michelson_vm/tests/runner/mod.rs @@ -0,0 +1,9 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + +#![allow(dead_code)] + +pub mod e2e; +pub mod micheline; +pub mod tzt; diff --git a/tezos_vm/tests/runner/tzt.rs b/michelson_vm/tests/runner/tzt.rs similarity index 98% rename from tezos_vm/tests/runner/tzt.rs rename to michelson_vm/tests/runner/tzt.rs index e2fad82..24f0d6f 100644 --- a/tezos_vm/tests/runner/tzt.rs +++ b/michelson_vm/tests/runner/tzt.rs @@ -1,4 +1,18 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + use hex; +use michelson_vm::typechecker::check_pair_len; +use michelson_vm::{ + interpreter::{Interpreter, InterpreterContext, LazyStorage, OperationScope}, + mock::{default_scope, MockContext}, + stack::Stack, + trace_enter, trace_exit, + types::big_map::get_key_hash, + types::{BigMapDiff, BigMapItem, MapItem, StackItem}, + Error, Result, +}; use tezos_core::{ internal::crypto::blake2b, types::encoded::{self, Encoded, ScriptExprHash}, @@ -10,20 +24,8 @@ use tezos_michelson::michelson::{ data::Instruction, types::{Code, Type}, }; -use tezos_vm::typechecker::check_pair_len; -use tezos_vm::{ - interpreter::{Interpreter, InterpreterContext, LazyStorage, OperationScope}, - stack::Stack, - trace_enter, trace_exit, - types::big_map::get_key_hash, - types::{BigMapDiff, BigMapItem, MapItem, StackItem}, - Error, Result, -}; -use crate::runner::{ - micheline::read_from_file, - mock::{default_scope, MockContext}, -}; +use crate::runner::micheline::read_from_file; pub struct TZT { input: Input, diff --git a/tezos_vm/tests/tzt.rs b/michelson_vm/tests/tzt.rs similarity index 99% rename from tezos_vm/tests/tzt.rs rename to michelson_vm/tests/tzt.rs index 1a5e024..b6d6a06 100644 --- a/tezos_vm/tests/tzt.rs +++ b/michelson_vm/tests/tzt.rs @@ -1,7 +1,11 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + mod runner; +use michelson_vm::Result; use runner::tzt::TZT; -use tezos_vm::Result; #[test] fn tzt_sub_timestamp_int_00() -> Result<()> { diff --git a/nairobi.env b/nairobi.env new file mode 100644 index 0000000..b3a643c --- /dev/null +++ b/nairobi.env @@ -0,0 +1,3 @@ +OCTEZ_TAG=v17.1 +OCTEZ_PROTO=PtNairob +NETWORK=nairobinet \ No newline at end of file diff --git a/sapling_kernel/Cargo.toml b/sapling_kernel/Cargo.toml new file mode 100644 index 0000000..3c2759b --- /dev/null +++ b/sapling_kernel/Cargo.toml @@ -0,0 +1,27 @@ +# SPDX-FileCopyrightText: 2023 Baking Bad +# +# SPDX-License-Identifier: MIT + +[package] +name = "sapling_kernel" +version = "0.1.0" +edition = "2021" + +[lib] +crate-type = ["cdylib", "rlib"] + +[dependencies] +anyhow = "1.0" +derive_more = "0.99" +kernel_io = { path = "../kernel_io" } +sapling_proto = { path = "../sapling_proto" } +tezos-smart-rollup-host = { version = "0.2.0", features = ["proto-nairobi"], default-features = false } +# TODO: feature enable "panic-hook-abort" +tezos-smart-rollup-entrypoint = { version = "0.2.0", features = ["panic-hook", "std", "panic-hook-debug"], default-features = false } +tezos-smart-rollup-core = { version = "0.2.0", default-features = false } + +[dev-dependencies] +tezos_data_encoding = { version = "0.5" } +tezos-smart-rollup = { version = "0.2.0", features = ["proto-nairobi", "panic-hook", "crypto"] } +tezos-smart-rollup-mock = { version = "0.2.0", features = ["proto-nairobi"] } +hex = "*" \ No newline at end of file diff --git a/sapling_kernel/README.md b/sapling_kernel/README.md new file mode 100644 index 0000000..12ee2b5 --- /dev/null +++ b/sapling_kernel/README.md @@ -0,0 +1,119 @@ +# Sapling kernel + +Smart rollup kernel implementing Tezos-adapted Sapling protocol for privacy preserving transactions. + +## About + +The behavior of this kernel is analogues to a simple sapling pool on Tezos. +For demo purposes anti replay string is set to constant `KT1PwYL1B8hagFeCcByAcsN3KTQHmJFfDwnjNetXnHfVqm9iesp` — this is the address of a sapling pool contract in Ghostnet https://ghostnet.tzkt.io/KT1PwYL1B8hagFeCcByAcsN3KTQHmJFfDwnj + +It can be used to validate kernel behavior by replaying all sapling transactions (basically sending them as external messages to the rollup). + +## How to send transactions + +Prepare a Sapling transaction using one of the existing tool: +* Taquito https://tezostaquito.io/docs/sapling/#how-to-prepare-a-sapling-transaction +* tezos-client https://tezos.gitlab.io/alpha/sapling.html#sandbox-tutorial + +Send resulting payload as an external inbox message: +https://tezos.gitlab.io/alpha/smart_rollups.html#sending-an-external-inbox-message + +## How to get ciphertexts + +Assuming your rollup node is running at `http://localhost:8932`, access the storage via the following requests: +* Get ciphertext at position 1 `http://localhost:8932/global/block/head/durable/wasm_2_0_0/value?key=/ciphertexts/1` +* Get total ciphertexts count `http://localhost:8932/global/block/head/durable/wasm_2_0_0/value?key=/head` + + +## Tutorial + +This is a modified version of https://tezos.gitlab.io/alpha/sapling.html#sandbox-tutorial that uses existing contract in the Ghostnet. + +### Generate Sapling transactions & state + +```sh +# generate new key +octez-client gen keys bootstrap1 +octez-client show address bootstrap1 + +# top up its balance using https://faucet.ghostnet.teztnets.xyz/ +octez-client get balance for bootstrap1 + +# generate two shielded keys for Alice and Bob and use them for the shielded-tez contract +# the memo size has to be indicated +octez-client sapling gen key alice +octez-client sapling use key alice for contract KT1PwYL1B8hagFeCcByAcsN3KTQHmJFfDwnj --memo-size 8 +octez-client sapling gen key bob +octez-client sapling use key bob for contract KT1PwYL1B8hagFeCcByAcsN3KTQHmJFfDwnj --memo-size 8 + +# generate an address for Alice to receive shielded tokens. +octez-client sapling gen address alice +zet1AliceXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX # Alice's address + +# shield 10 tez from bootstrap1 to alice +octez-client sapling shield 10 from bootstrap1 to zet1AliceXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX using KT1PwYL1B8hagFeCcByAcsN3KTQHmJFfDwnj --burn-cap 2 + +# generate an address for Bob to receive shielded tokens. +octez-client sapling gen address bob +zet1BobXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX # Bob's address + +# forge a shielded transaction from alice to bob that is saved to a file +octez-client sapling forge transaction 10 from alice to zet1BobXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX using KT1PwYL1B8hagFeCcByAcsN3KTQHmJFfDwnj + +# submit the shielded transaction from any transparent account +octez-client sapling submit sapling_transaction from bootstrap1 using KT1PwYL1B8hagFeCcByAcsN3KTQHmJFfDwnj --burn-cap 1 + +# unshield from bob to any transparent account +octez-client sapling unshield 10 from bob to bootstrap1 using KT1PwYL1B8hagFeCcByAcsN3KTQHmJFfDwnj --burn-cap 1 +``` + +### Replay all generated transactions + +Now let's send all transaction payloads to the rollup and check that its state is in sync with the sapling state of our contract in Ghostnet. + +Setting everything ready: + +```sh +make run-sapling-operator +# inside operator container +$ operator deploy_rollup +``` + +The easiest way to do that is to open the contract page on [TzKT](https://ghostnet.tzkt.io/KT1PwYL1B8hagFeCcByAcsN3KTQHmJFfDwnj), open raw payload for every operation in the list, and copy sapling transaction bytes (in hex). + +Next, for each sapling transaction we need to send an external message to our rollup: + +```sh +# In the operator container +$ operator send_message %TX_HEX% +``` + +**NOTE**: due to the inbox message limitation (currently 2KB) some transactions might be truncated. + +Finally, run the rollup node to execute the transactions: + +```sh +# In the operator container +$ operator run_node +``` + +### Compare states + +Check the logs to wait for the moment when all transactions are handled. + +Now, let's validate the kernel state: +1. General info (number of commitments, nullifiers, roots) -> see `SaplingHead` struct layout + https://rpc.tzkt.io/ghostnet/chains/main/blocks/head/context/raw/json/sapling/index/6055/ + http://localhost:8932/global/block/head/durable/wasm_2_0_0/value?key=/head +2. Ciphertexts -> see `Ciphertext` struct layout + https://rpc.tzkt.io/ghostnet/chains/main/blocks/head/context/raw/json/sapling/index/6055/ciphertexts/0` + http://localhost:8932/global/block/head/durable/wasm_2_0_0/value?key=/ciphertexts/0 +3. Commitments + https://rpc.tzkt.io/ghostnet/chains/main/blocks/head/context/raw/json/sapling/index/6055/commitments/4294967296` + http://localhost:8932/global/block/head/durable/wasm_2_0_0/value?key=/commitments/4294967296 +4. Nullifiers + https://rpc.tzkt.io/ghostnet/chains/main/blocks/head/context/raw/json/sapling/index/6055/nullifiers_ordered/0` + http://localhost:8932/global/block/head/durable/wasm_2_0_0/value?key=/nullifiers_ordered/0 +5. Roots + https://rpc.tzkt.io/ghostnet/chains/main/blocks/head/context/raw/json/sapling/index/6055/roots/1 + http://localhost:8932/global/block/head/durable/wasm_2_0_0/value?key=/roots/1 \ No newline at end of file diff --git a/sapling_kernel/src/error.rs b/sapling_kernel/src/error.rs new file mode 100644 index 0000000..faf9be9 --- /dev/null +++ b/sapling_kernel/src/error.rs @@ -0,0 +1,82 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + +use derive_more::{Display, Error}; +use std::backtrace::Backtrace; + +#[derive(Debug)] +pub struct InternalError { + pub message: String, + pub backtrace: Backtrace, +} + +impl InternalError { + pub fn new(message: String) -> Self { + Self { + message, + backtrace: Backtrace::capture(), + } + } + + pub fn format(&self) -> String { + format!( + "Kernel internal error\n{}\nStacktrace:\n{}", + self.message, self.backtrace + ) + } +} + +impl std::fmt::Display for InternalError { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.write_fmt(format_args!( + "Kernel internal error, {}", + self.message.replace("\n", " ") + )) + } +} + +impl std::error::Error for InternalError { + fn description(&self) -> &str { + &self.message + } +} + +#[derive(Debug, Display, Error)] +pub enum Error { + Internal(InternalError), +} + +pub type Result = std::result::Result; + +#[macro_export] +macro_rules! internal_error { + ($($arg:tt)*) => { + $crate::Error::Internal( + $crate::error::InternalError::new(format!($($arg)*)) + ) + }; +} + +macro_rules! impl_from_error { + ($inner_err_ty: ty) => { + impl From<$inner_err_ty> for Error { + fn from(error: $inner_err_ty) -> Self { + $crate::internal_error!("Caused by: {:?}", error) + } + } + }; +} + +impl_from_error!(tezos_smart_rollup_host::runtime::RuntimeError); +impl_from_error!(tezos_smart_rollup_host::path::PathError); +impl_from_error!(anyhow::Error); + +impl Error { + pub fn format(&self) -> String { + match self { + Self::Internal(internal) => internal.format(), + //err => format!("{:#?}", err), + } + } +} diff --git a/sapling_kernel/src/kernel.rs b/sapling_kernel/src/kernel.rs new file mode 100644 index 0000000..b908f72 --- /dev/null +++ b/sapling_kernel/src/kernel.rs @@ -0,0 +1,163 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + +use kernel_io::{ + inbox::{read_inbox, InboxMessage}, + KernelStore, KernelStoreAsHost, +}; +use sapling_proto::{ + executor::execute_transaction, + formatter::Formatter, + storage::{run_migrations, SaplingHead, SaplingStorage}, + types::SaplingTransaction, + validator::validate_transaction, +}; +use tezos_smart_rollup_core::SmartRollupCore; + +use crate::{payload::SaplingPayload, Result}; + +// For demo purpose only (replicate L1 contract state) +pub const ANTI_REPLAY: &'static str = "KT1PwYL1B8hagFeCcByAcsN3KTQHmJFfDwnjNetXnHfVqm9iesp"; + +pub fn apply_transaction( + storage: &mut impl SaplingStorage, + transaction: &SaplingTransaction, +) -> Result { + validate_transaction(storage, &transaction, &ANTI_REPLAY.into())?; + execute_transaction(storage, &transaction)?; + let head = storage.get_head()?; + Ok(head) +} + +pub fn kernel_run(host: &mut Host) { + let mut context = KernelStore::attach(host); + + let mut head = context.get_head().expect("Failed to get head"); + context.log(format!("Kernel invoked, prev head: {}", head.to_string())); + + let res: Result<()> = loop { + match read_inbox(context.as_host(), b"") { + Ok(InboxMessage::BeginBlock(_)) => { + if let Err(err) = run_migrations(&mut context, &head) { + break Err(err.into()); + } + } + Ok(InboxMessage::LevelInfo(_)) => {} + Ok(InboxMessage::Payload(SaplingPayload::Transaction(tx))) => { + context.log(format!("Transaction pending: {}", tx.to_string())); + match apply_transaction(&mut context, &tx) { + Ok(new_head) => { + head = new_head; + context.log(format!( + "Transaction applied, new head: {}", + head.to_string() + )); + } + Err(err) => { + context.rollback(); + context.log(format!("Transaction failed: {}", err)); + } + } + } + Ok(InboxMessage::EndBlock(_)) => break Ok(()), + Ok(InboxMessage::NoMoreData) => break Ok(()), + Ok(InboxMessage::Foreign(id)) => context.log(format!("Foreign message #{}", id)), + Ok(InboxMessage::Unknown(id)) => context.log(format!("Unknown message #{}", id)), + Err(err) => context.log(err.to_string()), + } + }; + + match res { + Ok(_) => { + context + .as_mut() + .persist() + .expect("Failed to persist changes"); + context.log(format!("Kernel yields")); + } + Err(err) => { + context.log(err.format()); + context.clear(); + } + } +} + +#[cfg(test)] +mod test { + use std::io::Write; + + use super::*; + + use hex; + use kernel_io::{KernelStore, KernelStoreAsHost}; + use tezos_data_encoding::enc::{BinResult, BinWriter}; + use tezos_smart_rollup_mock::MockHost; + + struct ExternalMessage(Vec); + + impl ExternalMessage { + pub fn from_hex(value: &str) -> Self { + Self(hex::decode(value).unwrap()) + } + } + + impl BinWriter for ExternalMessage { + fn bin_write(&self, output: &mut Vec) -> BinResult { + match output.write(self.0.as_slice()) { + Ok(_) => BinResult::Ok(()), + Err(err) => BinResult::Err(err.into()), + } + } + } + + #[test] + fn sapling_deposit() -> Result<()> { + let mut host = MockHost::default(); + let mut context = KernelStore::::attach(&mut host); + + let message = ExternalMessage::from_hex( + "00000000000001f3f1de6f589f17cda6e8811dd2fb5b2b78875d440de07f6964a2f06e4e26f99b25\ + b004c78eee562cbe5db1eb52042efda378c227c07d649a496121ed51155a322a6f768ee30ab0cfe3\ + 7bb0b6cd238e325292b888683f720828a01615d126d847107e7ab1847ef07d3b19d7260318b457b7\ + 951c0cb95f5c72a32b85d6fef303bb5011e4125162c16b4c9a845bab7b175e379debc044e98f161b\ + 46cb6f955e9d03a6e708cc10df0e2c0a7fdab46cef61a07d837a2f287811f659b3410e3f9e78827b\ + b035b27df9a052fa82af43d4f68dca2a7d4a9576168f07ed419d33f7c30cd78cd363af03b3fcccd9\ + f24287b7f67ca79213a6a3a1bb8cb6a28cbed6027d829b92e177b6a94c8c1c5f1392d79f579d0349\ + e0fd981a8e641ca46d0aa521a0a2c3a40000004ff9db50a921e41f8acbcb0c0006504c20732add90\ + 6bccba01e5f5b6ee50cddb5356a61029569c0a0adc8879467d7c5c393b8738d55876b41e2406818c\ + b68e07e6807c1e9411f8898c8feff9e55d5474a8634c173d9fa81abc1e442a1336a2855a3f6db56c\ + e44031230850008eca4d0a70d9ed8005d93fa5545de7b7bfbe53ae70f963ebcdb5e57218dadac436\ + adb2bad786311759780b786d4bcee0ed3f76801903ce3d41c6ded99145c8b276cf0109dce50c80ad\ + 64808aaf789de3fa54ae752f75735905f15dd2f30b923de19d53bab0ec5d7886735824b2ddf15fc7\ + 2a48313b90a9ddf6a4df7cc3fad8c3495da0a4f40809c3710af64718dcf7d6b9de7fd52955ab9b0c\ + 53be54ca0c827dc52ed50cffffffffff676980fbc2f4300c01f0b7820d00e3347c8da4ee61467437\ + 6cbc45359daa54f9b5493e00000000", + ); + + context.as_host().run_level(|_| {}); // Add StartOfLevel & InfoPerLevel + context.as_host().add_external(message); + context.as_host().run_level(kernel_run); + + let head = context.get_head()?; + assert_eq!(1, head.commitments_size); + assert_eq!(0, head.nullifiers_size); + assert_eq!(1, head.roots_pos); + + let root1 = context.get_root(1)?.expect("Failed to get root #1"); + assert_eq!( + root1.to_string(), + "69a1f12aea9ef4019a059e69e70d6317c35d936d3ea61181f9fa9fa297fe092f" + ); + + let cm1 = context + .get_commitment(4294967296)? + .expect("Failed to get commitment #4294967296"); + assert_eq!( + cm1.to_string(), + "f1de6f589f17cda6e8811dd2fb5b2b78875d440de07f6964a2f06e4e26f99b25" + ); + + Ok(()) + } +} diff --git a/sapling_kernel/src/lib.rs b/sapling_kernel/src/lib.rs new file mode 100644 index 0000000..71a84be --- /dev/null +++ b/sapling_kernel/src/lib.rs @@ -0,0 +1,11 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + +pub mod error; +pub mod kernel; +pub mod payload; + +pub use error::{Error, Result}; + +tezos_smart_rollup_entrypoint::kernel_entry!(crate::kernel::kernel_run); diff --git a/sapling_kernel/src/payload.rs b/sapling_kernel/src/payload.rs new file mode 100644 index 0000000..1e054db --- /dev/null +++ b/sapling_kernel/src/payload.rs @@ -0,0 +1,17 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + +use kernel_io::{error::err_into, inbox::PayloadType}; +use sapling_proto::types::SaplingTransaction; + +pub enum SaplingPayload { + Transaction(SaplingTransaction), +} + +impl PayloadType for SaplingPayload { + fn from_external_message(message: &[u8]) -> kernel_io::Result { + let tx = SaplingTransaction::try_from(message).map_err(err_into)?; + Ok(SaplingPayload::Transaction(tx)) + } +} diff --git a/sapling_proto/Cargo.toml b/sapling_proto/Cargo.toml new file mode 100644 index 0000000..4f9cda9 --- /dev/null +++ b/sapling_proto/Cargo.toml @@ -0,0 +1,28 @@ +# SPDX-FileCopyrightText: 2023 Baking Bad +# +# SPDX-License-Identifier: MIT + +[package] +name = "sapling_proto" +version = "0.1.0" +edition = "2021" + +[lib] +crate-type = ["cdylib", "rlib"] + +[dependencies] +layered_store = { path = "../layered_store", default-features = false } +zcash_proofs = { version = "0.12.1", default-features = false } +zcash_primitives = { version = "0.12.0", default-features = false } +zcash_note_encryption = { version = "0.4.0", default-features = false } +incrementalmerkletree = { version = "0.4", features = ["legacy-api"], default-features = false } +bls12_381 = "0.8" +blake2b_simd = "1.0.1" +bellman = { version = "0.14", default-features = false, features = ["groth16"] } +anyhow = "1.0" +derive_more = "*" +lazy_static = "*" +hex = "*" + +[dev-dependencies] +mockall = "*" \ No newline at end of file diff --git a/sapling_proto/README.md b/sapling_proto/README.md new file mode 100644 index 0000000..07a5b2f --- /dev/null +++ b/sapling_proto/README.md @@ -0,0 +1,13 @@ +# Sapling proto + +This is the Tezos-adapted implementation of the Sapling protocol in Rust. + +## About + +The implementation is aimed to be compatible with the Tezos tooling, in particular: +* Binary codec of the Michelson type `sapling_transaction` is used as is +* Storage layout for commitments, ciphertexts, nullifiers, and roots resembles the one used in Tezos + +## Limitation + +Sapling states are currently not distinguished, assuming there's only one state (as opposed to Tezos where multiple states identified by ID with different memo size can co-live). This will be fixed in the next versions. \ No newline at end of file diff --git a/sapling_proto/src/codec.rs b/sapling_proto/src/codec.rs new file mode 100644 index 0000000..b062544 --- /dev/null +++ b/sapling_proto/src/codec.rs @@ -0,0 +1,297 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + +use std::io::{self, Read, Write}; + +use crate::{ + storage::ciphertext::{Ciphertext, NONCE_SIZE, PAYLOAD_OUT_SIZE}, + types::{ + Commitment, Input, Nullifier, Output, Proof, PublicKey, SaplingTransaction, Signature, + ValueCommitment, + }, +}; + +pub fn read_size(mut reader: R) -> io::Result { + let mut buf: [u8; 4] = [0u8; 4]; + reader.read_exact(&mut buf)?; + Ok(u32::from_be_bytes(buf).try_into().unwrap()) +} + +pub fn read_bytes32(mut reader: R) -> io::Result<[u8; 32]> { + let mut bytes = [0u8; 32]; + reader.read_exact(&mut bytes)?; + Ok(bytes) +} + +pub fn read_input(mut reader: R) -> io::Result { + let mut buf = [0u8; 32 * 3 + 192]; + reader.read_exact(&mut buf)?; + + let sig_payload = buf.to_vec(); + let mut sub_reader = buf.as_slice(); + + let cv = read_value_commitment(&mut sub_reader)?; + let nf = Nullifier(read_bytes32(&mut sub_reader)?); + let rk = PublicKey::read(&mut sub_reader)?; + let proof_i = Proof::read(&mut sub_reader)?; + + let signature = Signature::read(&mut reader)?; + Ok(Input { + cv, + nf, + rk, + proof_i, + signature, + sig_payload, + }) +} + +pub fn read_list(mut reader: R) -> io::Result> { + let total_size = read_size(&mut reader)?; + let mut bytes = Vec::with_capacity(total_size); + + reader + .take(total_size.try_into().unwrap()) + .read_to_end(&mut bytes)?; + + Ok(bytes) +} + +pub fn read_inputs(mut reader: R) -> io::Result> { + let mut inputs: Vec = Vec::with_capacity(1); + while let Ok(input) = read_input(&mut reader) { + inputs.push(input); + } + Ok(inputs) +} + +pub fn read_cmu(mut reader: R) -> io::Result { + let bytes = read_bytes32(&mut reader)?; + Option::from(Commitment::from_bytes(&bytes)) + .ok_or_else(|| io::Error::new(io::ErrorKind::InvalidInput, "cmu not in field")) +} + +pub fn read_value_commitment(mut reader: R) -> io::Result { + let bytes = read_bytes32(&mut reader)?; + let cv = ValueCommitment::from_bytes_not_small_order(&bytes); + if cv.is_none().into() { + Err(io::Error::new( + io::ErrorKind::InvalidInput, + "Invalid value commitment", + )) + } else { + Ok(cv.unwrap()) + } +} + +pub fn read_payload_enc(mut reader: R) -> io::Result> { + let payload_enc_size = read_size(&mut reader)?; + let mut payload_enc = Vec::with_capacity(payload_enc_size); + reader + .take(payload_enc_size.try_into().unwrap()) + .read_to_end(&mut payload_enc)?; + + Ok(payload_enc) +} + +pub fn read_ciphertext(mut reader: R) -> io::Result { + let cv = read_value_commitment(&mut reader)?; + let epk = PublicKey::read(&mut reader)?; + let payload_enc = read_payload_enc(&mut reader)?; + + let mut nonce_enc = [0u8; NONCE_SIZE]; + let mut payload_out = [0u8; PAYLOAD_OUT_SIZE]; + let mut nonce_out = [0u8; NONCE_SIZE]; + reader.read_exact(&mut nonce_enc)?; + reader.read_exact(&mut payload_out)?; + reader.read_exact(&mut nonce_out)?; + + Ok(Ciphertext { + cv, + epk, + payload_enc, + nonce_enc, + payload_out, + nonce_out, + }) +} + +pub fn write_ciphertext(ciphertext: &Ciphertext, mut writer: W) -> io::Result<()> { + writer.write(ciphertext.cv.to_bytes().as_slice())?; + ciphertext.epk.write(&mut writer)?; + + writer.write(&ciphertext.payload_enc.len().to_be_bytes()[4..])?; + writer.write(ciphertext.payload_enc.as_slice())?; + + writer.write(ciphertext.nonce_enc.as_slice())?; + writer.write(ciphertext.payload_out.as_slice())?; + writer.write(ciphertext.nonce_out.as_slice())?; + + Ok(()) +} + +pub fn read_output(mut reader: R) -> io::Result { + let cm = read_cmu(&mut reader)?; + let proof_o = Proof::read(&mut reader)?; + let ciphertext = read_ciphertext(&mut reader)?; + + Ok(Output { + cm, + proof_o, + ciphertext, + }) +} + +pub fn read_outputs(mut reader: R) -> io::Result> { + let mut outputs: Vec = Vec::with_capacity(2); + while let Ok(output) = read_output(&mut reader) { + outputs.push(output); + } + Ok(outputs) +} + +pub fn read_i64(mut reader: R) -> io::Result { + let mut buf = [0u8; 8]; + reader.read_exact(&mut buf)?; + Ok(i64::from_be_bytes(buf)) +} + +pub fn read_vec(mut reader: R) -> io::Result> { + let vec_size = read_size(&mut reader)?; + let mut bytes = Vec::with_capacity(vec_size); + reader + .take(vec_size.try_into().unwrap()) + .read_to_end(&mut bytes)?; + Ok(bytes) +} + +pub fn read_transaction(mut reader: R) -> io::Result { + let input_bytes = read_list(&mut reader)?; + let output_bytes = read_list(&mut reader)?; + let inputs = read_inputs(input_bytes.as_slice())?; + let outputs = read_outputs(output_bytes.as_slice())?; + let binding_sig = Signature::read(&mut reader)?; + let balance = read_i64(&mut reader)?; + let root = read_bytes32(&mut reader)?; + let bound_data = read_vec(&mut reader)?; + let sig_payload = [input_bytes, output_bytes, bound_data.clone()].concat(); + Ok(SaplingTransaction { + inputs, + outputs, + binding_sig, + balance, + root, + bound_data, + sig_payload, + }) +} + +impl TryFrom<&[u8]> for SaplingTransaction { + type Error = io::Error; + + fn try_from(value: &[u8]) -> Result { + let mut reader = io::BufReader::new(value); + read_transaction(&mut reader) + } +} + +impl TryFrom<&[u8]> for Ciphertext { + type Error = io::Error; + + fn try_from(value: &[u8]) -> Result { + read_ciphertext(value) + } +} + +impl TryInto> for &Ciphertext { + type Error = io::Error; + + fn try_into(self) -> Result, Self::Error> { + let mut writer: Vec = Vec::new(); + write_ciphertext(self, &mut writer)?; + Ok(writer) + } +} + +#[cfg(test)] +mod test { + use std::{borrow::Borrow, io}; + + use crate::{storage::Ciphertext, types::SaplingTransaction}; + + const CIPHERTEXT_HEX: &'static str = "\ + 3f0d39c7e0\ + 071712cd21d82d70079ea270c4d2ee26121db6c12f8b922f8af9909bf1a5e50d\ + 8364707f657cef0ac568ba9368afb1f7d1b4d77fff07bad9a3f96a0000004f0c\ + 4eab5d24f6c3c137a28428f2b4d2b33ab386f1fa1544ea5b0019e7479e362f92\ + 6dc2c878ea6c3015aecc01aaa531d1c08f55e8f49cb65c96c3f9089b8a66d121\ + 94147e16b95f2340eb5860beae21ed571a724ec5c9ec685b0e22adc2a7294375\ + 5fdfe1ebdff616882b096762e8bc996a899452b1132678b879d8f306c3dc3a17\ + 925b8c65e14de34023c22dc4bdba5dddee4def4cd25b5c2597582b754d982145\ + ea29cfcb132cf2a35a7b41c17a90f83d675ed156159ea8e7acf58889e83e1b73\ + ed59f5f954af127b0469e5c3216c"; + + #[test] + fn test_ciphertext_encode() -> std::io::Result<()> { + let payload = hex::decode(CIPHERTEXT_HEX) + .map_err(|e| io::Error::new(io::ErrorKind::InvalidInput, e.to_string()))?; + + let ciphertext = Ciphertext::try_from(payload.as_slice())?; + let res: Vec = ciphertext.borrow().try_into()?; + + assert_eq!(payload, res); + Ok(()) + } + + // https://ghostnet.tzkt.io/KT1PwYL1B8hagFeCcByAcsN3KTQHmJFfDwnj + const SHIELDING_TX_HEX: &'static str = + include_str!("../tests/data/op4u8djpMUU5n2q1vuoSa4CApTa2cim3jjyXJD7pJeMQ9mH6Vxc"); + + #[test] + fn test_shielding_tx_decode() -> std::io::Result<()> { + let payload = hex::decode(SHIELDING_TX_HEX) + .map_err(|e| io::Error::new(io::ErrorKind::InvalidInput, e.to_string()))?; + + let tx = SaplingTransaction::try_from(payload.as_slice())?; + assert_eq!(0, tx.bound_data.len(), "Expected empty bound data"); + assert_eq!(-10000000, tx.balance, "Expected negative balance"); + assert_eq!(0, tx.inputs.len(), "Expected no inputs"); + assert_eq!(1, tx.outputs.len(), "Expected one output"); + Ok(()) + } + + // https://ghostnet.tzkt.io/KT1PwYL1B8hagFeCcByAcsN3KTQHmJFfDwnj + const SAPLING_TX_HEX: &'static str = + include_str!("../tests/data/opDWbJCeqTFayGipzgtczTxdvwVjVFYpC2qAbkvFJLLVcqF6rEx"); + + #[test] + fn test_sapling_tx_decode() -> std::io::Result<()> { + let payload = hex::decode(SAPLING_TX_HEX) + .map_err(|e| io::Error::new(io::ErrorKind::InvalidInput, e.to_string()))?; + + let tx = SaplingTransaction::try_from(payload.as_slice())?; + assert_eq!(0, tx.bound_data.len(), "Expected empty bound data"); + assert_eq!(0, tx.balance, "Expected zero balance"); + assert_eq!(1, tx.inputs.len(), "Expected single input"); + assert_eq!(2, tx.outputs.len(), "Expected two outputs"); + Ok(()) + } + + // https://ghostnet.tzkt.io/KT1PwYL1B8hagFeCcByAcsN3KTQHmJFfDwnj + const UNSHIELDING_TX_HEX: &'static str = + include_str!("../tests/data/ooCfUWEY9785vAiGxvCqS74qDyCd8vWPXikuLycHjexwe17ALAb"); + + #[test] + fn test_unshielding_tx_decode() -> std::io::Result<()> { + let payload = hex::decode(UNSHIELDING_TX_HEX) + .map_err(|e| io::Error::new(io::ErrorKind::InvalidInput, e.to_string()))?; + + let tx = SaplingTransaction::try_from(payload.as_slice())?; + assert_ne!(0, tx.bound_data.len(), "Expected non-empty bound data"); + assert_eq!(10000000, tx.balance, "Expected positibe balance"); + assert_eq!(1, tx.inputs.len(), "Expected single input"); + assert_eq!(1, tx.outputs.len(), "Expected single output"); + Ok(()) + } +} diff --git a/sapling_proto/src/executor.rs b/sapling_proto/src/executor.rs new file mode 100644 index 0000000..ddf7373 --- /dev/null +++ b/sapling_proto/src/executor.rs @@ -0,0 +1,43 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + +use anyhow::Result; + +use crate::{ + storage::{SaplingStorage, MAX_HEIGHT, MAX_ROOTS}, + tree::CommitmentTree, + types::{Commitment, SaplingTransaction}, +}; + +pub fn execute_transaction( + storage: &mut impl SaplingStorage, + transaction: &SaplingTransaction, +) -> Result<()> { + storage.check_no_pending_changes()?; + + let mut head = storage.get_head()?; + + for input in transaction.inputs.iter() { + storage.set_nullifier(input.nf.clone(), head.nullifiers_size)?; + head.nullifiers_size += 1; + } + + let mut tree = CommitmentTree::new(head.commitments_size, MAX_HEIGHT); + let mut commitments: Vec = Vec::with_capacity(transaction.outputs.len()); + + for output in transaction.outputs.iter() { + commitments.push(output.cm); + storage.set_ciphertext(output.ciphertext.clone(), head.commitments_size)?; + head.commitments_size += 1; + } + + let root = tree.add_commitments(storage, &commitments)?; + + // Starting from position 1, because at the very beginning there's empty root at position 0 + head.roots_pos = (head.roots_pos + 1) % MAX_ROOTS; + storage.set_root(root, head.roots_pos)?; + + storage.set_head(head)?; + storage.commit() +} diff --git a/sapling_proto/src/formatter.rs b/sapling_proto/src/formatter.rs new file mode 100644 index 0000000..49cc0f2 --- /dev/null +++ b/sapling_proto/src/formatter.rs @@ -0,0 +1,207 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + +use hex; +use zcash_primitives::merkle_tree::HashSer; + +use crate::{ + storage::{Ciphertext, SaplingHead}, + types::{ + Commitment, CommitmentNode, Hash, Input, Nullifier, Output, Proof, PublicKey, + SaplingTransaction, Signature, ValueCommitment, + }, +}; + +pub trait Formatter { + fn sprintf(&self, indent: usize, output: &mut String); + + fn to_string(&self) -> String { + let mut output = String::with_capacity(256); + self.sprintf(0, &mut output); + output + } +} + +impl Formatter for &[u8] { + fn sprintf(&self, _indent: usize, output: &mut String) { + output.push_str(&hex::encode(self)); + } +} + +impl Formatter for Vec { + fn sprintf(&self, indent: usize, output: &mut String) { + self.as_slice().sprintf(indent, output); + } +} + +impl Formatter for Hash { + fn sprintf(&self, indent: usize, output: &mut String) { + self.as_slice().sprintf(indent, output); + } +} + +impl Formatter for Commitment { + fn sprintf(&self, indent: usize, output: &mut String) { + self.to_bytes().sprintf(indent, output); + } +} + +impl Formatter for ValueCommitment { + fn sprintf(&self, indent: usize, output: &mut String) { + self.to_bytes().sprintf(indent, output); + } +} + +impl Formatter for CommitmentNode { + fn sprintf(&self, indent: usize, output: &mut String) { + let mut bytes = [0u8; 32]; + self.write(bytes.as_mut_slice()) + .expect("Failed to serialize commitment node"); + bytes.sprintf(indent, output) + } +} + +impl Formatter for Nullifier { + fn sprintf(&self, indent: usize, output: &mut String) { + self.0.sprintf(indent, output); + } +} + +impl Formatter for PublicKey { + fn sprintf(&self, indent: usize, output: &mut String) { + let mut bytes = [0u8; 32]; + self.write(bytes.as_mut_slice()) + .expect("Failed to serialize public key"); + bytes.as_slice().sprintf(indent, output) + } +} + +impl Formatter for Signature { + fn sprintf(&self, indent: usize, output: &mut String) { + let mut bytes = [0u8; 64]; + self.write(bytes.as_mut_slice()) + .expect("Failed to serialize signature"); + bytes.as_slice().sprintf(indent, output) + } +} + +impl Formatter for Proof { + fn sprintf(&self, indent: usize, output: &mut String) { + let mut bytes = [0u8; 192]; + self.write(bytes.as_mut_slice()) + .expect("Failed to serialize groth16 proof"); + bytes.as_slice().sprintf(indent, output) + } +} + +impl Formatter for Ciphertext { + fn sprintf(&self, indent: usize, output: &mut String) { + output.push_str("{"); + output.push_str(&format!("\n{}cv: ", " ".repeat(indent + 2))); + self.cv.sprintf(0, output); + output.push_str(&format!("\n{}epk: ", " ".repeat(indent + 2))); + self.epk.sprintf(0, output); + output.push_str(&format!("\n{}payload_enc: ", " ".repeat(indent + 2))); + self.payload_enc.as_slice().sprintf(0, output); + output.push_str(&format!("\n{}nonce_enc: ", " ".repeat(indent + 2))); + self.nonce_enc.as_slice().sprintf(0, output); + output.push_str(&format!("\n{}payload_out: ", " ".repeat(indent + 2))); + self.payload_out.as_slice().sprintf(0, output); + output.push_str(&format!("\n{}nonce_out: ", " ".repeat(indent + 2))); + self.nonce_out.as_slice().sprintf(0, output); + output.push_str(&format!("\n{}}}", " ".repeat(indent))); + } +} + +impl Formatter for Input { + fn sprintf(&self, indent: usize, output: &mut String) { + output.push_str("{"); + output.push_str(&format!("\n{}cv: ", " ".repeat(indent + 2))); + self.cv.sprintf(0, output); + output.push_str(&format!("\n{}nf: ", " ".repeat(indent + 2))); + self.nf.sprintf(0, output); + output.push_str(&format!("\n{}rk: ", " ".repeat(indent + 2))); + self.rk.sprintf(0, output); + output.push_str(&format!("\n{}proof_i: ", " ".repeat(indent + 2))); + self.proof_i.sprintf(0, output); + output.push_str(&format!("\n{}signature: ", " ".repeat(indent + 2))); + self.signature.sprintf(0, output); + output.push_str(&format!("\n{}}}", " ".repeat(indent))); + } +} + +impl Formatter for Output { + fn sprintf(&self, indent: usize, output: &mut String) { + output.push_str("{"); + output.push_str(&format!("\n{}cm: ", " ".repeat(indent + 2))); + self.cm.sprintf(0, output); + output.push_str(&format!("\n{}proof_o: ", " ".repeat(indent + 2))); + self.proof_o.sprintf(0, output); + output.push_str(&format!("\n{}ciphertext: ", " ".repeat(indent + 2))); + self.ciphertext.sprintf(indent + 2, output); + output.push_str(&format!("\n{}}}", " ".repeat(indent))); + } +} + +impl Formatter for Vec { + fn sprintf(&self, indent: usize, output: &mut String) { + output.push_str("["); + for (i, item) in self.iter().enumerate() { + item.sprintf(indent + 2, output); + if i < self.len() - 1 { + output.push_str(", "); + } + } + output.push_str("]"); + } +} + +impl Formatter for SaplingTransaction { + fn sprintf(&self, indent: usize, output: &mut String) { + output.push_str("{"); + output.push_str(&format!("\n{}inputs: ", " ".repeat(indent + 2))); + self.inputs.sprintf(indent + 2, output); + output.push_str(&format!("\n{}outputs: ", " ".repeat(indent + 2))); + self.outputs.sprintf(indent + 2, output); + output.push_str(&format!("\n{}binding_sig: ", " ".repeat(indent + 2))); + self.binding_sig.sprintf(0, output); + output.push_str(&format!( + "\n{}balance: {}", + " ".repeat(indent + 2), + self.balance + )); + output.push_str(&format!("\n{}root: ", " ".repeat(indent + 2))); + self.root.sprintf(0, output); + output.push_str(&format!("\n{}bound_data: ", " ".repeat(indent + 2))); + self.bound_data.sprintf(0, output); + output.push_str(&format!("\n{}}}", " ".repeat(indent))); + } +} + +impl Formatter for SaplingHead { + fn sprintf(&self, indent: usize, output: &mut String) { + output.push_str("{"); + output.push_str(&format!( + "\n{}roots_pos: {}", + " ".repeat(indent + 2), + self.roots_pos + )); + output.push_str(&format!( + "\n{}nullifiers_size: {}", + " ".repeat(indent + 2), + self.nullifiers_size + )); + output.push_str(&format!( + "\n{}commitments_size: {}", + " ".repeat(indent + 2), + self.commitments_size + )); + output.push_str(&format!( + "\n{}memo_size: {}", + " ".repeat(indent + 2), + self.memo_size + )); + output.push_str(&format!("\n{}}}", " ".repeat(indent))); + } +} diff --git a/sapling_proto/src/keys/output.bin b/sapling_proto/src/keys/output.bin new file mode 100644 index 0000000..4873a8b Binary files /dev/null and b/sapling_proto/src/keys/output.bin differ diff --git a/sapling_proto/src/keys/spend.bin b/sapling_proto/src/keys/spend.bin new file mode 100644 index 0000000..9d42604 Binary files /dev/null and b/sapling_proto/src/keys/spend.bin differ diff --git a/sapling_proto/src/lib.rs b/sapling_proto/src/lib.rs new file mode 100644 index 0000000..12732b3 --- /dev/null +++ b/sapling_proto/src/lib.rs @@ -0,0 +1,12 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + +pub mod codec; +pub mod executor; +pub mod formatter; +pub mod params; +pub mod storage; +pub mod tree; +pub mod types; +pub mod validator; diff --git a/sapling_proto/src/params.rs b/sapling_proto/src/params.rs new file mode 100644 index 0000000..fa3f536 --- /dev/null +++ b/sapling_proto/src/params.rs @@ -0,0 +1,35 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + +use bellman::groth16::{prepare_verifying_key, PreparedVerifyingKey, VerifyingKey}; +use bls12_381::Bls12; +use lazy_static::lazy_static; +use std::io; + +pub fn read_verifying_key(data: &[u8]) -> io::Result> { + let vk = VerifyingKey::::read(data)?; + Ok(prepare_verifying_key(&vk)) +} + +pub struct SaplingParams { + pub spend_vk: PreparedVerifyingKey, + pub output_vk: PreparedVerifyingKey, +} + +impl SaplingParams { + pub fn zcash() -> Self { + let spend_vk = read_verifying_key(include_bytes!("./keys/spend.bin")) + .expect("Failed to read spend verifying key"); + let output_vk = read_verifying_key(include_bytes!("./keys/output.bin")) + .expect("Failed to read spend output key"); + Self { + spend_vk, + output_vk, + } + } +} + +lazy_static! { + pub static ref ZCASH_PARAMS: SaplingParams = SaplingParams::zcash(); +} diff --git a/sapling_proto/src/storage/ciphertext.rs b/sapling_proto/src/storage/ciphertext.rs new file mode 100644 index 0000000..823195f --- /dev/null +++ b/sapling_proto/src/storage/ciphertext.rs @@ -0,0 +1,36 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + +use zcash_primitives::sapling::{redjubjub::PublicKey, value::ValueCommitment}; + +pub const PAYLOAD_OUT_SIZE: usize = 80; +pub const NONCE_SIZE: usize = 24; + +#[derive(Clone, Debug)] +pub struct Ciphertext { + pub cv: ValueCommitment, + pub epk: PublicKey, + pub payload_enc: Vec, + pub nonce_enc: [u8; NONCE_SIZE], + pub payload_out: [u8; PAYLOAD_OUT_SIZE], + pub nonce_out: [u8; NONCE_SIZE], +} + +impl Ciphertext { + // Payload contains fixed length fields and a variable size memo. + // The fixed length things are diversifier, amount, rcm and a message + // authentication code and 4 bytes added by the encoding for the length + // of the variable length field memo. + pub fn get_memo_size(&self) -> u8 { + const DIVERSIFIER_SIZE: usize = 11; + const AMOUNT_SIZE: usize = 8; + const RCM_SIZE: usize = 32; + const TAG_SIZE: usize = 16; + let memo_size = + self.payload_enc.len() - (DIVERSIFIER_SIZE + AMOUNT_SIZE + RCM_SIZE + TAG_SIZE + 4); + memo_size + .try_into() + .expect("Memo size cannot be larger than 256") + } +} diff --git a/sapling_proto/src/storage/head.rs b/sapling_proto/src/storage/head.rs new file mode 100644 index 0000000..c5d05ea --- /dev/null +++ b/sapling_proto/src/storage/head.rs @@ -0,0 +1,30 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + +pub const DEFAULT_MEMO_SIZE: u8 = 8; + +#[derive(Clone, Debug, PartialEq)] +pub struct SaplingHead { + pub roots_pos: u64, + pub nullifiers_size: u64, // FIXME: bigint + pub commitments_size: u64, // FIXME: bigint + pub memo_size: u8, +} + +impl SaplingHead { + pub fn new(memo_size: u8) -> Self { + Self { + roots_pos: 0, + nullifiers_size: 0, + commitments_size: 0, + memo_size, + } + } +} + +impl Default for SaplingHead { + fn default() -> Self { + Self::new(DEFAULT_MEMO_SIZE) + } +} diff --git a/sapling_proto/src/storage/migrations.rs b/sapling_proto/src/storage/migrations.rs new file mode 100644 index 0000000..7de8c9d --- /dev/null +++ b/sapling_proto/src/storage/migrations.rs @@ -0,0 +1,20 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + +use anyhow::Result; + +use crate::{ + storage::{SaplingHead, SaplingStorage}, + tree::CommitmentTree, +}; + +pub fn run_migrations(storage: &mut impl SaplingStorage, head: &SaplingHead) -> Result<()> { + storage.check_no_pending_changes()?; + + if head.commitments_size == 0 { + storage.set_root(CommitmentTree::empty_root(), 0)?; + } + + storage.commit() +} diff --git a/sapling_proto/src/storage/mod.rs b/sapling_proto/src/storage/mod.rs new file mode 100644 index 0000000..3459b67 --- /dev/null +++ b/sapling_proto/src/storage/mod.rs @@ -0,0 +1,19 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + +pub mod ciphertext; +pub mod head; +pub mod migrations; +pub mod sapling; +pub mod store; + +pub const MAX_ROOTS: u64 = 120; +pub const MAX_HEIGHT: u8 = 32; + +pub use ciphertext::Ciphertext; +pub use head::SaplingHead; +pub use migrations::run_migrations; +pub use sapling::SaplingStorage; + +pub type SaplingEphemeralStorage = layered_store::EphemeralStore; diff --git a/sapling_proto/src/storage/sapling.rs b/sapling_proto/src/storage/sapling.rs new file mode 100644 index 0000000..1d0892f --- /dev/null +++ b/sapling_proto/src/storage/sapling.rs @@ -0,0 +1,136 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + +use anyhow::Result; +use layered_store::{LayeredStore, StoreBackend}; +use zcash_primitives::merkle_tree::HashSer; + +use crate::{ + formatter::Formatter, + storage::{Ciphertext, SaplingHead}, + types::{CommitmentNode, Hash, Nullifier}, +}; + +pub trait SaplingStorage { + fn set_head(&mut self, head: SaplingHead) -> Result<()>; + fn get_head(&mut self) -> Result; + + // Dual representation: as a ring queue and as a hashset + fn set_root(&mut self, root: Hash, position: u64) -> Result<()>; + fn has_root(&self, root: &Hash) -> Result; + fn get_root(&mut self, position: u64) -> Result>; + + // Dual representation: as an array and as a hashset + fn set_nullifier(&mut self, nullifier: Nullifier, position: u64) -> Result<()>; + fn has_nullifier(&self, nullifier: &Nullifier) -> Result; + fn get_nullifier(&mut self, position: u64) -> Result>; + + // Flattened incremental Merkle tree + // The height of the leaves level is 0, height of the root is [MAX_HEIGHT] + // Path is the sequential number of a node in the tree: root = 1, left = 2, right = 3, etc + // [CommitmentNode] is a more generic type for commitment tree structure, can be constructed out of a [Commitment] + fn set_commitment(&mut self, commitment: CommitmentNode, path: u64) -> Result<()>; + fn get_commitment(&mut self, path: u64) -> Result>; + + // Linked to leaves-level commitments + // Position is relative number of the leaf, starts from 0, actually it's [Path] - 2 ^ [MAX_HEIGHT] + fn set_ciphertext(&mut self, ciphertext: Ciphertext, position: u64) -> Result<()>; + fn get_ciphertext(&mut self, position: u64) -> Result>; + + fn check_no_pending_changes(&self) -> Result<()>; + fn commit(&mut self) -> Result<()>; + fn rollback(&mut self); +} + +impl SaplingStorage for LayeredStore { + fn get_head(&mut self) -> Result { + Ok(self + .get("/head".into())? + .unwrap_or_else(|| SaplingHead::default())) + } + + fn set_head(&mut self, head: SaplingHead) -> Result<()> { + Ok(self.set("/head".into(), Some(head))?) + } + + fn set_root(&mut self, root: Hash, position: u64) -> Result<()> { + if let Some(expired_root) = self.get_root(position)? { + self.set::(format!("/roots_hashed/{}", expired_root.to_string()), None)?; + } + self.set(format!("/roots/{}", position), Some(root.clone()))?; + self.set( + format!("/roots_hashed/{}", root.to_string()), + Some(position), + )?; + Ok(()) + } + + fn has_root(&self, root: &Hash) -> Result { + Ok(self.has(format!("/roots_hashed/{}", root.to_string()))?) + } + + fn get_root(&mut self, position: u64) -> Result> { + Ok(self.get(format!("/roots/{}", position))?) + } + + fn set_nullifier(&mut self, nullifier: Nullifier, position: u64) -> Result<()> { + self.set( + format!("/nullifiers_ordered/{}", position), + Some(nullifier.0), + )?; + self.set( + format!("/nullifiers_hashed/{}", nullifier.to_string()), + Some(position), + )?; + Ok(()) + } + + fn has_nullifier(&self, nullifier: &Nullifier) -> Result { + Ok(self.has(format!("/nullifiers_hashed/{}", nullifier.to_string()))?) + } + + fn get_nullifier(&mut self, position: u64) -> Result> { + Ok(self + .get(format!("/nullifiers_ordered/{}", position))? + .map(|nf| Nullifier(nf))) + } + + fn set_commitment(&mut self, commitment: CommitmentNode, path: u64) -> Result<()> { + let mut cm = [0u8; 32]; + commitment.write(cm.as_mut_slice())?; + Ok(self.set(format!("/commitments/{}", path), Some(cm))?) + } + + fn get_commitment(&mut self, path: u64) -> Result> { + if let Some(cm) = self.get::<[u8; 32]>(format!("/commitments/{}", path))? { + Ok(Some(CommitmentNode::read(cm.as_slice())?)) + } else { + Ok(None) + } + } + + fn set_ciphertext(&mut self, ciphertext: Ciphertext, position: u64) -> Result<()> { + Ok(self.set(format!("/ciphertexts/{}", position), Some(ciphertext))?) + } + + fn get_ciphertext(&mut self, position: u64) -> Result> { + Ok(self.get(format!("/ciphertexts/{}", position))?) + } + + fn check_no_pending_changes(&self) -> Result<()> { + if self.has_pending_changes() { + Err(layered_store::Error::ContextUnstagedError.into()) + } else { + Ok(()) + } + } + + fn commit(&mut self) -> Result<()> { + Ok(LayeredStore::commit(self)?) + } + + fn rollback(&mut self) { + LayeredStore::rollback(self); + } +} diff --git a/sapling_proto/src/storage/store.rs b/sapling_proto/src/storage/store.rs new file mode 100644 index 0000000..92c8009 --- /dev/null +++ b/sapling_proto/src/storage/store.rs @@ -0,0 +1,44 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + +use layered_store::{error::err_into, internal_error, Result, StoreType}; +use std::io::Write; + +use crate::storage::{Ciphertext, SaplingHead}; + +impl StoreType for SaplingHead { + fn from_bytes(bytes: &[u8]) -> Result { + if bytes.len() != 25 { + return Err(internal_error!( + "Unexpected SaplingHead byte len: {}", + bytes.len() + )); + } + Ok(SaplingHead { + roots_pos: u64::from_be_bytes(bytes[..8].try_into().unwrap()), + nullifiers_size: u64::from_be_bytes(bytes[8..16].try_into().unwrap()), + commitments_size: u64::from_be_bytes(bytes[16..24].try_into().unwrap()), + memo_size: bytes[24], + }) + } + + fn to_bytes(&self) -> Result> { + let mut buf = Vec::with_capacity(32); + buf.write(self.roots_pos.to_be_bytes().as_slice())?; + buf.write(self.nullifiers_size.to_be_bytes().as_slice())?; + buf.write(self.commitments_size.to_be_bytes().as_slice())?; + buf.write(&[self.memo_size])?; + Ok(buf) + } +} + +impl StoreType for Ciphertext { + fn from_bytes(bytes: &[u8]) -> Result { + Ciphertext::try_from(bytes).map_err(err_into) + } + + fn to_bytes(&self) -> Result> { + self.try_into().map_err(err_into) + } +} diff --git a/sapling_proto/src/tree.rs b/sapling_proto/src/tree.rs new file mode 100644 index 0000000..2991b0c --- /dev/null +++ b/sapling_proto/src/tree.rs @@ -0,0 +1,189 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + +use anyhow::{bail, Result}; +use incrementalmerkletree::Hashable; +use zcash_primitives::merkle_tree::HashSer; + +use crate::{ + storage::{SaplingStorage, MAX_HEIGHT}, + types::{Commitment, CommitmentNode, Hash}, +}; + +pub struct CommitmentTree { + pub max_height: u8, + pub dissect_path: u64, + pub commitments_size: u64, +} + +impl CommitmentTree { + pub fn new(commitments_size: u64, max_height: u8) -> Self { + Self { + dissect_path: if commitments_size > 0 { + (1 << max_height) + commitments_size + } else { + 0 + }, + max_height, + commitments_size, + } + } + + pub fn empty_root() -> Hash { + let root = CommitmentNode::empty_root(MAX_HEIGHT.try_into().unwrap()); + let mut hash = [0u8; 32]; + root.write(hash.as_mut_slice()) + .expect("Failed to serialize root"); + hash + } + + pub fn get_root_at( + &self, + storage: &mut impl SaplingStorage, + height: u8, + path: u64, + ) -> Result { + if path <= self.dissect_path >> height { + let cm = storage + .get_commitment(path)? + .unwrap_or_else(|| CommitmentNode::empty_root(height.into())); + Ok(cm) + } else { + Ok(CommitmentNode::empty_root(height.into())) + } + } + + fn split_at(commitments: &[Commitment], mid: usize) -> (&[Commitment], &[Commitment]) { + if mid < commitments.len() { + commitments.split_at(mid) + } else { + (commitments, &[]) + } + } + + fn add_commitments_at( + &self, + storage: &mut impl SaplingStorage, + commitments: &[Commitment], + position: u64, + height: u8, + path: u64, + ) -> Result { + if height > self.max_height { + bail!( + "Height {} is greater than expected maximum {}", + height, + self.max_height + ); + } + + // If no pending commitments, return commitment for this path (if exists) + if commitments.is_empty() { + return self.get_root_at(storage, height, path); + } + + let node = if height == 0 { + if commitments.len() != 1 { + bail!("Unexpected number of commitments {}", commitments.len()); + } + + CommitmentNode::from_cmu(&commitments[0]) + } else { + // We know that the tree is append only + // In case of a single commitment it's safe to assume all right-side branches are uncommitted + // Everything on the left side we need to fetch from the storage + // If we insert more than one commitment there might be cases when both branches are affected + let height = height - 1; + let level_pos = 1 << height; + + // Recall that position is the index of first commitment related to the left-most leaf of the given subtree + let (hl, hr) = if position < level_pos { + let (cml, cmr) = Self::split_at(commitments, (level_pos - position) as usize); + ( + self.add_commitments_at(storage, cml, position, height, path << 1)?, + self.add_commitments_at(storage, cmr, 0, height, (path << 1) + 1)?, + ) + } else { + ( + self.get_root_at(storage, height, path << 1)?, + self.add_commitments_at( + storage, + commitments, + position - level_pos, + height, + (path << 1) + 1, + )?, + ) + }; + + CommitmentNode::combine(height.try_into().unwrap(), &hl, &hr) + }; + + storage.set_commitment(node.clone(), path)?; + Ok(node) + } + + pub fn add_commitments( + &mut self, + storage: &mut impl SaplingStorage, + commitments: &Vec, + ) -> Result { + let res = self.add_commitments_at( + storage, + commitments.as_slice(), + self.commitments_size, + MAX_HEIGHT, + 1, + )?; + self.commitments_size += commitments.len() as u64; + + let mut root: Hash = Hash::default(); + res.write(root.as_mut_slice())?; + Ok(root) + } +} + +#[cfg(test)] +mod test { + use anyhow::Result; + use hex; + use incrementalmerkletree::Hashable; + + use crate::{ + storage::{SaplingEphemeralStorage, MAX_HEIGHT}, + tree::CommitmentTree, + types::{Commitment, CommitmentNode}, + }; + + // https://rpc.tzkt.io/ghostnet/chains/main/blocks/head/context/raw/json/sapling/index/6055 + + #[test] + fn test_empty_tree() -> Result<()> { + let mut storage = SaplingEphemeralStorage::default(); + let tree = CommitmentTree::new(0, MAX_HEIGHT); + let root = tree.get_root_at(&mut storage, MAX_HEIGHT, 1)?; + + assert_eq!( + CommitmentNode::empty_root(MAX_HEIGHT.try_into().unwrap()), + root + ); + Ok(()) + } + + #[test] + fn test_single_commitment() -> Result<()> { + let mut storage = SaplingEphemeralStorage::default(); + let mut tree = CommitmentTree::new(0, MAX_HEIGHT); + + let cm = hex::decode("f1de6f589f17cda6e8811dd2fb5b2b78875d440de07f6964a2f06e4e26f99b25")?; + let commitment = Commitment::from_bytes(cm.as_slice().try_into().unwrap()).unwrap(); + + let root = hex::decode("69a1f12aea9ef4019a059e69e70d6317c35d936d3ea61181f9fa9fa297fe092f")?; + let root_hash: [u8; 32] = root.as_slice().try_into().unwrap(); + + let res = tree.add_commitments(&mut storage, &vec![commitment])?; + assert_eq!(root_hash, res); + Ok(()) + } +} diff --git a/sapling_proto/src/types.rs b/sapling_proto/src/types.rs new file mode 100644 index 0000000..c230a9d --- /dev/null +++ b/sapling_proto/src/types.rs @@ -0,0 +1,44 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + +use crate::storage::Ciphertext; +pub use zcash_primitives::sapling::{ + note::ExtractedNoteCommitment as Commitment, + redjubjub::{PublicKey, Signature}, + value::ValueCommitment, + Node as CommitmentNode, Nullifier, +}; + +pub const HASH_SIZE: usize = 32; + +pub type Hash = [u8; HASH_SIZE]; +pub type Proof = bellman::groth16::Proof; + +#[derive(Clone, Debug)] +pub struct Input { + pub cv: ValueCommitment, + pub nf: Nullifier, + pub rk: PublicKey, + pub proof_i: Proof, + pub signature: Signature, + pub sig_payload: Vec, +} + +#[derive(Clone, Debug)] +pub struct Output { + pub cm: Commitment, + pub proof_o: Proof, + pub ciphertext: Ciphertext, +} + +#[derive(Clone, Debug)] +pub struct SaplingTransaction { + pub inputs: Vec, + pub outputs: Vec, + pub binding_sig: Signature, + pub balance: i64, + pub root: Hash, // aka "anchor" + pub bound_data: Vec, // packed arbitrary Micheline expression + pub sig_payload: Vec, +} diff --git a/sapling_proto/src/validator.rs b/sapling_proto/src/validator.rs new file mode 100644 index 0000000..9c815f7 --- /dev/null +++ b/sapling_proto/src/validator.rs @@ -0,0 +1,230 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + +use anyhow::{bail, Result}; + +use blake2b_simd::Params; +use zcash_proofs::sapling::SaplingVerificationContext; + +pub const MAX_INPUTS: usize = 5208; +pub const MAX_OUTPUTS: usize = 2019; + +use crate::{ + formatter::Formatter, + params::ZCASH_PARAMS, + storage::SaplingStorage, + types::{Hash, Input, Output, SaplingTransaction, HASH_SIZE}, +}; + +pub fn get_sighash(payload: &Vec, anti_replay: &String) -> Result { + let mut blake2b = Params::new(); + let digest = blake2b + .key(anti_replay.as_bytes()) + .hash_length(HASH_SIZE) + .hash(payload.as_slice()); + + Ok(digest.as_bytes().try_into().unwrap()) +} + +pub fn check_spend( + ctx: &mut SaplingVerificationContext, + input: &Input, + anchor: &bls12_381::Scalar, + anti_replay: &String, +) -> Result { + let sighash_value = get_sighash(&input.sig_payload, &anti_replay)?; + let res = ctx.check_spend( + &input.cv, + anchor.clone(), + &input.nf.0, + input.rk.clone(), + &sighash_value, + input.signature.clone(), + input.proof_i.clone(), + &ZCASH_PARAMS.spend_vk, + ); + Ok(res) +} + +pub fn check_output(ctx: &mut SaplingVerificationContext, output: &Output) -> Result { + let res = ctx.check_output( + &output.ciphertext.cv, + output.cm.clone(), + output.ciphertext.epk.0.clone(), + output.proof_o.clone(), + &ZCASH_PARAMS.output_vk, + ); + Ok(res) +} + +pub fn validate_transaction( + storage: &mut impl SaplingStorage, + transaction: &SaplingTransaction, + anti_replay: &String, +) -> Result<()> { + let mut ctx = SaplingVerificationContext::new(false); + let head = storage.get_head()?; + + if transaction.inputs.len() >= MAX_INPUTS { + bail!("Too many inputs: {}", transaction.inputs.len()); + } + + if transaction.outputs.len() >= MAX_OUTPUTS { + bail!("Too many outputs: {}", transaction.outputs.len()); + } + + if !storage.has_root(&transaction.root)? { + bail!( + "Transaction is expired (root = {:?})", + transaction.root.to_string() + ); + } + + // Mind the order (first outputs, then inputs) — it influences the final PK for verifying binding sig + for (idx, output) in transaction.outputs.iter().enumerate() { + if output.ciphertext.get_memo_size() != head.memo_size { + bail!("Output #{} has invalid memo size", idx); + } + + if !check_output(&mut ctx, output)? { + bail!("Output #{} is not valid", idx); + } + } + + let anchor = bls12_381::Scalar::from_bytes(&transaction.root).unwrap(); + for (idx, input) in transaction.inputs.iter().enumerate() { + if storage.has_nullifier(&input.nf)? { + bail!( + "Input #{} nullifier already in use (nf = {})", + idx, + input.nf.to_string() + ); + } + + if !check_spend(&mut ctx, input, &anchor, anti_replay)? { + bail!("Input #{} is not valid", idx); + } + } + + let sighash_value = get_sighash(&transaction.sig_payload, anti_replay)?; + if !ctx.final_check( + transaction.balance.try_into().unwrap(), + &sighash_value, + transaction.binding_sig, + ) { + bail!("Binding signature is invalid"); + } + + Ok(()) +} + +#[cfg(test)] +mod test { + use anyhow::Result; + use hex; + use mockall::predicate::*; + use mockall::*; + use std::io; + use zcash_primitives::{ + constants::SPENDING_KEY_GENERATOR, + sapling::redjubjub::{PublicKey, Signature}, + }; + + use crate::{ + storage::{Ciphertext, SaplingHead, SaplingStorage}, + types::{CommitmentNode, Hash, Nullifier, SaplingTransaction}, + validator::{get_sighash, validate_transaction}, + }; + + const CHAIN_ID: &'static str = "NetXnHfVqm9iesp"; + const CONTRACT_ADDRESS: &'static str = "KT1PwYL1B8hagFeCcByAcsN3KTQHmJFfDwnj"; + const SAPLING_TX_HEX: &'static str = + include_str!("../tests/data/ong6gzsvydC8zgFn1KAM3HFFVymZbroRKqAH4tt1ejcYBcyvroy"); + + mock! { + Storage {} + impl SaplingStorage for Storage { + fn set_head(&mut self, head: SaplingHead) -> Result<()>; + fn get_head(&mut self) -> Result; + fn set_root(&mut self, root: Hash, position: u64) -> Result<()>; + fn has_root(&self, root: &Hash) -> Result; + fn get_root(&mut self, position: u64) -> Result>; + fn set_nullifier(&mut self, nullifier: Nullifier, position: u64) -> Result<()>; + fn has_nullifier(&self, nullifier: &Nullifier) -> Result; + fn get_nullifier(&mut self, position: u64) -> Result>; + fn set_commitment(&mut self, commitment: CommitmentNode, path: u64) -> Result<()>; + fn get_commitment(&mut self, path: u64) -> Result>; + fn set_ciphertext(&mut self, ciphertext: Ciphertext, position: u64) -> Result<()>; + fn get_ciphertext(&mut self, position: u64) -> Result>; + fn check_no_pending_changes(&self) -> Result<()>; + fn commit(&mut self) -> Result<()>; + fn rollback(&mut self); + } + } + + #[test] + fn test_verify_spend_sig() -> Result<()> { + // { "cv": "8e57b5c09010468f27dea7390f868d6a2bc475b90351fa44cfc91dd7fdab2caa", + // "nf": "d97a43b97ebda42b4d286c31f867bc58b416af0ddf4b8a33a07d448cbe74c97f", + // "rk": "96d53d578c08d2e0f6f8a264c7248d5c4f796d8eee2fef2f5537fea627e3e7da", + // "proof_i": "b56896734358241671d5368087da32cd308d915621f9933149d730f85091a4fbbac51abeba1c9c89d878e0b66c8dff2fa9cf7d09dbc0018db4cc77c7500772fb1a64919830ee62c075f8c4684219cfd3e6dc17896427c0c94b71a6e8fd9f1e7c0a0cf2c03c0d4b64791bf016aeda53f39981790310a5e1697e624ea704ef283bc86eda92646ecbf6f60d97e24285695dadd2af4d5c62f1cba2029f7408c4f3c314ec23e9b0a28fd9b68d83b2462a0612a20a7bbb5f7f6de622b0b68c3d7dcb34", + // "signature": "1f14e5bace9641fae8fe745c639acf75692d39e8cb56f433b5cf11928b8563b2ad910cacf5641e1e5e4e676f873baabab20707ca230fe036ebc4289622908108" } + let sig_payload: &'static str = "\ + 8e57b5c09010468f27dea7390f868d6a2bc475b90351fa44cfc91dd7fdab2caa\ + d97a43b97ebda42b4d286c31f867bc58b416af0ddf4b8a33a07d448cbe74c97f\ + 96d53d578c08d2e0f6f8a264c7248d5c4f796d8eee2fef2f5537fea627e3e7da\ + b56896734358241671d5368087da32cd308d915621f9933149d730f85091a4fb\ + bac51abeba1c9c89d878e0b66c8dff2fa9cf7d09dbc0018db4cc77c7500772fb\ + 1a64919830ee62c075f8c4684219cfd3e6dc17896427c0c94b71a6e8fd9f1e7c\ + 0a0cf2c03c0d4b64791bf016aeda53f39981790310a5e1697e624ea704ef283b\ + c86eda92646ecbf6f60d97e24285695dadd2af4d5c62f1cba2029f7408c4f3c3\ + 14ec23e9b0a28fd9b68d83b2462a0612a20a7bbb5f7f6de622b0b68c3d7dcb34"; + + let anti_replay = [CONTRACT_ADDRESS, CHAIN_ID].concat(); + let sighash = get_sighash(&hex::decode(sig_payload)?, &anti_replay)?; + + let rk_bytes = + hex::decode("96d53d578c08d2e0f6f8a264c7248d5c4f796d8eee2fef2f5537fea627e3e7da")?; + let rk = PublicKey::read(rk_bytes.as_slice())?; + + let mut data_to_be_signed = [0u8; 64]; + data_to_be_signed[0..32].copy_from_slice(&rk_bytes.as_slice()); + data_to_be_signed[32..64].copy_from_slice(&sighash[..]); + + let sig_bytes = hex::decode("1f14e5bace9641fae8fe745c639acf75692d39e8cb56f433b5cf11928b8563b2ad910cacf5641e1e5e4e676f873baabab20707ca230fe036ebc4289622908108")?; + let spend_auth_sig = Signature::read(sig_bytes.as_slice())?; + + let res = rk.verify_with_zip216( + &data_to_be_signed, + &spend_auth_sig, + SPENDING_KEY_GENERATOR, + false, + ); + assert_eq!(res, true); + + Ok(()) + } + + #[test] + fn test_verify_transaction() -> Result<()> { + let payload = hex::decode(SAPLING_TX_HEX) + .map_err(|e| io::Error::new(io::ErrorKind::InvalidInput, e.to_string()))?; + + let mut storage = MockStorage::new(); + storage.expect_get_head().returning(|| { + Ok(SaplingHead { + commitments_size: 1, + memo_size: 8, + nullifiers_size: 0, + roots_pos: 1, + }) + }); + storage.expect_has_root().returning(|_| Ok(true)); + storage.expect_has_nullifier().returning(|_| Ok(true)); + storage.expect_commit().returning(|| Ok(())); + + let tx = SaplingTransaction::try_from(payload.as_slice())?; + validate_transaction(&mut storage, &tx, &[CONTRACT_ADDRESS, CHAIN_ID].concat()) + } +} diff --git a/sapling_proto/tests/data/ong6gzsvydC8zgFn1KAM3HFFVymZbroRKqAH4tt1ejcYBcyvroy b/sapling_proto/tests/data/ong6gzsvydC8zgFn1KAM3HFFVymZbroRKqAH4tt1ejcYBcyvroy new file mode 100644 index 0000000..ec3954e --- /dev/null +++ b/sapling_proto/tests/data/ong6gzsvydC8zgFn1KAM3HFFVymZbroRKqAH4tt1ejcYBcyvroy @@ -0,0 +1 @@ +00000000000001f3f1de6f589f17cda6e8811dd2fb5b2b78875d440de07f6964a2f06e4e26f99b25b004c78eee562cbe5db1eb52042efda378c227c07d649a496121ed51155a322a6f768ee30ab0cfe37bb0b6cd238e325292b888683f720828a01615d126d847107e7ab1847ef07d3b19d7260318b457b7951c0cb95f5c72a32b85d6fef303bb5011e4125162c16b4c9a845bab7b175e379debc044e98f161b46cb6f955e9d03a6e708cc10df0e2c0a7fdab46cef61a07d837a2f287811f659b3410e3f9e78827bb035b27df9a052fa82af43d4f68dca2a7d4a9576168f07ed419d33f7c30cd78cd363af03b3fcccd9f24287b7f67ca79213a6a3a1bb8cb6a28cbed6027d829b92e177b6a94c8c1c5f1392d79f579d0349e0fd981a8e641ca46d0aa521a0a2c3a40000004ff9db50a921e41f8acbcb0c0006504c20732add906bccba01e5f5b6ee50cddb5356a61029569c0a0adc8879467d7c5c393b8738d55876b41e2406818cb68e07e6807c1e9411f8898c8feff9e55d5474a8634c173d9fa81abc1e442a1336a2855a3f6db56ce44031230850008eca4d0a70d9ed8005d93fa5545de7b7bfbe53ae70f963ebcdb5e57218dadac436adb2bad786311759780b786d4bcee0ed3f76801903ce3d41c6ded99145c8b276cf0109dce50c80ad64808aaf789de3fa54ae752f75735905f15dd2f30b923de19d53bab0ec5d7886735824b2ddf15fc72a48313b90a9ddf6a4df7cc3fad8c3495da0a4f40809c3710af64718dcf7d6b9de7fd52955ab9b0c53be54ca0c827dc52ed50cffffffffff676980fbc2f4300c01f0b7820d00e3347c8da4ee614674376cbc45359daa54f9b5493e00000000 \ No newline at end of file diff --git a/sapling_proto/tests/data/ooCfUWEY9785vAiGxvCqS74qDyCd8vWPXikuLycHjexwe17ALAb b/sapling_proto/tests/data/ooCfUWEY9785vAiGxvCqS74qDyCd8vWPXikuLycHjexwe17ALAb new file mode 100644 index 0000000..b1d2ddd --- /dev/null +++ b/sapling_proto/tests/data/ooCfUWEY9785vAiGxvCqS74qDyCd8vWPXikuLycHjexwe17ALAb @@ -0,0 +1 @@ +0000016030db8158f4999c7bac5814168b0ce2321d3b33aa3ac280ae5e8649c5ab52fd3d0472ee6f33596ababa40ef282f8bd9bfeb4fe5b9eab0ef4fec4f1c781dadab5a3539443a3c703dc6ebdecd7f72a5197caf01e5baab97c6cd58f0de27fc60519496443346ab96387eac99403c877c184a9b168f1573c3d66ab4f31ee1db6911216dcb6fe71f022fa8b076cb79007cbe1894c4b3e6ff068097546526b983832088eb710468d58436d2c2cbd4ec153c8dcaeb7c23c2b29cfb818df5f154037519e5083b5d5b33edbb0832002ed5123512e66a7fc2fd65f154c9564a71e552e3460e1bb479c59fa30a68d7f126322ef2bcef93c391e8307e1130b4e8b500102c094ad2912ccc7314f8206eff68eccb15e829a43de7343e13ef615db265518dd891431d12de0cd0c26ba98c90517e85ebc14efcd5bc14ff40e361f58ad26da2127907dca0206c19d41fd457059f668ddab51299156a325513db30ad6b6c75116f6703000001f379fef9f76b2c32d59a079892a52a777f4a2b510210b69edc9324c8491ae8e756895c7a80cd9dfcadbaa42d4497014c3a7820bd6a7e225c43705621d4f87c5dc44199aadf7ba9f0b02f8472dd3d71f153874c465aa78c9ae212e991ceb2eaeb11a76491a64875a1189a4f876989855c2965ae8c7805d28943a7dc458eb95216ad00599890bb3c59a48c4a63d632739478b3ce469240b8562d1ff46fedc9dd97eaa829ca7b0850376b10b9eef0a80b57baab41f4cba2bb52657f0b5da355db3a08450f1d5409d3e333c5050ad3b1cd57c1c496d5462fa7893cf126fae13e3c96ec8096ecbed7f0aa79917746f139310d7c7c158176679ef78ab30b66f81b01e7f1376331136e2b772943feffe49a014371ee2caff019a26761080e43f40dcb2d450000004fed167026a4b59fc7d7c112339f01f8759e67b4892b70aa47f2bbe008e1b92591a0edc032731d6c1f7d64f2d7a3847f2df04b8d0165346ba6d488485f87b8c83d6c0124f93789478d308702cc18526c8b377eb5743b94ac66fc6516441d5cc65f41c259ab148b8d90f57616b81b769236aacea37b4e4d3f24edd188c9b6652b482755436837af482bd3d853852cb4dedf6c28da367262d5c8b95f174fead54a349ce1c3afd966d63b71fac4a01be30038323d24519449da23a55b478427392f8a83b7e8ef9111a6a71a6240686aca78ab4e9f62bbc700f9d1331549f56dbc1f0027395bd638abbbd2d4b714c8c8d02e6e8d4a370ce3ecd1e6fa14b079060a9d2e30281a21b883fa8c7c2167466a060100000000009896804b73f854fd39c11097ed73b0a914b024bbe45abaebbc074007755ae6d7ab94320000001b050a000000150093245e9590d9df43c21a2d96eb838fb2de240e8c \ No newline at end of file diff --git a/sapling_proto/tests/data/op4u8djpMUU5n2q1vuoSa4CApTa2cim3jjyXJD7pJeMQ9mH6Vxc b/sapling_proto/tests/data/op4u8djpMUU5n2q1vuoSa4CApTa2cim3jjyXJD7pJeMQ9mH6Vxc new file mode 100644 index 0000000..238b8e4 --- /dev/null +++ b/sapling_proto/tests/data/op4u8djpMUU5n2q1vuoSa4CApTa2cim3jjyXJD7pJeMQ9mH6Vxc @@ -0,0 +1 @@ +00000000000001f38ba3d31963a0184389fc80ff58e9c3ed968fb6b9e7135ffad68e7fa7a1b8bd1783645ee4125fcfa3e4d02709eb4e712d98c6e8a978746cd8abe77b01503e27989cb22446881b7e1a162e77bc102feee48c8ec16a05794e000b34dc3bfb7033aebc602bba397a919be7de582c273f3f2c9ff6ba4133181cc2d75055ebab5b7fc3182b3b205a27e162bd4902e0316b58915ba451d9a447f76a6fb3bcc72ad460be1548359b049fc0e85edae784d7e0410887278156efe75d1f0f8d592e4b8943db6e74fe8b336736c997ca3ae425f9546486f943595ce273aa9281845a9d04af03b100b04b9e84741632c04a692b9eee4312b1e7b7df8cb5c4b1b802d3632e70a2d92a5ba0cf158da9f3b121d91489b4c5ed541caf09e6ae14faec020b35b33fd60000004f91130da67348b812db9049d6a3a813a1a60ba4c5bc11581fd8f51df38734083cc153bb97b221e2a08cff8c7b9123189373cf031fded69a997e654c972085ef39e806e4b053faa9f57a44d7dfa36e27f540d0eb340562a1bc1b35aabb9521f71659d073e7a3d19aa48c9b6fae73e4a94567dd488ebb2b75142bd207a7aa43730fd216a7f801e84e3b52a08d161faa65daee9447f96492e89cda70e0451065b9b4d1b3665558a3a7a896364662a9eb3ae820bb042fe1e863ae0ebe5000107d8e61203ab10611cdaa04937da046301e457272efd2cbb7d4f76136971f0fddbb9d9247f7a103389436d64b8a7bc7a7750b63a4bf001f67eb820598e6902887f351d123db853c2e477cbe531a44ab47150effffffffff67698069a1f12aea9ef4019a059e69e70d6317c35d936d3ea61181f9fa9fa297fe092f00000000 \ No newline at end of file diff --git a/sapling_proto/tests/data/opDWbJCeqTFayGipzgtczTxdvwVjVFYpC2qAbkvFJLLVcqF6rEx b/sapling_proto/tests/data/opDWbJCeqTFayGipzgtczTxdvwVjVFYpC2qAbkvFJLLVcqF6rEx new file mode 100644 index 0000000..217e325 --- /dev/null +++ b/sapling_proto/tests/data/opDWbJCeqTFayGipzgtczTxdvwVjVFYpC2qAbkvFJLLVcqF6rEx @@ -0,0 +1 @@ +00000160d4778ae11c0c25669486bfd5b3369b94c24e5366bf7ba2de4ca56d0b916e3b3a030700de85725894845556bb4ed68338bd6a9617160def55ffcbe766c59003026744eef0eecc3c58152cc9ac9854f04fbae1fd39b5c9b720d70fbf418f77beba890becc81e5a97867721b48a5302689fafe8f4e944d8639efbd3c58ea47c25adaa63dafe459bbabc584128d99b752abd8cbb8aedfc68c3ccc7674f30cf951ad9e0847d5b331645e9968480de567552d57597bae0d3c71dce6d1b6b20515a7a3e0d9f85fb4f0f5b5a329c9df8c8da2931dfd417056d59b8177d826dbd193f915545f7a7bc71f04460a22128431b9e34e4a396a48fb422b3f2d336ba42209150505fc243ef30f8ee42e3f7b004dba583b02a031e91966c16e90046bb70c3e085434fc55b569a4bad8f766acbbc10b5b18f7dcecd35da64341704afb913a434c99c5cb5dbd95e92fc85100676b02467a2370ed3f416436c4017c0d9fcd53d264401000003e66c85ffeda41d72a44c58e1b77ea8be7f0745fd3096c0be192485b76a8d88f64ca422b6239d5c54b56060c059250e12c44794e65482cbf3cbe4ee987ebd7ecd317e6616990268eabd5a19ab23bb47dec489ebbc9375383c166ab3f16b93303393c54b55b57d358ab43f143b6ae70c9b401cfae580383f986affef7c2ee546f288137ac136a59d3cf387a663fe8017aff4753956333315120c780e62993ea6135be8ed3d393b2beb468dd85ad36665814a8f89e67c56fe1499b8b823709106c24c7d7a28bb3b5727ac123d05f1c5f93ae35b7f2a506e22377a781752fa46aa9d6ffa29c6451145847e28b5170236d72f812c3cb1aaced25379867f28712ecc50225f28f62904a388b1940060ae1b4c373633f05e8fb716d53ce9a67f14ea36d7810000004f4c1f9ba2d73ef093527e4931bd19bb2aba978ae6e680be8a907dd5811f156073b4708b88f13a71455134f692f65825073fd53c694b99bd754705e7371bb66fe76c516bde0c9bba2f4f606359a15e5c1f568ae9569c9beb2427da227ce47670d85b62bf18d3a57d47f4734d3150d0c597ce0d233043d3541f7c1ed735d37c1921aac42597375722d88f4f9c047543f0aac42f26fda1740c788196686318d97d8c6f61c44d0800990e2c639187ecf0d8eaf9191a83ae65510d77562b7a256af37148a43f07e549164d4c8780756dcfafc5262dbcf2c24e4211c5f649f86c9ea1e1e5ba320e0e10d9af0913fea47d8a59954f234a6982500b62780b276a0655d373138d25b3075cdf3ee0e872df5ea904f175a8ea4498a1eee9f29609c00c9cd38595083c7dcb9c8097850af215cc5631611dc1dcf1e7aeb5358a2bb2796ede7598364add4cde7258b033f3b3e41da17d031634e7e35901c0a000f7c643ca821a8252e47fa7d9459cdc565132698bab8433a9b0a0b6db48224a457df6138d040ba5280331ff0537e3eb6672b66b2f817d410c88853703f376d6043e77fb453e2f7a456d65b8959137787e53430a918a178b16a04faceb206cb82572376f2f3aba9f5df595e20ab109d49319e8475ec2c8a862a7611ff93d6d89dfa89c56eddb5b3838ae4a42dcf980860acbd6d9bf47820000004fbb7414b93fc9cf35773445fd6fbcdd5326bde269542d7182e4a2d1bb6d9ce6def451369c5ac9de94c47c9551ef7e5c73c01cdd74ed8ef4b96b9f3a5ba414b3f00db530a7731d85444691d1f914297454ef572c384fdb5af976f9aa0afcbadf86e2fa26496c2196b033f015105f13da004ad9299c36996a0936296139ab2f06ffa2e31abd29176a0e1825da35335dedde56f6dc8dab37811a8d9c39051c7fd678f965a9b6c716c8ae7beaafcc98c72532b27000f70a65a7970169a2e86ceb90edfe77bf9ca616a47f93974ec47c22e56d9c7d6bc526b11a6b4782b63d68ebd747294285eaa665af907ed11e040200ae0dbcef8f83d4163a293acf9e18cac5051f84cb34d94f589abbd12996bd5c050a0000000000000000370084d45a7b912a1e5f4a1646a9f0b7d890a025803aa560eb1a3f0bdf0b2f2b00000000 \ No newline at end of file diff --git a/sapling_proto/tests/tutorial.rs b/sapling_proto/tests/tutorial.rs new file mode 100644 index 0000000..6171a1d --- /dev/null +++ b/sapling_proto/tests/tutorial.rs @@ -0,0 +1,51 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + +use anyhow::Result; +use hex; +use layered_store::EphemeralStore; +use sapling_proto::{ + executor::execute_transaction, + storage::{run_migrations, SaplingStorage}, + //formatter::Formatter, + types::SaplingTransaction, + validator::validate_transaction, +}; + +// https://ghostnet.tzkt.io/KT1PwYL1B8hagFeCcByAcsN3KTQHmJFfDwnj +const SHIELDING_TX1_HEX: &'static str = + include_str!("../tests/data/ong6gzsvydC8zgFn1KAM3HFFVymZbroRKqAH4tt1ejcYBcyvroy"); +const SHIELDING_TX2_HEX: &'static str = + include_str!("../tests/data/op4u8djpMUU5n2q1vuoSa4CApTa2cim3jjyXJD7pJeMQ9mH6Vxc"); +const SAPLING_TX_HEX: &'static str = + include_str!("../tests/data/opDWbJCeqTFayGipzgtczTxdvwVjVFYpC2qAbkvFJLLVcqF6rEx"); +const UNSHIELDING_TX_HEX: &'static str = + include_str!("../tests/data/ooCfUWEY9785vAiGxvCqS74qDyCd8vWPXikuLycHjexwe17ALAb"); +pub const ANTI_REPLAY: &'static str = "KT1PwYL1B8hagFeCcByAcsN3KTQHmJFfDwnjNetXnHfVqm9iesp"; + +#[test] +fn run_tutorial() -> Result<()> { + let mut storage = EphemeralStore::default(); + let head = storage.get_head()?; + run_migrations(&mut storage, &head)?; + + for (_i, tx_hex) in [ + SHIELDING_TX1_HEX, + SHIELDING_TX2_HEX, + SAPLING_TX_HEX, + UNSHIELDING_TX_HEX, + ] + .into_iter() + .enumerate() + { + let payload = hex::decode(tx_hex)?; + let transaction = SaplingTransaction::try_from(payload.as_slice())?; + //println!("Tx {}\n{}\n", i, transaction.to_string()); + + validate_transaction(&mut storage, &transaction, &ANTI_REPLAY.into())?; + execute_transaction(&mut storage, &transaction)?; + } + + Ok(()) +} diff --git a/scripts/codegen_e2e_tests.ipynb b/scripts/codegen_e2e_tests.ipynb index 0da1f4b..d5bffbd 100644 --- a/scripts/codegen_e2e_tests.ipynb +++ b/scripts/codegen_e2e_tests.ipynb @@ -1155,7 +1155,7 @@ "source": [ "header = \"\"\"mod runner;\n", "\n", - "use tezos_vm::Result;\n", + "use michelson_vm::Result;\n", "use runner::e2e::E2E;\n", "\"\"\"\n", "\n", diff --git a/scripts/codegen_tzt_tests.ipynb b/scripts/codegen_tzt_tests.ipynb index ae2e8a1..0167c54 100644 --- a/scripts/codegen_tzt_tests.ipynb +++ b/scripts/codegen_tzt_tests.ipynb @@ -58,7 +58,7 @@ "source": [ "header = \"\"\"mod runner;\n", "\n", - "use tezos_vm::Result;\n", + "use michelson_vm::Result;\n", "use runner::tzt::TZT;\n", "\"\"\"\n", "\n", diff --git a/tezos_ctx/Cargo.toml b/tezos_ctx/Cargo.toml deleted file mode 100644 index 2545166..0000000 --- a/tezos_ctx/Cargo.toml +++ /dev/null @@ -1,17 +0,0 @@ -[package] -name = "tezos_ctx" -version = "0.1.0" -edition = "2021" - -[lib] -crate-type = ["cdylib", "rlib"] - -[dependencies] -tezos_core = { git = "https://github.com/baking-bad/tezos-rust-sdk", branch = "develop", package = "tezos-core", default-features = false } -tezos_rpc = { git = "https://github.com/baking-bad/tezos-rust-sdk", branch = "develop", package = "tezos-rpc", default-features = false } -tezos_michelson = { git = "https://github.com/baking-bad/tezos-rust-sdk", branch = "develop", package = "tezos-michelson", default-features = false } -tezos_operation = { git = "https://github.com/baking-bad/tezos-rust-sdk", branch = "develop", package = "tezos-operation", default-features = false, features = ["ed25519"] } -serde-json-wasm = { git = "https://github.com/CosmWasm/serde-json-wasm", branch = "main" } -serde = { version = "1.0", features = ["derive"] } -derive_more = "0.99" -chrono = { version = "0.4", default-features = false } \ No newline at end of file diff --git a/tezos_ctx/src/context.rs b/tezos_ctx/src/context.rs deleted file mode 100644 index e6b288a..0000000 --- a/tezos_ctx/src/context.rs +++ /dev/null @@ -1,101 +0,0 @@ -pub mod ephemeral; -pub mod executor; -pub mod interpreter; -pub mod viewer; - -use tezos_core::types::{ - encoded::{ContractAddress, PublicKey, ScriptExprHash}, - mutez::Mutez, - number::Nat, -}; -use tezos_michelson::micheline::Micheline; -use tezos_rpc::models::operation::Operation; - -use crate::{BatchReceipt, ContextNode, Head, Result}; - -pub trait GenericContext { - fn log(&self, msg: String); - fn has(&self, key: String) -> Result; - fn get(&mut self, key: String) -> Result>; - fn set(&mut self, key: String, val: Option) -> Result<()>; - fn has_pending_changes(&self) -> bool; - fn commit(&mut self) -> Result<()>; - fn rollback(&mut self); - fn clear(&mut self); -} - -pub trait ExecutorContext { - fn get_head(&mut self) -> Result; - fn set_head(&mut self, head: Head) -> Result<()>; - fn get_balance(&mut self, address: &str) -> Result>; - fn set_balance(&mut self, address: &str, balance: Mutez) -> Result<()>; - fn get_counter(&mut self, address: &str) -> Result; - fn set_counter(&mut self, address: &str, counter: Nat) -> Result<()>; - fn has_public_key(&self, address: &str) -> Result; - fn get_public_key(&mut self, address: &str) -> Result>; - fn set_public_key(&mut self, address: &str, public_key: PublicKey) -> Result<()>; - fn set_contract_code(&mut self, address: &str, code: Micheline) -> Result<()>; - fn get_contract_code(&mut self, address: &str) -> Result>; - fn get_contract_storage(&mut self, address: &str) -> Result>; - fn set_contract_storage(&mut self, address: &str, storage: Micheline) -> Result<()>; - fn set_batch_receipt(&mut self, receipt: BatchReceipt) -> Result<()>; - fn get_batch_receipt(&mut self, hash: &str) -> Result; - fn set_operation_receipt(&mut self, receipt: Operation) -> Result<()>; - fn get_operation_receipt(&mut self, hash: &str) -> Result; - fn check_no_pending_changes(&self) -> Result<()>; -} - -pub trait InterpreterContext { - fn get_contract_type(&mut self, address: &ContractAddress) -> Result>; - fn set_contract_type(&mut self, address: ContractAddress, value: Micheline) -> Result<()>; - fn allocate_big_map(&mut self, owner: ContractAddress) -> Result; - // TODO: transfer_big_map - fn get_big_map_owner(&mut self, ptr: i64) -> Result>; - fn has_big_map_value(&mut self, ptr: i64, key_hash: &ScriptExprHash) -> Result; - fn get_big_map_value( - &mut self, - ptr: i64, - key_hash: &ScriptExprHash, - ) -> Result>; - fn set_big_map_value( - &mut self, - ptr: i64, - key_hash: ScriptExprHash, - value: Option, - ) -> Result<()>; -} - -pub trait ViewerContext {} - -#[macro_export] -macro_rules! context_get_opt { - ($context: expr, $($arg:tt)*) => { - match $context.get(format!($($arg)*)) { - Ok(Some(value)) => Ok(Some(value.try_into()?)), - Ok(None) => Ok(None), - Err(err) => Err(err) - } - }; -} - -#[macro_export] -macro_rules! context_get { - ($context: expr, $default: expr, $($arg:tt)*) => { - match $context.get(format!($($arg)*)) { - Ok(Some(value)) => Ok(value.try_into()?), - Ok(None) => Ok($default), - Err(err) => Err(err) - } - }; -} - -#[macro_export] -macro_rules! context_unwrap { - ($context: expr, $($arg:tt)*) => { - match $context.get(format!($($arg)*)) { - Ok(Some(value)) => Ok(value.try_into()?), - Ok(None) => Err($crate::internal_error!(Store, $($arg)*)), - Err(err) => Err(err) - } - }; -} diff --git a/tezos_ctx/src/context/ephemeral.rs b/tezos_ctx/src/context/ephemeral.rs deleted file mode 100644 index c39eba1..0000000 --- a/tezos_ctx/src/context/ephemeral.rs +++ /dev/null @@ -1,130 +0,0 @@ -use std::collections::HashMap; - -use crate::{ContextNode, GenericContext, Result}; - -pub struct EphemeralContext { - state: HashMap, - pending_state: HashMap>, - modified_keys: Vec, -} - -impl EphemeralContext { - pub fn new() -> Self { - Self { - state: HashMap::new(), - pending_state: HashMap::new(), - modified_keys: Vec::new(), - } - } - - pub fn spawn(&self) -> Self { - Self { - state: self.state.clone(), - pending_state: HashMap::new(), - modified_keys: Vec::new(), - } - } - - pub fn pending_removed(&self, key: &String) -> bool { - match self.pending_state.get(key) { - Some(None) => true, - _ => false, - } - } -} - -impl GenericContext for EphemeralContext { - fn log(&self, msg: String) { - eprintln!("[DEBUG] {}", msg); - } - - fn has(&self, key: String) -> Result { - match self.pending_state.get(&key) { - Some(Some(_)) => Ok(true), - Some(None) => Ok(false), - None => Ok(self.state.contains_key(&key)), - } - } - - fn get(&mut self, key: String) -> Result> { - // self.log(format!("get {}", &key)); - match self.pending_state.get(&key) { - Some(cached_value) => Ok(cached_value.to_owned()), - None => match self.state.get(&key) { - Some(value) => { - self.pending_state.insert(key, Some(value.to_owned())); - Ok(Some(value.to_owned())) - } - None => Ok(None), - }, - } - } - - fn set(&mut self, key: String, val: Option) -> Result<()> { - // self.log(format!("set {} = {:?}", &key, &val)); - self.pending_state.insert(key.clone(), val); - self.modified_keys.push(key); - Ok(()) - } - - fn has_pending_changes(&self) -> bool { - !self.modified_keys.is_empty() - } - - fn commit(&mut self) -> Result<()> { - while !self.modified_keys.is_empty() { - let key = self.modified_keys.remove(0); - let val = self - .pending_state - .get(&key) - .expect("Modified key must be in the pending state"); - - match val { - Some(val) => self.state.insert(key, val.clone()), - None => self.state.remove(&key), - }; - } - Ok(()) - } - - fn rollback(&mut self) { - for key in self.modified_keys.drain(..) { - self.pending_state.remove(&key); - } - } - - fn clear(&mut self) { - self.pending_state.clear(); - self.modified_keys.clear(); - } -} - -#[cfg(test)] -mod test { - use crate::{EphemeralContext, ExecutorContext, GenericContext, Result}; - use tezos_core::types::mutez::Mutez; - - #[test] - fn store_balance() -> Result<()> { - let mut context = EphemeralContext::new(); - - let address = "tz1Mj7RzPmMAqDUNFBn5t5VbXmWW4cSUAdtT"; - let balance: Mutez = 1000u32.into(); - - assert!(context.get_balance(&address)?.is_none()); // both host and cache accessed - - context.set_balance(&address, balance.clone())?; // cached - context.commit()?; // save - context.clear(); // cache cleared - - assert!(context.get_balance(&address)?.is_some()); // cached - assert_eq!( - context - .get_balance(&address)? - .expect("Balance must not be null"), - balance - ); // served from the cache - - Ok(()) - } -} diff --git a/tezos_ctx/src/context/executor.rs b/tezos_ctx/src/context/executor.rs deleted file mode 100644 index 437bc2b..0000000 --- a/tezos_ctx/src/context/executor.rs +++ /dev/null @@ -1,117 +0,0 @@ -use tezos_core::types::{ - encoded::{Encoded, PublicKey}, - mutez::Mutez, - number::Nat, -}; -use tezos_michelson::micheline::Micheline; -use tezos_rpc::models::operation::Operation; - -use crate::{ - context_get, context_get_opt, context_unwrap, BatchReceipt, Error, ExecutorContext, - GenericContext, Head, Result, -}; - -impl ExecutorContext for T { - fn get_head(&mut self) -> Result { - context_get!(self, Head::default(), "/head") - } - - fn set_head(&mut self, head: Head) -> Result<()> { - self.set("/head".into(), Some(head.into()))?; - Ok(()) - } - - fn get_balance(&mut self, address: &str) -> Result> { - context_get_opt!(self, "/context/contracts/{}/balance", address) - } - - fn set_balance(&mut self, address: &str, balance: Mutez) -> Result<()> { - return self.set( - format!("/context/contracts/{}/balance", address), - Some(balance.into()), - ); - } - - fn get_counter(&mut self, address: &str) -> Result { - context_get!(self, 0u32.into(), "/context/contracts/{}/counter", address) - } - - fn set_counter(&mut self, address: &str, counter: Nat) -> Result<()> { - return self.set( - format!("/context/contracts/{}/counter", address), - Some(counter.into()), - ); - } - - fn get_public_key(&mut self, address: &str) -> Result> { - context_get_opt!(self, "/context/contracts/{}/pubkey", address) - } - - fn set_public_key(&mut self, address: &str, public_key: PublicKey) -> Result<()> { - // NOTE: Underscores are not allowed in path (host restriction) - return self.set( - format!("/context/contracts/{}/pubkey", address), - Some(public_key.into()), - ); - } - - fn has_public_key(&self, address: &str) -> Result { - return self.has(format!("/context/contracts/{}/pubkey", address)); - } - - fn set_batch_receipt(&mut self, receipt: BatchReceipt) -> Result<()> { - self.set( - format!("/batches/{}", receipt.hash.value()).into(), - Some(receipt.into()), - ) - } - - fn get_batch_receipt(&mut self, hash: &str) -> Result { - context_unwrap!(self, "/batches/{}", hash) - } - - fn set_operation_receipt(&mut self, receipt: Operation) -> Result<()> { - self.set( - format!( - "/operations/{}", - receipt.hash.as_ref().expect("Operation hash").value() - ), - Some(receipt.into()), - ) - } - - fn get_operation_receipt(&mut self, hash: &str) -> Result { - context_unwrap!(self, "/operations/{}", hash) - } - - fn get_contract_code(&mut self, address: &str) -> Result> { - context_get_opt!(self, "/context/contracts/{}/code", address) - } - - fn set_contract_code(&mut self, address: &str, code: Micheline) -> Result<()> { - // TODO: support splitting into chunks (generic read/write loop) - self.set( - format!("/context/contracts/{}/code", address), - Some(code.into()), - ) - } - - fn get_contract_storage(&mut self, address: &str) -> Result> { - context_get_opt!(self, "/context/contracts/{}/storage", address) - } - - fn set_contract_storage(&mut self, address: &str, storage: Micheline) -> Result<()> { - self.set( - format!("/context/contracts/{}/storage", address), - Some(storage.into()), - ) - } - - fn check_no_pending_changes(&self) -> Result<()> { - if self.has_pending_changes() { - Err(Error::ContextUnstagedError) - } else { - Ok(()) - } - } -} diff --git a/tezos_ctx/src/context/viewer.rs b/tezos_ctx/src/context/viewer.rs deleted file mode 100644 index b05c4d0..0000000 --- a/tezos_ctx/src/context/viewer.rs +++ /dev/null @@ -1,3 +0,0 @@ -use crate::{GenericContext, ViewerContext}; - -impl ViewerContext for T {} diff --git a/tezos_ctx/src/lib.rs b/tezos_ctx/src/lib.rs deleted file mode 100644 index 12e0be9..0000000 --- a/tezos_ctx/src/lib.rs +++ /dev/null @@ -1,16 +0,0 @@ -pub mod context; -pub mod error; -pub mod migrations; -pub mod types; - -pub use crate::{ - context::{ - ephemeral::EphemeralContext, ExecutorContext, GenericContext, InterpreterContext, - ViewerContext, - }, - error::{Error, Result}, - types::batch::{BatchHeader, BatchReceipt}, - types::config::Config, - types::head::Head, - types::node::ContextNode, -}; diff --git a/tezos_ctx/src/types/mod.rs b/tezos_ctx/src/types/mod.rs deleted file mode 100644 index ce1cadf..0000000 --- a/tezos_ctx/src/types/mod.rs +++ /dev/null @@ -1,4 +0,0 @@ -pub mod batch; -pub mod config; -pub mod head; -pub mod node; diff --git a/tezos_ctx/src/types/node.rs b/tezos_ctx/src/types/node.rs deleted file mode 100644 index b086de2..0000000 --- a/tezos_ctx/src/types/node.rs +++ /dev/null @@ -1,141 +0,0 @@ -use derive_more::{From, TryInto}; -use tezos_core::types::{ - encoded::{ContractAddress, Encoded, OperationHash, PublicKey}, - mutez::Mutez, - number::Nat, -}; -use tezos_michelson::micheline::Micheline; -use tezos_rpc::models::operation::Operation; - -use crate::{internal_error, BatchReceipt, Head, Result}; - -#[derive(Debug, Clone, From, TryInto)] -pub enum ContextNode { - Head(Head), - Int(i64), - Operation(Operation), - Batch(BatchReceipt), - PublicKey(PublicKey), - OperationHash(OperationHash), - ContractAddress(ContractAddress), - Micheline(Micheline), - Nat(Nat), - Mutez(Mutez), -} - -impl ContextNode { - pub fn to_vec(&self) -> Result> { - let (prefix, payload) = match self { - Self::Head(value) => (b'\x01', value.encode()?), - Self::Int(value) => (b'\x02', value.encode()?), - Self::Operation(value) => (b'\x03', value.encode()?), - Self::Batch(value) => (b'\x04', value.encode()?), - Self::PublicKey(value) => (b'\x05', value.encode()?), - Self::OperationHash(value) => (b'\x06', value.encode()?), - Self::ContractAddress(value) => (b'\x07', value.encode()?), - Self::Micheline(value) => (b'\x08', value.encode()?), - Self::Nat(value) => (b'\x09', value.encode()?), - Self::Mutez(value) => (b'\x0A', value.encode()?), - }; - Ok([vec![prefix], payload].concat()) - } - - pub fn from_vec(value: Vec) -> Result { - match value.as_slice() { - [b'\x01', bytes @ ..] => Head::decode(bytes), - [b'\x02', bytes @ ..] => i64::decode(bytes), - [b'\x03', bytes @ ..] => Operation::decode(bytes), - [b'\x04', bytes @ ..] => BatchReceipt::decode(bytes), - [b'\x05', bytes @ ..] => PublicKey::decode(bytes), - [b'\x06', bytes @ ..] => OperationHash::decode(bytes), - [b'\x07', bytes @ ..] => ContractAddress::decode(bytes), - [b'\x08', bytes @ ..] => Micheline::decode(bytes), - [b'\x09', bytes @ ..] => Nat::decode(bytes), - [b'\x0A', bytes @ ..] => Mutez::decode(bytes), - _ => Err(internal_error!(Encoding, "Invalid context node prefix")), - } - } -} - -pub trait ContextNodeType: Clone { - fn encode(&self) -> Result>; - fn decode(bytes: &[u8]) -> Result; -} - -macro_rules! context_node_type_core { - ($ty: ty) => { - impl ContextNodeType for $ty { - fn decode(bytes: &[u8]) -> Result { - match Self::from_bytes(bytes) { - Ok(value) => Ok(value.into()), - Err(error) => Err(error.into()), - } - } - - fn encode(&self) -> Result> { - self.to_bytes().map_err(|e| e.into()) - } - } - }; -} - -context_node_type_core!(PublicKey); -context_node_type_core!(OperationHash); -context_node_type_core!(ContractAddress); -context_node_type_core!(Micheline); -context_node_type_core!(Mutez); -context_node_type_core!(Nat); - -macro_rules! context_node_type_rpc { - ($ty: ty) => { - impl ContextNodeType for $ty { - fn decode(_bytes: &[u8]) -> Result { - #[cfg(not(target_arch = "wasm32"))] - { - // This is a workaround to avoid floating point operations introduced by serde. - // Since we do not need RPC models deserialization inside the kernel, - // we can only enable that for tests and binaries that are not compiled to wasm. - let value: $ty = serde_json_wasm::de::from_slice(_bytes)?; - return Ok(value.into()); - } - #[cfg(target_arch = "wasm32")] - unimplemented!() - } - - fn encode(&self) -> Result> { - Ok(serde_json_wasm::ser::to_vec(self)?) - } - } - }; -} - -context_node_type_rpc!(Operation); -context_node_type_rpc!(BatchReceipt); - -impl ContextNodeType for i64 { - fn decode(bytes: &[u8]) -> Result { - if bytes.len() == 8 { - let value = i64::from_be_bytes([ - bytes[0], bytes[1], bytes[2], bytes[3], bytes[4], bytes[5], bytes[6], bytes[7], - ]); - Ok(value.into()) - } else { - Err(internal_error!(Encoding, "")) - } - } - - fn encode(&self) -> Result> { - Ok(self.to_be_bytes().to_vec()) - } -} - -impl ContextNodeType for Head { - fn decode(bytes: &[u8]) -> Result { - let value: Head = serde_json_wasm::de::from_slice(bytes)?; - Ok(value.into()) - } - - fn encode(&self) -> Result> { - Ok(serde_json_wasm::ser::to_vec(self)?) - } -} diff --git a/tezos_kernel/Cargo.toml b/tezos_kernel/Cargo.toml new file mode 100644 index 0000000..4ea0ffe --- /dev/null +++ b/tezos_kernel/Cargo.toml @@ -0,0 +1,29 @@ +# SPDX-FileCopyrightText: 2023 Baking Bad +# +# SPDX-License-Identifier: MIT + +[package] +name = "tezos_kernel" +version = "0.1.0" +edition = "2021" + +[lib] +crate-type = ["cdylib", "rlib"] + +[dependencies] +derive_more = "0.99" +kernel_io = { path = "../kernel_io" } +tezos_proto = { path = "../tezos_proto" } +tezos_core = { git = "https://github.com/baking-bad/tezos-rust-sdk", branch = "develop", package = "tezos-core", default-features = false } +tezos_operation = { git = "https://github.com/baking-bad/tezos-rust-sdk", branch = "develop", package = "tezos-operation", default-features = false } +tezos-smart-rollup-host = { version = "0.2.0", features = ["proto-nairobi"], default-features = false } +# TODO: feature enable "panic-hook-abort" +tezos-smart-rollup-entrypoint = { version = "0.2.0", features = ["panic-hook", "std", "panic-hook-debug"], default-features = false } +tezos-smart-rollup-core = { version = "0.2.0", default-features = false } + +[dev-dependencies] +tezos_data_encoding = { version = "0.5" } +tezos-smart-rollup = { version = "0.2.0", features = ["proto-nairobi", "panic-hook", "crypto"] } +tezos-smart-rollup-mock = { version = "0.2.0", features = ["proto-nairobi"] } +tezos_rpc = { git = "https://github.com/baking-bad/tezos-rust-sdk", branch = "develop", package = "tezos-rpc", default-features = false } +hex = "*" \ No newline at end of file diff --git a/tezos_kernel/README.md b/tezos_kernel/README.md new file mode 100644 index 0000000..aef829a --- /dev/null +++ b/tezos_kernel/README.md @@ -0,0 +1,5 @@ +# Tezos kernel + +Smart rollup kernel implementing Tezos-compatible protocol. + +Currently can handle external inbox messages with L2 operations encoded. diff --git a/kernel/src/error.rs b/tezos_kernel/src/error.rs similarity index 53% rename from kernel/src/error.rs rename to tezos_kernel/src/error.rs index e1ab8f4..3959c99 100644 --- a/kernel/src/error.rs +++ b/tezos_kernel/src/error.rs @@ -1,25 +1,19 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + use derive_more::{Display, Error}; use std::backtrace::Backtrace; -use tezos_l2::error::{Error as TezosProtoError, TezosCoreError, TezosOperationError}; - -#[derive(Debug, Display)] -pub enum InternalKind { - WasmHost, - TezosEncoding, - TezosProtocol, -} #[derive(Debug)] pub struct InternalError { - pub kind: InternalKind, pub message: String, pub backtrace: Backtrace, } impl InternalError { - pub fn new(kind: InternalKind, message: String) -> Self { + pub fn new(message: String) -> Self { Self { - kind, message, backtrace: Backtrace::capture(), } @@ -27,8 +21,8 @@ impl InternalError { pub fn format(&self) -> String { format!( - "{} error\n{}\nStacktrace:\n{}", - self.kind, self.message, self.backtrace + "Kernel internal error\n{}\nStacktrace:\n{}", + self.message, self.backtrace ) } } @@ -36,8 +30,7 @@ impl InternalError { impl std::fmt::Display for InternalError { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { f.write_fmt(format_args!( - "{} error, {}", - self.kind, + "Kernel internal error, {}", self.message.replace("\n", " ") )) } @@ -52,16 +45,10 @@ impl std::error::Error for InternalError { #[derive(Debug, Display, Error)] pub enum Error { Internal(InternalError), - #[display(fmt = "UnexpectedL2OperationPrefix")] - UnexpectedL2OperationPrefix, #[display(fmt = "UnexpectedL2OperationLength")] UnexpectedL2OperationLength { length: usize, }, - #[display(fmt = "UnexpectedLevelInfoLength")] - UnexpectedLevelInfoLength { - length: usize, - }, #[display(fmt = "InconsistentHeadLevel")] InconsistentHeadLevel { expected: i32, @@ -73,34 +60,31 @@ pub type Result = std::result::Result; #[macro_export] macro_rules! internal_error { - ($kind: ident, $($arg:tt)*) => { + ($($arg:tt)*) => { $crate::Error::Internal( - $crate::error::InternalError::new( - $crate::error::InternalKind::$kind, - format!($($arg)*) - ) + $crate::error::InternalError::new(format!($($arg)*)) ) }; } macro_rules! impl_from_error { - ($inner_err_ty: ty, $kind: ident) => { + ($inner_err_ty: ty) => { impl From<$inner_err_ty> for Error { fn from(error: $inner_err_ty) -> Self { - $crate::internal_error!($kind, "Caused by: {:?}", error) + $crate::internal_error!("Caused by: {:?}", error) } } }; } -impl_from_error!(TezosCoreError, TezosEncoding); -impl_from_error!(TezosOperationError, TezosEncoding); -impl_from_error!(host::runtime::RuntimeError, WasmHost); -impl_from_error!(host::path::PathError, WasmHost); +impl_from_error!(tezos_operation::Error); +impl_from_error!(tezos_core::Error); +impl_from_error!(tezos_smart_rollup_host::runtime::RuntimeError); +impl_from_error!(tezos_smart_rollup_host::path::PathError); -impl From for Error { - fn from(error: TezosProtoError) -> Self { - internal_error!(TezosProtocol, "Caused by: {}", error) +impl From for Error { + fn from(error: tezos_proto::Error) -> Self { + internal_error!("Caused by: {}", error) } } diff --git a/kernel/src/kernel.rs b/tezos_kernel/src/kernel.rs similarity index 59% rename from kernel/src/kernel.rs rename to tezos_kernel/src/kernel.rs index 996cb04..98cb786 100644 --- a/kernel/src/kernel.rs +++ b/tezos_kernel/src/kernel.rs @@ -1,17 +1,23 @@ -use host::{rollup_core::RawRollupCore, runtime::Runtime}; -use tezos_core::types::encoded::{ChainId, Encoded, OperationHash}; -use tezos_ctx::{ExecutorContext, GenericContext}; -use tezos_l2::batcher::apply_batch; -use tezos_operation::operations::SignedOperation; +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT -use crate::{ - context::PVMContext, +use kernel_io::{ inbox::{read_inbox, InboxMessage}, - Error, Result, + KernelStore, KernelStoreAsHost, }; +use tezos_core::types::encoded::{ChainId, Encoded, OperationHash}; +use tezos_operation::operations::SignedOperation; +use tezos_proto::{batcher::apply_batch, context::TezosContext}; +use tezos_smart_rollup_core::SmartRollupCore; +use tezos_smart_rollup_host::runtime::Runtime; -pub fn kernel_run(context: &mut PVMContext) { - let metadata = Runtime::reveal_metadata(context.as_mut()).expect("Failed to reveal metadata"); +use crate::{payload::TezosPayload, Error, Result}; + +pub fn kernel_run(host: &mut Host) { + let mut context = KernelStore::attach(host); + + let metadata = Runtime::reveal_metadata(context.as_host()); let mut head = context.get_head().expect("Failed to get head"); head.chain_id = ChainId::from_bytes(&metadata.raw_rollup_address[..4]).expect("Failed to decode chain ID"); @@ -20,12 +26,12 @@ pub fn kernel_run(context: &mut PVMContext) { let mut batch_payload: Vec<(OperationHash, SignedOperation)> = Vec::new(); let res: Result<()> = loop { - match read_inbox(context.as_mut(), &metadata.raw_rollup_address[..4]) { + match read_inbox(context.as_host(), &metadata.raw_rollup_address[..4]) { Ok(InboxMessage::BeginBlock(inbox_level)) => { // Origination level is the one before kernel is first time invoked // We assume single rollup block per inbox block here // Note that head level is the one prior to the current block - let expected = inbox_level - metadata.origination_level - 2; + let expected = inbox_level - metadata.origination_level as i32 - 2; if head.level != expected { break Err(Error::InconsistentHeadLevel { expected, @@ -35,17 +41,13 @@ pub fn kernel_run(context: &mut PVMContext) { } Ok(InboxMessage::LevelInfo(info)) => { head.timestamp = info.predecessor_timestamp; - context.log(format!( - "L1 predecessor block: {}", - info.predecessor.value() - )) } - Ok(InboxMessage::L2Operation { hash, opg }) => { + Ok(InboxMessage::Payload(TezosPayload::Operation { hash, opg })) => { context.log(format!("Operation pending: {}", &hash.value())); batch_payload.push((hash, opg)); } Ok(InboxMessage::EndBlock(_)) => { - match apply_batch(context, head.clone(), batch_payload, false) { + match apply_batch(&mut context, head.clone(), batch_payload, false) { Ok(new_head) => { head = new_head; context.log(format!("Batch applied: {}", head)); @@ -55,6 +57,7 @@ pub fn kernel_run(context: &mut PVMContext) { } } Ok(InboxMessage::NoMoreData) => break Ok(()), + Ok(InboxMessage::Foreign(id)) => context.log(format!("Foreign message #{}", id)), Ok(InboxMessage::Unknown(id)) => context.log(format!("Unknown message #{}", id)), Err(err) => context.log(err.to_string()), } @@ -62,7 +65,10 @@ pub fn kernel_run(context: &mut PVMContext) { match res { Ok(_) => { - context.persist().expect("Failed to persist changes"); + context + .as_mut() + .persist() + .expect("Failed to persist changes"); context.log(format!("Kernel yields")); } Err(err) => { @@ -74,45 +80,53 @@ pub fn kernel_run(context: &mut PVMContext) { #[cfg(test)] mod test { + use std::io::Write; + use super::*; - use crate::context::PVMContext; use hex; - use host::rollup_core::Input; - use mock_runtime::host::MockHost; - use tezos_ctx::{ExecutorContext, Result}; + use kernel_io::{KernelStore, KernelStoreAsHost}; + use tezos_data_encoding::enc::{BinResult, BinWriter}; + use tezos_proto::context::TezosContext; + use tezos_smart_rollup_mock::MockHost; + + struct ExternalMessage(Vec); + + impl ExternalMessage { + pub fn from_hex(value: &str) -> Self { + Self(hex::decode(value).unwrap()) + } + } + + impl BinWriter for ExternalMessage { + fn bin_write(&self, output: &mut Vec) -> BinResult { + match output.write(self.0.as_slice()) { + Ok(_) => BinResult::Ok(()), + Err(err) => BinResult::Err(err.into()), + } + } + } #[test] fn send_tez() -> Result<()> { - let mut context = PVMContext::new(MockHost::default()); - // default rollup address is sr1V6huFSUBUujzubUCg9nNXqpzfG9t4XD1h - // chain_id is first 4 bytes (fceda8e6) - // 01 is inbox prefix for external messages + let mut host = MockHost::default(); + let mut context = KernelStore::::attach(&mut host); + // default rollup address is sr163Lv22CdE8QagCwf48PWDTquk6isQwv57Head + // chain_id is first 4 bytes (00000000) // the rest is the operation payload - let input = hex::decode( - "01fceda8e662fd30ac16979d9b88aca559e8fd8b97abd2519bebe09ad8a269d60df0b17ddc6b\ + let message = ExternalMessage::from_hex( + "0000000062fd30ac16979d9b88aca559e8fd8b97abd2519bebe09ad8a269d60df0b17ddc6b\ 00e8b36c80efb51ec85a14562426049aa182a3ce38f902e18a18e807000017143f62ff9c2f41b30ee00b8c64d233fda43adf05\ eb829cfd2e733ee9a8f44b6c00e8b36c80efb51ec85a14562426049aa182a3ce3800e28a18ab0b8102c0843d00006b82198cb1\ 79e8306c1bedd08f12dc863f32888600b2014573fd63d27895841ea6ca9d45e23e1e3b836298801b5e390b3b0a0b412003af89\ c08e63b6d8cf6847300e627c4ce0882ce4e2b842295309de3a0bd6260f", - ) - .unwrap(); - let level = 1; - context.as_mut().as_mut().set_ready_for_input(level); - context.as_mut().as_mut().add_next_inputs( - level, - vec![ - (Input::MessageData, b"\x00\x01".to_vec()), - (Input::MessageData, input), - (Input::MessageData, b"\x00\x02".to_vec()), - ] - .iter(), ); - kernel_run(&mut context); + context.as_host().run_level(|_| {}); // Add StartOfLevel & InfoPerLevel + context.as_host().add_external(message); + context.as_host().run_level(kernel_run); let head = context.get_head()?; - println!("{:?}", head); assert_eq!(0, head.level); assert_eq!(1, head.operations.len()); diff --git a/tezos_kernel/src/lib.rs b/tezos_kernel/src/lib.rs new file mode 100644 index 0000000..71a84be --- /dev/null +++ b/tezos_kernel/src/lib.rs @@ -0,0 +1,11 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + +pub mod error; +pub mod kernel; +pub mod payload; + +pub use error::{Error, Result}; + +tezos_smart_rollup_entrypoint::kernel_entry!(crate::kernel::kernel_run); diff --git a/tezos_kernel/src/payload.rs b/tezos_kernel/src/payload.rs new file mode 100644 index 0000000..40ff25c --- /dev/null +++ b/tezos_kernel/src/payload.rs @@ -0,0 +1,40 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + +use kernel_io::{error::err_into, inbox::PayloadType}; +use tezos_core::types::encoded::{Encoded, OperationHash, Signature}; +use tezos_operation::operations::{SignedOperation, UnsignedOperation}; + +use crate::error::{Error, Result}; + +const SIGNATURE_SIZE: usize = 64; + +pub fn parse_l2_operation<'a>(bytes: &'a [u8]) -> Result<(OperationHash, SignedOperation)> { + if bytes.len() <= SIGNATURE_SIZE { + return Err(Error::UnexpectedL2OperationLength { + length: bytes.len(), + }); + } + + let unsigned_op = UnsignedOperation::from_forged_bytes(&bytes[..bytes.len() - SIGNATURE_SIZE])?; + let signature = Signature::from_bytes(&bytes[bytes.len() - SIGNATURE_SIZE..])?; + let hash = SignedOperation::operation_hash(bytes)?; + let opg = SignedOperation::from(unsigned_op, signature); + + Ok((hash, opg)) +} + +pub enum TezosPayload { + Operation { + hash: OperationHash, + opg: SignedOperation, + }, +} + +impl PayloadType for TezosPayload { + fn from_external_message(message: &[u8]) -> kernel_io::Result { + let (hash, opg) = parse_l2_operation(message).map_err(err_into)?; + Ok(TezosPayload::Operation { hash, opg }) + } +} diff --git a/tezos_l2/src/error.rs b/tezos_l2/src/error.rs deleted file mode 100644 index 7dd42bd..0000000 --- a/tezos_l2/src/error.rs +++ /dev/null @@ -1,130 +0,0 @@ -use derive_more::{Display, Error}; -use std::backtrace::Backtrace; -use tezos_core::types::mutez::Mutez; - -pub use chrono::ParseError as TimestampParsingError; -pub use ibig::error::OutOfBoundsError as BigIntOutOfBoundsError; -pub use ibig::error::ParseError as BigIntParsingError; -pub use serde_json_wasm::de::Error as DeserializationError; -pub use serde_json_wasm::ser::Error as SerializationError; -pub use tezos_core::Error as TezosCoreError; -pub use tezos_ctx::Error as ContextError; -pub use tezos_michelson::Error as TezosMichelsonError; -pub use tezos_operation::Error as TezosOperationError; -pub use tezos_rpc::Error as TezosRpcError; -pub use tezos_vm::Error as InterpreterError; - -#[derive(Debug, Display)] -pub enum InternalKind { - Context, - Encoding, - Interpreter, - TezosEncoding, -} - -#[derive(Debug)] -pub struct InternalError { - pub kind: InternalKind, - pub message: String, - pub backtrace: Backtrace, -} - -impl InternalError { - pub fn new(kind: InternalKind, message: String) -> Self { - Self { - kind, - message, - backtrace: Backtrace::capture(), - } - } - - pub fn format(&self) -> String { - format!( - "{} error\n{}\nStacktrace:\n{}", - self.kind, self.message, self.backtrace - ) - } -} - -impl std::fmt::Display for InternalError { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - f.write_fmt(format_args!( - "{} error, {}", - self.kind, - self.message.replace("\n", " ") - )) - } -} - -impl std::error::Error for InternalError { - fn description(&self) -> &str { - &self.message - } -} - -#[derive(Debug, Display, Error)] -pub enum Error { - Internal(InternalError), - OperationKindUnsupported, - BalanceNotInitialized, - BalanceTooLow { balance: Mutez }, - ContractCodeMissing { address: String }, - ContractStorageMissing { address: String }, - InconsistentSources, - ContentsListError, - UnrevealedPublicKey, - InvalidSignature, - EmptyImplicitContract, - CounterInThePast { counter: String }, -} - -pub type Result = std::result::Result; - -#[macro_export] -macro_rules! internal_error { - ($kind: ident, $($arg:tt)*) => { - $crate::Error::Internal( - $crate::error::InternalError::new( - $crate::error::InternalKind::$kind, - format!($($arg)*) - ) - ) - }; -} - -macro_rules! impl_from_error { - ($inner_err_ty: ty, $kind: ident) => { - impl From<$inner_err_ty> for Error { - fn from(error: $inner_err_ty) -> Self { - $crate::internal_error!($kind, "{:?}", error) - } - } - }; -} - -impl_from_error!(ContextError, Context); -impl_from_error!(TezosRpcError, TezosEncoding); -impl_from_error!(TezosCoreError, TezosEncoding); -impl_from_error!(TezosOperationError, TezosEncoding); -impl_from_error!(TezosMichelsonError, TezosEncoding); -impl_from_error!(SerializationError, Encoding); -impl_from_error!(DeserializationError, Encoding); -impl_from_error!(BigIntOutOfBoundsError, Encoding); -impl_from_error!(BigIntParsingError, Encoding); -impl_from_error!(TimestampParsingError, Encoding); -impl_from_error!(&str, Encoding); - -impl From for Error { - fn from(error: InterpreterError) -> Self { - internal_error!(Interpreter, "Caused by: {}", error) - } -} - -impl Error { - pub fn format(&self) -> String { - match self { - Self::Internal(internal) => internal.format(), - err => format!("{:#?}", err), - } - } -} diff --git a/tezos_l2/src/lib.rs b/tezos_l2/src/lib.rs deleted file mode 100644 index c1e6fdd..0000000 --- a/tezos_l2/src/lib.rs +++ /dev/null @@ -1,11 +0,0 @@ -pub mod batcher; -pub mod error; -pub mod executor; -pub mod validator; - -pub use error::{Error, Result}; - -pub mod constants { - pub const PROTOCOL: &str = "ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK"; - pub const BLOCK_TIME: i64 = 8; -} diff --git a/tezos_l2/src/validator/mod.rs b/tezos_l2/src/validator/mod.rs deleted file mode 100644 index 694b185..0000000 --- a/tezos_l2/src/validator/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub mod batch; -pub mod operation; diff --git a/tezos_l2/tests/runner/mod.rs b/tezos_l2/tests/runner/mod.rs deleted file mode 100644 index 48ca136..0000000 --- a/tezos_l2/tests/runner/mod.rs +++ /dev/null @@ -1,4 +0,0 @@ -#![allow(dead_code)] - -pub mod client; -pub mod mock; diff --git a/tezos_node/Cargo.toml b/tezos_node/Cargo.toml index 181b09c..ace69e3 100644 --- a/tezos_node/Cargo.toml +++ b/tezos_node/Cargo.toml @@ -1,3 +1,7 @@ +# SPDX-FileCopyrightText: 2023 Baking Bad +# +# SPDX-License-Identifier: MIT + [package] name = "tezos_node" version = "0.1.0" @@ -22,9 +26,9 @@ env_logger = "0.10.0" hex = "*" derive_more = "0.99" serde_json = "*" -tezos_ctx = { path = "../tezos_ctx" } -tezos_l2 = { path = "../tezos_l2" } -tezos_vm = { path = "../tezos_vm" } +layered_store = { path = "../layered_store", default-features = false, features = ["tezos"] } +tezos_proto = { path = "../tezos_proto" } +michelson_vm = { path = "../michelson_vm" } tezos_rpc = { git = "https://github.com/baking-bad/tezos-rust-sdk", branch = "develop", package = "tezos-rpc", default-features = false } tezos_core = { git = "https://github.com/baking-bad/tezos-rust-sdk", branch = "develop", package = "tezos-core", default-features = false, features = ["ed25519"] } tezos_operation = { git = "https://github.com/baking-bad/tezos-rust-sdk", branch = "develop", package = "tezos-operation", default-features = false, features = ["ed25519"] } diff --git a/tezos_node/README.md b/tezos_node/README.md new file mode 100644 index 0000000..bb362f8 --- /dev/null +++ b/tezos_node/README.md @@ -0,0 +1,51 @@ +# Tezos node + +This is a facade node for Tezos smart rollup enabling compatibility at the RPC level. + +## Supported endpoints + +``` +/version +/chains/main/chain_id +/chains/main/is_bootstrapped +/chains/main/mempool/pending_operations +/injection/operation +/chains/main/blocks/{block_id}/helpers/forge/operations +/chains/main/blocks/{block_id}/helpers/preapply/operations +/chains/main/blocks/{block_id}/hash +/chains/main/blocks/{block_id}/header +/chains/main/blocks/{block_id}/metadata +/chains/main/blocks/{block_id}/protocols +/chains/main/blocks/{block_id}/live_blocks +/chains/main/blocks/{block_id} +/chains/main/blocks/{block_id}/context/delegates +/chains/main/blocks/{block_id}/context/delegates/{delegate_id} +/chains/main/blocks/{block_id}/context/constants +/chains/main/blocks/{block_id}/context/big_maps/{big_map_id}/{key_hash} +/chains/main/blocks/{block_id}/context/big_maps/{big_map_id}/{key_hash}/normalized +/chains/main/blocks/{block_id}/context/contracts/{contract_id}/manager_key +/chains/main/blocks/{block_id}/context/contracts/{contract_id}/balance +/chains/main/blocks/{block_id}/context/contracts/{contract_id}/counter +/chains/main/blocks/{block_id}/context/contracts/{contract_id}/delegate +/chains/main/blocks/{block_id}/context/contracts/{contract_id}/storage +/chains/main/blocks/{block_id}/context/contracts/{contract_id}/script +/chains/main/blocks/{block_id}/context/contracts/{contract_id}/script/normalized +/chains/main/blocks/{block_id}/context/contracts/{contract_id}/entrypoints +/chains/main/blocks/{block_id}/context/contracts/{contract_id} +/chains/main/blocks/{block_id}/operations/{pass}/{index} +/chains/main/blocks/{block_id}/operations/{pass} +/chains/main/blocks/{block_id}/operations +/chains/main/blocks/{block_id}/operation_hashes/{pass}/{index} +/chains/main/blocks/{block_id}/operation_hashes/{pass} +/chains/main/blocks/{block_id}/operation_hashes +``` + +## Mockup mode + +Run `mock-node` (no arguments) binary to spin up a stateless facade node with Tezos protocol initialized: it can be used to run e2e test scenarios or for other purposes. + +## Sequencer + +Currently facade node routes injection queries through the rollup node: 1 injected operation — 1 external inbox message. +In order to increase the throughput and overcome the limitations (max inbox message size, single manager L1 operation per block) we will integrate DAC* (and eventually DAL**) solution. +In order to decrease latency we will switch to the optimistic sequencer node provided by the Kernel SDK. \ No newline at end of file diff --git a/tezos_node/src/error.rs b/tezos_node/src/error.rs index 2f7bd3e..f352c2b 100644 --- a/tezos_node/src/error.rs +++ b/tezos_node/src/error.rs @@ -1,3 +1,7 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + use actix_web::{error::ResponseError, http::StatusCode, HttpResponse}; use derive_more::{Display, Error}; use std::backtrace::Backtrace; @@ -97,7 +101,7 @@ impl_from_error!(tezos_rpc::Error, TezosRpc); impl_from_error!(tezos_core::Error, TezosCore); impl_from_error!(tezos_operation::Error, TezosOperation); impl_from_error!(tezos_michelson::Error, TezosMichelson); -impl_from_error!(tezos_l2::Error, TezosProtocol); +impl_from_error!(tezos_proto::Error, TezosProtocol); impl_from_error!(std::num::ParseIntError, StdNum); impl_from_error!(std::num::TryFromIntError, StdNum); impl_from_error!(serde_json::Error, SerdeJson); @@ -108,14 +112,14 @@ impl_from_error!(reqwest::Error, Reqwest); impl_from_error!(ibig::error::ParseError, IBig); impl_from_error!(actix_web::rt::task::JoinError, Actix); -impl From for Error { - fn from(error: tezos_ctx::Error) -> Self { +impl From for Error { + fn from(error: layered_store::Error) -> Self { internal_error!(Context, "Caused by: {}", error.format()) } } -impl From for Error { - fn from(error: tezos_vm::Error) -> Self { +impl From for Error { + fn from(error: michelson_vm::Error) -> Self { internal_error!(Context, "Caused by: {}", error.format()) } } diff --git a/tezos_node/src/lib.rs b/tezos_node/src/lib.rs index c4d9090..214a11d 100644 --- a/tezos_node/src/lib.rs +++ b/tezos_node/src/lib.rs @@ -1,3 +1,7 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + pub mod error; pub mod rollup; pub mod services; diff --git a/tezos_node/src/main.rs b/tezos_node/src/main.rs index df3e034..2298b3a 100644 --- a/tezos_node/src/main.rs +++ b/tezos_node/src/main.rs @@ -1,3 +1,7 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + use actix_web::web::Data; use clap::Parser; use tezos_node::{launch_node, rollup::rpc_client::RollupRpcClient, rollup::RollupClient}; diff --git a/tezos_node/src/mock.rs b/tezos_node/src/mock.rs index 38f449b..b35d2a0 100644 --- a/tezos_node/src/mock.rs +++ b/tezos_node/src/mock.rs @@ -1,3 +1,7 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + use actix_web::web::Data; use std::time::Duration; use tezos_node::{launch_node, rollup::mock_client::RollupMockClient, rollup::RollupClient}; diff --git a/tezos_node/src/rollup.rs b/tezos_node/src/rollup.rs index 21e4e5f..a6b0d2d 100644 --- a/tezos_node/src/rollup.rs +++ b/tezos_node/src/rollup.rs @@ -1,20 +1,25 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + pub mod block_id; pub mod facade; pub mod mock_client; +pub mod rpc_backend; pub mod rpc_client; -pub mod rpc_context; pub mod rpc_helpers; use async_trait::async_trait; +use layered_store::StoreType; use serde::Serialize; use tezos_core::types::encoded::{ Address, BlockHash, ChainId, ContractAddress, Encoded, ImplicitAddress, OperationHash, ProtocolHash, PublicKey, ScriptExprHash, }; use tezos_core::types::{mutez::Mutez, number::Nat}; -use tezos_ctx::{BatchReceipt, ContextNode, Head}; use tezos_michelson::micheline::Micheline; use tezos_operation::operations::SignedOperation; +use tezos_proto::context::{batch::BatchReceipt, head::Head, store::OperationReceipt}; use tezos_rpc::models::{ block::{Block, FullHeader, Metadata}, contract::{ContractEntrypoints, ContractInfo, ContractScript}, @@ -28,25 +33,21 @@ pub use block_id::BlockId; #[async_trait] pub trait RollupClient { async fn initialize(&mut self) -> Result<()>; - async fn get_state_value(&self, key: String, block_id: &BlockId) -> Result; + async fn store_get(&self, key: String, block_id: &BlockId) -> Result; async fn get_chain_id(&self) -> Result; async fn get_version(&self) -> Result; async fn is_chain_synced(&self) -> Result; async fn inject_batch(&self, messages: Vec>) -> Result<()>; async fn get_batch_head(&self, block_id: &BlockId) -> Result { - let head: Head = self - .get_state_value("/head".into(), block_id) - .await? - .try_into()?; + let head: Head = self.store_get("/head".into(), block_id).await?; Ok(head) } async fn get_batch_level(&self, hash: &BlockHash) -> Result { let receipt: BatchReceipt = self - .get_state_value(format!("/batches/{}", hash.value()), &BlockId::Head) - .await? - .try_into()?; + .store_get(format!("/batches/{}", hash.value()), &BlockId::Head) + .await?; Ok(receipt.header.level) } @@ -56,18 +57,16 @@ pub trait RollupClient { _ => self.get_batch_head(block_id).await?.hash, }; let receipt: BatchReceipt = self - .get_state_value(format!("/batches/{}", hash.value()), &BlockId::Head) - .await? - .try_into()?; + .store_get(format!("/batches/{}", hash.value()), &BlockId::Head) + .await?; Ok(receipt) } async fn get_operation_receipt(&self, hash: &OperationHash) -> Result { - let receipt: Operation = self - .get_state_value(format!("/operations/{}", hash.value()), &BlockId::Head) - .await? - .try_into()?; - Ok(receipt) + let receipt: OperationReceipt = self + .store_get(format!("/operations/{}", hash.value()), &BlockId::Head) + .await?; + Ok(receipt.0) } } diff --git a/tezos_node/src/rollup/block_id.rs b/tezos_node/src/rollup/block_id.rs index 16042b1..d3a67aa 100644 --- a/tezos_node/src/rollup/block_id.rs +++ b/tezos_node/src/rollup/block_id.rs @@ -1,3 +1,7 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + use tezos_core::types::encoded::{BlockHash, Encoded}; use crate::{Error, Result}; diff --git a/tezos_node/src/rollup/facade.rs b/tezos_node/src/rollup/facade.rs index cdae127..ee18d92 100644 --- a/tezos_node/src/rollup/facade.rs +++ b/tezos_node/src/rollup/facade.rs @@ -1,4 +1,9 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + use async_trait::async_trait; +use michelson_vm::entrypoints::collect_entrypoints; use std::collections::HashMap; use tezos_core::types::encoded::{ Address, BlockHash, ContractAddress, Encoded, ImplicitAddress, OperationHash, PublicKey, @@ -12,7 +17,6 @@ use tezos_rpc::models::{ contract::{ContractEntrypoints, ContractInfo, ContractScript}, operation::Operation, }; -use tezos_vm::entrypoints::collect_entrypoints; use crate::{ rollup::{BlockId, BlockProtocols, RollupClient, TezosFacade}, @@ -48,13 +52,13 @@ impl TezosFacade for T { async fn get_contract_balance(&self, block_id: &BlockId, address: &Address) -> Result { let balance: Mutez = match self - .get_state_value( + .store_get( format!("/context/contracts/{}/balance", address.value()), block_id, ) .await { - Ok(val) => val.try_into()?, + Ok(val) => val, Err(Error::KeyNotFound { key: _ }) => 0u32.into(), Err(err) => return Err(err), }; @@ -67,13 +71,13 @@ impl TezosFacade for T { address: &ImplicitAddress, ) -> Result { let counter: Nat = match self - .get_state_value( + .store_get( format!("/context/contracts/{}/counter", address.value()), block_id, ) .await { - Ok(val) => val.try_into()?, + Ok(val) => val, Err(Error::KeyNotFound { key: _ }) => 0u32.into(), Err(err) => return Err(err), }; @@ -86,13 +90,13 @@ impl TezosFacade for T { address: &ImplicitAddress, ) -> Result> { let pubkey: Option = match self - .get_state_value( + .store_get( format!("/context/contracts/{}/pubkey", address.value()), block_id, ) .await { - Ok(val) => Some(val.try_into()?), + Ok(val) => Some(val), Err(Error::KeyNotFound { key: _ }) => None, Err(err) => return Err(err), }; @@ -105,12 +109,11 @@ impl TezosFacade for T { address: &ContractAddress, ) -> Result { let script: Micheline = self - .get_state_value( + .store_get( format!("/context/contracts/{}/code", address.value()), block_id, ) - .await? - .try_into()?; + .await?; Ok(script) } @@ -120,12 +123,11 @@ impl TezosFacade for T { address: &ContractAddress, ) -> Result { let storage: Micheline = self - .get_state_value( + .store_get( format!("/context/contracts/{}/storage", address.value()), block_id, ) - .await? - .try_into()?; + .await?; Ok(storage) } @@ -168,12 +170,11 @@ impl TezosFacade for T { address: &ContractAddress, ) -> Result { let value: Micheline = self - .get_state_value( + .store_get( format!("/context/contracts/{}/entrypoints", address.value()), block_id, ) - .await? - .try_into()?; + .await?; let param_type: Type = value.try_into()?; let mut entrypoints: HashMap = HashMap::new(); @@ -194,7 +195,7 @@ impl TezosFacade for T { key_hash: &ScriptExprHash, ) -> Result { let value: Micheline = self - .get_state_value( + .store_get( format!( "/context/bigmaps/{}/values/{}", big_map_id, @@ -202,8 +203,7 @@ impl TezosFacade for T { ), block_id, ) - .await? - .try_into()?; + .await?; Ok(value) } diff --git a/tezos_node/src/rollup/mock_client.rs b/tezos_node/src/rollup/mock_client.rs index bc2ff85..e33b4a8 100644 --- a/tezos_node/src/rollup/mock_client.rs +++ b/tezos_node/src/rollup/mock_client.rs @@ -1,18 +1,20 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + use async_trait::async_trait; +use layered_store::{ephemeral::EphemeralCopy, StoreType}; use log::debug; use std::cell::RefCell; use std::sync::Mutex; use tezos_core::types::encoded::{ChainId, Encoded, OperationHash}; -use tezos_ctx::{ - migrations::run_migrations, ContextNode, EphemeralContext, ExecutorContext, GenericContext, - Head, -}; -use tezos_l2::{ +use tezos_operation::operations::SignedOperation; +use tezos_proto::{ batcher::apply_batch, + context::{head::Head, migrations::run_migrations, TezosContext, TezosEphemeralContext}, executor::operation::execute_operation, validator::operation::{validate_operation, ValidatedOperation}, }; -use tezos_operation::operations::SignedOperation; use tezos_rpc::models::operation::Operation; use tezos_rpc::models::version::{ AdditionalInfo, CommitInfo, NetworkVersion, Version, VersionInfo, @@ -26,7 +28,7 @@ use crate::{ const CHAIN_ID: &str = "NetXP2FfcNxFANL"; pub struct RollupMockClient { - context: Mutex>, + context: Mutex>, mempool: Mutex>>, } @@ -39,7 +41,7 @@ macro_rules! get_mut { impl Default for RollupMockClient { fn default() -> Self { Self { - context: Mutex::new(RefCell::new(EphemeralContext::new())), + context: Mutex::new(RefCell::new(TezosEphemeralContext::default())), mempool: Mutex::new(RefCell::new(Vec::new())), } } @@ -58,7 +60,7 @@ impl RollupMockClient { Ok(()) } - pub fn patch(&self, func: fn(&mut EphemeralContext) -> Result<()>) -> Result<()> { + pub fn patch(&self, func: fn(&mut TezosEphemeralContext) -> Result<()>) -> Result<()> { func(get_mut!(self.context)) } } @@ -72,7 +74,7 @@ impl RollupClient for RollupMockClient { Ok(()) } - async fn get_state_value(&self, key: String, block_id: &BlockId) -> Result { + async fn store_get(&self, key: String, block_id: &BlockId) -> Result { match &block_id { BlockId::Head => {} _ => unimplemented!("Can only access state at head level in the mockup mode"), diff --git a/tezos_node/src/rollup/rpc_backend.rs b/tezos_node/src/rollup/rpc_backend.rs new file mode 100644 index 0000000..8184e12 --- /dev/null +++ b/tezos_node/src/rollup/rpc_backend.rs @@ -0,0 +1,86 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + +use layered_store::{error::err_into, StoreBackend}; +use log::debug; +use reqwest::blocking::Client; + +use crate::{rollup::rpc_client::StateResponse, Error, Result}; + +pub struct RpcBackend { + base_url: String, + client: Client, + state_level: u32, +} + +impl RpcBackend { + pub fn new(base_url: String, state_level: u32) -> Self { + Self { + client: Client::new(), + base_url, + state_level, + } + } + + fn store_get(&self, key: &str) -> Result>> { + let res = self + .client + .get(format!( + "{}/global/block/{}/durable/wasm_2_0_0/value?key={}", + self.base_url, self.state_level, key + )) + .send()?; + + if res.status() == 200 || res.status() == 500 { + let content: Option = res.json()?; + match content { + Some(StateResponse::Value(value)) => { + let payload = hex::decode(value)?; + Ok(Some(payload)) + } + Some(StateResponse::Errors(errors)) => { + let message = errors.first().unwrap().to_string(); + Err(Error::RollupInternalError { message }) + } + None => Ok(None), + } + } else { + Err(Error::RollupClientError { + status: res.status().as_u16(), + }) + } + } +} + +impl StoreBackend for RpcBackend { + fn default() -> Self { + unimplemented!() + } + + fn log(&self, msg: &str) { + debug!("{}", msg) + } + + fn has(&self, key: &str) -> layered_store::Result { + // TODO: more optimal check without fetching data + match self.store_get(key) { + Ok(val) => Ok(val.is_some()), + Err(err) => Err(err_into(err)), + } + } + + fn read(&self, key: &str) -> layered_store::Result>> { + self.store_get(key).map_err(err_into) + } + + fn write(&mut self, _key: &str, _val: &[u8]) -> layered_store::Result<()> { + Ok(()) + } + + fn delete(&mut self, _key: &str) -> layered_store::Result<()> { + Ok(()) + } + + fn clear(&mut self) {} +} diff --git a/tezos_node/src/rollup/rpc_client.rs b/tezos_node/src/rollup/rpc_client.rs index 1f2f49a..99cb66f 100644 --- a/tezos_node/src/rollup/rpc_client.rs +++ b/tezos_node/src/rollup/rpc_client.rs @@ -1,9 +1,13 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + use async_trait::async_trait; +use layered_store::StoreType; use log::debug; use reqwest::Client; use serde::Deserialize; use tezos_core::types::encoded::{ChainId, Encoded, SmartRollupAddress}; -use tezos_ctx::ContextNode; use tezos_rpc::models::version::{ AdditionalInfo, CommitInfo, NetworkVersion, Version, VersionInfo, }; @@ -65,6 +69,7 @@ impl RollupRpcClient { } } + // FIXME: too much copypaste in the following several methods pub async fn get_rollup_address(&self) -> Result { let res = self .client @@ -184,7 +189,8 @@ impl RollupClient for RollupRpcClient { Ok(()) } - async fn get_state_value(&self, key: String, block_id: &BlockId) -> Result { + // Code duplication + async fn store_get(&self, key: String, block_id: &BlockId) -> Result { let block_id = self.convert_block_id(block_id).await?; let res = self .client @@ -200,7 +206,7 @@ impl RollupClient for RollupRpcClient { match content { Some(StateResponse::Value(value)) => { let payload = hex::decode(value)?; - Ok(ContextNode::from_vec(payload)?) + Ok(StoreType::from_bytes(payload.as_slice())?) } Some(StateResponse::Errors(errors)) => { let message = errors.first().unwrap().to_string(); diff --git a/tezos_node/src/rollup/rpc_context.rs b/tezos_node/src/rollup/rpc_context.rs deleted file mode 100644 index 22bc40c..0000000 --- a/tezos_node/src/rollup/rpc_context.rs +++ /dev/null @@ -1,112 +0,0 @@ -use log::debug; -use reqwest::blocking::Client; -use tezos_ctx::{ContextNode, EphemeralContext, GenericContext}; - -use crate::{rollup::rpc_client::StateResponse, Error, Result}; - -fn err_into(e: impl std::fmt::Debug) -> tezos_ctx::Error { - tezos_ctx::Error::Internal(tezos_ctx::error::InternalError::new( - tezos_ctx::error::InternalKind::Store, - format!("RPC context error: {:?}", e), - )) -} - -pub struct RpcContext { - base_url: String, - client: Client, - tmp_ctx: EphemeralContext, - state_level: u32, -} - -impl RpcContext { - pub fn new(base_url: String, state_level: u32) -> Self { - Self { - client: Client::new(), - tmp_ctx: EphemeralContext::new(), - base_url, - state_level, - } - } - - fn get_state_value(&self, key: String) -> Result> { - let res = self - .client - .get(format!( - "{}/global/block/{}/durable/wasm_2_0_0/value?key={}", - self.base_url, self.state_level, key - )) - .send()?; - - if res.status() == 200 || res.status() == 500 { - let content: Option = res.json()?; - match content { - Some(StateResponse::Value(value)) => { - let payload = hex::decode(value)?; - Ok(Some(ContextNode::from_vec(payload)?)) - } - Some(StateResponse::Errors(errors)) => { - let message = errors.first().unwrap().to_string(); - Err(Error::RollupInternalError { message }) - } - None => Ok(None), - } - } else { - Err(Error::RollupClientError { - status: res.status().as_u16(), - }) - } - } -} - -impl GenericContext for RpcContext { - fn log(&self, msg: String) { - debug!("{}", msg) - } - - fn has(&self, key: String) -> tezos_ctx::Result { - match self.tmp_ctx.has(key.clone())? { - true => return Ok(true), - false => { - if self.tmp_ctx.pending_removed(&key) { - return Ok(false); - } - } - }; - match self.get_state_value(key) { - Ok(val) => Ok(val.is_some()), - Err(err) => Err(err_into(err)), - } - } - - fn get(&mut self, key: String) -> tezos_ctx::Result> { - match self.tmp_ctx.get(key.clone())? { - Some(val) => return Ok(Some(val)), - None => { - if self.tmp_ctx.pending_removed(&key) { - return Ok(None); - } - } - }; - self.get_state_value(key).map_err(err_into) - } - - fn set(&mut self, key: String, val: Option) -> tezos_ctx::Result<()> { - self.tmp_ctx.set(key, val) - } - - fn has_pending_changes(&self) -> bool { - self.tmp_ctx.has_pending_changes() - } - - fn commit(&mut self) -> tezos_ctx::Result<()> { - self.tmp_ctx.commit() - } - - fn rollback(&mut self) { - self.tmp_ctx.rollback() - } - - fn clear(&mut self) { - self.tmp_ctx.clear() - } -} diff --git a/tezos_node/src/rollup/rpc_helpers.rs b/tezos_node/src/rollup/rpc_helpers.rs index 140175a..52257cd 100644 --- a/tezos_node/src/rollup/rpc_helpers.rs +++ b/tezos_node/src/rollup/rpc_helpers.rs @@ -1,21 +1,27 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + use actix_web::rt::task; use async_trait::async_trait; +use layered_store::LayeredStore; use tezos_core::types::encoded::{Encoded, OperationHash, Signature}; -use tezos_l2::{ +use tezos_operation::operations::{SignedOperation, UnsignedOperation}; +use tezos_proto::{ executor::operation::execute_operation, validator::operation::{validate_operation, ValidatedOperation}, }; -use tezos_operation::operations::{SignedOperation, UnsignedOperation}; use tezos_rpc::models::operation::Operation; use crate::{ rollup::{ - block_id::BlockId, rpc_client::RollupRpcClient, rpc_context::RpcContext, RollupClient, + block_id::BlockId, rpc_backend::RpcBackend, rpc_client::RollupRpcClient, RollupClient, TezosHelpers, }, Error, Result, }; +// TODO: reuse from kernel? pub fn parse_operation(payload: &[u8]) -> Result<(OperationHash, SignedOperation)> { const SIGNATURE_SIZE: usize = 64; if payload.len() < SIGNATURE_SIZE { @@ -51,7 +57,7 @@ impl TezosHelpers for RollupRpcClient { let base_url = self.base_url.clone(); task::spawn_blocking(move || -> Result { - let mut context = RpcContext::new(base_url, state_level); + let mut context = LayeredStore::new(RpcBackend::new(base_url, state_level)); let hash = operation.hash()?; let opg = match validate_operation(&mut context, operation, hash, true)? { ValidatedOperation::Valid(opg) => opg, diff --git a/tezos_node/src/services.rs b/tezos_node/src/services.rs index d6874c7..6ee0376 100644 --- a/tezos_node/src/services.rs +++ b/tezos_node/src/services.rs @@ -1,3 +1,7 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + pub mod blocks; pub mod context; pub mod contracts; diff --git a/tezos_node/src/services/blocks.rs b/tezos_node/src/services/blocks.rs index 4eff03e..4455771 100644 --- a/tezos_node/src/services/blocks.rs +++ b/tezos_node/src/services/blocks.rs @@ -1,3 +1,7 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + use actix_web::{ web::{Data, Path}, Responder, Result, @@ -63,7 +67,11 @@ pub async fn block( mod test { use actix_web::{test, web::Data, App}; use tezos_core::types::encoded::{BlockHash, Encoded}; - use tezos_ctx::{BatchHeader, BatchReceipt, ExecutorContext, Head}; + use tezos_proto::context::{ + batch::{BatchHeader, BatchReceipt}, + head::Head, + TezosContext, + }; use tezos_rpc::models::block::FullHeader; use crate::{rollup::mock_client::RollupMockClient, services::config, Result}; diff --git a/tezos_node/src/services/context.rs b/tezos_node/src/services/context.rs index e8f7f69..224bcc0 100644 --- a/tezos_node/src/services/context.rs +++ b/tezos_node/src/services/context.rs @@ -1,10 +1,14 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + use actix_web::{ http::StatusCode, web::{Data, Path}, HttpResponse, Responder, Result, }; use tezos_core::types::encoded::ScriptExprHash; -use tezos_ctx::Config; +use tezos_proto::config::Config; use crate::{json_response, rollup::TezosFacade, Error}; diff --git a/tezos_node/src/services/contracts.rs b/tezos_node/src/services/contracts.rs index 2b71f3e..36b5d06 100644 --- a/tezos_node/src/services/contracts.rs +++ b/tezos_node/src/services/contracts.rs @@ -1,3 +1,7 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + use actix_web::{ http::StatusCode, web::{Data, Path}, @@ -103,7 +107,7 @@ pub async fn contract( mod test { use actix_web::{test, web::Data, App}; use tezos_core::types::{encoded::PublicKey, mutez::Mutez, number::Nat}; - use tezos_ctx::{ExecutorContext, Head}; + use tezos_proto::context::{head::Head, TezosContext}; use tezos_rpc::models::contract::ContractInfo; use crate::{rollup::mock_client::RollupMockClient, services::config, Result}; diff --git a/tezos_node/src/services/helpers.rs b/tezos_node/src/services/helpers.rs index 9056638..0cdbe06 100644 --- a/tezos_node/src/services/helpers.rs +++ b/tezos_node/src/services/helpers.rs @@ -1,3 +1,7 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + use actix_web::{ error::ErrorInternalServerError, web::{Data, Json, Path}, @@ -188,7 +192,7 @@ mod test { encoded::{Encoded, PublicKey}, mutez::Mutez, }; - use tezos_ctx::{ExecutorContext, GenericContext, Head}; + use tezos_proto::context::{head::Head, TezosContext}; use tezos_rpc::models::{error::RpcError, operation::Operation}; use crate::{rollup::mock_client::RollupMockClient, services::config, Result}; diff --git a/tezos_node/src/services/operations.rs b/tezos_node/src/services/operations.rs index 9e4180f..1ac075d 100644 --- a/tezos_node/src/services/operations.rs +++ b/tezos_node/src/services/operations.rs @@ -1,3 +1,7 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + use actix_web::{ web::{Data, Path}, Responder, Result, diff --git a/tezos_node/src/services/shell.rs b/tezos_node/src/services/shell.rs index 6c3b42b..bc116a0 100644 --- a/tezos_node/src/services/shell.rs +++ b/tezos_node/src/services/shell.rs @@ -1,3 +1,7 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + use actix_web::{ web::{Data, Json}, Responder, Result, diff --git a/tezos_node/tests/quickstart.rs b/tezos_node/tests/quickstart.rs index 2e44dc4..a0280a4 100644 --- a/tezos_node/tests/quickstart.rs +++ b/tezos_node/tests/quickstart.rs @@ -1,3 +1,7 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + use serde_json::json; use static_init::dynamic; use std::path::PathBuf; @@ -6,11 +10,11 @@ use std::time::Duration; use tezos_contract::ContractFetcher; use tezos_core::types::encoded::{Encoded, ImplicitAddress, OperationHash, SecretKey}; use tezos_core::types::number::Nat; -use tezos_l2::executor::origination::originated_address; use tezos_michelson::michelson::data; use tezos_operation::operations::{ OperationContent, Origination, Reveal, Script, Transaction, UnsignedOperation, }; +use tezos_proto::executor::origination::originated_address; use tezos_rpc::{client::TezosRpc, http::default::HttpClient, Result}; use tokio::time::sleep; diff --git a/tezos_l2/Cargo.toml b/tezos_proto/Cargo.toml similarity index 81% rename from tezos_l2/Cargo.toml rename to tezos_proto/Cargo.toml index eaec0a0..4906f45 100644 --- a/tezos_l2/Cargo.toml +++ b/tezos_proto/Cargo.toml @@ -1,5 +1,9 @@ +# SPDX-FileCopyrightText: 2023 Baking Bad +# +# SPDX-License-Identifier: MIT + [package] -name = "tezos_l2" +name = "tezos_proto" version = "0.1.0" edition = "2021" @@ -7,8 +11,8 @@ edition = "2021" crate-type = ["cdylib", "rlib"] [dependencies] -tezos_vm = { path = "../tezos_vm" } -tezos_ctx = { path = "../tezos_ctx" } +michelson_vm = { path = "../michelson_vm" } +layered_store = { path = "../layered_store", default-features = false, features = ["tezos"] } tezos_core = { git = "https://github.com/baking-bad/tezos-rust-sdk", branch = "develop", package = "tezos-core", default-features = false, features = ["ed25519"] } tezos_operation = { git = "https://github.com/baking-bad/tezos-rust-sdk", branch = "develop", package = "tezos-operation", default-features = false, features = ["ed25519"] } tezos_rpc = { git = "https://github.com/baking-bad/tezos-rust-sdk", branch = "develop", package = "tezos-rpc", default-features = false } diff --git a/tezos_proto/README.md b/tezos_proto/README.md new file mode 100644 index 0000000..10efe87 --- /dev/null +++ b/tezos_proto/README.md @@ -0,0 +1,40 @@ +# Tezos proto + +This is a subset of the Tezos economic protocol implemented in Rust. + +## Design + +Top-level entities: +* `TezosContext` trait — Tezos global context abstraction, implemented for `LayeredStore` +* `SignedOperation` struct — original operation injected to the network +* `ValidatedOperation` enum — holds either a `ValidOperation` or a list of `RpcError` +* `BatchHeader` struct — batches are basically L2 blocks +* `Head` struct — L2 chain state + +Basic features: +* Context migrations: see `context::migrations` +* Operation validation: see `validator::operation` +* Operation execution: see `executor::operation` +* Batching operations: see `batcher` + +Note the dependency links for `tezos_*` crates (temporary, will be fixed later): +```toml +tezos_core = { git = "https://github.com/baking-bad/tezos-rust-sdk", branch = "develop", package = "tezos-core", default-features = false, features = ["ed25519"] } +tezos_operation = { git = "https://github.com/baking-bad/tezos-rust-sdk", branch = "develop", package = "tezos-operation", default-features = false, features = ["ed25519"] } +tezos_rpc = { git = "https://github.com/baking-bad/tezos-rust-sdk", branch = "develop", package = "tezos-rpc", default-features = false } +tezos_michelson = { git = "https://github.com/baking-bad/tezos-rust-sdk", branch = "develop", package = "tezos-michelson", default-features = false } +``` + +## Limitations + +Current design is intentionally simplified to speed up development while having a minimal necessary functional to operate. +* No gas/storage metering (although it can be incorporated rather easily) +* No money burning +* Non-sequential account counters +* Only 3 manager operations supported: transaction, reveal, origination +* Branch is currently not validated (infinite TTL) +* Several Michelson features are not supported (see `michelson_vm` crate for more details) + +### Test coverage + +Partially ported test suite from the Tezos repo: https://gitlab.com/tezos/tezos/-/blob/master/tests_python/tests_016/test_contract_onchain_opcodes.py \ No newline at end of file diff --git a/tezos_l2/src/batcher.rs b/tezos_proto/src/batcher.rs similarity index 88% rename from tezos_l2/src/batcher.rs rename to tezos_proto/src/batcher.rs index 8f4b85d..e4993e9 100644 --- a/tezos_l2/src/batcher.rs +++ b/tezos_proto/src/batcher.rs @@ -1,12 +1,13 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + +use michelson_vm::interpreter::InterpreterContext; use tezos_core::{ internal::coder::Encoder, internal::crypto::blake2b, types::encoded::{BlockHash, BlockPayloadHash, Encoded, OperationHash, OperationListListHash}, }; -use tezos_ctx::{ - migrations::run_migrations, BatchHeader, BatchReceipt, ExecutorContext, GenericContext, Head, - InterpreterContext, -}; use tezos_operation::{ block_header, internal::coder::operation_content_bytes_coder::OperationContentBytesCoder, operations::SignedOperation, @@ -14,7 +15,13 @@ use tezos_operation::{ use tezos_rpc::models::operation::Operation as OperationReceipt; use crate::{ - constants::*, + config::*, + context::{ + batch::{BatchHeader, BatchReceipt}, + head::Head, + migrations::run_migrations, + TezosContext, + }, executor::operation::execute_operation, validator::{batch::validate_batch, operation::ValidOperation}, Result, @@ -45,7 +52,7 @@ fn naive_header(prev_head: Head, operations: &Vec) -> Result, atomic: bool, diff --git a/tezos_ctx/src/types/config.rs b/tezos_proto/src/config.rs similarity index 83% rename from tezos_ctx/src/types/config.rs rename to tezos_proto/src/config.rs index 00507b2..d889466 100644 --- a/tezos_ctx/src/types/config.rs +++ b/tezos_proto/src/config.rs @@ -1,6 +1,13 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + use serde::{Deserialize, Serialize}; use tezos_core::types::number::Nat; +pub const PROTOCOL: &str = "ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK"; +pub const BLOCK_TIME: i64 = 8; + #[derive(Clone, Debug, Serialize, Deserialize)] pub struct Config { pub blocks_per_cycle: i32, diff --git a/tezos_ctx/src/types/batch.rs b/tezos_proto/src/context/batch.rs similarity index 97% rename from tezos_ctx/src/types/batch.rs rename to tezos_proto/src/context/batch.rs index 81dc5b9..72e34ca 100644 --- a/tezos_ctx/src/types/batch.rs +++ b/tezos_proto/src/context/batch.rs @@ -1,3 +1,7 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + use tezos_core::types::encoded::{ BlockHash, BlockPayloadHash, ChainId, ContextHash, OperationListListHash, ProtocolHash, }; @@ -13,7 +17,7 @@ use tezos_rpc::models::{ use chrono::NaiveDateTime; use serde::{Deserialize, Serialize}; -use crate::Config; +use crate::config::Config; pub const ZERO_SIGNATURE: &str = "sigMzJ4GVAvXEd2RjsKGfG2H9QvqTSKCZsuB2KiHbZRGFz72XgF6KaKADznh674fQgBatxw3xdHqTtMHUZAGRprxy64wg1aq"; diff --git a/tezos_ctx/src/types/head.rs b/tezos_proto/src/context/head.rs similarity index 93% rename from tezos_ctx/src/types/head.rs rename to tezos_proto/src/context/head.rs index 470ebbf..49578b7 100644 --- a/tezos_ctx/src/types/head.rs +++ b/tezos_proto/src/context/head.rs @@ -1,3 +1,7 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + use serde::{Deserialize, Serialize}; use tezos_core::types::encoded::{BlockHash, ChainId, Encoded, OperationHash}; diff --git a/tezos_ctx/src/migrations.rs b/tezos_proto/src/context/migrations.rs similarity index 83% rename from tezos_ctx/src/migrations.rs rename to tezos_proto/src/context/migrations.rs index 4decc4a..87ea14d 100644 --- a/tezos_ctx/src/migrations.rs +++ b/tezos_proto/src/context/migrations.rs @@ -1,7 +1,14 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + use tezos_core::types::mutez::Mutez; use tezos_rpc::models::balance_update::{BalanceUpdate, Contract, Kind, Origin}; -use crate::{ExecutorContext, GenericContext, Head, Result}; +use crate::{ + context::{head::Head, TezosContext}, + Result, +}; const SEED_ACCOUNTS: [&str; 8] = [ "tz1grSQDByRpnVs7sPtaprNZRp531ZKz6Jmm", // Pytezos built-in key @@ -15,9 +22,7 @@ const SEED_ACCOUNTS: [&str; 8] = [ ]; const SEED_BALANCE: u64 = 40_000_000_000_000u64; -pub fn genesis_migration( - context: &mut (impl ExecutorContext + GenericContext), -) -> Result> { +pub fn genesis_migration(context: &mut impl TezosContext) -> Result> { let mut updates: Vec = Vec::with_capacity(SEED_ACCOUNTS.len()); let balance = Mutez::try_from(SEED_BALANCE).unwrap(); @@ -36,7 +41,7 @@ pub fn genesis_migration( } pub fn run_migrations( - context: &mut (impl ExecutorContext + GenericContext), + context: &mut impl TezosContext, head: &Head, ) -> Result>> { context.check_no_pending_changes()?; @@ -49,11 +54,11 @@ pub fn run_migrations( #[cfg(test)] mod test { use super::*; - use crate::{EphemeralContext, Result}; + use crate::{context::TezosEphemeralContext, Result}; #[test] fn test_seed_acconuts() -> Result<()> { - let mut context = EphemeralContext::new(); + let mut context = TezosEphemeralContext::default(); let head = context.get_head()?; assert_eq!(-1, head.level); diff --git a/tezos_proto/src/context/mod.rs b/tezos_proto/src/context/mod.rs new file mode 100644 index 0000000..67e5b19 --- /dev/null +++ b/tezos_proto/src/context/mod.rs @@ -0,0 +1,12 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + +pub mod batch; +pub mod head; +pub mod migrations; +pub mod store; +pub mod tezos; + +pub use tezos::TezosContext; +pub type TezosEphemeralContext = layered_store::EphemeralStore; diff --git a/tezos_proto/src/context/store.rs b/tezos_proto/src/context/store.rs new file mode 100644 index 0000000..2eeedf7 --- /dev/null +++ b/tezos_proto/src/context/store.rs @@ -0,0 +1,55 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + +use layered_store::{error::err_into, Result, StoreType}; +use tezos_rpc::models::operation::Operation; + +use crate::{context::batch::BatchReceipt, context::head::Head}; + +impl StoreType for Head { + fn from_bytes(bytes: &[u8]) -> Result { + serde_json_wasm::de::from_slice(bytes).map_err(err_into) + } + + fn to_bytes(&self) -> Result> { + serde_json_wasm::ser::to_vec(self).map_err(err_into) + } +} + +impl StoreType for BatchReceipt { + fn from_bytes(_bytes: &[u8]) -> Result { + #[cfg(not(target_arch = "wasm32"))] + { + // This is a workaround to avoid floating point operations introduced by serde. + // Since we do not need RPC models deserialization inside the kernel, + // we can only enable that for tests and binaries that are not compiled to wasm. + serde_json_wasm::de::from_slice(_bytes).map_err(err_into) + } + #[cfg(target_arch = "wasm32")] + unimplemented!() + } + + fn to_bytes(&self) -> Result> { + serde_json_wasm::ser::to_vec(self).map_err(err_into) + } +} + +#[derive(Clone, Debug)] +pub struct OperationReceipt(pub Operation); + +impl StoreType for OperationReceipt { + fn from_bytes(_bytes: &[u8]) -> Result { + #[cfg(not(target_arch = "wasm32"))] + { + let operation: Operation = serde_json_wasm::de::from_slice(_bytes).map_err(err_into)?; + Ok(OperationReceipt(operation)) + } + #[cfg(target_arch = "wasm32")] + unimplemented!() + } + + fn to_bytes(&self) -> Result> { + serde_json_wasm::ser::to_vec(&self.0).map_err(err_into) + } +} diff --git a/tezos_proto/src/context/tezos.rs b/tezos_proto/src/context/tezos.rs new file mode 100644 index 0000000..b875354 --- /dev/null +++ b/tezos_proto/src/context/tezos.rs @@ -0,0 +1,179 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + +use layered_store::{LayeredStore, StoreBackend}; +use tezos_core::types::{ + encoded::{Encoded, PublicKey}, + mutez::Mutez, + number::Nat, +}; +use tezos_michelson::micheline::Micheline; +use tezos_rpc::models::operation::Operation; + +use crate::{ + context::{batch::BatchReceipt, head::Head, store::OperationReceipt}, + error::err_into, + Error, Result, +}; + +pub trait TezosContext { + fn get_head(&mut self) -> Result; + fn set_head(&mut self, head: Head) -> Result<()>; + fn get_balance(&mut self, address: &str) -> Result>; + fn set_balance(&mut self, address: &str, balance: Mutez) -> Result<()>; + fn get_counter(&mut self, address: &str) -> Result; + fn set_counter(&mut self, address: &str, counter: Nat) -> Result<()>; + fn has_public_key(&self, address: &str) -> Result; + fn get_public_key(&mut self, address: &str) -> Result>; + fn set_public_key(&mut self, address: &str, public_key: PublicKey) -> Result<()>; + fn set_contract_code(&mut self, address: &str, code: Micheline) -> Result<()>; + fn get_contract_code(&mut self, address: &str) -> Result>; + fn get_contract_storage(&mut self, address: &str) -> Result>; + fn set_contract_storage(&mut self, address: &str, storage: Micheline) -> Result<()>; + fn set_batch_receipt(&mut self, receipt: BatchReceipt) -> Result<()>; + fn get_batch_receipt(&mut self, hash: &str) -> Result; + fn set_operation_receipt(&mut self, receipt: Operation) -> Result<()>; + fn get_operation_receipt(&mut self, hash: &str) -> Result; + fn check_no_pending_changes(&self) -> Result<()>; + fn commit(&mut self) -> Result<()>; + fn rollback(&mut self); + fn log(&self, msg: String); +} + +impl TezosContext for LayeredStore { + fn get_head(&mut self) -> Result { + match self.get("/head".into()) { + Ok(Some(head)) => Ok(head), + Ok(None) => Ok(Head::default()), + Err(err) => Err(err_into(err)), + } + } + + fn set_head(&mut self, head: Head) -> Result<()> { + self.set("/head".into(), Some(head)).map_err(err_into) + } + + fn get_balance(&mut self, address: &str) -> Result> { + self.get(format!("/context/contracts/{}/balance", address)) + .map_err(err_into) + } + + fn set_balance(&mut self, address: &str, balance: Mutez) -> Result<()> { + self.set( + format!("/context/contracts/{}/balance", address), + Some(balance), + ) + .map_err(err_into) + } + + fn get_counter(&mut self, address: &str) -> Result { + match self.get(format!("/context/contracts/{}/counter", address)) { + Ok(Some(value)) => Ok(value), + Ok(None) => Ok(Nat::from_integer(0)), + Err(err) => Err(err_into(err)), + } + } + + fn set_counter(&mut self, address: &str, counter: Nat) -> Result<()> { + self.set( + format!("/context/contracts/{}/counter", address), + Some(counter), + ) + .map_err(err_into) + } + + fn get_public_key(&mut self, address: &str) -> Result> { + self.get(format!("/context/contracts/{}/pubkey", address)) + .map_err(err_into) + } + + fn set_public_key(&mut self, address: &str, public_key: PublicKey) -> Result<()> { + // NOTE: Underscores are not allowed in path (host restriction) + self.set( + format!("/context/contracts/{}/pubkey", address), + Some(public_key), + ) + .map_err(err_into) + } + + fn has_public_key(&self, address: &str) -> Result { + self.has(format!("/context/contracts/{}/pubkey", address)) + .map_err(err_into) + } + + fn set_batch_receipt(&mut self, receipt: BatchReceipt) -> Result<()> { + self.set( + format!("/batches/{}", receipt.hash.value()).into(), + Some(receipt), + ) + .map_err(err_into) + } + + fn get_batch_receipt(&mut self, hash: &str) -> Result { + self.get(format!("/batches/{}", hash)) + .map_err(err_into)? + .ok_or(Error::BatchNotFound { hash: hash.into() }) + } + + fn set_operation_receipt(&mut self, receipt: Operation) -> Result<()> { + self.set( + format!( + "/operations/{}", + receipt.hash.as_ref().expect("Operation hash").value() + ), + Some(OperationReceipt(receipt)), + ) + .map_err(err_into) + } + + fn get_operation_receipt(&mut self, hash: &str) -> Result { + self.get::(format!("/operations/{}", hash)) + .map_err(err_into)? + .ok_or(Error::OperationNotFound { hash: hash.into() }) + .map(|receipt| receipt.0) + } + + fn get_contract_code(&mut self, address: &str) -> Result> { + self.get(format!("/context/contracts/{}/code", address)) + .map_err(err_into) + } + + fn set_contract_code(&mut self, address: &str, code: Micheline) -> Result<()> { + self.set(format!("/context/contracts/{}/code", address), Some(code)) + .map_err(err_into) + } + + fn get_contract_storage(&mut self, address: &str) -> Result> { + self.get(format!("/context/contracts/{}/storage", address)) + .map_err(err_into) + } + + fn set_contract_storage(&mut self, address: &str, storage: Micheline) -> Result<()> { + self.set( + format!("/context/contracts/{}/storage", address), + Some(storage), + ) + .map_err(err_into) + } + + fn check_no_pending_changes(&self) -> Result<()> { + if self.has_pending_changes() { + Err(layered_store::Error::ContextUnstagedError.into()) + } else { + Ok(()) + } + } + + fn commit(&mut self) -> Result<()> { + LayeredStore::commit(self).map_err(err_into) + } + + fn rollback(&mut self) { + LayeredStore::rollback(self) + } + + fn log(&self, msg: String) { + LayeredStore::log(&self, msg) + } +} diff --git a/tezos_proto/src/error.rs b/tezos_proto/src/error.rs new file mode 100644 index 0000000..3d02338 --- /dev/null +++ b/tezos_proto/src/error.rs @@ -0,0 +1,119 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + +use derive_more::{Display, Error}; +use std::backtrace::Backtrace; +use tezos_core::types::mutez::Mutez; + +#[derive(Debug)] +pub struct InternalError { + pub message: String, + pub backtrace: Backtrace, +} + +impl InternalError { + pub fn new(message: String) -> Self { + Self { + message, + backtrace: Backtrace::capture(), + } + } + + pub fn format(&self) -> String { + format!( + "Tezos proto error\n{}\nStacktrace:\n{}", + self.message, self.backtrace + ) + } +} + +impl std::fmt::Display for InternalError { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.write_fmt(format_args!( + "Tezos proto error, {}", + self.message.replace("\n", " ") + )) + } +} + +impl std::error::Error for InternalError { + fn description(&self) -> &str { + &self.message + } +} + +#[derive(Debug, Display, Error)] +pub enum Error { + Internal(InternalError), + OperationKindUnsupported, + BalanceNotInitialized, + BalanceTooLow { balance: Mutez }, + ContractCodeMissing { address: String }, + ContractStorageMissing { address: String }, + InconsistentSources, + ContentsListError, + UnrevealedPublicKey, + InvalidSignature, + EmptyImplicitContract, + CounterInThePast { counter: String }, + BatchNotFound { hash: String }, + OperationNotFound { hash: String }, +} + +pub type Result = std::result::Result; + +#[macro_export] +macro_rules! internal_error { + ($($arg:tt)*) => { + $crate::Error::Internal( + $crate::error::InternalError::new(format!($($arg)*)) + ) + }; +} + +macro_rules! impl_from_error { + ($inner_err_ty: ty, $kind: ident) => { + impl From<$inner_err_ty> for Error { + fn from(error: $inner_err_ty) -> Self { + $crate::internal_error!("{:?}", error) + } + } + }; +} + +impl_from_error!(tezos_rpc::Error, TezosEncoding); +impl_from_error!(tezos_core::Error, TezosEncoding); +impl_from_error!(tezos_operation::Error, TezosEncoding); +impl_from_error!(tezos_michelson::Error, TezosEncoding); +impl_from_error!(serde_json_wasm::ser::Error, Encoding); +impl_from_error!(serde_json_wasm::de::Error, Encoding); +impl_from_error!(ibig::error::OutOfBoundsError, Encoding); +impl_from_error!(ibig::error::ParseError, Encoding); +impl_from_error!(chrono::ParseError, Encoding); +impl_from_error!(&str, Encoding); + +impl From for Error { + fn from(error: michelson_vm::Error) -> Self { + internal_error!("> Michelson VM: {}", error) + } +} + +impl From for Error { + fn from(error: layered_store::Error) -> Self { + internal_error!("> Layered storage: {}", error) + } +} + +impl Error { + pub fn format(&self) -> String { + match self { + Self::Internal(internal) => internal.format(), + err => format!("{:#?}", err), + } + } +} + +pub fn err_into(e: impl std::fmt::Debug) -> Error { + Error::Internal(InternalError::new(format!("{:?}", e))) +} diff --git a/tezos_l2/src/executor/balance_updates.rs b/tezos_proto/src/executor/balance_updates.rs similarity index 89% rename from tezos_l2/src/executor/balance_updates.rs rename to tezos_proto/src/executor/balance_updates.rs index c256d73..45c2632 100644 --- a/tezos_l2/src/executor/balance_updates.rs +++ b/tezos_proto/src/executor/balance_updates.rs @@ -1,8 +1,11 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + use tezos_core::types::mutez::Mutez; -use tezos_ctx::ExecutorContext; use tezos_rpc::models::balance_update::{BalanceUpdate, Contract, Kind, Origin}; -use crate::{Error, Result}; +use crate::{context::TezosContext, Error, Result}; #[derive(Clone, Debug)] pub struct BalanceUpdates { @@ -38,7 +41,7 @@ impl BalanceUpdates { pub fn transfer( &mut self, - context: &mut impl ExecutorContext, + context: &mut impl TezosContext, source: &str, destination: &str, amount: &Mutez, @@ -69,11 +72,7 @@ impl BalanceUpdates { Ok((src_balance, dst_balance)) } - pub fn reserve( - context: &mut impl ExecutorContext, - source: &str, - amount: &Mutez, - ) -> Result { + pub fn reserve(context: &mut impl TezosContext, source: &str, amount: &Mutez) -> Result { let mut src_balance = context .get_balance(source)? .ok_or(Error::BalanceNotInitialized)?; diff --git a/tezos_l2/src/executor/contract.rs b/tezos_proto/src/executor/contract.rs similarity index 88% rename from tezos_l2/src/executor/contract.rs rename to tezos_proto/src/executor/contract.rs index 4c6bf9e..12d91c0 100644 --- a/tezos_l2/src/executor/contract.rs +++ b/tezos_proto/src/executor/contract.rs @@ -1,28 +1,31 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + use derive_more::From; +use michelson_vm::{ + interpreter::{InterpreterContext, OperationScope}, + script::{MichelsonScript, ScriptReturn}, + types::InternalContent, +}; use tezos_core::types::{ encoded::{Address, ContractAddress, Encoded}, mutez::Mutez, }; -use tezos_ctx::{ExecutorContext, InterpreterContext}; use tezos_operation::operations::{ Entrypoint, OperationContent, Origination, Parameters, Transaction, }; -use tezos_vm::{ - interpreter::OperationScope, - script::{MichelsonScript, ScriptReturn}, - types::InternalContent, -}; -use crate::{constants, Error, Result}; +use crate::{config, context::TezosContext, Error, Result}; #[derive(Debug, From)] pub enum ContractOutput { - Error(tezos_vm::Error), + Error(michelson_vm::Error), Return(ScriptReturn), } pub fn deploy_contract( - context: &mut (impl ExecutorContext + InterpreterContext), + context: &mut (impl TezosContext + InterpreterContext), origination: &Origination, self_address: ContractAddress, balance: Mutez, @@ -35,7 +38,7 @@ pub fn deploy_contract( balance, chain_id: head.chain_id, level: head.level + 1, - now: head.timestamp + constants::BLOCK_TIME, + now: head.timestamp + config::BLOCK_TIME, parameters: None, self_address, self_type: script.get_type(), @@ -55,7 +58,7 @@ pub fn deploy_contract( } pub fn execute_contract( - context: &mut (impl ExecutorContext + InterpreterContext), + context: &mut (impl TezosContext + InterpreterContext), transaction: &Transaction, sender: Option
, balance: Mutez, @@ -81,7 +84,7 @@ pub fn execute_contract( balance, chain_id: head.chain_id, level: head.level + 1, - now: head.timestamp + constants::BLOCK_TIME, + now: head.timestamp + config::BLOCK_TIME, parameters: match &transaction.parameters { Some(params) => Some((params.entrypoint.to_str().into(), params.value.clone())), None => None, diff --git a/tezos_l2/src/executor/lazy_diff.rs b/tezos_proto/src/executor/lazy_diff.rs similarity index 94% rename from tezos_l2/src/executor/lazy_diff.rs rename to tezos_proto/src/executor/lazy_diff.rs index 4a27042..074f49f 100644 --- a/tezos_l2/src/executor/lazy_diff.rs +++ b/tezos_proto/src/executor/lazy_diff.rs @@ -1,3 +1,8 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + +use michelson_vm::types::BigMapDiff; use tezos_michelson::micheline::Micheline; use tezos_rpc::models::operation::operation_result::{ lazy_storage_diff::{ @@ -6,7 +11,6 @@ use tezos_rpc::models::operation::operation_result::{ }, DiffAction, }; -use tezos_vm::types::BigMapDiff; use crate::Result; diff --git a/tezos_l2/src/executor/mod.rs b/tezos_proto/src/executor/mod.rs similarity index 63% rename from tezos_l2/src/executor/mod.rs rename to tezos_proto/src/executor/mod.rs index 5443231..0228ad8 100644 --- a/tezos_l2/src/executor/mod.rs +++ b/tezos_proto/src/executor/mod.rs @@ -1,3 +1,7 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + pub mod balance_updates; pub mod contract; pub mod lazy_diff; diff --git a/tezos_l2/src/executor/operation.rs b/tezos_proto/src/executor/operation.rs similarity index 93% rename from tezos_l2/src/executor/operation.rs rename to tezos_proto/src/executor/operation.rs index 4c06871..a12bcfd 100644 --- a/tezos_l2/src/executor/operation.rs +++ b/tezos_proto/src/executor/operation.rs @@ -1,10 +1,15 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + +use michelson_vm::interpreter::InterpreterContext; use tezos_core::types::encoded::Encoded; -use tezos_ctx::{ExecutorContext, GenericContext, InterpreterContext}; use tezos_operation::operations::OperationContent; use tezos_rpc::models::operation::Operation as OperationReceipt; use crate::{ - constants::PROTOCOL, + config::PROTOCOL, + context::TezosContext, error::{Error, Result}, executor::{ balance_updates::BalanceUpdates, origination::execute_origination, reveal::execute_reveal, @@ -14,7 +19,7 @@ use crate::{ }; pub fn execute_operation( - context: &mut (impl GenericContext + ExecutorContext + InterpreterContext), + context: &mut (impl TezosContext + InterpreterContext), opg: &ValidOperation, ) -> Result { context.check_no_pending_changes()?; @@ -78,13 +83,11 @@ pub fn execute_operation( #[cfg(test)] mod test { use tezos_core::types::{mutez::Mutez, number::Nat}; - use tezos_ctx::{EphemeralContext, ExecutorContext}; use tezos_operation::operations::{SignedOperation, Transaction}; use tezos_rpc::models::operation::{operation_result::OperationResultStatus, OperationContent}; use super::*; - use crate::validator::operation::ValidOperation; - use crate::Result; + use crate::{context::TezosEphemeralContext, validator::operation::ValidOperation, Result}; macro_rules! get_status { ($receipt: expr) => { @@ -106,7 +109,7 @@ mod test { #[test] fn test_skipped_backtracked() -> Result<()> { - let mut context = EphemeralContext::new(); + let mut context = TezosEphemeralContext::default(); let source = "tz1V3dHSCJnWPRdzDmZGCZaTMuiTmbtPakmU"; let destination = "tz1NEgotHhj4fkm8AcwquQqQBrQsAMRUg86c"; diff --git a/tezos_l2/src/executor/origination.rs b/tezos_proto/src/executor/origination.rs similarity index 93% rename from tezos_l2/src/executor/origination.rs rename to tezos_proto/src/executor/origination.rs index 50371e1..c48723c 100644 --- a/tezos_l2/src/executor/origination.rs +++ b/tezos_proto/src/executor/origination.rs @@ -1,16 +1,20 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + +use michelson_vm::interpreter::InterpreterContext; use tezos_core::{ internal::crypto::blake2b, types::encoded::{ContractAddress, ContractHash, Encoded, OperationHash}, }; -use tezos_ctx::ExecutorContext; use tezos_operation::operations::Origination; use tezos_rpc::models::operation::{ operation_result::operations::origination::OriginationOperationResult, operation_result::OperationResultStatus, }; -use tezos_vm::interpreter::InterpreterContext; use crate::{ + context::TezosContext, executor::balance_updates::BalanceUpdates, executor::contract::{deploy_contract, ContractOutput}, executor::lazy_diff::LazyDiff, @@ -27,7 +31,7 @@ pub fn originated_address(opg_hash: &OperationHash, index: i32) -> Result Result<()> { - let mut context = EphemeralContext::new(); + let mut context = TezosEphemeralContext::default(); let source = "tz1V3dHSCJnWPRdzDmZGCZaTMuiTmbtPakmU"; context.set_balance(source, Mutez::from(1000000000u32))?; diff --git a/tezos_l2/src/executor/result.rs b/tezos_proto/src/executor/result.rs similarity index 98% rename from tezos_l2/src/executor/result.rs rename to tezos_proto/src/executor/result.rs index f2ca90b..7023a70 100644 --- a/tezos_l2/src/executor/result.rs +++ b/tezos_proto/src/executor/result.rs @@ -1,3 +1,7 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + use derive_more::{From, TryInto}; use tezos_core::types::encoded::{Address, Encoded}; use tezos_operation::operations::{Origination, Reveal, Transaction}; diff --git a/tezos_l2/src/executor/reveal.rs b/tezos_proto/src/executor/reveal.rs similarity index 87% rename from tezos_l2/src/executor/reveal.rs rename to tezos_proto/src/executor/reveal.rs index 6c110c6..afc7f43 100644 --- a/tezos_l2/src/executor/reveal.rs +++ b/tezos_proto/src/executor/reveal.rs @@ -1,14 +1,20 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + use tezos_core::types::encoded::Encoded; -use tezos_ctx::ExecutorContext; use tezos_operation::operations::Reveal; use tezos_rpc::models::operation::operation_result::{ operations::reveal::RevealOperationResult, OperationResultStatus, }; -use crate::{executor::result::ExecutionResult, executor::rpc_errors::RpcErrors, Result}; +use crate::{ + context::TezosContext, executor::result::ExecutionResult, executor::rpc_errors::RpcErrors, + Result, +}; pub fn execute_reveal( - context: &mut impl ExecutorContext, + context: &mut impl TezosContext, reveal: &Reveal, skip: bool, ) -> Result { @@ -49,15 +55,14 @@ pub fn execute_reveal( #[cfg(test)] mod test { use tezos_core::types::{encoded::PublicKey, mutez::Mutez, number::Nat}; - use tezos_ctx::{EphemeralContext, ExecutorContext}; use tezos_operation::operations::Reveal; use super::*; - use crate::Result; + use crate::{context::TezosEphemeralContext, Result}; #[test] fn test_reveal_applied() -> Result<()> { - let mut context = EphemeralContext::new(); + let mut context = TezosEphemeralContext::default(); let address = "tz1V3dHSCJnWPRdzDmZGCZaTMuiTmbtPakmU"; let public_key = diff --git a/tezos_l2/src/executor/rpc_errors.rs b/tezos_proto/src/executor/rpc_errors.rs similarity index 98% rename from tezos_l2/src/executor/rpc_errors.rs rename to tezos_proto/src/executor/rpc_errors.rs index 1e8a5c6..de582bb 100644 --- a/tezos_l2/src/executor/rpc_errors.rs +++ b/tezos_proto/src/executor/rpc_errors.rs @@ -1,3 +1,7 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + use tezos_core::types::{mutez::Mutez, number::Nat}; pub use tezos_rpc::models::error::RpcError; diff --git a/tezos_l2/src/executor/transaction.rs b/tezos_proto/src/executor/transaction.rs similarity index 93% rename from tezos_l2/src/executor/transaction.rs rename to tezos_proto/src/executor/transaction.rs index 751674e..0f3e9e2 100644 --- a/tezos_l2/src/executor/transaction.rs +++ b/tezos_proto/src/executor/transaction.rs @@ -1,5 +1,9 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + +use michelson_vm::interpreter::InterpreterContext; use tezos_core::types::encoded::{Address, Encoded}; -use tezos_ctx::{ExecutorContext, InterpreterContext}; use tezos_michelson::micheline::Micheline; use tezos_operation::operations::{OperationContent, Transaction}; use tezos_rpc::models::operation::{ @@ -8,6 +12,7 @@ use tezos_rpc::models::operation::{ }; use crate::{ + context::TezosContext, executor::balance_updates::BalanceUpdates, executor::contract::{execute_contract, expand_content, ContractOutput}, executor::lazy_diff::LazyDiff, @@ -17,7 +22,7 @@ use crate::{ }; pub fn execute_transaction( - context: &mut (impl ExecutorContext + InterpreterContext), + context: &mut (impl TezosContext + InterpreterContext), transaction: &Transaction, sender: Option
, skip: bool, @@ -119,15 +124,14 @@ pub fn execute_transaction( #[cfg(test)] mod test { use tezos_core::types::mutez::Mutez; - use tezos_ctx::{EphemeralContext, ExecutorContext}; use tezos_operation::operations::Transaction; use super::*; - use crate::Result; + use crate::{context::TezosEphemeralContext, Result}; #[test] fn test_transaction_applied() -> Result<()> { - let mut context = EphemeralContext::new(); + let mut context = TezosEphemeralContext::default(); let source = "tz1V3dHSCJnWPRdzDmZGCZaTMuiTmbtPakmU"; let destination = "tz1NEgotHhj4fkm8AcwquQqQBrQsAMRUg86c"; diff --git a/tezos_proto/src/lib.rs b/tezos_proto/src/lib.rs new file mode 100644 index 0000000..46b144f --- /dev/null +++ b/tezos_proto/src/lib.rs @@ -0,0 +1,12 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + +pub mod batcher; +pub mod config; +pub mod context; +pub mod error; +pub mod executor; +pub mod validator; + +pub use error::{Error, Result}; diff --git a/tezos_l2/src/validator/batch.rs b/tezos_proto/src/validator/batch.rs similarity index 90% rename from tezos_l2/src/validator/batch.rs rename to tezos_proto/src/validator/batch.rs index 3b2bf1f..9e73e9e 100644 --- a/tezos_l2/src/validator/batch.rs +++ b/tezos_proto/src/validator/batch.rs @@ -1,14 +1,18 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + use tezos_core::types::encoded::{Encoded, OperationHash}; -use tezos_ctx::{ExecutorContext, GenericContext}; use tezos_operation::operations::SignedOperation; use crate::{ + context::TezosContext, validator::operation::{validate_operation, ValidOperation, ValidatedOperation}, Result, }; pub fn validate_batch( - context: &mut (impl GenericContext + ExecutorContext), + context: &mut impl TezosContext, batch_payload: Vec<(OperationHash, SignedOperation)>, atomic: bool, ) -> Result> { diff --git a/tezos_proto/src/validator/mod.rs b/tezos_proto/src/validator/mod.rs new file mode 100644 index 0000000..cd592b8 --- /dev/null +++ b/tezos_proto/src/validator/mod.rs @@ -0,0 +1,6 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + +pub mod batch; +pub mod operation; diff --git a/tezos_l2/src/validator/operation.rs b/tezos_proto/src/validator/operation.rs similarity index 96% rename from tezos_l2/src/validator/operation.rs rename to tezos_proto/src/validator/operation.rs index 95343c0..61616e6 100644 --- a/tezos_l2/src/validator/operation.rs +++ b/tezos_proto/src/validator/operation.rs @@ -1,13 +1,17 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + use derive_more::{From, TryInto}; use tezos_core::types::{ encoded::{Encoded, ImplicitAddress, OperationHash}, mutez::Mutez, number::Nat, }; -use tezos_ctx::ExecutorContext; use tezos_operation::operations::{OperationContent, SignedOperation}; use crate::{ + context::TezosContext, executor::rpc_errors::{RpcError, RpcErrors}, Error, Result, }; @@ -29,7 +33,7 @@ pub struct ValidOperation { } pub fn validate_operation( - context: &mut impl ExecutorContext, + context: &mut impl TezosContext, opg: SignedOperation, hash: OperationHash, dry_run: bool, @@ -161,15 +165,14 @@ mod test { mutez::Mutez, number::Nat, }; - use tezos_ctx::{EphemeralContext, ExecutorContext, GenericContext}; use tezos_operation::operations::{Reveal, SignedOperation, Transaction}; use super::*; - use crate::Result; + use crate::{context::TezosEphemeralContext, Result}; #[test] fn test_valid_tx() -> Result<()> { - let mut context = EphemeralContext::new(); + let mut context = TezosEphemeralContext::default(); let address = "tz1V3dHSCJnWPRdzDmZGCZaTMuiTmbtPakmU"; context.set_balance(address, Mutez::from(1000000000u32))?; @@ -210,7 +213,7 @@ mod test { #[test] fn test_reveal_and_tx_batch() -> Result<()> { - let mut context = EphemeralContext::new(); + let mut context = TezosEphemeralContext::default(); let address = ImplicitAddress::try_from("tz1Ng3bkhPwf6byrSWzBeBRTuaiKCQXzyRUK").unwrap(); context.set_balance(&address.value(), Mutez::from(1000000000u32))?; diff --git a/tezos_vm/tests/data/scripts/big_map_to_self.json b/tezos_proto/tests/data/scripts/big_map_to_self.json similarity index 100% rename from tezos_vm/tests/data/scripts/big_map_to_self.json rename to tezos_proto/tests/data/scripts/big_map_to_self.json diff --git a/tezos_vm/tests/data/scripts/contract.json b/tezos_proto/tests/data/scripts/contract.json similarity index 100% rename from tezos_vm/tests/data/scripts/contract.json rename to tezos_proto/tests/data/scripts/contract.json diff --git a/tezos_vm/tests/data/scripts/noop.json b/tezos_proto/tests/data/scripts/noop.json similarity index 100% rename from tezos_vm/tests/data/scripts/noop.json rename to tezos_proto/tests/data/scripts/noop.json diff --git a/tezos_vm/tests/data/scripts/proxy.json b/tezos_proto/tests/data/scripts/proxy.json similarity index 100% rename from tezos_vm/tests/data/scripts/proxy.json rename to tezos_proto/tests/data/scripts/proxy.json diff --git a/tezos_vm/tests/data/scripts/self.json b/tezos_proto/tests/data/scripts/self.json similarity index 100% rename from tezos_vm/tests/data/scripts/self.json rename to tezos_proto/tests/data/scripts/self.json diff --git a/tezos_vm/tests/data/scripts/sender.json b/tezos_proto/tests/data/scripts/sender.json similarity index 100% rename from tezos_vm/tests/data/scripts/sender.json rename to tezos_proto/tests/data/scripts/sender.json diff --git a/tezos_vm/tests/data/scripts/source.json b/tezos_proto/tests/data/scripts/source.json similarity index 100% rename from tezos_vm/tests/data/scripts/source.json rename to tezos_proto/tests/data/scripts/source.json diff --git a/tezos_vm/tests/data/scripts/store_input.json b/tezos_proto/tests/data/scripts/store_input.json similarity index 100% rename from tezos_vm/tests/data/scripts/store_input.json rename to tezos_proto/tests/data/scripts/store_input.json diff --git a/tezos_vm/tests/data/scripts/store_now.json b/tezos_proto/tests/data/scripts/store_now.json similarity index 100% rename from tezos_vm/tests/data/scripts/store_now.json rename to tezos_proto/tests/data/scripts/store_now.json diff --git a/tezos_vm/tests/data/scripts/transfer_amount.json b/tezos_proto/tests/data/scripts/transfer_amount.json similarity index 100% rename from tezos_vm/tests/data/scripts/transfer_amount.json rename to tezos_proto/tests/data/scripts/transfer_amount.json diff --git a/tezos_vm/tests/data/scripts/transfer_tokens.json b/tezos_proto/tests/data/scripts/transfer_tokens.json similarity index 100% rename from tezos_vm/tests/data/scripts/transfer_tokens.json rename to tezos_proto/tests/data/scripts/transfer_tokens.json diff --git a/tezos_l2/tests/managers.rs b/tezos_proto/tests/managers.rs similarity index 93% rename from tezos_l2/tests/managers.rs rename to tezos_proto/tests/managers.rs index 6897e91..df0fd4d 100644 --- a/tezos_l2/tests/managers.rs +++ b/tezos_proto/tests/managers.rs @@ -1,3 +1,7 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + /// Ported from https://gitlab.com/tezos/tezos/-/blob/master/tezt/tests/manager_operations.ml mod runner; diff --git a/tezos_l2/tests/opcodes.rs b/tezos_proto/tests/opcodes.rs similarity index 98% rename from tezos_l2/tests/opcodes.rs rename to tezos_proto/tests/opcodes.rs index b1ca817..bbaae5c 100644 --- a/tezos_l2/tests/opcodes.rs +++ b/tezos_proto/tests/opcodes.rs @@ -1,3 +1,7 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + /// Ported from https://gitlab.com/tezos/tezos/-/blob/master/tests_python/tests_016/test_contract_onchain_opcodes.py mod runner; diff --git a/tezos_l2/tests/runner/client.rs b/tezos_proto/tests/runner/client.rs similarity index 96% rename from tezos_l2/tests/runner/client.rs rename to tezos_proto/tests/runner/client.rs index dcce15e..f81d646 100644 --- a/tezos_l2/tests/runner/client.rs +++ b/tezos_proto/tests/runner/client.rs @@ -1,3 +1,8 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + +use michelson_vm::interpreter::InterpreterContext; use std::collections::HashMap; use tezos_core::internal::crypto::blake2b; use tezos_core::types::{ @@ -7,9 +12,6 @@ use tezos_core::types::{ }, number::Nat, }; -use tezos_ctx::{ - migrations::run_migrations, ExecutorContext, GenericContext, Head, InterpreterContext, -}; use tezos_michelson::micheline::Micheline; use tezos_operation::operations::{ Entrypoint, OperationContent, Origination, Parameters, Reveal, Script, SignedOperation, @@ -17,7 +19,10 @@ use tezos_operation::operations::{ }; use tezos_rpc::models::operation::Operation; -use tezos_l2::batcher::apply_batch; +use tezos_proto::{ + batcher::apply_batch, + context::{head::Head, migrations::run_migrations, TezosContext}, +}; pub struct Wallet { pub counter: u32, @@ -72,7 +77,7 @@ pub struct Client { alias: Option<&'static str>, } -impl Client { +impl Client { pub fn new(context: Context) -> Self { Self { context, diff --git a/tezos_l2/tests/runner/mock.rs b/tezos_proto/tests/runner/mock.rs similarity index 87% rename from tezos_l2/tests/runner/mock.rs rename to tezos_proto/tests/runner/mock.rs index 05fd180..4e6db82 100644 --- a/tezos_l2/tests/runner/mock.rs +++ b/tezos_proto/tests/runner/mock.rs @@ -1,15 +1,19 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + use serde_json::Value; use std::fs::File; use std::io::Read; use std::path::PathBuf; use tezos_core::types::encoded::Encoded; -use tezos_ctx::EphemeralContext; -use tezos_l2::executor::origination::originated_address; use tezos_michelson::micheline::Micheline; +use tezos_proto::{context::TezosEphemeralContext, executor::origination::originated_address}; + use crate::runner::client::Client; -pub type MockClient = Client; +pub type MockClient = Client; pub fn read_script(filename: &str) -> Micheline { let mut path = PathBuf::from(env!("CARGO_MANIFEST_DIR")); @@ -27,7 +31,7 @@ pub fn read_script(filename: &str) -> Micheline { impl MockClient { pub fn default() -> Self { - let mut client = Self::new(EphemeralContext::new()); + let mut client = Self::new(TezosEphemeralContext::default()); client.migrate().bake(); client.import_wallet( "pytezos", diff --git a/tezos_proto/tests/runner/mod.rs b/tezos_proto/tests/runner/mod.rs new file mode 100644 index 0000000..321f6f8 --- /dev/null +++ b/tezos_proto/tests/runner/mod.rs @@ -0,0 +1,8 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + +#![allow(dead_code)] + +pub mod client; +pub mod mock; diff --git a/tezos_vm/tests/runner/mod.rs b/tezos_vm/tests/runner/mod.rs deleted file mode 100644 index 92f963e..0000000 --- a/tezos_vm/tests/runner/mod.rs +++ /dev/null @@ -1,6 +0,0 @@ -#![allow(dead_code)] - -pub mod e2e; -pub mod micheline; -pub mod mock; -pub mod tzt; diff --git a/zcash_params/Cargo.toml b/zcash_params/Cargo.toml new file mode 100644 index 0000000..063bfa9 --- /dev/null +++ b/zcash_params/Cargo.toml @@ -0,0 +1,17 @@ +# SPDX-FileCopyrightText: 2023 Baking Bad +# +# SPDX-License-Identifier: MIT + +[package] +name = "zcash_params" +version = "0.1.0" +edition = "2021" + +[[bin]] +name = "fetch-verifying-keys" +path = "src/main.rs" + +[dependencies] +bls12_381 = "0.8" +bellman = { version = "0.14", default-features = false, features = ["groth16"] } +zcash_proofs = { version = "0.12.1", default-features = false, features = ["download-params"] } \ No newline at end of file diff --git a/zcash_params/README.md b/zcash_params/README.md new file mode 100644 index 0000000..0bbdf6a --- /dev/null +++ b/zcash_params/README.md @@ -0,0 +1,3 @@ +# Zcash parameters + +This crate is used to download Sapling params and to extract verifying keys for the further use. \ No newline at end of file diff --git a/zcash_params/src/main.rs b/zcash_params/src/main.rs new file mode 100644 index 0000000..6a3eca7 --- /dev/null +++ b/zcash_params/src/main.rs @@ -0,0 +1,26 @@ +// SPDX-FileCopyrightText: 2023 Baking Bad +// +// SPDX-License-Identifier: MIT + +use bellman::groth16::VerifyingKey; +use bls12_381::Bls12; +use std::fs::File; +use std::path::Path; +use zcash_proofs::{download_sapling_parameters, load_parameters}; + +fn save_vk(vk: &VerifyingKey, path: &Path) { + let mut writer = File::create(path).expect("Failed to create key file"); + vk.write(&mut writer).expect("Failed to serialize vk"); +} + +fn main() { + let target_dir = Path::new("./sapling_proto/src/keys"); + assert!(target_dir.exists() && target_dir.is_dir()); + + let params_paths = + download_sapling_parameters(Some(60)).expect("Failed to download sapling parameters"); + + let params = load_parameters(¶ms_paths.spend, ¶ms_paths.output, None); + save_vk(¶ms.spend_params.vk, &target_dir.join("spend.bin")); + save_vk(¶ms.output_params.vk, &target_dir.join("output.bin")); +}