Skip to content
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

New verification model #913

Merged
merged 13 commits into from
Jun 1, 2019
Merged

New verification model #913

merged 13 commits into from
Jun 1, 2019

Conversation

xxuejie
Copy link
Collaborator

@xxuejie xxuejie commented May 29, 2019

Based on feedbacks gathered earlier, we are revising our verification
model with the following changes:

  • When validating a transaction, CKB will grab all lock scripts from
    all inputs, and group them based on lock script hash. The script in
    each group will only be run once. The lock script itself will have
    to do the validation task for all inputs in the same group
  • CKB will also grab all type scripts from inputs and outputs(notice
    different from previous version, the type scripts in inputs are
    included here as well), and group them based on type script hash as
    well. Each type script in each group will also be run once. The type
    script itself needs to handle the validation task within the group
  • Syscalls are also revised to allow fetching all the
    inputs/outputs/witnesses within a single group.
  • Input args is removed since the functionality can be replicated elsewhere

@xxuejie xxuejie requested review from a team May 29, 2019 02:59
@nervos-bot
Copy link

nervos-bot bot commented May 29, 2019

@jjyr is assigned as the chief reviewer

@nervos-bot
Copy link

nervos-bot bot commented May 29, 2019

CI status of the fork branch is Build Status

script/src/syscalls/load_cell.rs Show resolved Hide resolved
script/src/syscalls/load_witness.rs Show resolved Hide resolved
script/src/syscalls/mod.rs Outdated Show resolved Hide resolved
script/src/verify.rs Show resolved Hide resolved
core/src/transaction.rs Outdated Show resolved Hide resolved
@doitian doitian added b:consensus Break consensus b:database Break database schema b:p2p Break P2P protocols b:rpc Break RPC interface labels May 29, 2019
Copy link
Member

@janx janx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a test case to cover the fix?

fix: use separate lock and type groups in case of duplicate script
fd67f74

script/src/verify.rs Show resolved Hide resolved
script/src/verify.rs Show resolved Hide resolved
core/src/transaction.rs Outdated Show resolved Hide resolved
Based on feedbacks gathered earlier, we are revising our verification
model with the following changes:

* When validating a transaction, CKB will grab all lock scripts from
  all inputs, and group them based on lock script hash. The script in
  each group will only be run once. The lock script itself will have
  to do the validation task for all inputs in the same group
* CKB will also grab all type scripts from inputs and outputs(notice
  different from previous version, the type scripts in inputs are
  included here as well), and group them based on type script hash as
  well. Each type script in each group will also be run once. The type
  script itself needs to handle the validation task within the group
* Syscalls are also revised to allow fetching all the
  inputs/outputs/witnesses within a single group.

The default secp256k1_blake160_sighash_all lock script is compiled
from the following source:

https://github.com/nervosnetwork/ckb-system-scripts/blob/e00ba451dccb7a516454ea9606de3a21c8f9a80c/c/secp256k1_blake160_sighash_all.c

The exact gcc version used in the compilation can be located in the
following docker image:

xxuejie/riscv-gnu-toolchain-rv64imac:20190529
The default secp256k1_blake160_sighash_all lock script is compiled
from the following source:

https://github.com/nervosnetwork/ckb-system-scripts/blob/680f4287ab3211025761aaf5cae3727fb4ea7241/c/secp256k1_blake160_sighash_all.c

The exact gcc version used in the compilation can be located in the
following docker image:

xxuejie/riscv-gnu-toolchain-rv64imac:20190529
@zhangsoledad zhangsoledad merged commit 3c4bd8f into nervosnetwork:develop Jun 1, 2019
@xxuejie xxuejie deleted the new-verification-model branch June 1, 2019 15:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
b:consensus Break consensus b:database Break database schema b:p2p Break P2P protocols b:rpc Break RPC interface
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants