New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DAWN-610 ⁃ Context Free Actions #1387

Closed
wanderingbort opened this Issue Feb 14, 2018 · 5 comments

Comments

Projects
None yet
5 participants
@wanderingbort
Copy link
Contributor

wanderingbort commented Feb 14, 2018

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.

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.

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.

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

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 successful as 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.

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.

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

@blockone-syncclient blockone-syncclient changed the title Witness Actions DAWN-610 ⁃ Witness Actions Feb 14, 2018

@wanderingbort

This comment has been minimized.

Copy link
Contributor

wanderingbort commented Feb 14, 2018

Notes from Dan re: Sibling Action API

  • 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.

@blockone-syncclient blockone-syncclient changed the title DAWN-610 ⁃ Witness Actions DAWN-610 ⁃ Context Free Actions Feb 28, 2018

@blockone-syncclient

This comment has been minimized.

Copy link

blockone-syncclient commented Mar 9, 2018

➤ Kevin Heifner commented:

From Bart:

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

@andriantolie

This comment has been minimized.

Copy link
Contributor

andriantolie commented Mar 27, 2018

Related PR is #1678

@andriantolie

This comment has been minimized.

Copy link
Contributor

andriantolie commented Mar 28, 2018

ATC:

  • Verify tests/chain_tests for block_tests and api_tests/cf_action_tests pass
@andriantolie

This comment has been minimized.

Copy link
Contributor

andriantolie commented Mar 28, 2018

ATC passes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment