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

Limit network actions to tracked chains (in main) #2393

Merged
merged 13 commits into from
Aug 28, 2024

Conversation

jvff
Copy link
Contributor

@jvff jvff commented Aug 21, 2024

Motivation

This PR is a port of #2035 to the main branch.

Currently, processing a chain on the client creates network actions for all other chains it sends messages to. This leads to cross-chain requests that create chain states on storage for those other chains. These other chains might not be relevant to the client, which means it wastes storage and hinders performance.

As a real world example, the faucet chain is used to create new chains. Every block creates a new chain. That means that when a user uses the wallet to create a chain using the faucet, it will keep in storage the initial chain states for all chains created by the faucet before it.

Proposal

Add an optional tracked_chains field to ChainWorkerState, and only create NetworkActions for those tracked chains. The set of tracked chains is updated by the Client.

Test Plan

@afck, @Twey, could you please check to see if this fixes the issue you ran into?

Release Plan

This changes internal client behavior, so:

  • Need to bump the major/minor version number in the next release of the crates.

Links

@jvff jvff added this to the Testnet #1 milestone Aug 21, 2024
@jvff jvff requested review from Twey, ma2bd and afck August 21, 2024 00:40
@jvff jvff self-assigned this Aug 21, 2024
linera-core/src/client.rs Outdated Show resolved Hide resolved
self.client
.local_node
.retry_pending_cross_chain_requests(self.chain_id)
.await?;
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not even sure we always want that. E.g. the faucet probably shouldn't track all its children. Maybe it's better to default to not doing that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Summary of what we discussed offline: for most users it makes sense to track child chains they create. For the Faucet it's not great, but not tracking them would increase the size of its outboxes, which could be less scalable.

Copy link
Contributor

@ma2bd ma2bd Aug 28, 2024

Choose a reason for hiding this comment

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

Just to be sure: By "tracking" here, do you mean subscribing to notifications or just allowing a local chain state to exist?

(found the answer I think)

@jvff jvff force-pushed the limit-network-actions-to-tracked-chains-in-testnet-abel branch 2 times, most recently from 5d83e58 to f1f8c3e Compare August 21, 2024 19:20
@afck
Copy link
Contributor

afck commented Aug 22, 2024

export LINERA_FAUCET_URL="https://faucet.testnet-abel.linera.net/"
cargo test -p linera-service --features remote_net test_wasm_end_to_end_fungible::remote_net_grpc

passes for me on this branch. ✔️

@jvff jvff changed the base branch from testnet_abel to main August 26, 2024 17:49
@jvff jvff changed the title Limit network actions to tracked chains (in testnet_abel) Limit network actions to tracked chains (in main) Aug 26, 2024
@jvff jvff force-pushed the limit-network-actions-to-tracked-chains-in-testnet-abel branch from f1f8c3e to d1d8128 Compare August 26, 2024 18:24
@jvff jvff requested a review from afck August 26, 2024 23:03
linera-core/src/chain_worker/state/mod.rs Outdated Show resolved Hide resolved
@jvff jvff force-pushed the limit-network-actions-to-tracked-chains-in-testnet-abel branch from 640108c to 354f2bb Compare August 27, 2024 14:01
jvff added 12 commits August 27, 2024 14:08
Prepare to only create network actions for the set of tracked chains.
Share it with the created chain worker actors.
Keep track of the chains that client is interested in.
Specify which chains should be tracked by a new `Client`.
Configure the worker based on the client's selection.
Avoid handling chains that aren't interesting to the client.
Allow resending messages intended for chains that weren't tracked when
the outgoing message was scheduled, but became tracked later.
Allow adding more chains to the initial set of tracked chains.
Ensure that chains that the client open are tracked.
So that the worker can properly handle it.
Ensure that they are properly executed during the benchmark.
Remember to replace the quick-fix with a more comprehensive refactor.
@jvff jvff force-pushed the limit-network-actions-to-tracked-chains-in-testnet-abel branch from 354f2bb to dac2387 Compare August 27, 2024 14:37
Check all executed blocks for messages that open new chains, and add the
new chain IDs to the set of tracked chains.
@jvff jvff force-pushed the limit-network-actions-to-tracked-chains-in-testnet-abel branch from dac2387 to ecb1f71 Compare August 27, 2024 19:40
@jvff jvff requested a review from afck August 28, 2024 01:59
@@ -91,6 +91,9 @@ where
message_policy: MessagePolicy,
/// Whether to block on cross-chain message delivery.
cross_chain_message_delivery: CrossChainMessageDelivery,
/// Chains that should be tracked by the client.
// TODO(#2412): Merge with set of chains the client is receiving notifications from validators
Copy link
Contributor

@ma2bd ma2bd Aug 28, 2024

Choose a reason for hiding this comment

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

Ok that answers my question. We actually don't want that for the faucet, so perhaps we need two notions of "tracked" (replication allowed <> subscription)

@jvff jvff merged commit 3bc1928 into main Aug 28, 2024
4 checks passed
@jvff jvff deleted the limit-network-actions-to-tracked-chains-in-testnet-abel branch August 28, 2024 12:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants