15
votes
Accepted
LevelDB in Geth, key and values
Let's start with having a look at what we get in geth console for block number 40.
Now let's consider a Go program. I Explained everything in code comments about how it is constructing keys and ...
15
votes
Accepted
Why was RLP chosen as the low level protocol encoding algorithm?
RLP was chosen because of (1) simplicity of implementation, and (2) guaranteed absolute byte-perfect consistency.
Source is Ethereum Wiki:
RLP is intended to be a highly minimalistic serialization ...
eth♦
- 83.3k
9
votes
Clarification of "256 bit word" semantics
The EVM is always 256 bits big-endian. From the Yellow Paper, Appendix H: "When interpreting 256-bit binary values as integers, the representation is big-endian."
RLP is different from the Contract ...
eth♦
- 83.3k
9
votes
Accepted
Clarification of "256 bit word" semantics
It will be easier to understand if we make these two definitions (note: this might not be fully correct, but is enough for the following explanation):
the EVM is the machine executing the ...
6
votes
Accepted
Ethereum network messaging
I wrote this on the gitter.im channel, so here it is again anyway. Caveat is I have not looked at recent geth code for this, so there may be subtle discrepancies with actuality.
A key paragraph is ...
4
votes
Accepted
What does string mean in patricia tree wiki
Different computers store binary data differently. The purpose of the RLP as stated in the referenced document is to
The purpose of RLP (Recursive Length Prefix) is to encode
arbitrarily nested ...
4
votes
Accepted
RLP encoding of 0
It appears that encoding the integer 0 no longer equates to \x00 (as the documentation would imply). This can be seen both in your example, and in the fact that it can't be decoded:
>>> ...
4
votes
Block header format
You can find the block header's structure in the Yellow paper, 4.4 (page 5).
I don't have time to go through eveyrthing, but if I do not make any mistake, for example, you could bind the following:
...
4
votes
Accepted
Understanding serialized unsigned raw transaction
Partial answer.
Why does the ChainId is 0x1c or 28 ? Given this list it don't understand.
The link you point to shows network ID, which isn't the same as chain ID.
Further, 28 isn't the chain ID, ...
3
votes
How to RLP-encode messages in Solidity
https://www.npmjs.com/package/solidity-rlp
Here is a package I am maintaining to decode rlp bytes in solidity. you can checkout the code and usage instructions here: https://github.com/hamdiallam/...
3
votes
Accepted
Does RLP specify integer encoding?
RLP deals only in structures made up of bytes (binary data). It doesn't care whether those bytes represent strings, integers, big integers, floating point numbers or whatever. This is in the sentence ...
3
votes
RLP ethereum decoding
The other answer gives useful information, but to directly answer your question: RLP encoding does not give any information about types. It only encodes strings (byte sequences) and lists of lists/...
3
votes
Accepted
Can I add leading zeroes at will when building an RLP-encoded transaction?
You can't. RLP can't have leading zeros. It is designed to encode values in a shortest way, so redundant leading zeros make RLP not canonical.
What's more, transaction's RLP starts with payload ...
3
votes
Accepted
How to decode the output of an eth_call that returns a Tuple[]
After re-reading https://docs.soliditylang.org/en/latest/abi-spec.html#use-of-dynamic-types with a fresher brain, I understood that the way the bytes are divided is as follows:
first 32 bytes: offset ...
2
votes
RLP encoding of 0
RLP is defined in Ethereum Yellow Paper (Appendix A, page 16).
There are few interesting quotes:
We define the RLP function as RLP through two sub-functions, the first handling the instance when the ...
2
votes
Accepted
Confusion over RLP encoding for byte array > 55 bytes
It is just once the length of the byte array - the wiki describes it a bit confusing. Better look at the yellowpaper PDF (appendix RLP):
https://ethereum.github.io/yellowpaper/paper.pdf
Or an ...
2
votes
LevelDB in Geth, key and values
I think keys are needed to organize tree - to know how to move nodes in trie without knowledge of stored information, read about Patricia-Tree. In examples, they use keys to organize trie.
2
votes
Accepted
How Merkle Tree obtain root node hash (example from 'Understanding the ethereum trie')?
I read code bad: when we got
key = pack_nibbles(with_terminator('\x01\x01\x02')
value = rlp.encode(['hello'])
which is tantamount to:
key = '\x01\x01\x02'
value = '\xc6\x85hello'
this value ...
2
votes
Accepted
RLP Rationale Question
It says that RLP is
simple
unambiguous
It's simpler than other algorithms because it doesn't define any data types other than bytes and arrays.
It's unambiguous because the same input data is ...
2
votes
Accepted
geth inter-node communication (devp2p/rlpx) encryption
Does someone know if there is any documentation on encryption in the inter-node protocol?
You might have already found these, but here are few sources I've used in the past:
https://github.com/...
2
votes
block hash from block-header rlp
Below are the steps to calculate blockHash, given a blockNumber:
Step1. eth.getBlock(400000)
Output:{ difficulty: '6022643743806', extraData: '0xd583010202844765746885676f312e35856c696e7578', ...
2
votes
Accepted
RLP decoding for a list
131 can't be encoded as just 0x83. From https://github.com/ethereum/wiki/wiki/%5BEnglish%5D-RLP:
For a single byte whose value is in the [0x00, 0x7f] range, that byte is its own RLP encoding.
0x83 ...
2
votes
Understanding serialized unsigned raw transaction
The byte 0xe6 was simply following the 3rd rule describing an rlp list serialized.
tx = new ethTx({});
console.log('RLP-Encoded Tx: 0x' + tx.serialize().toString('hex'))
Gives: 0x c9 ...
2
votes
Accepted
How to encode empty transaction fields?
All of these field have to be provided and should not be nil. There are generally 2 different types when encoding a transaction with RLP: 256-bit Number and a Bytes.
So if we have an empty data we ...
2
votes
Accepted
How is the FROM address known for historic transactions?
The encoded transaction when decoded has properties v, r and s.
{
"nonce": "0x0",
"maxFeePerGas": "0x1234",
"maxPriorityFeePerGas": "0x1234&...
2
votes
How to decode the output of an eth_call that returns a Tuple[]
If you look at the source code of the contract, the return type of the function getAllReserveTokens is TokenData[] memory which is an array of a custom struct defined in the storage of the contract. ...
1
vote
what type of encoding is used by the abi specification in solidity
May be I don’t fully understand your question, but I can say that it should be taken into account that ABI is not the internal coding for the contract, but the description of the interface in a human ...
1
vote
Accepted
How to RLP-encode messages in Solidity
I don't know if there is any native library available in Solidity, but there are node-js libraries available will help you do that.
I also found this solidity code when doing a search on RLP, have a ...
1
vote
Broadcast error rlp: non-canonical integer (leading zero bytes) for uint64
https://github.com/MOACChain/moac-core/issues/24
signed r and s need to clear leading zero bytes
1
vote
Broadcast error rlp: non-canonical integer (leading zero bytes) for uint64
The gas price, limit, and value are all unparsed from _bn (big number) when they should be a number. Not sure if that's happening when you decide the signed transaction or encode the unsigned ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
rlp × 54raw-transaction × 9
go-ethereum × 8
transactions × 6
encoding × 6
solidity × 4
python × 4
signature × 4
sendrawtransaction × 4
web3js × 3
json-rpc × 3
abi × 3
string × 3
yellow-paper × 3
protocol × 3
leveldb × 3
block-header × 3
white-paper × 3
evm × 2
blocks × 2
network × 2
bytecode × 2
nonce × 2
merkle-patricia-tries × 2
pyethereum × 2