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

Verkle support #56

Draft
wants to merge 32 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
ba940db
add verkle fork version in index + replace dependency
gballet Oct 20, 2023
02c89eb
use kaustinen-with-shapella
gballet Oct 20, 2023
b7d6a7f
update go-eth2-client to latest kaustinen-with-shapella
gballet Oct 20, 2023
9e9aab7
added electra fork tag
pk910 Oct 20, 2023
b3b05ef
replace go-eth2-client
pk910 Oct 20, 2023
692a22a
enable Eth Data display on the slot page for verkle blocks
gballet Nov 2, 2023
6a5ca9b
Add a "stateless tab" to display ExecutionWitness data
gballet Nov 2, 2023
bcf099a
register stateless template
gballet Nov 3, 2023
d3bd381
fix missing intermediate member field
gballet Nov 3, 2023
454927d
get go-eth2-client with fixed JSON deserializatoin
gballet Nov 3, 2023
7a0cb36
update to latest go-eth2-client replacement
gballet Nov 6, 2023
38a3a8d
ensure hex numbers are all displayed in proven location table
gballet Nov 6, 2023
b0a93b2
add div to display the pretree
gballet Nov 6, 2023
06ba407
fix stacktrace: replace ' with "
gballet Nov 6, 2023
00840ab
fix alignment in key table
gballet Nov 6, 2023
8c57703
Merge remote-tracking branch 'origin-pk910/master' into verkle-support
pk910 Nov 21, 2023
63a0b53
update go.mod replacement
pk910 Nov 21, 2023
b36ba55
Merge remote-tracking branch 'origin-pk910/master' into verkle-suppor…
pk910 Nov 21, 2023
08c4451
Merge remote-tracking branch 'origin/execution-witness-data' into ver…
pk910 Nov 21, 2023
fba43d2
update dependency replacement
pk910 Nov 21, 2023
ffd0c3e
update `go-eth2-client` replacement
pk910 Nov 23, 2023
acad91f
force JSON requests as SSZ parsing is broken
pk910 Nov 24, 2023
ca0158e
Merge branch 'master' into electra-support
pk910 Nov 24, 2023
aa66e8a
Merge remote-tracking branch 'origin-pk910/master' into verkle-support
pk910 Nov 30, 2023
38d5e27
Merge remote-tracking branch 'origin-pk910/master' into verkle-support
pk910 Dec 15, 2023
38c5343
Merge remote-tracking branch 'origin-pk910/master' into verkle-support
pk910 Dec 15, 2023
2890b58
update go-eth2-client replacement
pk910 Dec 17, 2023
b71aec4
Merge branch 'verkle-support' into verkle-support
pk910 Apr 8, 2024
41f63fe
Merge pull request #37 from gballet/verkle-support
pk910 Apr 8, 2024
704e623
bump `go-eth2-client` & use SSZ encoding again (with dynamic SSZ lib)
pk910 Apr 9, 2024
fb66196
Merge branch 'master' into verkle-support
pk910 Jun 18, 2024
5f5475d
bump `go-eth2-client` override
pk910 Nov 1, 2024
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: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down Expand Up @@ -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=
Expand Down
8 changes: 8 additions & 0 deletions handlers/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
29 changes: 29 additions & 0 deletions handlers/slot.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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)
}
}

Expand Down
17 changes: 17 additions & 0 deletions indexer/ssz_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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")
}
Expand Down Expand Up @@ -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")
}
Expand All @@ -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")
}
Expand Down Expand Up @@ -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")
}
Expand Down
2 changes: 1 addition & 1 deletion rpc/beaconapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
26 changes: 25 additions & 1 deletion templates/slot/slot.html
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ <h1 class="h4 my-2 mb-md-0 h1-pager">
<a class="nav-link" id="blobSidecars-tab" data-bs-toggle="tab" href="#blobSidecars" role="tab" aria-controls="blobSidecars" aria-selected="false">Blob Sidecars <span class="badge bg-secondary text-white">{{ .Block.BlobsCount }}</span></a>
</li>
{{ end }}
{{ if .Block.ExecutionWitness }}
<li class="nav-item">
<a class="nav-link" id="deposits-tab" data-bs-toggle="tab" href="#stateless" role="tab" aria-controls="stateless" aria-selected="false">Stateless</a>
</li>
{{ end }}
{{ end }}
</ul>

Expand Down Expand Up @@ -205,7 +210,26 @@ <h3 class="h5 col-md-12 text-center"><b>Showing {{ .Block.BlobsCount }} Blob sid
{{ template "block_blobSidecar" . }}
</div>
{{ end }}

{{ if .Block.ExecutionWitness }}
<div class="tab-pane fade show active" id="stateless" role="tabpanel" aria-labelledby="stateless-tab">
<div class="card block-card">
<div style="margin-bottom: -.25rem;" class="card-body px-0 py-1">
<div class="row p-1 mx-0">
<h3 class="h5 col-md-12 text-center"><b>Showing Proven Locations</b></h3>
</div>
</div>
{{ template "block_execution_witness" . }}
</div>
<div class="card block-card">
<div style="margin-bottom: -.25rem;" class="card-body px-0 py-1">
<div class="row p-1 mx-0">
<h3 class="h5 col-md-12 text-center"><b>Reconstructed tree</b></h3>
</div>
</div>
{{ template "block_execution_pretree" . }}
</div>
</div>
{{ end }}
{{ end }}
</div>
<script type="text/javascript">
Expand Down
44 changes: 44 additions & 0 deletions templates/slot/stateless.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{{ define "block_execution_witness" }}
<div class="table">
<table id="block_witness" class="table table-sm text-left">
<thead>
<tr>
<th class="border-0">Stem</th>
<th class="border-0">Suffix</th>
<th class="border-0">Current Value</th>
<th class="border-0">New Value</th>
</tr>
</thead>
<tbody style="word-break: break-all;">
{{ range $i, $statediff := .Block.ExecutionWitness.Witness.StateDiff }}
{{ range $j, $suffixdiff := $statediff.SuffixDiffs }}
<tr>
<td>{{ printf "%#x" $statediff.Stem }}</td>
<td>{{ printf "%#02x" $suffixdiff.Suffix }}</td>
<td>
{{ if $suffixdiff.CurrentValue }}
{{ printf "%#x" $suffixdiff.CurrentValue }}
{{ else }}
absent
{{ end }}
</td>
<td>
{{ if $suffixdiff.NewValue }}
{{ printf "%#x" $suffixdiff.NewValue }}
{{ else }}
unchanged
{{ end }}
</td>
</tr>
{{ end }}
{{ end }}
</tbody>
</table>
</div>
{{ end }}

{{ define "block_execution_pretree" }}
<div class="table">
{{ .Block.ExecutionWitness.Witness.VerkleProof }}
</div>
{{ end }}
4 changes: 2 additions & 2 deletions types/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ type ChainConfig struct {
CappellaForkEpoch uint64 `yaml:"CAPELLA_FORK_EPOCH"`
DenebForkVersion string `yaml:"DENEB_FORK_VERSION"`
DenebForkEpoch uint64 `yaml:"DENEB_FORK_EPOCH"`
ShardingForkVersion string `yaml:"SHARDING_FORK_VERSION"`
ShardingForkEpoch uint64 `yaml:"SHARDING_FORK_EPOCH"`
ElectraForkVersion string `yaml:"ELECTRA_FORK_VERSION"`
ElectraForkEpoch uint64 `yaml:"ELECTRA_FORK_EPOCH"`
SecondsPerSlot uint64 `yaml:"SECONDS_PER_SLOT"`
SecondsPerEth1Block uint64 `yaml:"SECONDS_PER_ETH1_BLOCK"`
MinValidatorWithdrawabilityDelay uint64 `yaml:"MIN_VALIDATOR_WITHDRAWABILITY_DELAY"`
Expand Down
6 changes: 6 additions & 0 deletions types/models/slot.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package models
import (
"time"

"github.com/attestantio/go-eth2-client/spec/verkle"
"github.com/ethpandaops/dora/types"
)

Expand Down Expand Up @@ -75,6 +76,7 @@ type SlotPageBlockData struct {
Withdrawals []*SlotPageWithdrawal `json:"withdrawals"` // Withdrawals included in this block
Blobs []*SlotPageBlob `json:"blobs"` // Blob sidecars included in this block
Transactions []*SlotPageTransaction `json:"transactions"` // Transactions included in this block
ExecutionWitness *SlotPageExecutionWitness `json:"executionWitness"`
}

type SlotPageExecutionData struct {
Expand Down Expand Up @@ -210,3 +212,7 @@ type SlotPageTransaction struct {
FuncSig string `json:"func_sig"`
Type uint64 `json:"type"`
}

type SlotPageExecutionWitness struct {
Witness *verkle.ExecutionWitness `json:"execution_witness"`
}
Loading