Skip to content

Commit

Permalink
Merge branch 'electra' into electra
Browse files Browse the repository at this point in the history
  • Loading branch information
jtraglia authored May 6, 2024
2 parents 5640c26 + 3e81eac commit d6e0b79
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
6 changes: 3 additions & 3 deletions api/v1/deneb/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
package deneb

// Need to `go install github.com/ferranbt/fastssz/sszgen@latest` for this to work.
//go:generate rm -f blindedbeaconblock_ssz.go blindedbeaconblockbody_ssz.go blindedblobsidecar_ssz.go blindedblockcontents_ssz.go blockcontents_ssz.go signedblindedbeaconblock_ssz.go signedblindedblockcontents_ssz.go signedblockcontents_ssz.go
//go:generate sszgen --include ../../../spec/phase0,../../../spec/altair,../../../spec/bellatrix,../../../spec/capella,../../../spec/deneb -path . --suffix ssz -objs BlindedBeaconBlock,BlindedBeaconBlockBody,BlindedBlobSidecar,BlindedBlockContents,BlockContents,SignedBlindedBeaconBlock,SignedBlindedBlockContents,SignedBlockContents
//go:generate goimports -w blindedbeaconblock_ssz.go blindedbeaconblockbody_ssz.go blindedblobsidecar_ssz.go blindedblockcontents_ssz.go blockcontents_ssz.go signedblindedbeaconblock_ssz.go signedblindedblockcontents_ssz.go,signedblockcontents_ssz.go
//go:generate rm -f blindedbeaconblock_ssz.go blindedbeaconblockbody_ssz.go blockcontents_ssz.go signedblindedbeaconblock_ssz.go signedblockcontents_ssz.go
//go:generate sszgen --include ../../../spec/phase0,../../../spec/altair,../../../spec/bellatrix,../../../spec/capella,../../../spec/deneb -path . --suffix ssz -objs BlindedBeaconBlock,BlindedBeaconBlockBody,BlockContents,SignedBlindedBeaconBlock,SignedBlockContents
//go:generate goimports -w blindedbeaconblock_ssz.go blindedbeaconblockbody_ssz.go blockcontents_ssz.go signedblindedbeaconblock_ssz.go signedblockcontents_ssz.go
2 changes: 1 addition & 1 deletion spec/phase0/attestation.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func (a *Attestation) unpack(attestationJSON *attestationJSON) error {
return errors.New("aggregation bits missing")
}
if a.AggregationBits, err = hex.DecodeString(strings.TrimPrefix(attestationJSON.AggregationBits, "0x")); err != nil {
return errors.Wrap(err, "invalid value for beacon block root")
return errors.Wrap(err, "invalid value for aggregation bits")
}
a.Data = attestationJSON.Data
if a.Data == nil {
Expand Down
2 changes: 1 addition & 1 deletion spec/phase0/attestation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func TestAttestationJSON(t *testing.T) {
{
name: "AggregationBitsInvalid",
input: []byte(`{"aggregation_bits":"invalid","data":{"slot":"100","index":"1","beacon_block_root":"0x000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f","source":{"epoch":"1","root":"0x202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f"},"target":{"epoch":"2","root":"0x404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f"}},"signature":"0x606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebf"}`),
err: "invalid value for beacon block root: encoding/hex: invalid byte: U+0069 'i'",
err: "invalid value for aggregation bits: encoding/hex: invalid byte: U+0069 'i'",
},
{
name: "DataMissing",
Expand Down
5 changes: 4 additions & 1 deletion spec/phase0/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ func (e *Epoch) UnmarshalJSON(input []byte) error {
if len(input) == 0 {
return errors.New("input missing")
}
if len(input) < 3 {
return errors.New("input malformed")
}

if !bytes.HasPrefix(input, []byte{'"'}) {
return errors.New("invalid prefix")
Expand All @@ -47,7 +50,7 @@ func (e *Epoch) UnmarshalJSON(input []byte) error {
}

// MarshalJSON implements json.Marshaler.
func (e *Epoch) MarshalJSON() ([]byte, error) {
func (e Epoch) MarshalJSON() ([]byte, error) {
return []byte(fmt.Sprintf(`"%d"`, e)), nil
}

Expand Down

0 comments on commit d6e0b79

Please sign in to comment.