Skip to content

Commit 24c4047

Browse files
committed
Update docs
1 parent 53ac259 commit 24c4047

File tree

2 files changed

+25
-16
lines changed

2 files changed

+25
-16
lines changed

ibc/docs/ics24.md

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
# ICS-24 Host Requirements <!-- omit in toc -->
22

33
- [Overview](#overview)
4+
- [Host Configuration](#host-configuration)
45
- [Implementation](#implementation)
6+
- [Persistence](#persistence)
57
- [Paths and Identifiers](#paths-and-identifiers)
68
- [Timestamps](#timestamps)
79
- [IBC State](#ibc-state)
@@ -45,15 +47,15 @@ The following is a simplified sequence diagram of an IBC fungible token transfer
4547
```mermaid
4648
sequenceDiagram
4749
actor UA as User A
48-
box Blue Chain A
50+
box Transparent Chain A
4951
participant A1 as Validator A
5052
participant A2 as IBC Host A
5153
participant A3 as Light Client B
5254
end
5355
box Transparent Relayer
5456
actor R1 as Relayer
5557
end
56-
box Red Chain B
58+
box Transparent Chain B
5759
participant B1 as Validator B
5860
participant B2 as IBC Host B
5961
participant B3 as Light Client A
@@ -152,23 +154,12 @@ See: [ibc/module.go](../module.go) for the specific implementation details.
152154

153155
With the `IbcMessage` now propagated through the network's mempool, when it is reaped (by the block proposer) the message's validity will be handled by first determining the type of the `IbcMessage`:
154156

155-
- `UpdateIbcStore`: The `key` and `value` fields of the `IbcMessage` are inserted into the `ibc_messages` Postgres table along with the current height
156-
- `PruneIbcStore`: The `key` with a `nil` value is passed into the `ibc_messages` Postgres table along with the current height
157-
158-
_Note: Prior to insertion the `key` and `value` fields of the messages are hexadecimally encoded into strings._
157+
- `UpdateIbcStore`: The `key` and `value` fields are tracked by persistence and used to update the `ibc` store state tree
158+
- `PruneIbcStore`: The `key` field is tracked by persistence and marked for removal in the `ibc` store state tree
159159

160160
### State Transition
161161

162-
When the new state hash is computed, the different state trees read the updates from their respective Postgres tables and update the trees accordingly. For each entry in the `ibc_message` table depending on the entries `value` field the tree will perform one of two operations:
163-
164-
- `value == nil`
165-
- This is a `PruneIbcStore` message and thus the tree will delete the entry with the given `key`
166-
- `ibcTree.Delete(key)`
167-
- `value != nil`
168-
- This is an `UpdateIbcStore` message and thus the tree will update the entry with the given `key` to have the given `value`
169-
- `ibcTree.Update(key, value)`
170-
171-
The new root hash of the IBC store tree is then included in the `rootTree` and the new state hash is computed, ensuring the IBC store's state is consistent across the network.
162+
See: [PROTOCOL_STATE_HASH.md](../../persistence/docs/PROTOCOL_STATE_HASH.md#ibc-state-tree) for more information on how the persistence module uses the data it has tracked from the `IbcMessage` objects, in order to update the actual state trees and in turn the root hash.
172163

173164
[ics24]: https://github.com/cosmos/ibc/blob/main/spec/core/ics-024-host-requirements/README.md
174165
[ics20]: https://github.com/cosmos/ibc/blob/main/spec/app/ics-020-fungible-token-transfer/README.md

persistence/docs/PROTOCOL_STATE_HASH.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Alternative implementation of the persistence module are free to choose their ow
1010
- [Block Proto](#block-proto)
1111
- [Trees](#trees)
1212
- [Compute State Hash](#compute-state-hash)
13+
- [IBC State Tree](#ibc-state-tree)
1314
- [Store Block (Commit)](#store-block-commit)
1415
- [Failed Commitments](#failed-commitments)
1516

@@ -96,6 +97,23 @@ sequenceDiagram
9697
deactivate P
9798
```
9899

100+
### IBC State Tree
101+
102+
When the new state hash is computed, the different state trees read the updates from their respective Postgres tables and update the trees accordingly.
103+
104+
`IbcMessage` objects are inserted into the `ibc_message` table in two ways., depending on the IBC messages' type: 1. `UpdateIbcStore`: the `key` and `value` fields are inserted with the height into the table 2. `PruneIbcStore`: the `key` with a `nil` value is inserted into the table
105+
106+
For each entry in the `ibc_message` table depending on the entries `value` field the tree will perform one of two operations:
107+
108+
- `value == nil`
109+
- This is a `PruneIbcStore` message and thus the tree will delete the entry with the given `key`
110+
- `ibcTree.Delete(key)`
111+
- `value != nil`
112+
- This is an `UpdateIbcStore` message and thus the tree will update the entry with the given `key` to have the given `value`
113+
- `ibcTree.Update(key, value)`
114+
115+
_Note: Prior to insertion the `key` and `value` fields of the messages are hexadecimally encoded into strings._
116+
99117
## Store Block (Commit)
100118

101119
When the `Commit(proposer, quorumCert)` function is invoked, the current context is committed to disk. The `PersistenceContext` does the following:

0 commit comments

Comments
 (0)