From 03f2dab6bce4ffa2fae55a1d5dc3622b3eb79a14 Mon Sep 17 00:00:00 2001 From: Martin Milata Date: Fri, 24 Jul 2020 01:02:16 +0200 Subject: [PATCH] core: reduce gc.collect calls during bitcon sign_tx --- core/src/apps/bitcoin/sign_tx/bitcoin.py | 2 -- core/src/apps/bitcoin/sign_tx/bitcoinlike.py | 2 -- core/src/apps/bitcoin/sign_tx/decred.py | 2 -- core/src/apps/bitcoin/sign_tx/helpers.py | 7 ------- 4 files changed, 13 deletions(-) diff --git a/core/src/apps/bitcoin/sign_tx/bitcoin.py b/core/src/apps/bitcoin/sign_tx/bitcoin.py index 6334a53cc7..4f6aae0b31 100644 --- a/core/src/apps/bitcoin/sign_tx/bitcoin.py +++ b/core/src/apps/bitcoin/sign_tx/bitcoin.py @@ -1,4 +1,3 @@ -import gc from micropython import const from trezor import wire @@ -438,7 +437,6 @@ class Bitcoin: signature = ecdsa_sign(node, tx_digest) # serialize input with correct signature - gc.collect() script_sig = self.input_derive_script(txi, node.public_key(), signature) self.write_tx_input(self.serialized_tx, txi, script_sig) self.set_serialized_signature(i, signature) diff --git a/core/src/apps/bitcoin/sign_tx/bitcoinlike.py b/core/src/apps/bitcoin/sign_tx/bitcoinlike.py index 233aced72d..726810ec44 100644 --- a/core/src/apps/bitcoin/sign_tx/bitcoinlike.py +++ b/core/src/apps/bitcoin/sign_tx/bitcoinlike.py @@ -1,4 +1,3 @@ -import gc from micropython import const from trezor import wire @@ -31,7 +30,6 @@ class Bitcoinlike(Bitcoin): multisig.multisig_pubkey_index(txi.multisig, public_key) # serialize input with correct signature - gc.collect() script_sig = self.input_derive_script(txi, public_key, signature) self.write_tx_input(self.serialized_tx, txi, script_sig) self.set_serialized_signature(i_sign, signature) diff --git a/core/src/apps/bitcoin/sign_tx/decred.py b/core/src/apps/bitcoin/sign_tx/decred.py index d34325e00c..5ac27ee948 100644 --- a/core/src/apps/bitcoin/sign_tx/decred.py +++ b/core/src/apps/bitcoin/sign_tx/decred.py @@ -1,4 +1,3 @@ -import gc from micropython import const from trezor import wire @@ -123,7 +122,6 @@ class Decred(Bitcoin): signature = ecdsa_sign(key_sign, sig_hash) # serialize input with correct signature - gc.collect() script_sig = self.input_derive_script(txi_sign, key_sign_pub, signature) self.write_tx_input_witness(self.serialized_tx, txi_sign, script_sig) self.set_serialized_signature(i_sign, signature) diff --git a/core/src/apps/bitcoin/sign_tx/helpers.py b/core/src/apps/bitcoin/sign_tx/helpers.py index 0848d62eae..e0bd628663 100644 --- a/core/src/apps/bitcoin/sign_tx/helpers.py +++ b/core/src/apps/bitcoin/sign_tx/helpers.py @@ -1,5 +1,3 @@ -import gc - from trezor import utils, wire from trezor.messages import InputScriptType, OutputScriptType from trezor.messages.RequestType import ( @@ -117,7 +115,6 @@ def request_tx_meta(tx_req: TxRequest, coin: CoinInfo, tx_hash: bytes = None) -> tx_req.details.tx_hash = tx_hash ack = yield tx_req _clear_tx_request(tx_req) - gc.collect() return sanitize_tx_meta(ack.tx, coin) @@ -130,7 +127,6 @@ def request_tx_extra_data( # type: ignore tx_req.details.tx_hash = tx_hash ack = yield tx_req _clear_tx_request(tx_req) - gc.collect() return ack.tx.extra_data @@ -140,7 +136,6 @@ def request_tx_input(tx_req: TxRequest, i: int, coin: CoinInfo, tx_hash: bytes = tx_req.details.tx_hash = tx_hash ack = yield tx_req _clear_tx_request(tx_req) - gc.collect() return sanitize_tx_input(ack.tx, coin) @@ -150,7 +145,6 @@ def request_tx_output(tx_req: TxRequest, i: int, coin: CoinInfo, tx_hash: bytes tx_req.details.tx_hash = tx_hash ack = yield tx_req _clear_tx_request(tx_req) - gc.collect() if tx_hash is None: return sanitize_tx_output(ack.tx, coin) else: @@ -161,7 +155,6 @@ def request_tx_finish(tx_req: TxRequest) -> Awaitable[Any]: # type: ignore tx_req.request_type = TXFINISHED yield tx_req _clear_tx_request(tx_req) - gc.collect() def _clear_tx_request(tx_req: TxRequest) -> None: