Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parser #1

Merged
merged 30 commits into from
Jun 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
4fd9f57
[ledger-blockstack] Initial parser implementation, Rust files
neithanmo Jun 16, 2020
9c3561b
[ledger-blockstack] rust formatting implementation
neithanmo Jun 16, 2020
7387573
[ledger-blockstack] Initial parser implementation - c files
neithanmo Jun 16, 2020
6ca2eda
Added some spending-contition tests
neithanmo Jun 18, 2020
194ca49
Added two post-condition tests
neithanmo Jun 18, 2020
c2160be
Test for token transfer payloads
neithanmo Jun 18, 2020
ee7e1fa
Check if a transaction has a standard auth field which enable token-t…
neithanmo Jun 18, 2020
5b592aa
[ledger-blockstack] Initial parser implementation, Rust files
neithanmo Jun 16, 2020
93284f3
[ledger-blockstack] rust formatting implementation
neithanmo Jun 16, 2020
07cc029
[ledger-blockstack] Initial parser implementation - c files
neithanmo Jun 16, 2020
d209c6e
Added some spending-contition tests
neithanmo Jun 18, 2020
9fa3f55
Added two post-condition tests
neithanmo Jun 18, 2020
1c74085
Test for token transfer payloads
neithanmo Jun 18, 2020
3627af8
Check if a transaction has a standard auth field which enable token-t…
neithanmo Jun 18, 2020
d4c4f31
disable zemu signing test
jleni Jun 18, 2020
72ba50e
improve JS implementation
jleni Jun 18, 2020
062bda7
correct JS naming
jleni Jun 18, 2020
3839331
Merging from latest Parser
neithanmo Jun 19, 2020
bb80b81
Fixing minor issues which were about hex crate version, parser state …
neithanmo Jun 19, 2020
94adb44
Added calls to the canary checker - aso, fixed some clippy warnings
neithanmo Jun 20, 2020
c92776f
Lets start with TokenTransfer payload first - the other payloads woul…
neithanmo Jun 20, 2020
221a608
Adapted the base32-check blockstack's address encoder
neithanmo Jun 25, 2020
bad3cac
address get/show APDU
jleni Jun 27, 2020
b097099
upgrade zxlib + icons
jleni Jun 27, 2020
e3879e3
Fix CI issues
jleni Jun 27, 2020
d879f75
A global variable wrapper and pic macro
neithanmo Jun 28, 2020
ef86ded
New tests, debug, minor fixes according to cargo fmt
neithanmo Jun 28, 2020
ec12101
Restoring to previous cicleci config.yml
neithanmo Jun 28, 2020
84ac923
Adding missing test files
neithanmo Jun 28, 2020
f77aba6
updating zemu tests
jleni Jun 29, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 48 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,21 @@
version: 2
version: 2.1

commands:
restore-sccache-cache:
steps:
- restore_cache:
name: Restore sccache cache
key: sccache-cache-stable-{{ arch }}
# key: sccache-cache-stable-{{ arch }}-{{ .Environment.CIRCLE_JOB }}
save-sccache-cache:
steps:
- save_cache:
name: Save sccache cache
# key: sccache-cache-stable-{{ arch }}-{{ .Environment.CIRCLE_JOB }}-{{ epoch }}
key: sccache-cache-stable-{{ arch }}-{{ epoch }}
paths:
- "~/.cache/sccache"

jobs:
build:
docker:
Expand Down Expand Up @@ -27,7 +44,34 @@ jobs:
source /home/zondax/.cargo/env
cd /home/zondax/project
make

build_rust:
docker:
- image: zondax/rust-ci:latest
steps:
- checkout
- run:
name: rustfmt
command: |
cd ~/project/app/rust
cargo fmt --version
cargo fmt -- --check
- run:
name: clippy
command: |
cd ~/project/app/rust
cargo clippy --version
cargo clippy --all-features --all-targets || true
- run:
name: audit
command: |
cd ~/project/app/rust
cargo audit --version
cargo audit
- run:
name: run tests
command: |
cd ~/project/app/rust
cargo test
test_zemu:
machine:
image: ubuntu-1604:201903-01
Expand Down Expand Up @@ -57,7 +101,6 @@ jobs:
command: |
nvm use 13.12.0
make zemu_test

build_package:
docker:
- image: zondax/builder-bolos:latest
Expand All @@ -83,14 +126,15 @@ workflows:
default:
jobs:
- build
- build_rust
- build_ledger
- test_zemu
- build_package:
requires:
- build
- build_rust
- build_ledger
- test_zemu
filters:
branches:
only:
- master
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,7 @@ cmake-build-fuzz/
yarn.lock
!/tests_zemu/yarn.lock
!/tests_zemu/yarn-error.log

app/tmp.gif

app/tmp.gif~
55 changes: 0 additions & 55 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,58 +25,3 @@ add_subdirectory(cmake/gtest)

string(APPEND CMAKE_CXX_FLAGS " -fsanitize=address -fno-omit-frame-pointer")
string(APPEND CMAKE_LINKER_FLAGS " -fsanitize=address -fno-omit-frame-pointer")

add_definitions(-DAPP_STANDARD)

##############################################################
##############################################################
# static libs
file(GLOB_RECURSE OTHERLIBS_SRC
)

file(GLOB_RECURSE LIB_SRC
${CMAKE_CURRENT_SOURCE_DIR}/deps/BLAKE2/ref/blake2b-ref.c
${CMAKE_CURRENT_SOURCE_DIR}/deps/ledger-zxlib/src/hexutils.c
${CMAKE_CURRENT_SOURCE_DIR}/deps/ledger-zxlib/src/bignum.c
${CMAKE_CURRENT_SOURCE_DIR}/deps/ledger-zxlib/src/zxmacros.c
${CMAKE_CURRENT_SOURCE_DIR}/deps/ledger-zxlib/hexutils.c
#########
${CMAKE_CURRENT_SOURCE_DIR}/app/src/parser.c
${CMAKE_CURRENT_SOURCE_DIR}/app/src/parser_impl.c
)

add_library(app_lib STATIC
${LIB_SRC}
${OTHERLIBS_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}/app/src
${CMAKE_CURRENT_SOURCE_DIR}/app/src/lib
)

##############################################################
##############################################################
# Tests
file(GLOB_RECURSE TESTS_SRC
${CMAKE_CURRENT_SOURCE_DIR}/tests/*.cpp)

add_executable(unittests ${TESTS_SRC})
target_include_directories(unittests PUBLIC
${gtest_SOURCE_DIR}/include
${gmock_SOURCE_DIR}/include
${CONAN_INCLUDE_DIRS_FMT}
${CONAN_INCLUDE_DIRS_JSONCPP}
${CMAKE_CURRENT_SOURCE_DIR}/deps/BLAKE2/ref
)

target_link_libraries(unittests PRIVATE
gtest_main
app_lib
CONAN_PKG::fmt
CONAN_PKG::jsoncpp)

add_test(unittests ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/unittests)
set_tests_properties(unittests PROPERTIES WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/tests)
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ TESTS_ZEMU_JS_PACKAGE = "@zondax/ledger-blockstack"
TESTS_ZEMU_JS_DIR = $(CURDIR)/js

ifeq ($(BOLOS_SDK),)
include $(CURDIR)/deps/ledger-zxlib/dockerized_build.mk
include $(CURDIR)/deps/ledger-zxlib/dockerized_build.mk
else
default:
$(MAKE) -C app
Expand Down
72 changes: 42 additions & 30 deletions app/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,24 @@ endif

MY_DIR := $(dir $(lastword $(MAKEFILE_LIST)))

ifeq ($(APP_TESTING),1)
DEFINES += APP_TESTING
DEFINES += ZEMU_LOGGING
endif

all: bin/app.elf
@echo "#!/usr/bin/env bash" > $(CURDIR)/pkg/zxtool.sh
@echo "APPNAME=\"${APPNAME}\"" >> $(CURDIR)/pkg/zxtool.sh
@echo "APPVERSION=\"${APPVERSION}\"" >> $(CURDIR)/pkg/zxtool.sh
@echo "APPPATH=\""${APPPATH}"\"" >> $(CURDIR)/pkg/zxtool.sh
@echo "LOAD_PARAMS=\"${COMMON_LOAD_PARAMS}\"" >> $(CURDIR)/pkg/zxtool.sh
@echo "DELETE_PARAMS=\"${COMMON_DELETE_PARAMS}\"" >> $(CURDIR)/pkg/zxtool.sh
@echo "APPHEX=\"" >> $(CURDIR)/pkg/zxtool.sh
@cat $(CURDIR)/bin/app.hex >> $(CURDIR)/pkg/zxtool.sh
@echo "\"" >> $(CURDIR)/pkg/zxtool.sh
@cat $(CURDIR)/../deps/ledger-zxlib/scripts/template.sh >> $(CURDIR)/pkg/zxtool.sh
@chmod +x $(CURDIR)/pkg/zxtool.sh

include $(BOLOS_SDK)/Makefile.defines

ifndef COIN
Expand Down Expand Up @@ -66,38 +84,25 @@ ifndef ICONNAME
$(error ICONNAME is not set)
endif

all: default
@echo "#!/usr/bin/env bash" > $(CURDIR)/pkg/zxtool.sh
@echo "APPNAME=\"${APPNAME}\"" >> $(CURDIR)/pkg/zxtool.sh
@echo "APPVERSION=\"${APPVERSION}\"" >> $(CURDIR)/pkg/zxtool.sh
@echo "APPPATH=\""${APPPATH}"\"" >> $(CURDIR)/pkg/zxtool.sh
@echo "LOAD_PARAMS=\"${COMMON_LOAD_PARAMS}\"" >> $(CURDIR)/pkg/zxtool.sh
@echo "DELETE_PARAMS=\"${COMMON_DELETE_PARAMS}\"" >> $(CURDIR)/pkg/zxtool.sh
@echo "APPHEX=\"" >> $(CURDIR)/pkg/zxtool.sh
@cat $(CURDIR)/bin/app.hex >> $(CURDIR)/pkg/zxtool.sh
@echo "\"" >> $(CURDIR)/pkg/zxtool.sh
@cat $(CURDIR)/../deps/ledger-zxlib/scripts/template.sh >> $(CURDIR)/pkg/zxtool.sh
@chmod +x $(CURDIR)/pkg/zxtool.sh

############
# Platform

DEFINES += UNUSED\(x\)=\(void\)x
DEFINES += PRINTF\(...\)=
DEFINES += UNUSED\(x\)=\(void\)x
DEFINES += PRINTF\(...\)=

APPVERSION=$(APPVERSION_M).$(APPVERSION_N).$(APPVERSION_P)
DEFINES += APPVERSION=\"$(APPVERSION)\"
DEFINES += APPVERSION=\"$(APPVERSION)\"

DEFINES += OS_IO_SEPROXYHAL
DEFINES += HAVE_BAGL HAVE_SPRINTF
DEFINES += HAVE_IO_USB HAVE_L4_USBLIB IO_USB_MAX_ENDPOINTS=7 IO_HID_EP_LENGTH=64 HAVE_USB_APDU

DEFINES += OS_IO_SEPROXYHAL
DEFINES += HAVE_BAGL HAVE_SPRINTF
DEFINES += HAVE_IO_USB HAVE_L4_USBLIB IO_USB_MAX_ENDPOINTS=7 IO_HID_EP_LENGTH=64 HAVE_USB_APDU
DEFINES += LEDGER_MAJOR_VERSION=$(APPVERSION_M) LEDGER_MINOR_VERSION=$(APPVERSION_N) LEDGER_PATCH_VERSION=$(APPVERSION_P)

DEFINES += LEDGER_MAJOR_VERSION=$(APPVERSION_M) LEDGER_MINOR_VERSION=$(APPVERSION_N) LEDGER_PATCH_VERSION=$(APPVERSION_P)
DEFINES += USB_SEGMENT_SIZE=64
DEFINES += HAVE_BOLOS_APP_STACK_CANARY
DEFINES += USB_SEGMENT_SIZE=64
DEFINES += HAVE_BOLOS_APP_STACK_CANARY

WEBUSB_URL = www.ledgerwallet.com
DEFINES += HAVE_WEBUSB WEBUSB_URL_SIZE_B=$(shell echo -n $(WEBUSB_URL) | wc -c) WEBUSB_URL=$(shell echo -n $(WEBUSB_URL) | sed -e "s/./\\\'\0\\\',/g")
DEFINES += HAVE_WEBUSB WEBUSB_URL_SIZE_B=0 WEBUSB_URL=""

ifeq ($(TARGET_NAME),TARGET_NANOX)
DEFINES += IO_SEPROXYHAL_BUFFER_SIZE_B=300
Expand All @@ -117,7 +122,7 @@ DEFINES += HAVE_BLE_APDU BLE_COMMAND_TIMEOUT_MS=2000
SDK_SOURCE_PATH += lib_blewbxx lib_blewbxx_impl
else
# Assume Nano S
DEFINES += IO_SEPROXYHAL_BUFFER_SIZE_B=128
DEFINES += IO_SEPROXYHAL_BUFFER_SIZE_B=64
DEFINES += COMPLIANCE_UX_160 HAVE_UX_LEGACY HAVE_UX_FLOW
endif

Expand Down Expand Up @@ -154,7 +159,8 @@ AFLAGS +=

LD := $(GCCPATH)arm-none-eabi-gcc
LDFLAGS += -O3 -Os -z muldefs
LDLIBS += -Lrust/target/thumbv6m-none-eabi/release -lrslib -lm -lgcc -lc
LDLIBS += -lm -lgcc -lc
LDLIBS += -Lrust/target/thumbv6m-none-eabi/release -lrslib

##########################
include $(BOLOS_SDK)/Makefile.glyphs
Expand All @@ -168,28 +174,34 @@ APP_SOURCE_PATH += $(MY_DIR)/../deps/ledger-zxlib/app/common
SDK_SOURCE_PATH += lib_stusb lib_stusb_impl
SDK_SOURCE_PATH += lib_ux

.PHONY: rust
rust:
cd rust && CARGO_HOME="$(CURDIR)/rust/.cargo" cargo build --target thumbv6m-none-eabi --release

# Before linking, we need to be sure rust lib is there
bin/app.elf: rust

.PHONY: rust_clean
rust_clean:
cd rust && CARGO_HOME="$(CURDIR)/rust/.cargo" cargo clean

clean: rust_clean

# load, delete and listvariants are provided to comply with Ledger requirements
.PHONY: load
load:
python -m ledgerblue.loadApp $(APP_LOAD_PARAMS)

.PHONY: delete
delete:
python -m ledgerblue.deleteApp $(COMMON_DELETE_PARAMS)

.PHONY: rust

all: default rust

# Import generic rules from the SDK
include $(BOLOS_SDK)/Makefile.rules

#add dependency on custom makefile filename
dep/%.d: %.c Makefile

.PHONY: listvariants
listvariants:
@echo VARIANTS COIN STX
Binary file modified app/glyphs/icon_app.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/nanos_icon.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/nanox_icon.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading