Closed jolestar closed 5 years ago
Thanks for the report! But this is quite strange there - an emptystring resolves to the same as zero
"emptystring": {
"in": "",
"out": "0x80"
},
"zero": {
"in": 0,
"out": "0x80"
},
will investigate
/*
* For a single byte whose value is in the [0x00, 0x7f] range, that byte is
* its own RLP encoding.
*/
/**
* [0x80]
* If a string is 0-55 bytes long, the RLP encoding consists of a single
* byte with value 0x80 plus the length of the string followed by the
* string. The range of the first byte is thus [0x80, 0xb7].
*/
private static final int OFFSET_SHORT_ITEM = 0x80;
empty string and zero both startWith 0x80
thanks - yes for empty string we agree on 0x80 - but I am still puzzled about zero as:
/*
that would mean 0 -> 0x00
Interestingly parity and web3j also resolves it to 0x00 --->
https://github.com/paritytech/parity-common/blob/master/rlp/tests/tests.rs#L237
and
https://github.com/web3j/web3j/blob/master/rlp/src/test/java/org/web3j/rlp/RlpEncoderTest.java#L70
Thanks for pointing this out @jolestar - it is fixed in 0.68
some more context to this issue: https://github.com/ethereum/tests/pull/485
org/kethereum/functions/rlp/RLPTestData.kt
but https://github.com/ethereum/tests/blob/develop/RLPTests/rlptest.json