From 0f732582a1c585b9f0de290333b66f1ba9df3b69 Mon Sep 17 00:00:00 2001 From: Charles Li Date: Thu, 5 Dec 2024 22:02:21 +0000 Subject: [PATCH] refactor(eqvoc): bugfix fd_eqvoc_test, rework APIs, and add unit tests --- src/ballet/shred/fd_shred.h | 8 +- src/ballet/shred/fuzz_shred_parse.c | 8 +- src/choreo/eqvoc/fd_eqvoc.c | 251 +++++++++++++-------- src/choreo/eqvoc/fd_eqvoc.h | 240 ++++++++++++-------- src/choreo/eqvoc/test_eqvoc.c | 332 ++++------------------------ src/disco/shred/fd_fec_resolver.c | 14 +- 6 files changed, 373 insertions(+), 480 deletions(-) diff --git a/src/ballet/shred/fd_shred.h b/src/ballet/shred/fd_shred.h index bf323de2ef..0f95bdabcf 100644 --- a/src/ballet/shred/fd_shred.h +++ b/src/ballet/shred/fd_shred.h @@ -200,7 +200,7 @@ struct __attribute__((packed)) fd_shred { union { /* Common data shred header */ - struct __attribute__((packed)) { + struct __attribute__((packed)) fd_shred_data { /* Slot number difference between this block and the parent block. parent_off <= slot. Always greater than zero, except for slot 0, in which case the @@ -220,7 +220,7 @@ struct __attribute__((packed)) fd_shred { } data; /* Common coding shred header */ - struct __attribute__((packed)) { + struct __attribute__((packed)) fd_shred_code { /* Total number of data shreds in slot. Must be positive. */ /* 0x53 */ ushort data_cnt; @@ -234,6 +234,8 @@ struct __attribute__((packed)) fd_shred { }; }; typedef struct fd_shred fd_shred_t; +typedef struct fd_shred_data fd_shred_data_t; +typedef struct fd_shred_code fd_shred_code_t; FD_PROTOTYPES_BEGIN @@ -406,7 +408,7 @@ fd_shred_code_payload( fd_shred_t const * shred ) { of the chained Merkle root. U.B. if the shred is not a chained variant. */ FD_FN_CONST static inline ulong -fd_shred_chain_offset( uchar variant ) { +fd_shred_chain_off( uchar variant ) { ulong type = fd_shred_type( variant ); return fd_ulong_if( type & FD_SHRED_TYPEMASK_CODE, FD_SHRED_MAX_SZ, FD_SHRED_MIN_SZ ) - FD_SHRED_MERKLE_ROOT_SZ diff --git a/src/ballet/shred/fuzz_shred_parse.c b/src/ballet/shred/fuzz_shred_parse.c index 6ab08412ce..6d1664a056 100644 --- a/src/ballet/shred/fuzz_shred_parse.c +++ b/src/ballet/shred/fuzz_shred_parse.c @@ -100,7 +100,7 @@ LLVMFuzzerTestOneInput( uchar const * data, assert( !fd_shred_is_resigned( type ) ); BOUNDS_CHECK ( fd_shred_code_payload( shred ), fd_shred_payload_sz( shred ) ); BOUNDS_CHECK ( fd_shred_merkle_nodes( shred ), fd_shred_merkle_sz( variant ) ); - BOUNDS_CHECK_OFF( fd_shred_chain_offset( variant ), FD_SHRED_MERKLE_ROOT_SZ ); + BOUNDS_CHECK_OFF( fd_shred_chain_off( variant ), FD_SHRED_MERKLE_ROOT_SZ ); break; case FD_SHRED_TYPE_MERKLE_DATA_CHAINED: @@ -112,7 +112,7 @@ LLVMFuzzerTestOneInput( uchar const * data, assert( !fd_shred_is_resigned( type ) ); BOUNDS_CHECK ( fd_shred_data_payload( shred ), fd_shred_payload_sz( shred ) ); BOUNDS_CHECK ( fd_shred_merkle_nodes( shred ), fd_shred_merkle_sz( variant ) ); - BOUNDS_CHECK_OFF( fd_shred_chain_offset( variant ), FD_SHRED_MERKLE_ROOT_SZ ); + BOUNDS_CHECK_OFF( fd_shred_chain_off( variant ), FD_SHRED_MERKLE_ROOT_SZ ); break; case FD_SHRED_TYPE_MERKLE_CODE_CHAINED_RESIGNED: @@ -124,7 +124,7 @@ LLVMFuzzerTestOneInput( uchar const * data, assert( fd_shred_is_resigned( type ) ); BOUNDS_CHECK ( fd_shred_code_payload( shred ), fd_shred_payload_sz( shred ) ); BOUNDS_CHECK ( fd_shred_merkle_nodes( shred ), fd_shred_merkle_sz( variant ) ); - BOUNDS_CHECK_OFF( fd_shred_chain_offset( variant ), FD_SHRED_MERKLE_ROOT_SZ ); + BOUNDS_CHECK_OFF( fd_shred_chain_off( variant ), FD_SHRED_MERKLE_ROOT_SZ ); BOUNDS_CHECK_OFF( fd_shred_retransmitter_sig_off( shred ), FD_SHRED_SIGNATURE_SZ ); break; @@ -137,7 +137,7 @@ LLVMFuzzerTestOneInput( uchar const * data, assert( fd_shred_is_resigned( type ) ); BOUNDS_CHECK ( fd_shred_data_payload( shred ), fd_shred_payload_sz( shred ) ); BOUNDS_CHECK ( fd_shred_merkle_nodes( shred ), fd_shred_merkle_sz( variant ) ); - BOUNDS_CHECK_OFF( fd_shred_chain_offset( variant ), FD_SHRED_MERKLE_ROOT_SZ ); + BOUNDS_CHECK_OFF( fd_shred_chain_off( variant ), FD_SHRED_MERKLE_ROOT_SZ ); BOUNDS_CHECK_OFF( fd_shred_retransmitter_sig_off( shred ), FD_SHRED_SIGNATURE_SZ ); break; diff --git a/src/choreo/eqvoc/fd_eqvoc.c b/src/choreo/eqvoc/fd_eqvoc.c index 7ab0400d28..72f13a3222 100644 --- a/src/choreo/eqvoc/fd_eqvoc.c +++ b/src/choreo/eqvoc/fd_eqvoc.c @@ -1,4 +1,5 @@ #include "fd_eqvoc.h" +#include "../../ballet/shred/fd_shred.h" void * fd_eqvoc_new( void * shmem, ulong key_max, ulong seed ) { @@ -15,18 +16,23 @@ fd_eqvoc_new( void * shmem, ulong key_max, ulong seed ) { FD_SCRATCH_ALLOC_INIT( l, shmem ); fd_eqvoc_t * eqvoc = FD_SCRATCH_ALLOC_APPEND( l, alignof(fd_eqvoc_t), sizeof(fd_eqvoc_t) ); - void * pool = FD_SCRATCH_ALLOC_APPEND( l, fd_eqvoc_pool_align(), fd_eqvoc_pool_footprint( key_max ) ); - void * map = FD_SCRATCH_ALLOC_APPEND( l, fd_eqvoc_map_align(), fd_eqvoc_map_footprint( key_max ) ); + void * fec_pool = FD_SCRATCH_ALLOC_APPEND( l, fd_eqvoc_fec_pool_align(), fd_eqvoc_fec_pool_footprint( key_max ) ); + void * fec_map = FD_SCRATCH_ALLOC_APPEND( l, fd_eqvoc_fec_map_align(), fd_eqvoc_fec_map_footprint( key_max ) ); + void * proof_pool = FD_SCRATCH_ALLOC_APPEND( l, fd_eqvoc_proof_pool_align(), fd_eqvoc_proof_pool_footprint( key_max ) ); + void * proof_map = FD_SCRATCH_ALLOC_APPEND( l, fd_eqvoc_proof_map_align(), fd_eqvoc_proof_map_footprint( key_max ) ); void * sha512 = FD_SCRATCH_ALLOC_APPEND( l, fd_sha512_align(), fd_sha512_footprint() ); void * bmtree_mem = FD_SCRATCH_ALLOC_APPEND( l, fd_bmtree_commit_align(), fd_bmtree_commit_footprint( FD_SHRED_MERKLE_LAYER_CNT ) ); FD_SCRATCH_ALLOC_FINI( l, fd_eqvoc_align() ); - fd_eqvoc_pool_new( pool, key_max ); - fd_eqvoc_map_new( map, key_max, seed ); - fd_sha512_new( sha512 ); - (void)bmtree_mem; /* does not require `new` */ + eqvoc->key_max = key_max; + eqvoc->fec_pool = fd_eqvoc_fec_pool_join( fd_eqvoc_fec_pool_new( fec_pool, key_max ) ); + eqvoc->fec_map = fd_eqvoc_fec_map_join( fd_eqvoc_fec_map_new( fec_map, key_max, seed ) ); + eqvoc->proof_pool = fd_eqvoc_proof_pool_join( fd_eqvoc_proof_pool_new( proof_pool, key_max ) ); + eqvoc->proof_map = fd_eqvoc_proof_map_join( fd_eqvoc_proof_map_new( proof_map, key_max, seed ) ); + eqvoc->sha512 = fd_sha512_join( fd_sha512_new( sha512 ) ); + eqvoc->bmtree_mem = bmtree_mem; /* does not require join / new */ - eqvoc->min_slot = FD_SLOT_NULL; + eqvoc->fec_min = FD_SLOT_NULL; eqvoc->key_max = key_max; eqvoc->shred_version = 0; @@ -46,21 +52,7 @@ fd_eqvoc_join( void * sheqvoc ) { return NULL; } - FD_SCRATCH_ALLOC_INIT( l, sheqvoc ); - fd_eqvoc_t * eqvoc = FD_SCRATCH_ALLOC_APPEND( l, alignof(fd_eqvoc_t), sizeof(fd_eqvoc_t) ); - void * pool = FD_SCRATCH_ALLOC_APPEND( l, fd_eqvoc_pool_align(), fd_eqvoc_pool_footprint( eqvoc->key_max ) ); - void * map = FD_SCRATCH_ALLOC_APPEND( l, fd_eqvoc_map_align(), fd_eqvoc_map_footprint( eqvoc->key_max ) ); - void * sha512 = FD_SCRATCH_ALLOC_APPEND( l, fd_sha512_align(), fd_sha512_footprint() ); - void * bmtree_mem = FD_SCRATCH_ALLOC_APPEND( l, fd_bmtree_commit_align(), fd_bmtree_commit_footprint( FD_SHRED_MERKLE_LAYER_CNT ) ); - FD_SCRATCH_ALLOC_FINI( l, fd_eqvoc_align() ); - - (void)eqvoc; /* does not require `join` */ - eqvoc->pool = fd_eqvoc_pool_join( pool ); - eqvoc->map = fd_eqvoc_map_join( map ); - eqvoc->sha512 = fd_sha512_join( sha512 ); - eqvoc->bmtree_mem = bmtree_mem; - - return eqvoc; + return (fd_eqvoc_t *)sheqvoc; } void * @@ -90,37 +82,53 @@ fd_eqvoc_delete( void * eqvoc ) { return eqvoc; } +fd_eqvoc_proof_t * +fd_eqvoc_proof_insert( fd_eqvoc_t * eqvoc, fd_gossip_duplicate_shred_t const * ds ) { + fd_slot_pubkey_t key = { ds->slot, ds->from }; + fd_eqvoc_proof_t * proof = fd_eqvoc_proof_map_ele_query( eqvoc->proof_map, &key, NULL, eqvoc->proof_pool ); + if( FD_UNLIKELY( !proof ) ) { + proof = fd_eqvoc_proof_pool_ele_acquire( eqvoc->proof_pool ); + proof->key.slot = ds->slot; + proof->key.hash = ds->from; + fd_eqvoc_proof_map_ele_insert( eqvoc->proof_map, proof, eqvoc->proof_pool ); + } + if( FD_LIKELY( !fd_uchar_extract_bit( proof->bit_vec, ds->chunk_index ) ) ) { + memcpy( proof->chunks[ds->chunk_index], ds->chunk, ds->chunk_len ); + proof->bit_vec = fd_uchar_set_bit( proof->bit_vec, ds->chunk_index ); + } + return proof; +} + void -fd_eqvoc_insert( fd_eqvoc_t * eqvoc, fd_shred_t const * shred ) { - fd_eqvoc_key_t key = { shred->slot, shred->fec_set_idx }; - fd_eqvoc_entry_t * entry = fd_eqvoc_map_ele_query( eqvoc->map, &key, NULL, eqvoc->pool ); - if( FD_UNLIKELY( !entry ) ) { +fd_eqvoc_fec_insert( fd_eqvoc_t * eqvoc, fd_shred_t const * shred ) { + fd_slot_fec_t key = { shred->slot, shred->fec_set_idx }; + fd_eqvoc_fec_t * fec = fd_eqvoc_fec_map_ele_query( eqvoc->fec_map, &key, NULL, eqvoc->fec_pool ); + if( FD_UNLIKELY( !fec ) ) { /* TODO eviction logic */ - entry = fd_eqvoc_pool_ele_acquire( eqvoc->pool ); - entry->key.slot = shred->slot; - entry->key.fec_set_idx = shred->fec_set_idx; - entry->code_cnt = 0; - entry->data_cnt = 0; - entry->last_idx = FD_SHRED_IDX_NULL; - memcpy( entry->sig, shred->signature, FD_ED25519_SIG_SZ ); + fec = fd_eqvoc_fec_pool_ele_acquire( eqvoc->fec_pool ); + fec->key.slot = shred->slot; + fec->key.fec_set_idx = shred->fec_set_idx; + fec->code_cnt = 0; + fec->data_cnt = 0; + fec->last_idx = FD_SHRED_IDX_NULL; + memcpy( fec->sig, shred->signature, FD_ED25519_SIG_SZ ); } if( FD_LIKELY( fd_shred_is_code( fd_shred_type( shred->variant ) ) ) ) { /* optimize for coding shreds (code_cnt >= data_cnt) */ - entry->code_cnt = shred->code.code_cnt; - entry->data_cnt = shred->code.data_cnt; + fec->code_cnt = shred->code.code_cnt; + fec->data_cnt = shred->code.data_cnt; } else if( FD_UNLIKELY( shred->data.flags & FD_SHRED_DATA_FLAG_SLOT_COMPLETE ) ) { - entry->last_idx = shred->idx; + fec->last_idx = shred->idx; } - /* This cannot fail */ - fd_eqvoc_map_ele_insert( eqvoc->map, entry, eqvoc->pool ); + fd_eqvoc_fec_map_ele_insert( eqvoc->fec_map, fec, eqvoc->fec_pool ); } -fd_eqvoc_entry_t const * -fd_eqvoc_search( fd_eqvoc_t const * eqvoc, fd_shred_t const * shred ) { - fd_eqvoc_entry_t const * entry = fd_eqvoc_query( eqvoc, shred->slot, shred->fec_set_idx ); +fd_eqvoc_fec_t const * +fd_eqvoc_fec_search( fd_eqvoc_t const * eqvoc, fd_shred_t const * shred ) { + fd_eqvoc_fec_t const * entry = fd_eqvoc_fec_query( eqvoc, shred->slot, shred->fec_set_idx ); /* If we've already seen a shred in this FEC set */ @@ -144,7 +152,7 @@ fd_eqvoc_search( fd_eqvoc_t const * eqvoc, fd_shred_t const * shred ) { /* Look backward FEC_MAX idxs for overlap. */ for( uint i = 1; shred->fec_set_idx >= i && i < FD_EQVOC_FEC_MAX; i++ ) { - fd_eqvoc_entry_t const * conflict = fd_eqvoc_query( eqvoc, shred->slot, shred->fec_set_idx - i ); + fd_eqvoc_fec_t const * conflict = fd_eqvoc_fec_query( eqvoc, shred->slot, shred->fec_set_idx - i ); if( FD_UNLIKELY( conflict && conflict->data_cnt > 0 && conflict->key.fec_set_idx + conflict->data_cnt > shred->fec_set_idx ) ) { @@ -155,7 +163,7 @@ fd_eqvoc_search( fd_eqvoc_t const * eqvoc, fd_shred_t const * shred ) { /* Look forward data_cnt idxs for overlap. */ for( uint i = 1; entry && i < entry->data_cnt; i++ ) { - fd_eqvoc_entry_t const * conflict = fd_eqvoc_query( eqvoc, shred->slot, shred->fec_set_idx + i ); + fd_eqvoc_fec_t const * conflict = fd_eqvoc_fec_query( eqvoc, shred->slot, shred->fec_set_idx + i ); if( FD_UNLIKELY( conflict ) ) return conflict; } @@ -187,37 +195,43 @@ shred_merkle_root( fd_eqvoc_t const * eqvoc, fd_shred_t const * shred, fd_bmtree return fd_bmtree_commitp_insert_with_proof( tree, shred_idx, &leaf, (uchar const *)fd_shred_merkle_nodes( shred ), fd_shred_merkle_cnt( shred->variant ), root_out ); } -/* https://github.com/anza-xyz/agave/blob/v2.0.3/gossip/src/duplicate_shred.rs#L107-L177 */ int fd_eqvoc_test( fd_eqvoc_t const * eqvoc, fd_shred_t * shred1, fd_shred_t * shred2 ) { - /* Optimize for valid equivocation proof */ + /* Input validation. */ if( FD_UNLIKELY( shred1->slot != shred2->slot ) ) { - return 0; + return -1; } if( FD_UNLIKELY( shred1->version != eqvoc->shred_version ) ) { - return 0; + return -1; } if( FD_UNLIKELY( shred2->version != eqvoc->shred_version ) ) { - return 0; + return -1; } - /* Verify both shreds contain valid signatures for the leader of their - slot, which requires deriving the merkle root and sig-verifying it - because the leader signs the merkle root for merkle shreds. */ + if( FD_UNLIKELY( fd_shred_type( shred1->variant ) != fd_shred_type( shred2->variant ) ) ) { + return -1; + } - fd_pubkey_t const * leader = fd_epoch_leaders_get( eqvoc->leaders, shred1->slot ); - fd_bmtree_node_t root1; + /* Check both shreds contain valid signatures from the assigned leader + to that slot. This requires deriving the merkle root and + sig-verifying it, because the leader signs the merkle root for + merkle shreds. + + TODO remove? */ + + fd_bmtree_node_t root1; if( FD_UNLIKELY( !shred_merkle_root( eqvoc, shred1, &root1 ) ) ) { - return 0; + return -1; } fd_bmtree_node_t root2; if( FD_UNLIKELY( !shred_merkle_root( eqvoc, shred2, &root2 ) ) ) { - return 0; + return -1; } + fd_pubkey_t const * leader = fd_epoch_leaders_get( eqvoc->leaders, shred1->slot ); if( FD_UNLIKELY( FD_ED25519_SUCCESS != fd_ed25519_verify( root1.hash, 32UL, shred1->signature, @@ -228,63 +242,114 @@ fd_eqvoc_test( fd_eqvoc_t const * eqvoc, fd_shred_t * shred1, fd_shred_t * shred shred2->signature, leader->uc, eqvoc->sha512 ) ) ) { - return 0; + return -1; } - if( FD_UNLIKELY( shred1->fec_set_idx == shred2->fec_set_idx - && 0 != memcmp( &root1, &root2, sizeof( fd_bmtree_node_t ) ) ) ) { - return 1; - } + /* Test if the shreds have different payloads, but the same index and + shred type. This will be true if their signatures compare + different, because a shred's signature is ultimately derived from + its payload. - if( FD_UNLIKELY( fd_shred_type( shred1->variant ) != fd_shred_type( shred2->variant ) ) ) { - return 0; - } + Return false if they are the same payload, because the remaining + checks assume the shreds have different idxs. */ - if( FD_UNLIKELY( shred1->idx == shred2->idx ) ) { + if( FD_UNLIKELY( shred1->idx == shred2->idx && + fd_shred_type( shred1->variant ) == fd_shred_type( shred2->variant ) ) ) { if( FD_LIKELY( 0 != memcmp( shred1->signature, shred2->signature, FD_ED25519_SIG_SZ ) ) ) { - return 1; + return FD_EQVOC_TEST_PAYLOAD; } - return 0; + return FD_EQVOC_TEST_FALSE; } - if( FD_UNLIKELY( fd_shred_is_data( fd_shred_type( shred1->variant ) ) ) ) { - if( FD_UNLIKELY( ( shred1->data.flags & FD_SHRED_DATA_FLAG_SLOT_COMPLETE && shred2->idx > shred1->idx ) ) - || ( shred2->data.flags & FD_SHRED_DATA_FLAG_SLOT_COMPLETE && shred1->idx > shred2->idx ) ) { - return 1; - } - } + /* Test if the shreds have different merkle roots when they're in the + same FEC set. */ - fd_eqvoc_entry_t const * entry1 = fd_eqvoc_query( eqvoc, shred1->slot, shred1->fec_set_idx ); - fd_eqvoc_entry_t const * entry2 = fd_eqvoc_query( eqvoc, shred2->slot, shred2->fec_set_idx ); + if( FD_UNLIKELY( shred1->fec_set_idx == shred2->fec_set_idx && + 0 != memcmp( &root1, &root2, sizeof(fd_bmtree_node_t) ) ) ) { + return FD_EQVOC_TEST_MERKLE_ROOT; + } - /* If the FEC set idx is the same but any metadata is different, mark - it as equivocating. */ + /* Test if the shreds have different coding metadata when they're both + coding shreds in the same FEC set. */ - if( FD_UNLIKELY( shred1->fec_set_idx == shred2->fec_set_idx && - ( entry1->code_cnt != entry2->code_cnt || - entry1->data_cnt != entry2->data_cnt || - entry1->last_idx != entry2->last_idx ) ) ) { - return 1; + if( FD_UNLIKELY( fd_shred_is_code( fd_shred_type( shred1->variant ) ) && fd_shred_is_code( fd_shred_type( shred2->variant ) ) && + shred1->fec_set_idx == shred2->fec_set_idx && + ( 0 != memcmp( &shred1->code, &shred2->code, sizeof( fd_shred_code_t ) ) || shred1->idx - shred1->code.idx == shred2->idx - shred2->code.idx )) ) { + return FD_EQVOC_TEST_CODE_META; } - /* This is only reachable if shred1 and shred2 are in different FEC - sets, so check for overlap. */ + /* Test if one shred is marked the last shred in the slot, but the + other shred has a higher index when both shreds are data shreds. */ - ulong lo = fd_ulong_min( shred1->fec_set_idx, shred2->fec_set_idx ); - ulong hi = fd_ulong_max( shred1->fec_set_idx, shred2->fec_set_idx ); + if( FD_UNLIKELY( fd_shred_is_data( fd_shred_type( shred1->variant ) ) && + fd_shred_is_data( fd_shred_type( shred2->variant ) ) && + ( shred1->data.flags & FD_SHRED_DATA_FLAG_SLOT_COMPLETE && shred2->idx > shred1->idx ) ) || + ( shred2->data.flags & FD_SHRED_DATA_FLAG_SLOT_COMPLETE && shred1->idx > shred2->idx ) ) { + return FD_EQVOC_TEST_LAST_IDX; + } - fd_eqvoc_entry_t const * lo_entry = fd_ptr_if( shred1->fec_set_idx < shred2->fec_set_idx, entry1, entry2 ); - FD_LOG_NOTICE(("lo %lu hi %lu data_cnt %lu %lu", lo, hi, lo_entry->data_cnt, lo + lo_entry->data_cnt )); + /* Test for overlap. The FEC sets overlap if the lower fec_set_idx + + data_cnt > higher fec_set_idx. We must have received at least one + coding shred in the FEC set with the lower fec_set_idx to perform + this check. */ - /* The FEC sets must overlap in data shred indices if the lower FEC - set index crosses into the higher FEC set index based on the data - shred count. */ + uint lo = fd_uint_min( shred1->fec_set_idx, shred2->fec_set_idx ); + uint hi = fd_uint_max( shred1->fec_set_idx, shred2->fec_set_idx ); + fd_eqvoc_fec_t const * entry = fd_eqvoc_fec_query( eqvoc, shred1->slot, lo ); + if ( FD_UNLIKELY( entry && entry->data_cnt > 0 && (lo + entry->data_cnt - 1) >= hi ) ) { + return FD_EQVOC_TEST_OVERLAP; + } - if ( FD_UNLIKELY( lo_entry && lo_entry->data_cnt > 0 && lo + lo_entry->data_cnt >= hi ) ) { - return 1; + /* Test for conflicting chained merkle root when shred1 and shred2 are + in adjacent FEC sets. We know the FEC sets are adjacent if the last + data shred index in the lower FEC set is one less than the first + data shred index in the higher FEC set. */ + + int adjacent = entry && entry->data_cnt > 0 && ( lo + entry->data_cnt == hi ); + if( FD_UNLIKELY( adjacent ) ) { + uchar * lo_hash = fd_ptr_if( shred1->fec_set_idx < shred2->fec_set_idx, + (uchar *)shred1 + fd_shred_chain_off( shred1->variant ), + (uchar *)shred2 + fd_shred_chain_off( shred2->variant ) ); + uchar * hi_hash = fd_ptr_if( shred1->fec_set_idx > shred2->fec_set_idx, + (uchar *)shred1 + fd_shred_merkle_off( shred1 ), + (uchar *)shred2 + fd_shred_merkle_off( shred2 ) ); + if ( FD_LIKELY( 0 != memcmp( lo_hash, hi_hash, FD_SHRED_MERKLE_ROOT_SZ ) ) ) { + return FD_EQVOC_TEST_CHAINED; + }; } +return FD_EQVOC_TEST_FALSE; +} + +int +fd_eqvoc_fec_verify( FD_PARAM_UNUSED fd_eqvoc_t const * eqvoc, + fd_blockstore_t * blockstore, + ulong slot, + uint fec_set_idx, + fd_hash_t * chained_hash ) { + + fd_shred_t * shred = NULL; + uint idx = fec_set_idx; + do { + shred = fd_buf_shred_query( blockstore, slot, idx ); + +#if FD_EQVOC_USE_HANDHOLDING + if( FD_UNLIKELY( !shred ) ) { + FD_LOG_WARNING(( "[%s] couldn't find shred %lu %u", __func__, slot, fec_set_idx )); + return 0; + } +#endif + +#if FD_EQVOC_USE_HANDHOLDING + FD_TEST( fd_shred_is_chained( fd_shred_type( shred->variant ) ) ); +#endif + + if( FD_UNLIKELY( 0 != memcmp( chained_hash, shred + fd_shred_chain_off( shred->variant ), FD_SHRED_MERKLE_ROOT_SZ ) ) ) { + return 0; + } + + } while( shred->fec_set_idx == fec_set_idx ); - return 0; + return 1; } void diff --git a/src/choreo/eqvoc/fd_eqvoc.h b/src/choreo/eqvoc/fd_eqvoc.h index 885dff2787..d89542bd5e 100644 --- a/src/choreo/eqvoc/fd_eqvoc.h +++ b/src/choreo/eqvoc/fd_eqvoc.h @@ -4,31 +4,23 @@ #include "../../ballet/shred/fd_shred.h" #include "../../flamenco/leaders/fd_leaders.h" #include "../fd_choreo_base.h" +#include "../../flamenco/runtime/fd_blockstore.h" /* fd_eqvoc presents an API for detecting and sending / receiving "proofs" of equivocation. Equivocation is when the shred producer produces two or more versions - of a shred for the same (slot, idx). An equivocation proof comprises + of a shred for the same (slot, idx). An equivocation proof comprises a sample of two shreds that conflict in a way that imply the shreds' producer equivocated. - The proof can be both direct and indirect (implied). A direct proof - is simpler: the proof is generated when you observe two versions of - the same shred, ie. two shreds that have the same slot and shred_idx - but a different data payload. Indirect + The proof can be both direct and indirect (implied). A direct proof + contains two shreds with the same slot and shred_idx but different + data payloads. An indirect proof contains two shreds with the same + slot but different shred_idxs, and the metadata on the shreds implies + there must be two or more versions of a block for that slot. See + fd_eqvoc_test for a detailed list of equivocation cases. - The following lists the equivocation cases: - - 1. Two shreds with the same slot and idx but different data payloads. - 2. Two shreds in the same FEC set have different merkle roots. - 3. Two shreds in the same FEC set with different metadata ie. - code_cnt, data_cnt, last_idx. - 4. Two shreds in the same FEC set that are both data shreds, where - one is marked as the last data shred in the slot, but the other - shred has a higher data shred index than that. - 3. Two shreds in different FEC sets and the FEC sets are overlapping - ie. the same shred idx appears in both FEC sets. Every FEC set must have the same signature for every shred in the set, so a different signature would indicate equivocation. Note in @@ -53,84 +45,101 @@ /* The chunk_cnt is encoded in a UCHAR_MAX, so you can have at most UCHAR_MAX chunkskj */ #define FD_EQVOC_CHUNK_MIN ( FD_SHRED_MAX_SZ * 2 / UCHAR_MAX + 1 ) -struct fd_eqvoc_chunk { - fd_slot_pubkey_t key; - ulong next; - fd_gossip_duplicate_shred_t duplicate_shred; +#define FD_EQVOC_TEST_FALSE 0 +#define FD_EQVOC_TEST_PAYLOAD 1 +#define FD_EQVOC_TEST_MERKLE_ROOT 2 +#define FD_EQVOC_TEST_CODE_META 3 +#define FD_EQVOC_TEST_LAST_IDX 4 +#define FD_EQVOC_TEST_OVERLAP 5 +#define FD_EQVOC_TEST_CHAINED 6 + +struct fd_eqvoc_proof { + fd_slot_pubkey_t key; + ulong next; + uchar bit_vec; + + union { + struct __attribute__((packed)) { + uchar chunks[FD_EQVOC_CHUNK_MAX][3]; + }; + struct __attribute__((packed)) { + fd_shred_t shred1; + fd_shred_t shred2; + }; + }; }; -typedef struct fd_eqvoc_chunk fd_eqvoc_chunk_t; +typedef struct fd_eqvoc_proof fd_eqvoc_proof_t; -#define POOL_NAME fd_eqvoc_chunk_pool -#define POOL_T fd_eqvoc_chunk_t +#define POOL_NAME fd_eqvoc_proof_pool +#define POOL_T fd_eqvoc_proof_t #include "../../util/tmpl/fd_pool.c" /* clang-format off */ -#define MAP_NAME fd_eqvoc_chunk_map -#define MAP_ELE_T fd_eqvoc_chunk_t +#define MAP_NAME fd_eqvoc_proof_map +#define MAP_ELE_T fd_eqvoc_proof_t #define MAP_KEY_T fd_slot_pubkey_t #define MAP_KEY_EQ(k0,k1) (FD_SLOT_PUBKEY_EQ(k0,k1)) #define MAP_KEY_HASH(key,seed) (FD_SLOT_PUBKEY_HASH(key,seed)) #include "../../util/tmpl/fd_map_chain.c" +/* clang-format on */ - -struct fd_eqvoc_key { +struct fd_slot_fec { ulong slot; uint fec_set_idx; }; -typedef struct fd_eqvoc_key fd_eqvoc_key_t; +typedef struct fd_slot_fec fd_slot_fec_t; /* clang-format off */ -static const fd_eqvoc_key_t fd_eqvoc_key_null = { 0 }; -#define FD_EQVOC_KEY_NULL fd_eqvoc_key_null -#define FD_EQVOC_KEY_INVAL(key) (!((key).slot) & !((key).fec_set_idx)) -#define FD_EQVOC_KEY_EQ(k0,k1) (!(((k0).slot) ^ ((k1).slot))) & !(((k0).fec_set_idx) ^ (((k1).fec_set_idx))) -#define FD_EQVOC_KEY_HASH(key) ((uint)(((key).slot)<<15UL) | (((key).fec_set_idx))) +static const fd_slot_fec_t fd_slot_fec_null = { 0 }; +#define FD_SLOT_FEC_NULL fd_slot_fec_null +#define FD_SLOT_FEC_INVAL(key) (!((key).slot) & !((key).fec_set_idx)) +#define FD_SLOT_FEC_EQ(k0,k1) (!(((k0).slot) ^ ((k1).slot))) & !(((k0).fec_set_idx) ^ (((k1).fec_set_idx))) +#define FD_SLOT_FEC_HASH(key) ((uint)(((key).slot)<<15UL) | (((key).fec_set_idx))) /* clang-format on */ -struct fd_eqvoc_entry { - fd_eqvoc_key_t key; +struct fd_eqvoc_fec { + fd_slot_fec_t key; ulong next; ulong code_cnt; ulong data_cnt; uint last_idx; fd_ed25519_sig_t sig; }; -typedef struct fd_eqvoc_entry fd_eqvoc_entry_t; +typedef struct fd_eqvoc_fec fd_eqvoc_fec_t; -#define POOL_NAME fd_eqvoc_pool -#define POOL_T fd_eqvoc_entry_t +#define POOL_NAME fd_eqvoc_fec_pool +#define POOL_T fd_eqvoc_fec_t #include "../../util/tmpl/fd_pool.c" /* clang-format off */ -#define MAP_NAME fd_eqvoc_map -#define MAP_ELE_T fd_eqvoc_entry_t -#define MAP_KEY_T fd_eqvoc_key_t -#define MAP_KEY_EQ(k0,k1) (FD_EQVOC_KEY_EQ(*k0,*k1)) -#define MAP_KEY_HASH(key,seed) (FD_EQVOC_KEY_HASH(*key)^seed) +#define MAP_NAME fd_eqvoc_fec_map +#define MAP_ELE_T fd_eqvoc_fec_t +#define MAP_KEY_T fd_slot_fec_t +#define MAP_KEY_EQ(k0,k1) (FD_SLOT_FEC_EQ(*k0,*k1)) +#define MAP_KEY_HASH(key,seed) (FD_SLOT_FEC_HASH(*key)^seed) #include "../../util/tmpl/fd_map_chain.c" /* clang-format on */ -typedef int (*fd_eqvoc_sig_verify_fn)( void * arg, fd_shred_t * shred ); - struct fd_eqvoc { /* primitives */ - ulong min_slot; /* min slot we're currently indexing. */ + ulong fec_min; /* min slot we're currently tracking fec meta for (will be evicted first). */ ulong key_max; /* max # of FEC sets we can index. */ ulong shred_version; /* shred version we expect in all shreds in eqvoc-related msgs. */ /* owned */ - fd_eqvoc_map_t * map; - fd_eqvoc_entry_t * pool; - fd_sha512_t * sha512; - void * bmtree_mem; + fd_eqvoc_fec_t * fec_pool; + fd_eqvoc_fec_map_t * fec_map; + fd_eqvoc_proof_t * proof_pool; + fd_eqvoc_proof_map_t * proof_map; + fd_sha512_t * sha512; + void * bmtree_mem; /* borrowed */ - fd_epoch_leaders_t const * leaders; - fd_eqvoc_sig_verify_fn sig_verify_fn; + fd_epoch_leaders_t const * leaders; }; typedef struct fd_eqvoc fd_eqvoc_t; @@ -154,13 +163,15 @@ fd_eqvoc_footprint( ulong key_max ) { FD_LAYOUT_APPEND( FD_LAYOUT_APPEND( FD_LAYOUT_APPEND( + FD_LAYOUT_APPEND( FD_LAYOUT_INIT, - alignof(fd_eqvoc_t), sizeof(fd_eqvoc_t) ), - fd_eqvoc_pool_align(), fd_eqvoc_pool_footprint( key_max ) ), - fd_eqvoc_map_align(), fd_eqvoc_map_footprint( FD_EQVOC_MAX ) ), - fd_sha512_align(), fd_sha512_footprint() ), - fd_bmtree_commit_align(), fd_bmtree_commit_footprint( FD_SHRED_MERKLE_LAYER_CNT ) ), - fd_eqvoc_map_align(), fd_eqvoc_map_footprint( FD_EQVOC_MAX ) ), + alignof(fd_eqvoc_t), sizeof(fd_eqvoc_t) ), + fd_eqvoc_fec_pool_align(), fd_eqvoc_fec_pool_footprint( key_max ) ), + fd_eqvoc_fec_map_align(), fd_eqvoc_fec_map_footprint( key_max ) ), + fd_eqvoc_proof_pool_align(), fd_eqvoc_proof_pool_footprint( key_max ) ), + fd_eqvoc_proof_map_align(), fd_eqvoc_proof_map_footprint( key_max ) ), + fd_sha512_align(), fd_sha512_footprint() ), + fd_bmtree_commit_align(), fd_bmtree_commit_footprint( FD_SHRED_MERKLE_LAYER_CNT ) ), fd_eqvoc_align() ); } /* clang-format on */ @@ -198,28 +209,44 @@ fd_eqvoc_leave( fd_eqvoc_t const * eqvoc ); void * fd_eqvoc_delete( void * sheqvoc ); -/* fd_eqvoc_insert inserts `shred` into eqvoc, indexing it by (slot, - fec_set_idx). If `shred` is a coding shred, it populates entry's - metadata fields. */ +/* fd_eqvoc_proof_insert inserts a fd_gossip_duplicate_shred_t `chunk` + into eqvoc, indexed by (slot, pubkey). Each chunk is buffered until + all chunks for the given (slot, pubkey) are received (max 3). */ + +fd_eqvoc_proof_t * +fd_eqvoc_proof_insert( fd_eqvoc_t * eqvoc, fd_gossip_duplicate_shred_t const * chunk ); + +/* fd_eqvoc_fec_insert inserts `shred` into eqvoc, indexed by (slot, + fec_set_idx). */ void -fd_eqvoc_insert( fd_eqvoc_t * eqvoc, fd_shred_t const * shred ); +fd_eqvoc_fec_insert( fd_eqvoc_t * eqvoc, fd_shred_t const * shred ); -/* fd_eqvoc_query queries for FEC set metadata on (slot, fec_set_idx). - At least one coding shred most be inserted to populate code_cnt, - data_cnt, and the last data shred in the slot to populate last_idx. - Otherwise fields are defaulted to 0, 0, FD_SHRED_IDX_NULL + +/* fd_eqvoc_proof_query queries for the proof that two shreds are + equivocating at (slot, from). */ + +FD_FN_CONST static inline fd_eqvoc_proof_t const * +fd_eqvoc_proof_query( fd_eqvoc_t const * eqvoc, ulong slot, fd_hash_t from ) { + fd_slot_pubkey_t key = { slot, from }; + return fd_eqvoc_proof_map_ele_query_const( eqvoc->proof_map, &key, NULL, eqvoc->proof_pool ); +} + +/* fd_eqvoc_fec_query queries for FEC set metadata on (slot, + fec_set_idx). At least one coding shred most be inserted to populate + code_cnt, data_cnt, and the last data shred in the slot to populate + last_idx. Otherwise fields are defaulted to 0, 0, FD_SHRED_IDX_NULL respectively. Callers should check whether fields are the default values before using them. */ -FD_FN_CONST static inline fd_eqvoc_entry_t const * -fd_eqvoc_query( fd_eqvoc_t const * eqvoc, ulong slot, uint fec_set_idx ) { - fd_eqvoc_key_t key = { slot, fec_set_idx }; - return fd_eqvoc_map_ele_query_const( eqvoc->map, &key, NULL, eqvoc->pool ); +FD_FN_CONST static inline fd_eqvoc_fec_t const * +fd_eqvoc_fec_query( fd_eqvoc_t const * eqvoc, ulong slot, uint fec_set_idx ) { + fd_slot_fec_t key = { slot, fec_set_idx }; + return fd_eqvoc_fec_map_ele_query_const( eqvoc->fec_map, &key, NULL, eqvoc->fec_pool ); } -/* fd_eqvoc_search searches for whether `shred` implies equivocation by - checking for a conflict in the currently indexed FEC sets. Returns +/* fd_eqvoc_fec_search searches for whether `shred` implies equivocation + by checking for a conflict in the currently indexed FEC sets. Returns the conflicting entry if there is one, NULL otherwise. A FEC set "overlaps" with another if they both contain a data shred @@ -242,25 +269,58 @@ fd_eqvoc_query( fd_eqvoc_t const * eqvoc, ulong slot, uint fec_set_idx ) { set. Similarly, we look forward at most data_cnt idxs to find the next FEC set. */ -fd_eqvoc_entry_t const * -fd_eqvoc_search( fd_eqvoc_t const * eqvoc, fd_shred_t const * shred ); - -/* fd_eqvoc_test tests whether shred1 and shred2 present a valid - equivocation proof. See the header at the top of the file for an - explanation and enumeration of the equivocation cases. - - To prevent false positives, this function checks equivocation proofs - contain the following: +fd_eqvoc_fec_t const * +fd_eqvoc_fec_search( fd_eqvoc_t const * eqvoc, fd_shred_t const * shred ); + +/* fd_eqvoc_test tests whether shred1 and shred2 are equivocating. + Returns a positive integer they are equivocating, 0 if they are not, + and -1 if they could not be compared for equivocation. See + FD_EQVOC_TEST_* constants defined at top of header for the list of + return values. + + Two shreds are equivocating if they satisfy any of the following: + + 1. Two shreds in the same FEC set but have different merkle roots. + 2. Two coding shreds in the same FEC set but with different coding + metadata ie. code_cnt, data_cnt, first_code_idx. + 3. Two data shreds in the same FEC set where one is marked as the + last data shred in the slot (FD_SHRED_DATA_FLAG_SLOT_COMPLETE is + set), but the other shred has a higher data shred index. + 4. Two shreds in different FEC sets, where the shred with the lower + FEC set index is a coding shred (the shred with the higher FEC set + index can be either be a coding or data shred), and the FEC sets + are overlapping based on the lower coding shred's `data_cnt` ie. + the same data shred index would appear in both FEC sets. + 5. Two shreds in different FEC sets, where the FEC sets are adjacent + (ie. the last data shred index in the lower FEC set is one less + than the first data shred index in the higher FEC set), and the + merkle root of the lower FEC set is different from the chained + merkle root of the higher FEC set. + + To prevent false positives, this function also performs the following + input validation on the shreds: + + 1. shred1 and shred2 are both the expected shred_version. + 2. shred1 and shred2 are for the same slot. + 3. shred1 and shred2 contain valid signatures by the assigned leader + for that slot. + 4. shred1 and shred2 are the same shred type. + + If any of the above input validation fail, this function returns -1 + ie. these two shreds cannot be compared for equivocation. - 1. shred1 and shred2 are for the same slot - 2. shred1 and shred2 are the expected shred_version - 3. shred1 and shred2 contain valid signatures by the current leader - 4. shred1 and shred2 are the same shred type */ int fd_eqvoc_test( fd_eqvoc_t const * eqvoc, fd_shred_t * shred1, fd_shred_t * shred2 ); +/* fd_eqvoc_verify verifies `slot` has FEC sets with merkle roots that + correctly chain, including that the first FEC set in slot's merkle + hash chains from the last FEC set in parent slot's merkle hash. */ + +int +fd_eqvoc_slot_verify( fd_eqvoc_t const * eqvoc, fd_blockstore_t * blockstore, ulong slot ); + /* fd_eqvoc_from_chunks reconstructs shred1_out and shred2_out from `chunks` which is an array of "duplicate shred" gossip msgs. Shred1 and shred2 comprise a "duplicate shred proof", ie. proof of two @@ -278,7 +338,10 @@ fd_eqvoc_test( fd_eqvoc_t const * eqvoc, fd_shred_t * shred1, fd_shred_t * shred Behavior is undefined otherwise. Does additional sanity-check validation eg. checking chunk_len <= - FD_EQVOC_CHUNK_MAX. */ + FD_eqvoc_proof_MAX. + + This function is expected to be deprecated once chunks are specified + to be fixed-length in the gossip protocol. */ void fd_eqvoc_from_chunks( fd_eqvoc_t const * eqvoc, @@ -303,7 +366,10 @@ fd_eqvoc_from_chunks( fd_eqvoc_t const * eqvoc, IMPORTANT SAFETY TIP! The lifetime of each chunk in `chunks_out` must be at least as long as the lifetime of the array of duplicate_shreds. Caller is responsible for ensuring this memory - safety guarantee. */ + safety guarantee. + + This function is expected to be deprecated once chunks are specified + to be fixed-length in the gossip protocol. */ void fd_eqvoc_to_chunks( fd_eqvoc_t const * eqvoc, diff --git a/src/choreo/eqvoc/test_eqvoc.c b/src/choreo/eqvoc/test_eqvoc.c index 9ff39181d3..cd93308b28 100644 --- a/src/choreo/eqvoc/test_eqvoc.c +++ b/src/choreo/eqvoc/test_eqvoc.c @@ -1,31 +1,59 @@ #include "fd_eqvoc.h" #include -static const uchar shred13_code_bytes[FD_SHRED_MAX_SZ]; -static const uchar shred15_code_bytes[FD_SHRED_MAX_SZ]; -static const uchar shred13_data_bytes[FD_SHRED_MIN_SZ]; -static const uchar shred13_data_bytes_eqvoc[FD_SHRED_MIN_SZ]; - void test_eqvoc_test( fd_eqvoc_t * eqvoc ) { + uchar data_0_cnt_2_slot_42_idx_0_fec_0[FD_SHRED_MIN_SZ] = { 12, 20, 88, 140, 221, 68, 111, 148, 187, 119, 30, 22, 42, 221, 65, 43, 93, 170, 201, 121, 37, 87, 253, 68, 228, 161, 159, 159, 149, 93, 96, 134, 155, 92, 2, 73, 33, 46, 100, 22, 245, 94, 0, 144, 43, 171, 120, 101, 93, 222, 110, 116, 17, 96, 149, 145, 33, 119, 0, 163, 70, 166, 206, 6, 149, 42, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 42, 0, 0, 0, 0, 0, 1, 0, 42, 47, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 247, 131, 90, 55, 245, 41, 73, 211, 141, 173, 29, 87, 159, 58, 136, 18, 205, 115, 200, 64, 195, 242, 252, 120, 220, 58, 254, 31, 67, 199, 42, 81, 109, 14, 250, 128, 50, 24, 176, 41, 132, 8, 60, 164, 149, 81, 6, 236, 49, 238, 200, 131, 75, 27, 146, 57, 2, 85, 228, 37, 131, 223, 245, 89, 100, 51, 148, 245, 134, 194, 194, 110, 240, 25, 201, 234, 239, 3, 62, 134, 94, 74, 139, 131, 28, 116, 160, 239, 153, 61, 58, 57, 122, 55, 56, 220, 88, 16, 105, 185 }; + uchar data_1_cnt_2_slot_42_idx_0_fec_0[FD_SHRED_MIN_SZ] = { 128, 8, 40, 83, 97, 158, 52, 213, 19, 114, 169, 99, 127, 71, 178, 51, 189, 151, 76, 75, 255, 116, 101, 241, 99, 16, 228, 64, 24, 208, 72, 238, 110, 240, 250, 242, 239, 157, 216, 56, 18, 211, 45, 171, 50, 253, 216, 234, 175, 225, 17, 143, 27, 169, 138, 101, 208, 70, 74, 244, 39, 28, 240, 10, 149, 42, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 42, 0, 0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, 96, 46, 225, 229, 134, 149, 82, 72, 248, 50, 61, 99, 210, 37, 184, 112, 201, 169, 151, 43, 17, 23, 200, 150, 239, 20, 41, 227, 195, 104, 226, 107, 63, 186, 151, 97, 134, 138, 25, 231, 191, 6, 60, 233, 40, 114, 238, 13, 65, 219, 138, 196, 107, 178, 191, 9, 232, 154, 44, 185, 4, 242, 41, 131, 102, 19, 60, 171, 111, 205, 218, 251, 26, 100, 107, 57, 185, 254, 42, 8, 98, 47, 46, 228, 219, 12, 162, 41, 73, 100, 56, 221, 13, 242, 107, 117, 216, 219, 206 }; + uchar data_1_cnt_2_slot_42_idx_1_fec_0[FD_SHRED_MIN_SZ] = { 128, 8, 40, 83, 97, 158, 52, 213, 19, 114, 169, 99, 127, 71, 178, 51, 189, 151, 76, 75, 255, 116, 101, 241, 99, 16, 228, 64, 24, 208, 72, 238, 110, 240, 250, 242, 239, 157, 216, 56, 18, 211, 45, 171, 50, 253, 216, 234, 175, 225, 17, 143, 27, 169, 138, 101, 208, 70, 74, 244, 39, 28, 240, 10, 149, 42, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 42, 0, 0, 0, 0, 0, 1, 0, 106, 105, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 151, 13, 77, 143, 153, 147, 93, 11, 148, 179, 51, 95, 49, 245, 3, 101, 44, 199, 157, 249, 43, 17, 23, 200, 150, 239, 20, 41, 227, 195, 104, 226, 107, 63, 186, 151, 97, 134, 138, 25, 231, 191, 6, 60, 233, 40, 114, 238, 13, 65, 219, 138, 196, 107, 178, 191, 9, 232, 154, 44, 185, 4, 242, 41, 131, 102, 19, 60, 171, 111, 205, 218, 251, 26, 100, 107, 57, 185, 254, 42, 8, 98, 47, 46, 228, 219, 12, 162, 41, 73, 100, 56, 221, 13, 242, 107, 117, 216, 219, 206 }; + uchar data_0_cnt_2_slot_42_idx_1_fec_1[FD_SHRED_MIN_SZ] = { 183, 11, 167, 20, 94, 249, 232, 94, 234, 86, 145, 8, 185, 143, 32, 144, 177, 86, 3, 15, 93, 201, 70, 5, 117, 163, 14, 251, 119, 237, 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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 232, 173, 131, 184, 66, 122, 133, 169, 88, 162, 11, 120, 87, 91, 217, 16, 93, 20, 35, 15, 183, 91, 207, 214, 189, 133, 47, 226, 49, 142, 54, 28, 19, 241, 130, 229, 161, 5, 110, 159, 15, 109, 183, 201, 163, 45, 191, 254, 195, 132, 96, 208, 229, 38, 81, 62, 69, 71, 71, 206, 211, 133, 58, 130, 232, 93, 92, 148, 181, 204, 167, 125, 215, 152, 114, 46, 250, 163, 149, 193, 133, 212, 211, 177, 69, 122, 15, 154, 230, 15, 179, 157, 42, 7, 13, 101, 173, 147, 253, 220 }; + uchar data_0_cnt_2_slot_42_idx_2_fec_2[FD_SHRED_MIN_SZ] = { 124, 153, 67, 205, 171, 159, 114, 172, 162, 231, 100, 239, 55, 219, 200, 182, 158, 82, 140, 212, 55, 9, 211, 207, 46, 242, 120, 176, 64, 244, 110, 33, 85, 155, 36, 0, 127, 168, 169, 113, 247, 72, 123, 3, 92, 19, 64, 234, 244, 15, 100, 151, 203, 3, 233, 48, 105, 91, 218, 16, 16, 102, 97, 14, 149, 42, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 42, 0, 2, 0, 0, 0, 1, 0, 42, 47, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 47, 236, 83, 133, 36, 190, 82, 27, 109, 0, 210, 43, 165, 148, 19, 228, 25, 240, 186, 24, 162, 107, 224, 90, 149, 140, 210, 234, 46, 124, 130, 254, 129, 219, 133, 89, 126, 237, 86, 124, 184, 82, 133, 78, 192, 4, 238, 195, 248, 43, 10, 27, 70, 173, 213, 168, 47, 118, 183, 243, 136, 255, 96, 2, 58, 148, 9, 66, 24, 244, 166, 208, 210, 128, 78, 100, 21, 51, 166, 59, 185, 195, 86, 250, 156, 79, 6, 221, 135, 108, 255, 144, 57, 19, 42, 84, 230, 12, 205, 103 }; + + /* same idx, payload should be marked false */ + + fd_shred_t * identity = (fd_shred_t *)fd_type_pun( data_0_cnt_2_slot_42_idx_0_fec_0 ); + FD_TEST( fd_eqvoc_test( eqvoc, identity, identity ) == FD_EQVOC_TEST_FALSE ); + + /* same idx, diff payload */ + + fd_shred_t * payload1 = (fd_shred_t *)fd_type_pun( data_0_cnt_2_slot_42_idx_0_fec_0 ); + fd_shred_t * payload2 = (fd_shred_t *)fd_type_pun( data_1_cnt_2_slot_42_idx_0_fec_0 ); + FD_TEST( fd_eqvoc_test( eqvoc, payload1, payload2 ) == FD_EQVOC_TEST_PAYLOAD ); + + /* same fec, diff mr */ - fd_shred_t * shred13_code = (fd_shred_t *)shred13_code_bytes; - fd_shred_t * shred15_code = (fd_shred_t *)shred15_code_bytes; + fd_shred_t * mr1 = (fd_shred_t *)fd_type_pun( data_0_cnt_2_slot_42_idx_0_fec_0 ); + fd_shred_t * mr2 = (fd_shred_t *)fd_type_pun( data_1_cnt_2_slot_42_idx_1_fec_0 ); + FD_TEST( fd_eqvoc_test( eqvoc, mr1, mr2 ) == FD_EQVOC_TEST_MERKLE_ROOT ); - fd_shred_t * shred13_data = (fd_shred_t *)shred13_data_bytes; - fd_shred_t * shred13_data_eqvoc = (fd_shred_t *)shred13_data_bytes_eqvoc; + /* same fec, diff code meta data cnt */ - /* Insert 13-15, 15-20 */ + uchar meta1_bytes[FD_SHRED_MAX_SZ] = { 12, 20, 88, 140, 221, 68, 111, 148, 187, 119, 30, 22, 42, 221, 65, 43, 93, 170, 201, 121, 37, 87, 253, 68, 228, 161, 159, 159, 149, 93, 96, 134, 155, 92, 2, 73, 33, 46, 100, 22, 245, 94, 0, 144, 43, 171, 120, 101, 93, 222, 110, 116, 17, 96, 149, 145, 33, 119, 0, 163, 70, 166, 206, 6, 101, 42, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 42, 0, 0, 0, 0, 0, 2, 0, 18, 0, 1, 0, 149, 42, 0, 0, 0, 0,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 1, 1, 1, 1, 1, 1, 1, 1, 1, 48, 203, 32, 97, 141, 180, 171, 78, 220, 157, 79, 41, 73, 0, 111, 71, 194, 131, 154, 78, 79, 215, 203, 112, 63, 5, 125, 58, 82, 158, 193, 32, 9, 35, 216, 240, 142, 239, 108, 86, 132, 8, 60, 164, 149, 81, 6, 236, 49, 238, 200, 131, 75, 27, 146, 57, 2, 85, 228, 37, 131, 223, 245, 89, 100, 51, 148, 245, 134, 194, 194, 110, 240, 25, 201, 234, 239, 3, 62, 134, 94, 74, 139, 131, 28, 116, 160, 239, 153, 61, 58, 57, 122, 55, 56, 220, 88, 16, 105, 185 }; + uchar meta2_bytes[FD_SHRED_MAX_SZ] = { 12, 20, 88, 140, 221, 68, 111, 148, 187, 119, 30, 22, 42, 221, 65, 43, 93, 170, 201, 121, 37, 87, 253, 68, 228, 161, 159, 159, 149, 93, 96, 134, 155, 92, 2, 73, 33, 46, 100, 22, 245, 94, 0, 144, 43, 171, 120, 101, 93, 222, 110, 116, 17, 96, 149, 145, 33, 119, 0, 163, 70, 166, 206, 6, 101, 42, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 42, 0, 0, 0, 0, 0, 2, 0, 18, 0, 0, 0, 149, 42, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 42, 0, 0, 0, 0, 0, 1, 0, 170, 163, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 230, 8, 69, 64, 210, 132, 148, 172, 103, 187, 218, 64, 201, 188, 79, 155, 96, 6, 112, 170, 79, 215, 203, 112, 63, 5, 125, 58, 82, 158, 193, 32, 9, 35, 216, 240, 142, 239, 108, 86, 132, 8, 60, 164, 149, 81, 6, 236, 49, 238, 200, 131, 75, 27, 146, 57, 2, 85, 228, 37, 131, 223, 245, 89, 100, 51, 148, 245, 134, 194, 194, 110, 240, 25, 201, 234, 239, 3, 62, 134, 94, 74, 139, 131, 28, 116, 160, 239, 153, 61, 58, 57, 122, 55, 56, 220, 88, 16, 105, 185 }; + fd_shred_t * meta1 = (fd_shred_t *)fd_type_pun( meta1_bytes ); + fd_shred_t * meta2 = (fd_shred_t *)fd_type_pun( meta2_bytes ); + FD_TEST( fd_eqvoc_test( eqvoc, meta1, meta2 ) == FD_EQVOC_TEST_CODE_META ); - FD_TEST( !fd_eqvoc_search( eqvoc, shred15_code ) ); - fd_eqvoc_insert( eqvoc, shred13_code ); - FD_TEST( fd_eqvoc_search( eqvoc, shred15_code ) ); + /* same fec, last idx violation */ - FD_TEST( fd_eqvoc_test( eqvoc, shred13_code, shred15_code ) ); - FD_TEST( fd_eqvoc_test( eqvoc, shred13_data, shred13_data_eqvoc ) ); + uchar last1_bytes[FD_SHRED_MAX_SZ] = { 12, 39, 105, 234, 41, 237, 189, 168, 237, 28, 0, 67, 59, 213, 90, 19, 238, 96, 203, 169, 88, 22, 87, 108, 120, 78, 240, 136, 210, 188, 178, 182, 132, 95, 82, 1, 17, 194, 56, 232, 97, 228, 195, 198, 208, 145, 227, 208, 107, 86, 229, 30, 137, 68, 253, 173, 125, 219, 13, 226, 106, 227, 93, 15, 149, 42, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 42, 0, 0, 0, 0, 0, 1, 0, 234, 47, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 247, 131, 90, 55, 245, 41, 73, 211, 141, 173, 29, 87, 159, 58, 136, 18, 205, 115, 200, 64, 108, 90, 247, 217, 224, 139, 115, 18, 173, 24, 134, 250, 51, 146, 132, 222, 5, 204, 88, 4, 224, 99, 224, 229, 11, 224, 118, 63, 32, 232, 170, 43, 49, 150, 33, 187, 134, 78, 135, 142, 111, 232, 30, 238, 182, 11, 145, 245, 158, 123, 110, 237, 87, 218, 227, 83, 103, 108, 24, 87, 190, 101, 144, 112, 100, 79, 73, 103, 220, 112, 223, 130, 163, 196, 49, 234, 230, 193, 249, 209 }; + uchar last2_bytes[FD_SHRED_MAX_SZ] = { 12, 39, 105, 234, 41, 237, 189, 168, 237, 28, 0, 67, 59, 213, 90, 19, 238, 96, 203, 169, 88, 22, 87, 108, 120, 78, 240, 136, 210, 188, 178, 182, 132, 95, 82, 1, 17, 194, 56, 232, 97, 228, 195, 198, 208, 145, 227, 208, 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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 190, 35, 203, 182, 187, 32, 71, 124, 128, 187, 158, 106, 18, 223, 164, 151, 250, 225, 26, 246, 108, 90, 247, 217, 224, 139, 115, 18, 173, 24, 134, 250, 51, 146, 132, 222, 5, 204, 88, 4, 224, 99, 224, 229, 11, 224, 118, 63, 32, 232, 170, 43, 49, 150, 33, 187, 134, 78, 135, 142, 111, 232, 30, 238, 182, 11, 145, 245, 158, 123, 110, 237, 87, 218, 227, 83, 103, 108, 24, 87, 190, 101, 144, 112, 100, 79, 73, 103, 220, 112, 223, 130, 163, 196, 49, 234, 230, 193, 249, 209 }; + fd_shred_t * last1 = (fd_shred_t *)fd_type_pun( last1_bytes ); + fd_shred_t * last2 = (fd_shred_t *)fd_type_pun( last2_bytes ); + FD_TEST( fd_eqvoc_test( eqvoc, last1, last2 ) == FD_EQVOC_TEST_LAST_IDX ); - FD_TEST( !fd_eqvoc_test( eqvoc, shred13_code, shred13_code ) ); - FD_TEST( !fd_eqvoc_test( eqvoc, shred13_data, shred13_data ) ); + /* diff fec, overlap */ + + fd_eqvoc_fec_insert( eqvoc, meta1 ); + fd_shred_t * overlap1 = (fd_shred_t *)fd_type_pun( data_0_cnt_2_slot_42_idx_0_fec_0 ); + fd_shred_t * overlap2 = (fd_shred_t *)fd_type_pun( data_0_cnt_2_slot_42_idx_1_fec_1 ); + FD_TEST( fd_eqvoc_test( eqvoc, overlap1, overlap2 ) == FD_EQVOC_TEST_OVERLAP ); + + /* diff fec, adjacent & chained wrong */ + + fd_shred_t * chained1 = (fd_shred_t *)fd_type_pun( data_0_cnt_2_slot_42_idx_0_fec_0 ); + fd_shred_t * chained2 = (fd_shred_t *)fd_type_pun( data_0_cnt_2_slot_42_idx_2_fec_2 ); + FD_TEST( fd_eqvoc_test( eqvoc, chained1, chained2 ) == FD_EQVOC_TEST_CHAINED ); } void @@ -210,7 +238,7 @@ main( int argc, char ** argv ) { FD_TEST( eqvoc_mem ); fd_eqvoc_t * eqvoc = fd_eqvoc_join( fd_eqvoc_new( eqvoc_mem, key_max, 0UL ) ); - eqvoc->min_slot = 42; + eqvoc->fec_min = 42; eqvoc->key_max = key_max; eqvoc->shred_version = 42; eqvoc->leaders = &leaders; @@ -220,8 +248,6 @@ main( int argc, char ** argv ) { test_eqvoc_test( eqvoc ); - // test_eqvoc_to_chunks( eqvoc, FD_SHRED_MAX_SZ, FD_SHRED_MAX_SZ, FD_EQVOC_CHUNK_MAX ); - ulong shred_szs[2] = { FD_SHRED_MIN_SZ, FD_SHRED_MAX_SZ }; ulong chunk_lens[4] = { FD_EQVOC_CHUNK_MAX, 117, 42, 10 }; @@ -239,269 +265,3 @@ main( int argc, char ** argv ) { fd_halt(); return 0; } - -static const uchar shred13_code_bytes[FD_SHRED_MAX_SZ] = { - 231, 55, 111, 140, 57, 159, 84, 2, 69, 28, 60, 138, 91, 207, 27, 144, 226, 213, 244, - 133, 134, 71, 120, 190, 239, 225, 110, 38, 196, 207, 75, 201, 149, 131, 80, 231, 218, 244, - 168, 179, 253, 221, 211, 118, 147, 243, 170, 234, 173, 89, 247, 74, 63, 110, 65, 232, 94, - 234, 146, 221, 121, 249, 194, 15, 69, 42, 0, 0, 0, 0, 0, 0, 0, 208, 0, 0, - 0, 42, 0, 13, 0, 0, 0, 3, 0, 19, 0, 0, 0, 133, 42, 0, 0, 0, 0, - 0, 0, 0, 12, 0, 0, 0, 42, 0, 13, 0, 0, 0, 1, 0, 106, 34, 4, 111, - 137, 126, 193, 31, 17, 240, 103, 195, 254, 170, 63, 235, 168, 91, 178, 230, 57, 120, 184, - 53, 227, 250, 166, 188, 128, 24, 65, 228, 3, 190, 59, 178, 14, 24, 3, 101, 50, 148, - 7, 233, 119, 7, 48, 51, 60, 46, 144, 252, 140, 38, 175, 18, 76, 144, 235, 131, 24, - 210, 231, 28, 45, 190, 213, 105, 151, 248, 159, 93, 54, 239, 128, 87, 6, 44, 157, 25, - 192, 176, 193, 207, 85, 173, 35, 3, 201, 52, 240, 13, 152, 204, 49, 204, 243, 253, 37, - 214, 29, 26, 23, 188, 0, 197, 29, 159, 59, 170, 222, 67, 117, 0, 36, 61, 131, 222, - 4, 94, 73, 250, 70, 117, 4, 114, 239, 199, 92, 222, 177, 222, 172, 59, 138, 231, 107, - 195, 72, 17, 243, 24, 175, 37, 52, 184, 96, 228, 188, 124, 51, 201, 115, 205, 6, 232, - 247, 159, 72, 239, 224, 106, 202, 2, 113, 25, 126, 157, 179, 159, 52, 199, 107, 240, 50, - 117, 255, 37, 50, 246, 203, 233, 186, 47, 240, 225, 135, 63, 27, 29, 181, 15, 9, 43, - 151, 69, 35, 124, 63, 31, 104, 94, 210, 11, 69, 252, 97, 175, 176, 244, 122, 43, 61, - 104, 17, 168, 77, 113, 226, 74, 20, 187, 63, 25, 134, 101, 98, 24, 204, 243, 104, 171, - 24, 105, 232, 88, 123, 12, 241, 219, 182, 196, 193, 29, 141, 227, 207, 170, 183, 4, 244, - 45, 170, 85, 101, 90, 223, 171, 167, 56, 203, 164, 127, 48, 139, 147, 241, 89, 144, 189, - 108, 52, 176, 154, 167, 31, 203, 100, 138, 242, 98, 144, 46, 204, 143, 12, 48, 111, 202, - 34, 191, 213, 118, 76, 132, 111, 120, 237, 212, 43, 101, 79, 56, 173, 143, 15, 207, 188, - 241, 66, 30, 62, 5, 194, 191, 148, 191, 234, 3, 233, 33, 26, 199, 72, 81, 147, 120, - 60, 10, 111, 182, 21, 108, 35, 148, 136, 217, 187, 209, 219, 62, 197, 33, 212, 166, 135, - 158, 166, 207, 179, 229, 80, 186, 245, 69, 90, 4, 77, 117, 71, 193, 140, 165, 206, 254, - 16, 38, 88, 162, 233, 144, 108, 113, 187, 180, 227, 192, 208, 236, 86, 34, 154, 134, 104, - 121, 11, 30, 142, 90, 170, 59, 163, 218, 194, 133, 248, 178, 236, 159, 135, 150, 57, 160, - 176, 147, 236, 130, 15, 68, 246, 205, 103, 119, 185, 59, 58, 180, 178, 79, 148, 32, 247, - 110, 102, 201, 154, 162, 121, 126, 233, 66, 76, 115, 110, 239, 151, 86, 167, 213, 79, 217, - 87, 126, 19, 236, 9, 202, 26, 110, 252, 63, 41, 23, 87, 96, 29, 129, 168, 203, 7, - 37, 122, 110, 251, 5, 48, 179, 144, 171, 219, 146, 129, 112, 97, 106, 239, 42, 55, 92, - 116, 246, 108, 204, 18, 175, 66, 94, 27, 144, 34, 115, 57, 192, 167, 133, 43, 71, 36, - 134, 0, 205, 9, 142, 44, 137, 195, 105, 33, 120, 191, 187, 36, 8, 44, 48, 96, 7, - 100, 112, 181, 129, 184, 238, 226, 65, 236, 216, 66, 145, 54, 121, 168, 8, 254, 116, 187, - 3, 146, 239, 90, 228, 13, 5, 173, 224, 85, 193, 62, 111, 190, 7, 25, 196, 243, 50, - 13, 194, 151, 48, 180, 75, 89, 91, 157, 56, 159, 137, 129, 31, 188, 30, 203, 192, 29, - 188, 226, 205, 210, 246, 179, 191, 12, 21, 119, 77, 161, 182, 152, 202, 124, 58, 95, 102, - 250, 170, 198, 233, 186, 121, 45, 175, 242, 253, 17, 142, 229, 150, 16, 200, 232, 57, 212, - 143, 199, 95, 217, 246, 20, 197, 124, 155, 23, 12, 174, 113, 6, 182, 171, 195, 38, 166, - 142, 77, 52, 247, 144, 59, 111, 200, 63, 78, 70, 195, 42, 18, 184, 252, 116, 217, 231, - 93, 223, 215, 188, 189, 57, 60, 101, 173, 166, 75, 213, 29, 79, 90, 10, 88, 41, 3, - 6, 181, 225, 49, 90, 44, 174, 209, 247, 133, 12, 35, 75, 91, 177, 104, 165, 184, 127, - 35, 70, 43, 248, 66, 191, 67, 227, 203, 152, 183, 43, 121, 211, 254, 203, 40, 189, 40, - 237, 113, 60, 37, 46, 141, 106, 128, 23, 136, 30, 96, 237, 76, 150, 205, 235, 205, 46, - 77, 187, 231, 111, 30, 90, 113, 107, 60, 116, 196, 171, 126, 207, 51, 123, 158, 227, 84, - 66, 23, 158, 98, 168, 161, 45, 66, 118, 23, 67, 42, 215, 26, 255, 49, 144, 150, 10, - 39, 2, 7, 71, 85, 225, 193, 72, 219, 234, 193, 6, 208, 188, 219, 105, 207, 84, 198, - 244, 175, 90, 60, 154, 156, 25, 3, 153, 103, 118, 91, 225, 8, 84, 100, 105, 3, 190, - 215, 47, 150, 136, 47, 156, 141, 44, 149, 120, 119, 44, 99, 5, 255, 44, 97, 65, 250, - 104, 8, 242, 150, 153, 229, 255, 50, 23, 157, 200, 159, 24, 174, 14, 115, 138, 193, 1, - 224, 182, 113, 127, 81, 181, 36, 169, 129, 141, 47, 45, 184, 174, 199, 22, 200, 191, 62, - 248, 64, 84, 180, 68, 128, 128, 218, 255, 40, 151, 210, 86, 154, 196, 122, 246, 255, 179, - 230, 216, 122, 69, 97, 36, 132, 84, 171, 169, 228, 206, 163, 3, 29, 213, 149, 187, 76, - 79, 189, 27, 184, 13, 111, 209, 240, 130, 88, 66, 85, 88, 25, 212, 213, 44, 217, 162, - 176, 217, 71, 71, 54, 72, 131, 67, 64, 21, 166, 50, 122, 230, 89, 106, 123, 131, 148, - 144, 98, 35, 124, 156, 42, 98, 131, 8, 241, 119, 202, 97, 85, 172, 50, 155, 117, 50, - 226, 100, 10, 96, 230, 88, 3, 153, 120, 122, 72, 253, 197, 169, 115, 79, 115, 37, 112, - 119, 144, 83, 93, 29, 12, 207, 140, 109, 30, 131, 153, 114, 183, 246, 174, 18, 10, 45, - 12, 231, 252, 179, 193, 182, 239, 125, 171, 0, 37, 106, 124, 78, 143, 252, 4, 249, 244, - 58, 116, 3, 71, 199, 11, 62, 90, 193, 243, 253, 91, 60, 253, 148, 124, 164, 1, 204, - 186, 245, 154, 238, 6, 7, 126, 68, 216, 172, 96, 221, 18, 166, 174, 169, 84, 221, 158, - 156, 180, 184, 132, 133, 105, 146, 244, 35, 87, 73, 156, 128, 12, 201, 2, 253, 192, 7, - 145, 151, 218, 14, 97, 14, 219, 139, 186, 84, 168, 121, 3, 126, 126, 189, 130, 199, 150, - 93, 107, 162, 139, 27, 22, 57, 139, 140, 148, 208, 125, 171, 41, 253, 125, 80, 59, 60, - 240, 117, 114, 248, 60, 188, 94, 70, 62, 35, 141, 193 }; - -static const uchar shred15_code_bytes[FD_SHRED_MAX_SZ] = { - 188, 5, 217, 105, 26, 255, 20, 92, 10, 44, 3, 73, 168, 161, 81, 146, 64, 209, 2, - 222, 195, 207, 61, 132, 167, 236, 49, 45, 241, 49, 174, 80, 220, 120, 34, 53, 240, 248, - 70, 27, 70, 120, 160, 234, 133, 156, 95, 57, 26, 66, 242, 43, 146, 116, 227, 252, 66, - 247, 100, 19, 122, 60, 120, 1, 69, 42, 0, 0, 0, 0, 0, 0, 0, 208, 0, 0, - 0, 42, 0, 15, 0, 0, 0, 3, 0, 19, 0, 0, 0, 133, 42, 0, 0, 0, 0, - 0, 0, 0, 14, 0, 0, 0, 42, 0, 15, 0, 0, 0, 1, 0, 106, 34, 4, 128, - 61, 215, 89, 181, 23, 104, 216, 73, 204, 178, 124, 4, 225, 255, 70, 209, 154, 102, 57, - 92, 122, 118, 249, 53, 245, 243, 64, 244, 203, 54, 65, 66, 170, 194, 200, 71, 135, 116, - 101, 1, 185, 161, 185, 154, 29, 131, 168, 179, 30, 39, 73, 47, 228, 185, 130, 175, 84, - 249, 155, 248, 157, 113, 172, 92, 93, 43, 162, 13, 120, 126, 80, 233, 44, 76, 225, 22, - 76, 48, 73, 219, 171, 187, 25, 201, 105, 228, 33, 246, 150, 5, 74, 41, 197, 158, 137, - 172, 65, 202, 6, 10, 134, 119, 120, 65, 18, 155, 0, 86, 171, 117, 186, 174, 63, 81, - 127, 5, 146, 142, 120, 48, 225, 58, 149, 130, 104, 59, 169, 195, 32, 172, 85, 229, 169, - 143, 159, 52, 163, 125, 85, 52, 97, 245, 45, 152, 110, 219, 53, 163, 181, 110, 70, 219, - 131, 76, 120, 241, 64, 214, 150, 62, 129, 141, 187, 58, 1, 119, 243, 106, 171, 25, 117, - 212, 251, 244, 166, 85, 239, 207, 48, 132, 201, 4, 16, 78, 243, 25, 120, 133, 18, 126, - 11, 175, 94, 33, 123, 220, 73, 150, 0, 69, 224, 95, 203, 65, 22, 139, 89, 229, 169, - 155, 132, 230, 214, 115, 66, 43, 17, 94, 122, 38, 255, 67, 106, 155, 248, 183, 29, 221, - 108, 254, 189, 59, 55, 193, 83, 157, 109, 65, 33, 130, 206, 45, 44, 213, 8, 138, 218, - 179, 5, 141, 149, 210, 244, 86, 156, 76, 96, 127, 136, 247, 11, 49, 56, 10, 99, 139, - 225, 67, 73, 131, 247, 163, 178, 78, 159, 146, 66, 73, 254, 189, 247, 51, 71, 143, 36, - 247, 123, 38, 27, 12, 241, 29, 221, 35, 219, 11, 237, 39, 162, 39, 79, 201, 179, 249, - 62, 38, 163, 236, 229, 129, 176, 225, 242, 136, 54, 29, 102, 19, 5, 42, 207, 136, 209, - 220, 133, 211, 105, 122, 154, 22, 206, 179, 36, 20, 57, 233, 132, 144, 250, 30, 9, 202, - 120, 106, 127, 52, 29, 168, 93, 85, 210, 15, 14, 27, 129, 93, 239, 41, 110, 118, 71, - 0, 148, 200, 60, 56, 168, 2, 36, 145, 120, 119, 26, 30, 148, 50, 214, 83, 24, 65, - 4, 213, 30, 131, 177, 157, 193, 80, 192, 121, 53, 254, 179, 58, 157, 23, 95, 9, 30, - 107, 210, 255, 223, 53, 105, 43, 110, 99, 166, 82, 55, 116, 72, 182, 119, 16, 219, 31, - 45, 50, 211, 176, 130, 114, 193, 154, 17, 167, 143, 246, 85, 201, 205, 136, 68, 147, 120, - 1, 79, 103, 61, 148, 21, 14, 245, 229, 207, 218, 175, 66, 105, 83, 125, 16, 106, 216, - 198, 133, 125, 102, 136, 164, 49, 246, 14, 52, 225, 137, 98, 150, 99, 110, 247, 167, 184, - 159, 172, 255, 185, 34, 14, 249, 137, 159, 123, 242, 112, 152, 20, 105, 254, 207, 183, 250, - 108, 151, 143, 220, 120, 61, 145, 155, 116, 236, 130, 43, 14, 40, 221, 78, 204, 153, 37, - 149, 220, 151, 245, 82, 22, 171, 27, 252, 119, 68, 230, 114, 220, 11, 245, 248, 69, 162, - 80, 206, 252, 65, 230, 0, 201, 22, 242, 193, 176, 214, 59, 214, 221, 11, 226, 8, 145, - 26, 177, 1, 104, 123, 93, 35, 35, 146, 230, 115, 157, 149, 215, 194, 193, 44, 171, 167, - 161, 163, 158, 87, 68, 60, 127, 182, 91, 2, 78, 140, 199, 46, 3, 164, 239, 86, 22, - 49, 31, 106, 245, 112, 111, 46, 189, 160, 82, 202, 180, 185, 207, 207, 118, 39, 170, 251, - 3, 41, 131, 113, 121, 79, 202, 214, 217, 215, 51, 252, 69, 139, 22, 234, 143, 201, 31, - 68, 81, 165, 25, 82, 166, 192, 223, 174, 197, 153, 90, 122, 238, 223, 132, 50, 195, 70, - 207, 106, 120, 251, 28, 39, 34, 177, 169, 217, 183, 98, 81, 161, 248, 75, 54, 201, 14, - 70, 202, 39, 65, 245, 217, 16, 217, 118, 141, 147, 176, 212, 182, 170, 173, 87, 7, 252, - 64, 247, 107, 174, 137, 232, 63, 53, 227, 67, 112, 90, 232, 206, 192, 223, 12, 135, 176, - 13, 181, 49, 20, 94, 188, 113, 253, 13, 68, 143, 3, 183, 81, 134, 18, 249, 171, 180, - 47, 28, 62, 149, 4, 155, 120, 172, 184, 136, 67, 34, 231, 52, 32, 38, 121, 140, 27, - 182, 183, 35, 126, 127, 211, 60, 233, 235, 120, 177, 199, 176, 138, 53, 79, 22, 191, 150, - 77, 102, 56, 254, 154, 5, 159, 27, 209, 243, 151, 174, 90, 73, 73, 237, 138, 23, 71, - 200, 108, 17, 188, 13, 162, 223, 83, 246, 93, 229, 240, 244, 49, 44, 112, 82, 112, 90, - 178, 253, 59, 224, 48, 86, 10, 250, 216, 95, 179, 74, 77, 249, 94, 15, 76, 14, 167, - 79, 46, 235, 72, 26, 185, 28, 124, 69, 42, 97, 23, 34, 60, 191, 29, 42, 29, 241, - 113, 176, 110, 36, 153, 201, 46, 226, 40, 138, 149, 79, 23, 151, 104, 83, 91, 70, 189, - 68, 225, 201, 98, 207, 172, 102, 102, 168, 121, 129, 65, 125, 26, 85, 212, 158, 60, 100, - 16, 169, 207, 206, 11, 4, 95, 136, 94, 3, 101, 217, 41, 23, 29, 70, 26, 189, 72, - 147, 40, 99, 90, 48, 51, 161, 42, 25, 45, 103, 182, 62, 91, 8, 50, 67, 3, 84, - 228, 126, 193, 138, 105, 48, 119, 238, 218, 61, 112, 132, 89, 34, 236, 18, 136, 175, 204, - 168, 11, 39, 233, 236, 82, 147, 193, 172, 198, 90, 240, 102, 105, 32, 7, 102, 43, 72, - 222, 159, 57, 101, 218, 193, 75, 119, 133, 186, 114, 92, 234, 47, 13, 95, 49, 42, 42, - 104, 27, 203, 74, 123, 104, 92, 69, 63, 76, 43, 161, 188, 191, 4, 25, 67, 43, 229, - 14, 82, 1, 249, 117, 37, 8, 168, 153, 92, 160, 8, 242, 210, 144, 255, 114, 89, 154, - 112, 161, 186, 119, 214, 131, 209, 61, 33, 27, 7, 239, 244, 62, 24, 245, 123, 252, 124, - 136, 30, 25, 128, 53, 233, 108, 201, 140, 30, 78, 79, 196, 229, 70, 203, 60, 151, 149, - 184, 211, 211, 211, 129, 156, 63, 10, 50, 29, 91, 156, 45, 122, 54, 202, 212, 3, 93, - 82, 29, 17, 207, 132, 190, 151, 179, 92, 194, 197, 125, 128, 141, 81, 64, 161, 55, 191, - 137, 184, 210, 183, 204, 105, 151, 43, 245, 16, 63, 4, 108, 108, 87, 135, 70, 213, 136, - 59, 137, 220, 226, 158, 86, 222, 25, 233, 244, 26, 30 }; - -static const uchar shred13_data_bytes[FD_SHRED_MIN_SZ] = { - 6, 110, 124, 101, 85, 227, 31, 118, 212, 51, 144, 98, 206, 54, 48, 235, 150, 181, 132, - 90, 80, 148, 32, 68, 132, 1, 63, 174, 55, 97, 169, 212, 152, 60, 94, 218, 60, 35, - 11, 83, 80, 254, 240, 65, 155, 177, 102, 175, 55, 136, 16, 76, 198, 216, 26, 80, 167, - 18, 114, 178, 62, 109, 213, 3, 133, 42, 0, 0, 0, 0, 0, 0, 0, 13, 0, 0, - 0, 42, 0, 13, 0, 0, 0, 1, 0, 42, 79, 4, 68, 226, 106, 240, 224, 45, 152, - 233, 54, 71, 16, 187, 90, 189, 211, 29, 246, 221, 83, 123, 68, 195, 87, 226, 230, 21, - 219, 26, 115, 105, 57, 129, 79, 47, 64, 89, 9, 43, 213, 80, 230, 163, 44, 98, 11, - 114, 235, 125, 151, 110, 18, 84, 237, 80, 212, 59, 90, 77, 5, 2, 102, 102, 166, 21, - 53, 8, 19, 233, 5, 107, 237, 59, 113, 212, 128, 94, 43, 26, 187, 34, 141, 36, 232, - 18, 16, 194, 88, 244, 54, 207, 212, 189, 183, 143, 181, 11, 30, 192, 192, 235, 251, 219, - 242, 5, 88, 27, 138, 8, 122, 185, 29, 78, 248, 121, 240, 254, 10, 215, 175, 3, 253, - 175, 51, 184, 117, 208, 37, 183, 71, 143, 60, 250, 255, 180, 124, 17, 177, 155, 174, 196, - 226, 87, 155, 3, 1, 192, 216, 170, 5, 49, 20, 217, 226, 129, 178, 119, 227, 207, 162, - 109, 18, 232, 138, 239, 73, 9, 98, 123, 208, 132, 22, 200, 149, 32, 53, 141, 93, 79, - 12, 40, 184, 133, 71, 229, 193, 177, 168, 73, 182, 245, 6, 52, 52, 153, 209, 91, 172, - 172, 41, 207, 235, 139, 176, 214, 3, 175, 41, 144, 73, 120, 173, 135, 137, 61, 162, 142, - 136, 123, 122, 210, 84, 84, 1, 134, 77, 90, 246, 109, 204, 4, 189, 64, 122, 182, 134, - 199, 65, 22, 132, 240, 165, 2, 124, 131, 240, 171, 120, 157, 146, 95, 228, 165, 9, 19, - 74, 98, 78, 92, 139, 68, 73, 23, 225, 111, 234, 177, 132, 199, 185, 158, 58, 67, 60, - 10, 235, 62, 42, 90, 218, 142, 27, 109, 143, 142, 255, 134, 64, 48, 42, 33, 204, 132, - 209, 178, 33, 153, 233, 6, 86, 206, 186, 121, 21, 131, 234, 32, 240, 188, 31, 229, 223, - 32, 1, 58, 226, 112, 33, 130, 27, 155, 27, 230, 158, 136, 43, 119, 14, 15, 122, 53, - 56, 8, 29, 208, 165, 65, 123, 203, 196, 96, 183, 129, 62, 27, 67, 227, 210, 135, 35, - 102, 149, 46, 59, 223, 50, 98, 15, 146, 200, 107, 147, 61, 190, 198, 149, 41, 157, 165, - 113, 176, 157, 77, 181, 239, 49, 171, 54, 170, 127, 243, 239, 58, 123, 22, 184, 79, 200, - 47, 139, 25, 6, 191, 196, 28, 87, 212, 47, 250, 20, 201, 103, 93, 183, 45, 37, 24, - 134, 204, 79, 192, 80, 142, 233, 121, 199, 10, 164, 15, 223, 116, 216, 136, 180, 182, 211, - 148, 188, 66, 59, 91, 78, 15, 185, 65, 212, 228, 190, 34, 68, 57, 251, 25, 77, 118, - 43, 29, 154, 153, 149, 138, 67, 57, 221, 49, 63, 152, 199, 120, 64, 222, 18, 6, 246, - 181, 149, 224, 30, 28, 19, 55, 226, 34, 246, 202, 62, 171, 149, 90, 102, 205, 12, 5, - 87, 223, 217, 42, 151, 206, 22, 137, 232, 211, 201, 96, 175, 168, 149, 82, 16, 220, 231, - 187, 169, 129, 196, 250, 213, 128, 44, 230, 142, 40, 144, 174, 177, 67, 27, 172, 255, 220, - 204, 124, 162, 152, 206, 52, 27, 118, 71, 217, 215, 224, 220, 124, 87, 178, 223, 120, 127, - 5, 148, 45, 43, 194, 52, 194, 151, 89, 31, 90, 17, 224, 198, 126, 1, 68, 25, 92, - 11, 133, 235, 127, 227, 22, 184, 129, 67, 79, 62, 202, 86, 52, 158, 198, 62, 51, 116, - 128, 36, 53, 205, 77, 184, 216, 18, 91, 244, 250, 104, 41, 220, 185, 94, 135, 104, 139, - 103, 237, 159, 94, 42, 201, 197, 140, 145, 221, 222, 217, 71, 77, 107, 102, 131, 91, 61, - 86, 199, 61, 70, 90, 164, 47, 26, 95, 52, 61, 192, 167, 85, 197, 28, 106, 134, 110, - 164, 229, 239, 215, 162, 41, 142, 105, 111, 77, 163, 145, 212, 30, 156, 5, 52, 115, 12, - 7, 70, 186, 255, 205, 121, 153, 248, 252, 235, 199, 9, 86, 240, 185, 61, 189, 168, 15, - 236, 254, 192, 66, 66, 173, 188, 122, 67, 56, 5, 36, 10, 38, 112, 61, 47, 246, 59, - 138, 18, 7, 22, 67, 238, 93, 135, 7, 210, 35, 227, 171, 93, 38, 176, 81, 5, 109, - 26, 67, 246, 8, 41, 248, 165, 167, 180, 212, 64, 38, 8, 179, 68, 228, 246, 184, 107, - 21, 241, 36, 240, 191, 84, 151, 82, 221, 174, 3, 200, 19, 236, 179, 21, 92, 123, 14, - 156, 236, 203, 95, 100, 28, 210, 104, 169, 61, 162, 243, 37, 151, 47, 148, 62, 126, 39, - 201, 114, 165, 121, 4, 32, 84, 227, 28, 96, 119, 195, 250, 9, 223, 143, 101, 140, 153, - 117, 78, 52, 17, 191, 240, 104, 19, 3, 107, 29, 71, 166, 185, 106, 113, 172, 100, 51, - 98, 126, 196, 209, 244, 77, 176, 70, 77, 197, 151, 119, 141, 17, 69, 214, 147, 194, 64, - 88, 199, 170, 72, 152, 182, 111, 93, 255, 30, 241, 170, 189, 143, 198, 32, 104, 123, 134, - 168, 162, 248, 242, 192, 84, 85, 36, 193, 92, 174, 151, 169, 156, 187, 205, 203, 178, 70, - 32, 215, 172, 83, 175, 247, 2, 215, 96, 244, 152, 0, 213, 127, 142, 100, 69, 44, 212, - 153, 94, 238, 99, 188, 74, 98, 100, 18, 198, 182, 48, 99, 207, 23, 149, 127, 250, 74, - 99, 45, 115, 32, 149, 246, 105, 42, 244, 219, 16, 162, 11, 78, 122, 229, 26, 22, 209, - 250, 87, 151, 165, 171, 172, 42, 59, 164, 70, 236, 228, 229, 79, 91, 254, 27, 79, 239, - 98, 247, 217, 61, 61, 193, 134, 3, 74, 224, 222, 51, 15, 198, 142, 85, 11, 249, 15, - 16, 111, 44, 184, 50, 202, 131, 85, 194, 50, 214, 34, 184, 98, 156, 161, 117, 21, 137, - 203, 41, 34, 31, 0, 172, 223, 61, 26, 21, 246, 98, 105, 229, 53, 223, 203, 135, 244, - 87, 42, 249, 139, 32, 190, 28, 57, 6, 87, 37, 234, 26, 115, 57, 37, 54, 189, 74, - 77, 168, 73, 246, 42, 176, 180, 233, 167, 194, 80, 207, 124, 32, 94, 229, 25, 48, 40, - 85, 1, 106, 8, 141, 91, 47, 230, 217, 110, 156, 213, 108, 39, 197, 35, 102, 99, 47, - 201, 14, 114, 235, 231, 60, 119, 223, 81, 10, 60, 15, 78, 187, 39, 197, 80, 64, 96, - 0, 157, 26, 55, 5, 180, 219, 183, 158, 237, 30, 228, 47, 152, 206, 68, 202, 17, 111, - 188, 96, 54, 8, 221, 80, 228, 234, 214, 35, 22, 172, 65, 217, 165, 190, 30, 147, 39, - 193, 214, 157, 222, 255, 181 }; - -static const uchar shred13_data_bytes_eqvoc[FD_SHRED_MIN_SZ] = { - 231, 55, 111, 140, 57, 159, 84, 2, 69, 28, 60, 138, 91, 207, 27, 144, 226, 213, 244, - 133, 134, 71, 120, 190, 239, 225, 110, 38, 196, 207, 75, 201, 149, 131, 80, 231, 218, 244, - 168, 179, 253, 221, 211, 118, 147, 243, 170, 234, 173, 89, 247, 74, 63, 110, 65, 232, 94, - 234, 146, 221, 121, 249, 194, 15, 133, 42, 0, 0, 0, 0, 0, 0, 0, 13, 0, 0, - 0, 42, 0, 13, 0, 0, 0, 1, 0, 42, 79, 4, 237, 248, 73, 77, 173, 95, 27, - 47, 14, 141, 238, 91, 139, 242, 196, 136, 240, 216, 122, 126, 173, 230, 220, 80, 161, 39, - 93, 131, 88, 234, 217, 30, 99, 183, 58, 63, 147, 24, 90, 68, 165, 44, 200, 172, 160, - 137, 253, 151, 178, 141, 88, 19, 241, 18, 130, 124, 27, 223, 40, 4, 45, 181, 53, 232, - 136, 180, 3, 79, 230, 205, 59, 165, 227, 161, 229, 47, 105, 215, 154, 227, 142, 16, 15, - 117, 20, 205, 249, 58, 101, 103, 163, 214, 115, 254, 133, 204, 114, 46, 155, 160, 214, 161, - 15, 93, 126, 87, 35, 142, 23, 67, 204, 207, 201, 135, 228, 166, 131, 91, 5, 64, 63, - 120, 243, 72, 61, 53, 109, 227, 125, 68, 173, 211, 205, 58, 105, 12, 193, 218, 206, 187, - 127, 21, 214, 233, 109, 24, 68, 31, 132, 129, 63, 125, 108, 31, 202, 83, 173, 29, 154, - 185, 64, 78, 30, 113, 216, 22, 34, 101, 199, 94, 195, 242, 188, 156, 125, 109, 135, 208, - 131, 78, 211, 127, 82, 17, 163, 39, 16, 237, 3, 166, 1, 127, 153, 208, 242, 219, 193, - 56, 16, 56, 181, 191, 39, 15, 25, 214, 249, 134, 36, 214, 38, 172, 238, 210, 110, 248, - 238, 243, 21, 50, 184, 164, 236, 60, 61, 136, 86, 144, 220, 115, 241, 59, 144, 123, 181, - 146, 187, 163, 86, 67, 45, 190, 177, 221, 177, 161, 23, 142, 186, 117, 131, 8, 101, 241, - 222, 231, 149, 133, 226, 195, 37, 35, 156, 214, 131, 124, 132, 147, 82, 24, 22, 150, 139, - 90, 26, 171, 129, 246, 56, 146, 3, 117, 112, 77, 47, 22, 137, 151, 14, 158, 45, 181, - 47, 80, 56, 190, 173, 116, 215, 109, 110, 220, 31, 139, 252, 210, 117, 67, 183, 53, 237, - 12, 198, 212, 116, 54, 201, 75, 50, 190, 129, 171, 150, 3, 68, 228, 26, 248, 183, 94, - 184, 175, 218, 73, 86, 175, 86, 41, 0, 198, 57, 243, 13, 54, 80, 245, 129, 226, 28, - 117, 191, 166, 24, 112, 182, 238, 228, 93, 121, 37, 114, 145, 57, 63, 4, 235, 21, 228, - 255, 168, 21, 126, 38, 41, 197, 120, 111, 31, 93, 184, 229, 236, 86, 31, 102, 128, 20, - 230, 97, 151, 74, 131, 255, 69, 61, 43, 39, 203, 83, 43, 90, 66, 7, 149, 30, 122, - 3, 107, 26, 204, 223, 57, 191, 211, 251, 189, 142, 152, 147, 44, 36, 74, 40, 59, 63, - 239, 247, 182, 218, 15, 220, 245, 42, 154, 224, 146, 104, 46, 32, 128, 98, 29, 156, 108, - 253, 33, 116, 151, 185, 59, 45, 232, 241, 83, 51, 97, 205, 79, 221, 179, 90, 54, 234, - 89, 125, 175, 133, 130, 18, 23, 43, 68, 98, 20, 62, 100, 10, 193, 106, 79, 64, 6, - 42, 134, 245, 44, 22, 120, 50, 179, 215, 28, 99, 44, 42, 27, 177, 117, 52, 47, 117, - 132, 137, 42, 214, 229, 250, 121, 84, 19, 227, 242, 118, 147, 32, 39, 169, 133, 2, 47, - 213, 50, 188, 98, 142, 225, 219, 206, 169, 201, 68, 103, 124, 126, 87, 85, 119, 20, 123, - 24, 190, 42, 225, 210, 11, 47, 224, 152, 112, 106, 195, 44, 107, 136, 113, 171, 121, 227, - 21, 165, 91, 177, 233, 125, 229, 224, 91, 170, 42, 224, 29, 84, 62, 9, 74, 99, 169, - 245, 48, 96, 152, 113, 54, 176, 215, 207, 180, 206, 59, 253, 45, 107, 195, 124, 79, 162, - 157, 248, 3, 64, 77, 81, 185, 50, 105, 204, 72, 66, 163, 45, 132, 15, 253, 73, 213, - 4, 56, 134, 97, 160, 217, 223, 61, 0, 107, 52, 159, 45, 57, 197, 207, 245, 39, 199, - 222, 171, 163, 248, 91, 43, 54, 203, 176, 7, 28, 152, 247, 227, 170, 192, 119, 97, 28, - 181, 61, 18, 176, 250, 254, 22, 131, 104, 131, 201, 57, 35, 116, 214, 36, 246, 125, 145, - 102, 10, 165, 19, 31, 233, 110, 46, 79, 235, 90, 235, 177, 249, 1, 9, 244, 60, 37, - 245, 104, 154, 185, 79, 42, 129, 172, 10, 58, 123, 119, 34, 83, 245, 94, 92, 126, 58, - 150, 4, 70, 251, 251, 94, 81, 184, 113, 225, 234, 101, 66, 125, 50, 223, 255, 122, 29, - 152, 14, 43, 54, 161, 112, 183, 10, 31, 193, 61, 87, 71, 180, 165, 237, 221, 47, 40, - 219, 49, 214, 24, 194, 254, 253, 100, 66, 112, 147, 167, 2, 147, 61, 99, 38, 5, 145, - 53, 133, 244, 145, 233, 135, 216, 14, 194, 162, 175, 243, 227, 34, 228, 154, 76, 136, 17, - 105, 35, 73, 222, 196, 45, 25, 116, 86, 18, 35, 202, 128, 150, 10, 13, 65, 252, 203, - 155, 203, 21, 105, 16, 144, 164, 60, 193, 213, 12, 89, 234, 149, 94, 100, 195, 118, 3, - 159, 212, 156, 14, 22, 27, 163, 199, 164, 132, 177, 192, 187, 144, 9, 69, 170, 65, 240, - 180, 97, 215, 53, 15, 37, 54, 233, 112, 186, 69, 6, 50, 199, 199, 255, 84, 200, 187, - 70, 30, 35, 164, 155, 217, 39, 76, 18, 166, 13, 195, 240, 96, 168, 80, 113, 161, 26, - 161, 25, 198, 152, 61, 61, 252, 126, 71, 65, 121, 231, 37, 57, 159, 231, 168, 125, 41, - 87, 88, 83, 83, 53, 255, 231, 178, 235, 190, 96, 148, 9, 37, 202, 101, 61, 77, 159, - 41, 56, 166, 205, 14, 80, 157, 95, 253, 149, 161, 129, 20, 102, 221, 248, 24, 113, 79, - 13, 132, 165, 172, 112, 37, 193, 50, 71, 30, 121, 68, 134, 206, 253, 141, 86, 41, 164, - 60, 23, 89, 102, 121, 248, 177, 25, 70, 213, 28, 89, 140, 126, 104, 80, 178, 28, 91, - 129, 16, 245, 186, 216, 234, 153, 4, 160, 43, 190, 35, 251, 47, 18, 223, 89, 19, 165, - 168, 199, 61, 65, 138, 173, 41, 170, 220, 139, 147, 100, 150, 8, 191, 233, 12, 215, 54, - 157, 134, 227, 238, 138, 221, 206, 89, 197, 124, 137, 5, 81, 70, 72, 104, 78, 218, 175, - 77, 137, 95, 23, 251, 69, 57, 201, 13, 231, 46, 114, 14, 10, 69, 141, 191, 101, 122, - 163, 194, 218, 87, 73, 156, 128, 12, 201, 2, 253, 192, 7, 145, 151, 218, 14, 97, 14, - 219, 139, 186, 84, 168, 121, 3, 126, 126, 189, 130, 199, 150, 93, 107, 162, 139, 27, 22, - 57, 139, 140, 148, 208, 125, 171, 41, 253, 125, 80, 59, 60, 240, 117, 114, 248, 60, 188, - 94, 70, 62, 35, 141, 193 }; diff --git a/src/disco/shred/fd_fec_resolver.c b/src/disco/shred/fd_fec_resolver.c index d744dce316..1f95a93e1a 100644 --- a/src/disco/shred/fd_fec_resolver.c +++ b/src/disco/shred/fd_fec_resolver.c @@ -569,7 +569,7 @@ int fd_fec_resolver_add_shred( fd_fec_resolver_t * resolver, return FD_FEC_RESOLVER_SHRED_REJECTED; } - uchar const * chained_root = fd_ptr_if( fd_shred_is_chained( shred_type ), (uchar *)shred+fd_shred_chain_offset( variant ), NULL ); + uchar const * chained_root = fd_ptr_if( fd_shred_is_chained( shred_type ), (uchar *)shred+fd_shred_chain_off( variant ), NULL ); /* Iterate over recovered shreds, add them to the Merkle tree, populate headers and signatures. */ @@ -577,7 +577,7 @@ int fd_fec_resolver_add_shred( fd_fec_resolver_t * resolver, if( !d_rcvd_test( set->data_shred_rcvd, i ) ) { fd_memcpy( set->data_shreds[i], shred, sizeof(fd_ed25519_sig_t) ); if( FD_UNLIKELY( fd_shred_is_chained( shred_type ) ) ) { - fd_memcpy( set->data_shreds[i]+fd_shred_chain_offset( data_variant ), chained_root, FD_SHRED_MERKLE_ROOT_SZ ); + fd_memcpy( set->data_shreds[i]+fd_shred_chain_off( data_variant ), chained_root, FD_SHRED_MERKLE_ROOT_SZ ); } fd_bmtree_hash_leaf( leaf, set->data_shreds[i]+sizeof(fd_ed25519_sig_t), data_merkle_protected_sz, FD_BMTREE_LONG_PREFIX_SZ ); if( FD_UNLIKELY( !fd_bmtree_commitp_insert_with_proof( tree, i, leaf, NULL, 0, NULL ) ) ) { @@ -604,7 +604,7 @@ int fd_fec_resolver_add_shred( fd_fec_resolver_t * resolver, p_shred->code.idx = (ushort)i; if( FD_UNLIKELY( fd_shred_is_chained( shred_type ) ) ) { - fd_memcpy( set->parity_shreds[i]+fd_shred_chain_offset( parity_variant ), chained_root, FD_SHRED_MERKLE_ROOT_SZ ); + fd_memcpy( set->parity_shreds[i]+fd_shred_chain_off( parity_variant ), chained_root, FD_SHRED_MERKLE_ROOT_SZ ); } fd_bmtree_hash_leaf( leaf, set->parity_shreds[i]+ sizeof(fd_ed25519_sig_t), parity_merkle_protected_sz, FD_BMTREE_LONG_PREFIX_SZ ); @@ -644,8 +644,8 @@ int fd_fec_resolver_add_shred( fd_fec_resolver_t * resolver, reject |= parsed->data.parent_off != base_data_shred->data.parent_off; reject |= fd_shred_is_chained( fd_shred_type( parsed->variant ) ) && - !fd_memeq( (uchar *)parsed +fd_shred_chain_offset( parsed->variant ), - (uchar *)base_data_shred+fd_shred_chain_offset( base_data_shred->variant ), FD_SHRED_MERKLE_ROOT_SZ ); + !fd_memeq( (uchar *)parsed +fd_shred_chain_off( parsed->variant ), + (uchar *)base_data_shred+fd_shred_chain_off( base_data_shred->variant ), FD_SHRED_MERKLE_ROOT_SZ ); } for( ulong i=0UL; (!reject) & (iparity_shred_cnt); i++ ) { fd_shred_t const * parsed = fd_shred_parse( set->parity_shreds[ i ], FD_SHRED_MAX_SZ ); @@ -660,8 +660,8 @@ int fd_fec_resolver_add_shred( fd_fec_resolver_t * resolver, reject |= parsed->code.idx != (ushort)i; reject |= fd_shred_is_chained( fd_shred_type( parsed->variant ) ) && - !fd_memeq( (uchar *)parsed +fd_shred_chain_offset( parsed->variant ), - (uchar *)base_data_shred+fd_shred_chain_offset( base_data_shred->variant ), FD_SHRED_MERKLE_ROOT_SZ ); + !fd_memeq( (uchar *)parsed +fd_shred_chain_off( parsed->variant ), + (uchar *)base_data_shred+fd_shred_chain_off( base_data_shred->variant ), FD_SHRED_MERKLE_ROOT_SZ ); } if( FD_UNLIKELY( reject ) ) { freelist_push_tail( free_list, set );