Skip to content
This repository has been archived by the owner on Oct 18, 2024. It is now read-only.

Commit

Permalink
Upgrade to runtime 2022 (#37)
Browse files Browse the repository at this point in the history
* add support for 2.2022.x
* update testcases
* do not allow customizing reject
  • Loading branch information
jleni authored Aug 18, 2020
1 parent b72f89a commit d768d63
Show file tree
Hide file tree
Showing 12 changed files with 8,216 additions and 8,049 deletions.
4 changes: 2 additions & 2 deletions app/Makefile.version
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
APPVERSION_M=2
APPVERSION_N=2019
APPVERSION_P=5
APPVERSION_N=2022
APPVERSION_P=0
8 changes: 4 additions & 4 deletions app/src/apdu_handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ __Z_INLINE void handleGetAddr(volatile uint32_t *flags, volatile uint32_t *tx, u
if (requireConfirmation) {
app_fill_address();

view_review_init(addr_getItem, addr_getNumItems, app_reply_address, app_reject);
view_review_init(addr_getItem, addr_getNumItems, app_reply_address);
view_review_show();

*flags |= IO_ASYNCH_REPLY;
Expand Down Expand Up @@ -200,7 +200,7 @@ __Z_INLINE void handleSign(volatile uint32_t *flags, volatile uint32_t *tx, uint
}

CHECK_APP_CANARY()
view_review_init(tx_getItem, tx_getNumItems, app_sign, app_reject);
view_review_init(tx_getItem, tx_getNumItems, app_sign);
view_review_show();
*flags |= IO_ASYNCH_REPLY;
}
Expand Down Expand Up @@ -243,7 +243,7 @@ __Z_INLINE void handleAllowlistSetPublicKey(volatile uint32_t *flags, volatile u

zemu_log_stack("allowlist: try update pubkey");

view_review_init(allowlist_getItem, allowlist_getNumItems, app_allowlist_SetPublicKey, app_reject);
view_review_init(allowlist_getItem, allowlist_getNumItems, app_allowlist_SetPublicKey);
view_review_show();
*flags |= IO_ASYNCH_REPLY;
}
Expand Down Expand Up @@ -287,7 +287,7 @@ __Z_INLINE void handleAllowlistUpload(volatile uint32_t *flags, volatile uint32_
THROW(APDU_CODE_EXECUTION_ERROR);
}

view_review_init(allowlist_getItem, allowlist_getNumItems, app_allowlist_Upload, app_reject);
view_review_init(allowlist_getItem, allowlist_getNumItems, app_allowlist_Upload);
view_review_show();
*flags |= IO_ASYNCH_REPLY;
}
Expand Down
36 changes: 36 additions & 0 deletions app/src/substrate_dispatch.c
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,13 @@ __Z_INLINE parser_error_t _readMethod_grandpa_report_equivocation_unsigned(
return parser_ok;
}

__Z_INLINE parser_error_t _readMethod_grandpa_note_stalled(
parser_context_t *c, pd_grandpa_note_stalled_t *m) {
CHECK_ERROR(_readBlockNumber(c, &m->delay))
CHECK_ERROR(_readBlockNumber(c, &m->best_finalized_block_number))
return parser_ok;
}

__Z_INLINE parser_error_t _readMethod_imonline_heartbeat(
parser_context_t *c, pd_imonline_heartbeat_t *m) {
CHECK_ERROR(_readHeartbeat(c, &m->heartbeat))
Expand Down Expand Up @@ -1465,6 +1472,9 @@ parser_error_t _readMethodBasic(
case 2561: /* module 10 call 1 */
CHECK_ERROR(_readMethod_grandpa_report_equivocation_unsigned(c, &method->grandpa_report_equivocation_unsigned))
break;
case 2562: /* module 10 call 2 */
CHECK_ERROR(_readMethod_grandpa_note_stalled(c, &method->grandpa_note_stalled))
break;
case 2816: /* module 11 call 0 */
CHECK_ERROR(_readMethod_imonline_heartbeat(c, &method->imonline_heartbeat))
break;
Expand Down Expand Up @@ -2038,6 +2048,9 @@ parser_error_t _readMethod(
case 2561: /* module 10 call 1 */
CHECK_ERROR(_readMethod_grandpa_report_equivocation_unsigned(c, &method->basic.grandpa_report_equivocation_unsigned))
break;
case 2562: /* module 10 call 2 */
CHECK_ERROR(_readMethod_grandpa_note_stalled(c, &method->basic.grandpa_note_stalled))
break;
case 2816: /* module 11 call 0 */
CHECK_ERROR(_readMethod_imonline_heartbeat(c, &method->basic.imonline_heartbeat))
break;
Expand Down Expand Up @@ -2562,6 +2575,7 @@ const char * _getMethod_Name(uint8_t moduleIdx, uint8_t callIdx) {
case 2304: /* module 9 call 0 */ return "Final hint";
case 2560: /* module 10 call 0 */ return "Report equivocation";
case 2561: /* module 10 call 1 */ return "Report equivocation unsigned";
case 2562: /* module 10 call 2 */ return "Note stalled";
case 2816: /* module 11 call 0 */ return "Heartbeat";
case 3328: /* module 13 call 0 */ return "Propose";
case 3329: /* module 13 call 1 */ return "Second";
Expand Down Expand Up @@ -2763,6 +2777,7 @@ uint8_t _getMethod_NumItems(uint8_t moduleIdx, uint8_t callIdx, pd_Method_t *met
case 2304: /* module 9 call 0 */ return 1;
case 2560: /* module 10 call 0 */ return 2;
case 2561: /* module 10 call 1 */ return 2;
case 2562: /* module 10 call 2 */ return 2;
case 2816: /* module 11 call 0 */ return 2;
case 3328: /* module 13 call 0 */ return 2;
case 3329: /* module 13 call 1 */ return 2;
Expand Down Expand Up @@ -3197,6 +3212,12 @@ const char * _getMethod_ItemName(uint8_t moduleIdx, uint8_t callIdx, uint8_t ite
case 1: return "Key owner proof";
default: return NULL;
}
case 2562: /* module 10 call 2 */
switch(itemIdx) {
case 0: return "Delay";
case 1: return "Best finalized block number";
default: return NULL;
}
case 2816: /* module 11 call 0 */
switch(itemIdx) {
case 0: return "Heartbeat";
Expand Down Expand Up @@ -4660,6 +4681,21 @@ parser_error_t _getMethod_ItemValue(
default:
return parser_no_data;
}
case 2562: /* module 10 call 2 */
switch(itemIdx) {
case 0: /* grandpa_note_stalled - delay */;
return _toStringBlockNumber(
&m->basic.grandpa_note_stalled.delay,
outValue, outValueLen,
pageIdx, pageCount);
case 1: /* grandpa_note_stalled - best_finalized_block_number */;
return _toStringBlockNumber(
&m->basic.grandpa_note_stalled.best_finalized_block_number,
outValue, outValueLen,
pageIdx, pageCount);
default:
return parser_no_data;
}
case 2816: /* module 11 call 0 */
switch(itemIdx) {
case 0: /* imonline_heartbeat - heartbeat */;
Expand Down
7 changes: 7 additions & 0 deletions app/src/substrate_methods.h
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,12 @@ typedef struct {
pd_KeyOwnerProof_t key_owner_proof;
} pd_grandpa_report_equivocation_unsigned_t;

#define PD_CALL_GRANDPA_NOTE_STALLED 2
typedef struct {
pd_BlockNumber_t delay;
pd_BlockNumber_t best_finalized_block_number;
} pd_grandpa_note_stalled_t;

#define PD_CALL_IMONLINE_HEARTBEAT 0
typedef struct {
pd_Heartbeat_t heartbeat;
Expand Down Expand Up @@ -1178,6 +1184,7 @@ typedef union {
pd_finalitytracker_final_hint_t finalitytracker_final_hint;
pd_grandpa_report_equivocation_t grandpa_report_equivocation;
pd_grandpa_report_equivocation_unsigned_t grandpa_report_equivocation_unsigned;
pd_grandpa_note_stalled_t grandpa_note_stalled;
pd_imonline_heartbeat_t imonline_heartbeat;
pd_democracy_propose_t democracy_propose;
pd_democracy_second_t democracy_second;
Expand Down
10 changes: 3 additions & 7 deletions deps/ledger-zxlib/app/common/view.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

view_t viewdata;

void h_accept(unsigned int _) {
void h_approve(unsigned int _) {
UNUSED(_);
view_idle_show(0);
UX_WAIT();
Expand All @@ -49,9 +49,7 @@ void h_reject(unsigned int _) {
UNUSED(_);
view_idle_show(0);
UX_WAIT();
if (viewdata.viewfuncReject != NULL) {
viewdata.viewfuncReject();
}
app_reject();
}

void h_error_accept(unsigned int _) {
Expand Down Expand Up @@ -184,12 +182,10 @@ void view_idle_show(uint8_t item_idx) {

void view_review_init(viewfunc_getItem_t viewfuncGetItem,
viewfunc_getNumItems_t viewfuncGetNumItems,
viewfunc_accept_t viewfuncAccept,
viewfunc_reject_t viewfuncReject) {
viewfunc_accept_t viewfuncAccept) {
viewdata.viewfuncGetItem = viewfuncGetItem;
viewdata.viewfuncGetNumItems = viewfuncGetNumItems;
viewdata.viewfuncAccept = viewfuncAccept;
viewdata.viewfuncReject = viewfuncReject;
}

void view_review_show() {
Expand Down
5 changes: 1 addition & 4 deletions deps/ledger-zxlib/app/common/view.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ typedef zxerr_t (*viewfunc_getItem_t)(int8_t displayIdx,

typedef void (*viewfunc_accept_t)();

typedef void (*viewfunc_reject_t)();

/// view_init (initializes UI)
void view_init();

Expand All @@ -50,7 +48,6 @@ void view_error_show();

void view_review_init(viewfunc_getItem_t viewfuncGetItem,
viewfunc_getNumItems_t viewfuncGetNumItems,
viewfunc_accept_t viewfuncAccept,
viewfunc_reject_t viewfuncReject);
viewfunc_accept_t viewfuncAccept);

void view_review_show();
3 changes: 1 addition & 2 deletions deps/ledger-zxlib/app/common/view_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ typedef struct {
viewfunc_getItem_t viewfuncGetItem;
viewfunc_getNumItems_t viewfuncGetNumItems;
viewfunc_accept_t viewfuncAccept;
viewfunc_reject_t viewfuncReject;

uint8_t itemIdx;
uint8_t itemCount;
Expand Down Expand Up @@ -94,7 +93,7 @@ void h_paging_decrease();

void view_review_show_impl();

void h_accept(unsigned int _);
void h_approve(unsigned int _);

void h_reject(unsigned int _);

Expand Down
2 changes: 1 addition & 1 deletion deps/ledger-zxlib/app/common/view_s.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const ux_menu_entry_t menu_main[] = {
};

const ux_menu_entry_t menu_decision_review[] = {
{NULL, h_accept, 0, NULL, "Approve", NULL, 0, 0},
{NULL, h_approve, 0, NULL, "Approve", NULL, 0, 0},
{NULL, h_reject, 0, NULL, "Reject", NULL, 0, 0},
UX_MENU_END
};
Expand Down
43 changes: 8 additions & 35 deletions deps/ledger-zxlib/app/common/view_x.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,33 +72,19 @@ UX_FLOW(
);

///////////

UX_STEP_INIT(ux_review_flow_2_start_step, NULL, NULL, { h_review_loop_start(); });
UX_STEP_NOCB_INIT(ux_review_flow_2_step, bnnn_paging, { h_review_loop_inside(); }, { .title = viewdata.key, .text = viewdata.value, });
UX_STEP_INIT(ux_review_flow_2_end_step, NULL, NULL, { h_review_loop_end(); });
UX_STEP_VALID(ux_review_flow_3_step, pb, h_approve(0), { &C_icon_validate_14, "Approve" });
UX_STEP_VALID(ux_review_flow_4_step, pb, h_reject(0), { &C_icon_crossmark, "Reject" });

UX_STEP_NOCB(ux_sign_flow_1_step, pbb, { &C_icon_eye, "View", "Transaction" });
UX_STEP_VALID(ux_sign_flow_3_step, pbb, h_sign_accept(0), { &C_icon_validate_14, "Sign", "Transaction" });
UX_STEP_VALID(ux_sign_flow_4_step, pbb, h_sign_reject(0), { &C_icon_crossmark, "Reject", "Transaction" });

const ux_flow_step_t *const ux_sign_flow[] = {
&ux_sign_flow_1_step,
&ux_review_flow_2_start_step,
&ux_review_flow_2_step,
&ux_review_flow_2_end_step,
&ux_sign_flow_3_step,
&ux_sign_flow_4_step,
FLOW_END_STEP,
};

UX_STEP_NOCB(ux_address_flow_1_step, pbb, { &C_icon_eye, "View", "Address" });
UX_STEP_VALID(ux_address_flow_3_step, pbb, h_address_accept(0), { &C_icon_validate_14, "Accept", "Address" });

const ux_flow_step_t *const ux_address_flow[] = {
&ux_address_flow_1_step,
const ux_flow_step_t *const ux_review_flow[] = {
&ux_review_flow_2_start_step,
&ux_review_flow_2_step,
&ux_review_flow_2_end_step,
&ux_address_flow_3_step,
&ux_review_flow_3_step,
&ux_review_flow_4_step,
FLOW_END_STEP,
};

Expand Down Expand Up @@ -212,27 +198,15 @@ void view_idle_show_impl(uint8_t item_idx) {
ux_flow_init(0, ux_idle_flow, NULL);
}

void view_address_show_impl() {
h_paging_init();
h_paging_decrease();

////
flow_inside_loop = 0;
if(G_ux.stack_count == 0) {
ux_stack_push();
}
ux_flow_init(0, ux_address_flow, NULL);
}

void view_sign_show_impl(){
void view_review_show_impl(){
h_paging_init();
h_paging_decrease();
////
flow_inside_loop = 0;
if(G_ux.stack_count == 0) {
ux_stack_push();
}
ux_flow_init(0, ux_sign_flow, NULL);
ux_flow_init(0, ux_review_flow, NULL);
}

void view_error_show_impl() {
Expand All @@ -242,5 +216,4 @@ void view_error_show_impl() {
}
ux_flow_init(0, ux_error_flow, NULL);
}

#endif
2 changes: 1 addition & 1 deletion deps/ledger-zxlib/include/zxversion.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@

#define ZXLIB_MAJOR 5
#define ZXLIB_MINOR 0
#define ZXLIB_PATCH 0
#define ZXLIB_PATCH 1
Loading

0 comments on commit d768d63

Please sign in to comment.