Replies: 3 comments 9 replies
-
I think there are potential drawback having the module listening to EVM logs
For the second point , anyone can emit any kind of event within the smart contract. We need a strong mechanism to be sure it is a log emitted by a "contract" module wont break anything. Overall even though I like the idea to have contract interacting with module in cosmos, there could be some security concern because SC has been designed to be run in an isolated context to prevent any wrong behavior that could break the main chain execution. Need to think carefully. |
Beta Was this translation helpful? Give feedback.
-
I think we can implement hooks (pre-post tx) to make more the implementation cleaner and with the same result. Then, we can create a separate module that implements this hooks and just unpacks the logs using the abi |
Beta Was this translation helpful? Give feedback.
-
https://gist.github.com/yihuang/f072e6d91d4845105b7698f52171053a |
Beta Was this translation helpful? Give feedback.
-
Call Native Modules From EVM
To improve interoperanility between EVM and native modules, and inspired by the cosmwasm messaging system, we can introduce a similar messaging system between EVM and native modules.
Call native modules
Logs can be used for evm contract to send and execute messages to native modules, for example:
This log can tell the host to do a native token transfer from the contract address to the recipient after the evm contract succesfully executed, if the native message execution failed, the whole tx is reverted.
Tx post processing
We need to add tx post processing logic to execute the message, the new tx processing procedure would be like this:
Query native modules
State querying can be implemented by precompiled smart contract directly, since we don't need to do the authentication:
The precompiled contract would be something like this:
Allow Sending Native Tokens to EVM Contract
By allow sending native tokens to EVM contract, it enables more interoperability between EVM contract and native modules.
Contract can query the native tokens sent to it by calling some precompiled contract.
So a erc20 contract that wrapping a native token would look like this:
If gravity bridge module is embed, one can even call gravity message directly from the contract, and send the token to ethereum:
https://gist.github.com/yihuang/f072e6d91d4845105b7698f52171053a
Some pseudocode to how how this could work together with gravity bridge to make transparent evm to evm bridge.
Mint Native Tokens from EVM Contract
For an exiting smart contract to convert to native token, it needs to have some native token minting ability. We can provide a call for contract to mint native token whose denomination is just the contract address prefixed with
evm/
.Beta Was this translation helpful? Give feedback.
All reactions