nance-eth / nance-interface

An Interface of Nance platform
https://nance.app
4 stars 0 forks source link

update Tenderly simulation to be Safe multicall compatible #152

Closed jigglyjams closed 3 months ago

jigglyjams commented 3 months ago

Integrate state overrides into Tenderly API call so we can match safe.global's way of simulation

to should be the Safe address itself as well

nance-ts implementation: https://github.com/nance-eth/nance-ts/blob/04536ea7f0db251ad83272f1a3c92fb5fe892e38/src/tenderly/tenderlyHandler.ts#L76

checkout example https://dashboard.tenderly.co/public/safe/safe-apps/simulator/939a1c7a-887e-44d4-80a3-09a6a9c7349c

Image

jigglyjams commented 3 months ago

prepopulated re-simulation

https://dashboard.tenderly.co/jigglyjams/nance/simulator/new?contractFunction=0x6a761202&simulationId=939a1c7a-887e-44d4-80a3-09a6a9c7349c&value=0&contractAddress=0xaf28bcb48c40dbc86f52d459a6562f658fc94b1e&rawFunctionInput=0x6a7612020000000000000000000000009641d764fc13c8b624c04430c7356c1c7c8102e200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000090000000000000000000000000000000000000000000000000000000000000007848d80ff0a0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000072c00594cb208b5bb48db1bcbc9354d1694998864ec63000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000447258002c000000000000000000000000fa391de95fcbcd3157268b91d8c7af083e607a5c000000000000000000000000000000000000000000000000000000000000000100594cb208b5bb48db1bcbc9354d1694998864ec63000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000447258002c000000000000000000000000457cd63bee88ac01f3cd4a67d5dcc921d8c0d573000000000000000000000000000000000000000000000000000000000000000100594cb208b5bb48db1bcbc9354d1694998864ec63000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000447258002c0000000000000000000000001d9619e10086fdc1065b114298384aae3f680cc0000000000000000000000000000000000000000000000000000000000000000100fa391de95fcbcd3157268b91d8c7af083e607a5c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000447258002c000000000000000000000000594cb208b5bb48db1bcbc9354d1694998864ec63000000000000000000000000000000000000000000000000000000000000000100fa391de95fcbcd3157268b91d8c7af083e607a5c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000447258002c000000000000000000000000457cd63bee88ac01f3cd4a67d5dcc921d8c0d573000000000000000000000000000000000000000000000000000000000000000100fa391de95fcbcd3157268b91d8c7af083e607a5c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000447258002c0000000000000000000000001d9619e10086fdc1065b114298384aae3f680cc0000000000000000000000000000000000000000000000000000000000000000100457cd63bee88ac01f3cd4a67d5dcc921d8c0d573000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000447258002c000000000000000000000000594cb208b5bb48db1bcbc9354d1694998864ec63000000000000000000000000000000000000000000000000000000000000000100457cd63bee88ac01f3cd4a67d5dcc921d8c0d573000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000447258002c000000000000000000000000fa391de95fcbcd3157268b91d8c7af083e607a5c000000000000000000000000000000000000000000000000000000000000000100457cd63bee88ac01f3cd4a67d5dcc921d8c0d573000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000447258002c0000000000000000000000001d9619e10086fdc1065b114298384aae3f680cc00000000000000000000000000000000000000000000000000000000000000001001d9619e10086fdc1065b114298384aae3f680cc0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000447258002c000000000000000000000000594cb208b5bb48db1bcbc9354d1694998864ec63000000000000000000000000000

twodam commented 3 months ago

implemented by https://github.com/nance-eth/nance-interface/commit/a998e4841ff1f10bc1831b6be2b31a926e0c99b1

here's the some code details I found: state_override update threshold of that Safe contract to be one, it means there's only one owner the signature 0x0000...address...1 we pass as signatures will be interpreted as "approved hash", it's valid as long as msg.sender == address. check contract code below

  else if (v == 1) {
    // If v is 1 then it is an approved hash
    // When handling approved hashes the address of the approver is encoded into r
    currentOwner = address(uint160(uint256(r)));
    // Hashes are automatically approved by the sender of the message or when they have been pre-approved via a separate transaction
    if (executor != currentOwner && approvedHashes[currentOwner][dataHash] == 0) revertWithError("GS025");
}

https://github.com/safe-global/safe-smart-account/blob/af53bdf82cda7530783b1ca5530afd12ea82cbb2/contracts/Safe.sol#L304-L309