Closed ryanschneider closed 1 year ago
I'm just wondering if there are any other places where this function should be used.
Good point, I just did a search for NewQuantity(.*\.String)
and only hit the implementation of NewQuantityFromRLP
so I think this PR got them all:
$ git grep 'NewQuantity(.*\.String)' | cat
eth/quantity.go: return NewQuantity(v.String)
When debugging a bad block found on Ropsten today (which I added a test case for in
block_from_raw_test.go
I ran into another issue: Post mergeBlock.Difficulty
is0
, and since difficulty is aQUANTITY
it actually needs to be encoded as0x80
instead of0x00
.Luckily in adding EIP-1559 support I already had created a
NewQuantityFromRLP
function, I just had never gone back to other places where I was decoding RLP and started using it. This PR fixes that and uses the new function instead of special casing a couple block fields in FromRaw.Also, since I got kind of confused about the fact that
0x00
totally is valid RLP, but is NOT a valid representation of a quantity, I added test cases in rlp_from_test.go with more specific examples.Anyways this all turned out to be a total side quest, as the bad block was totally unrelated to any of these issues, but rather an issue where Erigon wasn't properly filtering out EIP-1559 txs with the wrong chain id, but since I ran into these issues while debugging this I figured I'd fix them.
I also updated the
rlp/fuzz
subdir and ourgo.mod
files to work w/ later versions ofgo-fuzz
. I still need to convert this project to using the new builtin fuzzer but that's too far out of scope for this PR.