Skip to content

Commit

Permalink
Merge branch 'master' into pk910/validators-in-db
Browse files Browse the repository at this point in the history
  • Loading branch information
pk910 committed Feb 13, 2025
2 parents 2b482e6 + 63802c1 commit 8f0c771
Show file tree
Hide file tree
Showing 22 changed files with 400 additions and 264 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/check-typos.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Check typos

on:
pull_request:
branches:
- master

jobs:
check-typos:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Check for typos
uses: crate-ci/[email protected]

9 changes: 9 additions & 0 deletions _typos.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

[files]
extend-exclude = ["static/**/*","ui-package/node_modules/**/*", "ui-package/dist/*", "go.mod", "go.sum"]

[default]
check-filename = false

[default.extend-words]
CoSE = "CoSE"
2 changes: 1 addition & 1 deletion clients/execution/clientlogic.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func (client *Client) checkClient() error {
client.logger.Warnf("error updating node peers: %v", err)
}

// get & comare chain specs
// get & compare chain specs
specs, err := client.rpcClient.GetChainSpec(ctx)
if err != nil {
return fmt.Errorf("error while fetching specs: %v", err)
Expand Down
8 changes: 4 additions & 4 deletions db/txsignatures.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ func InsertTxFunctionSignature(txFuncSig *dbtypes.TxFunctionSignature, tx *sqlx.
}

func GetUnknownFunctionSignatures(sigBytes []types.TxSignatureBytes) []*dbtypes.TxUnknownFunctionSignature {
unknwonFnSigs := []*dbtypes.TxUnknownFunctionSignature{}
unknownFnSigs := []*dbtypes.TxUnknownFunctionSignature{}
if len(sigBytes) == 0 {
return unknwonFnSigs
return unknownFnSigs
}
var sql strings.Builder
fmt.Fprintf(&sql, `
Expand All @@ -79,12 +79,12 @@ func GetUnknownFunctionSignatures(sigBytes []types.TxSignatureBytes) []*dbtypes.
argIdx += 1
}
fmt.Fprintf(&sql, ")")
err := ReaderDb.Select(&unknwonFnSigs, sql.String(), args...)
err := ReaderDb.Select(&unknownFnSigs, sql.String(), args...)
if err != nil {
logger.Errorf("Error while fetching unknown function signatures: %v", err)
return nil
}
return unknwonFnSigs
return unknownFnSigs
}

func InsertUnknownFunctionSignatures(txUnknownSigs []*dbtypes.TxUnknownFunctionSignature, tx *sqlx.Tx) error {
Expand Down
12 changes: 6 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ toolchain go1.22.5
require (
github.com/520MianXiangDuiXiang520/MapSize v0.0.0-20230414174449-030467540731
github.com/Masterminds/sprig/v3 v3.3.0
github.com/attestantio/go-eth2-client v0.0.0-20250205171128-0c99cbcafc0b
github.com/attestantio/go-eth2-client v0.24.0
github.com/coocood/freecache v1.2.4
github.com/ethereum/go-ethereum v1.14.7
github.com/ethpandaops/ethwallclock v0.3.0
Expand Down Expand Up @@ -35,10 +35,10 @@ require (
github.com/tdewolff/minify v2.3.6+incompatible
github.com/timandy/routine v1.1.4
github.com/urfave/negroni v1.0.0
golang.org/x/crypto v0.32.0
golang.org/x/crypto v0.33.0
golang.org/x/exp v0.0.0-20240808152545-0cdaa3abc0fa
golang.org/x/text v0.21.0
golang.org/x/time v0.9.0
golang.org/x/text v0.22.0
golang.org/x/time v0.10.0
gopkg.in/yaml.v3 v3.0.1
)

Expand Down Expand Up @@ -139,8 +139,8 @@ require (
go.opentelemetry.io/otel/trace v1.29.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/net v0.33.0 // indirect
golang.org/x/sync v0.10.0 // indirect
golang.org/x/sys v0.29.0 // indirect
golang.org/x/sync v0.11.0 // indirect
golang.org/x/sys v0.30.0 // indirect
golang.org/x/xerrors v0.0.0-20240903120638-7835f813f4da // indirect
google.golang.org/protobuf v1.35.1 // indirect
gopkg.in/Knetic/govaluate.v3 v3.0.0
Expand Down
28 changes: 14 additions & 14 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,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-20250205171128-0c99cbcafc0b h1:XZUyt8cU6wMRnfqaafA+EQOOG8rPsm+vTeYA8V9yC/c=
github.com/attestantio/go-eth2-client v0.0.0-20250205171128-0c99cbcafc0b/go.mod h1:/KTLN3WuH1xrJL7ZZrpBoWM1xCCihnFbzequD5L+83o=
github.com/attestantio/go-eth2-client v0.24.0 h1:lGVbcnhlBwRglt1Zs56JOCgXVyLWKFZOmZN8jKhE7Ws=
github.com/attestantio/go-eth2-client v0.24.0/go.mod h1:/KTLN3WuH1xrJL7ZZrpBoWM1xCCihnFbzequD5L+83o=
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.17.0 h1:1X2TS7aHz1ELcC0yU1y2stUs/0ig5oMU6STFZGrhvHI=
Expand Down Expand Up @@ -494,8 +494,8 @@ golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5y
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
golang.org/x/crypto v0.20.0/go.mod h1:Xwo95rrVNIoSMx9wa1JroENMToLWn3RNVrTBpLHgZPQ=
golang.org/x/crypto v0.32.0 h1:euUpcYgM8WcP71gNpTqQCn6rC2t6ULUPiOzfWaXVVfc=
golang.org/x/crypto v0.32.0/go.mod h1:ZnnJkOaASj8g0AjIduWNlq2NRxL0PlBrbKVyZ6V/Ugc=
golang.org/x/crypto v0.33.0 h1:IOBPskki6Lysi0lo9qQvbxiQ+FvsCC/YWOecCHAixus=
golang.org/x/crypto v0.33.0/go.mod h1:bVdXmD7IV/4GdElGPozy6U7lWdRXA4qyRVGJV57uQ5M=
golang.org/x/exp v0.0.0-20240808152545-0cdaa3abc0fa h1:ELnwvuAXPNtPk1TJRuGkI9fDTwym6AYBu0qzT8AcHdI=
golang.org/x/exp v0.0.0-20240808152545-0cdaa3abc0fa/go.mod h1:akd2r19cwCdwSwWeIdzYQGa/EZZyqcOdwWiwj5L5eKQ=
golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
Expand Down Expand Up @@ -525,8 +525,8 @@ golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJ
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ=
golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sync v0.11.0 h1:GGz8+XQP4FvTTrjZPzNKTMFtSXH80RAzG+5ghFPgK9w=
golang.org/x/sync v0.11.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190130150945-aca44879d564/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
Expand Down Expand Up @@ -559,16 +559,16 @@ golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU=
golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc=
golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo=
golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk=
golang.org/x/term v0.28.0 h1:/Ts8HFuMR2E6IP/jlo7QVLZHggjKQbhu/7H0LJFr3Gg=
golang.org/x/term v0.28.0/go.mod h1:Sw/lC2IAUZ92udQNf3WodGtn4k/XoLyZoh8v/8uiwek=
golang.org/x/term v0.29.0 h1:L6pJp37ocefwRRtYPKSWOWzOtWSxVajvz2ldH/xi3iU=
golang.org/x/term v0.29.0/go.mod h1:6bl4lRlvVuDgSf3179VpIxBF0o10JUpXWOnI7nErv7s=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
Expand All @@ -578,10 +578,10 @@ golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo=
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
golang.org/x/time v0.9.0 h1:EsRrnYcQiGH+5FfbgvV4AP7qEZstoyrHB0DzarOQ4ZY=
golang.org/x/time v0.9.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
golang.org/x/text v0.22.0 h1:bofq7m3/HAFvbF51jz3Q9wLg3jkvSPuiZu/pD1XwgtM=
golang.org/x/text v0.22.0/go.mod h1:YRoo4H8PVmsu+E3Ou7cqLVH8oXWIHVoX0jqUWALQhfY=
golang.org/x/time v0.10.0 h1:3usCWA8tQn0L8+hFJQNgzpWbd89begxN66o1Ojdn5L4=
golang.org/x/time v0.10.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20190425163242-31fd60d6bfdc/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
Expand Down
12 changes: 6 additions & 6 deletions handlers/clients_cl.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ func buildCLClientsPageData() (*models.ClientsCLPageData, time.Duration) {
PeerDASInfos: &models.ClientCLPagePeerDAS{
Warnings: models.ClientCLPageDataPeerDASWarnings{
MissingENRsPeers: []string{},
MissingCSCFromENRPeers: []string{},
MissingCGCFromENRPeers: []string{},
EmptyColumns: []uint64{},
},
},
Expand Down Expand Up @@ -416,15 +416,15 @@ func buildCLClientsPageData() (*models.ClientsCLPageData, time.Duration) {

custodySubnetCount := pageData.PeerDASInfos.CustodyRequirement

if cscHex, ok := enrValues["csc"]; ok {
val, err := strconv.ParseUint(cscHex.(string), 0, 64)
if cgcHex, ok := enrValues["cgc"]; ok {
val, err := strconv.ParseUint(cgcHex.(string), 0, 64)
if err != nil {
logrus.WithFields(logrus.Fields{"node": v.Alias, "peer_id": v.PeerID, "csc": cscHex.(string)}).Error("failed to decode csc. ", err)
logrus.WithFields(logrus.Fields{"node": v.Alias, "peer_id": v.PeerID, "cgc": cgcHex.(string)}).Error("failed to decode cgc. ", err)
} else {
custodySubnetCount = val
}
} else {
pageData.PeerDASInfos.Warnings.MissingCSCFromENRPeers = append(pageData.PeerDASInfos.Warnings.MissingCSCFromENRPeers, v.PeerID)
pageData.PeerDASInfos.Warnings.MissingCGCFromENRPeers = append(pageData.PeerDASInfos.Warnings.MissingCGCFromENRPeers, v.PeerID)
pageData.PeerDASInfos.Warnings.HasWarnings = true
}

Expand All @@ -450,7 +450,7 @@ func buildCLClientsPageData() (*models.ClientsCLPageData, time.Duration) {
peerDASInfo := models.ClientCLPageDataNodePeerDAS{
Columns: resColumns,
Subnets: resSubnets,
CSC: custodySubnetCount,
CGC: custodySubnetCount,
IsSuperNode: uint64(len(resColumns)) == pageData.PeerDASInfos.NumberOfColumns,
}
v.PeerDAS = &peerDASInfo
Expand Down
95 changes: 86 additions & 9 deletions handlers/slot.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,21 @@ func Slot(w http.ResponseWriter, r *http.Request) {
}
}

urlArgs := r.URL.Query()
if pageError := services.GlobalCallRateLimiter.CheckCallLimit(r, 1); pageError != nil {
handlePageError(w, r, pageError)
return
}

var pageData *models.SlotPageData
var pageError error
pageError = services.GlobalCallRateLimiter.CheckCallLimit(r, 1)
if pageError == nil {
pageData, pageError = getSlotPageData(blockSlot, blockRootHash)
urlArgs := r.URL.Query()
if urlArgs.Has("download") {
if err := handleSlotDownload(r.Context(), w, blockSlot, blockRootHash, urlArgs.Get("download")); err != nil {
http.Error(w, err.Error(), http.StatusBadRequest)
return
}
return
}

pageData, pageError := getSlotPageData(blockSlot, blockRootHash)
if pageError != nil {
handlePageError(w, r, pageError)
return
Expand Down Expand Up @@ -734,12 +741,12 @@ func getSlotPageBlockData(blockData *services.CombinedBlockResponse, epochStatsV
return pageData
}

func getSlotPageTransactions(pageData *models.SlotPageBlockData, tranactions []bellatrix.Transaction) {
func getSlotPageTransactions(pageData *models.SlotPageBlockData, transactions []bellatrix.Transaction) {
pageData.Transactions = make([]*models.SlotPageTransaction, 0)
sigLookupBytes := []types.TxSignatureBytes{}
sigLookupMap := map[types.TxSignatureBytes][]*models.SlotPageTransaction{}

for idx, txBytes := range tranactions {
for idx, txBytes := range transactions {
var tx ethtypes.Transaction

err := tx.UnmarshalBinary(txBytes)
Expand Down Expand Up @@ -793,7 +800,7 @@ func getSlotPageTransactions(pageData *models.SlotPageBlockData, tranactions []b
txData.FuncName = "transfer"
}
}
pageData.TransactionsCount = uint64(len(tranactions))
pageData.TransactionsCount = uint64(len(transactions))

if len(sigLookupBytes) > 0 {
sigLookups := services.GlobalTxSignaturesService.LookupSignatures(sigLookupBytes)
Expand Down Expand Up @@ -885,3 +892,73 @@ func getSlotPageConsolidationRequests(pageData *models.SlotPageBlockData, consol

pageData.ConsolidationRequestsCount = uint64(len(pageData.ConsolidationRequests))
}

func handleSlotDownload(ctx context.Context, w http.ResponseWriter, blockSlot int64, blockRoot []byte, downloadType string) error {
chainState := services.GlobalBeaconService.GetChainState()
currentSlot := chainState.CurrentSlot()
var blockData *services.CombinedBlockResponse
var err error
if blockSlot > -1 {
if phase0.Slot(blockSlot) <= currentSlot {
blockData, err = services.GlobalBeaconService.GetSlotDetailsBySlot(ctx, phase0.Slot(blockSlot))
}
} else {
blockData, err = services.GlobalBeaconService.GetSlotDetailsByBlockroot(ctx, phase0.Root(blockRoot))
}

if err != nil {
return fmt.Errorf("error getting block data: %v", err)
}

if blockData == nil || blockData.Block == nil {
return fmt.Errorf("block not found")
}

switch downloadType {
case "block-ssz":
w.Header().Set("Content-Type", "application/octet-stream")
w.Header().Set("Content-Disposition", fmt.Sprintf("attachment; filename=block-%d-%x.ssz", blockData.Header.Message.Slot, blockData.Root[:]))

dynSsz := services.GlobalBeaconService.GetBeaconIndexer().GetDynSSZ()
_, blockSSZ, err := beacon.MarshalVersionedSignedBeaconBlockSSZ(dynSsz, blockData.Block, false, true)
if err != nil {
return fmt.Errorf("error serializing block: %v", err)
}
w.Write(blockSSZ)
return nil

case "block-json":
w.Header().Set("Content-Type", "application/json")
w.Header().Set("Content-Disposition", fmt.Sprintf("attachment; filename=block-%d-%x.json", blockData.Header.Message.Slot, blockData.Root[:]))

_, jsonRes, err := beacon.MarshalVersionedSignedBeaconBlockJson(blockData.Block)
if err != nil {
return fmt.Errorf("error serializing block: %v", err)
}
w.Write(jsonRes)
return nil

case "header-ssz":
w.Header().Set("Content-Type", "application/octet-stream")
w.Header().Set("Content-Disposition", fmt.Sprintf("attachment; filename=header-%d-%x.ssz", blockData.Header.Message.Slot, blockData.Root[:]))
headerSSZ, err := blockData.Header.MarshalSSZ()
if err != nil {
return fmt.Errorf("error serializing header: %v", err)
}
w.Write(headerSSZ)
return nil

case "header-json":
w.Header().Set("Content-Type", "application/json")
w.Header().Set("Content-Disposition", fmt.Sprintf("attachment; filename=header-%d-%x.json", blockData.Header.Message.Slot, blockData.Root[:]))
jsonRes, err := blockData.Header.MarshalJSON()
if err != nil {
return fmt.Errorf("error serializing header: %v", err)
}
w.Write(jsonRes)
return nil

default:
return fmt.Errorf("unknown download type: %s", downloadType)
}
}
6 changes: 3 additions & 3 deletions indexer/beacon/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ type Block struct {
processedActivity uint8
}

// BlockBodyIndex holds important block propoerties that are used as index for cache lookups.
// BlockBodyIndex holds important block properties that are used as index for cache lookups.
// this structure should be preserved after pruning, so the block is still identifiable.
type BlockBodyIndex struct {
Graffiti [32]byte
Expand Down Expand Up @@ -317,7 +317,7 @@ func (block *Block) buildUnfinalizedBlock(compress bool) (*dbtypes.UnfinalizedBl
return nil, fmt.Errorf("marshal header ssz failed: %v", err)
}

blockVer, blockSSZ, err := marshalVersionedSignedBeaconBlockSSZ(block.dynSsz, block.GetBlock(), compress)
blockVer, blockSSZ, err := MarshalVersionedSignedBeaconBlockSSZ(block.dynSsz, block.GetBlock(), compress, false)
if err != nil {
return nil, fmt.Errorf("marshal block ssz failed: %v", err)
}
Expand Down Expand Up @@ -345,7 +345,7 @@ func (block *Block) buildOrphanedBlock(compress bool) (*dbtypes.OrphanedBlock, e
return nil, fmt.Errorf("marshal header ssz failed: %v", err)
}

blockVer, blockSSZ, err := marshalVersionedSignedBeaconBlockSSZ(block.dynSsz, block.GetBlock(), compress)
blockVer, blockSSZ, err := MarshalVersionedSignedBeaconBlockSSZ(block.dynSsz, block.GetBlock(), compress, false)
if err != nil {
return nil, fmt.Errorf("marshal block ssz failed: %v", err)
}
Expand Down
12 changes: 6 additions & 6 deletions indexer/beacon/block_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ import (
var jsonVersionFlag uint64 = 0x40000000
var compressionFlag uint64 = 0x20000000

// marshalVersionedSignedBeaconBlockSSZ marshals a versioned signed beacon block using SSZ encoding.
func marshalVersionedSignedBeaconBlockSSZ(dynSsz *dynssz.DynSsz, block *spec.VersionedSignedBeaconBlock, compress bool) (version uint64, ssz []byte, err error) {
if utils.Config.KillSwitch.DisableSSZEncoding {
// MarshalVersionedSignedBeaconBlockSSZ marshals a versioned signed beacon block using SSZ encoding.
func MarshalVersionedSignedBeaconBlockSSZ(dynSsz *dynssz.DynSsz, block *spec.VersionedSignedBeaconBlock, compress bool, forceSSZ bool) (version uint64, ssz []byte, err error) {
if utils.Config.KillSwitch.DisableSSZEncoding && !forceSSZ {
// SSZ encoding disabled, use json instead
version, ssz, err = marshalVersionedSignedBeaconBlockJson(block)
version, ssz, err = MarshalVersionedSignedBeaconBlockJson(block)
} else {
// SSZ encoding
switch block.Version {
Expand Down Expand Up @@ -116,8 +116,8 @@ func unmarshalVersionedSignedBeaconBlockSSZ(dynSsz *dynssz.DynSsz, version uint6
return block, nil
}

// marshalVersionedSignedBeaconBlockJson marshals a versioned signed beacon block using JSON encoding.
func marshalVersionedSignedBeaconBlockJson(block *spec.VersionedSignedBeaconBlock) (version uint64, jsonRes []byte, err error) {
// MarshalVersionedSignedBeaconBlockJson marshals a versioned signed beacon block using JSON encoding.
func MarshalVersionedSignedBeaconBlockJson(block *spec.VersionedSignedBeaconBlock) (version uint64, jsonRes []byte, err error) {
switch block.Version {
case spec.DataVersionPhase0:
version = uint64(block.Version)
Expand Down
2 changes: 1 addition & 1 deletion indexer/beacon/epochcache.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
)

// epochStatsKey is the primary key for EpochStats entries in cache.
// consists of dependendRoot (32 byte) and epoch (8 byte).
// consists of dependentRoot (32 byte) and epoch (8 byte).
type epochStatsKey [32 + 8]byte

// generate epochStatsKey from epoch and dependentRoot
Expand Down
Loading

0 comments on commit 8f0c771

Please sign in to comment.