Skip to content

Commit

Permalink
Merge branch 'master' into peerdas-as-deneb
Browse files Browse the repository at this point in the history
  • Loading branch information
pk910 committed Oct 16, 2024
2 parents a43882d + 67b30c1 commit e6235e9
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 77 deletions.
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ require (
rsc.io/tmplfunc v0.0.3 // indirect
)

replace github.com/attestantio/go-eth2-client => github.com/pk910/go-eth2-client v0.0.0-20240828114153-a531e55c7857

replace github.com/attestantio/go-eth2-client => github.com/pk910/go-eth2-client v0.0.0-20241016143409-89c508cc29cf

replace github.com/ethereum/go-ethereum => github.com/lightclient/go-ethereum v0.0.0-20240907155054-183e7b702a00
12 changes: 9 additions & 3 deletions handlers/slot.go
Original file line number Diff line number Diff line change
Expand Up @@ -681,9 +681,6 @@ func getSlotPageBlockData(blockData *services.CombinedBlockResponse, epochStatsV
BlockNumber: uint64(executionPayload.BlockNumber),
}
getSlotPageTransactions(pageData, executionPayload.Transactions)
getSlotPageDepositRequests(pageData, executionPayload.DepositRequests)
getSlotPageWithdrawalRequests(pageData, executionPayload.WithdrawalRequests)
getSlotPageConsolidationRequests(pageData, executionPayload.ConsolidationRequests)
}
}

Expand Down Expand Up @@ -725,6 +722,15 @@ func getSlotPageBlockData(blockData *services.CombinedBlockResponse, epochStatsV
}
}

if specs.ElectraForkEpoch != nil && uint64(epoch) >= *specs.ElectraForkEpoch {
requests, err := blockData.Block.ExecutionRequests()
if err == nil && requests != nil {
getSlotPageDepositRequests(pageData, requests.Deposits)
getSlotPageWithdrawalRequests(pageData, requests.Withdrawals)
getSlotPageConsolidationRequests(pageData, requests.Consolidations)
}
}

return pageData
}

Expand Down
69 changes: 0 additions & 69 deletions indexer/beacon/block_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,75 +223,6 @@ func getBlockExecutionExtraData(v *spec.VersionedSignedBeaconBlock) ([]byte, err
}
}

func getBlockExecutionDepositRequests(v *spec.VersionedSignedBeaconBlock) ([]*electra.DepositRequest, error) {
switch v.Version {
case spec.DataVersionPhase0:
return nil, errors.New("no deposit requests in phase0")
case spec.DataVersionAltair:
return nil, errors.New("no deposit requests in altair")
case spec.DataVersionBellatrix:
return nil, errors.New("no deposit requests in bellatrix")
case spec.DataVersionCapella:
return nil, errors.New("no deposit requests in capella")
case spec.DataVersionDeneb:
return nil, errors.New("no deposit requests in deneb")
case spec.DataVersionElectra:
if v.Electra == nil || v.Electra.Message == nil || v.Electra.Message.Body == nil || v.Electra.Message.Body.ExecutionPayload == nil {
return nil, errors.New("no electra block")
}

return v.Electra.Message.Body.ExecutionPayload.DepositRequests, nil
default:
return nil, errors.New("unknown version")
}
}

func getBlockExecutionConsolidationRequests(v *spec.VersionedSignedBeaconBlock) ([]*electra.ConsolidationRequest, error) {
switch v.Version {
case spec.DataVersionPhase0:
return nil, errors.New("no deposit requests in phase0")
case spec.DataVersionAltair:
return nil, errors.New("no deposit requests in altair")
case spec.DataVersionBellatrix:
return nil, errors.New("no deposit requests in bellatrix")
case spec.DataVersionCapella:
return nil, errors.New("no deposit requests in capella")
case spec.DataVersionDeneb:
return nil, errors.New("no deposit requests in deneb")
case spec.DataVersionElectra:
if v.Electra == nil || v.Electra.Message == nil || v.Electra.Message.Body == nil || v.Electra.Message.Body.ExecutionPayload == nil {
return nil, errors.New("no electra block")
}

return v.Electra.Message.Body.ExecutionPayload.ConsolidationRequests, nil
default:
return nil, errors.New("unknown version")
}
}

func getBlockExecutionWithdrawalRequests(v *spec.VersionedSignedBeaconBlock) ([]*electra.WithdrawalRequest, error) {
switch v.Version {
case spec.DataVersionPhase0:
return nil, errors.New("no deposit requests in phase0")
case spec.DataVersionAltair:
return nil, errors.New("no deposit requests in altair")
case spec.DataVersionBellatrix:
return nil, errors.New("no deposit requests in bellatrix")
case spec.DataVersionCapella:
return nil, errors.New("no deposit requests in capella")
case spec.DataVersionDeneb:
return nil, errors.New("no deposit requests in deneb")
case spec.DataVersionElectra:
if v.Electra == nil || v.Electra.Message == nil || v.Electra.Message.Body == nil || v.Electra.Message.Body.ExecutionPayload == nil {
return nil, errors.New("no electra block")
}

return v.Electra.Message.Body.ExecutionPayload.WithdrawalRequests, nil
default:
return nil, errors.New("unknown version")
}
}

// getStateRandaoMixes returns the RANDAO mixes from a versioned beacon state.
func getStateRandaoMixes(v *spec.VersionedBeaconState) ([]phase0.Root, error) {
switch v.Version {
Expand Down
12 changes: 9 additions & 3 deletions indexer/beacon/writedb.go
Original file line number Diff line number Diff line change
Expand Up @@ -485,11 +485,13 @@ func (dbw *dbWriter) buildDbDepositRequests(block *Block, orphaned bool, overrid
return nil
}

deposits, err := getBlockExecutionDepositRequests(blockBody)
requests, err := blockBody.ExecutionRequests()
if err != nil {
return nil
}

deposits := requests.Deposits

Check failure on line 493 in indexer/beacon/writedb.go

View workflow job for this annotation

GitHub Actions / Build Dora / Build linux/amd64 binary

requests.Deposits undefined (type *"github.com/attestantio/go-eth2-client/spec/electra".ExecutionRequests has no field or method Deposits)

Check failure on line 493 in indexer/beacon/writedb.go

View workflow job for this annotation

GitHub Actions / Build Dora / Build macos/arm64 binary

requests.Deposits undefined (type *"github.com/attestantio/go-eth2-client/spec/electra".ExecutionRequests has no field or method Deposits)

Check failure on line 493 in indexer/beacon/writedb.go

View workflow job for this annotation

GitHub Actions / Build Dora / Build macos/amd64 binary

requests.Deposits undefined (type *"github.com/attestantio/go-eth2-client/spec/electra".ExecutionRequests has no field or method Deposits)

Check failure on line 493 in indexer/beacon/writedb.go

View workflow job for this annotation

GitHub Actions / Build Dora / Build linux/arm64 binary

requests.Deposits undefined (type *"github.com/attestantio/go-eth2-client/spec/electra".ExecutionRequests has no field or method Deposits)

Check failure on line 493 in indexer/beacon/writedb.go

View workflow job for this annotation

GitHub Actions / Build Dora / Build windows/amd64 binary

requests.Deposits undefined (type *"github.com/attestantio/go-eth2-client/spec/electra".ExecutionRequests has no field or method Deposits)

dbDeposits := make([]*dbtypes.Deposit, len(deposits))
for idx, deposit := range deposits {
dbDeposit := &dbtypes.Deposit{
Expand Down Expand Up @@ -673,11 +675,13 @@ func (dbw *dbWriter) buildDbConsolidationRequests(block *Block, orphaned bool, o
return nil
}

consolidations, err := getBlockExecutionConsolidationRequests(blockBody)
requests, err := blockBody.ExecutionRequests()
if err != nil {
return nil
}

consolidations := requests.Consolidations

Check failure on line 683 in indexer/beacon/writedb.go

View workflow job for this annotation

GitHub Actions / Build Dora / Build linux/amd64 binary

requests.Consolidations undefined (type *"github.com/attestantio/go-eth2-client/spec/electra".ExecutionRequests has no field or method Consolidations)

Check failure on line 683 in indexer/beacon/writedb.go

View workflow job for this annotation

GitHub Actions / Build Dora / Build macos/arm64 binary

requests.Consolidations undefined (type *"github.com/attestantio/go-eth2-client/spec/electra".ExecutionRequests has no field or method Consolidations)

Check failure on line 683 in indexer/beacon/writedb.go

View workflow job for this annotation

GitHub Actions / Build Dora / Build macos/amd64 binary

requests.Consolidations undefined (type *"github.com/attestantio/go-eth2-client/spec/electra".ExecutionRequests has no field or method Consolidations)

Check failure on line 683 in indexer/beacon/writedb.go

View workflow job for this annotation

GitHub Actions / Build Dora / Build linux/arm64 binary

requests.Consolidations undefined (type *"github.com/attestantio/go-eth2-client/spec/electra".ExecutionRequests has no field or method Consolidations)

Check failure on line 683 in indexer/beacon/writedb.go

View workflow job for this annotation

GitHub Actions / Build Dora / Build windows/amd64 binary

requests.Consolidations undefined (type *"github.com/attestantio/go-eth2-client/spec/electra".ExecutionRequests has no field or method Consolidations)

if len(consolidations) == 0 {
return []*dbtypes.ConsolidationRequest{}
}
Expand Down Expand Up @@ -736,11 +740,13 @@ func (dbw *dbWriter) buildDbWithdrawalRequests(block *Block, orphaned bool, over
return nil
}

withdrawalRequests, err := getBlockExecutionWithdrawalRequests(blockBody)
requests, err := blockBody.ExecutionRequests()
if err != nil {
return nil
}

withdrawalRequests := requests.Withdrawals

Check failure on line 748 in indexer/beacon/writedb.go

View workflow job for this annotation

GitHub Actions / Build Dora / Build linux/amd64 binary

requests.Withdrawals undefined (type *"github.com/attestantio/go-eth2-client/spec/electra".ExecutionRequests has no field or method Withdrawals)

Check failure on line 748 in indexer/beacon/writedb.go

View workflow job for this annotation

GitHub Actions / Build Dora / Build macos/arm64 binary

requests.Withdrawals undefined (type *"github.com/attestantio/go-eth2-client/spec/electra".ExecutionRequests has no field or method Withdrawals)

Check failure on line 748 in indexer/beacon/writedb.go

View workflow job for this annotation

GitHub Actions / Build Dora / Build macos/amd64 binary

requests.Withdrawals undefined (type *"github.com/attestantio/go-eth2-client/spec/electra".ExecutionRequests has no field or method Withdrawals)

Check failure on line 748 in indexer/beacon/writedb.go

View workflow job for this annotation

GitHub Actions / Build Dora / Build linux/arm64 binary

requests.Withdrawals undefined (type *"github.com/attestantio/go-eth2-client/spec/electra".ExecutionRequests has no field or method Withdrawals)

Check failure on line 748 in indexer/beacon/writedb.go

View workflow job for this annotation

GitHub Actions / Build Dora / Build windows/amd64 binary

requests.Withdrawals undefined (type *"github.com/attestantio/go-eth2-client/spec/electra".ExecutionRequests has no field or method Withdrawals)

if len(withdrawalRequests) == 0 {
return []*dbtypes.WithdrawalRequest{}
}
Expand Down

0 comments on commit e6235e9

Please sign in to comment.