Skip to content

Conversation

@geoknee
Copy link
Contributor

@geoknee geoknee commented Dec 16, 2025

Preparatory work for #726

Add multiple raw DB receipt hex test vectors and iterate over them using
t.Run to create subtests. Decode each receipt inside the subtest and
remove hardcoded assertions. Add fmt import.
Comment on lines +68 to +69
err = rlp.DecodeBytes(rawDBReceiptBytes, sr)
require.NoError(t, err)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this test actually still passes with https://github.com/ethereum-optimism/op-geth/pull/726/files#r2543824260.

This may not mean it is totally safe, since the test data here may not be sufficient to expose any problems.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For a time I had thought this is because the decoder would fallback to decodeLegacyOptimismReceiptRLP for these test cases, but on further investigation that is not the case. We need a concrete example of a legacy receipt to add to this test.

Replace the local storedReceiptRLP with core/types.ReceiptForStorage in
decoding code. Update tests to decode into ReceiptForStorage and compare
FeeScalar as a big.Float. Use ReceiptForStorage, remove duplicate struct

Mark legacy receipt fields as rlp:"optional" so mixed-format receipts
can be parsed without errors. Update unit tests to decode legacy
receipts into ReceiptForStorage and compare FeeScalar by parsing it into
a big.Float to match the stored representation
@geoknee geoknee changed the title test(core/rawdb/accessors): Additional tests for legacy (pre-bedrock) receipt decoding refactor(core/rawdb/accessors): Remove storedReceiptsRLP struct Dec 16, 2025
@geoknee geoknee marked this pull request as ready for review December 17, 2025 15:46
@geoknee geoknee requested a review from a team as a code owner December 17, 2025 15:46
@geoknee geoknee requested a review from Inphi December 17, 2025 15:46
rawDBReceiptBytes, err := hexutil.Decode(rawDBReceiptHex)
require.NoError(t, err)

sr := new([]receiptLogs)
Copy link
Contributor

@joshklop joshklop Dec 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be

Suggested change
sr := new([]receiptLogs)
sr := make([]*types.ReceiptForStorage, 0)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implemented here #738

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would trigger the same RLP decoder. I think I chose to do it this way since #726 just changes the implementation of the decoder on receiptLogs to use ReceiptForStorage.

// DecodeRLP implements rlp.Decoder.
func (r *receiptLogs) DecodeRLP(s *rlp.Stream) error {
var rs types.ReceiptForStorage
if err := rs.DecodeRLP(s); err != nil {
return err
}
r.Logs = rs.Logs
return nil
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants