diff --git a/go.mod b/go.mod index 637a07e..442ae4b 100644 --- a/go.mod +++ b/go.mod @@ -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 diff --git a/go.sum b/go.sum index a3aedc4..e7f3330 100644 --- a/go.sum +++ b/go.sum @@ -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= diff --git a/handlers/slot.go b/handlers/slot.go index f87d151..52d0982 100644 --- a/handlers/slot.go +++ b/handlers/slot.go @@ -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) } } @@ -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 } diff --git a/indexer/beacon/block_helper.go b/indexer/beacon/block_helper.go index 788769a..2be6744 100644 --- a/indexer/beacon/block_helper.go +++ b/indexer/beacon/block_helper.go @@ -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 { diff --git a/indexer/beacon/writedb.go b/indexer/beacon/writedb.go index be393df..0dcba97 100644 --- a/indexer/beacon/writedb.go +++ b/indexer/beacon/writedb.go @@ -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{ @@ -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{} } @@ -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{} }