Skip to content

Commit bf474f0

Browse files
authored
Revert Protobuf removal (#243)
* add nanopb submodule * add protobuf support * update makefiles * update tests * update snapshots
1 parent a3c5342 commit bf474f0

File tree

449 files changed

+8331
-199
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

449 files changed

+8331
-199
lines changed

CMakeLists.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,13 @@ file(GLOB_RECURSE TINYCBOR_SRC
9999
${CMAKE_CURRENT_SOURCE_DIR}/deps/tinycbor/src/cborvalidation.c
100100
)
101101

102+
# static libs
103+
file(GLOB_RECURSE TINYPB_SRC
104+
${CMAKE_CURRENT_SOURCE_DIR}/deps/nanopb_tiny/pb_common.c
105+
${CMAKE_CURRENT_SOURCE_DIR}/deps/nanopb_tiny/pb_decode.c
106+
${CMAKE_CURRENT_SOURCE_DIR}/deps/nanopb_tiny/pb_encode.c
107+
)
108+
102109
file(GLOB_RECURSE LIB_SRC
103110
${CMAKE_CURRENT_SOURCE_DIR}/deps/ledger-zxlib/src/hexutils.c
104111
${CMAKE_CURRENT_SOURCE_DIR}/deps/ledger-zxlib/src/app_mode.c
@@ -115,19 +122,22 @@ file(GLOB_RECURSE LIB_SRC
115122
${CMAKE_CURRENT_SOURCE_DIR}/app/src/parser_impl.c
116123
${CMAKE_CURRENT_SOURCE_DIR}/app/src/crypto.c
117124
${CMAKE_CURRENT_SOURCE_DIR}/app/src/base32.c
125+
${CMAKE_CURRENT_SOURCE_DIR}/app/src/protobuf/*.c
118126
${CMAKE_CURRENT_SOURCE_DIR}/app/src/parser_print_*.c
119127
)
120128

121129
add_library(app_lib STATIC
122130
${LIB_SRC}
123131
${TINYCBOR_SRC}
132+
${TINYPB_SRC}
124133
)
125134

126135
target_include_directories(app_lib PUBLIC
127136
${CMAKE_CURRENT_SOURCE_DIR}/deps/BLAKE2/ref
128137
${CMAKE_CURRENT_SOURCE_DIR}/deps/ledger-zxlib/include
129138
${CMAKE_CURRENT_SOURCE_DIR}/deps/tinycbor/src
130139
${CMAKE_CURRENT_SOURCE_DIR}/deps/picohash/
140+
${CMAKE_CURRENT_SOURCE_DIR}/deps/nanopb_tiny/
131141
${CMAKE_CURRENT_SOURCE_DIR}/app/src
132142
${CMAKE_CURRENT_SOURCE_DIR}/app/src/candid
133143
${CMAKE_CURRENT_SOURCE_DIR}/app/src/lib
@@ -146,6 +156,7 @@ target_include_directories(unittests PRIVATE
146156
${CMAKE_CURRENT_SOURCE_DIR}/app/src/lib
147157
${CMAKE_CURRENT_SOURCE_DIR}/deps/tinycbor/src
148158
${CMAKE_CURRENT_SOURCE_DIR}/deps/picohash/
159+
${CMAKE_CURRENT_SOURCE_DIR}/deps/nanopb_tiny/
149160
)
150161

151162

@@ -165,6 +176,7 @@ set_tests_properties(unittests PROPERTIES WORKING_DIRECTORY ${CMAKE_CURRENT_SOUR
165176
if (ENABLE_FUZZING)
166177
set(FUZZ_TARGETS
167178
parser_parse
179+
parser_protobuf
168180
)
169181

170182
foreach (target ${FUZZ_TARGETS})

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ ZXLIB_COMPILE_STAX ?= 1
2727
PRODUCTION_BUILD ?= 1
2828
include $(CURDIR)/deps/ledger-zxlib/dockerized_build.mk
2929

30+
proto:
31+
cd $(CURDIR)/app/src/protobuf && $(CURDIR)/deps/nanopb/generator/protoc ./base_types.proto ./types.proto ./governance.proto ./dfinity.proto --nanopb_out=.
32+
3033
else
3134
default:
3235
$(MAKE) -C app

app/Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ endif
6868

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

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

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

86+
CFLAGS += -I$(MY_DIR)/../deps/nanopb/
87+
APP_SOURCE_PATH += $(MY_DIR)/../deps/nanopb_tiny/
88+
8689
.PHONY: rust
8790
rust:
8891
@echo "No rust code"

app/Makefile.version

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This is the major version of this release
22
APPVERSION_M=3
33
# This is the minor version of this release
4-
APPVERSION_N=0
4+
APPVERSION_N=1
55
# This is the patch version of this release
6-
APPVERSION_P=3
6+
APPVERSION_P=0

app/src/parser.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "timeutils.h"
2929
#include "parser_print_candid.h"
3030
#include "parser_print_helper.h"
31+
#include "parser_print_protobuf.h"
3132

3233
#if defined(TARGET_NANOX) || defined(TARGET_NANOS2) || defined(TARGET_STAX) || defined(TARGET_FLEX)
3334
// For some reason NanoX requires this function
@@ -200,6 +201,16 @@ parser_error_t parser_getItem(const parser_context_t *ctx,
200201
switch (parser_tx_obj.txtype) {
201202
case call: {
202203
switch (parser_tx_obj.tx_fields.call.method_type) {
204+
case pb_sendrequest:
205+
case pb_manageneuron:
206+
case pb_listneurons:
207+
case pb_claimneurons: {
208+
return parser_getItemProtobuf(displayIdx,
209+
outKey, outKeyLen,
210+
outVal, outValLen,
211+
pageIdx, pageCount);
212+
}
213+
203214
case candid_manageneuron:
204215
case candid_listneurons:
205216
case candid_updatenodeprovider:

0 commit comments

Comments
 (0)