Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Store peers in the database #2439

Merged
merged 6 commits into from
Jun 30, 2022
Merged

Store peers in the database #2439

merged 6 commits into from
Jun 30, 2022

Conversation

tomaka
Copy link
Contributor

@tomaka tomaka commented Jun 27, 2022

Close #1768

We currently store the finalized state of the chain in the database as a JSON text.
This PR modifies the format and wraps this finalized state of the chain within another object.
The format of the database now looks like {chain:{...}, nodes:{...}}.

The nodes entry stores the list of nodes that we know are part of the network.

The next time a chain is added with a database, we immediately insert the nodes in the k-buckets.

Because the database format is intentionally not stable, we simply ignore faulty values. This PR breaks the format of the database, but database coming from previous versions will simply be ignored.

Copy link
Contributor

@mergify mergify bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automatically approving tomaka's pull requests. This auto-approval will be removed once more maintainers are active.

@github-actions
Copy link
Contributor

github-actions bot commented Jun 27, 2022

twiggy diff report

Difference in .wasm size before and after this pull request.


 Delta Bytes │ Item
─────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
      +11628 ┊ <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::h3c9e3fe5bec34ba8
      -11628 ┊ <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::h7cc3404db1d81e03
      +11343 ┊ smoldot_light_base::Client<TChain,TPlat>::add_chain::ha5ea49f04b1655bb
      -11192 ┊ smoldot_light_base::Client<TChain,TPlat>::add_chain::h43673acc6b0cbb22
      -11191 ┊ <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::h10d6380aaa593bd8
      +11191 ┊ <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::habc8728986e5e22a
      -10668 ┊ <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::h49e8b51d1d5b62df
      +10668 ┊ <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::hfa07384e11a5330b
      -10628 ┊ smoldot::network::service::ChainNetwork<TNow>::next_event::h52cad4c75926f346
      +10628 ┊ smoldot::network::service::ChainNetwork<TNow>::next_event::h64cea0bc1c48044d
       -9676 ┊ smoldot::libp2p::connection::established::substream::Substream<TNow,TRqUd,TNotifUd>::read_write2::h11b95086c6500fce
       +9676 ┊ smoldot::libp2p::connection::established::substream::Substream<TNow,TRqUd,TNotifUd>::read_write2::h9c658de2666beb0f
       +7880 ┊ <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::h6c8e84cd8dcc087f
       -7880 ┊ <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::h714270646b04ed3d
       -7690 ┊ <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::h30e97cdaf7f01d26
       +7690 ┊ <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::h910fa52bbf338bf6
       +6555 ┊ <&mut serde_json::de::Deserializer<R> as serde::de::Deserializer>::deserialize_map::hd95690d034677067
       -6543 ┊ <&mut serde_json::de::Deserializer<R> as serde::de::Deserializer>::deserialize_map::h068b8d0b2867f794
       +6216 ┊ <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::hc8176cf4d4cd6be1
       -6216 ┊ <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::hcfc0ce8c464f3797
      +20320 ┊ ... and 19090 more.
      +35022 ┊ Σ [19110 Total Rows]

bin/light-base/Cargo.toml Show resolved Hide resolved
serde_json::from_str(&encoded).unwrap()
}
None => {
// If the database can't be obtained, we just return a dummy value that will
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are you saying services.sync_service.serialize_chain_information() above obtains the database? maybe you thought to say "If the chain information can't be obtained"?

@tomaka tomaka added the automerge Automatically merge pull request as soon as possible label Jun 30, 2022
@mergify mergify bot merged commit 3a257ca into paritytech:main Jun 30, 2022
@tomaka tomaka deleted the database-peers branch June 30, 2022 08:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge Automatically merge pull request as soon as possible
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add known peers to wasm-node database
2 participants