add data on reverts

This commit is contained in:
Sina Mahmoodi 2024-06-12 15:01:43 +02:00
parent a9842e500c
commit a6f80c750d

View file

@ -212,16 +212,14 @@ func (sim *simulator) processBlock(ctx context.Context, block *simBlock, header,
gasUsed += result.UsedGas gasUsed += result.UsedGas
receipts[i] = core.MakeReceipt(evm, result, sim.state, blockContext.BlockNumber, common.Hash{}, tx, gasUsed, root) receipts[i] = core.MakeReceipt(evm, result, sim.state, blockContext.BlockNumber, common.Hash{}, tx, gasUsed, root)
blobGasUsed += receipts[i].BlobGasUsed blobGasUsed += receipts[i].BlobGasUsed
// If the result contains a revert reason, try to unpack it.
if len(result.Revert()) > 0 {
result.Err = newRevertError(result.Revert())
}
logs := tracer.Logs() logs := tracer.Logs()
callRes := simCallResult{ReturnValue: result.Return(), Logs: logs, GasUsed: hexutil.Uint64(result.UsedGas)} callRes := simCallResult{ReturnValue: result.Return(), Logs: logs, GasUsed: hexutil.Uint64(result.UsedGas)}
if result.Failed() { if result.Failed() {
callRes.Status = hexutil.Uint64(types.ReceiptStatusFailed) callRes.Status = hexutil.Uint64(types.ReceiptStatusFailed)
if errors.Is(result.Err, vm.ErrExecutionReverted) { if errors.Is(result.Err, vm.ErrExecutionReverted) {
callRes.Error = &callError{Message: result.Err.Error(), Code: errCodeReverted} // If the result contains a revert reason, try to unpack it.
revertErr := newRevertError(result.Revert())
callRes.Error = &callError{Message: revertErr.Error(), Code: errCodeReverted, Data: revertErr.ErrorData().(string)}
} else { } else {
callRes.Error = &callError{Message: result.Err.Error(), Code: errCodeVMError} callRes.Error = &callError{Message: result.Err.Error(), Code: errCodeVMError}
} }