-
Notifications
You must be signed in to change notification settings - Fork 200
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
Extra receipt for internal EVM call when finalizing blocks #584
Changes from all commits
b678496
741ea34
f52e5c2
ec2951e
206c638
94fc4f6
f773d04
0354ea7
b222c83
41f8160
ff30d36
5d76786
d0a9474
963d481
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -84,8 +84,20 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg | |
allLogs = append(allLogs, receipt.Logs...) | ||
} | ||
// Finalize the block, applying any consensus engine specific extras (e.g. block rewards) | ||
statedb.Prepare(common.Hash{}, block.Hash(), len(block.Transactions())) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this needed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When logs are added, the associated transaction will be read from the instance variables that are set by this method. |
||
p.engine.Finalize(p.bc, header, statedb, block.Transactions(), block.Uncles(), receipts, block.Randomness()) | ||
|
||
if len(statedb.GetLogs(common.Hash{})) > 0 { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not 100% clear on what's going on here. Would there be a single receipt for all blocks? If not, won't we have the null hash being mapped to many receipts? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, many receipts will be associated into null hash, but they can be separated because they are contained in different blocks. Comparison between using null and block hash
I'll next check that tx hash in receipt is not consensus data. |
||
receipt := types.NewReceipt(nil, false, 0) | ||
receipt.Logs = statedb.GetLogs(common.Hash{}) | ||
receipt.Bloom = types.CreateBloom(types.Receipts{receipt}) | ||
for i := range receipt.Logs { | ||
receipt.Logs[i].TxIndex = uint(len(receipts)) | ||
receipt.Logs[i].TxHash = block.Hash() | ||
} | ||
receipts = append(receipts, receipt) | ||
} | ||
|
||
return receipts, allLogs, *usedGas, nil | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -614,6 +614,10 @@ func (w *worker) resultLoop() { | |
// receipt/log of individual transactions were created. | ||
for _, log := range receipt.Logs { | ||
log.BlockHash = hash | ||
// Handle block finalization receipt | ||
if (log.TxHash == common.Hash{}) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add a comment |
||
log.TxHash = hash | ||
} | ||
} | ||
logs = append(logs, receipt.Logs...) | ||
} | ||
|
@@ -1068,6 +1072,17 @@ func (w *worker) commit(uncles []*types.Header, interval func(), update bool, st | |
} | ||
|
||
block, err := w.engine.Finalize(w.chain, w.current.header, s, w.current.txs, uncles, w.current.receipts, w.current.randomness) | ||
|
||
if len(s.GetLogs(common.Hash{})) > 0 { | ||
receipt := types.NewReceipt(nil, false, 0) | ||
receipt.Logs = s.GetLogs(common.Hash{}) | ||
for i := range receipt.Logs { | ||
receipt.Logs[i].TxIndex = uint(len(receipts)) | ||
} | ||
receipt.Bloom = types.CreateBloom(types.Receipts{receipt}) | ||
receipts = append(receipts, receipt) | ||
} | ||
|
||
if err != nil { | ||
log.Error("Unable to finalize block", "err", err) | ||
return err | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a comment above this:
The receipts may include an additional "block finalization" receipt