refactor(core): inline `data_length` into `_get_digest_length()`
What changed, and why it matters
This is a tiny code cleanup in the Ethereum transaction signing code. It moves where a variable is defined without changing what the code actually does. There is no security issue visible in the change.
No action needed; treat as routine refactoring.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit refactors sign_tx_eip1559.py by removing a local data_length = msg.data_length cache in the caller and instead reading msg.data_length directly inside _get_digest_length(). The function signature is updated to drop the data_length parameter. The computed RLP digest length is identical before and after; no validation, parsing, or cryptographic behavior changes.
Changed components
core/src/apps/ethereum/sign_tx_eip1559.pyInspect captured patch +3 / −3
### core/src/apps/ethereum/sign_tx_eip1559.py
@@ -46,7 +46,6 @@ async def sign_tx_eip1559(
)
gas_limit = msg.gas_limit # local_cache_attribute
- data_length = msg.data_length # local_cache_attribute
# check
if len(msg.max_gas_fee) + len(gas_limit) > 30:
@@ -83,7 +82,7 @@ async def sign_tx_eip1559(
sha = keccak256()
rlp.write(sha, _TX_TYPE)
- rlp.write_header(sha, _get_digest_length(msg, data_length), rlp.LIST_HEADER_BYTE)
+ rlp.write_header(sha, _get_digest_length(msg), rlp.LIST_HEADER_BYTE)
fields: tuple[rlp.RLPItem, ...] = (
msg.chain_id,
@@ -128,7 +127,7 @@ async def sign_tx_eip1559(
return result
-def _get_digest_length(msg: EthereumSignTxEIP1559, data_length: int) -> int:
+def _get_digest_length(msg: EthereumSignTxEIP1559) -> int:
length = 0
fields: tuple[rlp.RLPItem, ...] = (
@@ -143,6 +142,7 @@ def _get_digest_length(msg: EthereumSignTxEIP1559, data_length: int) -> int:
for field in fields:
length += rlp.length(field)
+ data_length = msg.data_length
length += rlp.header_length(data_length, msg.data_initial_chunk)
length += data_length
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.