You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/architecture/adr-010.md
+21-12Lines changed: 21 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -16,7 +16,7 @@ App-chain specific logics can be embedded to the pre-compiled so that it could b
16
16
### Fork go-ethereum for stateful precompiled support
17
17
18
18
One of the major difficulties in supporting pre-compiled is the lack of flexibility in geth for defining custom precompiled and its non-ability to modify the state.
19
-
We made the choice of forking geth and implement additional interfaces and logics so that app-chain can define its own precompiled.
19
+
We made the choice of forking geth and implement additional interfaces so that app-chain can define its own precompiled.
20
20
21
21
The PR [#7](https://github.com/evmos/go-ethereum/pull/7) implements the ability to set custom precompiled to the EVM.
22
22
while this PR [#10](https://github.com/evmos/go-ethereum/pull/10) allows the precompiled to modify the state (for stateful precompiled)
@@ -26,9 +26,7 @@ In the future, we are planning to maintain the following fork permanently
26
26
27
27
### Implement pre-compiled for cosmos native module
28
28
29
-
We provide pre-compile for cosmos native module such as bank module.
30
-
31
-
The input and output of methods are mapped with those defined cosmos native transactions
29
+
We provide pre-compiles for cosmos native module such as bank module.
32
30
33
31
```solidity
34
32
@@ -41,10 +39,14 @@ interface IBankModule {
41
39
42
40
43
41
```
42
+
The input and output of methods are mapped with those defined cosmos native transactions.
43
+
Because the precompiled is called at the evm layer, it uses the evm authentication instead of the cosmos authentication for transactions.
44
+
It is important to define for each precompiled module the range of action "authorized" for each request.
45
+
For the bank module, the precompiled is authenticated with `msg.sender` address. The smart contracts or users can only mint/burn cosmos coins denoted by the denom `evm/0x{msg.sender}` or transfer coins from the `0x{msg.sender}` account.
44
46
45
-
To call a precompiled, create an instance of the module interface with the precompiled address.
46
-
The methods are ABI encoded, and can be called directly as calling the function through the interface:
47
47
48
+
To call a precompiled from a smart contract, create an instance of the module interface with the precompiled address.
49
+
The methods are ABI encoded, and can be called directly as calling the function through the interface:
48
50
49
51
```solidity
50
52
@@ -94,26 +96,33 @@ const (
94
96
-> TODO describe the change in go-relayer
95
97
96
98
#### ICA
97
-
For ICA, we are following the same standard as for the cosmos module.
The request is authenticated by `msg.sender` and it can only send request on behalf of this account.
108
112
109
-
The calldata in `submitMsgs` represents the cosmos proto-encoded msg to be sent to the destination app-chain. Only one msg is supported at the moment.
113
+
The calldata in `submitMsgs` represents the cosmos proto-encoded message to be sent to the destination app-chain. Only one message can be sent at the moment.
110
114
111
-
For example to call a bank transaction to another app-chain
115
+
For example to call a bank transaction to another app-chain :
112
116
113
117
```solidity
114
-
#todo
115
-
```
116
118
119
+
function ICACallBank(string memory connectionID, uint256 timeout, params.....) public returns (uint64) {
In case of ICA, it is also important to be able to track the result of the transaction `submitMsgs` so that the user or the smart contract can respond accordingly.
119
128
The function `submitMsgs` returns a sequence number that can be used by the user or smart contract to track the state of the msg using the precompiled `ICACallback`.
0 commit comments