fix empty tx, receipts hash

This commit is contained in:
Sina Mahmoodi 2024-01-17 16:11:09 +03:30
parent ae335662af
commit 12d7dd0746

View file

@ -205,8 +205,7 @@ func (sim *simulator) execute(ctx context.Context, opts simOpts) ([]simBlockResu
root = state.IntermediateRoot(config.IsEIP158(blockContext.BlockNumber)).Bytes()
}
gasUsed += result.UsedGas
receipt := core.MakeReceipt(evm, result, state, blockContext.BlockNumber, common.Hash{}, tx, gasUsed, root)
receipts[i] = receipt
receipts[i] = core.MakeReceipt(evm, result, state, blockContext.BlockNumber, common.Hash{}, tx, gasUsed, root)
// If the result contains a revert reason, try to unpack it.
if len(result.Revert()) > 0 {
result.Err = newRevertError(result.Revert())
@ -236,8 +235,13 @@ func (sim *simulator) execute(ctx context.Context, opts simOpts) ([]simBlockResu
header.ParentHash = parentHash
header.Root = state.IntermediateRoot(true)
header.GasUsed = gasUsed
if len(txes) > 0 {
header.TxHash = types.DeriveSha(types.Transactions(txes), trie.NewStackTrie(nil))
}
if len(receipts) > 0 {
header.ReceiptHash = types.DeriveSha(types.Receipts(receipts), trie.NewStackTrie(nil))
header.Bloom = types.CreateBloom(types.Receipts(receipts))
}
results[bi] = mcBlockResultFromHeader(header, callResults)
repairLogs(results, header.Hash())
}
@ -389,6 +393,8 @@ func makeHeaders(config *params.ChainConfig, blocks []simBlock, base *types.Head
}
header = &types.Header{
UncleHash: types.EmptyUncleHash,
ReceiptHash: types.EmptyReceiptsHash,
TxHash: types.EmptyTxsHash,
Coinbase: base.Coinbase,
Difficulty: base.Difficulty,
GasLimit: base.GasLimit,