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

pectra devnet 4 compatibility (spec v1.5.0-alpha.8) #135

Merged
merged 5 commits into from
Oct 16, 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
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,6 @@ require (
rsc.io/tmplfunc v0.0.3 // indirect
)

replace github.com/attestantio/go-eth2-client => github.com/attestantio/go-eth2-client v0.0.0-20240701211822-0a60485fce68
replace github.com/attestantio/go-eth2-client => github.com/attestantio/go-eth2-client v0.0.0-20241006200801-8fa702e3a895

replace github.com/ethereum/go-ethereum => github.com/lightclient/go-ethereum v0.0.0-20240907155054-183e7b702a00
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERo
github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU=
github.com/VictoriaMetrics/fastcache v1.12.2 h1:N0y9ASrJ0F6h0QaC3o6uJb3NIZ9VKLjCM7NQbSmF7WI=
github.com/VictoriaMetrics/fastcache v1.12.2/go.mod h1:AmC+Nzz1+3G2eCPapF6UcsnkThDcMsQicp4xDukwJYI=
github.com/attestantio/go-eth2-client v0.0.0-20240701211822-0a60485fce68 h1:7WPMn57cFdqlpYRwbEmMdHFXdwu9GVethzEXheTcIpk=
github.com/attestantio/go-eth2-client v0.0.0-20240701211822-0a60485fce68/go.mod h1:vy5jU/uDZ2+RcVzq5BfnG+bQ3/6uu9DGwCrGsPtjJ1A=
github.com/attestantio/go-eth2-client v0.0.0-20241006200801-8fa702e3a895 h1:SCPPFhrZXcr4VbQWy1EwBZyHEIL0rTpL8itkWwfY4pM=
github.com/attestantio/go-eth2-client v0.0.0-20241006200801-8fa702e3a895/go.mod h1:vy5jU/uDZ2+RcVzq5BfnG+bQ3/6uu9DGwCrGsPtjJ1A=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
github.com/bits-and-blooms/bitset v1.13.0 h1:bAQ9OPNFYbGHV6Nez0tmNI0RiEu7/hxlYJRUA0wFAVE=
Expand Down
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

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

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

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