-
Notifications
You must be signed in to change notification settings - Fork 22
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
feat: Add NervosDAO as a CKB VM script #21
Conversation
@doitian
EDIT: we tried a different route: an RC version is first published to use in the CKB main repo PR, which can solve the problem. |
0005da6
to
137d76d
Compare
Tests for NervosDAO are included here |
unsigned char witness[WITNESS_SIZE]; | ||
|
||
len = WITNESS_SIZE; | ||
ret = ckb_load_witness(witness, &len, 0, input_index, CKB_SOURCE_INPUT); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🐞Check that len <= WITNESS_SIZE
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ℹ️Review Information
Each withdraw consumes a former deposited cell as an input. The corresponding witnesses contain two arguments:
- The first is intended to be consumed by the lock script to prove the user owns the cell.
- The second one is a u64 encoded in little endian, it is the index into the transaction deps, which references an anchor header. We assume that the cell is withdraw from that anchor header. Transaction submitter should use the most recent block as the anchor header. The interest between anchor header to the block really commit the withdraw transaction is an implicit cost of the withdraw.
Could you please provide a brief description in the PR about:
|
return ERROR_INVALID_WITHDRAW_BLOCK; | ||
} | ||
|
||
unsigned char deposit_dao[DAO_SIZE]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ℹ️Review Information
Reference of the DAO data layout
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will add a comment at the top of the script document everything.
unsigned char witness[WITNESS_SIZE]; | ||
|
||
len = WITNESS_SIZE; | ||
ret = ckb_load_witness(witness, &len, 0, input_index, CKB_SOURCE_INPUT); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ℹ️Review Information
Each withdraw consumes a former deposited cell as an input. The corresponding witnesses contain two arguments:
- The first is intended to be consumed by the lock script to prove the user owns the cell.
- The second one is a u64 encoded in little endian, it is the index into the transaction deps, which references an anchor header. We assume that the cell is withdraw from that anchor header. Transaction submitter should use the most recent block as the anchor header. The interest between anchor header to the block really commit the withdraw transaction is an implicit cost of the withdraw.
} | ||
|
||
uint64_t counted_capacity = 0; | ||
if (__builtin_usubl_overflow(original_capacity, occupied_capacity, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ℹ️Review Information
Occupied capacity does not count when calculating interest.
dao_input = 1; | ||
} | ||
} else if (ret == CKB_ITEM_MISSING) { | ||
/* DAO Issuing input here, we can just skip it */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ℹ️Review Information
Issuing input is a special OutPoint
which is used as an indicator to tells the transaction verifier that the rule outputs total capacity <= inputs total capacity
is handled in this script, dao.c
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Request changes are marked with 🐞
be5317d
to
14f4e3f
Compare
TODO: