Skip to content

Commit

Permalink
Update interaction timeout (#73)
Browse files Browse the repository at this point in the history
* update interaction.md to set timeout height

Signed-off-by: Ryo Sato <ryo.sato@datachain.jp>

* use ibc-solidity v0.3.14

Signed-off-by: Ryo Sato <ryo.sato@datachain.jp>

* improve the explanation about timeout height

Signed-off-by: Ryo Sato <ryo.sato@datachain.jp>

---------

Signed-off-by: Ryo Sato <ryo.sato@datachain.jp>
  • Loading branch information
3100 authored Sep 29, 2023
1 parent 48e569c commit 0fe640a
Show file tree
Hide file tree
Showing 10 changed files with 74 additions and 20 deletions.
20 changes: 17 additions & 3 deletions contracts/minitoken/solidity/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion contracts/minitoken/solidity/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@
"truffle": "5.8.4"
},
"dependencies": {
"@hyperledger-labs/yui-ibc-solidity": "git+https://git@github.com/hyperledger-labs/yui-ibc-solidity.git#v0.3.13"
"@hyperledger-labs/yui-ibc-solidity": "git+https://git@github.com/hyperledger-labs/yui-ibc-solidity.git#v0.3.14"
}
}
8 changes: 4 additions & 4 deletions docsrcs/yui-ibc-solidity/docs/minitoken/contract.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ Use [solidity-protobuf](https://github.com/datachainlab/solidity-protobuf) to ge
First, get solidity-protobuf and install the necessary modules.
For details on the revision specified by yui-ibc-solidity, please refer to the following:

https://github.com/hyperledger-labs/yui-ibc-solidity/tree/v0.3.13#for-developers
https://github.com/hyperledger-labs/yui-ibc-solidity/tree/v0.3.14#for-developers

```sh
git clone https://github.com/datachainlab/solidity-protobuf.git
Expand Down Expand Up @@ -227,8 +227,8 @@ function _sendPacket(
### IBCAppBase

When the IBC Module receives a Channel handshake or a Packet, it needs to be called back to MiniToken.
It is convenient to inherit from the abstract contract [IBCAppBase](https://github.com/hyperledger-labs/yui-ibc-solidity/blob/v0.3.13/contracts/apps/commons/IBCAppBase.sol) provided by `yui-ibc-solidity`.
This implements the [IIBCModule](https://github.com/hyperledger-labs/yui-ibc-solidity/blob/v0.3.13/contracts/core/05-port/IIBCModule.sol) interface as shown below.
It is convenient to inherit from the abstract contract [IBCAppBase](https://github.com/hyperledger-labs/yui-ibc-solidity/blob/v0.3.14/contracts/apps/commons/IBCAppBase.sol) provided by `yui-ibc-solidity`.
This implements the [IIBCModule](https://github.com/hyperledger-labs/yui-ibc-solidity/blob/v0.3.14/contracts/core/05-port/IIBCModule.sol) interface as shown below.

```solidity
interface IIBCModule {
Expand Down Expand Up @@ -324,7 +324,7 @@ The token implemented here is different from ICS-20.

For an example of ICS-20 implementation, please refer to the following:

https://github.com/hyperledger-labs/yui-ibc-solidity/tree/v0.3.13/contracts/apps
https://github.com/hyperledger-labs/yui-ibc-solidity/tree/v0.3.14/contracts/apps

### Distinction between currency units

Expand Down
15 changes: 14 additions & 1 deletion docsrcs/yui-ibc-solidity/docs/minitoken/interaction.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,30 @@ MiniToken.deployed()
.then(event => console.log(event));
```

## Check the block height on ledger IBC1

When sending a Packet from IBC0 to IBC1, it's necessary to specify the height at which it will timeout based on the receiving ledger IBC1.
Therefore, let's check the current block height on IBC1.

```js
await web3.eth.getBlockNumber()
```

## Transfer token from Alice on ledger IBC0 to Bob on ledger IBC1

Transfer 50 MiniTokens to Bob on IBC1.
For the height at which the Packet will timeout on the receiving ledger, specify a height that adds sufficiently to the one previously obtained for IBC1, ensuring adequate time for Packet relay.
For instance, if the height of IBC1 was 500, considering that this operation will be performed immediately afterward, adding about 1000 should be enough, depending on the environment.

```js
const port = "transfer";
const channel = "channel-0";

const bob = accounts[2];
// Please configure according to your environment
const timeoutHeight = 1500;
await MiniToken.deployed()
.then(instance => instance.sendTransfer(50, bob, port, channel, 0, {from: alice}));
.then(instance => instance.sendTransfer(50, bob, port, channel, timeoutHeight, {from: alice}));
```

## Check the MiniToken balance from Bob on the ledger IBC1.
Expand Down
2 changes: 1 addition & 1 deletion docsrcs/yui-ibc-solidity/docs/minitoken/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ This tutorial will take you through building your first IBC application with
[yui-ibc-solidity](https://github.com/hyperledger-labs/yui-ibc-solidity).
We will create a smart contract that allows us to transfer tokens between two ledgers using IBC.
At the time of writing the tutorial, we are using
[v0.3.13](https://github.com/hyperledger-labs/yui-ibc-solidity/tree/v0.3.13).
[v0.3.14](https://github.com/hyperledger-labs/yui-ibc-solidity/tree/v0.3.14).


You will learn how to
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ Packetを定義したら
まず、solidity-protobufを取得し、必要なモジュールをインストールします。
yui-ibc-solidityが指定するrevisionについての詳細は以下を参照ください。

https://github.com/hyperledger-labs/yui-ibc-solidity/tree/v0.3.13#for-developers
https://github.com/hyperledger-labs/yui-ibc-solidity/tree/v0.3.14#for-developers

```sh
git clone https://github.com/datachainlab/solidity-protobuf.git
Expand Down Expand Up @@ -227,8 +227,8 @@ function _sendPacket(
### IBCAppBase

IBC ModuleでのChannelハンドシェイクやPacketを受信した際などに、MiniTokenへコールバックしてもらう必要があります。
yui-ibc-solidityで提供されている抽象コントラクトである[IBCAppBase](https://github.com/hyperledger-labs/yui-ibc-solidity/blob/v0.3.13/contracts/apps/commons/IBCAppBase.sol)を継承すると便利です。
これは以下のような[IIBCModule](https://github.com/hyperledger-labs/yui-ibc-solidity/blob/v0.3.13/contracts/core/05-port/IIBCModule.sol)インタフェースを実装しています。
yui-ibc-solidityで提供されている抽象コントラクトである[IBCAppBase](https://github.com/hyperledger-labs/yui-ibc-solidity/blob/v0.3.14/contracts/apps/commons/IBCAppBase.sol)を継承すると便利です。
これは以下のような[IIBCModule](https://github.com/hyperledger-labs/yui-ibc-solidity/blob/v0.3.14/contracts/core/05-port/IIBCModule.sol)インタフェースを実装しています。

```solidity
interface IIBCModule {
Expand Down Expand Up @@ -325,7 +325,7 @@ function onAcknowledgementPacket(Packet.Data calldata packet, bytes calldata ack

尚、ICS-20の実装例としては以下を参照ください。

https://github.com/hyperledger-labs/yui-ibc-solidity/tree/v0.3.13/contracts/apps
https://github.com/hyperledger-labs/yui-ibc-solidity/tree/v0.3.14/contracts/apps

### 通貨単位の区別

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,30 @@ MiniToken.deployed()
.then(event => console.log(event));
```

## 台帳IBC1上のBlock高さを確認

IBC0上からIBC1へ向けてPacketを送る際に、Packetがタイムアウトする高さを受信側台帳であるIBC1を基準に指定する必要があります。
そのため、現在のIBC1上でBlockの高さを確認しておきましょう。

```js
await web3.eth.getBlockNumber()
```

## 台帳IBC0上のAliceから台帳IBC1上のBobへトークン転送

IBC1上のBobへMiniTokenを50だけ転送します。
Packetが受信側台帳でタイムアウトする高さとして、1つ前で得たIBC1の高さにPacket中継を行うのに十分な高さを追加します。
例えばIBC1の高さが500だったとして、直後にこの操作を行うのであれば環境にもよりますがここでは1000ほど加えておけば十分すぎるでしょう。

```js
const port = "transfer";
const channel = "channel-0";

const bob = accounts[2];
// あなたの環境に合わせて設定してください
const timeoutHeight = 1500
await MiniToken.deployed()
.then(instance => instance.sendTransfer(50, bob, port, channel, 0, {from: alice}));
.then(instance => instance.sendTransfer(50, bob, port, channel, timeoutHeight, {from: alice}));
```

## 台帳IBC1上のBobから、MiniToken残高を確認
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ sidebar_position: 1
[yui-ibc-solidity](https://github.com/hyperledger-labs/yui-ibc-solidity)
を用いて、初めてのIBCアプリケーションを構築するプロセスを紹介します。
チュートリアル執筆時点では
[v0.3.13](https://github.com/hyperledger-labs/yui-ibc-solidity/tree/v0.3.13)
[v0.3.14](https://github.com/hyperledger-labs/yui-ibc-solidity/tree/v0.3.14)
を用いています。

IBCを使って2つの台帳間でトークンを転送できるスマートコントラクトを作成します。
Expand Down
20 changes: 17 additions & 3 deletions samples/minitoken-besu-ethereum/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 0fe640a

Please sign in to comment.