-
Notifications
You must be signed in to change notification settings - Fork 622
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
feat: orphan chunk state witness pool #10613
Commits on Feb 21, 2024
-
Remove witness retrying logic on missing block
Sometimes when a ChunkStateWitness arrives to be processed, the block required to process it isn't available yet, we have to wait for it. near#10535 implemented a hacky way to do it by retrying the processing every 500ms until the required block arrives. This PR will implement a proper solution, so let's remove the hacky workaround.
Configuration menu - View commit details
-
Copy full SHA for 8dd0c4e - Browse repository at this point
Copy the full SHA 8dd0c4eView commit details -
Add verify_chunk_state_witness_signature_in_epoch
The current function to verify state witness signatures takes the epoch_id from the previous block. For orphaned state witnesses the previous block isn't available, so it's impossible to use this function. Let's add another function that takes the epoch_id as an argument instead of fetching it from a block. It will allow us to verify signatures of orphaned chunk state witnesses.
Configuration menu - View commit details
-
Copy full SHA for 456a821 - Browse repository at this point
Copy the full SHA 456a821View commit details -
Add a struct which keeps a cache of orphaned ChunkStateWitnesses. It provides two methods that allow to easily add a ChunkStateWitness to the pool, and then when a block arrrives, another method allows to easily fetch all orphaned ChunkStateWitnesses that were waiting for this block.
Configuration menu - View commit details
-
Copy full SHA for 16828b3 - Browse repository at this point
Copy the full SHA 16828b3View commit details -
Split process_chunk_state_witness into two parts
Let's split this function into two parts - one part which tries to find the previous block for the given ChunkStateWitness and another which processes the witness when the previous block is available. It will make handling orphaned witnesses easier - once the block arrives, we can just call the second function to process it. In the future it might also make it easier to process witnesses before the previous block is saved to the database, which could reduce latency.
Configuration menu - View commit details
-
Copy full SHA for d3dc400 - Browse repository at this point
Copy the full SHA d3dc400View commit details -
Add possible_epochs_of_height_around_tip
Add a function which tries to determine in which epoch the specified height is located. It looks at the previous, current and next epoch around the chain Tip and tries to figure out to which one of them this height belongs. It's not always possible to determine in which epoch a given height will be, as the start height of the next epoch isn't known in the current epoch, so the function returns a set of possible epochs where the height might be. For example if the tip is in the middle of the current epoch, and the height is about epoch_length blocks higher than the tip, this function would return [current_epoch_id, next_epoch_id], as this height could be in either one of those epochs. It will later be used to verify the signature of orphaned witnesses. To verify the signature we need to know what is the chunk producer who should produce a witness at some height, and for that we need to know what's the epoch_id at this height.
Configuration menu - View commit details
-
Copy full SHA for 5da1fea - Browse repository at this point
Copy the full SHA 5da1feaView commit details -
Add orphan state witnesses to the orphan pool
When the previous block isn't available, we can't process the ChunkStateWitness and it becomes an orphaned state witness, waiting for the required block to arrive. In such situations the witness is partialy validated and then put in the `OrphanStateWitnessPool`. It's impossible to fully validate the witness, as the previous block isn't available, but we can do some basic checks to curb abusive behavior - check the shard_id, signature, size, etc.
Configuration menu - View commit details
-
Copy full SHA for 9cb7df9 - Browse repository at this point
Copy the full SHA 9cb7df9View commit details -
Process orphaned witnesses when a new block is accepted
When a new block is accepted we can process all orphaned state witnesses that were waiting for this block. Witnesses which became ready are taken out of the pool and processed one by one.
Configuration menu - View commit details
-
Copy full SHA for 5a76c7c - Browse repository at this point
Copy the full SHA 5a76c7cView commit details -
Allow to configure orphan pool size from config.js
There is no ideal size of the witness pool, node operators might want to adjust it to achieve optimal performance. Let's make this possible by adding a configuration option which allows to control the pool size.
Configuration menu - View commit details
-
Copy full SHA for 97a0482 - Browse repository at this point
Copy the full SHA 97a0482View commit details -
Add metrics to improve observability of OrphanStateWitnessPool
Add metrics which provide information about witnesses kept in the pool. Metrics are increased and decreased using a RAII struct to ensure that they're always correct, no matter what happens with the pool.
Configuration menu - View commit details
-
Copy full SHA for f9b9c52 - Browse repository at this point
Copy the full SHA f9b9c52View commit details -
Configuration menu - View commit details
-
Copy full SHA for 42af070 - Browse repository at this point
Copy the full SHA 42af070View commit details -
Add TestEnv::get_client_index()
There was no way to get the index of a client with some AccountId, let's add a method that enables it to `TestEnv`
Configuration menu - View commit details
-
Copy full SHA for 6592ace - Browse repository at this point
Copy the full SHA 6592aceView commit details -
Add TestEnv::wait_for_chunk_endorsement
Add a function that allows to wait until some chunk endorsement is sent out. It will later be used to verify that a validator sends out endorsements for an orphaned chunk state witness when its block arrives.
Configuration menu - View commit details
-
Copy full SHA for a29b8df - Browse repository at this point
Copy the full SHA a29b8dfView commit details -
Expose some items that are needed for the integration tests
`stateless_validation` is a private module of `near_client`, so it's impossible to use items defined there in integration tests. Let's expose some of them to make their use in tests possible.
Configuration menu - View commit details
-
Copy full SHA for 22a2b15 - Browse repository at this point
Copy the full SHA 22a2b15View commit details -
Move get_block_producer to TestEnv
`run_chunk_validation_test` has a very useful function which allows to determine a block producer at some offset. I would like to also use it in my integration tests. Let's add it to `TestEnv` so that other tests can also use it.
Configuration menu - View commit details
-
Copy full SHA for 9974f09 - Browse repository at this point
Copy the full SHA 9974f09View commit details -
Add TestEnv::get_chunk_producer_at_offset
Add a function analogous to `get_block_producer_at_offset`, but for chunk producers.
Configuration menu - View commit details
-
Copy full SHA for dc19727 - Browse repository at this point
Copy the full SHA dc19727View commit details -
Configuration menu - View commit details
-
Copy full SHA for 0183075 - Browse repository at this point
Copy the full SHA 0183075View commit details
Commits on Feb 22, 2024
-
Configuration menu - View commit details
-
Copy full SHA for aedb405 - Browse repository at this point
Copy the full SHA aedb405View commit details -
Configuration menu - View commit details
-
Copy full SHA for 198a428 - Browse repository at this point
Copy the full SHA 198a428View commit details -
Configuration menu - View commit details
-
Copy full SHA for 49bea32 - Browse repository at this point
Copy the full SHA 49bea32View commit details -
Configuration menu - View commit details
-
Copy full SHA for 36b7391 - Browse repository at this point
Copy the full SHA 36b7391View commit details -
Configuration menu - View commit details
-
Copy full SHA for f4cd1e7 - Browse repository at this point
Copy the full SHA f4cd1e7View commit details -
Configuration menu - View commit details
-
Copy full SHA for 3b3f8c4 - Browse repository at this point
Copy the full SHA 3b3f8c4View commit details -
Configuration menu - View commit details
-
Copy full SHA for db14aa8 - Browse repository at this point
Copy the full SHA db14aa8View commit details -
Configuration menu - View commit details
-
Copy full SHA for 3c045e2 - Browse repository at this point
Copy the full SHA 3c045e2View commit details -
Use ChunkStateWitness::new_dummy in another test
There is another test that created a ChunkStateWitness manually. Let's use the newly introduced `ChunkStateWitness::new_dummy` in this test, it simplifies things.
Configuration menu - View commit details
-
Copy full SHA for 3bcd5c5 - Browse repository at this point
Copy the full SHA 3bcd5c5View commit details -
Configuration menu - View commit details
-
Copy full SHA for 0b126b8 - Browse repository at this point
Copy the full SHA 0b126b8View commit details -
Configuration menu - View commit details
-
Copy full SHA for a6858eb - Browse repository at this point
Copy the full SHA a6858ebView commit details -
Configuration menu - View commit details
-
Copy full SHA for 0edf57a - Browse repository at this point
Copy the full SHA 0edf57aView commit details
Commits on Feb 23, 2024
-
fix log message when a witness is ejected
In previous commit I added debug spans to avoid writing witness_height, ... everywhere. I also removed them from the ejection message, but that was a mistake. The span contains information about the witness that is being added, not the one that is being ejected. Because of that the message about ejecting a witness would contain invalid witness_height and other parameters. Fix by using the correct parameters, and names which don't collide with the ones in the span.
Configuration menu - View commit details
-
Copy full SHA for f61f34c - Browse repository at this point
Copy the full SHA f61f34cView commit details -
Configuration menu - View commit details
-
Copy full SHA for bb41b37 - Browse repository at this point
Copy the full SHA bb41b37View commit details -
Configuration menu - View commit details
-
Copy full SHA for 33248ac - Browse repository at this point
Copy the full SHA 33248acView commit details -
Configuration menu - View commit details
-
Copy full SHA for 4e6711d - Browse repository at this point
Copy the full SHA 4e6711dView commit details -
I imported near-o11y to use the function for initializing a tracing-subscriber in epoch manager tests, but I didn't import the corresponding nightly packages, so a CI check failed. Let's fix this by importing the packages that the CI check prosposed.
Configuration menu - View commit details
-
Copy full SHA for 24b25f5 - Browse repository at this point
Copy the full SHA 24b25f5View commit details -
Fix formatting of epoch-manager/Cargo.toml
Ran python3 scripts/fix_nightly_feature_flags.py fix to satisfy the CI
Configuration menu - View commit details
-
Copy full SHA for 58be57b - Browse repository at this point
Copy the full SHA 58be57bView commit details -
Configuration menu - View commit details
-
Copy full SHA for 056393d - Browse repository at this point
Copy the full SHA 056393dView commit details -
fix: Don't remove the handler for ChunkEndorsementMessage
While resolving a merge conflict caused by near#10646, I accidentally removed a handler for chunk endorsement messages. I didn't mean to do it, I wanted to only modify handlers for chunk state witnesses. Let's undo the change and bring the chunk endorsement handler back.
Configuration menu - View commit details
-
Copy full SHA for 5cae3c3 - Browse repository at this point
Copy the full SHA 5cae3c3View commit details -
Revert "fix: Don't remove the handler for ChunkEndorsementMessage"
This reverts commit 5cae3c3. It was actually necessary to remove the endorsement message handler, it doesn't compile otherwise 🤦
Configuration menu - View commit details
-
Copy full SHA for 6e9b143 - Browse repository at this point
Copy the full SHA 6e9b143View commit details