From d8377cc2343cfc9b414d981e94c8b9b7ba995d90 Mon Sep 17 00:00:00 2001 From: fmoletta <99273364+fmoletta@users.noreply.github.com> Date: Mon, 10 Jun 2024 15:50:18 -0300 Subject: [PATCH 1/6] Add `cairo-native` setup instructions to README --- README.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/README.md b/README.md index 4c58108..4bd50c3 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,28 @@ # starknet-replay Provides a way of reading a real Starknet State, so you can re-execute an existing transaction in any of the Starknet networks in an easy way + +### Cairo Native setup + +Starknet Replay is currenlty integrated with [Cairo Native](https://github.com/lambdaclass/cairo_native), which makes the execution of sierra programs possible through native machine code. To use it, the following needs to be setup: + +- LLVM `18` needs to be installed and the `MLIR_SYS_180_PREFIX` and `TABLEGEN_180_PREFIX` environment variable needs to point to said installation. In macOS, run + ``` + brew install llvm@17 + export MLIR_SYS_180_PREFIX=/opt/homebrew/opt/llvm@18 + export LLVM_SYS_180_PREFIX=/opt/homebrew/opt/llvm@18 + export TABLEGEN_180_PREFIX=/opt/homebrew/opt/llvm@18 + ``` + and you're set. + +Afterwards, compiling with the feature flag `cairo-native` will enable native execution. You can check out some example test code that uses it under `tests/cairo_native.rs`. + +#### Using ahead of time compilation with Native. + +Currently cairo-native with AOT needs a runtime library in a known place. For this you need to compile the [cairo-native-runtime](https://github.com/lambdaclass/cairo_native/tree/main/runtime) crate and point the following environment variable to a folder containing the dynamic library. The path **must** be an absolute path. + +```bash +CAIRO_NATIVE_RUNTIME_LIBDIR=/absolute/path/to/cairo-native/target/release +``` + +If you don't do this you will get a linker error when using AOT. + From aaf8f3bbe4e20fffd15056e5cd8a415bfb64a514 Mon Sep 17 00:00:00 2001 From: fmoletta <99273364+fmoletta@users.noreply.github.com> Date: Mon, 10 Jun 2024 15:51:16 -0300 Subject: [PATCH 2/6] Capitalize --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4bd50c3..34fae01 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # starknet-replay Provides a way of reading a real Starknet State, so you can re-execute an existing transaction in any of the Starknet networks in an easy way -### Cairo Native setup +### Cairo Native Setup Starknet Replay is currenlty integrated with [Cairo Native](https://github.com/lambdaclass/cairo_native), which makes the execution of sierra programs possible through native machine code. To use it, the following needs to be setup: From 21739d21e43669abdc8c8cfc4645c1ae53f29cce Mon Sep 17 00:00:00 2001 From: fmoletta <99273364+fmoletta@users.noreply.github.com> Date: Mon, 10 Jun 2024 16:18:41 -0300 Subject: [PATCH 3/6] Fix env var name --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 34fae01..7c704f2 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ Afterwards, compiling with the feature flag `cairo-native` will enable native ex Currently cairo-native with AOT needs a runtime library in a known place. For this you need to compile the [cairo-native-runtime](https://github.com/lambdaclass/cairo_native/tree/main/runtime) crate and point the following environment variable to a folder containing the dynamic library. The path **must** be an absolute path. ```bash -CAIRO_NATIVE_RUNTIME_LIBDIR=/absolute/path/to/cairo-native/target/release +CAIRO_NATIVE_RUNTIME_LIBRARY=/absolute/path/to/cairo-native/target/release ``` If you don't do this you will get a linker error when using AOT. From 2791bd6534ee6aee26266d3db17be04ab05a7882 Mon Sep 17 00:00:00 2001 From: fmoletta <99273364+fmoletta@users.noreply.github.com> Date: Mon, 10 Jun 2024 16:29:16 -0300 Subject: [PATCH 4/6] Fix env var --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7c704f2..29563f3 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ Afterwards, compiling with the feature flag `cairo-native` will enable native ex Currently cairo-native with AOT needs a runtime library in a known place. For this you need to compile the [cairo-native-runtime](https://github.com/lambdaclass/cairo_native/tree/main/runtime) crate and point the following environment variable to a folder containing the dynamic library. The path **must** be an absolute path. ```bash -CAIRO_NATIVE_RUNTIME_LIBRARY=/absolute/path/to/cairo-native/target/release +CAIRO_NATIVE_RUNTIME_LIBRARY=/absolute/path/to/cairo-native/target/release/ ``` If you don't do this you will get a linker error when using AOT. From fb67b94c75f4ee1b5c5056c63c7c44f23bac8806 Mon Sep 17 00:00:00 2001 From: fmoletta <99273364+fmoletta@users.noreply.github.com> Date: Mon, 10 Jun 2024 16:39:00 -0300 Subject: [PATCH 5/6] Fix --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 29563f3..77f4ea2 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ Starknet Replay is currenlty integrated with [Cairo Native](https://github.com/l - LLVM `18` needs to be installed and the `MLIR_SYS_180_PREFIX` and `TABLEGEN_180_PREFIX` environment variable needs to point to said installation. In macOS, run ``` - brew install llvm@17 + brew install llvm@18 export MLIR_SYS_180_PREFIX=/opt/homebrew/opt/llvm@18 export LLVM_SYS_180_PREFIX=/opt/homebrew/opt/llvm@18 export TABLEGEN_180_PREFIX=/opt/homebrew/opt/llvm@18 From 80b71ee651dcfd6a75643bec64a430209d81fdc4 Mon Sep 17 00:00:00 2001 From: fmoletta <99273364+fmoletta@users.noreply.github.com> Date: Mon, 10 Jun 2024 17:02:50 -0300 Subject: [PATCH 6/6] Update env var --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 77f4ea2..b258d95 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ Afterwards, compiling with the feature flag `cairo-native` will enable native ex Currently cairo-native with AOT needs a runtime library in a known place. For this you need to compile the [cairo-native-runtime](https://github.com/lambdaclass/cairo_native/tree/main/runtime) crate and point the following environment variable to a folder containing the dynamic library. The path **must** be an absolute path. ```bash -CAIRO_NATIVE_RUNTIME_LIBRARY=/absolute/path/to/cairo-native/target/release/ +CAIRO_NATIVE_RUNTIME_LIBRARY=/absolute/path/to/cairo-native/target/release/libcairo_native_runtime.a ``` If you don't do this you will get a linker error when using AOT.