diff --git a/go.mod b/go.mod index ef477c2f..3e3761e7 100644 --- a/go.mod +++ b/go.mod @@ -130,3 +130,5 @@ require ( modernc.org/sqlite v1.29.6 // indirect rsc.io/tmplfunc v0.0.3 // indirect ) + +replace github.com/attestantio/go-eth2-client => github.com/pk910/go-eth2-client v0.0.0-20241101224015-0837d3e033e9 diff --git a/go.sum b/go.sum index c13d3642..3550b7ae 100644 --- a/go.sum +++ b/go.sum @@ -13,8 +13,6 @@ github.com/StackExchange/wmi v1.2.1 h1:VIkavFPXSjcnS+O8yTq7NI32k0R5Aj+v39y29VYDO github.com/StackExchange/wmi v1.2.1/go.mod h1:rcmrprowKIVzvc+NUiLncP2uuArMWLCbu9SBzvHz7e8= github.com/VictoriaMetrics/fastcache v1.12.1 h1:i0mICQuojGDL3KblA7wUNlY5lOK6a4bwt3uRKnkZU40= github.com/VictoriaMetrics/fastcache v1.12.1/go.mod h1:tX04vaqcNoQeGLD+ra5pU5sWkuxnzWhEzLwhP9w653o= -github.com/attestantio/go-eth2-client v0.21.6 h1:eLhQ/OFHPhWrT7LYERL1Z6EPOoec6fJeDHsjjn73KBg= -github.com/attestantio/go-eth2-client v0.21.6/go.mod h1:d7ZPNrMX8jLfIgML5u7QZxFo2AukLM+5m08iMaLdqb8= github.com/aws/aws-sdk-go-v2 v1.26.1 h1:5554eUqIYVWpU0YmeeYZ0wU64H2VLBs8TlhRB2L+EkA= github.com/aws/aws-sdk-go-v2 v1.26.1/go.mod h1:ffIFB97e2yNsv4aTSGkqtHnppsIJzw7G7BReUZ3jCXM= github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.2 h1:x6xsQXGSmW6frevwDA+vi/wqhp1ct18mVXYN08/93to= @@ -328,6 +326,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.3 h1:fCWzFowq9P6SYCc7NtJMkZcIHk+r5hSVD+32zVi6Aio= github.com/pk910/dynamic-ssz v0.0.3/go.mod h1:b6CrLaB2X7pYA+OSEEbkgXDEcRnjLOZIxZTsMuO/Y9c= +github.com/pk910/go-eth2-client v0.0.0-20241101224015-0837d3e033e9 h1:SxX3azMJaul5c2EUtQXF2baEWl8IqMi92E/91Z9DwlY= +github.com/pk910/go-eth2-client v0.0.0-20241101224015-0837d3e033e9/go.mod h1:VdkMTum681ZufpSSYxCuui8KFiB7YOpXtiNJ5kTHosA= 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/index.go b/handlers/index.go index 5b4e8b96..8542c0da 100644 --- a/handlers/index.go +++ b/handlers/index.go @@ -198,6 +198,14 @@ func buildIndexPageData() (*models.IndexPageData, time.Duration) { Active: uint64(currentEpoch) >= utils.Config.Chain.Config.DenebForkEpoch, }) } + if utils.Config.Chain.Config.ElectraForkEpoch < uint64(18446744073709551615) && utils.Config.Chain.Config.ElectraForkVersion != "" { + pageData.NetworkForks = append(pageData.NetworkForks, &models.IndexPageDataForks{ + Name: "Electra", + Epoch: utils.Config.Chain.Config.ElectraForkEpoch, + Version: utils.MustParseHex(utils.Config.Chain.Config.ElectraForkVersion), + Active: uint64(currentEpoch) >= utils.Config.Chain.Config.ElectraForkEpoch, + }) + } // load recent epochs buildIndexPageRecentEpochsData(pageData, uint64(currentEpoch), finalizedEpoch, justifiedEpoch, recentEpochCount) diff --git a/handlers/slot.go b/handlers/slot.go index 131e1888..07662944 100644 --- a/handlers/slot.go +++ b/handlers/slot.go @@ -41,6 +41,7 @@ func Slot(w http.ResponseWriter, r *http.Request) { "slot/voluntary_exits.html", "slot/slashings.html", "slot/blobs.html", + "slot/stateless.html", ) var notfoundTemplateFiles = append(layoutTemplateFiles, "slot/notfound.html", @@ -576,6 +577,34 @@ func getSlotPageBlockData(blockData *services.CombinedBlockResponse, assignments BlockNumber: uint64(executionPayload.BlockNumber), } getSlotPageTransactions(pageData, executionPayload.Transactions) + case spec.DataVersionVerkle: + if blockData.Block.Verkle == nil { + break + } + executionPayload := blockData.Block.Verkle.Message.Body.ExecutionPayload + var baseFeePerGasBEBytes [32]byte + for i := 0; i < 32; i++ { + baseFeePerGasBEBytes[i] = executionPayload.BaseFeePerGas[32-1-i] + } + baseFeePerGas := new(big.Int).SetBytes(baseFeePerGasBEBytes[:]) + pageData.ExecutionData = &models.SlotPageExecutionData{ + ParentHash: executionPayload.ParentHash[:], + FeeRecipient: executionPayload.FeeRecipient[:], + StateRoot: executionPayload.StateRoot[:], + ReceiptsRoot: executionPayload.ReceiptsRoot[:], + LogsBloom: executionPayload.LogsBloom[:], + Random: executionPayload.PrevRandao[:], + GasLimit: uint64(executionPayload.GasLimit), + GasUsed: uint64(executionPayload.GasUsed), + Timestamp: uint64(executionPayload.Timestamp), + Time: time.Unix(int64(executionPayload.Timestamp), 0), + ExtraData: executionPayload.ExtraData, + BaseFeePerGas: baseFeePerGas.Uint64(), + BlockHash: executionPayload.BlockHash[:], + BlockNumber: uint64(executionPayload.BlockNumber), + } + pageData.ExecutionWitness = &models.SlotPageExecutionWitness{Witness: executionPayload.ExecutionWitness} + getSlotPageTransactions(pageData, executionPayload.Transactions) } } diff --git a/indexer/ssz_helper.go b/indexer/ssz_helper.go index 4c787605..e2e7e57f 100644 --- a/indexer/ssz_helper.go +++ b/indexer/ssz_helper.go @@ -9,6 +9,7 @@ import ( "github.com/attestantio/go-eth2-client/spec/capella" "github.com/attestantio/go-eth2-client/spec/deneb" "github.com/attestantio/go-eth2-client/spec/phase0" + "github.com/attestantio/go-eth2-client/spec/verkle" "github.com/ethpandaops/dora/utils" dynssz "github.com/pk910/dynamic-ssz" "gopkg.in/yaml.v3" @@ -54,6 +55,9 @@ func MarshalVersionedSignedBeaconBlockSSZ(block *spec.VersionedSignedBeaconBlock case spec.DataVersionDeneb: version = uint64(block.Version) ssz, err = dynSsz.MarshalSSZ(block.Deneb) + case spec.DataVersionVerkle: + version = uint64(block.Version) + ssz, err = dynSsz.MarshalSSZ(block.Verkle) default: err = fmt.Errorf("unknown block version") } @@ -95,6 +99,11 @@ func UnmarshalVersionedSignedBeaconBlockSSZ(version uint64, ssz []byte) (*spec.V if err := dynSsz.UnmarshalSSZ(block.Deneb, ssz); err != nil { return nil, fmt.Errorf("failed to decode deneb signed beacon block: %v", err) } + case spec.DataVersionVerkle: + block.Verkle = &verkle.SignedBeaconBlock{} + if err := block.Verkle.UnmarshalSSZ(ssz); err != nil { + return nil, fmt.Errorf("failed to decode verkle signed beacon block: %v", err) + } default: return nil, fmt.Errorf("unknown block version") } @@ -118,6 +127,9 @@ func marshalVersionedSignedBeaconBlockJson(block *spec.VersionedSignedBeaconBloc case spec.DataVersionDeneb: version = uint64(block.Version) + jsonVersionOffset jsonRes, err = block.Deneb.MarshalJSON() + case spec.DataVersionVerkle: + version = uint64(block.Version) + jsonVersionOffset + jsonRes, err = block.Verkle.MarshalJSON() default: err = fmt.Errorf("unknown block version") } @@ -157,6 +169,11 @@ func unmarshalVersionedSignedBeaconBlockJson(version uint64, ssz []byte) (*spec. if err := block.Deneb.UnmarshalJSON(ssz); err != nil { return nil, fmt.Errorf("failed to decode deneb signed beacon block: %v", err) } + case spec.DataVersionVerkle: + block.Verkle = &verkle.SignedBeaconBlock{} + if err := block.Verkle.UnmarshalJSON(ssz); err != nil { + return nil, fmt.Errorf("failed to decode verkle signed beacon block: %v", err) + } default: return nil, fmt.Errorf("unknown block version") } diff --git a/rpc/beaconapi.go b/rpc/beaconapi.go index 9f6cf6e2..047f681e 100644 --- a/rpc/beaconapi.go +++ b/rpc/beaconapi.go @@ -149,7 +149,7 @@ func (bc *BeaconClient) Initialize() error { http.WithTimeout(10 * time.Minute), // TODO (when upstream PR is merged) //http.WithConnectionCheck(false), - http.WithCustomSpecSupport(true), + http.WithDynamicSSZ(true), } // set log level diff --git a/templates/slot/slot.html b/templates/slot/slot.html index a19a81c2..c3178fe3 100644 --- a/templates/slot/slot.html +++ b/templates/slot/slot.html @@ -81,6 +81,11 @@

Blob Sidecars {{ .Block.BlobsCount }} {{ end }} + {{ if .Block.ExecutionWitness }} + + {{ end }} {{ end }} @@ -205,7 +210,26 @@

Showing {{ .Block.BlobsCount }} Blob sid {{ template "block_blobSidecar" . }} {{ end }} - + {{ if .Block.ExecutionWitness }} +
+
+
+
+

Showing Proven Locations

+
+
+ {{ template "block_execution_witness" . }} +
+
+
+
+

Reconstructed tree

+
+
+ {{ template "block_execution_pretree" . }} +
+
+ {{ end }} {{ end }}