feat(consensus): assume-valid swift sync aggregator#836
feat(consensus): assume-valid swift sync aggregator#836JoseSK999 wants to merge 3 commits intogetfloresta:masterfrom
Conversation
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 |
| } | ||
| } | ||
|
|
||
| impl Add for SwiftSyncAgg { |
There was a problem hiding this comment.
Perhaps pedantic, but I would not expect the + operator to wrap.
There was a problem hiding this comment.
Since we add two SwiftSyncAggs here (not integers), I think this signals the logical operation of adding/combining them. IMO it's reasonable.
881b252 to
99ac86a
Compare
|
Pushed 99ac86a
|
|
Thanks to the |
21476df to
62c30d8
Compare
|
Derived |
62c30d8 to
017e785
Compare
- Implement `SwiftSyncAgg`, which is made of two `u64` values. Each of the two limbs is the result of a single 128-bit `SipHash24` key. The secret salt is the 32-byte pair of `SipHash24` keys. - 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 `SipHash24(txid || vout_le)`, with each of the two keys and limbs. In my old computer one `OutPoint` hash takes ~60ns (two `SipHash24` hashes). For outputs I've optimized hashing to reuse the midstate after processing the `txid`, across `vouts`.
`validate_script_size` only checked the 10k bytes length, but we should also return error on `OP_RETURN` (since this function is called for spends). Our implementation would anyway fail on the accumulator or aggregator side. We can call this too in `get_block_adds` and reduce duplication.
017e785 to
81175d9
Compare
|
@moisesPompilio has a fat finger? |
Sorry, I pressed the wrong button. |
|
It should ask you if you're sure about it. Terrible UX, specially since the |
|
My agg code is not that terrible 😅 |
Description and Notes
SwiftSyncAgg, which is made of twou64values. Each of the two limbs is the result of a single 128-bitSipHash24key. The secret salt is the 32-byte pair ofSipHash24keys.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.Consensus::is_unspendableandConsensus::total_out_value.The aggregator addition/subtraction is implemented as wrapping arithmetic with the result of
SipHash24(txid || vout_le), with each of the two keys and limbs. In my old computer oneOutPointhash takes ~60ns (twoSipHash24hashes).For outputs I've optimized hashing to reuse the midstate after processing the
txid, acrossvouts.