Skip to content

Commit

Permalink
Remove migrated-to-tenderbake as its redundant.
Browse files Browse the repository at this point in the history
  • Loading branch information
ajinkyaraj-23 committed Apr 5, 2024
1 parent 6302254 commit aab6b79
Show file tree
Hide file tree
Showing 181 changed files with 73 additions and 92 deletions.
21 changes: 6 additions & 15 deletions src/apdu_query.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,14 @@ int handle_query_all_hwm(void) {
write_u32_be(resp, offset, N_data.hwm.main.highest_level);
offset += sizeof(uint32_t);

bool has_a_chain_migrated =
N_data.hwm.main.migrated_to_tenderbake || N_data.hwm.test.migrated_to_tenderbake;

if (has_a_chain_migrated) {
write_u32_be(resp, offset, N_data.hwm.main.highest_round);
offset += sizeof(uint32_t);
}
write_u32_be(resp, offset, N_data.hwm.main.highest_round);
offset += sizeof(uint32_t);

write_u32_be(resp, offset, N_data.hwm.test.highest_level);
offset += sizeof(uint32_t);

if (has_a_chain_migrated) {
write_u32_be(resp, offset, N_data.hwm.test.highest_round);
offset += sizeof(uint32_t);
}
write_u32_be(resp, offset, N_data.hwm.test.highest_round);
offset += sizeof(uint32_t);

write_u32_be(resp, offset, N_data.main_chain_id.v);
offset += sizeof(uint32_t);
Expand All @@ -69,10 +62,8 @@ int handle_query_main_hwm(void) {
write_u32_be(resp, offset, N_data.hwm.main.highest_level);
offset += sizeof(uint32_t);

if (N_data.hwm.main.migrated_to_tenderbake) {
write_u32_be(resp, offset, N_data.hwm.main.highest_round);
offset += sizeof(uint32_t);
}
write_u32_be(resp, offset, N_data.hwm.main.highest_round);
offset += sizeof(uint32_t);

return io_send_response_pointer(resp, offset, SW_OK);
}
Expand Down
2 changes: 0 additions & 2 deletions src/apdu_setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,10 @@ static bool ok(void) {
ram->hwm.main.highest_round = 0;
ram->hwm.main.had_attestation = false;
ram->hwm.main.had_preattestation = false;
ram->hwm.main.migrated_to_tenderbake = false;
ram->hwm.test.highest_level = G.hwm.test;
ram->hwm.test.highest_round = 0;
ram->hwm.test.had_attestation = false;
ram->hwm.test.had_preattestation = false;
ram->hwm.test.migrated_to_tenderbake = false;
});

provide_pubkey(&global.path_with_curve);
Expand Down
1 change: 0 additions & 1 deletion src/baking_auth.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ tz_exc write_high_water_mark(parsed_baking_data_t const *const in) {
dest->highest_round = in->round;
dest->had_attestation |= in->type == BAKING_TYPE_ATTESTATION;
dest->had_preattestation |= in->type == BAKING_TYPE_PREATTESTATION;
dest->migrated_to_tenderbake |= in->is_tenderbake;
});

end:
Expand Down
28 changes: 12 additions & 16 deletions src/to_string.c
Original file line number Diff line number Diff line change
Expand Up @@ -305,25 +305,21 @@ int hwm_to_string(char *dest, size_t dest_size, high_watermark_t const *const hw
if (dest == NULL) {
return -1;
}
if (hwm->migrated_to_tenderbake) {
int result = number_to_string(dest, dest_size, hwm->highest_level);
if (result < 0) {
return result;
}
size_t offset = (size_t) result;

dest[offset] = ' ';
offset++;
int result = number_to_string(dest, dest_size, hwm->highest_level);
if (result < 0) {
return result;
}
size_t offset = (size_t) result;

result = number_to_string(dest + offset, dest_size - offset, hwm->highest_round);
if (result < 0) {
return result;
}
dest[offset] = ' ';
offset++;

return offset + (size_t) result;
} else {
return number_to_string(dest, dest_size, hwm->highest_level);
result = number_to_string(dest + offset, dest_size - offset, hwm->highest_round);
if (result < 0) {
return result;
}

return offset + (size_t) result;
}

int hwm_status_to_string(char *dest, size_t dest_size, volatile bool const *hwm_disabled) {
Expand Down
9 changes: 4 additions & 5 deletions src/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,11 +179,10 @@ static inline bool bip32_path_with_curve_eq(bip32_path_with_curve_t volatile con
*
*/
typedef struct {
level_t highest_level; ///< highest level seen
round_t highest_round; ///< highest round seen
bool had_attestation; ///< if an attestation has been seen at current level/round
bool had_preattestation; ///< if a pre-attestation has been seen at current level/round
bool migrated_to_tenderbake; ///< if chain has migrated to tenderbake
level_t highest_level; ///< highest level seen
round_t highest_round; ///< highest round seen
bool had_attestation; ///< if an attestation has been seen at current level/round
bool had_preattestation; ///< if a pre-attestation has been seen at current level/round
} high_watermark_t;

/**
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.
Binary file modified test/snapshots/nanos/test_review_home/high_watermark.png
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.
Binary file modified test/snapshots/nanosp/test_review_home/high_watermark.png
Binary file modified test/snapshots/nanox/test_review_home/high_watermark.png
Binary file modified test/snapshots/stax/test_deauthorize/app_context/app_context.png
Binary file modified test/snapshots/stax/test_review_home/app_context.png
96 changes: 48 additions & 48 deletions test/test_instructions.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ def test_review_home(account: Optional[Account],

if account is not None:
main_chain_id = "NetXH12AexHqTQa" # Chain = 1
main_hwm = Hwm(1)
test_hwm = Hwm(2)
main_hwm = Hwm(1,0)
test_hwm = Hwm(2,0)

tezos_navigator.setup_app_context(
account,
Expand Down Expand Up @@ -230,8 +230,8 @@ def test_ledger_screensaver(client: TezosClient, tezos_navigator: TezosNavigator

lvl = 0
main_chain_id = DEFAULT_CHAIN_ID
main_hwm = Hwm(lvl)
test_hwm = Hwm(0)
main_hwm = Hwm(lvl, 0)
test_hwm = Hwm(0, 0)

tezos_navigator.setup_app_context(
account,
Expand Down Expand Up @@ -259,8 +259,8 @@ def test_benchmark_attestation_time(account: Account, client: TezosClient, tezos

lvl = 0
main_chain_id = DEFAULT_CHAIN_ID
main_hwm = Hwm(lvl)
test_hwm = Hwm(0)
main_hwm = Hwm(lvl, 0)
test_hwm = Hwm(0, 0)

tezos_navigator.setup_app_context(
account,
Expand Down Expand Up @@ -295,8 +295,8 @@ def test_authorize_baking(account: Account, tezos_navigator: TezosNavigator) ->
tezos_navigator.check_app_context(
account,
chain_id=DEFAULT_CHAIN_ID,
main_hwm=Hwm(0),
test_hwm=Hwm(0),
main_hwm=Hwm(0, 0),
test_hwm=Hwm(0, 0),
snap_path=snap_path
)

Expand Down Expand Up @@ -327,8 +327,8 @@ def test_deauthorize(firmware: Firmware,
tezos_navigator.check_app_context(
None,
chain_id=DEFAULT_CHAIN_ID,
main_hwm=Hwm(0),
test_hwm=Hwm(0)
main_hwm=Hwm(0, 0),
test_hwm=Hwm(0, 0)
)

@pytest.mark.parametrize("account", ACCOUNTS)
Expand Down Expand Up @@ -401,8 +401,8 @@ def test_reset_app_context(tezos_navigator: TezosNavigator) -> None:
tezos_navigator.check_app_context(
None,
chain_id=DEFAULT_CHAIN_ID,
main_hwm=Hwm(reset_level),
test_hwm=Hwm(reset_level)
main_hwm=Hwm(reset_level, 0),
test_hwm=Hwm(reset_level, 0)
)


Expand All @@ -412,8 +412,8 @@ def test_setup_app_context(account: Account, tezos_navigator: TezosNavigator) ->
snap_path = Path(f"{account}")

main_chain_id = "NetXH12AexHqTQa" # Chain = 1
main_hwm = Hwm(1)
test_hwm = Hwm(2)
main_hwm = Hwm(1, 0)
test_hwm = Hwm(2, 0)

public_key = tezos_navigator.setup_app_context(
account,
Expand Down Expand Up @@ -442,8 +442,8 @@ def test_get_main_hwm(
"""Test the QUERY_MAIN_HWM instruction."""

main_chain_id = DEFAULT_CHAIN_ID
main_hwm = Hwm(0)
test_hwm = Hwm(0)
main_hwm = Hwm(0, 0)
test_hwm = Hwm(0, 0)

tezos_navigator.setup_app_context(
account,
Expand All @@ -466,8 +466,8 @@ def test_get_all_hwm(
"""Test the QUERY_ALL_HWM instruction."""

main_chain_id = DEFAULT_CHAIN_ID
main_hwm = Hwm(0)
test_hwm = Hwm(0)
main_hwm = Hwm(0, 0)
test_hwm = Hwm(0, 0)

tezos_navigator.setup_app_context(
account,
Expand Down Expand Up @@ -532,8 +532,8 @@ def test_sign_preattestation(
snap_path = Path(f"{account}")

main_chain_id = DEFAULT_CHAIN_ID
main_hwm = Hwm(0)
test_hwm = Hwm(0)
main_hwm = Hwm(0, 0)
test_hwm = Hwm(0, 0)

tezos_navigator.setup_app_context(
account,
Expand Down Expand Up @@ -590,8 +590,8 @@ def test_sign_attestation(
snap_path = Path(f"{account}")

main_chain_id = DEFAULT_CHAIN_ID
main_hwm = Hwm(0)
test_hwm = Hwm(0)
main_hwm = Hwm(0, 0)
test_hwm = Hwm(0, 0)

tezos_navigator.setup_app_context(
account,
Expand Down Expand Up @@ -647,8 +647,8 @@ def test_sign_attestation_dal(
snap_path = Path(f"{account}")

main_chain_id = DEFAULT_CHAIN_ID
main_hwm = Hwm(0)
test_hwm = Hwm(0)
main_hwm = Hwm(0, 0)
test_hwm = Hwm(0, 0)

tezos_navigator.setup_app_context(
account,
Expand Down Expand Up @@ -704,8 +704,8 @@ def test_sign_block(
snap_path = Path(f"{account}")

main_chain_id = DEFAULT_CHAIN_ID
main_hwm = Hwm(0)
test_hwm = Hwm(0)
main_hwm = Hwm(0, 0)
test_hwm = Hwm(0, 0)

tezos_navigator.setup_app_context(
account,
Expand Down Expand Up @@ -756,8 +756,8 @@ def test_sign_block_at_reset_level(client: TezosClient, tezos_navigator: TezosNa
reset_level: int = 1

main_chain_id = DEFAULT_CHAIN_ID
main_hwm = Hwm(reset_level)
test_hwm = Hwm(0)
main_hwm = Hwm(reset_level, 0)
test_hwm = Hwm(0, 0)

tezos_navigator.setup_app_context(
account,
Expand Down Expand Up @@ -823,8 +823,8 @@ def test_sign_level_authorized(
tezos_navigator.setup_app_context(
account,
main_chain_id,
main_hwm=Hwm(main_level),
test_hwm=Hwm(0)
main_hwm=Hwm(main_level, 0),
test_hwm=Hwm(0, 0)
)

level_1, round_1 = level_round_1
Expand Down Expand Up @@ -861,8 +861,8 @@ def test_sign_delegation(
tezos_navigator.setup_app_context(
account,
DEFAULT_CHAIN_ID,
main_hwm=Hwm(0),
test_hwm=Hwm(0)
main_hwm=Hwm(0, 0),
test_hwm=Hwm(0, 0)
)

delegation = Delegation(
Expand Down Expand Up @@ -932,8 +932,8 @@ def test_sign_delegation_constraints(
tezos_navigator.setup_app_context(
setup_account,
DEFAULT_CHAIN_ID,
main_hwm=Hwm(0),
test_hwm=Hwm(0)
main_hwm=Hwm(0, 0),
test_hwm=Hwm(0, 0)
)

delegation = Delegation(
Expand All @@ -960,8 +960,8 @@ def test_sign_reveal(
tezos_navigator.setup_app_context(
account,
DEFAULT_CHAIN_ID,
main_hwm=Hwm(0),
test_hwm=Hwm(0)
main_hwm=Hwm(0, 0),
test_hwm=Hwm(0, 0)
)

reveal = Reveal(
Expand Down Expand Up @@ -1027,8 +1027,8 @@ def test_sign_reveal_constraints(
tezos_navigator.setup_app_context(
setup_account,
DEFAULT_CHAIN_ID,
main_hwm=Hwm(0),
test_hwm=Hwm(0)
main_hwm=Hwm(0, 0),
test_hwm=Hwm(0, 0)
)

reveal = Reveal(
Expand Down Expand Up @@ -1056,8 +1056,8 @@ def test_sign_not_authorized_key(
tezos_navigator.setup_app_context(
account_1,
main_chain_id,
main_hwm=Hwm(0),
test_hwm=Hwm(0)
main_hwm=Hwm(0, 0),
test_hwm=Hwm(0, 0)
)

attestation = build_attestation(0, 0, main_chain_id)
Expand All @@ -1079,8 +1079,8 @@ def test_sign_transaction(
tezos_navigator.setup_app_context(
account_1,
main_chain_id,
main_hwm=Hwm(0),
test_hwm=Hwm(0)
main_hwm=Hwm(0, 0),
test_hwm=Hwm(0, 0)
)

ctxt = pytezos.using()
Expand Down Expand Up @@ -1196,8 +1196,8 @@ def test_sign_multiple_operation(
tezos_navigator.setup_app_context(
account,
DEFAULT_CHAIN_ID,
main_hwm=Hwm(0),
test_hwm=Hwm(0)
main_hwm=Hwm(0, 0),
test_hwm=Hwm(0, 0)
)

operation = operation_builder_1(account)
Expand Down Expand Up @@ -1238,8 +1238,8 @@ def test_sign_when_no_chain_setup(
tezos_navigator.setup_app_context(
account,
DEFAULT_CHAIN_ID, # Chain = 0
main_hwm=Hwm(0),
test_hwm=Hwm(0)
main_hwm=Hwm(0, 0),
test_hwm=Hwm(0, 0)
)

attestation = build_attestation(
Expand Down Expand Up @@ -1298,8 +1298,8 @@ def test_sign_when_chain_is_setup(
tezos_navigator.setup_app_context(
account,
main_chain_id,
main_hwm=Hwm(0),
test_hwm=Hwm(0)
main_hwm=Hwm(0, 0),
test_hwm=Hwm(0, 0)
)

attestation = build_attestation(
Expand Down
Loading

0 comments on commit aab6b79

Please sign in to comment.