Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

isBlockReceipt incorrectly called on non derived logs #2288

Open
piersy opened this issue Mar 21, 2024 · 2 comments
Open

isBlockReceipt incorrectly called on non derived logs #2288

piersy opened this issue Mar 21, 2024 · 2 comments
Labels
triage Issue needs triaging type:bug Something isn't working

Comments

@piersy
Copy link
Contributor

piersy commented Mar 21, 2024

The deriveLogFields function hydrates a log with information such as block number, transaction hash, block hash ...etc

But in the code below, before deriving the fields isBlockReceipt is called which checks whether the log's transaction hash matches the log's block hash ( block receipts are receipts that are not generated through a transaction, but instead track logs emitted by system calls, as such there is no corresponding transaction so the block hash is used in place of the transaction hash) of course because the fields are not yet defined they will both be zero values and so always match.

I think there is a further problem which is that in the case that len(txs) == len(receipts) the first part of the or condition will not be triggered, so the the next part of the or condition will be triggered, and that will return an error if the last receipt is not a block receipt, even though when len(txs) == len(receipts) no block receipt is expected. This problem probably hasn't been encountered since isBlockReceipt is always returning true in this context.

func deriveLogFields(receipts []*receiptLogs, hash common.Hash, number uint64, txs types.Transactions) error {
logIndex := uint(0)
// The receipts may include an additional "block finalization" receipt (only IBFT)
if len(txs) != len(receipts) && (len(txs)+1 != len(receipts) || !isBlockReceipt(receipts[len(receipts)-1])) {
return errors.New("transaction and receipt count mismatch")
}

@piersy piersy added type:bug Something isn't working triage Issue needs triaging labels Mar 21, 2024
@quickchase

This comment was marked as off-topic.

@palango

This comment was marked as off-topic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage Issue needs triaging type:bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants