Skip to content
This repository was archived by the owner on Jan 11, 2024. It is now read-only.

Look ahead limit use finalized height#433

Merged
adlrocha merged 5 commits intotracing-logsfrom
fix_look_ahead_limit
Nov 15, 2023
Merged

Look ahead limit use finalized height#433
adlrocha merged 5 commits intotracing-logsfrom
fix_look_ahead_limit

Conversation

@cryptoAtwill
Copy link
Copy Markdown
Contributor

Fix look ahead null block error.

This is a tricky edge case, say the current height is 100 and chain head is 1000 and our block fetching limit is 100. So we will be fetching from height 100 to 200 in this batch. Now, when in the loop we queried till block 199 and we need to fetch the top down messages. Because we need the block hash at block 200, so we query block 200 first to get the block hash. But sadly block 200 is a null block which throws an error. We should fetch block 201. As a safety precaution, if 201 is a null block ,we need to fetch 202 and so on. Theoretically, we can go all the way to block head. But block head is not considered finalised, so we put a look_ahead_limit.

According to the old logic, the look_ahead_limit is just the end block height of the current batch, which is 200 in the above example. So if block 200 is a null block, an error will be thrown as we reached look ahead limit. That's why the fetching parent is stuck. We change the look_ahead_limit to finalised_height, i.e. the height x blocks away from the chain head that we considered final. If 200 is the finalised height, it will throw an error, but as chain head progresses, the finalised_height will move beyond 200 and we should not get stuck.


let ending_height = parent_chain_head_height - config.chain_head_delay;
// we consider the chain head finalized only after the `chain_head_delay`
let finalized_chain_head = parent_chain_head_height - config.chain_head_delay;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
let finalized_chain_head = parent_chain_head_height - config.chain_head_delay;
let proposal_chain_head = parent_chain_head_height - config.chain_head_delay;

mut previous_hash: BlockHash,
start_height: BlockHeight,
end_height: BlockHeight,
look_ahead_limit: BlockHeight,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you add a comment of how look_ahead_limit modifies the behavior of this function?

@adlrocha adlrocha merged commit f79f7f3 into tracing-logs Nov 15, 2023
@adlrocha adlrocha deleted the fix_look_ahead_limit branch November 15, 2023 12:49
/// Sadly, the height h + 1 could be null block, we need to continuously look ahead until we found
/// a height that is not null. But we cannot go all the way to the block head as it's not considered
/// final yet. So we need to use a `look_ahead_limit` that restricts how far as head we should go.
/// If we still cannot find a height that is non-null, maybe we should try later
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

To confirm: if we go ahead to the limit and still can't find a non-null block, are we ever going to get out of it by trying later?

cryptoAtwill added a commit that referenced this pull request Nov 15, 2023
* skip null round retry

* rearrange logging

* specify import

* better null error handling

* format code

* add tracing logs

* expand tilda

* prettier logging

* prettier logs

* update logging

* prettier log

* use ipc user instead of root

* specify log path

* remove unused logs

* Update fendermint/vm/topdown/src/finality/null.rs

Co-authored-by: Akosh Farkash <aakoshh@gmail.com>

* Update fendermint/vm/interpreter/src/chain.rs

Co-authored-by: Akosh Farkash <aakoshh@gmail.com>

* Update fendermint/vm/topdown/src/sync.rs

Co-authored-by: Akosh Farkash <aakoshh@gmail.com>

* structured logging and log dir optional

* add debug logger

* add debug logs

* log fendermint only

* Look ahead limit use finalized height (#433)

* look ahead limit use finalized height

* rename variable

* more comments

* more logs

* comments

* Update fendermint/vm/topdown/src/sync.rs

Co-authored-by: Akosh Farkash <aakoshh@gmail.com>

* rename makes everything clearer

* Update fendermint/app/src/main.rs

Co-authored-by: Akosh Farkash <aakoshh@gmail.com>

* clean logs

* log to console

* update docker commands

---------

Co-authored-by: Akosh Farkash <aakoshh@gmail.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants