Commit Graph

1554 Commits

Author SHA1 Message Date
j-berman
30fc80b33e Don't copy when flattening leaves 2024-08-02 22:34:06 -07:00
j-berman
cbf6a5d618 Optimize conversion from output to leaf tuple 2024-08-02 22:32:03 -07:00
j-berman
b90cee8bab Store {O,C} for each leaf tuple instead of {O.x,I.x,C.x}
- Can derive {O.x,I.x,C.x} from {O,C}
- Note: this slows down tests since they do the derivation both
on insertion into the tree, and when auditing the tree
- At the hard fork, we don't need to store {O,C} in the
output_amounts table anymore since that table will no longer be
useful
2024-08-02 10:28:13 -07:00
j-berman
54d5d0d5c7 fcmp++: add support for new fcmp types in cryptonote::transaction
- Replace CLSAGs with a single fcmp_pp
- fcmp_pp is an opaque vector of bytes. The length of the vector
is calculated from the number of inputs on serialization (i.e. the
length is not serialized, only the raw bytes are serialized)
- Includes tests for binary serialization happy path and errors
2024-07-31 18:13:23 -07:00
j-berman
c383087955 Instantiate m_curve_trees on BlockchainLMDB class in c'tor 2024-07-29 03:40:44 -07:00
j-berman
b585a7f408 Remove copy in get_tree_extension and better named funcs 2024-07-29 03:40:44 -07:00
j-berman
93795b4c9d Match output unlock time (fix off by 1) 2024-07-29 03:40:44 -07:00
j-berman
634e12e9ad Guarantee insertion order into the tree using global output ID
- Leaves enter the tree in the block they unlock, in the order
they appear in the chain
2024-07-29 03:40:44 -07:00
j-berman
306488b690 Implemented growing the tree on sync + lots of cleaning
- validate output and commitment in tuple conversion function
- function to get_unlock_height from height in chain + unlock_time
- tx_outs_to_leaf_tuples function
- cleaned up trim impl (reduced num params in instructions and
conditional complexity)
- renamed locked_outputs table to locked_leaves (clearer tie to
merkle tree)
- size_t -> uint64_t for db compatibility across 32-bit and 64-bit
machines
- added hash_grow tests
2024-07-29 03:40:44 -07:00
j-berman
8a89c20f3b lmdb migration to init curve trees tree from existing outputs
still rough
2024-07-29 03:40:44 -07:00
j-berman
f50ad5baac trim_tree db impl + db test + some housekeeping 2024-07-29 03:40:44 -07:00
j-berman
42fd22c4ee Better organization 2024-07-29 03:40:44 -07:00
j-berman
55caee9a10 Better tests for hash_trim 2024-07-29 03:40:44 -07:00
j-berman
4be2d7cf91 whitespace fixes 2024-07-29 03:40:44 -07:00
j-berman
5ddca0ce11 Implement and test trim_tree algo in memory 2024-07-29 03:40:44 -07:00
j-berman
36f1e1965f Fix grow_tree, restructure it, and clean the approach
The initial impl didn't capture the following edge case:

  - Tree has 3 (or more) layers + 1 leaf layeri
  - Leaf layer last chunk IS full
  - Layer 0 last chunk is NOT full
  - Layer 1 last chunk is NOT full
  - Layer 2 last chunk IS NOT full

In this case, when updating layer 1, we need to use layer 0's old
last hash to update layer 1's old last hash. Same for Layer 2.

The solution is to use logic that checks the *prev* layer when
updating a layer to determine if the old last hash from the prev
layer is needed.

This commit restructures the grow_tree impl to account for this
and simplifies the approach as follows:

1. Read the tree to get num leaf tuples + last hashes in each layer

2. Get the tree extension using the above values + new leaf tuples
2a. Prior to updating the leaf layer, call the function
get_update_leaf_layer_metadata. This function uses existing totals
in the leaf layer, the new total of leaf tuples,  and tree params
to calculate how the layer after the leaf layer should be updated.
2b. For each subsequent layer, call the function
get_update_layer_metadata. This function uses the existing totals
in the *prev* layer, the new total of children in the *prev* layer,
and tree params to calculate how the layer should be updated.

3. Grow the tree using the tree extension.

This approach isolates update logic and actual hashing into neat
structured functions, rather than mix the two. This makes the code
easier to follow without needing to keep so much in your head at
one time.
2024-07-29 03:40:44 -07:00
j-berman
8287ba6f78 faster trim_tree tests 2024-07-29 03:40:44 -07:00
j-berman
ed040cacc1 implement trim_tree_in_memory 2024-07-29 03:40:44 -07:00
j-berman
e8af7090b0 expose and test hash_trim from rust lib 2024-07-29 03:40:44 -07:00
j-berman
ae89fddc00 Set up trim_tree_in_memory test 2024-07-29 03:40:44 -07:00
j-berman
c7c6c6afff CurveTreesUnitTest -> CurveTreesGlobalTree class 2024-07-29 03:40:44 -07:00
j-berman
17b1f421c0 cleaner lmdb test structure for curve trees 2024-07-29 03:40:44 -07:00
j-berman
6045357f6a implement db->audit_tree, and flesh out db test to init/extend tree 2024-07-29 03:40:44 -07:00
j-berman
ab7c74136b Simplify edge case handling in hash_layer
- When retrieving last chunks, set next_start_child_chunk_index
so can know the correct start index without needing to modify
the offset
- Other smaller cleanup
2024-07-29 03:40:44 -07:00
Luke Parker
c792b21535 Use statics on the Rust side for generators 2024-07-29 03:40:44 -07:00
Luke Parker
af47a135eb Remove cxx and expose scalars/points directly 2024-07-29 03:40:44 -07:00
j-berman
af9b74fcc7 start LMDB grow_tree 2024-07-29 03:40:44 -07:00
j-berman
5ad026975a Cleaner template usage, moved static functions out of CurveTrees class 2024-07-29 03:40:44 -07:00
j-berman
9ba00be519 Move curve_trees.h implementations into curve_trees.cpp file 2024-07-29 03:40:44 -07:00
j-berman
4ade675939 Consolidate hash_leaf_layer into hash_layer 2024-07-29 03:40:44 -07:00
j-berman
9e68475ebd Use widths from fcmp++ repo test & align tests with width 2024-07-29 03:40:44 -07:00
j-berman
29e0fe759e Add Curve class, and Helios & Selene classes that derive from Curve 2024-07-29 03:40:44 -07:00
j-berman
d9390c7b08 Implement CurveTrees & CurveTreesUnitTest classes to simplify callers 2024-07-29 03:40:44 -07:00
j-berman
5103a94ee9 template all curve_trees types & funcs, rename tower_cycle_types to tower_cycle 2024-07-29 03:40:44 -07:00
j-berman
ad8872a76b Cleaner file organization 2024-07-29 03:40:44 -07:00
j-berman
33ad50b176 fix c1 c2 layer indexing issue in test helper get_last_chunk 2024-07-29 03:40:44 -07:00
j-berman
1ba876bcc2 remove whitespaces 2024-07-29 03:40:44 -07:00
j-berman
e1c03f4d5a rough fcmp++ tree impl (lots of work remaining to clean it up and fix) 2024-07-29 03:40:44 -07:00
luigi1111
3b53db47cf
Merge pull request #9386
1d024f0 chore: fix some comments (haouvw)
2024-07-16 19:01:09 -04:00
luigi1111
66c5917876
Merge pull request #9353
32f3245 cryptonote_protocol: prevent duplicate txs in fluff queue (0xFFFC0000)
2024-07-16 18:51:30 -04:00
luigi1111
040bccc22f
Merge pull request #9338
4a376d6 copyright: fix vector.h typo (hinto.janaiyo)
d61e8e9 workflows: delete copyright.yml (plowsof)
341771a copyright: bump to 2024 (copyCat)
2024-07-16 18:42:49 -04:00
luigi1111
d7eece3cae
Merge pull request #8619
e71c8bf wallet: background sync with just the view key (j-berman)
2024-07-16 18:29:47 -04:00
haouvw
1d024f0701 chore: fix some comments
Signed-off-by: haouvw <jchaodaohang@foxmail.com>
2024-07-11 14:56:25 +08:00
0xFFFC0000
32f32453f1
cryptonote_protocol: prevent duplicate txs in fluff queue
1. Fix duplicate transaction #9335
2. Add test for cases where there are duplicate transaction in fluff

Co-authored-by: Boog900 <boog900@tutanota.com>
2024-06-05 16:33:15 +00:00
j-berman
e71c8bf190 wallet: background sync with just the view key
- When background syncing, the wallet wipes the spend key
from memory and processes all new transactions. The wallet saves
all receives, spends, and "plausible" spends of receives the
wallet does not know key images for.
- When background sync disabled, the wallet processes all
background synced txs and then clears the background sync cache.
- Adding "plausible" spends to the background sync cache ensures
that the wallet does not need to query the daemon to see if any
received outputs were spent while background sync was enabled.
This would harm privacy especially for users of 3rd party daemons.
- To enable the feature in the CLI wallet, the user can set
background-sync to reuse-wallet-password or
custom-background-password and the wallet automatically syncs in
the background when the wallet locks, then processes all
background synced txs when the wallet is unlocked.
- The custom-background-password option enables the user to
open a distinct background wallet that only has a view key saved
and can be opened/closed/synced separately from the main wallet.
When the main wallet opens, it processes the background wallet's
cache.
- To enable the feature in the RPC wallet, there is a new
`/setup_background_sync` endpoint.
- HW, multsig and view-only wallets cannot background sync.
2024-05-24 23:11:58 -07:00
koe
ddf3af1f0c add key exchange round booster to multisig_account 2024-05-21 15:27:08 -05:00
copyCat
341771ac3e copyright: bump to 2024 2024-05-21 16:29:33 +00:00
luigi1111
6c346eca03
Merge pull request #9305
de9c461 common: support boost filesystem copy_options. Co-authored-by: selsta <selsta@sent.at> (0xFFFC0000)
2024-05-20 23:38:20 -05:00
luigi1111
58b1e931f7
Merge pull request #9268
463228b Skip privacy networks (on tx sends) that don't have outgoing connections (Lee *!* Clagett)
2024-05-20 23:34:39 -05:00
luigi1111
eb35250895
Merge pull request #9257
d6609b8 serialization: do any N-tuple (jeffro256)
2024-05-20 23:31:17 -05:00