Skip to content

core, miner: do not populate receipts field during mining #31813

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

MariusVanDerWijden
Copy link
Member

Address an issue brought up by Optimism here: ethereum-optimism/op-geth#462
We are currently populating all receipt fields whenever a transaction is added to the pending state (which included calculating the blockhash). This PR changes it, so we only compute the necessary consensus fields

receipt := &types.Receipt{Type: tx.Type(), PostState: root, CumulativeGasUsed: usedGas}
if result.Failed() {
receipt.Status = types.ReceiptStatusFailed
} else {
receipt.Status = types.ReceiptStatusSuccessful
}
receipt.Logs = statedb.GetLogs(tx.Hash())
receipt.Bloom = types.CreateBloom(receipt)
Copy link
Member

Choose a reason for hiding this comment

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

The logs constructed during the block insertion (e.g., full sync) will be emitted to the log subscribers, which assumes the logs should be fully annotated.

Here, the logs are partially annotated, missing blockNumber and blockHash fields.

Copy link
Member Author

Choose a reason for hiding this comment

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

Are you sure? I don't see where they are emitted to the log subscribers. I only see them written to the db and later on read from the db during collectLogs and the missing fields are derived

Copy link
Contributor

Choose a reason for hiding this comment

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

Gary has a point. This is where the logs are being sent out to subscribers:

bc.logsFeed.Send(logs)

I missed this. We don't have pending subscription anymore but the log subscription to newly mined logs is there.

I think it will be tricky to derive the fields in the consumer unless we change the structure of the logsFeed. At least would need the header and unflattened logs.

@rjl493456442
Copy link
Member

I think generally it's a good direction to get rid of the log/receipts deriving in the chain progressing/block building. These field extension should only be added in the filter where the logs are pushed to the subscribers.

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.

4 participants