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(transitions): move berad transitions stuff around #1881

Merged
merged 3 commits into from
Aug 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
15 changes: 14 additions & 1 deletion examples/berad/pkg/state-transition/state_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ func (sp *StateProcessor[
return err
}

// process the deposits and ensure they match the local state.
// process the operations of whats on the block body.
if err := sp.processOperations(st, blk); err != nil {
return err
}
Expand Down Expand Up @@ -430,6 +430,19 @@ func (sp *StateProcessor[
return nil
}

// processOperations processes the operations and ensures they match the
// local state.
func (sp *StateProcessor[
BeaconBlockT, _, _, BeaconStateT, _, _, _, _, _, _, _, _, _, _, _, _,
]) processOperations(
st BeaconStateT,
blk BeaconBlockT,
) error {
// TODO: process attestations as well
deposits := blk.GetBody().GetDeposits()
return sp.processDeposits(st, deposits)
}
Comment on lines +433 to +444
Copy link
Contributor

Choose a reason for hiding this comment

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

Initial Implementation of processOperations Approved.

The function currently processes deposits and includes a TODO comment for future expansion to handle attestations. The implementation is consistent with existing error handling practices.

Address the TODO Comment.

Consider prioritizing the implementation of attestation processing to enhance the functionality of processOperations.


// getAttestationDeltas as defined in the Ethereum 2.0 specification.
// https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/beacon-chain.md#get_attestation_deltas
//
Expand Down
42 changes: 0 additions & 42 deletions examples/berad/pkg/state-transition/state_processor_staking.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,37 +29,6 @@ import (
"github.com/davecgh/go-spew/spew"
)

// processOperations processes the operations and ensures they match the
// local state.
func (sp *StateProcessor[
BeaconBlockT, _, _, BeaconStateT, _, _, _, _, _, _, _, _, _, _, _, _,
]) processOperations(
st BeaconStateT,
blk BeaconBlockT,
) error {
// Verify that outstanding deposits are processed up to the maximum number
// of deposits.
deposits := blk.GetBody().GetDeposits()
// index, err := st.GetEth1DepositIndex()
// if err != nil {
// return err
// }
// eth1Data, err := st.GetEth1Data()
// if err != nil {
// return err
// }
// depositCount := min(
// sp.cs.MaxDepositsPerBlock(),
// uint64(eth1Data.GetDepositCount())-index,
// )
// _ = depositCount
// TODO: Update eth1data count and check this.
// if uint64(len(deposits)) != depositCount {
// return errors.New("deposit count mismatch")
// }
return sp.processDeposits(st, deposits)
}

// processDeposits processes the deposits and ensures they match the
// local state.
func (sp *StateProcessor[
Expand All @@ -84,17 +53,6 @@ func (sp *StateProcessor[
st BeaconStateT,
dep DepositT,
) error {
// TODO: fill this in properly
// if !sp.isValidMerkleBranch(
// leaf,
// dep.Credentials,
// 32 + 1,
// dep.Index,
// st.root,
// ) {
// return errors.New("invalid merkle branch")
// }

depositIndex, err := st.GetEth1DepositIndex()
if err != nil {
return err
Expand Down
Loading