-
Notifications
You must be signed in to change notification settings - Fork 5
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
Create RawBitcoinTx wrapper type for Transaction #605
base: main
Are you sure you want to change the base?
Conversation
38589c9
to
00c4308
Compare
Commit: ca87374 SP1 Performance Test Results
|
Codecov ReportAttention: Patch coverage is
@@ Coverage Diff @@
## main #605 +/- ##
==========================================
- Coverage 56.68% 56.63% -0.05%
==========================================
Files 313 313
Lines 32505 32540 +35
==========================================
+ Hits 18425 18429 +4
- Misses 14080 14111 +31
|
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.
Looks good, but I want to confirm this with @delbonis. There must have been a reason why Vec<u8>
was previously chosen for L1Tx.tx
.
Are we somehow doing some basic checks as in https://docs.rs/bitcoin/0.32.5/bitcoin/consensus/trait.Decodable.html#impl-Decodable-for-Vec%3CTransaction%3E ? |
I'm soft against putting nontrivial structural checks which we "don't own" close to the database like this. The database layer should be concerned with just ensuring that the general shape of the data is sane, not that it's semantically correct. |
6dc1126
to
670e539
Compare
/// Represents a raw, byte-encoded Bitcoin transaction with custom [`Arbitrary`] support. | ||
/// Provides conversions (via [`TryFrom`]) to and from [`Transaction`]. | ||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, BorshSerialize, BorshDeserialize)] | ||
pub struct RawBitcoinTx(Vec<u8>); |
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.
This should come before the impl
s. Can you move it up?
impl TryFrom<RawBitcoinTx> for Transaction { | ||
type Error = encode::Error; | ||
fn try_from(value: RawBitcoinTx) -> Result<Self, Self::Error> { | ||
deserialize(&value.0) | ||
} | ||
} | ||
|
||
impl TryFrom<&RawBitcoinTx> for Transaction { | ||
type Error = encode::Error; | ||
fn try_from(value: &RawBitcoinTx) -> Result<Self, Self::Error> { | ||
deserialize(&value.0) | ||
} | ||
} |
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.
Can you add trivial tests:
- case when the transaction is valid in bytes and the
TryFrom
succeeds - case when the transaction is invalid in bytes and the
TryFrom
fails
Description
Type of Change
Notes to Reviewers
Checklist
Related Issues