Skip to content

Commit

Permalink
Merge branch 'attestantio:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
samcm authored Jul 14, 2023
2 parents 4aa5d42 + 0c8305f commit 1d1d5ef
Show file tree
Hide file tree
Showing 85 changed files with 2,418 additions and 3,716 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
0.18.0:
- support Graffiti, ProposerIndex and RandaoReveal on VersionedBeaconBlock
- use SSZ instead of JSON where available

0.17.0:
- reworked JSON parsing for custom types to make easier to transition to another parser in future
- added Deneb spec types
34 changes: 17 additions & 17 deletions api/v1/bellatrix/blindedbeaconblock_test.go

Large diffs are not rendered by default.

60 changes: 30 additions & 30 deletions api/v1/bellatrix/blindedbeaconblockbody_test.go

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions api/v1/bellatrix/signedblindedbeaconblock_test.go

Large diffs are not rendered by default.

60 changes: 30 additions & 30 deletions api/v1/capella/blindedbeaconblockbody_test.go

Large diffs are not rendered by default.

70 changes: 35 additions & 35 deletions api/v1/deneb/blindedbeaconblockbody_test.go

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions api/v1/deneb/blindedblobsidecar_json.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ type blindedBlobSidecarJSON struct {
KzgProof deneb.KzgProof `json:"kzg_proof"`
}

// MarshalJSON implements json.Marshaler.
func (b *BlindedBlobSidecar) MarshalJSON() ([]byte, error) {
return json.Marshal(&blindedBlobSidecarJSON{
BlockRoot: b.BlockRoot,
Expand All @@ -48,6 +49,7 @@ func (b *BlindedBlobSidecar) MarshalJSON() ([]byte, error) {
})
}

// UnmarshalJSON implements json.Unmarshaler.
func (b *BlindedBlobSidecar) UnmarshalJSON(input []byte) error {
raw, err := codecs.RawJSON(&blindedBlobSidecarJSON{}, input)
if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions api/v1/payloadattributesevent.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ type PayloadAttributesData struct {
V2 *PayloadAttributesV2
}

// PayloadAttributes represents the payload attributes.
// PayloadAttributesV1 represents the payload attributes.
type PayloadAttributesV1 struct {
// Timestamp is the timestamp of the payload.
Timestamp uint64
Expand Down Expand Up @@ -93,7 +93,7 @@ type payloadAttributesV2JSON struct {
Withdrawals []*capella.Withdrawal `json:"withdrawals"`
}

// MarshalJSON implements json.Marshaler.
// UnmarshalJSON implements json.Unmarshaler.
func (p *PayloadAttributesV1) UnmarshalJSON(input []byte) error {
var payloadAttributes payloadAttributesV1JSON
if err := json.Unmarshal(input, &payloadAttributes); err != nil {
Expand Down Expand Up @@ -140,7 +140,7 @@ func (p *PayloadAttributesV1) unpack(data *payloadAttributesV1JSON) error {
return nil
}

// MarshalJSON implements json.Marshaler.
// UnmarshalJSON implements json.Unmarshaler.
func (p *PayloadAttributesV2) UnmarshalJSON(input []byte) error {
var payloadAttributes payloadAttributesV2JSON
if err := json.Unmarshal(input, &payloadAttributes); err != nil {
Expand Down
107 changes: 107 additions & 0 deletions api/v1/validator_encoding.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

60 changes: 53 additions & 7 deletions api/versionedblindedbeaconblock.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func (v *VersionedBlindedBeaconBlock) IsEmpty() bool {
return v.Bellatrix == nil && v.Capella == nil && v.Deneb == nil
}

// Slot returns the slot of the beacon block.
// Slot returns the slot of the blinded beacon block.
func (v *VersionedBlindedBeaconBlock) Slot() (phase0.Slot, error) {
switch v.Version {
case spec.DataVersionBellatrix:
Expand All @@ -60,7 +60,53 @@ func (v *VersionedBlindedBeaconBlock) Slot() (phase0.Slot, error) {
}
}

// Attestations returns the attestations of the beacon block.
// RandaoReveal returns the RANDAO reveal of the blinded beacon block.
func (v *VersionedBlindedBeaconBlock) RandaoReveal() (phase0.BLSSignature, error) {
switch v.Version {
case spec.DataVersionBellatrix:
if v.Bellatrix == nil || v.Bellatrix.Body == nil {
return phase0.BLSSignature{}, errors.New("no bellatrix block")
}
return v.Bellatrix.Body.RANDAOReveal, nil
case spec.DataVersionCapella:
if v.Capella == nil || v.Capella.Body == nil {
return phase0.BLSSignature{}, errors.New("no capella block")
}
return v.Capella.Body.RANDAOReveal, nil
case spec.DataVersionDeneb:
if v.Deneb == nil || v.Deneb.Body == nil {
return phase0.BLSSignature{}, errors.New("no deneb block")
}
return v.Deneb.Body.RANDAOReveal, nil
default:
return phase0.BLSSignature{}, errors.New("unsupported version")
}
}

// Graffiti returns the graffiti of the blinded beacon block.
func (v *VersionedBlindedBeaconBlock) Graffiti() ([32]byte, error) {
switch v.Version {
case spec.DataVersionBellatrix:
if v.Bellatrix == nil || v.Bellatrix.Body == nil {
return [32]byte{}, errors.New("no bellatrix block")
}
return v.Bellatrix.Body.Graffiti, nil
case spec.DataVersionCapella:
if v.Capella == nil || v.Capella.Body == nil {
return [32]byte{}, errors.New("no capella block")
}
return v.Capella.Body.Graffiti, nil
case spec.DataVersionDeneb:
if v.Deneb == nil || v.Deneb.Body == nil {
return [32]byte{}, errors.New("no deneb block")
}
return v.Deneb.Body.Graffiti, nil
default:
return [32]byte{}, errors.New("unsupported version")
}
}

// Attestations returns the attestations of the blinded beacon block.
func (v *VersionedBlindedBeaconBlock) Attestations() ([]*phase0.Attestation, error) {
switch v.Version {
case spec.DataVersionBellatrix:
Expand All @@ -83,7 +129,7 @@ func (v *VersionedBlindedBeaconBlock) Attestations() ([]*phase0.Attestation, err
}
}

// Root returns the root of the beacon block.
// Root returns the root of the blinded beacon block.
func (v *VersionedBlindedBeaconBlock) Root() (phase0.Root, error) {
switch v.Version {
case spec.DataVersionBellatrix:
Expand All @@ -106,7 +152,7 @@ func (v *VersionedBlindedBeaconBlock) Root() (phase0.Root, error) {
}
}

// BodyRoot returns the body root of the beacon block.
// BodyRoot returns the body root of the blinded beacon block.
func (v *VersionedBlindedBeaconBlock) BodyRoot() (phase0.Root, error) {
switch v.Version {
case spec.DataVersionBellatrix:
Expand All @@ -129,7 +175,7 @@ func (v *VersionedBlindedBeaconBlock) BodyRoot() (phase0.Root, error) {
}
}

// ParentRoot returns the parent root of the beacon block.
// ParentRoot returns the parent root of the blinded beacon block.
func (v *VersionedBlindedBeaconBlock) ParentRoot() (phase0.Root, error) {
switch v.Version {
case spec.DataVersionBellatrix:
Expand All @@ -152,7 +198,7 @@ func (v *VersionedBlindedBeaconBlock) ParentRoot() (phase0.Root, error) {
}
}

// StateRoot returns the state root of the beacon block.
// StateRoot returns the state root of the blinded beacon block.
func (v *VersionedBlindedBeaconBlock) StateRoot() (phase0.Root, error) {
switch v.Version {
case spec.DataVersionBellatrix:
Expand All @@ -175,7 +221,7 @@ func (v *VersionedBlindedBeaconBlock) StateRoot() (phase0.Root, error) {
}
}

// TransactionsRoot returns the transactions root of the beacon block.
// TransactionsRoot returns the transactions root of the blinded beacon block.
func (v *VersionedBlindedBeaconBlock) TransactionsRoot() (phase0.Root, error) {
switch v.Version {
case spec.DataVersionBellatrix:
Expand Down
2 changes: 1 addition & 1 deletion codecs/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"github.com/pkg/errors"
)

// UnmarshalRawMessage generates raw JSON for a struct,
// RawJSON generates raw JSON for a struct,
// ensuring that all values are present.
func RawJSON(b any, input []byte) (map[string]json.RawMessage, error) {
// Make generic map from input.
Expand Down
52 changes: 29 additions & 23 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,45 +3,51 @@ module github.com/attestantio/go-eth2-client
go 1.20

require (
github.com/ferranbt/fastssz v0.1.2
github.com/ferranbt/fastssz v0.1.3
github.com/goccy/go-yaml v1.9.2
github.com/golang/snappy v0.0.4
github.com/holiman/uint256 v1.2.2
github.com/huandu/go-clone/generic v1.6.0
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.12.1
github.com/prometheus/client_golang v1.16.0
github.com/prysmaticlabs/go-bitfield v0.0.0-20210809151128-385d8c5e3fb7
github.com/r3labs/sse/v2 v2.7.4
github.com/rs/zerolog v1.26.1
github.com/stretchr/testify v1.7.0
golang.org/x/crypto v0.0.0-20211215165025-cf75a172585e
github.com/r3labs/sse/v2 v2.10.0
github.com/rs/zerolog v1.29.1
github.com/stretchr/testify v1.8.4
go.opentelemetry.io/otel v1.16.0
golang.org/x/crypto v0.10.0
)

require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/fatih/color v1.13.0 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/fatih/color v1.10.0 // indirect
github.com/go-logr/logr v1.2.4 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/huandu/go-clone v1.6.0 // indirect
github.com/klauspost/cpuid/v2 v2.1.2 // indirect
github.com/kr/pretty v0.2.0 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.16 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
github.com/klauspost/cpuid/v2 v2.0.9 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/mattn/go-colorable v0.1.12 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/minio/sha256-simd v1.0.0 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/mitchellh/mapstructure v1.3.2 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.32.1 // indirect
github.com/prometheus/procfs v0.7.3 // indirect
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd // indirect
golang.org/x/sys v0.2.0 // indirect
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
google.golang.org/protobuf v1.26.0 // indirect
github.com/prometheus/client_model v0.3.0 // indirect
github.com/prometheus/common v0.42.0 // indirect
github.com/prometheus/procfs v0.10.1 // indirect
github.com/rogpeppe/go-internal v1.11.0 // indirect
go.opentelemetry.io/otel/metric v1.16.0 // indirect
go.opentelemetry.io/otel/trace v1.16.0 // indirect
golang.org/x/net v0.10.0 // indirect
golang.org/x/sys v0.9.0 // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
google.golang.org/protobuf v1.30.0 // indirect
gopkg.in/cenkalti/backoff.v1 v1.1.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

retract (
Expand Down
Loading

0 comments on commit 1d1d5ef

Please sign in to comment.