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

accelerate getShufflingRef #4911

Merged
merged 12 commits into from
May 12, 2023
7 changes: 6 additions & 1 deletion AllTests-mainnet.md
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,11 @@ OK: 1/1 Fail: 0/1 Skip: 0/1
+ RestErrorMessage writer tests OK
```
OK: 2/2 Fail: 0/2 Skip: 0/2
## Shufflings
```diff
+ Accelerated shuffling computation OK
```
OK: 1/1 Fail: 0/1 Skip: 0/1
## Slashing Interchange tests [Preset: mainnet]
```diff
+ Slashing test: duplicate_pubkey_not_slashable.json OK
Expand Down Expand Up @@ -669,4 +674,4 @@ OK: 2/2 Fail: 0/2 Skip: 0/2
OK: 9/9 Fail: 0/9 Skip: 0/9

---TOTAL---
OK: 382/387 Fail: 0/387 Skip: 5/387
OK: 383/388 Fail: 0/388 Skip: 5/388
24 changes: 24 additions & 0 deletions beacon_chain/consensus_object_pools/block_dag.nim
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,30 @@ func get_ancestor*(blck: BlockRef, slot: Slot,

blck = blck.parent

func commonAncestor*(a, b: BlockRef, lowSlot: Slot): Opt[BlockRef] =
etan-status marked this conversation as resolved.
Show resolved Hide resolved
## Return the common ancestor with highest slot of two non-nil `BlockRef`,
## limited by `lowSlot` (`err` if exceeded).
doAssert a != nil
doAssert b != nil
if a.slot < lowSlot or b.slot < lowSlot:
return err()

var
aa = a
bb = b
while aa != bb:
if aa.slot >= bb.slot:
aa = aa.parent
doAssert aa != nil, "All `BlockRef` lead to `finalizedHead`"
if aa.slot < lowSlot:
return err()
Copy link
Member

Choose a reason for hiding this comment

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

Opt.none() looks better with Opt

else:
bb = bb.parent
doAssert bb != nil, "All `BlockRef` lead to `finalizedHead`"
if bb.slot < lowSlot:
return err()
ok aa

func atSlot*(blck: BlockRef, slot: Slot): BlockSlot =
## Return a BlockSlot at a given slot, with the block set to the closest block
## available. If slot comes from before the block, a suitable block ancestor
Expand Down
Loading