Skip to content

Commit

Permalink
Merge pull request #38 from Zondax/dev
Browse files Browse the repository at this point in the history
P3 actions support
  • Loading branch information
neithanmo authored Feb 3, 2025
2 parents 9744f90 + 4d261f3 commit 9f57b82
Show file tree
Hide file tree
Showing 530 changed files with 12,582 additions and 5,330 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ jobs:
make zemu_test
- name: Upload Snapshots (only failure)
if: ${{ failure() }}
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: snapshots-tmp
path: tests_zemu/snapshots-tmp/
Expand Down
10 changes: 9 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,12 @@ file(GLOB_RECURSE LIB_SRC
${CMAKE_CURRENT_SOURCE_DIR}/app/src/plan/ics20_withdrawal.c
${CMAKE_CURRENT_SOURCE_DIR}/app/src/plan/undelegate_claim.c
${CMAKE_CURRENT_SOURCE_DIR}/app/src/plan/delegator_vote.c
${CMAKE_CURRENT_SOURCE_DIR}/app/src/plan/position_open.c
${CMAKE_CURRENT_SOURCE_DIR}/app/src/plan/position_close.c
${CMAKE_CURRENT_SOURCE_DIR}/app/src/plan/position_withdraw.c
${CMAKE_CURRENT_SOURCE_DIR}/app/src/plan/action_dutch_auction_schedule.c
${CMAKE_CURRENT_SOURCE_DIR}/app/src/plan/action_dutch_auction_end.c
${CMAKE_CURRENT_SOURCE_DIR}/app/src/plan/action_dutch_auction_withdraw.c
)

add_library(app_lib STATIC ${LIB_SRC})
Expand Down Expand Up @@ -243,7 +249,9 @@ if(ENABLE_FUZZING)

foreach(target ${FUZZ_TARGETS})
add_executable(fuzz-${target} ${CMAKE_CURRENT_SOURCE_DIR}/fuzz/${target}.cpp)
target_link_libraries(fuzz-${target} PRIVATE app_lib)
target_link_libraries(fuzz-${target} PRIVATE
app_lib
rslib)
target_link_options(fuzz-${target} PRIVATE "-fsanitize=fuzzer")
endforeach()
else()
Expand Down
70 changes: 19 additions & 51 deletions app/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,9 @@ endif

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

include $(CURDIR)/../deps/ledger-zxlib/makefiles/Makefile.installer_script

include $(BOLOS_SDK)/Makefile.defines

# Set the default value for PRODUCTION_BUILD to 0 if not already defined
PRODUCTION_BUILD ?= 1

$(info ************ PENUMBRA_NAME = [$(TARGET_NAME)])

# Display whether this is a production build or for internal use
ifeq ($(PRODUCTION_BUILD), 1)
$(info ************ PRODUCTION_BUILD = [PRODUCTION BUILD])
Expand All @@ -39,9 +33,8 @@ else
endif

# Display whether swap functionality is enabled or not
ifdef HAVE_SWAP
ifeq ($(ENABLE_SWAP), 1)
$(info ************ HAVE_SWAP = [ENABLED])
DEFINES += HAVE_SWAP=$(HAVE_SWAP)
else
$(info ************ HAVE_SWAP = [DISABLED])
endif
Expand All @@ -55,6 +48,9 @@ ifndef COIN
COIN=UM
endif

VARIANT_PARAM=COIN
VARIANT_VALUES=$(COIN)

include $(CURDIR)/Makefile.version

$(info COIN = [$(COIN)])
Expand All @@ -78,12 +74,7 @@ $(info PATHS LIST = $(APPPATH))

APP_LOAD_PARAMS = --curve secp256k1 $(COMMON_LOAD_PARAMS) --path $(APPPATH)
INCLUDES_PATH += $(CURDIR)/src/protobuf

ifeq ($(TARGET_NAME),TARGET_NANOS)
APP_STACK_MIN_SIZE := 1600
else
APP_STACK_MIN_SIZE := 1752
endif
INCLUDES_PATH += $(CURDIR)/src/common

# Flag to compile all Penumbra actions
FULL_APP ?= 0
Expand All @@ -92,53 +83,39 @@ DEFINES += FULL_APP
$(info ************ FULL APP ENABLED ************)
endif

include $(CURDIR)/../deps/ledger-zxlib/makefiles/Makefile.devices

$(info TARGET_NAME = [$(TARGET_NAME)])
$(info ICONNAME = [$(ICONNAME)])

ifndef ICONNAME
$(error ICONNAME is not set)
endif

ifeq ($(TARGET_NAME),TARGET_NANOS)
RUST_TARGET:=thumbv6m-none-eabi
endif

ifeq ($(TARGET_NAME),TARGET_NANOX)
RUST_TARGET:=thumbv6m-none-eabi
endif

ifeq ($(TARGET_NAME),TARGET_NANOS2)
#RUST_TARGET:=thumbv8m.main-none-eabi
RUST_TARGET:=thumbv6m-none-eabi
endif
$(info ************ RUST_TARGET = [$(RUST_TARGET)])

ifeq ($(TARGET_NAME),TARGET_STAX)
RUST_TARGET:=thumbv6m-none-eabi
endif
include $(BOLOS_SDK)/Makefile.target

ifeq ($(TARGET_NAME),TARGET_FLEX)
RUST_TARGET:=thumbv6m-none-eabi
endif

$(info ************ RUST_TARGET = [$(RUST_TARGET)])
include $(CURDIR)/../deps/ledger-zxlib/makefiles/Makefile.devices

include $(CURDIR)/../deps/ledger-zxlib/makefiles/Makefile.platform

APP_SOURCE_PATH += $(CURDIR)/rust/include
CFLAGS += -Wvla
LDFLAGS += -z muldefs
LDLIBS += -lm -lgcc -lc
LDLIBS += -L$(MY_DIR)rust/target/$(RUST_TARGET)/release -lrslib

include $(CURDIR)/../deps/ledger-zxlib/makefiles/Makefile.installer_script

$(info TARGET_NAME = [$(TARGET_NAME)])
$(info ICONNAME = [$(ICONNAME)])

ifndef ICONNAME
$(error ICONNAME is not set)
endif

ifeq ($(DEBUG), 1)
CFLAGS += -O3 -Os -Wno-unknown-pragmas -Wno-unused-parameter -g
else
CFLAGS += -O3 -Os -Wno-unknown-pragmas -Wno-unused-parameter
endif

APP_CUSTOM_LINK_DEPENDENCIES = rust
# make rust a prerequisite for all object files
$(OBJECT_FILES): rust

.PHONY: rust
rust:
Expand All @@ -157,18 +134,9 @@ rust_clean:

clean: rust_clean

include $(CURDIR)/../deps/ledger-zxlib/makefiles/Makefile.side_loading

# 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 UM

.PHONY: version
version:
@echo "v$(APPVERSION)" > app.version
2 changes: 1 addition & 1 deletion app/Makefile.version
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ APPVERSION_M=0
# This is the minor version
APPVERSION_N=1
# This is the patch version
APPVERSION_P=1
APPVERSION_P=2
37 changes: 2 additions & 35 deletions app/rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions app/rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ crate-type = ["staticlib"]
rand = { version = "0.7.3", default-features = false }
nom = { version = "7.1.3", default-features = false }
arrayvec = { version = "0.7.4", default-features = false }
arrayref = { version = "0.3.7", default-features = false }
no-std-compat = "0.4.1"
educe = "0.5.9"
blake2b_simd = { version = "1.0.2", default-features = false }
# blake2b_simd = { path = "../blake2_simd/blake2b", default-features = false }
aes = { version = "0.8.4", default-features = false }
Expand All @@ -35,6 +33,7 @@ chacha20poly1305 = { version = "0.10.1", default-features = false }
rand_chacha = { version = "0.3.1", default-features = false }
ethnum = { version = "1.3", default-features = false }
itoa = { version = "1.0.1", default-features = false }
cfg-if = "1.0.0"

[dev-dependencies]
hex = "0.4.2"
Expand All @@ -51,13 +50,14 @@ panic-halt = "0.2.0"
codegen-units = 1
debug = false
opt-level = "z"
panic = "abort"
# lto = false
# Settings below aimed to reduce
# binary size due to code
lto = "fat"
# lto = "fat"
lto = "thin"
overflow-checks = false
strip = "symbols"
panic = "abort"

[profile.dev]
lto = false
Expand All @@ -70,4 +70,4 @@ derive-debug = []
cpp_tests = []
# use when compiling this crate as a lib for the full_app suite
full_app = []
fuzzing = []
fuzzing = []
3 changes: 3 additions & 0 deletions app/rust/include/rslib.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ parser_error_t rs_output_action_hash(output_plan_t *plan, bytes_t *memo_key, uin
parser_error_t rs_swap_action_hash(swap_plan_t *plan, uint8_t *output, size_t output_len);
parser_error_t rs_undelegate_claim_action_hash(undelegate_claim_plan_t *plan, uint8_t *output, size_t output_len);
parser_error_t rs_delegator_vote_action_hash(delegator_vote_plan_t *plan, uint8_t *output, size_t output_len);
parser_error_t rs_position_withdraw_action_hash(position_withdraw_plan_t *plan, uint8_t *output, size_t output_len);
parser_error_t rs_action_dutch_auction_withdraw_action_hash(action_dutch_auction_withdraw_plan_t *plan, uint8_t *output,
size_t output_len);
parser_error_t rs_generic_action_hash(bytes_t *data, uint8_t action_type, uint8_t *output, size_t output_len);

parser_error_t rs_get_asset_id_from_metadata(const bytes_t *metadata, uint8_t *asset_id, uint16_t asset_id_len);
Expand Down
Loading

0 comments on commit 9f57b82

Please sign in to comment.