Closed mshakeg closed 1 month ago
CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅
I have read the CLA Document and I hereby sign the CLA
recheck
Hey, thank you for the contribution. this can be an external contract used through https://github.com/safe-global/safe-smart-account/blob/8f80a8372d193be121dcdb52e869a258824e5c0f/contracts/common/StorageAccessible.sol#L42. We're quite short on the bytecode size, so I'm almost sure we will not include this in the core contract.
@mmv08 thanks, so I took a look at linked StorageAccessible. simulateAndRevert
section of code and what from I can tell it should work something like:
safe
where the safeTx is to
, value
, data
and operation
safe.simulateAndRevert(targetContract, calldataPayload)
targetContract
: this will be the SimulateTxAccessor
addresscalldataPayload
: this will be the encoded bytes of SimulateTxAccessor.simulate(to, value, data, operation)
success
can be extracted from the revert messageIs this understanding correct? And if so, does the ts sdk expose a function to do this simulation? Also, since it reverts eth_estimateGas wouldn't return the gasUsed for the simulation safeTx, so that seems to be a deficiency with this method.
@mmv08 I added the gasUsed to the revert data. It seems to work fine for most txs, however the simulations for txs that transfer the native asset all fail:
npx hardhat test test/core/Safe.Execution.spec.ts
@mmv08 thanks, so I took a look at linked
StorageAccessible. simulateAndRevert
section of code and what from I can tell it should work something like:
- say I've got a safeTx that I want to simulate on
safe
where the safeTx isto
,value
,data
andoperation
- now I can simulate the above safeTx but I don't have any owner signatures
so I call
safe.simulateAndRevert(targetContract, calldataPayload)
targetContract
: this will be theSimulateTxAccessor
addresscalldataPayload
: this will be the encoded bytes ofSimulateTxAccessor.simulate(to, value, data, operation)
- now
success
can be extracted from the revert messageIs this understanding correct? And if so, does the ts sdk expose a function to do this simulation? Also, since it reverts eth_estimateGas wouldn't return the gasUsed for the simulation safeTx, so that seems to be a deficiency with this method.
You can make a library that contains a function similar to your original simulateTransaction
method, have this function return whatever you want and then use the return data from there. There are no code changes required in the safe core contract to achieve the functionality you're suggesting
@mmv08 agreed, no changes are required to core, but does safe-global have a repo with periphery contracts? seems like this functionality would be quite essential to gas estimation and should be included in the sdk(and so would require leveraging a safe deployed contract).
This PR introduces a new function,
simulateTransaction
, to theSafe
contract, allowing users to simulate transactions without requiring the threshold of owner signatures. The simulation helps estimate gas usage and verify if a transaction would succeed without actually executing it, thus providing a reliable method for pre-execution checks.Fixes #788