-
Notifications
You must be signed in to change notification settings - Fork 84
feat(consensus): assume-valid swift sync aggregator #836
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
base: master
Are you sure you want to change the base?
Conversation
03f52b9 to
138473f
Compare
- Implement `SwiftSyncAgg`, which is just a `u128` newtype. - Implement `verify_block_transactions_swiftsync` and `process_block_swiftsync` for AssumeValid SwiftSync validation. - New `check_block` function to reduce duplication (merkle root, BIP34 height, witness commitment, max weight). - New `max_supply_at_height` function required for SwiftSync supply validation. - Add the first 176 mainnet blocks in order to test the SwiftSync aggregator and supply. - Rename old `blocks.txt` to `regtest_blocks.txt`. The aggregator addition/subtraction is implemented as wrapping arithmetic with the result of `SHA256(salt || txid || vout)`. The hash uses only one compression round, as the salt size is fixed to 19 bytes (152 secret bits should be enough). In my old computer one hash takes ~380ns.
138473f to
881b252
Compare
|
Is there a particular reason Some results from a local benchmark of |
|
Hi @rustaceanrob, thanks for pointing this out! Are the 64 bits of output length good enough or are you doing something like hashing it 4 times (with a counter) to get the four 64-bit limbs? I guess the output length is not that relevant here since it's keyed with 128 bits anyway |
|
As long as the salt is randomized I think 64 bits is sufficient, also considering this is an assume-valid implementation. |
I don't think this would make a difference in practice, since the bottleneck becomes fetching blocks from P2P instead of waiting on the CPU. |
|
So I have done some benches on my old computer and this would be the
Either way we will finish much faster than the blocks arrive (we can also parallelize), so I agree with @luisschwab. But |
|
Indeed, I'd go with |
|
Updated my comment, a better benchmark shows that two |
Description and Notes
SwiftSyncAgg, which is just au128newtype.verify_block_transactions_swiftsyncandprocess_block_swiftsyncfor AssumeValid SwiftSync validation.check_blockfunction to reduce duplication (merkle root, BIP34 height, witness commitment, max weight).max_supply_at_heightfunction required for SwiftSync supply validation.blocks.txttoregtest_blocks.txt.The aggregator addition/subtraction is implemented as wrapping arithmetic with the result of
SHA256(salt || txid || vout). The hash uses only one compression round, as the salt size is fixed to 19 bytes (152 secret bits should be enough). In my old computer one hash takes ~380ns.