Skip to content

Commit

Permalink
addressed G's second round of comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Sidu28 committed Feb 6, 2024
1 parent abcae34 commit 75a55e2
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 37 deletions.
4 changes: 2 additions & 2 deletions beacon/versioned_beacon_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/attestantio/go-eth2-client/spec/deneb"
)

func HistoricalSummaries(state *spec.VersionedBeaconState) ([]*capella.HistoricalSummary, error) {
func GetHistoricalSummaries(state *spec.VersionedBeaconState) ([]*capella.HistoricalSummary, error) {
switch state.Version {
case spec.DataVersionCapella:
return state.Capella.HistoricalSummaries, nil
Expand All @@ -19,7 +19,7 @@ func HistoricalSummaries(state *spec.VersionedBeaconState) ([]*capella.Historica
}
}

func GenesisTime(state *spec.VersionedBeaconState) (uint64, error) {
func GetGenesisTime(state *spec.VersionedBeaconState) (uint64, error) {
switch state.Version {
case spec.DataVersionCapella:
return state.Capella.GenesisTime, nil
Expand Down
2 changes: 1 addition & 1 deletion prove_withdrawal.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ func (epp *EigenPodProofs) ProveWithdrawal(
return nil, nil, errors.New("unsupported version")
}

oracleBeaconStateHistoricalSummaries, err := beacon.HistoricalSummaries(oracleBeaconState)
oracleBeaconStateHistoricalSummaries, err := beacon.GetHistoricalSummaries(oracleBeaconState)
if err != nil {
return nil, nil, err
}
Expand Down
10 changes: 4 additions & 6 deletions solidityProofGen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,9 @@ func GenerateWithdrawalFieldsProof(index, historicalSummariesIndex, blockHeaderI

beaconBlockHeaderToVerifyIndex := blockHeaderIndex

versionedOracleState := createVersionedState(spec.DataVersionDeneb)
versionedOracleState := beacon.CreateVersionedState(spec.DataVersionDeneb)
versionedOracleState.Deneb = &oracleState
versionedWithdrawalBlock := createVersionedSignedBlock(spec.DataVersionDeneb)
versionedWithdrawalBlock := beacon.CreateVersionedSignedBlock(spec.DataVersionDeneb)
versionedWithdrawalBlock.Deneb.Message = &withdrawalBlock

validatorIndex := phase0.ValidatorIndex(index)
Expand Down Expand Up @@ -298,10 +298,8 @@ func GenerateWithdrawalFieldsProofCapella(index, historicalSummariesIndex, block

beaconBlockHeaderToVerifyIndex := blockHeaderIndex

versionedOracleState := createVersionedState(spec.DataVersionCapella)
versionedOracleState.Deneb = &oracleState
versionedWithdrawalBlock := createVersionedSignedBlock(spec.DataVersionCapella)
versionedWithdrawalBlock.Capella.Message = &withdrawalBlock
versionedOracleState := beacon.CreateVersionedState(oracleState)
versionedWithdrawalBlock := beacon.CreateVersionedSignedBlock(withdrawalBlock)

validatorIndex := phase0.ValidatorIndex(index)
beaconStateRoot, _ := oracleState.HashTreeRoot()
Expand Down
27 changes: 0 additions & 27 deletions solidityProofGen/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
eigenpodproofs "github.com/Layr-Labs/eigenpod-proofs-generation"
ssz "github.com/ferranbt/fastssz"

"github.com/attestantio/go-eth2-client/spec"
"github.com/attestantio/go-eth2-client/spec/altair"
"github.com/attestantio/go-eth2-client/spec/capella"
"github.com/attestantio/go-eth2-client/spec/deneb"
Expand Down Expand Up @@ -482,29 +481,3 @@ func GetWithdrawalFields(w *capella.Withdrawal) []string {

return withdrawalFields
}

func createVersionedState(version spec.DataVersion) spec.VersionedBeaconState {
var versionedState spec.VersionedBeaconState
switch version {
case spec.DataVersionDeneb:
versionedState.Deneb = &deneb.BeaconState{}
case spec.DataVersionAltair:
versionedState.Altair = &altair.BeaconState{}
case spec.DataVersionCapella:
versionedState.Capella = &capella.BeaconState{}
}
versionedState.Version = version
return versionedState
}

func createVersionedSignedBlock(version spec.DataVersion) spec.VersionedSignedBeaconBlock {
var versionedBlock spec.VersionedSignedBeaconBlock
switch version {
case spec.DataVersionDeneb:
versionedBlock.Deneb.Message = &deneb.BeaconBlock{}
case spec.DataVersionCapella:
versionedBlock.Capella.Message = &capella.BeaconBlock{}
}
versionedBlock.Version = version
return versionedBlock
}
2 changes: 1 addition & 1 deletion utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func NextPowerOfTwo(v uint64) uint {
}

func GetSlotTimestamp(beaconState *spec.VersionedBeaconState, blockHeader *phase0.BeaconBlockHeader) (uint64, error) {
genesisTime, err := beacon.GenesisTime(beaconState)
genesisTime, err := beacon.GetGenesisTime(beaconState)
if err != nil {
return 0, err
}
Expand Down

0 comments on commit 75a55e2

Please sign in to comment.