Commit 21f3098f authored by Mark Tyneway's avatar Mark Tyneway Committed by GitHub

feat/simulate message (#238)

* add function

* cleaning

* fix revert prefixing and add test revertmsg

* write SM

* debug: progress

* Remove unnecessary logs

* Fix typo

Typo
Co-authored-by: default avatarben-chain <ben@pseudonym.party>

* Update contracts/optimistic-ethereum/OVM/execution/OVM_ExecutionManager.sol
Co-authored-by: default avatarben-chain <ben@pseudonym.party>
Co-authored-by: default avatarBen Jones <ben@pseudonym.party>
Co-authored-by: default avatarKelvin Fichter <kelvinfichter@gmail.com>
parent 2e4182cb
......@@ -1805,4 +1805,38 @@ contract OVM_ExecutionManager is iOVM_ExecutionManager, Lib_AddressResolver {
messageRecord.nuisanceGasLeft = 0;
messageRecord.revertFlag = RevertFlag.DID_NOT_REVERT;
}
/*****************************
* L2-only Helper Functions *
*****************************/
/**
* Unreachable helper function for simulating eth_calls with an OVM message context.
* This function will throw an exception in all cases other than when used as a custom entrypoint in L2 Geth to simulate eth_call.
* @param _transaction the message transaction to simulate.
* @param _from the OVM account the simulated call should be from.
*/
function simulateMessage(
Lib_OVMCodec.Transaction memory _transaction,
address _from,
iOVM_StateManager _ovmStateManager
)
external
returns (
bool,
bytes memory
)
{
// Prevent this call from having any effect unless in a custom-set VM frame
require(msg.sender == address(0));
ovmStateManager = _ovmStateManager;
_initContext(_transaction);
messageRecord.nuisanceGasLeft = uint(-1);
messageContext.ovmADDRESS = _transaction.entrypoint;
messageContext.ovmCALLER = _from;
return _transaction.entrypoint.call{gas: _transaction.gasLimit}(_transaction.data);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment