Commit Graph

4295 Commits

Author SHA1 Message Date
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
skoupidi
490084b26d blockchain: updated to sled-overlay 0.1.2 2024-05-27 12:15:26 +03:00
skoupidi
96a8068ec3 drk: refactor to support SMT
Additionaly, some cleanup was done, minor bugz fixed and updated DAO Propose call with the new setup and added its fee call.
2024-05-25 18:29:40 +03:00
draoi
70fc34f90e outbound_session: make clippy 2024-05-24 16:22:12 +02:00
draoi
8d9510478e net: add ipv6 addrs to dark list if we do not support ipv6
If ipv6_available is set to false, filter_addrs will send ipv6 addresses
to the darklist.

This is necessary since otherwise they would be deleted by the refinery
and not propagated on the network, even if they are perfectly valid
hosts.

Once on the dark list, these addresses will not be connected to in
OutboundSession.

Note that because there may be a delay when we establish ipv6 connectivity
(since it requires Connector to fail with ENETUNREACH), there is a
possibility of the following happening:

* recv ipv6 addrs, add to greylist
* try to connect to ipv6 addr
* set ipv6_available == false
* recv ivp6 addrs, add to darklist
* we now have duplicate addrs on darklist and greylist.

This is not a problem because the refinery will eventually delete the
greylist entries and from then on the dark list will be the definitive
list for ipv6 addrs.
2024-05-24 16:22:12 +02:00
draoi
0b8ea0db34 net/test: disable gold and white connections 2024-05-24 16:22:12 +02:00
draoi
ca4b415c42 outbound_session: remove SlotPreference
Previously if we didn't meet the gold count or white counts set in
settings, we would select from other lists that do not match what we
specified in the config. This feels like a side effect and in fact we
should more strictly adher to the prefereces.

If our preferences aren't met, we simply do peer discovery.
2024-05-24 16:22:12 +02:00
dasman
9e8bdd8630 eventgraph: replayer instruction log simplified a bit 2024-05-24 04:48:52 +03:00
parazyd
9f838d6d40 net/connector: Mark IPv6 unavailability if the connector gets ENETUNREACH 2024-05-23 15:33:24 +02:00
parazyd
d747188055 net/transport: Propagate everything as io::Result 2024-05-23 15:29:46 +02:00
parazyd
c51c1d1a1e net/transport: Use io::Result in the net::transport module instead of crate::Result 2024-05-23 15:17:36 +02:00
draoi
3bf9c67e77 outbound_session: fix bug in Slot white_count calculations
settings.white_count was 90 by default (a percentage) but was being
treated as an absolute value in outbound session.

we fix this and simplify the types to avoid excessive conversions.
2024-05-23 12:40:17 +02:00
draoi
394ccc7b63 outbound_session: move host to greylist before suspending
This is necessary since it could be a gold or whitelist peer that hasn't
updated and so fails the version exchange. Marking a gold or whitelist
peer as Suspend wouldn't do anything since it would never make it to the
refinery.
2024-05-23 10:37:17 +02:00
skoupidi
fb5865fce4 drk: provide liquidity to dao with transfer and token mint 2024-05-22 20:49:22 +03:00
skoupidi
10ea889e31 drk: dao records sympliefied and dao mint call fee added
Removed dao_id and use the dao name as the identifier. Cleaned up all dao record structures. Fixed dao mint call and added its fee.
2024-05-22 16:43:17 +03:00
draoi
511c26c904 outbound_session: suspend a peer that fails the version exchange 2024-05-22 15:07:50 +02:00
draoi
9806543de6 protocol_version: bugfix
The Error result of the version exchange was not being dealt with.
Instead we were only handling when the version exchange timed out.

There was also a bug in the handling of the failure in session/mod.rs
where the error case was similarly ignored. We now explicitly return
with an error in the case that the version exchange fails or times out.
2024-05-22 13:50:13 +02:00
draoi
27b03c2528 outbound_session: make clippy 2024-05-22 13:50:13 +02:00
draoi
5f9b862e9a refine_session: bugfix
Fix bug that was causing peers to pass the refinery even when the version exchange failed. We use futures::select instead of the system method timeout() for more fine grained control over the different return types.
2024-05-22 12:30:40 +02:00
draoi
0dea915843 p2p: better start(), stop() sequences
Before we would start the refine() session first because it contains a
SelfHandshake that ProtocolAddr/Seed were dependent on.

Since it's an internal process that deals with locks and HostState it
feels more logical to start() stop() it last in the sequence.
2024-05-22 11:50:05 +02:00
draoi
e6cdcc80e1 outbound_session: don't add to greylist if Connector stops
Also add a FIXME/ TODO note and various improved debug statements.
2024-05-22 11:30:53 +02:00
draoi
5828da13e3 net: rm SelfHandshake
Previously we would do a version exchange with our own external
address and perform a time stamp when the version exchange occured
successfully. This tuple of (external_addr, last_seen) would be shared
with other nodes in ProtocolAddr and ProtocolSeed.

This commit removes SelfHandshake. Instead, we simply set the last_seen
to now when we send our addrs in ProtocolAddr/Seed.

Rationale:

1. Doing a version exchange with ourselves requires creating two
   channels, an inbound and an outbound channel. This causes unintended
   message broadcasting to our own addrs in p2p.broadcast(), and race
   conditions when one of the two channels disconnects.

2. Being reachable by our own node does not guarantee our node is
   reachable by other nodes, so it's not a reliable method for
   determining whether an address is accessible.

3. As the external addrs ends up on the greylist of other peers, the
   work is essentially redundant, since they will also ping the address
   via their GreylistRefinery.

One notable impact of this change is that setting the timestamp to now
means that external addresses from other nodes will be placed on the top
of our greylist. Hostlists are sorted by last_seen, with the most
recently seen timestamp on the top of the list. However, this does not
impact the refinery ordering because refinery selects peers to refine
randomly.

The one area this could impact is outbound session, since we
search for an address to connect to by looping through the hostlists
(incl. greylist) starting from index 0 (i.e. the most recently seen
node). Therefore, this commit increases the probability of connecting to
a node that has recently sent its address to us (or marking that node as
"Suspend" if we cannot connect to it).
2024-05-21 17:05:53 +02:00
draoi
1915b38f8e net: rename anchor[..] to gold[..]
We have already mostly made this change so it's just for consistency.
2024-05-21 17:05:53 +02:00
draoi
55e9cc21d0 session: manually stop the connector on slot.stop()
This change required adding a new abstraction called Slot that stores a
Connector, and refactoring ManualSession significantly such that it more
closely resembles the format of other sessions.

We also use FuturesUnordered to stop process concurrently wherever
relevant.
2024-05-20 16:45:30 +02:00
draoi
eca97916f6 connector: add a stop signal to abort the Connector
Connector can be prematurely stopped even if a connection is in
progress.
2024-05-20 16:22:57 +02:00
draoi
a092f0d0eb transport: non-blocking tcp connect
`socket2::connect_with_timeout()` is blocking, and so would wait up to
`outbound_connect_timeout` seconds before returning even when the
underlying connection has been stopped.

To make the connection non-blocking, we wrap it in an Async object and
wait for it to complete using the socket method `take_error()`. If
there's a timeout configured, we use futures::select to return whatever
completes first. Otherwise, we wait on the connection.

For more info, see: https://github.com/rust-lang/socket2/issues/466

Also helpful: https://stackoverflow.com/questions/73101446/non-blocking-tcp-socket-fails-to-connect-using-socket2
2024-05-20 16:22:57 +02:00
draoi
007500d8e7 net/test: check all hostlists, not just 1 random hostlist
also give the seed node enough time to run the refinery twice, to ensure
peers have at least 1 addr from the seed node (since the node that was
refined will filter out its own addr in the first addr propagation).
2024-05-20 16:22:57 +02:00
draoi
efb3d05449 doc: adjust log level on session/mod.rs 2024-05-20 16:22:57 +02:00
draoi
85fb7bc684 protocol_seed: only append to greylist if addrs msg is not empty 2024-05-20 16:22:57 +02:00
draoi
f4d93104b5 seedsync: refactor to enable reseed on CondVar.notify()
We introduce a new abstraction called Slot which runs a connector for
each seed specified in Settings. On `p2p.start()`, seed slots are
started but sit in a pending state until a subsequent call to
`notify()`.

This change allows us to have more fine grained control over the `Connector`
(such as allowing us to stop the `Connector` when it is in progress).

Notably there has been a change to the error handling since we no longer
return a success or failure from the seedsync process. Instead, we store
success or failure of a given `Slot` in a AtomicBool, which allows us to
notify other parts of the codebase if all attempts to seed have failed.
2024-05-20 16:22:57 +02:00
skoupidi
e93b6cca95 contract/dao/{entrypoint, client}: replaced asserts with error returns and fixed log targets 2024-05-20 15:14:13 +03:00
skoupidi
0fb90b0978 contract/deployooor/client: replaced asserts with error returns and added log targets 2024-05-20 14:18:05 +03:00
skoupidi
5c126999a1 contract/money/client: replaced asserts with error returnes and added log targets 2024-05-20 14:11:11 +03:00
skoupidi
0243560e1f drk: added fee call to deployoOor calls 2024-05-17 20:18:04 +03:00
skoupidi
4661d797cd drk: attach-fee added and fixed otc swap 2024-05-17 20:04:42 +03:00
parazyd
f87382e856 serial: Use mutable references for non-async {en,de}code functions 2024-05-17 12:49:32 +02:00
skoupidi
c3433efe2e drk: cleanup on swap aisle 2024-05-16 22:07:20 +03:00
skoupidi
c37618f354 drk: fixed token freezing and added its fee call 2024-05-16 14:14:14 +03:00
skoupidi
f52b4573e9 contract/money: switched auth_token_mint and token_mint execution order 2024-05-16 12:10:04 +03:00
skoupidi
e262b08a85 src/system/condvar: chore clippy 2024-05-15 21:07:44 +03:00
skoupidi
8280857a00 contract/money: renamed TokenFreeze to AuthTokenFreeze and removed redundant proof 2024-05-15 20:48:48 +03:00
skoupidi
aa1c5d80d2 contract/money: shuffled functions enum 2024-05-15 19:47:15 +03:00