Skip to content

Commit f6ca7be

Browse files
authored
Fix retval for contract creation only when simulate (#4671)
1 parent 7d5c499 commit f6ca7be

File tree

1 file changed

+8
-2
lines changed
  • action/protocol/execution/evm

1 file changed

+8
-2
lines changed

action/protocol/execution/evm/evm.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ func ExecuteContract(
331331
revertMsg := string(data[64 : 64+msgLength])
332332
receipt.SetExecutionRevertMsg(revertMsg)
333333
}
334-
log.S().Debugf("Receipt: %+v, %v", receipt, err)
334+
log.S().Debugf("Retval: %x, Receipt: %+v, %v", retval, receipt, err)
335335
return retval, receipt, nil
336336
}
337337

@@ -516,13 +516,19 @@ func executeInEVM(ctx context.Context, evmParams *Params, stateDB stateDB) ([]by
516516
if evmParams.contract == nil {
517517
// create contract
518518
var evmContractAddress common.Address
519-
_, evmContractAddress, remainingGas, evmErr = evm.Create(executor, evmParams.data, remainingGas, amount)
519+
var createRet []byte
520+
createRet, evmContractAddress, remainingGas, evmErr = evm.Create(executor, evmParams.data, remainingGas, amount)
520521
log.T(ctx).Debug("evm Create.", log.Hex("addrHash", evmContractAddress[:]))
521522
if evmErr == nil {
522523
if contractAddress, err := address.FromBytes(evmContractAddress.Bytes()); err == nil {
523524
contractRawAddress = contractAddress.String()
524525
}
525526
}
527+
// ret updates may need hard fork
528+
// so we change it only when readonly mode now
529+
if evmParams.actionCtx.ReadOnly {
530+
ret = createRet
531+
}
526532
} else {
527533
stateDB.SetNonce(evmParams.txCtx.Origin, stateDB.GetNonce(evmParams.txCtx.Origin)+1)
528534
// process contract

0 commit comments

Comments
 (0)