Closed Jeanmichel7 closed 1 month ago
The latest updates on your projects. Learn more about Vercel for Git ↗︎
Name | Status | Preview | Comments | Updated (UTC) |
---|---|---|---|---|
raito | ✅ Ready (Inspect) | Visit Preview | 💬 Add feedback | Sep 5, 2024 2:04pm |
I forgot the header weight in the block size validation ...
I'd suggest to implement block weight validation in a follow up PR
@maciejka so what you suggested makes sense in terms of optimisation:
txid = hash(encoded)
wtxid = hash(encoded_with_witness)
weight = 4 * len(encoded) + (len(encoded_with_witness) - len(encoded))
So one option is to do this in fee_and_merkle_roots
function instead of TransactionTrait
that exposes txid, wtxid, and weight methods.
Another option is to implement byte_size
as part of the Encode
trait to have a lightweight size estimation, but it would still be an overhead.
Generally we are already doing double work when encoding two times w/ and w/o witnesses. Maybe it makes sense to leave optimizations for the future, idk.
Since we're computing directly in the function, I don't really see how to do the tests. So I've mocked the logic for my tests, but perhaps it would be better to move the tests to encode?
@Jeanmichel7 this is getting out of control 😅 I'll make a draft PR with interfaces to illustrate what is needed
See #146
@Jeanmichel7 this is getting out of control 😅 I'll make a draft PR with interfaces to illustrate what is needed
See #146
@Jeanmichel7 let's continue in #146