From 702f7c1560ecc3174cd283c28c57ae00219a7dbe Mon Sep 17 00:00:00 2001 From: abenso Date: Fri, 8 Nov 2024 08:45:33 -0300 Subject: [PATCH] sync --- CMakeLists.txt | 3 +++ app/rust/.cargo/config.toml | 9 +++++++++ app/rust/include/rslib.h | 8 ++++++++ app/rust/src/lib.rs | 16 ++++++++-------- app/src/spend_plan.h | 9 ++++----- 5 files changed, 32 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b348fa38..e5eae14d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -141,6 +141,8 @@ file(GLOB_RECURSE LIB_SRC ${CMAKE_CURRENT_SOURCE_DIR}/app/src/nanopb_tiny/pb_common.c ${CMAKE_CURRENT_SOURCE_DIR}/app/src/nanopb_tiny/pb_decode.c ${CMAKE_CURRENT_SOURCE_DIR}/app/src/parser_interface.c + ${CMAKE_CURRENT_SOURCE_DIR}/app/src/spend_plan.c + ${CMAKE_CURRENT_SOURCE_DIR}/app/src/parser_pb_utils.c ) add_library(app_lib STATIC ${LIB_SRC}) @@ -233,6 +235,7 @@ target_include_directories(unittests PRIVATE ${CONAN_INCLUDE_DIRS_JSONCPP} ${CMAKE_CURRENT_SOURCE_DIR}/app/src ${CMAKE_CURRENT_SOURCE_DIR}/app/src/lib + ${CMAKE_CURRENT_SOURCE_DIR}/app/rust/include ) target_link_libraries(unittests PRIVATE diff --git a/app/rust/.cargo/config.toml b/app/rust/.cargo/config.toml index f2079bf2..c136e931 100644 --- a/app/rust/.cargo/config.toml +++ b/app/rust/.cargo/config.toml @@ -20,3 +20,12 @@ rustflags = [ "-C", "inline-threshold=0", ] + + +[target.'cfg(target_os = "linux")'] +rustflags = [ + "-C", + "link-arg=-Wl,--gc-sections", + "-C", + "link-arg=-Wl,--as-needed", +] diff --git a/app/rust/include/rslib.h b/app/rust/include/rslib.h index aa9f175a..4e5a5274 100644 --- a/app/rust/include/rslib.h +++ b/app/rust/include/rslib.h @@ -4,6 +4,10 @@ #include "coin.h" +#ifdef __cplusplus +extern "C" { +#endif + void get_sr25519_sk(uint8_t *sk_ed25519_expanded); void sign_sr25519_phase1(const uint8_t *sk_ed25519_expanded, const uint8_t *pk, const uint8_t *context_ptr, @@ -27,3 +31,7 @@ parser_error_t rs_compute_transaction_plan(transaction_plan_t *plan, uint8_t *ou int32_t rs_bech32_encode(const uint8_t *hrp_ptr, size_t hrp_len, const uint8_t *data_ptr, size_t data_len, uint8_t *output_ptr, size_t output_len); + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/app/rust/src/lib.rs b/app/rust/src/lib.rs index c5e81b4a..f668a44c 100644 --- a/app/rust/src/lib.rs +++ b/app/rust/src/lib.rs @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. ********************************************************************************/ -#![no_std] +// #![no_std] #![no_builtins] #![allow(dead_code)] #![deny(unused_crate_dependencies)] @@ -43,14 +43,14 @@ pub(crate) use utils::prf::{expand_fq, expand_fr}; fn debug(_msg: &str) {} -#[cfg(all(not(test), not(feature = "clippy"), not(feature = "fuzzing")))] -use core::panic::PanicInfo; +// #[cfg(all(not(test), not(feature = "clippy"), not(feature = "fuzzing")))] +// use core::panic::PanicInfo; -#[cfg(all(not(test), not(feature = "clippy"), not(feature = "fuzzing")))] -#[panic_handler] -fn panic(_info: &PanicInfo) -> ! { - loop {} -} +// #[cfg(all(not(test), not(feature = "clippy"), not(feature = "fuzzing")))] +// #[panic_handler] +// fn panic(_info: &PanicInfo) -> ! { +// loop {} +// } extern "C" { fn check_app_canary(); diff --git a/app/src/spend_plan.h b/app/src/spend_plan.h index 18b500c8..61d70bfc 100644 --- a/app/src/spend_plan.h +++ b/app/src/spend_plan.h @@ -15,10 +15,6 @@ ********************************************************************************/ #pragma once -#ifdef __cplusplus -extern "C" { -#endif - #include #include @@ -31,7 +27,10 @@ extern "C" { #include "pb_common.h" #include "pb_decode.h" -#include "protobuf/penumbra/core/transaction/v1/transaction.pb.h" + +#ifdef __cplusplus +extern "C" { +#endif parser_error_t decode_spend_plan(const Bytes_t *input, spend_plan_t *spend_plan);