From 74655931ce996b566b99435195f8ece75080b7d0 Mon Sep 17 00:00:00 2001 From: M1nd3r Date: Thu, 24 Oct 2024 13:33:03 +0200 Subject: [PATCH] feat(core): allow benchmark on BITCOIN_ONLY debug build [no changelog] --- common/protob/messages-benchmark.proto | 4 ++++ core/SConscript.unix | 4 ++-- core/src/apps/workflow_handlers.py | 12 ++++++------ .../src/protos/generated/messages_benchmark.rs | 16 +++++++++------- 4 files changed, 21 insertions(+), 15 deletions(-) diff --git a/common/protob/messages-benchmark.proto b/common/protob/messages-benchmark.proto index 1b31b2c345..cc12f15a38 100644 --- a/common/protob/messages-benchmark.proto +++ b/common/protob/messages-benchmark.proto @@ -5,6 +5,10 @@ package hw.trezor.messages.bitcoin; option java_package = "com.satoshilabs.trezor.lib.protobuf"; option java_outer_classname = "TrezorMessageBenchmark"; +import "options.proto"; + +option (include_in_bitcoin_only) = true; + /** * Request: Ask device for a list of names of all supported benchmarks * @start diff --git a/core/SConscript.unix b/core/SConscript.unix index 69c995d76d..05b89f2079 100644 --- a/core/SConscript.unix +++ b/core/SConscript.unix @@ -699,6 +699,8 @@ if FROZEN: SOURCE_PY_DIR + 'apps/bitcoin/sign_tx/zcash_v4.py', ]) ) + if BENCHMARK: + SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/benchmark/*.py')) if EVERYTHING: SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/binance/*.py')) @@ -754,8 +756,6 @@ if FROZEN: SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/bitcoin/sign_tx/zcash_v4.py')) SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/enums/Zcash*.py')) - if BENCHMARK: - SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/benchmark/*.py')) source_mpy = env.FrozenModule( source=SOURCE_PY, diff --git a/core/src/apps/workflow_handlers.py b/core/src/apps/workflow_handlers.py index 973d807134..6128884ba2 100644 --- a/core/src/apps/workflow_handlers.py +++ b/core/src/apps/workflow_handlers.py @@ -31,6 +31,12 @@ def _find_message_handler_module(msg_type: int) -> str: if __debug__ and msg_type == MessageType.LoadDevice: return "apps.debug.load_device" + # benchmark + if __debug__ and msg_type == MessageType.BenchmarkListNames: + return "apps.benchmark.list_names" + if __debug__ and msg_type == MessageType.BenchmarkRun: + return "apps.benchmark.run" + # management if msg_type == MessageType.ResetDevice: return "apps.management.reset_device" @@ -206,12 +212,6 @@ def _find_message_handler_module(msg_type: int) -> str: if msg_type == MessageType.SolanaSignTx: return "apps.solana.sign_tx" - # benchmark - if __debug__ and msg_type == MessageType.BenchmarkListNames: - return "apps.benchmark.list_names" - if __debug__ and msg_type == MessageType.BenchmarkRun: - return "apps.benchmark.run" - raise ValueError diff --git a/rust/trezor-client/src/protos/generated/messages_benchmark.rs b/rust/trezor-client/src/protos/generated/messages_benchmark.rs index 0ddf065a72..f095c6be6c 100644 --- a/rust/trezor-client/src/protos/generated/messages_benchmark.rs +++ b/rust/trezor-client/src/protos/generated/messages_benchmark.rs @@ -621,12 +621,13 @@ impl ::protobuf::reflect::ProtobufValue for BenchmarkResult { } static file_descriptor_proto_data: &'static [u8] = b"\ - \n\x18messages-benchmark.proto\x12\x1ahw.trezor.messages.bitcoin\"\x14\n\ - \x12BenchmarkListNames\"&\n\x0eBenchmarkNames\x12\x14\n\x05names\x18\x01\ - \x20\x03(\tR\x05names\"\"\n\x0cBenchmarkRun\x12\x12\n\x04name\x18\x01\ - \x20\x01(\tR\x04name\";\n\x0fBenchmarkResult\x12\x14\n\x05value\x18\x01\ - \x20\x01(\tR\x05value\x12\x12\n\x04unit\x18\x03\x20\x01(\tR\x04unitB=\n#\ - com.satoshilabs.trezor.lib.protobufB\x16TrezorMessageBenchmark\ + \n\x18messages-benchmark.proto\x12\x1ahw.trezor.messages.bitcoin\x1a\rop\ + tions.proto\"\x14\n\x12BenchmarkListNames\"&\n\x0eBenchmarkNames\x12\x14\ + \n\x05names\x18\x01\x20\x03(\tR\x05names\"\"\n\x0cBenchmarkRun\x12\x12\n\ + \x04name\x18\x01\x20\x01(\tR\x04name\";\n\x0fBenchmarkResult\x12\x14\n\ + \x05value\x18\x01\x20\x01(\tR\x05value\x12\x12\n\x04unit\x18\x03\x20\x01\ + (\tR\x04unitBA\n#com.satoshilabs.trezor.lib.protobufB\x16TrezorMessageBe\ + nchmark\x80\xa6\x1d\x01\ "; /// `FileDescriptorProto` object which was a source for this generated file @@ -643,7 +644,8 @@ pub fn file_descriptor() -> &'static ::protobuf::reflect::FileDescriptor { static file_descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::FileDescriptor> = ::protobuf::rt::Lazy::new(); file_descriptor.get(|| { let generated_file_descriptor = generated_file_descriptor_lazy.get(|| { - let mut deps = ::std::vec::Vec::with_capacity(0); + let mut deps = ::std::vec::Vec::with_capacity(1); + deps.push(super::options::file_descriptor().clone()); let mut messages = ::std::vec::Vec::with_capacity(4); messages.push(BenchmarkListNames::generated_message_descriptor_data()); messages.push(BenchmarkNames::generated_message_descriptor_data());