Skip to content

Commit

Permalink
bet
Browse files Browse the repository at this point in the history
  • Loading branch information
ocnc committed Aug 14, 2024
1 parent 5813e7b commit 0ae8742
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
4 changes: 4 additions & 0 deletions examples/berad/pkg/state-transition/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ type ReadOnlyBeaconState[
ValidatorIndexByCometBFTAddress(
cometBFTAddress []byte,
) (math.ValidatorIndex, error)
ValidatorIndexByPubkey(
crypto.BLSPubkey,
) (math.ValidatorIndex, error)
}

// WriteOnlyBeaconState is the interface for a write-only beacon state.
Expand All @@ -106,6 +109,7 @@ type WriteOnlyBeaconState[

DecreaseBalance(math.ValidatorIndex, math.Gwei) error
IncreaseBalance(math.ValidatorIndex, math.Gwei) error
SetBalance(math.ValidatorIndex, math.Gwei) error
SetEth1DepositIndex(uint64) error
SetFork(ForkT) error
SetGenesisValidatorsRoot(root common.Root) error
Expand Down
17 changes: 14 additions & 3 deletions examples/berad/pkg/state-transition/state_processor_staking.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,10 +270,21 @@ func (sp *StateProcessor[
func (sp *StateProcessor[
_, _, _, BeaconStateT, _, _, _, _, _, _, _, _, _, _, _, _,
]) processForcedWithdrawals(
_ BeaconStateT,
_ transition.ValidatorUpdates,
st BeaconStateT,
valUpdates transition.ValidatorUpdates,
) error {
// TODO: Implement this function.
// Process the forced withdrawals.
for _, valUpdate := range valUpdates {
idx, err := st.ValidatorIndexByPubkey(valUpdate.Pubkey)
if err != nil {
return err
}

// Set the validator's effective balance to 0.
if err = st.SetBalance(idx, 0); err != nil {
return err
}
}
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion mod/storage/pkg/beacondb/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func (kv *KVStore[
BeaconBlockHeaderT, Eth1DataT, ExecutionPayloadHeaderT,
ForkT, ValidatorT, ValidatorsT,
]) AddValidatorBartio(val ValidatorT) error {
// Get the ne
// Get the next validator index from the sequence.
idx, err := kv.validatorIndex.Next(kv.ctx)
if err != nil {
return err
Expand Down

0 comments on commit 0ae8742

Please sign in to comment.