Skip to content

Commit

Permalink
make the timeout for collecting 3 peaks configurable. Set it to 1 sec…
Browse files Browse the repository at this point in the history
…onds in the simulation tests to avoid waiting on CI
  • Loading branch information
arvidn committed Oct 12, 2023
1 parent 9b37875 commit 2d65623
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
3 changes: 2 additions & 1 deletion chia/full_node/full_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -931,8 +931,9 @@ async def _sync(self) -> None:
self.log.info("Waiting to receive peaks from peers.")

# Wait until we have 3 peaks or up to a max of 30 seconds
max_iterations = int(self.config.get("max_sync_wait", 30)) * 10
peaks = []
for i in range(300):
for i in range(max_iterations):
peaks = [peak.header_hash for peak in self.sync_store.get_peak_of_each_peer().values()]
if len(self.sync_store.get_peers_that_have_peak(peaks)) < 3:
if self._shut_down:
Expand Down
4 changes: 4 additions & 0 deletions chia/simulator/setup_nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ async def setup_simulators_and_wallets(
disable_capabilities: Optional[List[Capability]] = None,
) -> AsyncIterator[Tuple[List[FullNodeSimulator], List[Tuple[WalletNode, ChiaServer]], BlockTools]]:
with TempKeyring(populate=True) as keychain1, TempKeyring(populate=True) as keychain2:
if config_overrides is None:
config_overrides = {}
if "full_node.max_sync_wait" not in config_overrides:
config_overrides["full_node.max_sync_wait"] = 1
async with setup_simulators_and_wallets_inner(
db_version,
consensus_constants,
Expand Down
4 changes: 4 additions & 0 deletions chia/util/initial-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,10 @@ full_node:
# timeout for weight proof request
weight_proof_timeout: &weight_proof_timeout 360

# when the full node enters sync-mode, we wait until we have collected peaks
# from at least 3 peers, or until we've waitied this many seconds
max_sync_wait: 30

# when enabled, the full node will print a pstats profile to the root_dir/profile every second
# analyze with chia/utils/profiler.py
enable_profiler: False
Expand Down
3 changes: 0 additions & 3 deletions tests/core/full_node/test_full_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -2214,9 +2214,6 @@ async def test_long_reorg_nodes(

await full_node_2.full_node.add_block(reorg_blocks[-1])

# node 1 will wait 30 seonds before it starts syncing. It would be nice to
# be able to configure this delay to be shorter

def check_nodes_in_sync():
try:
p1 = full_node_2.full_node.blockchain.get_peak()
Expand Down

0 comments on commit 2d65623

Please sign in to comment.