美文网首页EOS技术爱好者
【BM回复】Context Free Actions

【BM回复】Context Free Actions

作者: Lochaiching | 来源:发表于2018-03-22 18:23 被阅读33次

    版权声明:

    以下内容来自微信公共帐号“EOS技术爱好者”,搜索“EOSTechLover”即可订阅,译者Lochaiching。转载必须保留以上声明。仅授权原文转载。

    本文原文内容链接来自于https://github.com/EOSIO/eos/issues/1387,内容提供者wanderingbort,bytemaster和Kevin Heifner,由本号“EOS技术爱好者”翻译。

    此内容是wanderingbort 在2月15号开始这个话题,以下内容经过blockone-syncclient编辑.


    Context Free Actions

    Some computations necessary to build consensus are expensive from either a computational or block space perspective, or both. For example, the proof for inter-blockchain communication (IBC) is large, and validating it can only pass or fail. Once a block is irreversible, this code path and data is useless (unless someone is performing a verbose revalidation of the chain).

    Witness Actions provide a means to perform intense checks in a way that the computation is cheaper during production/validation and both computation and block space are prunable.

    This is conceptually equivalent to Segregated Witness for the EOS.IO blockchain.

    从算力或者(或者加上)区块容量的角度来看,构建共识所需的算力代价昂贵。就像实现区块链通信(IBC)证明需要非常巨大的基础一样,要不验证通过要不就失败了。一旦在区块中不可逆,这些代码路径和数据记录就没有用处了(除非有人重新从头开始验证这条链)。

    在生产或验证的时候,或者算力和区块容量都可以调整删减的时候,见证Action提供了一种严格检查的方法让算力成本变得更低。

    这相当于是在EOS.IO区块链上的隔离见证。

    Details

    New Action Type

    Witness Actions are a new type of action which may only read its own payload and a new section of transaction data referred to as "witness data". They are otherwise identical to normal actions.

    In the example of IBC this action's payload would be the provably retired action from the foreign chain and a block ID from the foreign chain whose state includes the transaction.

    In an example of a document publication platform (PUB) this action's payload would be the hash of a document to publish.

    细节

    新的action类型

    见证是新的action,它可能只能读取自己的有效负载和一段被称为“见证数据”的交易数据,这和标准的action是一样的。

    在IBC的示例中,这个action的有效负载将来自可执行外部链的退出action,以及同样是来自外部链包含交易的区块ID。

    在一个文档发布平台(PUB)的示例中,这个action的有效负载将会是一个公开文档的哈希值。

    Witness Data

    Transactions will contain a new section of data that provides witness data. Witness data is anything needed to process a witness action that doesn not need to persist if you can assume the action processed successfully. This is a broader definition that most cryptographic witness data would include.

    In the example of IBC, witness data would be the merkle proof that the retired action was present in a particular block on the foreign chain and the merkle proof that said block is included in the chain represented by the block ID listed in the action payload

    In an example of PUB the witness data would be the plaintext document.

    见证数据

    交易将包含一部分新的见证数据。假设你能成功进行,见证数据处理需要持久化的见证action。这是一个更广泛的定义,大多数加密见证数据都包括在内。

    在IBC的例子中,见证数据会变成能证明在外部链上特定区块中有退出功能的merkle证明,而merkle证明能够说明在链上的区块代表了被列出来有效负载action的区块ID。

    在PUB的例子中,见证数据将是明文文件。

    Witness Data Access API

    Witness actions can only read their payload and the associated witness data. They cannot write anything. They merely succeed in whole or fail. This makes them stateless or context-free and allows trivial parallel processing.

    In the example of IBC, the WebAssembly code will use this API and the action payload to assert that the proof is correct.

    In an example of PUB, the WebAssembly code will use this API and the action payload to assert that the hash of the document matches the hash in the payload.

    见证数据访问API

    见证action只能读取但不能编辑他们的有效负载和相关的见证数据。他们要不就全盘成功要不就全盘失败。这会让它们成为无状态或context-free,并允许小额的并行处理。

    在IBC的示例中,WebAssembly代码将使用API和有效负载action来assert这个证明是正确的。

    在一个PUB示例中,WebAssembly代码将使用这个API和有效负载action来 assert 文档的哈希值与有效负载中的哈希值是匹配的。

    Sibling Action API

    Non-witness actions will have access to a new API which allows them to assert that the transaction in which a current action is processing also includes another action. Due to our processing model, the current action can then assume that the sibling action was also successfulas any failure in any action is a failure of the transaction as a whole.

    In the example of IBC, the normal action will assert that a sibling action existed routed to the proper action name, with a properly formed payload (the transaction and block ID of the foreign chain). It can then proceed to do stateful processing based on the assumption that this sibling action succeeded and therefore the given action was included in the foreign chain.

    In the example of PUB, the normal action will assert that a sibling action existed with the given hash as a payload and proceed to mark the document as published based on the assumption that this sibling action succeeded and therefore the given hash IS the hash of the desired document.

    姐妹Action API

    非见证action将访问一个新的API,该API允许他们 assert 当前正在处理包含另一个action的交易。由于我们处理模型的关系,目前需要先假定姐妹action是成功的,毕竟任何action的失败都意味着整个交易的失败。

    在IBC的示例中,标准的action可以判断一个姐妹action用一个合适的action名称放在选择好的路径上,并能形成一个合适的有效负载(外部链的交易和区块ID)。基于这样的假设,姐妹action成功了而且给定的action被包含在外链中,它可以继续进行状态中的处理。

    在PUB的例子,基于假设姐妹action成功并能让给出的哈希正好是所需的哈希文档,标准的action可以判断一个姐妹action存在给定的哈希值作为有效负载和公布的文档标记。

    Resource Accounting

    As witness action processing will happen substantially in parallel, it becomes harder to account for in resource controls. However, as it depends on no state data it should also be possible to compute, ahead of time and deterministically, what resources this will consume.

    A transaction will commit to this resource usage, the same way it will commit to packed size as part of #1386

    Note, this commitment will only cover the resources spent on retiring witness actions. All normal actions are not deterministically billable ahead-of-time as they depend on state that is considered volatile until the precise moment a transaction is retired. If a transaction fails, the resources billed to it ahead of time for witness data will be refunded.

    资源计算

    见证action处理时并行也大概率会发生,这很难做到资源控制。但是,由于它不依赖于任何状态数据,所以它应该能提前计算出将要消耗的资源。

    交易将提交到资源使用中,并将承诺打包为#1386 大小的一部分。

    注意,这一承诺只会涵盖用于退出见证action的范围。所有标准的action都不能提前确定计费,因为它们直到交易结束的那一秒,才被认为是稳定的状态。如果交易失败,提前支付的见证数据资源将被退还。

    Prunable Data

    As part of this, the block structure (on disk and wire) will change such that all witness data and signatures are part of an explicit and well-contained section. This section can be truncated off of blocks when they are considered irreversible and will remain replay/re-indexable as irreversibility proves that all dependent processing "passes" and can therefore be implied

    Prunable数据

    作为这一点的一部分,区块结构(在磁盘和连线上)将会改变,这样所有见证数据和签名都是一个明确和包装好的一部分。当被认为是不可逆的时候,区块的这一部分可以被截断,并且将继续不可逆地重演和重新索引,证明所有依赖的处理都是“通过”的,因此可以被暗示。


    wanderingbort commented on 15 Feb

    Notes from Dan re: Sibling Action API

    wanderingbort回复,内容来自Dan的回复

    • consider access based on ordinal and type instead of data-driven. This allows actions to potentially explicitly reference other actions in their respective payloads for the cost of an ordinal if they can imply the type.

    • consider more than an assert which allows reading the given sibling action data directly so that data present on both a witness action and a dependent action is not duplicated, the dependent can read it from the witness action directly.

    •考虑基于顺序和类型而不是数据驱动的访问。这使得action可以在其各自有效的负载中,以一个序数为代价明确地引用其他action,如果它们能提示类型的话。

    •要考虑的不仅仅是一个assert,它允许直接读取给出的姐妹action数据,以便在见证action和依赖action上的数据不被复制,依赖者可以直接从见证action中读取数据。



    blockone-syncclient commented 12 days ago

    ➤ Kevin Heifner commented:

    From Bart:

    Kevin Heifner回复了这个帖子

    We have a few tests (one?) that actually exercises apply_block . I think we should add some context-free-action tests that generate a block on one tester and then push that block into another to exercise CFA on apply_block

    我们有一些(一个?)真的在运行apply_block的测试。我认为我们应该添加一些context-free-action的测试,在一个测试器上出块,然后将这个块推到另一个测试器上,以在apply_block上执行CFA。

    本号翻译转述,文中观点不代表本号任何立场

    本文图片来源于网络

    本文原文内容链接来自于https://github.com/EOSIO/eos/issues/1387,内容提供者wanderingbort,bytemaster和Kevin Heifner,由Lochaiching翻译。转载请参照本文文首说明。

    更多内容,关注“EOS技术爱好者”!

    要是这篇文章对你有用,扫描下面erc-20地址给我们赞赏吧

    相关文章

      网友评论

        本文标题:【BM回复】Context Free Actions

        本文链接:https://www.haomeiwen.com/subject/kjqzqftx.html