From 994fd9bb55fb0d606aacebf256210ccb7ca101dc Mon Sep 17 00:00:00 2001 From: Shreyan Gupta Date: Tue, 24 Oct 2023 14:10:44 -0400 Subject: [PATCH] Update trie.md (#9159) Just some better documentation --- docs/architecture/how/gc.md | 2 ++ docs/architecture/storage/trie.md | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/architecture/how/gc.md b/docs/architecture/how/gc.md index 43937d33b97..4df22525964 100644 --- a/docs/architecture/how/gc.md +++ b/docs/architecture/how/gc.md @@ -10,6 +10,8 @@ We run a single ‘round’ of GC after a new block is accepted to the chain - a in order not to delay the chain too much, we make sure that each round removes at most 2 blocks from the chain. +For more details look at function `clear_data()` in file `chain/chain/src/chain.rs` + ## How it works: Imagine the following chain (with 2 forks) diff --git a/docs/architecture/storage/trie.md b/docs/architecture/storage/trie.md index 0b5c13e7636..7f5b49ddf64 100644 --- a/docs/architecture/storage/trie.md +++ b/docs/architecture/storage/trie.md @@ -71,7 +71,9 @@ trie nodes using the `get_key_from_shard_id_and_hash` method. ### ShardTries -Contains stores and caches and allows to get `Trie` object for any shard. +This is the main struct that is used to access all Tries. There's usually only a single instance of this and it contains stores and caches. We use this to gain access to the `Trie` for a single shard by calling the `get_trie_for_shard` or equivalent methods. + +Each shard within `ShardTries` has their own `cache` and `view_cache`. The `cache` stores the most frequently accessed nodes and is usually used during block production. The `view_cache` is used to serve user request to get data, which usually come in via network. It is a good idea to have an independent cache for this as we can have patterns in accessing user data independent of block production. ## Primitives