Commit graph

21 commits

Author SHA1 Message Date
hinto-janai
5588671501
levin: enable workspace lints (#292)
* levin: enable workspace lints

* use `drop()`

* dep fixes
2024-09-20 15:11:27 +01:00
hinto-janai
bec8cc0aa4
helper: add and use cast module (#264)
* helper: add `cast` module

* fix crates

* spacing
2024-09-02 18:09:52 +01:00
hinto-janai
4b93dbec4c
workspace: enforce crate/directory naming scheme (#164)
Some checks failed
Audit / audit (push) Has been cancelled
Deny / audit (push) Has been cancelled
CI / fmt (push) Has been cancelled
CI / typo (push) Has been cancelled
CI / ci (macos-latest, stable, bash) (push) Has been cancelled
CI / ci (ubuntu-latest, stable, bash) (push) Has been cancelled
CI / ci (windows-latest, stable-x86_64-pc-windows-gnu, msys2 {0}) (push) Has been cancelled
* rename all directories and crates

* fix all `use`

* fix doc link

* `dandelion/` -> `dandelion-tower/`

* fix epee-encoding test

* fix `json-rpc`

* fix pruning

* crate import fixes

* fix leftover merge conflicts

* fix `epee-encoding`
2024-06-24 02:30:47 +01:00
hinto-janai
59a49b93ab
repo: update license (#134)
* add MIT license

* update LICENSE.md

* net: remove license files

* fix LICENSE-MIT formatting

use github formatting
2024-05-27 00:39:32 +01:00
Boog900
93372fa4b5
P2P Address book & Handshake changes (#89)
* use tokio's delay queue for bans

* document handles

* remove peers from address book when retrieving

* ping inbound peers during handshakes

* support receiving pings during handshakes

* add peer to anchor before reducing whit list

* clippy

* comment handshakes

* typos

* sort `use`

* use `rand::prelude::*`

* review comments

* update macro
2024-03-20 20:58:12 +00:00
Boog900
159c8a3b48
levin: fragmented messages (#84)
* levin: fix fragmented messages & use bitflags

* levin: add a method to fragment a message

* levin: add tests for fragmented messages and fix issues

* fix docs

* tests: don't include bytes length

* levin: add support for sending fragmented
/ dummy messages

* fmt

* add fragmented handshake tests.

* fix handshake detection when fragmented
and alt (non-monero) protocol info

* add tracing logs

* remove `already_built`, this was an old way I was thinking of sending raw buckets

* clippy

* clippy 2

* Update net/levin/src/message.rs

Co-authored-by: hinto-janai <hinto.janai@protonmail.com>

* review comments

* add timeout to tests

* Update net/levin/src/header.rs

Co-authored-by: hinto-janai <hinto.janai@protonmail.com>

---------

Co-authored-by: hinto-janai <hinto.janai@protonmail.com>
2024-03-05 01:29:57 +00:00
Boog900
b7df133175
consensus: fix batch handling when we don't have a full list of outputs. (#54)
* consensus: fix batch handling when we don't have a full list of outputs.

* change `scan_chain` to new API

* clippy

* add a test for calculating multiple difficulties

* fmt

* rx_seed -> rx_vms

* consensus-rules: ring members younger than current block.

* only create rx vms when required.

* fix rx initiation when syncing

* add single block verification (no batch)

* update serai
2024-02-13 00:51:11 +00:00
Boog900
83b59c557c
net: use epee_encoding instead of monero-epee-bin-serde
This gives us more control than what serde provides. This
PR also moves to use `Bytes` where possible to allow
zero-copy parsing of network messages.
2024-01-30 16:09:54 +00:00
Boog900
2b65be4b18
net: add epee-encoding and fixed-bytes 2024-01-29 22:44:59 +00:00
Boog900
0cc2acc816
monero-p2p: tell client message was sent after sending message.
Otherwise, the message might not be sent
2024-01-13 15:56:22 +00:00
Boog900
f7149863ae
levin: don't error when there isn't enough capacity 2024-01-13 14:41:19 +00:00
Boog900
a0b9280801
fix message requesting in Connection 2024-01-13 13:22:34 +00:00
Boog900
8557073c15
p2p changes (#38)
* start re-working p2p to work with change monero-wire

* start re-working p2p to work with change monero-wire

adds back some changes from #22

* change the peer module to use the new API + fix a couple bugs

* remove peer set for now

* add try_from/from conversion between `Message` and
`Request`/`Response`

* Allow specifying other parameters in levin-cuprate

* add new `LevinCommand` enum and clean up monero-wire message de/encoding

* fix issues with merge

* start splitting up p2p crate into smaller crates.

* add monerod action from serai to test network code

* remove tracing in tests
2023-11-30 18:09:05 +00:00
Boog900
bfbafa4ed5
change epee-encoding to monero-epee-bin-serde 2023-10-09 21:10:16 +01:00
Boog900
ab3c496bbd
add difficulty calculations 2023-09-06 15:54:49 +01:00
Boog900
477d9e42f3
change monero-wire to use epee-encoding (#25)
* change monero-wire to use epee-encoding

* Add back unified `Message` enum

* Run clippy & fmt

* add back default val for top_version
2023-07-17 18:43:34 +01:00
Boog900
e6e8bdaf6c
Re-work levin to remove a lot of the complexities (#24) 2023-07-13 22:10:52 +01:00
Boog900
a187d9a357
initial p2p code (#8)
* init

* save

* use macro to create the levin body enum

* add protocol docs and cargo fmt

* add response validation

* add client functionality to connection + fmt

* Add new cuprate-common crate
this crate will hold stuff needed across cuprate crates

+ init handshaker

* add stagenet & testnet hardforks + tests

+ cargo fmt

* split peer and protocol into separate crates
+ add sync state watcher

* finish initial sync states and add some tests

* save

* add initial address book

* cargo fmt

* save

* add pruning module to cuprate-common

* more address book updates
- added an address book client
- add some more address book requests
- add "NetZone"

* lots of changes

* cargo fmt

* combine p2p into one crate
they were all linked anyway

* cargo fmt

* turn the handshaker into a statemachine

* cargo fmt

* reduce the amt of copies when decoding

+ remove reliance on monero-rs

* update time_from_timestamp func

* cargo fmt
+ change qr code link
+ remove clippy.toml
2023-04-24 22:37:40 +01:00
Someone Else
be43216b3f
initial database code (#6)
* commit to start the draft pull request.

added a space

* Please don't look to close.It might hurt your eyes

* impl associated types

* errors, docs & divided ro/rw tx

Added some more errors to DB_FAILURES, rewrited crates docs, and specified
WriteTransaction subtype which implement write mode method.

* more changes see description

changed blockchain_db folder by database. Implemented (just for test) get_block_hash, open, from to Interface.
Also rewrited a declarative macro for tables. Will have to add Dummy Tables later.

* small changes

* Organized modules & implemented get_block_hash

* write prototype & error

Added prototype functions for clear(), put() & delete() in mdbx implementation. They still don't
consider table flags. Also added a temporary DB_FAILURES::EncodingError for monero-rs consensus_encode
errors. Still have to rethink about it to resend a reference to the data that can't be encoded.

* Multiple changes

- hse.rs
Added hse.rs that will contain db implementations for HSE. Since the codebase can't welcome unsafe
code, the wrapper will be written outside of the project.
- lib.rs
Added a specific FailedToCommit error. (will investigate if really necessary).
Added DupTable trait, which is a Table with DUPSORT/DUPFIXED support and its declarative macro.
Added two other tables, blockheaders that give block's header with specified hash & blockbody that give block's body with specified hash
Added Cursor methods, that are likely to be deprecated if I found a way to implemen Iterator on top of it.
Added WriteCursor trait & methods, which is basically put & del.
Added mandatory type for Cursors in Transaction & WriteTransactions
Refactored get_block_hash interface method.
- mdbx.rs
Added partial implementation of Cursor & WriteCursor trait for libmdbx::Cursor. Only the first() & get() methods are implemented
Added implementation of get & commit for Transaction

* put mdbx as features with its dependency

* save

* refactored some method with macros

* more mdbx errors, docs correction, moved to error.rs

* finish nodup mdbx impl, errors.rs, macros, tables

Finished the initial implementation of Cursor, WriteCursor, Transaction and WriteTransaction in mdbx.rs. Corrected some macros in mdbx.rs to simplify the implementations. There is certainly rooms to more flexible macros. Also added 3 other tables. I started to divide errors into category to more easily handle them at higher-level. Due to the large number of errors i just moved them into another file. There is know DB_SERIAL enum for errors relating of decoding/encoding error & DB_FULL enum for every errors relating a component being overeaching its capacity.

* bye bye match statement in mdbx.rs

* defined all blockchain tables (not txpool)

* dupsort/fixed support, dupcursor, basic block interface

* tables, types, encoding and documentations

Redefined all the database types from @Boog900's monero-rs db branch and added the needed
implementations. The database now use bincode2 for encoding and decoding. We observe that bincode was
5 times faster at serializing than monero::consensus_encode. Since we still use monero-rs types but can't implement
foreign trait to them, the encoding module contain a compatibility layer, the time we switch from monero-rs to properly
implement it. All the tables are now defined. (can be subject to change if there is good reason for). added documentations
to modules and types.

* replaced macros and added hfversion table

* save

* multiple changes

* modified database schema. deprecated output global index and splited up pre-rct from rct output.

* Fixed DupCursor function to return subkey (thx to rust turbofish inference).

* Added some output functions

* Added two new DB_FAILURES, one to handle a prohibited None case and one for undefined case where a dev msg is needed.

* fixed TxOutputIdx, previously used global index, now is a tuple of amount/amount_index.

* i hate lifetimes

* read-only method now use read-only tx

* initial output fn

* some tx functions. Yes I'll refactor them

* moved interface in a module

* redefined errors, more tx fn, None->error

* corrected a table + started blk fns

* save

* fixed TxOutputIdx + pop_block

* IIRC I finished initial interface fns

* fixed table name const + db build/check/open fn

* switched important tables to dummy keys + rm blockhfversion

* minor docs correction

* fixed mentioned issues

* make a test bin, just for fun

* fixed issues + cargo fmt

* removed monerod part

* fixed a comment
2023-04-20 18:20:32 +01:00
Boog900
8844d23d2e
Change license to AGPL-3 or MIT depending on crate 2023-03-07 23:36:48 +00:00
Boog900
265fb3e895
initial net code (#2)
* initial commit
not ready

* add new levin lib

* fix decoding multiple messages

* make the levin lib async

* saving progress

* saving progress

* init documention of levin and reorganise net

* update monero-wire

* remove p2p folder - this PR is just for net

* update Cargo.toml

* net: update links in cargo.toml
2023-03-07 22:37:55 +00:00