当前位置: 首页区块链正文 2021.05 – Substrate 技术更新速递 ## 重要提交和发布 * [为了在 benchmarking 时可以估计出存储项的编码结果最大值,引入了新的接口 BoundedEncodedLen](https://link.zhihu.com/?target=https%3A//github.com/paritytech/subs%3Ccode%3Etrate/issues/8719%3C/code%3E) – 为基本类型、固定大小的数组、tuple、BoundedVec、Option、Result 等等 Substrate 所支持的存储数据类型添加了对应的实现。 * [从 BlockBuilder runtime api 中删除了 random_seem 方法](https://link.zhihu.com/?target=https%3A//github.com/paritytech/substrate/pull/8718) – 此方法并没有被使用,在runtime里如果需要随机数应当使用 `Randomness` API。 * [在 frame_support 的 pallet_prelude 中添加了 BoundedVec](https://link.zhihu.com/?target=https%3A//github.com/paritytech/substrate/pull/8710) – 无需额外的引入就可以直接使用 BoundedVec 这一数据类型,runtime开发时,对于vector集合类型也应优先使用此类型,[例子](https://link.zhihu.com/?target=https%3A//github.com/paritytech/substrate/pull/8665)。 * [增加了获取 reserved nodes 的 RPC 接口](https://link.zhihu.com/?target=https%3A//github.com/paritytech/substrate/pull/8704) – Reserved nodes 是节点所设置的保留节点,用于网络之间的连接,如果节点把 reserved only 设置为true,那么只能连接 reserved nodes。 * [将 runtime version 嵌入 wasm 的 custom section](https://link.zhihu.com/?target=https%3A//github.com/paritytech/substrate/pull/8688) – 当前 runtime 的 wasm 暴露了一个函数 Runtime_version 来返回其版本信息,这种方式需要首先启动 Substrate runtime 执行环境,再执行该函数才可以获取结果,这种方式太重了。通过在wasm的custom添加runtime版本信息,只需要遍历不同的section再进行解码就可以了。 * [为 Substrate 底层通信协议引入了回退机制](https://link.zhihu.com/?target=https%3A//github.com/paritytech/substrate/pull/8682) – 遗留的通信协议很多需要重新命名,为了向后兼容,在配置某个通信协议的时候可以传入回退的协议名称。 * [subkey:显示公钥的 SS58 编码](https://link.zhihu.com/?target=https%3A//github.com/paritytech/substrate/pull/8674) – 对于 sr25519 和 ed25519 密码算法,account id 和公钥信息是一致的,因此account id经过SS58编码获取的address和公钥的SS58编码结果是一样的;对于 ECDSA,是将公钥进行blake2算法哈希之后获取的account id,相应的,SS58编码结果也就不再相同。将公钥的SS58编码结果显示出来,可以方便的使用在 chain spec JSON文件和 session keys的编码中。 * [实现了 StorageNMap](https://link.zhihu.com/?target=https%3A//github.com/paritytech/substrate/pull/8635) – 这一新的存储类型可以潜在地支持3个甚至更多键的映射类型,也可以在将来替换StorageMap和StorageDoubleMap类型。 * [引入了 PalletInfoAccess 接口,并在Pallet结构体应用的pallet宏里进行实现](https://link.zhihu.com/?target=https%3A//github.com/paritytech/substrate/pull/8630) – 此接口提供了pallet的 index 和 name,并存在于metadata中,潜在地,可以将目前runtime中配置的模块PalletId删除,而在pallet实现里直接使用此接口提供的信息。 ## 设计方案讨论 * [关于在pallets里废弃 runtime upgrade 方法的简单讨论](https://link.zhihu.com/?target=https%3A//github.com/paritytech/substrate/pull/8687) – runtime 升级过程中如何处理遗留数据,对开发者产生了很大的负担,希望一个开发者友好的 on_runtime_upgrade 替代方案能够尽快实现。 * [通过类型信息构建Substrate链的元数据](https://link.zhihu.com/?target=https%3A//github.com/paritytech/substrate/pull/8615) – 使用了 [scale-info](https://link.zhihu.com/?target=https%3A//github.com/paritytech/scale-info),可以极大地降低客户端解析和维护元数据的负担。 * [Statemint:支持使用Assets模块的资产支付交易手续费](https://link.zhihu.com/?target=https%3A//github.com/paritytech/statemint/pull/51) – 如何使用其它链的资产为当前链支付交易费用。 ## 文档和资料 * [添加了更多 XCM 代码的引用文档](https://link.zhihu.com/?target=https%3A//github.com/paritytech/polkadot/pull/2948) – xcm-format 文档比较抽象,结合实现代码和代码注释可以更好地理解消息格式和传递的机制。 * [官方存证教程更新至 FRAME v2](https://link.zhihu.com/?target=https%3A//substrate.dev/docs/en/tutorials/build-a-dapp/) – FRAME v2 对开发者更加友好,官方教程正在逐步迁移使用新的API。 ## 技术生态和社区 * [Polkadot Decoded 线上活动将在5月19号和20号举行](https://link.zhihu.com/?target=https%3A//decoded.polkadot.network/program) – 不仅有最新的Polkadot进展,还会有Substrate技术的深入分享。 * [Substrate 构建者计划里程碑更新](https://link.zhihu.com/?target=https%3A//www.parity.io/substrate-builders-program-milestone-update-may-2021/) – 这一计划是Parity支持社区团队开发的重要方式,包括构建生态工具、基于Substrate的链等,目前有超过50个团队,涵盖了声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。 收藏 海报 链接