Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: onAbort #66

Merged
merged 11 commits into from
Jan 23, 2025
Merged

feat: onAbort #66

merged 11 commits into from
Jan 23, 2025

Conversation

fadeev
Copy link
Member

@fadeev fadeev commented Jan 21, 2025

@fadeev
Copy link
Member Author

fadeev commented Jan 21, 2025

@lumtis so the logic is:

  • If EVM call to ZetaChain reverts, onAbort is executed on ZetaChain with outgoing false.
  • If EVM deposit or deposit and call reverts, if the ZRC-20 amount is enough to cover call back to the connected chain, onRevert is executed on a connected chain, if the amount is not enough, onAbort is executed on ZetaChain with outgoing false.
  • If ZetaChain call/deposit/deposit and call to connected chain fails, onRevert is executed on ZetaChain, if onRevert reverts, onAbort is called on ZetaChain with outgoing true.

@fadeev
Copy link
Member Author

fadeev commented Jan 22, 2025

On a second though, when you do a regular deposit from connected chain to ZetaChain and it reverts, we shouldn't be calling onAbort, right?

@lumtis
Copy link
Member

lumtis commented Jan 22, 2025

If EVM call to ZetaChain reverts, onAbort is executed on ZetaChain with outgoing false.

Only if onRevert on EVM reverts itself

If EVM deposit or deposit and call reverts, if the ZRC-20 amount is enough to cover call back to the connected chain, onRevert is executed on a connected chain, if the amount is not enough, onAbort is executed on ZetaChain with outgoing false.

Yes

If ZetaChain call/deposit/deposit and call to connected chain fails, onRevert is executed on ZetaChain, if onRevert reverts, onAbort is called on ZetaChain with outgoing true.

Yes

On a second though, when you do a regular deposit from connected chain to ZetaChain and it reverts, we shouldn't be calling onAbort, right?

I don't think there are particular workflow where a simple deposit would reverts, but in this case the fund would be sent back to the caller

onAbort is always called (if abortAddress specified) as the last resort for everything

@fadeev fadeev marked this pull request as ready for review January 23, 2025 13:27
@fadeev fadeev requested review from lumtis and skosito as code owners January 23, 2025 13:27
@fadeev
Copy link
Member Author

fadeev commented Jan 23, 2025

To test this functionality use zeta-chain/example-contracts#230

cd localnet
yarn link
cd ../example-contracts/examples/call
yarn link @zetachain/localnet
./scripts/localnet.sh start

The localnet script has already been updated with calls that should trigger onAbort. Reverts have also been added to contracts.

You should see something like this:

[ZetaChain]: onRevert failed: Error: transaction execution reverted (action="sendTransaction", data=null, reason=null, invocation=null, revert=null, transaction={ "data": "", "from": "0x735b14BB79463307AAcBED86DAf3322B1e6226aB", "to": "0x5FC8d32690cc91D4c39d9d3abcBD16989F875707" }, receipt={ "_type": "TransactionReceipt", "blobGasPrice": "1", "blobGasUsed": null, "blockHash": "0x1defd3eb86cb122ddd44005ca5d72a0772e9af55b7747bfb690ecc7651d6c07c", "blockNumber": 100, "contractAddress": null, "cumulativeGasUsed": "30674", "from": "0x735b14BB79463307AAcBED86DAf3322B1e6226aB", "gasPrice": "10000000000", "gasUsed": "30674", "hash": "0x4a946493d997b6b1c673d5edaf2873f0bf9c45c8f86426afe98f115cb92637f2", "index": 0, "logs": [  ], "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "root": null, "status": 0, "to": "0x5FC8d32690cc91D4c39d9d3abcBD16989F875707" }, code=CALL_EXCEPTION, version=6.13.2)

[ZetaChain]: Transferring tokens to abortAddress 0xc351628EB244ec633d5f21fBD6621e1a683B1181

[ZetaChain]: Executing onAbort

[ZetaChain]: Event from onAbort: {"_type":"log","address":"0xc351628EB244ec633d5f21fBD6621e1a683B1181","blockHash":"0x730abbed4c18e39c4096b456506411ffdd4aea642bd515c21d4def4967a189c4","blockNumber":101,"data":"0x00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000001241626f7274206f6e205a657461436861696e000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000050000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000002a3078633335313632384542323434656336333364356632316642443636323165316136383342313138310000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000023078000000000000000000000000000000000000000000000000000000000000","index":0,"removed":false,"topics":["0x1db2949e4142fe8b641ad8aad998e42b8968ccf18acb94c49c4c9f5d67eaa927"],"transactionHash":"0x405baf7301c2ec6453a03fb69c3ced3bca6a0da181de3d995d1d79f791dd270f","transactionIndex":0}
[ZetaChain]: onCall failed: Error: transaction execution reverted (action="sendTransaction", data=null, reason=null, invocation=null, revert=null, transaction={ "data": "", "from": "0x735b14BB79463307AAcBED86DAf3322B1e6226aB", "to": "0x5FC8d32690cc91D4c39d9d3abcBD16989F875707" }, receipt={ "_type": "TransactionReceipt", "blobGasPrice": "1", "blobGasUsed": null, "blockHash": "0x5b5cd5fd1460cde1b68dca622703439d6e5b18af917761f182035a1ef1330a2f", "blockNumber": 103, "contractAddress": null, "cumulativeGasUsed": "59200", "from": "0x735b14BB79463307AAcBED86DAf3322B1e6226aB", "gasPrice": "10000000000", "gasUsed": "59200", "hash": "0xee47dbbfeef6ec842e638457efe53a067cfdd6391869e35350a3b41926c40ca0", "index": 0, "logs": [  ], "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "root": null, "status": 0, "to": "0x5FC8d32690cc91D4c39d9d3abcBD16989F875707" }, code=CALL_EXCEPTION, version=6.13.2)

[ethereum]: callOnRevert is false, transferring amount 990000000000000000 of gas tokens to revertAddress 0xFD471836031dc5108809D173A067e8486B9047A3

@fadeev
Copy link
Member Author

fadeev commented Jan 23, 2025

This is not a breaking change, so I think once this is merged, we can ship it, even if this functionality is not available on testnet yet. Devs will have a chance to test it and share their feedback.

Copy link
Member

@lumtis lumtis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@fadeev fadeev merged commit 9f2213a into main Jan 23, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants