polaris icon indicating copy to clipboard operation
polaris copied to clipboard

Marshal/Unmarshal of core Geth types is slow

Open calbera opened this issue 1 year ago • 5 comments

Currently, headers, transactions, and receipts are marshaled/unmarshaled using RLP encoding/decoding, which is quite slow and not specifically useful. Convert to something faster like JSON.

calbera avatar Mar 10 '23 19:03 calbera

Hi! I would like to try this :D

anukul avatar Mar 21 '23 12:03 anukul

Awesome, that would be great!

calbera avatar Mar 21 '23 13:03 calbera

Related - https://github.com/berachain/polaris/issues/388, will benchmark a few alternatives and proceed after review

anukul avatar Mar 22 '23 10:03 anukul

mashallah @anukul

A few links here which may prove helpful: https://github.com/ethereum/go-ethereum/issues/20786 https://github.com/umbracle/fastrlp https://github.com/vorot93/fastrlp (if there was serious performance improvements, I wouldn't be opposed to using rust, we already have CGO so using FFI is whatever)

We likely lose rlpgen if we swtich to another method, but tbh gpt4 got us covered on that one.

itsdevbear avatar Mar 23 '23 01:03 itsdevbear

Hey guys, just dropping a quick update -

fastrlp isn't always faster than rlp in my benchmarks.
I have tried to use the same approach as polygon-edge. While there is a possibility that it may not be the most optimal code, I haven't been able to find the source for the quoted benchmark.

I see that Ethereum is moving to SSZ, and it seems faster than RLP for a simpler header struct (linked above).
The go implementation does not work with geth structs out of the box yet, so I'm currently working on that on a fork (specifically this ticket) to move further.

anukul avatar Apr 22 '23 22:04 anukul