Skip to content

Commit

Permalink
Merge pull request #1340 from bloxapp/stage
Browse files Browse the repository at this point in the history
v1.3.2
  • Loading branch information
Lior Rutenberg authored Mar 12, 2024
2 parents 3bd0066 + 6ff3397 commit 97d20e6
Show file tree
Hide file tree
Showing 5 changed files with 358 additions and 59 deletions.
2 changes: 2 additions & 0 deletions beacon/goclient/goclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ type Client interface {
eth2client.Service
eth2client.NodeVersionProvider
eth2client.NodeClientProvider
eth2client.SpecProvider
eth2client.GenesisProvider

eth2client.AttestationDataProvider
eth2client.AttestationsSubmitter
Expand Down
57 changes: 57 additions & 0 deletions beacon/goclient/signing.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,71 @@
package goclient

import (
"context"
"crypto/sha256"
"fmt"
"hash"
"sync"

"github.com/attestantio/go-eth2-client/api"
"github.com/attestantio/go-eth2-client/spec/phase0"
spectypes "github.com/bloxapp/ssv-spec/types"
ssz "github.com/ferranbt/fastssz"
"github.com/pkg/errors"
)

func (gc *goClient) computeVoluntaryExitDomain(ctx context.Context) (phase0.Domain, error) {
specResponse, err := gc.client.Spec(gc.ctx, &api.SpecOpts{})
if err != nil {
return phase0.Domain{}, fmt.Errorf("failed to obtain spec response: %w", err)
}
if specResponse == nil {
return phase0.Domain{}, fmt.Errorf("spec response is nil")
}
if specResponse.Data == nil {
return phase0.Domain{}, fmt.Errorf("spec response data is nil")
}

// TODO: consider storing fork version and genesis validators root in goClient
// instead of fetching it every time

forkVersionRaw, ok := specResponse.Data["CAPELLA_FORK_VERSION"]
if !ok {
return phase0.Domain{}, fmt.Errorf("capella fork version not known by chain")
}
forkVersion, ok := forkVersionRaw.(phase0.Version)
if !ok {
return phase0.Domain{}, fmt.Errorf("failed to decode capella fork version")
}

forkData := &phase0.ForkData{
CurrentVersion: forkVersion,
}

genesisResponse, err := gc.client.Genesis(ctx, &api.GenesisOpts{})
if err != nil {
return phase0.Domain{}, fmt.Errorf("failed to obtain genesis response: %w", err)
}
if genesisResponse == nil {
return phase0.Domain{}, fmt.Errorf("genesis response is nil")
}
if genesisResponse.Data == nil {
return phase0.Domain{}, fmt.Errorf("genesis response data is nil")
}
forkData.GenesisValidatorsRoot = genesisResponse.Data.GenesisValidatorsRoot

root, err := forkData.HashTreeRoot()
if err != nil {
return phase0.Domain{}, fmt.Errorf("failed to calculate signature domain, err: %w", err)
}

var domain phase0.Domain
copy(domain[:], spectypes.DomainVoluntaryExit[:])
copy(domain[4:], root[:])

return domain, nil
}

func (gc *goClient) DomainData(epoch phase0.Epoch, domain phase0.DomainType) (phase0.Domain, error) {
if domain == spectypes.DomainApplicationBuilder { // no domain for DomainApplicationBuilder. need to create. https://github.com/bloxapp/ethereum2-validator/blob/v2-main/signing/keyvault/signer.go#L62
var appDomain phase0.Domain
Expand All @@ -25,6 +80,8 @@ func (gc *goClient) DomainData(epoch phase0.Epoch, domain phase0.DomainType) (ph
copy(appDomain[:], domain[:])
copy(appDomain[4:], root[:])
return appDomain, nil
} else if domain == spectypes.DomainVoluntaryExit {
return gc.computeVoluntaryExitDomain(gc.ctx)
}

data, err := gc.client.Domain(gc.ctx, domain, epoch)
Expand Down
2 changes: 1 addition & 1 deletion eth/simulator/simulator.go
Original file line number Diff line number Diff line change
Expand Up @@ -916,7 +916,7 @@ func (fb *filterBackend) GetReceipts(ctx context.Context, hash common.Hash) (typ
}

func (fb *filterBackend) GetLogs(ctx context.Context, hash common.Hash, number uint64) ([][]*types.Log, error) {
logs := rawdb.ReadLogs(fb.db, hash, number, fb.bc.Config())
logs := rawdb.ReadLogs(fb.db, hash, number)
return logs, nil
}

Expand Down
44 changes: 26 additions & 18 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ require (
github.com/cornelk/hashmap v1.0.8
github.com/dgraph-io/badger/v4 v4.1.0
github.com/dgraph-io/ristretto v0.1.1
github.com/ethereum/go-ethereum v1.12.2
github.com/ethereum/go-ethereum v1.13.5
github.com/ferranbt/fastssz v0.1.3
github.com/go-chi/chi/v5 v5.0.8
github.com/go-chi/render v1.0.2
Expand All @@ -33,6 +33,7 @@ require (
github.com/patrickmn/go-cache v2.1.0+incompatible
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.16.0
github.com/prysmaticlabs/fastssz v0.0.0-20220628121656-93dfe28febab
github.com/prysmaticlabs/go-bitfield v0.0.0-20210809151128-385d8c5e3fb7
github.com/prysmaticlabs/prysm/v4 v4.0.8
github.com/rs/zerolog v1.29.1
Expand All @@ -44,41 +45,43 @@ require (
github.com/wealdtech/go-eth2-wallet-encryptor-keystorev4 v1.1.3
go.uber.org/multierr v1.11.0
go.uber.org/zap v1.24.0
golang.org/x/exp v0.0.0-20230810033253-352e893a4cad
golang.org/x/mod v0.11.0
golang.org/x/exp v0.0.0-20230905200255-921286631fa9
golang.org/x/mod v0.12.0
golang.org/x/sync v0.3.0
golang.org/x/text v0.14.0
gopkg.in/natefinch/lumberjack.v2 v2.2.1
gopkg.in/yaml.v3 v3.0.1
)

require (
github.com/BurntSushi/toml v1.2.1 // indirect
github.com/BurntSushi/toml v1.3.2 // indirect
github.com/DataDog/zstd v1.5.2 // indirect
github.com/VictoriaMetrics/fastcache v1.12.0 // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/VictoriaMetrics/fastcache v1.12.1 // indirect
github.com/ajg/form v1.5.1 // indirect
github.com/aristanetworks/goarista v0.0.0-20200805130819-fd197cf57d96 // indirect
github.com/benbjohnson/clock v1.3.5 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bits-and-blooms/bitset v1.7.0 // indirect
github.com/cockroachdb/errors v1.9.1 // indirect
github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect
github.com/cockroachdb/pebble v0.0.0-20230209160836-829675f94811 // indirect
github.com/cockroachdb/pebble v0.0.0-20230928194634-aa077af62593 // indirect
github.com/cockroachdb/redact v1.1.3 // indirect
github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect
github.com/consensys/bavard v0.1.13 // indirect
github.com/consensys/gnark-crypto v0.10.0 // indirect
github.com/consensys/gnark-crypto v0.12.1 // indirect
github.com/containerd/cgroups v1.1.0 // indirect
github.com/coreos/go-systemd/v22 v22.5.0 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
github.com/crate-crypto/go-kzg-4844 v0.3.0 // indirect
github.com/crate-crypto/go-kzg-4844 v0.7.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c // indirect
github.com/deckarep/golang-set/v2 v2.1.0 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/dustin/go-humanize v1.0.0 // indirect
github.com/elastic/gosigar v0.14.2 // indirect
github.com/ethereum/c-kzg-4844 v0.3.1 // indirect
github.com/ethereum/c-kzg-4844 v0.4.0 // indirect
github.com/fatih/color v1.16.0 // indirect
github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5 // indirect
github.com/flynn/noise v1.0.0 // indirect
Expand All @@ -95,15 +98,16 @@ require (
github.com/godbus/dbus/v5 v5.1.0 // indirect
github.com/gofrs/flock v0.8.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang-jwt/jwt/v4 v4.3.0 // indirect
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b // indirect
github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
github.com/golang/glog v1.0.0 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect
github.com/google/flatbuffers v1.12.1 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/gopacket v1.1.19 // indirect
github.com/google/pprof v0.0.0-20230602150820-91b7bce49751 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.0.1 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-bexpr v0.1.10 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
Expand All @@ -112,7 +116,7 @@ require (
github.com/holiman/bloomfilter/v2 v2.0.3 // indirect
github.com/holiman/uint256 v1.2.4 // indirect
github.com/huandu/go-clone v1.6.0 // indirect
github.com/huin/goupnp v1.2.0 // indirect
github.com/huin/goupnp v1.3.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/ipfs/boxo v0.8.0 // indirect
github.com/ipfs/go-cid v0.4.1 // indirect
Expand Down Expand Up @@ -154,6 +158,7 @@ require (
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/mitchellh/pointerstructure v1.2.0 // indirect
github.com/mmcloughlin/addchain v0.4.0 // indirect
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect
github.com/mr-tron/base58 v1.2.0 // indirect
github.com/multiformats/go-base32 v0.1.0 // indirect
github.com/multiformats/go-base36 v0.2.0 // indirect
Expand All @@ -173,6 +178,7 @@ require (
github.com/prometheus/client_model v0.4.0 // indirect
github.com/prometheus/common v0.42.0 // indirect
github.com/prometheus/procfs v0.10.1 // indirect
github.com/prysmaticlabs/gohashtree v0.0.3-alpha // indirect
github.com/quic-go/qpack v0.4.0 // indirect
github.com/quic-go/qtls-go1-19 v0.3.3 // indirect
github.com/quic-go/qtls-go1-20 v0.2.3 // indirect
Expand All @@ -191,10 +197,11 @@ require (
github.com/status-im/keycard-go v0.2.0 // indirect
github.com/supranational/blst v0.3.11 // indirect
github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect
github.com/tklauser/go-sysconf v0.3.11 // indirect
github.com/tklauser/numcpus v0.6.0 // indirect
github.com/thomaso-mirodin/intmath v0.0.0-20160323211736-5dc6d854e46e // indirect
github.com/tklauser/go-sysconf v0.3.12 // indirect
github.com/tklauser/numcpus v0.6.1 // indirect
github.com/tyler-smith/go-bip39 v1.1.0 // indirect
github.com/urfave/cli/v2 v2.24.1 // indirect
github.com/urfave/cli/v2 v2.25.7 // indirect
github.com/wealdtech/go-bytesutil v1.2.1 // indirect
github.com/whyrusleeping/go-keyspace v0.0.0-20160322163242-5b898ac5add1 // indirect
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
Expand All @@ -207,16 +214,17 @@ require (
go.uber.org/dig v1.17.0 // indirect
go.uber.org/fx v1.19.2 // indirect
golang.org/x/crypto v0.18.0 // indirect
golang.org/x/net v0.15.0 // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/sys v0.16.0 // indirect
golang.org/x/term v0.16.0 // indirect
golang.org/x/time v0.3.0 // indirect
golang.org/x/tools v0.9.1 // indirect
golang.org/x/tools v0.13.0 // indirect
golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 // indirect
gonum.org/v1/gonum v0.11.0 // indirect
google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f // indirect
google.golang.org/grpc v1.53.0 // indirect
google.golang.org/protobuf v1.30.0 // indirect
gopkg.in/cenkalti/backoff.v1 v1.1.0 // indirect
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
lukechampine.com/blake3 v1.2.1 // indirect
olympos.io/encoding/edn v0.0.0-20201019073823-d3554ca0b0a3 // indirect
Expand Down
Loading

0 comments on commit 97d20e6

Please sign in to comment.