-
Notifications
You must be signed in to change notification settings - Fork 236
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: Refactor OutPoint and add dep group support #1331
Conversation
@keroro520 is assigned as the chief reviewer |
7c8230e
to
399cc9b
Compare
block_hash: H256; | ||
dep_type: uint8; |
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.
Why not using a enum type here?
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.
Maybe we should change Script.hash_type
to enum as well.
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.
I have a note regarding this here:
Lines 11 to 15 in 59e7b47
// NOTE: we could've used enum as well in the wire format, but as of | |
// flatbuffer 1.11.0, unused constants will be generated in the Rust | |
// code for enum types, resulting in both compiler warnings and clippy | |
// errors. So for now we are sticking to a single integer in the wire | |
// format, and only use enums in core data structures. |
Previously we are allowed to specify I notice this PR remove |
Yes, we now should define this relationship in dep. |
df0584f
to
2704bd5
Compare
2704bd5
to
69204a7
Compare
6894bcd
to
1584d94
Compare
BREAKING CHANGE: OutPoint changed, add CellDep data structure
BREAKING CHANGE: Transaction/OutPoint data structure changed
BREAKING CHANGE: Protocol schema changed
BREAKING CHANGE: schema changed
1584d94
to
76dd08c
Compare
let tx_hash = H256::from_slice(&data[tx_hash_start..tx_hash_end]) | ||
.expect("Invalid tx hash length"); | ||
let mut index_bytes = [0u8; mem::size_of::<u32>()]; | ||
index_bytes.copy_from_slice(&data[index_start..index_end]); |
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.
index_bytes.copy_from_slice(&data[index_start..]);
/// Convert OutPoint to one dep group data item | ||
pub fn to_group_data(&self) -> Vec<u8> { | ||
[self.tx_hash.to_vec(), self.index.to_le_bytes().to_vec()].concat() | ||
} |
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.
Please add some tests for the from/to conversion.
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.
Changed to CellKey's implementation (see the code above in the same file).
@@ -31,7 +32,7 @@ impl BlockInfo { | |||
pub struct CellMeta { | |||
#[serde(skip)] | |||
pub cell_output: CellOutput, | |||
pub out_point: CellOutPoint, | |||
pub out_point: OutPoint, | |||
pub block_info: Option<BlockInfo>, | |||
pub cellbase: bool, |
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.
There is another struct TransactionInfo
https://github.com/nervosnetwork/ckb/blob/develop/core/src/extras.rs#L19
It's similar to the BlockInfo
, it seems that we can remove the BlockInfo
, and we can remove the pub cellbase: bool
as well, I think whether it's a cellbase
depends on the position in the Block. https://github.com/nervosnetwork/ckb/blob/develop/store/src/store.rs#L195
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.
Maybe create a new issue for another PR.
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.
Dead(OutPoint), | ||
Unknown(Vec<OutPoint>), | ||
OutOfOrder(OutPoint), | ||
} | ||
|
||
pub fn parse_dep_group_data(data: Bytes) -> Result<Vec<OutPoint>, usize> { | ||
// tx hash (32 bytes) + output index (4 bytes) | ||
const OUT_POINT_LEN: usize = mem::size_of::<H256>() + mem::size_of::<u32>(); |
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.
put it in transaction.rs?
Close this by: #1356 |
struct OutPoint
enum CellDep
trait CellProvider
andtrait HeaderProvider
chain
module