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

feat: add hyperchain sync support #2035

Merged
merged 41 commits into from
Jan 15, 2025
Merged

feat: add hyperchain sync support #2035

merged 41 commits into from
Jan 15, 2025

Conversation

yaboiishere
Copy link
Contributor

@yaboiishere yaboiishere commented Dec 5, 2024

BEGIN_COMMIT_OVERRIDE
feat: add hyperchain sync support
END_COMMIT_OVERRIDE

The hyperchains implementation in the node reverses the way key and microblocks are ordered. This is only done for hyperchains.

The current way is that there is a keyblock followed by all of it's microblocks until a new keyblock is produced, where after it are it's microblocks. The breaking change here is that in hc the microblocks come first followed by the keyblock they belong to. This resulted in the mdw creating sync mutations for key blocks at height N with the microblocks inside them for the next keyblock N+1.

@yaboiishere yaboiishere self-assigned this Dec 5, 2024
@yaboiishere yaboiishere changed the base branch from after-rebase-hyperchain-support to master December 13, 2024 08:19
Copy link
Contributor

@sborrazas sborrazas left a comment

Choose a reason for hiding this comment

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

Minor comments, rest is looking good to me!

@@ -162,7 +162,7 @@ defmodule AeMdw.Stats do

Map.put(stats, :validators_count, validators_count)
else
Model.stat(payload: miners_count) =
{:ok, Model.stat(payload: miners_count)} =
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we use fetch! here instead?

@@ -345,6 +346,16 @@ defmodule AeMdw.Node do
|> MapSet.new()
end

@spec epoch_start_height(epoch()) :: {:ok, height()} | {:error, atom()}
defmemo epoch_start_height(epoch) do
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we want to memoize these? they will accumulate in memory as we call them


first
|> Stream.iterate(fn x -> x + 1 end)
|> Enum.zip(schedule)
Copy link
Contributor

Choose a reason for hiding this comment

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

Enum.with_index(schedule, first)

@vatanasov vatanasov requested a review from sborrazas December 19, 2024 09:10
@yaboiishere yaboiishere requested a review from sborrazas January 15, 2025 14:48
@yaboiishere yaboiishere merged commit 74e098d into master Jan 15, 2025
7 checks passed
@yaboiishere yaboiishere deleted the fix-hyperchain-sync branch January 15, 2025 18:49
@yaboiishere yaboiishere changed the title fix: hyperchain sync feat: add hyperchain sync support Jan 15, 2025
yaboiishere added a commit that referenced this pull request Jan 15, 2025
yaboiishere added a commit that referenced this pull request Jan 15, 2025
---------

Co-authored-by: Valentin Atanasov <[email protected]>
yaboiishere added a commit that referenced this pull request Jan 15, 2025
---------

Co-authored-by: Valentin Atanasov <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants