Skip to content

Conversation

@clangenb
Copy link
Contributor

@clangenb clangenb commented Oct 12, 2023

  • The problem behind the OOM error was that we had synced the whole parentchain before we imported the blocks into the light client. This PR changes the behaviour to trigger the import of the parentchain blocks after each chunk in the sync_parentchain_and_import_blocks function. The behaviour of sync_parentchain has not been changed. This is because it is either used by non-primary workers, which have only small syncs, as they receive a light-client-db from the primary worker at startup, or it is used in the teeracle/offchain worker modes, which directly import the parentchain blocks when they are synced. Closes sidechain oom & preserve db #1462.

  • Another minor fix is included that fixes startup error: spam the loop to get parentchain blocks until it has finalized the sync target. #1465

@clangenb clangenb added A0-core Affects a core part A3-sidechain B1-releasenotes C3-medium 📣 Elevates a release containing this PR to "medium priority" E0-breaksnothing labels Oct 12, 2023

println!(
"[{:?}] Syncing blocks from {} to {}",
"[{:?}] Syncing blocks from #{} to #{}",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It simply struck me that substrate uses a # before the block numbers, so I thought we can do the same for homogenous logs :)

Comment on lines +214 to +219
println!(
"[{:?}] sync target #{} is not finalized (#{}), wait a sec ...",
id, sync_target.number, curr_block_number
);
std::thread::sleep(std::time::Duration::from_secs(1));
continue
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This resolves spamming network connections until the parentchain is ready: #1465

Comment on lines -390 to -391
#[cfg(feature = "teeracle")]
let teeracle_tokio_handle = tokio_handle.clone();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

No longer needed as another function needs a borrow now instead of an owned handle.

Comment on lines -546 to -548
// initialize teeracle interval
#[cfg(feature = "teeracle")]
if WorkerModeProvider::worker_mode() == WorkerMode::Teeracle {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The flow of the following section was a bit hard to understand because there were non-exclusive if statements (which is why I didn't notice that it doesn't work yet). Now we have three exclusive paths in the match statement, which make it easier to understand. The code redundancy is reduced to some function calls by extracting some code into functions.

WorkerMode::Teeracle => {
// ------------------------------------------------------------------------
// initialize teeracle interval
#[cfg(feature = "teeracle")]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The TEEracle code is not a lot, I am actually considering removing the feature gate in most places because it won't really affect the binary size, but I haven't thought much about it, this could be a preparation for #1418 or #1195.

@clangenb
Copy link
Contributor Author

Superseded by #1493, which is based on the new master.

@clangenb clangenb closed this Nov 15, 2023
@clangenb clangenb deleted the cl/fix-sidechain-light-client branch December 18, 2023 15:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A0-core Affects a core part A3-sidechain B1-releasenotes C3-medium 📣 Elevates a release containing this PR to "medium priority" E0-breaksnothing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

startup error: spam the loop to get parentchain blocks until it has finalized the sync target. sidechain oom & preserve db

2 participants