1. 引言

ics-024-host-requirements 中,定义了实现IBC的host状态机所需实现的最小接口集合属性。

2. 动机

IBC设计为不同区块链和状态机之间的通用标准,因此必须明确定义host的要求。

IBC应设计为对底层状态机来说是尽可能简单的接口,以使正确实现最大化。

3. 技术说明

3.1 module system

host状态机必须支持module system,通过这种方式,自包含的、可能相互不信任的代码包可安全地运行在同一ledger上,控制它们如何以及何时允许其他模块与其通讯,并由a “master module” 或 execution environment来识别和操作。

IBC/TAO说明书中定义了2种module实现:

  • 核心的"IBC handler" module
  • “IBC relayer” module

IBC/APP说明书中进一步定义了处理应用逻辑的特定packet的module。

IBC要求“master module” 或 execution environment可用于 批准该host状态机上的其它module来访问 IBC handler module 和(或)IBC routing module,但除此之外,不会对可能位于状态机上的任何其他模块的功能或通信能力施加要求。

3.2 paths, identifiers, separators

“Indentifier”:为a bytestring,作为存储在state中object的key,如connection、channel 或 light client。
identifier必须为非空值(长度为正数)。
identifier必须包含以下字符类型中的一种:

  • 字母
  • ., _, +, -, #
  • [, ], <, >

“path”:为a bytestring,作为存储在state中object的key。paths中仅包含identifiers,constant strings以及分隔符“/”。
identifier并不打算成为有价值的资源-为了防止名称占用,可以实现最小长度要求或伪随机生成,但本规范不施加特殊限制。

分隔符“/”用于分隔和连接2个identifiers,或一个identifier + 1个constant bytestring。identifiers中不能包含“/”字符,以避免混淆。

插入的变量以大括号包围,作为定义path格式的简写,如client/{clientIdentifier}/consensusState

本规范中的所有identifier以及所有string,都应以ASCII编码。

默认,identifier中的字符具有最小最大长度限制:

Port identifier Client identifier Connection identifier Channel identifier
2 - 128 9 - 64 10 - 64 10 - 64

3.3 key/value store

host 状态机必须提供key/value store接口,至少有以下三个函数:

  • get:
type get = (path: Path) => Value | void
  • set
type set = (path: Path, value: Value) => void
  • delete
type delete = (path: Path) => void

其中的Pathd定义见3.2节。Value为任意bytestring encoding of a particular data structure。

以上三个函数必须仅对IBC handler module许可授权,因此,仅IBC handler module可setdelete 其通过get读到的path。可实现为a sub-store (prefixed key-space) of a larger key/value store used by the entire state machine。

host状态机必须为该接口实现2个实例:

  • 1)provableStore:for storage read by (i.e. proven to) other chains。

    • MUST write to a key/value store whose data can be externally proved with a vector commitment as defined in ICS 23.
    • MUST use canonical data structure encodings provided in these specifications as proto3 files
  • 2)privateStore: for storage local to the host, upon which get, set, and delete can be called, e.g. provableStore.set('some/path', 'value')
    • MAY support external proofs, but is not required to - the IBC handler will never write data to it which needs to be proved.
    • MAY use canonical proto3 data structures, but is not required to - it can use whatever format is preferred by the application environment.

注意:任意实现了以上方法和属性的key/value store接口对于IBC就足够了。

3.4 path-space

当前,IBC/TAO中为provableStoreprivateStore推荐了如下path前缀:【注意下一client-related paths反应了ICS7中定义的Tendermint client,若为其它client,相关定义可能不同。】

Store Path format Value type Defined in
provableStore “clients/{identifier}/clientType” ClientType ICS 2
privateStore “clients/{identifier}/clientState” ClientState ICS 2
provableStore “clients/{identifier}/consensusStates/{height}” ConsensusState ICS 7
privateStore "clients/{identifier}/connections []Identifier ICS 3
provableStore “connections/{identifier}” ConnectionEnd ICS 3
privateStore “ports/{identifier}” CapabilityKey ICS 5
provableStore “channelEnds/ports/{identifier}/channels/{identifier}” ChannelEnd ICS 4
provableStore “nextSequenceSend/ports/{identifier}/channels/{identifier}” uint64 ICS 4
provableStore “nextSequenceRecv/ports/{identifier}/channels/{identifier}” uint64 ICS 4
provableStore “nextSequenceAck/ports/{identifier}/channels/{identifier}” uint64 ICS 4
provableStore “commitments/ports/{identifier}/channels/{identifier}/sequences/{sequence}” bytes ICS 4
provableStore “receipts/ports/{identifier}/channels/{identifier}/sequences/{sequence}” bytes ICS 4
provableStore “acks/ports/{identifier}/channels/{identifier}/sequences/{sequence}” bytes ICS 4

3.5 module布局

host状态机上modules布局为:(Aardvark、Betazoid 和 Cephalopod 为任意modules)

+----------------------------------------------------------------------------------+
|                                                                                  |
| Host State Machine                                                               |
|                                                                                  |
| +-------------------+       +--------------------+      +----------------------+ |
| | Module Aardvark   | <-->  | IBC Routing Module |      | IBC Handler Module   | |
| +-------------------+       |                    |      |                      | |
|                             | Implements ICS 26. |      | Implements ICS 2, 3, | |
|                             |                    |      | 4, 5 internally.     | |
| +-------------------+       |                    |      |                      | |
| | Module Betazoid   | <-->  |                    | -->  | Exposes interface    | |
| +-------------------+       |                    |      | defined in ICS 25.   | |
|                             |                    |      |                      | |
| +-------------------+       |                    |      |                      | |
| | Module Cephalopod | <-->  |                    |      |                      | |
| +-------------------+       +--------------------+      +----------------------+ |
|                                                                                  |
+----------------------------------------------------------------------------------+

3.6 consensus state introspection

host 状态机:

  • 必须提供getCurrentHeight函数获取其当前height。
  • 必须定义唯一的ConsensusState类型,实现ICS2要求,并可进行binary序列化。
  • 必须提供getConsensusState函数获取其当前共识状态。getConsensusState MUST return the consensus state for at least some number n of contiguous recent heights, where n is constant for the host state machine. Heights older than n MAY be safely pruned (causing future calls to fail for those heights).
  • 必须提供getStoredRecentConsensusStateCount返回最近存储的n个共识状态。

3.7 commitment path introspection

host 链:

  • 必须提供getCommitmentPrefix函数返回commitment path。返回的CommitmentPrefix(必须为常量)会作为host状态机key-value store的前缀。
type getCommitmentPrefix = () => CommitmentPrefix

CommitmentRoot rootCommitmentState state一起,满足如下属性:

if provableStore.get(path) === value {prefixedPath = applyPrefix(getCommitmentPrefix(), path)if value !== nil {proof = createMembershipProof(state, prefixedPath, value)assert(verifyMembership(root, proof, prefixedPath, value))} else {proof = createNonMembershipProof(state, prefixedPath)assert(verifyNonMembership(root, proof, prefixedPath))}
}

3.8 timestamp access

host 链 :

  • 必须提供currentTimestamp()函数返回当前Unix timestamp。

为了在timeout中安全使用timestamp,后续headers的timestamp必须为非递减的。

参考资料

[1] ics-024-host-requirements

IBC协议之 ics-024-host-requirements相关推荐

  1. 跨链Cosmos(3)IBC协议二

    1. IBC协议中设计了两个消息: IBCBlockCommitTx 发送方所在区块链的最新的区块信息. IBCPacketTx 跨链交易本身的信息,及其在发送方链中被打包的区块信息. 两个链建立连接 ...

  2. 跨链Cosmos(3)IBC协议

    1. (Inter-Blockchain Communication Protocol)IBC定义 IBC协议用于Hub与Zone之间消息传递. 通过数据包交换在多个不同的区块链网络之间转移数据和状态 ...

  3. 常见工控通讯协议(ICS)

    工控概述 工业控制系统(ICS)是一个通用术语,它包括几种工业生产中使用的控制系统类型,包括监控和数据采集(SCADA)系统,分布式控制系统(DCS),和其他较小的控制系统配置,如可编程逻辑控制器(P ...

  4. 跨链(8)Cosmos之“跨链交互协议IBC”前言

    1. 跨链流程 A链上的Alice发送10个ATOM代币给B链上的Bob step1. Tracking A链上的IBC模块会不断的同步B链上的区块头信息,B链上的IBC同理.通过这种方式,双方能够实 ...

  5. Cosmos IBC

    1. 引言 IBC(Inter-Blockchain Communication)协议用于链之间 以及 rollup之间 通讯. IBC协议是Cosmos中最核心的接口协议,能够实现区块链间跨链消息的 ...

  6. 《TCP/IP详解 卷1:协议》第4章 ARP:地址解析协议

    4.1 引言 本章我们要讨论的问题是只对TCP/IP协议簇有意义的IP地址.数据链路如以太网或令牌环网都有自己的寻址机制(常常为48 bit地址),这是使用数据链路的任何网络层都必须遵从的.一个网络如 ...

  7. TCP与UDP传输协议

    目录结构: contents structure [-] 1 TCP协议和UDP协议的比较 1.1 TCP协议 TCP的全称是Transmission Control Protocol (传输控制协议 ...

  8. ARP地址解析协议与RARP逆地址解析协议

    这里写目录标题 区分ARP与RARP ARP:地址解析协议 ARP高速缓存 ARP高速缓存超时设置 用户输入命令时ARP操作流程 ARP的分组格式 ARP代理 免费ARP RARP逆地址解析协议 RA ...

  9. FTP协议及其安全问题

    文章目录 一.FTP简单介绍 二.FTP安全问题 相关链接 一.FTP简单介绍 文件共享协议有两大类,一类是复制整个文件,另一类是联机访问.FTP是文件传送协议,属于文件共享协议中复制整个文件.(NF ...

最新文章

  1. 自动取款机如何使用无卡取款_如何设计700度高温下使用的自动夹具?
  2. 隐马尔可夫HMM中viterbi算法
  3. pycharm 调试(debug)模式时界面上的 mute breakpoint 是什么意思?(239)
  4. 行健设计_广西大学行健文理学院参加2019年第七届广西大学生工业设计大赛
  5. 第五周软件工程作业-每周例行报告
  6. html css position,[CSS]CSS Position 详解
  7. 《那些年啊,那些事——一个程序员的奋斗史》——107
  8. 华为推出鸿蒙超级系统,华为鸿蒙系统正式发布!十个人里竟然只有两个人支持?...
  9. POJ 1486 Sorting Slides (二分图关键匹配边)
  10. jq数组清空_JQuery 数组获取和删除元素
  11. 微信小程序——绘制时钟
  12. php的get和post,PHP中GET和POST区别
  13. Mac OS 连内外网
  14. itext设置字体间距_微信公众号文章字体怎么修改?行间距、字间距一般设置多少?...
  15. 大二计算机学期总结报告,大二计算机的实训总结.docx
  16. USB无线网卡和PCI-E无线网卡如何选择?
  17. 开启虚拟机的时候出现不支持虚拟化的Intel VT-x/EPT
  18. 一张图带你看完图论第一章(包含定义、定理、公式、推导证明和例题)
  19. Mac终端常用命令及报错处理
  20. 怎么使用大疆无人机建模?

热门文章

  1. 程序员普遍薪水都在3万以上?35岁码农用亲身经历和你聊聊
  2. java计算一元二次方程的根_java基础 --- 求一元二次方程的根(分情况讨论)-Go语言中文社区...
  3. Less学习笔记(尚硅谷前端less教程)
  4. 边缘云平台架构及商用实践(联通)
  5. win10系统想下载win7系统自带的游戏——分享游戏压缩包
  6. 如何通过晋升答辩?既升职又加薪!
  7. 关于解决HbuilderX终端不能输入问题
  8. linux进程的使用xps,linux kernel 网络协议栈之xps特性详解
  9. 用C语言写的一个顺序表实现图书馆书籍管理
  10. mavlink解码java_Mavlink通信协议Java版本