Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
domiwei committed Nov 28, 2024
1 parent ba4fa9b commit 53396fd
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
6 changes: 6 additions & 0 deletions cl/phase1/core/state/accessors.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,12 @@ func IsValidatorEligibleForActivation(b abstract.BeaconState, validator solid.Va

// IsMergeTransitionComplete returns whether a merge transition is complete by verifying the presence of a valid execution payload header.
func IsMergeTransitionComplete(b abstract.BeaconState) bool {
if b.Version() < clparams.BellatrixVersion {
return false
}
if b.Version() > clparams.BellatrixVersion {
return true
}
return !b.LatestExecutionPayloadHeader().IsZero()
}

Expand Down
1 change: 0 additions & 1 deletion cl/spectest/consensus_tests/operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,6 @@ func operationExecutionPayloadHandler(t *testing.T, root fs.FS, c spectest.TestC
return err
}
if err := c.Machine.ProcessExecutionPayload(preState, body); err != nil {
//if err := machine.ProcessBlock(c.Machine, preState, body); err != nil {
if expectedError {
return nil
}
Expand Down
7 changes: 4 additions & 3 deletions cl/transition/impl/eth2/operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -368,16 +368,17 @@ func (I *impl) ProcessExecutionPayload(s abstract.BeaconState, body cltypes.Gene
if state.IsMergeTransitionComplete(s) {
// Verify consistency of the parent hash with respect to the previous execution payload header
// assert payload.parent_hash == state.latest_execution_payload_header.block_hash
if parentHash != s.LatestExecutionPayloadHeader().BlockHash {
if !bytes.Equal(parentHash[:], s.LatestExecutionPayloadHeader().BlockHash[:]) {
return errors.New("ProcessExecutionPayload: invalid eth1 chain. mismatching parent")
}
}
if prevRandao != s.GetRandaoMixes(state.Epoch(s)) {
random := s.GetRandaoMixes(state.Epoch(s))
if !bytes.Equal(prevRandao[:], random[:]) {
// Verify prev_randao
// assert payload.prev_randao == get_randao_mix(state, get_current_epoch(state))
return fmt.Errorf(
"ProcessExecutionPayload: randao mix mismatches with mix digest, expected %x, got %x",
s.GetRandaoMixes(state.Epoch(s)),
random,
prevRandao,
)
}
Expand Down

0 comments on commit 53396fd

Please sign in to comment.