Skip to content

Commit

Permalink
Revert Protobuf removal (#243)
Browse files Browse the repository at this point in the history
* add nanopb submodule

* add protobuf support

* update makefiles

* update tests

* update snapshots
  • Loading branch information
chcmedeiros authored Sep 2, 2024
1 parent a3c5342 commit bf474f0
Show file tree
Hide file tree
Showing 449 changed files with 8,331 additions and 199 deletions.
12 changes: 12 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,13 @@ file(GLOB_RECURSE TINYCBOR_SRC
${CMAKE_CURRENT_SOURCE_DIR}/deps/tinycbor/src/cborvalidation.c
)

# static libs
file(GLOB_RECURSE TINYPB_SRC
${CMAKE_CURRENT_SOURCE_DIR}/deps/nanopb_tiny/pb_common.c
${CMAKE_CURRENT_SOURCE_DIR}/deps/nanopb_tiny/pb_decode.c
${CMAKE_CURRENT_SOURCE_DIR}/deps/nanopb_tiny/pb_encode.c
)

file(GLOB_RECURSE LIB_SRC
${CMAKE_CURRENT_SOURCE_DIR}/deps/ledger-zxlib/src/hexutils.c
${CMAKE_CURRENT_SOURCE_DIR}/deps/ledger-zxlib/src/app_mode.c
Expand All @@ -115,19 +122,22 @@ file(GLOB_RECURSE LIB_SRC
${CMAKE_CURRENT_SOURCE_DIR}/app/src/parser_impl.c
${CMAKE_CURRENT_SOURCE_DIR}/app/src/crypto.c
${CMAKE_CURRENT_SOURCE_DIR}/app/src/base32.c
${CMAKE_CURRENT_SOURCE_DIR}/app/src/protobuf/*.c
${CMAKE_CURRENT_SOURCE_DIR}/app/src/parser_print_*.c
)

add_library(app_lib STATIC
${LIB_SRC}
${TINYCBOR_SRC}
${TINYPB_SRC}
)

target_include_directories(app_lib PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/deps/BLAKE2/ref
${CMAKE_CURRENT_SOURCE_DIR}/deps/ledger-zxlib/include
${CMAKE_CURRENT_SOURCE_DIR}/deps/tinycbor/src
${CMAKE_CURRENT_SOURCE_DIR}/deps/picohash/
${CMAKE_CURRENT_SOURCE_DIR}/deps/nanopb_tiny/
${CMAKE_CURRENT_SOURCE_DIR}/app/src
${CMAKE_CURRENT_SOURCE_DIR}/app/src/candid
${CMAKE_CURRENT_SOURCE_DIR}/app/src/lib
Expand All @@ -146,6 +156,7 @@ target_include_directories(unittests PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/app/src/lib
${CMAKE_CURRENT_SOURCE_DIR}/deps/tinycbor/src
${CMAKE_CURRENT_SOURCE_DIR}/deps/picohash/
${CMAKE_CURRENT_SOURCE_DIR}/deps/nanopb_tiny/
)


Expand All @@ -165,6 +176,7 @@ set_tests_properties(unittests PROPERTIES WORKING_DIRECTORY ${CMAKE_CURRENT_SOUR
if (ENABLE_FUZZING)
set(FUZZ_TARGETS
parser_parse
parser_protobuf
)

foreach (target ${FUZZ_TARGETS})
Expand Down
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ ZXLIB_COMPILE_STAX ?= 1
PRODUCTION_BUILD ?= 1
include $(CURDIR)/deps/ledger-zxlib/dockerized_build.mk

proto:
cd $(CURDIR)/app/src/protobuf && $(CURDIR)/deps/nanopb/generator/protoc ./base_types.proto ./types.proto ./governance.proto ./dfinity.proto --nanopb_out=.

else
default:
$(MAKE) -C app
Expand Down
5 changes: 4 additions & 1 deletion app/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ endif

APP_LOAD_PARAMS = --curve secp256k1 $(COMMON_LOAD_PARAMS) --path $(APPPATH)

APP_STACK_MIN_SIZE := 3000
APP_STACK_MIN_SIZE := 2050
include $(CURDIR)/../deps/ledger-zxlib/makefiles/Makefile.devices

$(info TARGET_NAME = [$(TARGET_NAME)])
Expand All @@ -83,6 +83,9 @@ CFLAGS += -Wvla -Wno-implicit-fallthrough
CFLAGS += -I$(MY_DIR)/../deps/tinycbor/src
APP_SOURCE_PATH += $(MY_DIR)/../deps/tinycbor-ledger

CFLAGS += -I$(MY_DIR)/../deps/nanopb/
APP_SOURCE_PATH += $(MY_DIR)/../deps/nanopb_tiny/

.PHONY: rust
rust:
@echo "No rust code"
Expand Down
4 changes: 2 additions & 2 deletions app/Makefile.version
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This is the major version of this release
APPVERSION_M=3
# This is the minor version of this release
APPVERSION_N=0
APPVERSION_N=1
# This is the patch version of this release
APPVERSION_P=3
APPVERSION_P=0
11 changes: 11 additions & 0 deletions app/src/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "timeutils.h"
#include "parser_print_candid.h"
#include "parser_print_helper.h"
#include "parser_print_protobuf.h"

#if defined(TARGET_NANOX) || defined(TARGET_NANOS2) || defined(TARGET_STAX) || defined(TARGET_FLEX)
// For some reason NanoX requires this function
Expand Down Expand Up @@ -200,6 +201,16 @@ parser_error_t parser_getItem(const parser_context_t *ctx,
switch (parser_tx_obj.txtype) {
case call: {
switch (parser_tx_obj.tx_fields.call.method_type) {
case pb_sendrequest:
case pb_manageneuron:
case pb_listneurons:
case pb_claimneurons: {
return parser_getItemProtobuf(displayIdx,
outKey, outKeyLen,
outVal, outValLen,
pageIdx, pageCount);
}

case candid_manageneuron:
case candid_listneurons:
case candid_updatenodeprovider:
Expand Down
Loading

0 comments on commit bf474f0

Please sign in to comment.