-
-
Notifications
You must be signed in to change notification settings - Fork 317
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
Return blocks on same chain in BeaconBlocksByRange #1005
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should probably also change in this PR chain.getBlockAtSlot to return Array of blocks and propagate it into database. Currently if we get and process block thats on fork it will override last block linked to that slot.
4daa3dd
to
6f560c2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there was misuunderstanding.
We should change how we store slot -> root mapping. Currently is 1:1 and it should be 1:n aka 1 slot can have many block roots attached. That also means that db.blocks.getBlockAtSlot
should be db.blocks.getBlocksAtSlot
. slot -> root mapping is 1:1 only in finalized blocks (block archive)
@mpetrunic I see what you mean now. Can you have a look at https://github.com/ethereum/eth2.0-specs/pull/1818/files My understanding was we have 1-1 mapping for slot-block after that PR. |
I think this just prevents multiple blocks per slot in single head chain. In unfinalized chain we can have parallel chains (forks) where different block proposers are proposing different blocks for same slot we need to store multiple blocks per slot until we finalize this (decide on one fork to be correct). |
Thanks, clear to me now. With the latest implementation, I don't touch Just one clarification, we don't have |
5e76343
to
1ed8b25
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, although solving multiple fork blocks for same slot was probably more important than avoiding it 😞
merge conflict, looks ready to merge otherwise |
1ed8b25
to
5939740
Compare
if (!slots) { | ||
return []; | ||
} | ||
return await Promise.all(slots.map(this.getBlockAtSlot)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could rename getBlockAtSlot
to getCannonicalBlockAtSlot
and keet this method getBlocksAtSlot
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could rename getBlockAtSlot to
getCannonicalBlockAtSlot
this is good to me
and keet this method getBlocksAtSlot
as this method only gets unfinalized blocks, should we keep it getUnfinalizedBlocksAtSlots
to avoid any confusion? Or any better name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as this method only gets unfinalized blocks, should we keep it getUnfinalizedBlocksAtSlots to avoid any confusion? Or any better name?
oh scratch that, thought this method is on forkchoice.
Goals