2

Although probably not an issue in practice, I'm confused how nonce of zero is encoded in transactions.

According to RLP doc, \x00 should be encoded as \x00. But the source code of pyethereum shows that 0 is encoded as empty string '', i.e. nothing.

nonce is the number of transactions already sent by that account, encoded in binary form (eg. 0 -> '', 7 -> '\x07', 1000 -> '\x03\xd8').

Apparently, the latter is used in practice. Why is it inconsistent with the RLP doc?

1

In practice, leading zeroes may cause some problems across OS, for example, regarding big endian VS. little endian. In an other link (which I don't remember where it lies), it's said to an implementation just ignore such leading zeroes.

From the Ethereum yellow paper:

When interpreting RLP data, if an expected fragment is decoded as a scalar and leading zeroes are found in the byte sequence, clients are required to consider it non-canonical and treat it in the same manner as otherwise invalid RLP data, dismissing it completely.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.