Skip to content

Commit

Permalink
feat(core): allow benchmark only in debug
Browse files Browse the repository at this point in the history
[no changelog]
  • Loading branch information
onvej-sl committed Oct 10, 2024
1 parent aa8b8a0 commit 35da0e7
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
4 changes: 4 additions & 0 deletions core/SConscript.firmware
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ NEW_RENDERING = ARGUMENTS.get('NEW_RENDERING', '1') == '1'
MODEL_IDENTIFIER = models.get_model_identifier(TREZOR_MODEL)
BENCHMARK = ARGUMENTS.get('BENCHMARK', '0') == '1'

if BENCHMARK and PYOPT != '0':
print("BENCHMARK=1 works only with PYOPT=0.")
exit(1)

FEATURE_FLAGS = {
"RDI": True,
"SECP256K1_ZKP": True, # required for trezor.crypto.curve.bip340 (BIP340/Taproot)
Expand Down
4 changes: 4 additions & 0 deletions core/SConscript.unix
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ FROZEN = ARGUMENTS.get('TREZOR_EMULATOR_FROZEN', 0)
RASPI = os.getenv('TREZOR_EMULATOR_RASPI') == '1'


if BENCHMARK and PYOPT != '0':
print("BENCHMARK=1 works only with PYOPT=0.")
exit(1)

FEATURES_WANTED = ["input", "sd_card", "dma2d", "optiga", "sbu"]
if NEW_RENDERING:
FEATURES_WANTED.append("new_rendering")
Expand Down
4 changes: 4 additions & 0 deletions core/src/apps/benchmark/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
if not __debug__:
from trezor import utils

utils.halt("Disabled in production mode")
4 changes: 2 additions & 2 deletions core/src/apps/workflow_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,9 @@ def _find_message_handler_module(msg_type: int) -> str:
return "apps.solana.sign_tx"

# benchmark
if msg_type == MessageType.BenchmarkListNames:
if __debug__ and msg_type == MessageType.BenchmarkListNames:
return "apps.benchmark.list_names"
if msg_type == MessageType.BenchmarkRun:
if __debug__ and msg_type == MessageType.BenchmarkRun:
return "apps.benchmark.run"

raise ValueError
Expand Down

0 comments on commit 35da0e7

Please sign in to comment.