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

optimisation: trim fork headers in BTC light client #2

Open
Tracked by #84
maurolacy opened this issue Jul 31, 2024 · 2 comments
Open
Tracked by #84

optimisation: trim fork headers in BTC light client #2

maurolacy opened this issue Jul 31, 2024 · 2 comments

Comments

@maurolacy
Copy link
Collaborator

@SebastianElvis cloned issue babylonchain/babylon-contract#14 on 2023-04-12:

          Given that we want this contract to be deployed on consumer zones we should try to be as optimized as possible.

Originally posted by @vitsalis in https://www.github.com/babylonchain/babylon-contract/pull/13#discussion_r1163712316

@maurolacy
Copy link
Collaborator Author

@KonradStaniec commented on 2023-04-12:

just one note here, the easiest way to trim forks is for our light client to store only main chain and remove headers when doing reorg, this way main schema does not need to change at all.

Algorithm becomes:

  1. receive newfork

  2. travel from current tip to common ancestor of newfork and current fork. While traveling to common ancestor register hashes and height of seen headers

  3. Check that newfork have better total difficulty than current fork

  4. if newfork is indeed better:

a. remove all seen headers and heights

b. store headers and heights of newfork

  1. if not, reject newfork.

@maurolacy
Copy link
Collaborator Author

@SebastianElvis commented on 2023-04-12:

That's a smart idea! This way we can trim forks while handling new headers in the IBC packet. Will implement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants