Commit Graph

134 Commits

Author SHA1 Message Date
Hector Sanjuan
a97ed10d0b Adopt api.Cid type - replaces cid.Cid everwhere.
This commit introduces an api.Cid type and replaces the usage of cid.Cid
everywhere.

The main motivation here is to override MarshalJSON so that Cids are
JSON-ified as '"Qm...."' instead of '{ "/": "Qm....." }', as this "ipld"
representation of IDs is horrible to work with, and our APIs are not issuing
IPLD objects to start with.

Unfortunately, there is no way to do this cleanly, and the best way is to just
switch everything to our own type.
2022-04-07 14:27:39 +02:00
Hector Sanjuan
0d73d33ef5 Pintracker: streaming methods
This commit continues the work of taking advantage of the streaming
capabilities in go-libp2p-gorpc by improving the ipfsconnector and pintracker
components.

StatusAll and RecoverAll methods are now streaming methods, with the REST API
output changing accordingly to produce a stream of GlobalPinInfos rather than
a json array.

pin/ls request to the ipfs daemon now use ?stream=true and avoid having to
load the full pinset map on memory. StatusAllLocal and RecoverAllLocal
requests to the pin tracker stream all the way and no longer store the full
pinset, and the full PinInfo status slice before sending it out.

We have additionally switched to a pattern where streaming methods receive the
channel as an argument, allowing the caller to decide on whether to launch a
goroutine, do buffering etc.
2022-03-22 15:38:01 +01:00
Hector Sanjuan
9b9d76f92d Pinset streaming and method type revamp
This commit introduces the new go-libp2p-gorpc streaming capabilities for
Cluster. The main aim is to work towards heavily reducing memory usage when
working with very large pinsets.

As a side-effect, it takes the chance to revampt all types for all public
methods so that pointers to static what should be static objects are not used
anymore. This should heavily reduce heap allocations and GC activity.

The main change is that state.List now returns a channel from which to read
the pins, rather than pins being all loaded into a huge slice.

Things reading pins have been all updated to iterate on the channel rather
than on the slice. The full pinset is no longer fully loaded onto memory for
things that run regularly like StateSync().

Additionally, the /allocations endpoint of the rest API no longer returns an
array of pins, but rather streams json-encoded pin objects directly. This
change has extended to the restapi client (which puts pins into a channel as
they arrive) and to ipfs-cluster-ctl.

There are still pending improvements like StatusAll() calls which should also
stream responses, and specially BlockPut calls which should stream blocks
directly into IPFS on a single call.

These are coming up in future commits.
2022-03-19 03:02:55 +01:00
Hector Sanjuan
b8327e25e3 crdt: log when batches are committed 2022-03-10 00:15:12 +01:00
Hector Sanjuan
975814229c crdt: increase number of workers from 5 to 50. Upgrade.
The go-ds-crdt upgrade disables multi-head-processing by default again. We see
this causes a lot of branching.

We however increase the number of workers. With large deltas, it may be
possible that all the 5 workers are busy downloading a delta or processing
them, while we potentially have hundreds of children in the DAG. Thus it is
not bad to attempt to do more things in parallel.
2022-02-15 16:54:42 +01:00
Hector Sanjuan
a64a1c2b6e crdt: add RepairInterval option 2022-02-01 23:29:40 +01:00
Hector Sanjuan
4739ed9210 Changes pertaining to go-libp2p v0.16.0 2021-11-30 06:25:15 +01:00
Alan Shaw
275d01efb6
fix: error message for LogPin 2021-05-12 14:26:51 +01:00
Hector Sanjuan
8b33264a29 crdt: add test for batching items 2021-04-30 19:45:01 +02:00
Hector Sanjuan
d7e46f9e36 crdt: Increase default MaxQueueSize to 50000 2021-04-30 19:38:48 +02:00
Hector Sanjuan
b5cc68a321 Feat #1008: Support pin-batching with CRDT consensus.
This adds batching support to crdt-consensus per #1008 . The crdt component can now take
advantage of the BatchingState, which uses the batching-crdt datastore. In
batching mode, the crdt datastore groups any Add and Delete operations
in a single delta (instead of just 1, as it does by default).

Batching is enabled in the crdt configuration section by setting MaxBatchSize
**and** MaxBatchAge. These two settings control when a batch is committed,
either by reaching a maximum number of pin/unpin operations, or by reaching a
maximum age.

Batching unlocks large pin-ingestion scalability for clusters, but should be
set according to expected work loads. An additional, hidden MaxQueueSize
parameter provides the ability to perform backpressure on Pin/Unpin
requests. When more than MaxQueueSize pin/unpins are waiting to be included in
a batch, the LogPin/LogUnpin operations will fail. If this happens, it is
means cluster cannot commit batches as fast as pins are arriving. Thus,
MaxQueueSize should be increase (to accommodate bursts), or the batch size
increased (to perform less commits and hopefully handle the requests faster).

Note that the underlying CRDT library will auto-commit when batch deltas reach
1MB of size.
2021-04-29 01:18:37 +02:00
Hector Sanjuan
75cf1b32c7 Feat #1008: Add batching configuration options and parsing 2021-04-29 01:08:46 +02:00
Hector Sanjuan
82412ca91c crdt: fix pubsub validation for crdt messages
Currently, it was not looking at the signer of the message, but at the
peer that relayed it, to verify the validity of the message.

This caused that under certain gossip graph configurations, some nodes would only
get messages via untrusted peers, and thus be unable to sync the chain.
2021-01-13 22:13:03 +01:00
Hector Sanjuan
7e0d39cdf7 config: Fix some slices being appended the same values twice
trusted_peers and peer_addresses were appended the same info twice when
reparsing the config.

Once when parsing json and once when re-parsing with env-vars.
2021-01-13 22:13:03 +01:00
Hector Sanjuan
4125f12f52 chore: update dependencies 2020-09-02 12:18:16 +02:00
Kishan Mohanbhai Sagathiya
ae8e74453b Fix #937: Print full working configuration at startup
Only when using debug mode

Co-authored-by: Hector Sanjuan <code@hector.link>
2020-05-15 01:33:04 +02:00
Hector Sanjuan
b513ec194d Fix some mispellings 2020-04-14 23:47:09 +02:00
Hector Sanjuan
7ffd18e41b Feat: upgrade to dual DHT 2020-04-14 22:03:24 +02:00
Hector Sanjuan
f83ff9b655 staticcheck: fix all staticcheck warnings in the project 2020-04-14 20:16:10 +02:00
Hector Sanjuan
b14a3cdb4b crdt: tests: set dht mode to server in tests 2020-04-07 17:49:42 +02:00
Hector Sanjuan
eba3246b98 chore: update deps: dht to cypress
Add necessary validators.

There is currently no way to run a dynamic-mode DHT that supports
LAN-based peers. Therefore for the time-being we are setting the
dht.Mode to "server".
2020-04-07 16:22:46 +02:00
Hector Sanjuan
b3853caf36 Dependency ugprade: changes needed
* Libp2p protectors no longer needed, use PSK directly
* Generate cluster 32-byte secret here (helper gone from pnet)
* Switch to go-log/v2 in all places
* DHT bootstrapping not needed. Adjust DHT options for tests.
* Do not rely on dissappeared CidToDsKey and DsKeyToCid functions fro dshelp.
* Disable QUIC (does not support private networks)
* Fix tests: autodiscovery started working properly
2020-03-22 14:50:25 +01:00
Hector Sanjuan
5cd4abe58b consensus: fix panic when getting state 2019-12-16 15:43:38 +01:00
Hector Sanjuan
35c1a4895e crdt consensus: do not panic when getting the state while not ready.
Wait instead.
2019-12-16 14:22:09 +01:00
Hector Sanjuan
0671159bee Crdt: fix OfflineState comment 2019-12-16 13:42:35 +01:00
Kishan Sagathiya
5258a4d428 Remove map pintracker (#944)
This removes mappintracker and sets stateless tracker as the default (and only) pintracker component.

Because the stateless tracker matches the cluster state with only ongoing operations being kept on memory, and additional information provided by ipfs-pin-ls, syncing operations are not necessary. Therefore the Sync/SyncAll operations are removed cluster-wide.
2019-12-12 21:22:54 +01:00
Hector Sanjuan
b306bda877 Raft logging: update logger to new interface 2019-11-05 12:51:18 +01:00
Kishan Sagathiya
295915272b Tests: multiple fixes to tests reliability (#943)
This makes a number of fixes to improve the reliability of tests.
2019-10-31 21:51:13 +01:00
Hector Sanjuan
1a0998f10d CRDT: update and increase timeout
* Update go-ds-crdt to 0.1.5 which adds a return statement in case of error fetching a node.
* Increase DAG-Get timeout to 2 minutes
* Downgrade go-bitswap to 0.1.6.
2019-09-12 19:22:52 +02:00
Hector Sanjuan
81ea1e76bc Merge branch 'master' into feat/sort-responses 2019-09-06 15:13:54 +02:00
Hector Sanjuan
d63a7fd641
Merge pull request #877 from ipfs/fix/ipfs-to-p2p
Use `p2p` protocol name over `ipfs` for multiaddr
2019-09-06 15:00:36 +02:00
Hector Sanjuan
8ca0f5781c Fix: trust-all remained enabled always 2019-08-27 19:18:50 +02:00
Kishan Mohanbhai Sagathiya
c109a01343 Sort peers for crdt consensus.Peers 2019-08-26 18:27:17 +05:30
Hector Sanjuan
df7621ba6e crdt: inform about trust all mode 2019-08-26 12:22:44 +02:00
Kishan Mohanbhai Sagathiya
6656b80a00 Some more occurences of /ipfs
and use  SwapToP2pMultiaddrs (very helpful since ipfs still send
addresses with `/ipfs` tag)
2019-08-16 11:56:09 +05:30
Hector Sanjuan
28ae394fa9 Fix #883: Tweak timeouts for better tests 2019-08-13 19:44:48 +02:00
Hector Sanjuan
676ad1b61e CRDT: TrustAll by default. 2019-08-12 10:25:04 +02:00
Kishan Sagathiya
0a5598a922 Fix #211: Remove commented code around LeaderObservation (#858)
* Remove 32bit safegaurd and remove LeaderObersvation
2019-07-29 19:11:24 +02:00
Kishan Sagathiya
7f52242f35 Fix #840: Removed Raft peers should dissapear from peerstore (#846)
With this commit, cluster peer will observe on events of peer removal
from cluster. On occurence of the event, the cluster peer will clear
the removed peer from its peerstore.
2019-07-25 14:40:05 +02:00
Kishan Sagathiya
e7b731e0e4 Fix #835: service: init --peers
* Init should take a list of peers

This commit adds `--peers` option to `ipfs-cluster-service init`

`ipfs-cluster-service init --peers <multiaddress,multiaddress>`

- Adds and writes the given peers to the peerstore file
- For raft config section, adds the peer IDs to the `init_peerset`
- For crdt config section, add the peer IDs to the `trusted_peers`
2019-07-25 10:47:44 +02:00
Hector Sanjuan
b804e61ef0 Update deps along with go-libp2p-core refactor
Lots of rewrites in imports...
2019-06-14 13:10:45 +02:00
Hector Sanjuan
83c4866100 Remove Leftover println 2019-06-13 17:27:31 +02:00
Hector Sanjuan
27368ab077 Fix: alert at most once PER METRIC
Before it would alert at most once per peer, which prevented some metrics
from alerting at all.
2019-06-11 11:44:12 +02:00
Hector Sanjuan
f1707e40f2
Merge pull request #811 from ipfs/rpi-fixes
Multiple fixes to CRDTs
2019-06-10 14:53:34 +01:00
Hector Sanjuan
b349aacc83 crdt: Allow to configure CRDT in "TrustAll" mode
Specifying "*" as part of "trusted_peers" in the configuration will
result in trusting all peers.

This is useful for private clusters where we don't want to list every
peer ID in the config.
2019-06-10 13:35:25 +02:00
Hector Sanjuan
f0b7d2a839 crdt: fix: Create the ipfslite peer before peermanager bootstrapping
Bitswap needs to exist before connections are opened!

Fixes #798
2019-06-09 15:12:19 +02:00
Hector Sanjuan
451b91d8d1 crdt: fix wrapping the ipfslite dag syncer
No need to wrap it anymore since we don't time out in it.

Also, it was preventing the use of bitswap sessions because it does
not implement them.
2019-06-07 23:33:52 +02:00
Hector Sanjuan
16a2a3611f Reorder imports 2019-06-05 19:31:51 +02:00
Adrian Lanzafame
21c2b6fbdd
add tracing to all crdt methods
License: MIT
Signed-off-by: Adrian Lanzafame <adrianlanzafame92@gmail.com>
2019-05-31 12:58:26 +10:00
Adrian Lanzafame
4cc5182502
add tracing to crdt hooks
License: MIT
Signed-off-by: Adrian Lanzafame <adrianlanzafame92@gmail.com>
2019-05-31 12:56:33 +10:00