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

Fix minor ledger reported issues #107

Merged
merged 5 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 0 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,4 @@ all: show-app default
show-app:
@echo ">>>>> Building at commit $(COMMIT)"

CFLAGS += -Wno-incompatible-pointer-types-discards-qualifiers

include $(BOLOS_SDK)/Makefile.standard_app
13 changes: 12 additions & 1 deletion doc/apdu.md
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,10 @@ accepted, the signature of the message is returned.

Messages sent in more than one packet will be refused.

If the `message` is a valid `baking message` (`Block` or `Consensus
operation`), no confirmation screens will be displayed and the
signature will be automatic.

See [the messages in the specification](signing.md#messages) and the [API](https://tezos.gitlab.io/shell/p2p_api.html).

##### Input data
Expand Down Expand Up @@ -428,4 +432,11 @@ fixed message signed by the key associated with the `path` and `P2`.
|--------|--------|------|------|
| `0x80` | `0x0e` | `__` | `__` |

Alias for `SIGN`
Runs in the same way as `SIGN` except that the value returned, when *P1* is `0x01` or `0x81`, also contains the hash of the signed operation.

#### Output data

| Length | Description |
|--------------|---------------|
| `32` | The hash |
| `<variable>` | The signature |
10 changes: 3 additions & 7 deletions src/to_string.c
Original file line number Diff line number Diff line change
Expand Up @@ -274,15 +274,11 @@ int microtez_to_string(char *const dest, size_t dest_size, uint64_t number) {

// Eliminate trailing 0s
char *start = tmp + sizeof(tmp) - DECIMAL_DIGITS;
char *end;
for (end = tmp + sizeof(tmp) - 1u; end >= start; end--) {
if (*end != '0') {
end++;
break;
}
size_t length = DECIMAL_DIGITS;
while ((length > 0u) && (start[length - 1u] == '0')) {
length--;
}

size_t length = end - start;
if ((dest_size - offset) < length) {
return -1;
}
Expand Down
8 changes: 4 additions & 4 deletions src/to_string.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,13 @@ int hwm_to_string(char *dest, size_t dest_size, high_watermark_t const *const hw
int hwm_status_to_string(char *dest, size_t dest_size, volatile bool const *hwm_disabled);

/**
* @brief Copies a string in a buffer
* @brief Copies a string in a buffer.
*
* `src` may be unrelocated pointer to rodata.
* Returns -1 if the string is too large to fit in the buffer
*
* @param dest: output buffer
* @param dest_size: size of the buffer
* @param src: input to copy
* @param dest_size: size of the output buffer
* @param src: string to copy
* @return int: size of the result, negative integer on failure
*/
int copy_string(char *const dest, size_t const dest_size, char const *const src);
4 changes: 2 additions & 2 deletions src/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ typedef struct {
* @param in: bip32 path copied
* @return bool: whether the copy was successful or not
*/
static inline bool copy_bip32_path(bip32_path_t *const out, bip32_path_t volatile const *const in) {
static inline bool copy_bip32_path(bip32_path_t *const out, bip32_path_t const *const in) {
if ((out == NULL) || (in == NULL)) {
return false;
}
Expand Down Expand Up @@ -152,7 +152,7 @@ typedef struct {
* @return bool: whether the copy was successful or not
*/
static inline bool copy_bip32_path_with_curve(bip32_path_with_curve_t *const out,
bip32_path_with_curve_t volatile const *const in) {
bip32_path_with_curve_t const *const in) {
if ((out == NULL) || (in == NULL) || !copy_bip32_path(&out->bip32_path, &in->bip32_path)) {
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/ui_nbgl.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ static bool navigation_cb_baking(uint8_t page, nbgl_pageContent_t* content) {
content->type = INFOS_LIST;
content->infosList.nbInfos = 3;
content->infosList.infoTypes = bakeInfoTypes;
content->infosList.infoContents = bakeInfoContents;
content->infosList.infoContents = (const char* const*) bakeInfoContents;
break;
case 1:
switches[HWM_ENABLED_TOKEN_ID].initState = (nbgl_state_t) (!hwm_disabled);
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 38 additions & 0 deletions test/test_instructions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1086,6 +1086,44 @@ def test_sign_delegation(
account.check_signature(signature, bytes(raw_delegation))



PARAMETERS_SIGN_DELEGATION_FEES = [
1,
20000,
300000000,
50000060000,
789789789
]

@pytest.mark.parametrize("fee", PARAMETERS_SIGN_DELEGATION_FEES)
def test_sign_delegation_fee(
fee: int,
tezos_navigator: TezosNavigator) -> None:
"""Test fee display on delegation."""

account = DEFAULT_ACCOUNT
snap_path = Path(f"fee_{fee}")

tezos_navigator.setup_app_context(
account,
DEFAULT_CHAIN_ID,
main_hwm=Hwm(0, 0),
test_hwm=Hwm(0, 0)
)

delegation = Delegation(
delegate=account.public_key_hash,
source=account.public_key_hash,
fee=fee,
)

tezos_navigator.sign_delegation(
account,
delegation,
snap_path=snap_path
)


PARAMETERS_SIGN_DELEGATION_CONSTRAINTS = [
(
DEFAULT_ACCOUNT_2, DEFAULT_ACCOUNT, DEFAULT_ACCOUNT, DEFAULT_ACCOUNT,
Expand Down
Loading