From f373209a45695103ea4fb0a332d36917372b0066 Mon Sep 17 00:00:00 2001 From: pk910 Date: Tue, 24 Sep 2024 14:52:41 +0200 Subject: [PATCH 1/4] pectra devnet 4 compatibility (spec v1.5.0-alpha.6) --- go.mod | 2 +- go.sum | 4 +- handlers/slot.go | 12 ++++-- indexer/beacon/block_helper.go | 69 ---------------------------------- indexer/beacon/writedb.go | 12 ++++-- 5 files changed, 21 insertions(+), 78 deletions(-) diff --git a/go.mod b/go.mod index 1eca361..da81ce2 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/pk910/go-eth2-client v0.0.0-20240923174943-8d64565c83ca 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 2e9b3d0..e4f79db 100644 --- a/go.sum +++ b/go.sum @@ -16,8 +16,6 @@ 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/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= @@ -321,6 +319,8 @@ github.com/onsi/gomega v1.18.1 h1:M1GfJqGRrBrrGGsbxzV5dqM2U2ApXefZCQpkukxYRLE= github.com/onsi/gomega v1.18.1/go.mod h1:0q+aL8jAiMXy9hbwj2mr5GziHiwhAIQpFmmtT5hitRs= github.com/pk910/dynamic-ssz v0.0.5 h1:VP9heGYUwzlpyhk28P2nCAzhvGsePJOOOO5vQMDh2qQ= github.com/pk910/dynamic-ssz v0.0.5/go.mod h1:b6CrLaB2X7pYA+OSEEbkgXDEcRnjLOZIxZTsMuO/Y9c= +github.com/pk910/go-eth2-client v0.0.0-20240923174943-8d64565c83ca h1:rc6VVR79GdE58Wx1Arh9QNo+0qmXOfYjWQhrbkSeoI0= +github.com/pk910/go-eth2-client v0.0.0-20240923174943-8d64565c83ca/go.mod h1:vy5jU/uDZ2+RcVzq5BfnG+bQ3/6uu9DGwCrGsPtjJ1A= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= diff --git a/handlers/slot.go b/handlers/slot.go index f87d151..1367b6f 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.DepositRequests) + getSlotPageWithdrawalRequests(pageData, requests.WithdrawalRequests) + getSlotPageConsolidationRequests(pageData, requests.ConsolidationRequests) + } + } + 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..b20bea0 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.DepositRequests + 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.ConsolidationRequests + 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.WithdrawalRequests + if len(withdrawalRequests) == 0 { return []*dbtypes.WithdrawalRequest{} } From d4904390bf63fe79986370760e6de4df4d641909 Mon Sep 17 00:00:00 2001 From: pk910 Date: Tue, 24 Sep 2024 14:58:36 +0200 Subject: [PATCH 2/4] trigger CI From ccfba9fe140860d4877ede2b4d6ee8788f48f1dc Mon Sep 17 00:00:00 2001 From: pk910 Date: Sun, 6 Oct 2024 17:40:17 +0200 Subject: [PATCH 3/4] update to spec v1.5.0-alpha.7 --- go.mod | 2 +- go.sum | 4 ++-- handlers/slot.go | 6 +++--- indexer/beacon/writedb.go | 6 +++--- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index da81ce2..babdf4c 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/pk910/go-eth2-client v0.0.0-20240923174943-8d64565c83ca +replace github.com/attestantio/go-eth2-client => github.com/pk910/go-eth2-client v0.0.0-20241004214539-f6f806861d96 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 e4f79db..2c8bd57 100644 --- a/go.sum +++ b/go.sum @@ -319,8 +319,8 @@ github.com/onsi/gomega v1.18.1 h1:M1GfJqGRrBrrGGsbxzV5dqM2U2ApXefZCQpkukxYRLE= github.com/onsi/gomega v1.18.1/go.mod h1:0q+aL8jAiMXy9hbwj2mr5GziHiwhAIQpFmmtT5hitRs= github.com/pk910/dynamic-ssz v0.0.5 h1:VP9heGYUwzlpyhk28P2nCAzhvGsePJOOOO5vQMDh2qQ= github.com/pk910/dynamic-ssz v0.0.5/go.mod h1:b6CrLaB2X7pYA+OSEEbkgXDEcRnjLOZIxZTsMuO/Y9c= -github.com/pk910/go-eth2-client v0.0.0-20240923174943-8d64565c83ca h1:rc6VVR79GdE58Wx1Arh9QNo+0qmXOfYjWQhrbkSeoI0= -github.com/pk910/go-eth2-client v0.0.0-20240923174943-8d64565c83ca/go.mod h1:vy5jU/uDZ2+RcVzq5BfnG+bQ3/6uu9DGwCrGsPtjJ1A= +github.com/pk910/go-eth2-client v0.0.0-20241004214539-f6f806861d96 h1:I6qQcQtxwafsolKI5pj3gbRn1kc05Tq1571gxPG1/c8= +github.com/pk910/go-eth2-client v0.0.0-20241004214539-f6f806861d96/go.mod h1:vy5jU/uDZ2+RcVzq5BfnG+bQ3/6uu9DGwCrGsPtjJ1A= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= diff --git a/handlers/slot.go b/handlers/slot.go index 1367b6f..52d0982 100644 --- a/handlers/slot.go +++ b/handlers/slot.go @@ -725,9 +725,9 @@ 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.DepositRequests) - getSlotPageWithdrawalRequests(pageData, requests.WithdrawalRequests) - getSlotPageConsolidationRequests(pageData, requests.ConsolidationRequests) + getSlotPageDepositRequests(pageData, requests.Deposits) + getSlotPageWithdrawalRequests(pageData, requests.Withdrawals) + getSlotPageConsolidationRequests(pageData, requests.Consolidations) } } diff --git a/indexer/beacon/writedb.go b/indexer/beacon/writedb.go index b20bea0..0dcba97 100644 --- a/indexer/beacon/writedb.go +++ b/indexer/beacon/writedb.go @@ -490,7 +490,7 @@ func (dbw *dbWriter) buildDbDepositRequests(block *Block, orphaned bool, overrid return nil } - deposits := requests.DepositRequests + deposits := requests.Deposits dbDeposits := make([]*dbtypes.Deposit, len(deposits)) for idx, deposit := range deposits { @@ -680,7 +680,7 @@ func (dbw *dbWriter) buildDbConsolidationRequests(block *Block, orphaned bool, o return nil } - consolidations := requests.ConsolidationRequests + consolidations := requests.Consolidations if len(consolidations) == 0 { return []*dbtypes.ConsolidationRequest{} @@ -745,7 +745,7 @@ func (dbw *dbWriter) buildDbWithdrawalRequests(block *Block, orphaned bool, over return nil } - withdrawalRequests := requests.WithdrawalRequests + withdrawalRequests := requests.Withdrawals if len(withdrawalRequests) == 0 { return []*dbtypes.WithdrawalRequest{} From 5fcb8abfd8df9ece651775bfaa57578684807579 Mon Sep 17 00:00:00 2001 From: pk910 Date: Mon, 14 Oct 2024 21:53:11 +0200 Subject: [PATCH 4/4] cleanup override --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index babdf4c..6d0d258 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/pk910/go-eth2-client v0.0.0-20241004214539-f6f806861d96 +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 2c8bd57..8b3dc3a 100644 --- a/go.sum +++ b/go.sum @@ -16,6 +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-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= @@ -319,8 +321,6 @@ github.com/onsi/gomega v1.18.1 h1:M1GfJqGRrBrrGGsbxzV5dqM2U2ApXefZCQpkukxYRLE= github.com/onsi/gomega v1.18.1/go.mod h1:0q+aL8jAiMXy9hbwj2mr5GziHiwhAIQpFmmtT5hitRs= github.com/pk910/dynamic-ssz v0.0.5 h1:VP9heGYUwzlpyhk28P2nCAzhvGsePJOOOO5vQMDh2qQ= github.com/pk910/dynamic-ssz v0.0.5/go.mod h1:b6CrLaB2X7pYA+OSEEbkgXDEcRnjLOZIxZTsMuO/Y9c= -github.com/pk910/go-eth2-client v0.0.0-20241004214539-f6f806861d96 h1:I6qQcQtxwafsolKI5pj3gbRn1kc05Tq1571gxPG1/c8= -github.com/pk910/go-eth2-client v0.0.0-20241004214539-f6f806861d96/go.mod h1:vy5jU/uDZ2+RcVzq5BfnG+bQ3/6uu9DGwCrGsPtjJ1A= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=