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

Confirmation Rule #3339

Open
wants to merge 171 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 154 commits
Commits
Show all changes
171 commits
Select commit Hold shift + click to select a range
d137dbe
Change to filter_block_tree required for the confirmation rule
saltiniroberto Apr 12, 2023
e04c678
First draft implementation of the confirmation rule
saltiniroberto Apr 13, 2023
0a2e654
Rename safe-head.md
saltiniroberto Apr 13, 2023
d51ae0c
Require to run isConfirmed only on blocks from the current epoch
saltiniroberto Apr 13, 2023
3c145ec
Move get_leaf_block_roots to unused function section
saltiniroberto Apr 13, 2023
124eaba
Compute remaining voting weight starting from current_slot + 1 rather…
saltiniroberto Apr 15, 2023
1b3eb7c
Fix typo
saltiniroberto Apr 16, 2023
da75a4e
Make mypy happy
saltiniroberto Apr 18, 2023
e622582
Fix formula in isOneConfirmed
saltiniroberto Apr 18, 2023
7cd6f41
Change ffg weight calculation and fix error in other fomula
saltiniroberto Apr 18, 2023
4be510e
Account for proposer boost
saltiniroberto Apr 18, 2023
be8bfce
Fix minor issue
saltiniroberto Apr 18, 2023
e4ad646
Fix will_block_checkpoint_be_justified_by_end_of_the_current_epoch + …
saltiniroberto Apr 19, 2023
9bd335c
Merge branch 'ethereum:dev' into confirmation_rule
saltiniroberto Apr 19, 2023
f454b99
minor updates
saltiniroberto Apr 19, 2023
6f56d90
Increase style check line length for ease of development
saltiniroberto Apr 19, 2023
dc95b43
Use latest_message for computing get_ffg_weight_supporting_checkpoint…
saltiniroberto Apr 20, 2023
89a2818
Add helper function for calculating score
saltiniroberto Apr 20, 2023
a68c853
Add functions to calculate score
saltiniroberto Apr 21, 2023
c29053b
Use underscore for all function names
saltiniroberto Apr 21, 2023
a6c91b4
Removed files committed by mistake
saltiniroberto Apr 26, 2023
a69530d
Remove other files committed by mistake
saltiniroberto Apr 26, 2023
5f8e88e
Moved functions for calculating the confirmation score to a separate
saltiniroberto Apr 26, 2023
3b6afe5
Added very brief explainer
saltiniroberto Apr 26, 2023
ad97ef9
Add back get_safe_execution_payload_hash
saltiniroberto Apr 26, 2023
bcc1c3f
Revert ffg support commputation to use attestations in leaf blocks
saltiniroberto Apr 26, 2023
4d7b715
Doc
saltiniroberto Apr 27, 2023
c67cf35
Make mypy happy
saltiniroberto Apr 27, 2023
c3a0f7f
doctoc
saltiniroberto Apr 27, 2023
2493cb3
doc
saltiniroberto Apr 27, 2023
d338119
Add doc and fix bug in get_max_adversary_percentage_to_ensure_block_c…
saltiniroberto Apr 27, 2023
55bdbe0
Merge remote-tracking branch 'upstream/dev' into confirmation_rule
saltiniroberto Apr 27, 2023
08e3abd
Removed unused files
saltiniroberto Apr 27, 2023
3e29857
Remove unrequired files
saltiniroberto Apr 27, 2023
3066ad4
first pass for review
adiasg Apr 27, 2023
d53a44a
Merge pull request #2 from saltiniroberto/confirmation_rule_adiasg
saltiniroberto Apr 28, 2023
9354dc7
Small fix to the doc
saltiniroberto Apr 28, 2023
1dff966
Calculate vote_weight_till_now as diff between total and future
saltiniroberto Apr 28, 2023
bd85b41
Fix link in bellatrix fork choice
saltiniroberto Apr 28, 2023
16b26c1
review pass 2
adiasg May 4, 2023
9ccf48b
Merge pull request #3 from saltiniroberto/confirmation_rule_adiasg
saltiniroberto May 4, 2023
b8ac374
Merge remote-tracking branch 'upstream/dev' into confirmation_rule
saltiniroberto May 4, 2023
b99e31f
update confirmation score calc
adiasg May 15, 2023
0117eed
remove current_slot parameter
adiasg May 15, 2023
446baeb
use simplified comm weight calc for safe block
adiasg May 15, 2023
673b4f4
add function for computing proposer score
adiasg May 15, 2023
38ace65
remove old code
adiasg May 15, 2023
ca5006d
use get_checkpoint_block
adiasg May 15, 2023
9475b62
readability refactor
adiasg May 16, 2023
668c97d
use float calculations
adiasg May 16, 2023
6ccc528
Fix get_proposer_score
saltiniroberto May 16, 2023
97dc8be
Fix lint error
saltiniroberto May 16, 2023
0b2751d
Merge pull request #5 from saltiniroberto/confirmation_rule_adiasg_ro…
adiasg May 16, 2023
49a1365
fix lint errors
adiasg May 16, 2023
6a75d4e
update toc
adiasg May 16, 2023
03b194e
function renaming
adiasg May 16, 2023
b843dad
wip - update conf score comments
adiasg May 17, 2023
185338c
fix multiplier
adiasg May 17, 2023
5c38f67
remove comments
adiasg May 17, 2023
ba7cb1f
simplify confirmation score functions
adiasg May 17, 2023
c0efc70
attach paper
adiasg May 17, 2023
0041a00
Fix calculation bug in remaining_slots_in_current_epoch
saltiniroberto May 17, 2023
d8cbfbc
Merge pull request #6 from saltiniroberto/confirmation_rule_adiasg_ro…
adiasg May 17, 2023
569366b
minor update
adiasg May 17, 2023
dca4c34
Merge pull request #4 from saltiniroberto/confirmation_rule_adiasg
adiasg May 17, 2023
d792899
change typing
adiasg May 17, 2023
0d9e1a1
Update introductory notes
adiasg May 17, 2023
ee3991f
rename conflicting function
adiasg May 17, 2023
8b3ab9c
typo correction
adiasg May 18, 2023
79ffac1
apply review from @hwwhww and @mkalinin
adiasg Jun 5, 2023
448ffac
function name case suggestion by @mkalinin
adiasg Jun 5, 2023
c79df70
some more suggestions from @mkalinin
adiasg Jun 5, 2023
91643d9
Apply suggestions from code review
adiasg Jun 7, 2023
17d528a
commit change
saltiniroberto Jun 7, 2023
50e94fa
Fix small bug
saltiniroberto Jun 15, 2023
988b875
Port FFG support calculation to Altair logic
saltiniroberto Jun 15, 2023
b8c2ba6
Limit confirmation score negative values to -1
saltiniroberto Jun 15, 2023
bb4a6aa
Fix https://github.com/ethereum/consensus-specs/pull/3339#discussion_…
saltiniroberto Jun 15, 2023
783762a
Fix doc
saltiniroberto Jun 15, 2023
956a0b7
Fix doc
saltiniroberto Jun 15, 2023
28e3f64
Fix blank lines
saltiniroberto Jun 15, 2023
bfe43ce
Fix types in get_committee_weight_between_slots
saltiniroberto Jun 15, 2023
ddf8772
Move from floats to ints
saltiniroberto Jun 15, 2023
ce5670a
Update doc to reflect usage of unbound int rather than floats
saltiniroberto Jun 15, 2023
dd22c68
Moved missed float computations to int and fixed linting
saltiniroberto Jun 15, 2023
9933161
Replace float with integer arithmetic for calculations in get_committ…
saltiniroberto Jun 15, 2023
1269ea5
Fix https://github.com/ethereum/consensus-specs/pull/3339/files#r1230…
saltiniroberto Jun 16, 2023
b9919b6
Fix bug in fetching checkpoint state in get_ffg_confirmation_score an…
saltiniroberto Jun 16, 2023
0530af7
Make flake8 happy
saltiniroberto Jun 17, 2023
24b66c8
Use pulled up checkpoint state in get_ffg_support
saltiniroberto Jun 17, 2023
616ae4c
Fix bug in get_committee_weight_between_slots
saltiniroberto Jun 17, 2023
ae0bf67
Revert "Fix bug in get_committee_weight_between_slots"
saltiniroberto Jun 17, 2023
9bcefc1
Fix bug in get_committee_weight_between_slots
saltiniroberto Jun 17, 2023
444a7e6
Fix bug in get_ffg_support
saltiniroberto Jun 17, 2023
b0b93f8
Fix bug in get_confirmation_score
saltiniroberto Jun 17, 2023
a3c463f
Fix div by 0 in get_ffg_confirmation_score
saltiniroberto Jun 17, 2023
d80b701
Add slashing_th par to get_confirmation_score and improve pre div-by-…
saltiniroberto Jun 17, 2023
3ea5598
Allow is_confirmed for blocks from the previous epoch
saltiniroberto Jun 21, 2023
3ce6a0e
Extend handling of previous epoch to get_score
saltiniroberto Jun 21, 2023
8737f14
Use block state for balances and refactor get_remaining_weight
saltiniroberto Jun 21, 2023
72fb786
Fix return type issue in get_committee_weight_between_slots
saltiniroberto Jun 21, 2023
0e2e77a
Refactor get_ffg_confirmation_score to reduce code repetition
saltiniroberto Jun 21, 2023
1fb41c4
Refactor is_ffg_confirmed to reduce code duplication
saltiniroberto Jun 21, 2023
9a45487
doctoc
saltiniroberto Jun 21, 2023
0d93f11
Add tests
saltiniroberto Jun 21, 2023
3e4837a
Refactor tests
saltiniroberto Jun 21, 2023
2aba14f
Add get_confirmation_score checks in tests
saltiniroberto Jun 21, 2023
a77a8b0
Make linter happy
saltiniroberto Jun 21, 2023
12de731
Apply some of djrtwo’s review suggestions
saltiniroberto Jul 10, 2023
2760c72
Improve calculation for edge case in get_committee_weight_between_slots
saltiniroberto Jul 10, 2023
4433813
Improve get_committee_weight_between_slots (more precise calculations…
saltiniroberto Jul 10, 2023
78bcb38
Remove leftovers from previous code refactoring
saltiniroberto Jul 11, 2023
c32b9ef
Aligned long function defs to the convention used in the rest of the …
saltiniroberto Jul 11, 2023
7333dde
Simplify check on block epoch
saltiniroberto Jul 11, 2023
bb7fe9a
Remove duplicate line.
saltiniroberto Jul 11, 2023
b69dfb6
Fix doc for is_ffg_confirmed & helpers
saltiniroberto Jul 11, 2023
20c101f
Rename vars in is_confirmed
saltiniroberto Jul 11, 2023
b1d631a
Combine code for previous and current epoch in is_ffg_confirmed and g…
saltiniroberto Jul 18, 2023
ad268ec
Use inline comments style rather than docstrings for comments related…
saltiniroberto Jul 18, 2023
e29d0ac
Fix bug in get_committee_weight_between_slots
saltiniroberto Jul 19, 2023
e955658
Move config par to Configuration, add constant definition and improve…
saltiniroberto Jul 21, 2023
913260b
Implement early exit criteria for is_lmd_confirmed
saltiniroberto Jul 22, 2023
5e05100
Add link to committee weight estimation, introduce adjustment factor …
saltiniroberto Jul 23, 2023
ae1ef29
Use compute_slots_since_epoch_start in get_committee_weight_between_s…
saltiniroberto Jul 23, 2023
24b6db2
Fix variable names in get_committee_weight_between_slots
saltiniroberto Jul 23, 2023
1340706
Use ceiling division everywhere in get_committee_weight_between_slots
saltiniroberto Jul 23, 2023
49a2a30
Replace pythonic starred expression in get_leaf_block_roots with for …
saltiniroberto Jul 23, 2023
c41b95d
Rename var in get_ffg_support
saltiniroberto Jul 23, 2023
6961150
Allow for blocks from the previous epoch in find_confirmed_block, re-…
saltiniroberto Jul 23, 2023
f29df8b
Fix the level of indentation of some of the headings
saltiniroberto Jul 23, 2023
d243ce8
Add test for get_safe_beacon_block_root
saltiniroberto Jul 23, 2023
c59f1fe
Temporary fork choice spec test change
saltiniroberto Jul 23, 2023
f4a7a4f
Fix typo
saltiniroberto Jul 23, 2023
39d8b4f
Add new line to make the linter happy
saltiniroberto Jul 23, 2023
33b555d
Add new line to make linter happy
saltiniroberto Jul 23, 2023
cfa521d
Run confirmation rule tests only from bellatrix onwards
saltiniroberto Jul 23, 2023
7dfdcd7
Merge branch 'upstream/dev' into confirmation_rule
saltiniroberto Jul 23, 2023
0b8eb0b
Fix possible rounding issue in get_committee_weight_between_slots
saltiniroberto Jul 25, 2023
499e4f6
Improve doc on using unbounded integers
saltiniroberto Jul 25, 2023
a9597c4
Restore safe-block.md for now
saltiniroberto Jul 25, 2023
528bbdc
Fix mistake when restoring safe-block.md in previous commit
saltiniroberto Jul 25, 2023
4926681
Merge commit fork-choice-changes-for-confirmaton-rule into confirmati…
saltiniroberto Jul 27, 2023
e735a58
Fix error from previous merge
saltiniroberto Jul 27, 2023
8c23187
Fix comments
saltiniroberto Jul 30, 2023
6692612
Fix var name in get_committee_weight_between_slots
saltiniroberto Jul 30, 2023
cd0ad10
Rename low lever get_confirmation* functions to compute_confirmation*
saltiniroberto Jul 30, 2023
e365bc4
Use cell_div rather than the explicit formula
saltiniroberto Jul 30, 2023
d25b7ef
Rename committee_spans_full_epoch and committee_for_block_spans_full_…
saltiniroberto Jul 30, 2023
9fa4fca
Change implementation of ceil_div
saltiniroberto Jul 30, 2023
992dea0
Apply suggestions from @mkalinin's review
saltiniroberto Aug 1, 2023
508327e
Add handling of block from epoch prior to previous in is_confirmed
saltiniroberto Aug 2, 2023
d6c25e1
Calculate confirmation score for blocks prior to previous epoch as well
saltiniroberto Aug 3, 2023
e927509
Make the linter happy
saltiniroberto Aug 3, 2023
32232f6
Remove get_safe_beacon_block_root and get_safe_execution_payload_hash…
saltiniroberto Aug 4, 2023
3787e96
Apply suggestions from code review
saltiniroberto Aug 4, 2023
8ff01f5
Stop recursion earlier in compute_lmd_confirmation_score
saltiniroberto Aug 7, 2023
cacdc04
Refactor test to improve code reuse
saltiniroberto Aug 8, 2023
eebbe94
Merge commit dev branch into confirmation_rule
saltiniroberto Aug 8, 2023
21b9d2e
Fix issue in previous merge
saltiniroberto Aug 8, 2023
dff96e3
Merge 'dev' into confirmation_rule
saltiniroberto May 2, 2024
c9caf62
Update to match latest paper
saltiniroberto May 2, 2024
740be9a
Fix lint issues
saltiniroberto May 2, 2024
688aa19
Improve doc
saltiniroberto May 3, 2024
4ad1cc2
Fix typo
saltiniroberto May 3, 2024
be3648d
Renaming
saltiniroberto May 3, 2024
b89e93b
Fix lint issues
saltiniroberto May 3, 2024
696e22d
Merge branch 'dev' into pr3339
hwwhww Sep 3, 2024
ff3daaa
resolve conflict
hwwhww Sep 3, 2024
e0dc09b
Fix argument sequence error
hwwhww Sep 3, 2024
e6d9150
Move confirmation rule specs to Bellatrix
hwwhww Sep 3, 2024
687fd5c
Clean up phase0
hwwhww Sep 3, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions configs/mainnet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,13 @@ CHURN_LIMIT_QUOTIENT: 65536
# 40%
PROPOSER_SCORE_BOOST: 40

# Confirmation rule
# ---------------------------------------------------------------
# 20%
CONFIRMATION_BYZANTINE_THRESHOLD: 20
Copy link
Collaborator

Choose a reason for hiding this comment

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

I am hesitant to make it configurable with the configuration shared by all the clients. IMHO, client diversity would be better in this case. The way these parameters should be passed into runtime and also the default values can be decided by each client team independently, i think we should rather give recommendation than prescription.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought that each client could use a different configuration.

@adiasg @hwwhww
What do you think about this one?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Each client has an option to override the configuration I think but usually configuration isn't changed in the clients runtime. We should check with client devs

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's ok to define the default values in this config. Sophisticated users are always able to load their own configs, while normal users should be ok using the default value from here (which should be carefully chosen - whether that's 20 or something else!).

Copy link
Collaborator

Choose a reason for hiding this comment

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

Sophisticated users are always able to load their own configs

Yes, they are. A set of parameters in this and similar configs defines protocol parameters for a specific network, mainnet in this case. IMO, these parameters are not supposed to change in runtime and should not be a subject to a node operator's choice. From this perspective what we want for the confirmation rule doesn't fit a network configuration bur rather fits a client runtime parameters.

Copy link
Contributor

Choose a reason for hiding this comment

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

@mkalinin

But compared to "Constants" and "Presets", "Configurations" is the most configurable parameter set we have in the specs. Do you suggest that we define a new category of the parameters?

To provide test vectors, we still need to set the parameter value somewhere.

# 0 Gwei
CONFIRMATION_SLASHING_THRESHOLD: 0

# Deposit contract
# ---------------------------------------------------------------
# Ethereum PoW Mainnet
Expand Down
6 changes: 6 additions & 0 deletions configs/minimal.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,12 @@ CHURN_LIMIT_QUOTIENT: 32
# 40%
PROPOSER_SCORE_BOOST: 40

# Confirmation rule
# ---------------------------------------------------------------
# 20%
CONFIRMATION_BYZANTINE_THRESHOLD: 20
# 0 Gwei
CONFIRMATION_SLASHING_THRESHOLD: 0

# Deposit contract
# ---------------------------------------------------------------
Expand Down
639 changes: 639 additions & 0 deletions fork_choice/confirmation-rule.md

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,10 @@ def finalize_options(self):
print("no paths were specified, using default markdown file paths for pyspec"
" build (spec fork: %s)" % self.spec_fork)
self.md_doc_paths = get_md_doc_paths(self.spec_fork)
if self.spec_fork not in ('phase0', 'altair'):
self.md_doc_paths += """
fork_choice/confirmation-rule.md
"""
if len(self.md_doc_paths) == 0:
raise Exception('no markdown files specified, and spec fork "%s" is unknown', self.spec_fork)

Expand Down
46 changes: 28 additions & 18 deletions specs/phase0/fork-choice.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@
- [`get_forkchoice_store`](#get_forkchoice_store)
- [`get_slots_since_genesis`](#get_slots_since_genesis)
- [`get_current_slot`](#get_current_slot)
- [`get_current_store_epoch`](#get_current_store_epoch)
- [`compute_slots_since_epoch_start`](#compute_slots_since_epoch_start)
- [`get_ancestor`](#get_ancestor)
- [`get_checkpoint_block`](#get_checkpoint_block)
- [`get_proposer_score`](#get_proposer_score)
- [`get_weight`](#get_weight)
- [`get_voting_source`](#get_voting_source)
- [`filter_block_tree`](#filter_block_tree)
Expand Down Expand Up @@ -124,8 +126,7 @@ class Store(object):

```python
def is_previous_epoch_justified(store: Store) -> bool:
current_slot = get_current_slot(store)
current_epoch = compute_epoch_at_slot(current_slot)
current_epoch = get_current_store_epoch(store)
return store.justified_checkpoint.epoch + 1 == current_epoch
```

Expand Down Expand Up @@ -174,6 +175,13 @@ def get_current_slot(store: Store) -> Slot:
return Slot(GENESIS_SLOT + get_slots_since_genesis(store))
```

#### `get_current_store_epoch`

```python
def get_current_store_epoch(store: Store) -> Epoch:
return compute_epoch_at_slot(get_current_slot(store))
```

#### `compute_slots_since_epoch_start`

```python
Expand Down Expand Up @@ -202,6 +210,15 @@ def get_checkpoint_block(store: Store, root: Root, epoch: Epoch) -> Root:
return get_ancestor(store, root, epoch_first_slot)
```

#### `get_proposer_score`

```python
def get_proposer_score(store: Store) -> Gwei:
mkalinin marked this conversation as resolved.
Show resolved Hide resolved
justified_checkpoint_state = store.checkpoint_states[store.justified_checkpoint]
committee_weight = get_total_active_balance(justified_checkpoint_state) // SLOTS_PER_EPOCH
return (committee_weight * PROPOSER_SCORE_BOOST) // 100
```

#### `get_weight`

```python
Expand All @@ -225,8 +242,7 @@ def get_weight(store: Store, root: Root) -> Gwei:
proposer_score = Gwei(0)
# Boost is applied if ``root`` is an ancestor of ``proposer_boost_root``
if get_ancestor(store, store.proposer_boost_root, store.blocks[root].slot) == root:
committee_weight = get_total_active_balance(state) // SLOTS_PER_EPOCH
proposer_score = (committee_weight * PROPOSER_SCORE_BOOST) // 100
proposer_score = get_proposer_score(store)
return attestation_score + proposer_score
```

Expand All @@ -238,7 +254,7 @@ def get_voting_source(store: Store, block_root: Root) -> Checkpoint:
Compute the voting source checkpoint in event that block with root ``block_root`` is the head block
"""
block = store.blocks[block_root]
current_epoch = compute_epoch_at_slot(get_current_slot(store))
current_epoch = get_current_store_epoch(store)
block_epoch = compute_epoch_at_slot(block.slot)
if current_epoch > block_epoch:
# The block is from a prior epoch, the voting source will be pulled-up
Expand Down Expand Up @@ -271,23 +287,17 @@ def filter_block_tree(store: Store, block_root: Root, blocks: Dict[Root, BeaconB
return True
return False

current_epoch = compute_epoch_at_slot(get_current_slot(store))
current_epoch = get_current_store_epoch(store)
voting_source = get_voting_source(store, block_root)

# The voting source should be at the same height as the store's justified checkpoint
# The voting source should be either at the same height as the store's justified checkpoint or
# not more than two epochs ago
correct_justified = (
store.justified_checkpoint.epoch == GENESIS_EPOCH
or voting_source.epoch == store.justified_checkpoint.epoch
or voting_source.epoch + 2 >= current_epoch
)

# If the previous epoch is justified, the block should be pulled-up. In this case, check that unrealized
# justification is higher than the store and that the voting source is not more than two epochs ago
if not correct_justified and is_previous_epoch_justified(store):
correct_justified = (
store.unrealized_justifications[block_root].epoch >= store.justified_checkpoint.epoch and
voting_source.epoch + 2 >= current_epoch
)

saltiniroberto marked this conversation as resolved.
Show resolved Hide resolved
finalized_checkpoint_block = get_checkpoint_block(
store,
block_root,
Expand Down Expand Up @@ -391,7 +401,7 @@ def compute_pulled_up_tip(store: Store, block_root: Root) -> None:

# If the block is from a prior epoch, apply the realized values
block_epoch = compute_epoch_at_slot(store.blocks[block_root].slot)
current_epoch = compute_epoch_at_slot(get_current_slot(store))
current_epoch = get_current_store_epoch(store)
if block_epoch < current_epoch:
update_checkpoints(store, state.current_justified_checkpoint, state.finalized_checkpoint)
```
Expand Down Expand Up @@ -428,7 +438,7 @@ def validate_target_epoch_against_current_time(store: Store, attestation: Attest
target = attestation.data.target

# Attestations must be from the current or previous epoch
current_epoch = compute_epoch_at_slot(get_current_slot(store))
current_epoch = get_current_store_epoch(store)
# Use GENESIS_EPOCH for previous when genesis to avoid underflow
previous_epoch = current_epoch - 1 if current_epoch > GENESIS_EPOCH else GENESIS_EPOCH
# If attestation target is from a future epoch, delay consideration until the epoch arrives
Expand Down Expand Up @@ -525,7 +535,7 @@ def on_block(store: Store, signed_block: SignedBeaconBlock) -> None:
block.parent_root,
store.finalized_checkpoint.epoch,
)
assert store.finalized_checkpoint.root == finalized_checkpoint_block
assert store.finalized_checkpoint.root == finalized_checkpoint_block

# Check the block is valid and compute the post-state
state = pre_state.copy()
Expand Down
Loading