You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(l1): rlp decode impls for low size transactions (#5139)
**Motivation**
Transactions are encoded in the following format:
* Legacy: rlp(Transaction)
* Non Legacy: rlp(Payload) where Payload is a bytes object containing
(TxType || rlp(Transaction))
When decoding in order to differentiate between a legacy and a non
legacy transaction we check if the encoded data is a bytes object
(`is_encoded_as_bytes`) by checking if the prefix is between 0xb8 and
0xbf. The problem with this is that when encoding the payload the
0xb8..0xbf prefix is only applied if the length of the payload is higher
than 56 bytes. This is usually the case for most real-scenario
transactions, but if the transaction payload were to be lower than 56
bytes then we would not detect it as a bytes object and would attempt
and fail to decode the transaction as a legacy one.
This PR fixes this problem by:
* Changing the criteria for legacy vs non-legacy transactions to instead
check if the incoming encoded data is encoded as a list (if so it will
be legacy). Aka `is_encoded_as_bytes` -> `!is_encoded_as_list`
* Considering the case where the encoded payload doesn't have the bytes
prefix. Aka `get_rlp_bytes_item_payload` -> `decode_rlp_item`. The
latter which considers the prefix RLP_NULL+size that is used when
encoding less than 56 bytes
<!-- Why does this pull request exist? What are its goals? -->
**Description**
* Fix decoding for `Transaction` & `P2PTransaction` for cases where tx
payload encoding is less than 56 bytes
<!-- A clear and concise general description of the changes this PR
introduces -->
<!-- Link to issues: Resolves#111, Resolves#222 -->
Closes #issue_number
0 commit comments