Commit Graph

4336 Commits

Author SHA1 Message Date
dasman
c4ea68e474 event_graph: in dag_insert() continue instead of break when iterating over/cleaning unreferenced_tips 2024-06-25 03:18:54 +03:00
draoi
5d7632d79f hosts: use async mutex instead of async rwlock on HostRegistry
Mutex makes more sense here since there are orders of magnitude more call to write() than there are to read() (we counted) (trust me bro)
2024-06-24 18:00:37 +02:00
draoi
4abc12207a chore: cleanup hosts imports 2024-06-24 13:45:50 +02:00
draoi
43bad915a5 refinery: delete un-necessary and excessively long lock on greylist
Previously we were locking the greylist to prevent the index from changing
while performing a handshake. This isn't necessary. It is acceptable
for the greylist index to change while the handshake is ongoing.

The thing we don't want to happen is that the addr we are operating on
is somehow removed from the list- this should never happen since it has
been marked as "Refine" in the HostRegistry. Therefore, calling unwrap()
on get_index_at_addr() should pass 100% of the time (and if it doesn't,
that indicates a logic failure elsewhere in the code).
2024-06-24 13:34:34 +02:00
draoi
531e4b2f92 net: use sync Mutex for last_connection
RwLock is overkill in this case since there is only ever one reader and
one writer.

For more info why a sync Mutex is appropiate in this case, see commit 65a8e9a44fa3c835158550e7eb5b5e1946e3028f
2024-06-24 13:34:34 +02:00
draoi
76934ac216 net: use sync Mutex for ipv6_available
Locks should be sync for simple data operations and async if:

1. the lock must be held across an .await point
2. the new data being stored in the lock is calculated from data already inside the lock

Since ipv6_available is a fast and simple data operation it is more appropiate to use
a sync Mutex here.
2024-06-24 13:34:34 +02:00
draoi
aee1e571d4 error: fix wrong print on HostStateBlocked 2024-06-22 19:01:24 +02:00
draoi
348ed19a7d net/tests: ensure ports are unique 2024-06-21 19:43:02 +02:00
draoi
541166162e acceptor: return error instead of calling unwrap() on subscribe_stop
unwrap() can panic in the rare case that a node disconnects while we are
in the middle of accepting a connection from it.

In the case that this happens we should instead just exit with an error.
2024-06-21 12:01:55 +02:00
skoupidi
3f31e393e1 contract/money/client/pow_reward: minor cleanup 2024-06-20 14:18:27 +03:00
skoupidi
6e59afaee3 contract/money/client/genesis_mint: allow optional different recipient 2024-06-20 14:18:27 +03:00
skoupidi
8c33d59f40 chore: updated all repo references to codeberg 2024-06-19 20:51:25 +03:00
draoi
57499cff8b net/test: capture panics + select random ports to connect to
Selecting a random port allows us to run the test on the same machine
concurrently without conflicts.

Note that selecting a port for the seed node and seed sync session is
fairly safe, since we immediately start the node after the port is
selected, meaning most of the time the same port will not come up as
available if another test is being run concurrently.

However there is slightly less certainty with the manual session, since
we first generate a list of available ports, and then start them in a
loop, creating a slight delay and increasing the probability that
another test, run concurrently, could select one of those ports as
available.
2024-06-19 19:22:19 +02:00
skoupidi
5313217f9f contract/money/client/genesis_mint: minor cleanup 2024-06-19 20:07:25 +03:00
skoupidi
934d8f1a42 validator: check block timestamp is after genesis 2024-06-19 17:37:02 +03:00
skoupidi
82a56cd2c2 validator: properly handle gas limit checks 2024-06-19 12:00:21 +03:00
kalm
cff9d0e7f5 validator/consensus: gas-based limit for unproposed transactions retrieval
Gas-based limit implementation to retrieve unproposed transactions. The limit is maintained by the constant 'GAS_LIMIT_UNPROPOSED_TXS', currently calculated as the product of the average total gas used and a gas limit multiplier equivalent to the existing TX_CAP value (i.e, 50).

The average total gas was obtained through analysis of empirical transaction test data, using a gas analysis tool.

The aim of this approach is to allow a gradual and controlled transition towards an optimal gas-based system. This minimizes potential adverse effects brought by changes to TX_CAP's implementation and provides the benefits of using gas to limit the number of txs received. This implementation will be fine-tuned until the discovery of the most efficient formula for determining the unproposed transactions' gas limit.

Tests have been added to verify the implementation's correctness by running transactions against it. To run the tests, run the following command from the bin/darkfid directory:

cargo test --release --bin darkfid tests::unproposed_txs
2024-06-13 05:27:05 -07:00
draoi
c088ec5003 manual_session: reconnect when a manual connection disconnects 2024-06-10 17:22:18 +02:00
draoi
b0b192c3f2 system: rename Subscriber to Publisher + propagate change
We now subscribe to a Publisher which is clearer conceptually than
subscribing to a Subscriber.
2024-06-10 17:22:18 +02:00
foo
302d482475 money/client/transfer: Fix integer truncation issues when dividing for half-split
- Fix issue where `half` was calculated incorrectly for odd values of
  `value`
- Fix issue where sending a `value` of 1 and `half_split` of true would
  result in two empty value transfers

Note that this is only a client issue. The wasm back-end would cause the
invalid transfer to fail as the tx outputs from the client would not
match the inputs
2024-06-09 17:53:21 +03:00
foo
4eba00236d clippy: add suggested clippy lints to top-level Cargo.toml and enable
clippy linting at the workspace level for all crates

Configure all workspaces to use lints from the top-level Cargo.toml
  file
Add example lints that the project could configure to improve security
  and reliability.
Configure lints to warn level. Using deny level makes other binaries
fail to compile if even one of them has a failure.
No lints are added in this commit. Future changes can enable and fix
lints
2024-06-09 10:35:09 -04:00
dasman
cfe9f49de2 dakirc+tau: do not create_dir_all on replay path if not needed 2024-06-08 03:03:24 +03:00
dasman
3bbbaa6308 make clippy happy again 2024-06-06 13:32:40 +03:00
lunar-mining
63a91dde41 net: remove potential race conditions
1. Shutting down all channels in p2p.stop() is redundant since they will
   be cleaned up by the session shutdown.
2. subscribe_stop().expect(..) could panic in the case that the node we
   are connecting to disconnects at this exact moment (triggering a
   `ChannelStopped` error).
2024-06-06 08:33:10 +02:00
dasman
37f85f49cd event_graph: dag replay logs and db to be configurable, also user should choose to run in replay mode or not 2024-06-06 04:42:47 +03:00
skoupidi
a755c30b75 contract/dao: renamed all day references to blockwindow 2024-06-05 16:33:38 +03:00
skoupidi
b5cb5a55b7 contract/dao: use actual runtime block target time not hardcoded one in blockwindow() 2024-06-05 14:20:17 +03:00
skoupidi
43f9fc8aa1 runtime: get_block_target() fn added, to retrieve current block time target(seconds) 2024-06-05 13:25:48 +03:00
skoupidi
6b5ae99724 drk/transfer: added new --half-split to split output coin into two equal halves 2024-06-04 15:35:27 +03:00
dasman
c59eff836a event_graph: remove block until synced TODO 2024-06-04 15:09:56 +03:00
dasman
938681fc1b event_graph: do not handle EventPut until we are synced 2024-06-04 15:04:44 +03:00
parazyd
80d103a2ba chore: Update crate dependencies 2024-06-04 10:24:28 +02:00
dasman
fb78838277 event_graph: replace harcoded parent reply timeout to respect p2p outbound timeout 2024-06-03 05:05:51 +03:00
skoupidi
a0024ad508 drk: proposal exec functionalities added 2024-05-31 22:05:12 +03:00
skoupidi
5e0b592603 drk: fixed dao votes 2024-05-30 22:21:00 +03:00
parazyd
65df99394b net/transport/tor: Release stream Mutex lock after obtaining a RendRequest 2024-05-30 19:31:50 +02:00
parazyd
bddf4ce774 net/transport/tor: Delete unused code 2024-05-30 19:30:25 +02:00
parazyd
9465d558e9 net/transport/tor: Return proper errors where applicable 2024-05-30 19:29:05 +02:00
parazyd
871d89a3e9 net/transport: Add experimental Tor hidden service support 2024-05-30 19:27:20 +02:00
draoi
08141d9c50 net: select from the greylist if we have no white or gold
Also add a setting to allow us to specify slot_preference_strict = true, which
would disable greylist selection if set, even if we have no white or
gold connections. (this might be useful in the case of an attack where we want to strictly avoid greylist entries).
2024-05-30 17:50:16 +02:00
skoupidi
cbb53aa8ec drk: refactored DAO votes functionalities 2024-05-30 17:54:28 +03:00
skoupidi
78eeefe1d5 DAO: changed nullifiers SMT logic to store a set of roots and updated propose entrypoint accordingly 2024-05-28 14:11:21 +03:00
parazyd
f3fc43d37d error: Clean up unused error definitions 2024-05-28 11:02:22 +02:00
darkfi
8f4103d6e2 system: add condvar_wait_after_notify() unit test 2024-05-27 20:05:03 +02:00
parazyd
358b5e1670 net: Don't care if CryptoProvider has already been installed.
The second time this is done within a single process, it returns an error.
We might want to fix it in a better way.
2024-05-27 16:40:21 +02:00
parazyd
225aeebe7d net: Install default CryptoProvider for TLS connections 2024-05-27 16:24:18 +02:00
parazyd
2e37330d0d chore: Update crate dependencies 2024-05-27 15:29:58 +02:00
parazyd
1960ca795c blockchain/block_store: Derive serialization instead of manual impl 2024-05-27 14:40:57 +02:00
parazyd
124a9466cf serial: Add support for num-bigint 2024-05-27 14:39:22 +02:00
draoi
15b7bc4bd8 settings: set inbound/ outbound default to 8, white_connect_percent to 70
Also propgagate this change as the default to various configs.
2024-05-27 11:19:16 +02:00