Skip to content

Commit

Permalink
Merge pull request #58 from migalabs/feat/support-shapella
Browse files Browse the repository at this point in the history
Update crawler to support Capella fork
  • Loading branch information
cortze committed Apr 13, 2023
2 parents a101a01 + 6828263 commit 9589fb4
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 17 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ require (
github.com/multiformats/go-multiaddr v0.4.0
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.11.0
github.com/protolambda/zrnt v0.28.0
github.com/protolambda/zrnt v0.30.0
github.com/protolambda/ztyp v0.2.2
github.com/sirupsen/logrus v1.9.0
github.com/stretchr/testify v1.8.1
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1137,6 +1137,8 @@ github.com/protolambda/bls12-381-util v0.0.0-20210720105258-a772f2aac13e/go.mod
github.com/protolambda/messagediff v1.4.0/go.mod h1:LboJp0EwIbJsePYpzh5Op/9G1/4mIztMRYzzwR0dR2M=
github.com/protolambda/zrnt v0.28.0 h1:vdEL8JDqJ3wdzgqgh6Fhz1Wr3+AMGbUZ2nqoNt6QVX0=
github.com/protolambda/zrnt v0.28.0/go.mod h1:qcdX9CXFeVNCQK/q0nswpzhd+31RHMk2Ax/2lMsJ4Jw=
github.com/protolambda/zrnt v0.30.0 h1:pHEn69ZgaDFGpLGGYG1oD7DvYI7RDirbMBPfbC+8p4g=
github.com/protolambda/zrnt v0.30.0/go.mod h1:qcdX9CXFeVNCQK/q0nswpzhd+31RHMk2Ax/2lMsJ4Jw=
github.com/protolambda/ztyp v0.2.2 h1:rVcL3vBu9W/aV646zF6caLS/dyn9BN8NYiuJzicLNyY=
github.com/protolambda/ztyp v0.2.2/go.mod h1:9bYgKGqg3wJqT9ac1gI2hnVb0STQq7p/1lapqrqY1dU=
github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
Expand Down
28 changes: 15 additions & 13 deletions pkg/config/ethereum_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,20 +112,22 @@ func (c *EthereumCrawlerConfig) Apply(ctx *cli.Context) {
if valid {
c.ForkDigest = validForkDigest
}
// check if fork-digest is not empty -> eth-cl endpoint
if forkDigest == "" && ctx.IsSet("remote-cl-endpoint") {
c.EthCLRemoteEndpoint = ctx.String("remote-cl-endpoint")
log.Warnf("fork_digest not provided - fetching latest one from %s", c.EthCLRemoteEndpoint)
clEndp, err := rendp.NewInfuraClient(c.EthCLRemoteEndpoint)
if err != nil {
log.Panic(errors.Wrap(err, "unable to determine the latest fork_digest"))
}
forkD, err := rendp.GetForkDigetsOfEth2Head(ctx.Context, &clEndp)
if err != nil {
log.Panic(errors.Wrap(err, "unable to retreive the fork_digests from given rndp"))
}
c.ForkDigest = forkD.String()

}

// Check if the eth-cl endpoint
if ctx.IsSet("remote-cl-endpoint") {
c.EthCLRemoteEndpoint = ctx.String("remote-cl-endpoint")
log.Warnf("fork_digest not provided - fetching latest one from %s", c.EthCLRemoteEndpoint)
clEndp, err := rendp.NewInfuraClient(c.EthCLRemoteEndpoint)
if err != nil {
log.Panic(errors.Wrap(err, "unable to determine the latest fork_digest"))
}
forkD, err := rendp.GetForkDigetsOfEth2Head(ctx.Context, &clEndp)
if err != nil {
log.Panic(errors.Wrap(err, "unable to retreive the fork_digests from given rndp"))
}
c.ForkDigest = forkD.String()
}

// postgresql endpoint
Expand Down
4 changes: 2 additions & 2 deletions pkg/networks/ethereum/gossip_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
// bls "github.com/phoreproject/github.com/bls/g1pubs"

"github.com/migalabs/armiarma/pkg/gossipsub"
"github.com/protolambda/zrnt/eth2/beacon/bellatrix"
"github.com/protolambda/zrnt/eth2/beacon/capella"
"github.com/protolambda/zrnt/eth2/beacon/common"
"github.com/protolambda/zrnt/eth2/beacon/phase0"
"github.com/protolambda/zrnt/eth2/configs"
Expand Down Expand Up @@ -123,7 +123,7 @@ func (mh *EthMessageHandler) BeaconBlockMessageHandler(msg *pubsub.Message) (gos
return nil, err
}
msgBuf := bytes.NewBuffer(msgBytes)
bblock := new(bellatrix.SignedBeaconBlock)
bblock := new(capella.SignedBeaconBlock)

err = bblock.Deserialize(configs.Mainnet, codec.NewDecodingReader(msgBuf, uint64(len(msgBuf.Bytes()))))
if err != nil {
Expand Down
6 changes: 5 additions & 1 deletion pkg/networks/ethereum/network_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,33 +13,37 @@ var (
BlockchainName string = "eth2"

// default fork_digests
DefaultForkDigest string = ForkDigests[BellatrixKey]
DefaultForkDigest string = ForkDigests[CapellaKey]
AllForkDigest string = "All"

// Mainnet
Phase0Key string = "Mainnet"
AltairKey string = "Altair"
BellatrixKey string = "Bellatrix"
CapellaKey string = "Capella"
// Gnosis
GnosisPhase0Key string = "GnosisPhase0"
GnosisAltairKey string = "GnosisAltair"
GnosisBellatrixKey string = "Gnosisbellatrix"
// Goerli / Prater
PraterPhase0Key string = "PraterPhase0"
PraterBellatrixKey string = "PraterBellatrix"
PraterCapellaKey string = "PraterCapella"

ForkDigests = map[string]string{
AllForkDigest: "all",
// Mainnet
Phase0Key: "0xb5303f2a",
AltairKey: "0xafcaaba0",
BellatrixKey: "0x4a26c58b",
CapellaKey: "0xbba4da96",
// Gnosis
GnosisPhase0Key: "0xf925ddc5",
GnosisBellatrixKey: "0x56fdb5e0",
// Goerli
PraterPhase0Key: "0x79df0428",
PraterBellatrixKey: "0xc2ce3aa8",
PraterCapellaKey: "0x628941ef",
}

MessageTypes = []string{
Expand Down

0 comments on commit 9589fb4

Please sign in to comment.