github.com/prysmaticlabs/prysm@v1.4.4/proto/eth/v1/generated.ssz.go (about) 1 // Code generated by fastssz. DO NOT EDIT. 2 // Hash: d88bf8c7704ca0134277d0433309d72a5ca08f331f5390137c627b6bd1f5711b 3 package v1 4 5 import ( 6 ssz "github.com/ferranbt/fastssz" 7 github_com_prysmaticlabs_eth2_types "github.com/prysmaticlabs/eth2-types" 8 ) 9 10 // MarshalSSZ ssz marshals the Attestation object 11 func (a *Attestation) MarshalSSZ() ([]byte, error) { 12 return ssz.MarshalSSZ(a) 13 } 14 15 // MarshalSSZTo ssz marshals the Attestation object to a target array 16 func (a *Attestation) MarshalSSZTo(buf []byte) (dst []byte, err error) { 17 dst = buf 18 offset := int(228) 19 20 // Offset (0) 'AggregationBits' 21 dst = ssz.WriteOffset(dst, offset) 22 offset += len(a.AggregationBits) 23 24 // Field (1) 'Data' 25 if a.Data == nil { 26 a.Data = new(AttestationData) 27 } 28 if dst, err = a.Data.MarshalSSZTo(dst); err != nil { 29 return 30 } 31 32 // Field (2) 'Signature' 33 if len(a.Signature) != 96 { 34 err = ssz.ErrBytesLength 35 return 36 } 37 dst = append(dst, a.Signature...) 38 39 // Field (0) 'AggregationBits' 40 if len(a.AggregationBits) > 2048 { 41 err = ssz.ErrBytesLength 42 return 43 } 44 dst = append(dst, a.AggregationBits...) 45 46 return 47 } 48 49 // UnmarshalSSZ ssz unmarshals the Attestation object 50 func (a *Attestation) UnmarshalSSZ(buf []byte) error { 51 var err error 52 size := uint64(len(buf)) 53 if size < 228 { 54 return ssz.ErrSize 55 } 56 57 tail := buf 58 var o0 uint64 59 60 // Offset (0) 'AggregationBits' 61 if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { 62 return ssz.ErrOffset 63 } 64 65 if o0 < 228 { 66 return ssz.ErrInvalidVariableOffset 67 } 68 69 // Field (1) 'Data' 70 if a.Data == nil { 71 a.Data = new(AttestationData) 72 } 73 if err = a.Data.UnmarshalSSZ(buf[4:132]); err != nil { 74 return err 75 } 76 77 // Field (2) 'Signature' 78 if cap(a.Signature) == 0 { 79 a.Signature = make([]byte, 0, len(buf[132:228])) 80 } 81 a.Signature = append(a.Signature, buf[132:228]...) 82 83 // Field (0) 'AggregationBits' 84 { 85 buf = tail[o0:] 86 if err = ssz.ValidateBitlist(buf, 2048); err != nil { 87 return err 88 } 89 if cap(a.AggregationBits) == 0 { 90 a.AggregationBits = make([]byte, 0, len(buf)) 91 } 92 a.AggregationBits = append(a.AggregationBits, buf...) 93 } 94 return err 95 } 96 97 // SizeSSZ returns the ssz encoded size in bytes for the Attestation object 98 func (a *Attestation) SizeSSZ() (size int) { 99 size = 228 100 101 // Field (0) 'AggregationBits' 102 size += len(a.AggregationBits) 103 104 return 105 } 106 107 // HashTreeRoot ssz hashes the Attestation object 108 func (a *Attestation) HashTreeRoot() ([32]byte, error) { 109 return ssz.HashWithDefaultHasher(a) 110 } 111 112 // HashTreeRootWith ssz hashes the Attestation object with a hasher 113 func (a *Attestation) HashTreeRootWith(hh *ssz.Hasher) (err error) { 114 indx := hh.Index() 115 116 // Field (0) 'AggregationBits' 117 if len(a.AggregationBits) == 0 { 118 err = ssz.ErrEmptyBitlist 119 return 120 } 121 hh.PutBitlist(a.AggregationBits, 2048) 122 123 // Field (1) 'Data' 124 if err = a.Data.HashTreeRootWith(hh); err != nil { 125 return 126 } 127 128 // Field (2) 'Signature' 129 if len(a.Signature) != 96 { 130 err = ssz.ErrBytesLength 131 return 132 } 133 hh.PutBytes(a.Signature) 134 135 hh.Merkleize(indx) 136 return 137 } 138 139 // MarshalSSZ ssz marshals the AggregateAttestationAndProof object 140 func (a *AggregateAttestationAndProof) MarshalSSZ() ([]byte, error) { 141 return ssz.MarshalSSZ(a) 142 } 143 144 // MarshalSSZTo ssz marshals the AggregateAttestationAndProof object to a target array 145 func (a *AggregateAttestationAndProof) MarshalSSZTo(buf []byte) (dst []byte, err error) { 146 dst = buf 147 offset := int(108) 148 149 // Field (0) 'AggregatorIndex' 150 dst = ssz.MarshalUint64(dst, uint64(a.AggregatorIndex)) 151 152 // Offset (1) 'Aggregate' 153 dst = ssz.WriteOffset(dst, offset) 154 if a.Aggregate == nil { 155 a.Aggregate = new(Attestation) 156 } 157 offset += a.Aggregate.SizeSSZ() 158 159 // Field (2) 'SelectionProof' 160 if len(a.SelectionProof) != 96 { 161 err = ssz.ErrBytesLength 162 return 163 } 164 dst = append(dst, a.SelectionProof...) 165 166 // Field (1) 'Aggregate' 167 if dst, err = a.Aggregate.MarshalSSZTo(dst); err != nil { 168 return 169 } 170 171 return 172 } 173 174 // UnmarshalSSZ ssz unmarshals the AggregateAttestationAndProof object 175 func (a *AggregateAttestationAndProof) UnmarshalSSZ(buf []byte) error { 176 var err error 177 size := uint64(len(buf)) 178 if size < 108 { 179 return ssz.ErrSize 180 } 181 182 tail := buf 183 var o1 uint64 184 185 // Field (0) 'AggregatorIndex' 186 a.AggregatorIndex = github_com_prysmaticlabs_eth2_types.ValidatorIndex(ssz.UnmarshallUint64(buf[0:8])) 187 188 // Offset (1) 'Aggregate' 189 if o1 = ssz.ReadOffset(buf[8:12]); o1 > size { 190 return ssz.ErrOffset 191 } 192 193 if o1 < 108 { 194 return ssz.ErrInvalidVariableOffset 195 } 196 197 // Field (2) 'SelectionProof' 198 if cap(a.SelectionProof) == 0 { 199 a.SelectionProof = make([]byte, 0, len(buf[12:108])) 200 } 201 a.SelectionProof = append(a.SelectionProof, buf[12:108]...) 202 203 // Field (1) 'Aggregate' 204 { 205 buf = tail[o1:] 206 if a.Aggregate == nil { 207 a.Aggregate = new(Attestation) 208 } 209 if err = a.Aggregate.UnmarshalSSZ(buf); err != nil { 210 return err 211 } 212 } 213 return err 214 } 215 216 // SizeSSZ returns the ssz encoded size in bytes for the AggregateAttestationAndProof object 217 func (a *AggregateAttestationAndProof) SizeSSZ() (size int) { 218 size = 108 219 220 // Field (1) 'Aggregate' 221 if a.Aggregate == nil { 222 a.Aggregate = new(Attestation) 223 } 224 size += a.Aggregate.SizeSSZ() 225 226 return 227 } 228 229 // HashTreeRoot ssz hashes the AggregateAttestationAndProof object 230 func (a *AggregateAttestationAndProof) HashTreeRoot() ([32]byte, error) { 231 return ssz.HashWithDefaultHasher(a) 232 } 233 234 // HashTreeRootWith ssz hashes the AggregateAttestationAndProof object with a hasher 235 func (a *AggregateAttestationAndProof) HashTreeRootWith(hh *ssz.Hasher) (err error) { 236 indx := hh.Index() 237 238 // Field (0) 'AggregatorIndex' 239 hh.PutUint64(uint64(a.AggregatorIndex)) 240 241 // Field (1) 'Aggregate' 242 if err = a.Aggregate.HashTreeRootWith(hh); err != nil { 243 return 244 } 245 246 // Field (2) 'SelectionProof' 247 if len(a.SelectionProof) != 96 { 248 err = ssz.ErrBytesLength 249 return 250 } 251 hh.PutBytes(a.SelectionProof) 252 253 hh.Merkleize(indx) 254 return 255 } 256 257 // MarshalSSZ ssz marshals the SignedAggregateAttestationAndProof object 258 func (s *SignedAggregateAttestationAndProof) MarshalSSZ() ([]byte, error) { 259 return ssz.MarshalSSZ(s) 260 } 261 262 // MarshalSSZTo ssz marshals the SignedAggregateAttestationAndProof object to a target array 263 func (s *SignedAggregateAttestationAndProof) MarshalSSZTo(buf []byte) (dst []byte, err error) { 264 dst = buf 265 offset := int(100) 266 267 // Offset (0) 'Message' 268 dst = ssz.WriteOffset(dst, offset) 269 if s.Message == nil { 270 s.Message = new(AggregateAttestationAndProof) 271 } 272 offset += s.Message.SizeSSZ() 273 274 // Field (1) 'Signature' 275 if len(s.Signature) != 96 { 276 err = ssz.ErrBytesLength 277 return 278 } 279 dst = append(dst, s.Signature...) 280 281 // Field (0) 'Message' 282 if dst, err = s.Message.MarshalSSZTo(dst); err != nil { 283 return 284 } 285 286 return 287 } 288 289 // UnmarshalSSZ ssz unmarshals the SignedAggregateAttestationAndProof object 290 func (s *SignedAggregateAttestationAndProof) UnmarshalSSZ(buf []byte) error { 291 var err error 292 size := uint64(len(buf)) 293 if size < 100 { 294 return ssz.ErrSize 295 } 296 297 tail := buf 298 var o0 uint64 299 300 // Offset (0) 'Message' 301 if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { 302 return ssz.ErrOffset 303 } 304 305 if o0 < 100 { 306 return ssz.ErrInvalidVariableOffset 307 } 308 309 // Field (1) 'Signature' 310 if cap(s.Signature) == 0 { 311 s.Signature = make([]byte, 0, len(buf[4:100])) 312 } 313 s.Signature = append(s.Signature, buf[4:100]...) 314 315 // Field (0) 'Message' 316 { 317 buf = tail[o0:] 318 if s.Message == nil { 319 s.Message = new(AggregateAttestationAndProof) 320 } 321 if err = s.Message.UnmarshalSSZ(buf); err != nil { 322 return err 323 } 324 } 325 return err 326 } 327 328 // SizeSSZ returns the ssz encoded size in bytes for the SignedAggregateAttestationAndProof object 329 func (s *SignedAggregateAttestationAndProof) SizeSSZ() (size int) { 330 size = 100 331 332 // Field (0) 'Message' 333 if s.Message == nil { 334 s.Message = new(AggregateAttestationAndProof) 335 } 336 size += s.Message.SizeSSZ() 337 338 return 339 } 340 341 // HashTreeRoot ssz hashes the SignedAggregateAttestationAndProof object 342 func (s *SignedAggregateAttestationAndProof) HashTreeRoot() ([32]byte, error) { 343 return ssz.HashWithDefaultHasher(s) 344 } 345 346 // HashTreeRootWith ssz hashes the SignedAggregateAttestationAndProof object with a hasher 347 func (s *SignedAggregateAttestationAndProof) HashTreeRootWith(hh *ssz.Hasher) (err error) { 348 indx := hh.Index() 349 350 // Field (0) 'Message' 351 if err = s.Message.HashTreeRootWith(hh); err != nil { 352 return 353 } 354 355 // Field (1) 'Signature' 356 if len(s.Signature) != 96 { 357 err = ssz.ErrBytesLength 358 return 359 } 360 hh.PutBytes(s.Signature) 361 362 hh.Merkleize(indx) 363 return 364 } 365 366 // MarshalSSZ ssz marshals the AttestationData object 367 func (a *AttestationData) MarshalSSZ() ([]byte, error) { 368 return ssz.MarshalSSZ(a) 369 } 370 371 // MarshalSSZTo ssz marshals the AttestationData object to a target array 372 func (a *AttestationData) MarshalSSZTo(buf []byte) (dst []byte, err error) { 373 dst = buf 374 375 // Field (0) 'Slot' 376 dst = ssz.MarshalUint64(dst, uint64(a.Slot)) 377 378 // Field (1) 'Index' 379 dst = ssz.MarshalUint64(dst, uint64(a.Index)) 380 381 // Field (2) 'BeaconBlockRoot' 382 if len(a.BeaconBlockRoot) != 32 { 383 err = ssz.ErrBytesLength 384 return 385 } 386 dst = append(dst, a.BeaconBlockRoot...) 387 388 // Field (3) 'Source' 389 if a.Source == nil { 390 a.Source = new(Checkpoint) 391 } 392 if dst, err = a.Source.MarshalSSZTo(dst); err != nil { 393 return 394 } 395 396 // Field (4) 'Target' 397 if a.Target == nil { 398 a.Target = new(Checkpoint) 399 } 400 if dst, err = a.Target.MarshalSSZTo(dst); err != nil { 401 return 402 } 403 404 return 405 } 406 407 // UnmarshalSSZ ssz unmarshals the AttestationData object 408 func (a *AttestationData) UnmarshalSSZ(buf []byte) error { 409 var err error 410 size := uint64(len(buf)) 411 if size != 128 { 412 return ssz.ErrSize 413 } 414 415 // Field (0) 'Slot' 416 a.Slot = github_com_prysmaticlabs_eth2_types.Slot(ssz.UnmarshallUint64(buf[0:8])) 417 418 // Field (1) 'Index' 419 a.Index = github_com_prysmaticlabs_eth2_types.CommitteeIndex(ssz.UnmarshallUint64(buf[8:16])) 420 421 // Field (2) 'BeaconBlockRoot' 422 if cap(a.BeaconBlockRoot) == 0 { 423 a.BeaconBlockRoot = make([]byte, 0, len(buf[16:48])) 424 } 425 a.BeaconBlockRoot = append(a.BeaconBlockRoot, buf[16:48]...) 426 427 // Field (3) 'Source' 428 if a.Source == nil { 429 a.Source = new(Checkpoint) 430 } 431 if err = a.Source.UnmarshalSSZ(buf[48:88]); err != nil { 432 return err 433 } 434 435 // Field (4) 'Target' 436 if a.Target == nil { 437 a.Target = new(Checkpoint) 438 } 439 if err = a.Target.UnmarshalSSZ(buf[88:128]); err != nil { 440 return err 441 } 442 443 return err 444 } 445 446 // SizeSSZ returns the ssz encoded size in bytes for the AttestationData object 447 func (a *AttestationData) SizeSSZ() (size int) { 448 size = 128 449 return 450 } 451 452 // HashTreeRoot ssz hashes the AttestationData object 453 func (a *AttestationData) HashTreeRoot() ([32]byte, error) { 454 return ssz.HashWithDefaultHasher(a) 455 } 456 457 // HashTreeRootWith ssz hashes the AttestationData object with a hasher 458 func (a *AttestationData) HashTreeRootWith(hh *ssz.Hasher) (err error) { 459 indx := hh.Index() 460 461 // Field (0) 'Slot' 462 hh.PutUint64(uint64(a.Slot)) 463 464 // Field (1) 'Index' 465 hh.PutUint64(uint64(a.Index)) 466 467 // Field (2) 'BeaconBlockRoot' 468 if len(a.BeaconBlockRoot) != 32 { 469 err = ssz.ErrBytesLength 470 return 471 } 472 hh.PutBytes(a.BeaconBlockRoot) 473 474 // Field (3) 'Source' 475 if err = a.Source.HashTreeRootWith(hh); err != nil { 476 return 477 } 478 479 // Field (4) 'Target' 480 if err = a.Target.HashTreeRootWith(hh); err != nil { 481 return 482 } 483 484 hh.Merkleize(indx) 485 return 486 } 487 488 // MarshalSSZ ssz marshals the Checkpoint object 489 func (c *Checkpoint) MarshalSSZ() ([]byte, error) { 490 return ssz.MarshalSSZ(c) 491 } 492 493 // MarshalSSZTo ssz marshals the Checkpoint object to a target array 494 func (c *Checkpoint) MarshalSSZTo(buf []byte) (dst []byte, err error) { 495 dst = buf 496 497 // Field (0) 'Epoch' 498 dst = ssz.MarshalUint64(dst, uint64(c.Epoch)) 499 500 // Field (1) 'Root' 501 if len(c.Root) != 32 { 502 err = ssz.ErrBytesLength 503 return 504 } 505 dst = append(dst, c.Root...) 506 507 return 508 } 509 510 // UnmarshalSSZ ssz unmarshals the Checkpoint object 511 func (c *Checkpoint) UnmarshalSSZ(buf []byte) error { 512 var err error 513 size := uint64(len(buf)) 514 if size != 40 { 515 return ssz.ErrSize 516 } 517 518 // Field (0) 'Epoch' 519 c.Epoch = github_com_prysmaticlabs_eth2_types.Epoch(ssz.UnmarshallUint64(buf[0:8])) 520 521 // Field (1) 'Root' 522 if cap(c.Root) == 0 { 523 c.Root = make([]byte, 0, len(buf[8:40])) 524 } 525 c.Root = append(c.Root, buf[8:40]...) 526 527 return err 528 } 529 530 // SizeSSZ returns the ssz encoded size in bytes for the Checkpoint object 531 func (c *Checkpoint) SizeSSZ() (size int) { 532 size = 40 533 return 534 } 535 536 // HashTreeRoot ssz hashes the Checkpoint object 537 func (c *Checkpoint) HashTreeRoot() ([32]byte, error) { 538 return ssz.HashWithDefaultHasher(c) 539 } 540 541 // HashTreeRootWith ssz hashes the Checkpoint object with a hasher 542 func (c *Checkpoint) HashTreeRootWith(hh *ssz.Hasher) (err error) { 543 indx := hh.Index() 544 545 // Field (0) 'Epoch' 546 hh.PutUint64(uint64(c.Epoch)) 547 548 // Field (1) 'Root' 549 if len(c.Root) != 32 { 550 err = ssz.ErrBytesLength 551 return 552 } 553 hh.PutBytes(c.Root) 554 555 hh.Merkleize(indx) 556 return 557 } 558 559 // MarshalSSZ ssz marshals the BeaconBlock object 560 func (b *BeaconBlock) MarshalSSZ() ([]byte, error) { 561 return ssz.MarshalSSZ(b) 562 } 563 564 // MarshalSSZTo ssz marshals the BeaconBlock object to a target array 565 func (b *BeaconBlock) MarshalSSZTo(buf []byte) (dst []byte, err error) { 566 dst = buf 567 offset := int(84) 568 569 // Field (0) 'Slot' 570 dst = ssz.MarshalUint64(dst, uint64(b.Slot)) 571 572 // Field (1) 'ProposerIndex' 573 dst = ssz.MarshalUint64(dst, uint64(b.ProposerIndex)) 574 575 // Field (2) 'ParentRoot' 576 if len(b.ParentRoot) != 32 { 577 err = ssz.ErrBytesLength 578 return 579 } 580 dst = append(dst, b.ParentRoot...) 581 582 // Field (3) 'StateRoot' 583 if len(b.StateRoot) != 32 { 584 err = ssz.ErrBytesLength 585 return 586 } 587 dst = append(dst, b.StateRoot...) 588 589 // Offset (4) 'Body' 590 dst = ssz.WriteOffset(dst, offset) 591 if b.Body == nil { 592 b.Body = new(BeaconBlockBody) 593 } 594 offset += b.Body.SizeSSZ() 595 596 // Field (4) 'Body' 597 if dst, err = b.Body.MarshalSSZTo(dst); err != nil { 598 return 599 } 600 601 return 602 } 603 604 // UnmarshalSSZ ssz unmarshals the BeaconBlock object 605 func (b *BeaconBlock) UnmarshalSSZ(buf []byte) error { 606 var err error 607 size := uint64(len(buf)) 608 if size < 84 { 609 return ssz.ErrSize 610 } 611 612 tail := buf 613 var o4 uint64 614 615 // Field (0) 'Slot' 616 b.Slot = github_com_prysmaticlabs_eth2_types.Slot(ssz.UnmarshallUint64(buf[0:8])) 617 618 // Field (1) 'ProposerIndex' 619 b.ProposerIndex = github_com_prysmaticlabs_eth2_types.ValidatorIndex(ssz.UnmarshallUint64(buf[8:16])) 620 621 // Field (2) 'ParentRoot' 622 if cap(b.ParentRoot) == 0 { 623 b.ParentRoot = make([]byte, 0, len(buf[16:48])) 624 } 625 b.ParentRoot = append(b.ParentRoot, buf[16:48]...) 626 627 // Field (3) 'StateRoot' 628 if cap(b.StateRoot) == 0 { 629 b.StateRoot = make([]byte, 0, len(buf[48:80])) 630 } 631 b.StateRoot = append(b.StateRoot, buf[48:80]...) 632 633 // Offset (4) 'Body' 634 if o4 = ssz.ReadOffset(buf[80:84]); o4 > size { 635 return ssz.ErrOffset 636 } 637 638 if o4 < 84 { 639 return ssz.ErrInvalidVariableOffset 640 } 641 642 // Field (4) 'Body' 643 { 644 buf = tail[o4:] 645 if b.Body == nil { 646 b.Body = new(BeaconBlockBody) 647 } 648 if err = b.Body.UnmarshalSSZ(buf); err != nil { 649 return err 650 } 651 } 652 return err 653 } 654 655 // SizeSSZ returns the ssz encoded size in bytes for the BeaconBlock object 656 func (b *BeaconBlock) SizeSSZ() (size int) { 657 size = 84 658 659 // Field (4) 'Body' 660 if b.Body == nil { 661 b.Body = new(BeaconBlockBody) 662 } 663 size += b.Body.SizeSSZ() 664 665 return 666 } 667 668 // HashTreeRoot ssz hashes the BeaconBlock object 669 func (b *BeaconBlock) HashTreeRoot() ([32]byte, error) { 670 return ssz.HashWithDefaultHasher(b) 671 } 672 673 // HashTreeRootWith ssz hashes the BeaconBlock object with a hasher 674 func (b *BeaconBlock) HashTreeRootWith(hh *ssz.Hasher) (err error) { 675 indx := hh.Index() 676 677 // Field (0) 'Slot' 678 hh.PutUint64(uint64(b.Slot)) 679 680 // Field (1) 'ProposerIndex' 681 hh.PutUint64(uint64(b.ProposerIndex)) 682 683 // Field (2) 'ParentRoot' 684 if len(b.ParentRoot) != 32 { 685 err = ssz.ErrBytesLength 686 return 687 } 688 hh.PutBytes(b.ParentRoot) 689 690 // Field (3) 'StateRoot' 691 if len(b.StateRoot) != 32 { 692 err = ssz.ErrBytesLength 693 return 694 } 695 hh.PutBytes(b.StateRoot) 696 697 // Field (4) 'Body' 698 if err = b.Body.HashTreeRootWith(hh); err != nil { 699 return 700 } 701 702 hh.Merkleize(indx) 703 return 704 } 705 706 // MarshalSSZ ssz marshals the BeaconBlockV1 object 707 func (b *BeaconBlockV1) MarshalSSZ() ([]byte, error) { 708 return ssz.MarshalSSZ(b) 709 } 710 711 // MarshalSSZTo ssz marshals the BeaconBlockV1 object to a target array 712 func (b *BeaconBlockV1) MarshalSSZTo(buf []byte) (dst []byte, err error) { 713 dst = buf 714 offset := int(84) 715 716 // Field (0) 'Slot' 717 dst = ssz.MarshalUint64(dst, uint64(b.Slot)) 718 719 // Field (1) 'ProposerIndex' 720 dst = ssz.MarshalUint64(dst, uint64(b.ProposerIndex)) 721 722 // Field (2) 'ParentRoot' 723 if len(b.ParentRoot) != 32 { 724 err = ssz.ErrBytesLength 725 return 726 } 727 dst = append(dst, b.ParentRoot...) 728 729 // Field (3) 'StateRoot' 730 if len(b.StateRoot) != 32 { 731 err = ssz.ErrBytesLength 732 return 733 } 734 dst = append(dst, b.StateRoot...) 735 736 // Offset (4) 'Body' 737 dst = ssz.WriteOffset(dst, offset) 738 if b.Body == nil { 739 b.Body = new(BeaconBlockBodyV1) 740 } 741 offset += b.Body.SizeSSZ() 742 743 // Field (4) 'Body' 744 if dst, err = b.Body.MarshalSSZTo(dst); err != nil { 745 return 746 } 747 748 return 749 } 750 751 // UnmarshalSSZ ssz unmarshals the BeaconBlockV1 object 752 func (b *BeaconBlockV1) UnmarshalSSZ(buf []byte) error { 753 var err error 754 size := uint64(len(buf)) 755 if size < 84 { 756 return ssz.ErrSize 757 } 758 759 tail := buf 760 var o4 uint64 761 762 // Field (0) 'Slot' 763 b.Slot = github_com_prysmaticlabs_eth2_types.Slot(ssz.UnmarshallUint64(buf[0:8])) 764 765 // Field (1) 'ProposerIndex' 766 b.ProposerIndex = github_com_prysmaticlabs_eth2_types.ValidatorIndex(ssz.UnmarshallUint64(buf[8:16])) 767 768 // Field (2) 'ParentRoot' 769 if cap(b.ParentRoot) == 0 { 770 b.ParentRoot = make([]byte, 0, len(buf[16:48])) 771 } 772 b.ParentRoot = append(b.ParentRoot, buf[16:48]...) 773 774 // Field (3) 'StateRoot' 775 if cap(b.StateRoot) == 0 { 776 b.StateRoot = make([]byte, 0, len(buf[48:80])) 777 } 778 b.StateRoot = append(b.StateRoot, buf[48:80]...) 779 780 // Offset (4) 'Body' 781 if o4 = ssz.ReadOffset(buf[80:84]); o4 > size { 782 return ssz.ErrOffset 783 } 784 785 if o4 < 84 { 786 return ssz.ErrInvalidVariableOffset 787 } 788 789 // Field (4) 'Body' 790 { 791 buf = tail[o4:] 792 if b.Body == nil { 793 b.Body = new(BeaconBlockBodyV1) 794 } 795 if err = b.Body.UnmarshalSSZ(buf); err != nil { 796 return err 797 } 798 } 799 return err 800 } 801 802 // SizeSSZ returns the ssz encoded size in bytes for the BeaconBlockV1 object 803 func (b *BeaconBlockV1) SizeSSZ() (size int) { 804 size = 84 805 806 // Field (4) 'Body' 807 if b.Body == nil { 808 b.Body = new(BeaconBlockBodyV1) 809 } 810 size += b.Body.SizeSSZ() 811 812 return 813 } 814 815 // HashTreeRoot ssz hashes the BeaconBlockV1 object 816 func (b *BeaconBlockV1) HashTreeRoot() ([32]byte, error) { 817 return ssz.HashWithDefaultHasher(b) 818 } 819 820 // HashTreeRootWith ssz hashes the BeaconBlockV1 object with a hasher 821 func (b *BeaconBlockV1) HashTreeRootWith(hh *ssz.Hasher) (err error) { 822 indx := hh.Index() 823 824 // Field (0) 'Slot' 825 hh.PutUint64(uint64(b.Slot)) 826 827 // Field (1) 'ProposerIndex' 828 hh.PutUint64(uint64(b.ProposerIndex)) 829 830 // Field (2) 'ParentRoot' 831 if len(b.ParentRoot) != 32 { 832 err = ssz.ErrBytesLength 833 return 834 } 835 hh.PutBytes(b.ParentRoot) 836 837 // Field (3) 'StateRoot' 838 if len(b.StateRoot) != 32 { 839 err = ssz.ErrBytesLength 840 return 841 } 842 hh.PutBytes(b.StateRoot) 843 844 // Field (4) 'Body' 845 if err = b.Body.HashTreeRootWith(hh); err != nil { 846 return 847 } 848 849 hh.Merkleize(indx) 850 return 851 } 852 853 // MarshalSSZ ssz marshals the SignedBeaconBlock object 854 func (s *SignedBeaconBlock) MarshalSSZ() ([]byte, error) { 855 return ssz.MarshalSSZ(s) 856 } 857 858 // MarshalSSZTo ssz marshals the SignedBeaconBlock object to a target array 859 func (s *SignedBeaconBlock) MarshalSSZTo(buf []byte) (dst []byte, err error) { 860 dst = buf 861 offset := int(100) 862 863 // Offset (0) 'Block' 864 dst = ssz.WriteOffset(dst, offset) 865 if s.Block == nil { 866 s.Block = new(BeaconBlock) 867 } 868 offset += s.Block.SizeSSZ() 869 870 // Field (1) 'Signature' 871 if len(s.Signature) != 96 { 872 err = ssz.ErrBytesLength 873 return 874 } 875 dst = append(dst, s.Signature...) 876 877 // Field (0) 'Block' 878 if dst, err = s.Block.MarshalSSZTo(dst); err != nil { 879 return 880 } 881 882 return 883 } 884 885 // UnmarshalSSZ ssz unmarshals the SignedBeaconBlock object 886 func (s *SignedBeaconBlock) UnmarshalSSZ(buf []byte) error { 887 var err error 888 size := uint64(len(buf)) 889 if size < 100 { 890 return ssz.ErrSize 891 } 892 893 tail := buf 894 var o0 uint64 895 896 // Offset (0) 'Block' 897 if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { 898 return ssz.ErrOffset 899 } 900 901 if o0 < 100 { 902 return ssz.ErrInvalidVariableOffset 903 } 904 905 // Field (1) 'Signature' 906 if cap(s.Signature) == 0 { 907 s.Signature = make([]byte, 0, len(buf[4:100])) 908 } 909 s.Signature = append(s.Signature, buf[4:100]...) 910 911 // Field (0) 'Block' 912 { 913 buf = tail[o0:] 914 if s.Block == nil { 915 s.Block = new(BeaconBlock) 916 } 917 if err = s.Block.UnmarshalSSZ(buf); err != nil { 918 return err 919 } 920 } 921 return err 922 } 923 924 // SizeSSZ returns the ssz encoded size in bytes for the SignedBeaconBlock object 925 func (s *SignedBeaconBlock) SizeSSZ() (size int) { 926 size = 100 927 928 // Field (0) 'Block' 929 if s.Block == nil { 930 s.Block = new(BeaconBlock) 931 } 932 size += s.Block.SizeSSZ() 933 934 return 935 } 936 937 // HashTreeRoot ssz hashes the SignedBeaconBlock object 938 func (s *SignedBeaconBlock) HashTreeRoot() ([32]byte, error) { 939 return ssz.HashWithDefaultHasher(s) 940 } 941 942 // HashTreeRootWith ssz hashes the SignedBeaconBlock object with a hasher 943 func (s *SignedBeaconBlock) HashTreeRootWith(hh *ssz.Hasher) (err error) { 944 indx := hh.Index() 945 946 // Field (0) 'Block' 947 if err = s.Block.HashTreeRootWith(hh); err != nil { 948 return 949 } 950 951 // Field (1) 'Signature' 952 if len(s.Signature) != 96 { 953 err = ssz.ErrBytesLength 954 return 955 } 956 hh.PutBytes(s.Signature) 957 958 hh.Merkleize(indx) 959 return 960 } 961 962 // MarshalSSZ ssz marshals the SignedBeaconBlockV1 object 963 func (s *SignedBeaconBlockV1) MarshalSSZ() ([]byte, error) { 964 return ssz.MarshalSSZ(s) 965 } 966 967 // MarshalSSZTo ssz marshals the SignedBeaconBlockV1 object to a target array 968 func (s *SignedBeaconBlockV1) MarshalSSZTo(buf []byte) (dst []byte, err error) { 969 dst = buf 970 offset := int(100) 971 972 // Offset (0) 'Block' 973 dst = ssz.WriteOffset(dst, offset) 974 if s.Block == nil { 975 s.Block = new(BeaconBlockV1) 976 } 977 offset += s.Block.SizeSSZ() 978 979 // Field (1) 'Signature' 980 if len(s.Signature) != 96 { 981 err = ssz.ErrBytesLength 982 return 983 } 984 dst = append(dst, s.Signature...) 985 986 // Field (0) 'Block' 987 if dst, err = s.Block.MarshalSSZTo(dst); err != nil { 988 return 989 } 990 991 return 992 } 993 994 // UnmarshalSSZ ssz unmarshals the SignedBeaconBlockV1 object 995 func (s *SignedBeaconBlockV1) UnmarshalSSZ(buf []byte) error { 996 var err error 997 size := uint64(len(buf)) 998 if size < 100 { 999 return ssz.ErrSize 1000 } 1001 1002 tail := buf 1003 var o0 uint64 1004 1005 // Offset (0) 'Block' 1006 if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { 1007 return ssz.ErrOffset 1008 } 1009 1010 if o0 < 100 { 1011 return ssz.ErrInvalidVariableOffset 1012 } 1013 1014 // Field (1) 'Signature' 1015 if cap(s.Signature) == 0 { 1016 s.Signature = make([]byte, 0, len(buf[4:100])) 1017 } 1018 s.Signature = append(s.Signature, buf[4:100]...) 1019 1020 // Field (0) 'Block' 1021 { 1022 buf = tail[o0:] 1023 if s.Block == nil { 1024 s.Block = new(BeaconBlockV1) 1025 } 1026 if err = s.Block.UnmarshalSSZ(buf); err != nil { 1027 return err 1028 } 1029 } 1030 return err 1031 } 1032 1033 // SizeSSZ returns the ssz encoded size in bytes for the SignedBeaconBlockV1 object 1034 func (s *SignedBeaconBlockV1) SizeSSZ() (size int) { 1035 size = 100 1036 1037 // Field (0) 'Block' 1038 if s.Block == nil { 1039 s.Block = new(BeaconBlockV1) 1040 } 1041 size += s.Block.SizeSSZ() 1042 1043 return 1044 } 1045 1046 // HashTreeRoot ssz hashes the SignedBeaconBlockV1 object 1047 func (s *SignedBeaconBlockV1) HashTreeRoot() ([32]byte, error) { 1048 return ssz.HashWithDefaultHasher(s) 1049 } 1050 1051 // HashTreeRootWith ssz hashes the SignedBeaconBlockV1 object with a hasher 1052 func (s *SignedBeaconBlockV1) HashTreeRootWith(hh *ssz.Hasher) (err error) { 1053 indx := hh.Index() 1054 1055 // Field (0) 'Block' 1056 if err = s.Block.HashTreeRootWith(hh); err != nil { 1057 return 1058 } 1059 1060 // Field (1) 'Signature' 1061 if len(s.Signature) != 96 { 1062 err = ssz.ErrBytesLength 1063 return 1064 } 1065 hh.PutBytes(s.Signature) 1066 1067 hh.Merkleize(indx) 1068 return 1069 } 1070 1071 // MarshalSSZ ssz marshals the BeaconBlockBody object 1072 func (b *BeaconBlockBody) MarshalSSZ() ([]byte, error) { 1073 return ssz.MarshalSSZ(b) 1074 } 1075 1076 // MarshalSSZTo ssz marshals the BeaconBlockBody object to a target array 1077 func (b *BeaconBlockBody) MarshalSSZTo(buf []byte) (dst []byte, err error) { 1078 dst = buf 1079 offset := int(220) 1080 1081 // Field (0) 'RandaoReveal' 1082 if len(b.RandaoReveal) != 96 { 1083 err = ssz.ErrBytesLength 1084 return 1085 } 1086 dst = append(dst, b.RandaoReveal...) 1087 1088 // Field (1) 'Eth1Data' 1089 if b.Eth1Data == nil { 1090 b.Eth1Data = new(Eth1Data) 1091 } 1092 if dst, err = b.Eth1Data.MarshalSSZTo(dst); err != nil { 1093 return 1094 } 1095 1096 // Field (2) 'Graffiti' 1097 if len(b.Graffiti) != 32 { 1098 err = ssz.ErrBytesLength 1099 return 1100 } 1101 dst = append(dst, b.Graffiti...) 1102 1103 // Offset (3) 'ProposerSlashings' 1104 dst = ssz.WriteOffset(dst, offset) 1105 offset += len(b.ProposerSlashings) * 416 1106 1107 // Offset (4) 'AttesterSlashings' 1108 dst = ssz.WriteOffset(dst, offset) 1109 for ii := 0; ii < len(b.AttesterSlashings); ii++ { 1110 offset += 4 1111 offset += b.AttesterSlashings[ii].SizeSSZ() 1112 } 1113 1114 // Offset (5) 'Attestations' 1115 dst = ssz.WriteOffset(dst, offset) 1116 for ii := 0; ii < len(b.Attestations); ii++ { 1117 offset += 4 1118 offset += b.Attestations[ii].SizeSSZ() 1119 } 1120 1121 // Offset (6) 'Deposits' 1122 dst = ssz.WriteOffset(dst, offset) 1123 offset += len(b.Deposits) * 1240 1124 1125 // Offset (7) 'VoluntaryExits' 1126 dst = ssz.WriteOffset(dst, offset) 1127 offset += len(b.VoluntaryExits) * 112 1128 1129 // Field (3) 'ProposerSlashings' 1130 if len(b.ProposerSlashings) > 16 { 1131 err = ssz.ErrListTooBig 1132 return 1133 } 1134 for ii := 0; ii < len(b.ProposerSlashings); ii++ { 1135 if dst, err = b.ProposerSlashings[ii].MarshalSSZTo(dst); err != nil { 1136 return 1137 } 1138 } 1139 1140 // Field (4) 'AttesterSlashings' 1141 if len(b.AttesterSlashings) > 2 { 1142 err = ssz.ErrListTooBig 1143 return 1144 } 1145 { 1146 offset = 4 * len(b.AttesterSlashings) 1147 for ii := 0; ii < len(b.AttesterSlashings); ii++ { 1148 dst = ssz.WriteOffset(dst, offset) 1149 offset += b.AttesterSlashings[ii].SizeSSZ() 1150 } 1151 } 1152 for ii := 0; ii < len(b.AttesterSlashings); ii++ { 1153 if dst, err = b.AttesterSlashings[ii].MarshalSSZTo(dst); err != nil { 1154 return 1155 } 1156 } 1157 1158 // Field (5) 'Attestations' 1159 if len(b.Attestations) > 128 { 1160 err = ssz.ErrListTooBig 1161 return 1162 } 1163 { 1164 offset = 4 * len(b.Attestations) 1165 for ii := 0; ii < len(b.Attestations); ii++ { 1166 dst = ssz.WriteOffset(dst, offset) 1167 offset += b.Attestations[ii].SizeSSZ() 1168 } 1169 } 1170 for ii := 0; ii < len(b.Attestations); ii++ { 1171 if dst, err = b.Attestations[ii].MarshalSSZTo(dst); err != nil { 1172 return 1173 } 1174 } 1175 1176 // Field (6) 'Deposits' 1177 if len(b.Deposits) > 16 { 1178 err = ssz.ErrListTooBig 1179 return 1180 } 1181 for ii := 0; ii < len(b.Deposits); ii++ { 1182 if dst, err = b.Deposits[ii].MarshalSSZTo(dst); err != nil { 1183 return 1184 } 1185 } 1186 1187 // Field (7) 'VoluntaryExits' 1188 if len(b.VoluntaryExits) > 16 { 1189 err = ssz.ErrListTooBig 1190 return 1191 } 1192 for ii := 0; ii < len(b.VoluntaryExits); ii++ { 1193 if dst, err = b.VoluntaryExits[ii].MarshalSSZTo(dst); err != nil { 1194 return 1195 } 1196 } 1197 1198 return 1199 } 1200 1201 // UnmarshalSSZ ssz unmarshals the BeaconBlockBody object 1202 func (b *BeaconBlockBody) UnmarshalSSZ(buf []byte) error { 1203 var err error 1204 size := uint64(len(buf)) 1205 if size < 220 { 1206 return ssz.ErrSize 1207 } 1208 1209 tail := buf 1210 var o3, o4, o5, o6, o7 uint64 1211 1212 // Field (0) 'RandaoReveal' 1213 if cap(b.RandaoReveal) == 0 { 1214 b.RandaoReveal = make([]byte, 0, len(buf[0:96])) 1215 } 1216 b.RandaoReveal = append(b.RandaoReveal, buf[0:96]...) 1217 1218 // Field (1) 'Eth1Data' 1219 if b.Eth1Data == nil { 1220 b.Eth1Data = new(Eth1Data) 1221 } 1222 if err = b.Eth1Data.UnmarshalSSZ(buf[96:168]); err != nil { 1223 return err 1224 } 1225 1226 // Field (2) 'Graffiti' 1227 if cap(b.Graffiti) == 0 { 1228 b.Graffiti = make([]byte, 0, len(buf[168:200])) 1229 } 1230 b.Graffiti = append(b.Graffiti, buf[168:200]...) 1231 1232 // Offset (3) 'ProposerSlashings' 1233 if o3 = ssz.ReadOffset(buf[200:204]); o3 > size { 1234 return ssz.ErrOffset 1235 } 1236 1237 if o3 < 220 { 1238 return ssz.ErrInvalidVariableOffset 1239 } 1240 1241 // Offset (4) 'AttesterSlashings' 1242 if o4 = ssz.ReadOffset(buf[204:208]); o4 > size || o3 > o4 { 1243 return ssz.ErrOffset 1244 } 1245 1246 // Offset (5) 'Attestations' 1247 if o5 = ssz.ReadOffset(buf[208:212]); o5 > size || o4 > o5 { 1248 return ssz.ErrOffset 1249 } 1250 1251 // Offset (6) 'Deposits' 1252 if o6 = ssz.ReadOffset(buf[212:216]); o6 > size || o5 > o6 { 1253 return ssz.ErrOffset 1254 } 1255 1256 // Offset (7) 'VoluntaryExits' 1257 if o7 = ssz.ReadOffset(buf[216:220]); o7 > size || o6 > o7 { 1258 return ssz.ErrOffset 1259 } 1260 1261 // Field (3) 'ProposerSlashings' 1262 { 1263 buf = tail[o3:o4] 1264 num, err := ssz.DivideInt2(len(buf), 416, 16) 1265 if err != nil { 1266 return err 1267 } 1268 b.ProposerSlashings = make([]*ProposerSlashing, num) 1269 for ii := 0; ii < num; ii++ { 1270 if b.ProposerSlashings[ii] == nil { 1271 b.ProposerSlashings[ii] = new(ProposerSlashing) 1272 } 1273 if err = b.ProposerSlashings[ii].UnmarshalSSZ(buf[ii*416 : (ii+1)*416]); err != nil { 1274 return err 1275 } 1276 } 1277 } 1278 1279 // Field (4) 'AttesterSlashings' 1280 { 1281 buf = tail[o4:o5] 1282 num, err := ssz.DecodeDynamicLength(buf, 2) 1283 if err != nil { 1284 return err 1285 } 1286 b.AttesterSlashings = make([]*AttesterSlashing, num) 1287 err = ssz.UnmarshalDynamic(buf, num, func(indx int, buf []byte) (err error) { 1288 if b.AttesterSlashings[indx] == nil { 1289 b.AttesterSlashings[indx] = new(AttesterSlashing) 1290 } 1291 if err = b.AttesterSlashings[indx].UnmarshalSSZ(buf); err != nil { 1292 return err 1293 } 1294 return nil 1295 }) 1296 if err != nil { 1297 return err 1298 } 1299 } 1300 1301 // Field (5) 'Attestations' 1302 { 1303 buf = tail[o5:o6] 1304 num, err := ssz.DecodeDynamicLength(buf, 128) 1305 if err != nil { 1306 return err 1307 } 1308 b.Attestations = make([]*Attestation, num) 1309 err = ssz.UnmarshalDynamic(buf, num, func(indx int, buf []byte) (err error) { 1310 if b.Attestations[indx] == nil { 1311 b.Attestations[indx] = new(Attestation) 1312 } 1313 if err = b.Attestations[indx].UnmarshalSSZ(buf); err != nil { 1314 return err 1315 } 1316 return nil 1317 }) 1318 if err != nil { 1319 return err 1320 } 1321 } 1322 1323 // Field (6) 'Deposits' 1324 { 1325 buf = tail[o6:o7] 1326 num, err := ssz.DivideInt2(len(buf), 1240, 16) 1327 if err != nil { 1328 return err 1329 } 1330 b.Deposits = make([]*Deposit, num) 1331 for ii := 0; ii < num; ii++ { 1332 if b.Deposits[ii] == nil { 1333 b.Deposits[ii] = new(Deposit) 1334 } 1335 if err = b.Deposits[ii].UnmarshalSSZ(buf[ii*1240 : (ii+1)*1240]); err != nil { 1336 return err 1337 } 1338 } 1339 } 1340 1341 // Field (7) 'VoluntaryExits' 1342 { 1343 buf = tail[o7:] 1344 num, err := ssz.DivideInt2(len(buf), 112, 16) 1345 if err != nil { 1346 return err 1347 } 1348 b.VoluntaryExits = make([]*SignedVoluntaryExit, num) 1349 for ii := 0; ii < num; ii++ { 1350 if b.VoluntaryExits[ii] == nil { 1351 b.VoluntaryExits[ii] = new(SignedVoluntaryExit) 1352 } 1353 if err = b.VoluntaryExits[ii].UnmarshalSSZ(buf[ii*112 : (ii+1)*112]); err != nil { 1354 return err 1355 } 1356 } 1357 } 1358 return err 1359 } 1360 1361 // SizeSSZ returns the ssz encoded size in bytes for the BeaconBlockBody object 1362 func (b *BeaconBlockBody) SizeSSZ() (size int) { 1363 size = 220 1364 1365 // Field (3) 'ProposerSlashings' 1366 size += len(b.ProposerSlashings) * 416 1367 1368 // Field (4) 'AttesterSlashings' 1369 for ii := 0; ii < len(b.AttesterSlashings); ii++ { 1370 size += 4 1371 size += b.AttesterSlashings[ii].SizeSSZ() 1372 } 1373 1374 // Field (5) 'Attestations' 1375 for ii := 0; ii < len(b.Attestations); ii++ { 1376 size += 4 1377 size += b.Attestations[ii].SizeSSZ() 1378 } 1379 1380 // Field (6) 'Deposits' 1381 size += len(b.Deposits) * 1240 1382 1383 // Field (7) 'VoluntaryExits' 1384 size += len(b.VoluntaryExits) * 112 1385 1386 return 1387 } 1388 1389 // HashTreeRoot ssz hashes the BeaconBlockBody object 1390 func (b *BeaconBlockBody) HashTreeRoot() ([32]byte, error) { 1391 return ssz.HashWithDefaultHasher(b) 1392 } 1393 1394 // HashTreeRootWith ssz hashes the BeaconBlockBody object with a hasher 1395 func (b *BeaconBlockBody) HashTreeRootWith(hh *ssz.Hasher) (err error) { 1396 indx := hh.Index() 1397 1398 // Field (0) 'RandaoReveal' 1399 if len(b.RandaoReveal) != 96 { 1400 err = ssz.ErrBytesLength 1401 return 1402 } 1403 hh.PutBytes(b.RandaoReveal) 1404 1405 // Field (1) 'Eth1Data' 1406 if err = b.Eth1Data.HashTreeRootWith(hh); err != nil { 1407 return 1408 } 1409 1410 // Field (2) 'Graffiti' 1411 if len(b.Graffiti) != 32 { 1412 err = ssz.ErrBytesLength 1413 return 1414 } 1415 hh.PutBytes(b.Graffiti) 1416 1417 // Field (3) 'ProposerSlashings' 1418 { 1419 subIndx := hh.Index() 1420 num := uint64(len(b.ProposerSlashings)) 1421 if num > 16 { 1422 err = ssz.ErrIncorrectListSize 1423 return 1424 } 1425 for i := uint64(0); i < num; i++ { 1426 if err = b.ProposerSlashings[i].HashTreeRootWith(hh); err != nil { 1427 return 1428 } 1429 } 1430 hh.MerkleizeWithMixin(subIndx, num, 16) 1431 } 1432 1433 // Field (4) 'AttesterSlashings' 1434 { 1435 subIndx := hh.Index() 1436 num := uint64(len(b.AttesterSlashings)) 1437 if num > 2 { 1438 err = ssz.ErrIncorrectListSize 1439 return 1440 } 1441 for i := uint64(0); i < num; i++ { 1442 if err = b.AttesterSlashings[i].HashTreeRootWith(hh); err != nil { 1443 return 1444 } 1445 } 1446 hh.MerkleizeWithMixin(subIndx, num, 2) 1447 } 1448 1449 // Field (5) 'Attestations' 1450 { 1451 subIndx := hh.Index() 1452 num := uint64(len(b.Attestations)) 1453 if num > 128 { 1454 err = ssz.ErrIncorrectListSize 1455 return 1456 } 1457 for i := uint64(0); i < num; i++ { 1458 if err = b.Attestations[i].HashTreeRootWith(hh); err != nil { 1459 return 1460 } 1461 } 1462 hh.MerkleizeWithMixin(subIndx, num, 128) 1463 } 1464 1465 // Field (6) 'Deposits' 1466 { 1467 subIndx := hh.Index() 1468 num := uint64(len(b.Deposits)) 1469 if num > 16 { 1470 err = ssz.ErrIncorrectListSize 1471 return 1472 } 1473 for i := uint64(0); i < num; i++ { 1474 if err = b.Deposits[i].HashTreeRootWith(hh); err != nil { 1475 return 1476 } 1477 } 1478 hh.MerkleizeWithMixin(subIndx, num, 16) 1479 } 1480 1481 // Field (7) 'VoluntaryExits' 1482 { 1483 subIndx := hh.Index() 1484 num := uint64(len(b.VoluntaryExits)) 1485 if num > 16 { 1486 err = ssz.ErrIncorrectListSize 1487 return 1488 } 1489 for i := uint64(0); i < num; i++ { 1490 if err = b.VoluntaryExits[i].HashTreeRootWith(hh); err != nil { 1491 return 1492 } 1493 } 1494 hh.MerkleizeWithMixin(subIndx, num, 16) 1495 } 1496 1497 hh.Merkleize(indx) 1498 return 1499 } 1500 1501 // MarshalSSZ ssz marshals the BeaconBlockBodyV1 object 1502 func (b *BeaconBlockBodyV1) MarshalSSZ() ([]byte, error) { 1503 return ssz.MarshalSSZ(b) 1504 } 1505 1506 // MarshalSSZTo ssz marshals the BeaconBlockBodyV1 object to a target array 1507 func (b *BeaconBlockBodyV1) MarshalSSZTo(buf []byte) (dst []byte, err error) { 1508 dst = buf 1509 offset := int(380) 1510 1511 // Field (0) 'RandaoReveal' 1512 if len(b.RandaoReveal) != 96 { 1513 err = ssz.ErrBytesLength 1514 return 1515 } 1516 dst = append(dst, b.RandaoReveal...) 1517 1518 // Field (1) 'Eth1Data' 1519 if b.Eth1Data == nil { 1520 b.Eth1Data = new(Eth1Data) 1521 } 1522 if dst, err = b.Eth1Data.MarshalSSZTo(dst); err != nil { 1523 return 1524 } 1525 1526 // Field (2) 'Graffiti' 1527 if len(b.Graffiti) != 32 { 1528 err = ssz.ErrBytesLength 1529 return 1530 } 1531 dst = append(dst, b.Graffiti...) 1532 1533 // Offset (3) 'ProposerSlashings' 1534 dst = ssz.WriteOffset(dst, offset) 1535 offset += len(b.ProposerSlashings) * 416 1536 1537 // Offset (4) 'AttesterSlashings' 1538 dst = ssz.WriteOffset(dst, offset) 1539 for ii := 0; ii < len(b.AttesterSlashings); ii++ { 1540 offset += 4 1541 offset += b.AttesterSlashings[ii].SizeSSZ() 1542 } 1543 1544 // Offset (5) 'Attestations' 1545 dst = ssz.WriteOffset(dst, offset) 1546 for ii := 0; ii < len(b.Attestations); ii++ { 1547 offset += 4 1548 offset += b.Attestations[ii].SizeSSZ() 1549 } 1550 1551 // Offset (6) 'Deposits' 1552 dst = ssz.WriteOffset(dst, offset) 1553 offset += len(b.Deposits) * 1240 1554 1555 // Offset (7) 'VoluntaryExits' 1556 dst = ssz.WriteOffset(dst, offset) 1557 offset += len(b.VoluntaryExits) * 112 1558 1559 // Field (8) 'SyncCommitteeBits' 1560 if len(b.SyncCommitteeBits) != 64 { 1561 err = ssz.ErrBytesLength 1562 return 1563 } 1564 dst = append(dst, b.SyncCommitteeBits...) 1565 1566 // Field (9) 'SyncCommitteeSignature' 1567 if len(b.SyncCommitteeSignature) != 96 { 1568 err = ssz.ErrBytesLength 1569 return 1570 } 1571 dst = append(dst, b.SyncCommitteeSignature...) 1572 1573 // Field (3) 'ProposerSlashings' 1574 if len(b.ProposerSlashings) > 16 { 1575 err = ssz.ErrListTooBig 1576 return 1577 } 1578 for ii := 0; ii < len(b.ProposerSlashings); ii++ { 1579 if dst, err = b.ProposerSlashings[ii].MarshalSSZTo(dst); err != nil { 1580 return 1581 } 1582 } 1583 1584 // Field (4) 'AttesterSlashings' 1585 if len(b.AttesterSlashings) > 2 { 1586 err = ssz.ErrListTooBig 1587 return 1588 } 1589 { 1590 offset = 4 * len(b.AttesterSlashings) 1591 for ii := 0; ii < len(b.AttesterSlashings); ii++ { 1592 dst = ssz.WriteOffset(dst, offset) 1593 offset += b.AttesterSlashings[ii].SizeSSZ() 1594 } 1595 } 1596 for ii := 0; ii < len(b.AttesterSlashings); ii++ { 1597 if dst, err = b.AttesterSlashings[ii].MarshalSSZTo(dst); err != nil { 1598 return 1599 } 1600 } 1601 1602 // Field (5) 'Attestations' 1603 if len(b.Attestations) > 128 { 1604 err = ssz.ErrListTooBig 1605 return 1606 } 1607 { 1608 offset = 4 * len(b.Attestations) 1609 for ii := 0; ii < len(b.Attestations); ii++ { 1610 dst = ssz.WriteOffset(dst, offset) 1611 offset += b.Attestations[ii].SizeSSZ() 1612 } 1613 } 1614 for ii := 0; ii < len(b.Attestations); ii++ { 1615 if dst, err = b.Attestations[ii].MarshalSSZTo(dst); err != nil { 1616 return 1617 } 1618 } 1619 1620 // Field (6) 'Deposits' 1621 if len(b.Deposits) > 16 { 1622 err = ssz.ErrListTooBig 1623 return 1624 } 1625 for ii := 0; ii < len(b.Deposits); ii++ { 1626 if dst, err = b.Deposits[ii].MarshalSSZTo(dst); err != nil { 1627 return 1628 } 1629 } 1630 1631 // Field (7) 'VoluntaryExits' 1632 if len(b.VoluntaryExits) > 16 { 1633 err = ssz.ErrListTooBig 1634 return 1635 } 1636 for ii := 0; ii < len(b.VoluntaryExits); ii++ { 1637 if dst, err = b.VoluntaryExits[ii].MarshalSSZTo(dst); err != nil { 1638 return 1639 } 1640 } 1641 1642 return 1643 } 1644 1645 // UnmarshalSSZ ssz unmarshals the BeaconBlockBodyV1 object 1646 func (b *BeaconBlockBodyV1) UnmarshalSSZ(buf []byte) error { 1647 var err error 1648 size := uint64(len(buf)) 1649 if size < 380 { 1650 return ssz.ErrSize 1651 } 1652 1653 tail := buf 1654 var o3, o4, o5, o6, o7 uint64 1655 1656 // Field (0) 'RandaoReveal' 1657 if cap(b.RandaoReveal) == 0 { 1658 b.RandaoReveal = make([]byte, 0, len(buf[0:96])) 1659 } 1660 b.RandaoReveal = append(b.RandaoReveal, buf[0:96]...) 1661 1662 // Field (1) 'Eth1Data' 1663 if b.Eth1Data == nil { 1664 b.Eth1Data = new(Eth1Data) 1665 } 1666 if err = b.Eth1Data.UnmarshalSSZ(buf[96:168]); err != nil { 1667 return err 1668 } 1669 1670 // Field (2) 'Graffiti' 1671 if cap(b.Graffiti) == 0 { 1672 b.Graffiti = make([]byte, 0, len(buf[168:200])) 1673 } 1674 b.Graffiti = append(b.Graffiti, buf[168:200]...) 1675 1676 // Offset (3) 'ProposerSlashings' 1677 if o3 = ssz.ReadOffset(buf[200:204]); o3 > size { 1678 return ssz.ErrOffset 1679 } 1680 1681 if o3 < 380 { 1682 return ssz.ErrInvalidVariableOffset 1683 } 1684 1685 // Offset (4) 'AttesterSlashings' 1686 if o4 = ssz.ReadOffset(buf[204:208]); o4 > size || o3 > o4 { 1687 return ssz.ErrOffset 1688 } 1689 1690 // Offset (5) 'Attestations' 1691 if o5 = ssz.ReadOffset(buf[208:212]); o5 > size || o4 > o5 { 1692 return ssz.ErrOffset 1693 } 1694 1695 // Offset (6) 'Deposits' 1696 if o6 = ssz.ReadOffset(buf[212:216]); o6 > size || o5 > o6 { 1697 return ssz.ErrOffset 1698 } 1699 1700 // Offset (7) 'VoluntaryExits' 1701 if o7 = ssz.ReadOffset(buf[216:220]); o7 > size || o6 > o7 { 1702 return ssz.ErrOffset 1703 } 1704 1705 // Field (8) 'SyncCommitteeBits' 1706 if cap(b.SyncCommitteeBits) == 0 { 1707 b.SyncCommitteeBits = make([]byte, 0, len(buf[220:284])) 1708 } 1709 b.SyncCommitteeBits = append(b.SyncCommitteeBits, buf[220:284]...) 1710 1711 // Field (9) 'SyncCommitteeSignature' 1712 if cap(b.SyncCommitteeSignature) == 0 { 1713 b.SyncCommitteeSignature = make([]byte, 0, len(buf[284:380])) 1714 } 1715 b.SyncCommitteeSignature = append(b.SyncCommitteeSignature, buf[284:380]...) 1716 1717 // Field (3) 'ProposerSlashings' 1718 { 1719 buf = tail[o3:o4] 1720 num, err := ssz.DivideInt2(len(buf), 416, 16) 1721 if err != nil { 1722 return err 1723 } 1724 b.ProposerSlashings = make([]*ProposerSlashing, num) 1725 for ii := 0; ii < num; ii++ { 1726 if b.ProposerSlashings[ii] == nil { 1727 b.ProposerSlashings[ii] = new(ProposerSlashing) 1728 } 1729 if err = b.ProposerSlashings[ii].UnmarshalSSZ(buf[ii*416 : (ii+1)*416]); err != nil { 1730 return err 1731 } 1732 } 1733 } 1734 1735 // Field (4) 'AttesterSlashings' 1736 { 1737 buf = tail[o4:o5] 1738 num, err := ssz.DecodeDynamicLength(buf, 2) 1739 if err != nil { 1740 return err 1741 } 1742 b.AttesterSlashings = make([]*AttesterSlashing, num) 1743 err = ssz.UnmarshalDynamic(buf, num, func(indx int, buf []byte) (err error) { 1744 if b.AttesterSlashings[indx] == nil { 1745 b.AttesterSlashings[indx] = new(AttesterSlashing) 1746 } 1747 if err = b.AttesterSlashings[indx].UnmarshalSSZ(buf); err != nil { 1748 return err 1749 } 1750 return nil 1751 }) 1752 if err != nil { 1753 return err 1754 } 1755 } 1756 1757 // Field (5) 'Attestations' 1758 { 1759 buf = tail[o5:o6] 1760 num, err := ssz.DecodeDynamicLength(buf, 128) 1761 if err != nil { 1762 return err 1763 } 1764 b.Attestations = make([]*Attestation, num) 1765 err = ssz.UnmarshalDynamic(buf, num, func(indx int, buf []byte) (err error) { 1766 if b.Attestations[indx] == nil { 1767 b.Attestations[indx] = new(Attestation) 1768 } 1769 if err = b.Attestations[indx].UnmarshalSSZ(buf); err != nil { 1770 return err 1771 } 1772 return nil 1773 }) 1774 if err != nil { 1775 return err 1776 } 1777 } 1778 1779 // Field (6) 'Deposits' 1780 { 1781 buf = tail[o6:o7] 1782 num, err := ssz.DivideInt2(len(buf), 1240, 16) 1783 if err != nil { 1784 return err 1785 } 1786 b.Deposits = make([]*Deposit, num) 1787 for ii := 0; ii < num; ii++ { 1788 if b.Deposits[ii] == nil { 1789 b.Deposits[ii] = new(Deposit) 1790 } 1791 if err = b.Deposits[ii].UnmarshalSSZ(buf[ii*1240 : (ii+1)*1240]); err != nil { 1792 return err 1793 } 1794 } 1795 } 1796 1797 // Field (7) 'VoluntaryExits' 1798 { 1799 buf = tail[o7:] 1800 num, err := ssz.DivideInt2(len(buf), 112, 16) 1801 if err != nil { 1802 return err 1803 } 1804 b.VoluntaryExits = make([]*SignedVoluntaryExit, num) 1805 for ii := 0; ii < num; ii++ { 1806 if b.VoluntaryExits[ii] == nil { 1807 b.VoluntaryExits[ii] = new(SignedVoluntaryExit) 1808 } 1809 if err = b.VoluntaryExits[ii].UnmarshalSSZ(buf[ii*112 : (ii+1)*112]); err != nil { 1810 return err 1811 } 1812 } 1813 } 1814 return err 1815 } 1816 1817 // SizeSSZ returns the ssz encoded size in bytes for the BeaconBlockBodyV1 object 1818 func (b *BeaconBlockBodyV1) SizeSSZ() (size int) { 1819 size = 380 1820 1821 // Field (3) 'ProposerSlashings' 1822 size += len(b.ProposerSlashings) * 416 1823 1824 // Field (4) 'AttesterSlashings' 1825 for ii := 0; ii < len(b.AttesterSlashings); ii++ { 1826 size += 4 1827 size += b.AttesterSlashings[ii].SizeSSZ() 1828 } 1829 1830 // Field (5) 'Attestations' 1831 for ii := 0; ii < len(b.Attestations); ii++ { 1832 size += 4 1833 size += b.Attestations[ii].SizeSSZ() 1834 } 1835 1836 // Field (6) 'Deposits' 1837 size += len(b.Deposits) * 1240 1838 1839 // Field (7) 'VoluntaryExits' 1840 size += len(b.VoluntaryExits) * 112 1841 1842 return 1843 } 1844 1845 // HashTreeRoot ssz hashes the BeaconBlockBodyV1 object 1846 func (b *BeaconBlockBodyV1) HashTreeRoot() ([32]byte, error) { 1847 return ssz.HashWithDefaultHasher(b) 1848 } 1849 1850 // HashTreeRootWith ssz hashes the BeaconBlockBodyV1 object with a hasher 1851 func (b *BeaconBlockBodyV1) HashTreeRootWith(hh *ssz.Hasher) (err error) { 1852 indx := hh.Index() 1853 1854 // Field (0) 'RandaoReveal' 1855 if len(b.RandaoReveal) != 96 { 1856 err = ssz.ErrBytesLength 1857 return 1858 } 1859 hh.PutBytes(b.RandaoReveal) 1860 1861 // Field (1) 'Eth1Data' 1862 if err = b.Eth1Data.HashTreeRootWith(hh); err != nil { 1863 return 1864 } 1865 1866 // Field (2) 'Graffiti' 1867 if len(b.Graffiti) != 32 { 1868 err = ssz.ErrBytesLength 1869 return 1870 } 1871 hh.PutBytes(b.Graffiti) 1872 1873 // Field (3) 'ProposerSlashings' 1874 { 1875 subIndx := hh.Index() 1876 num := uint64(len(b.ProposerSlashings)) 1877 if num > 16 { 1878 err = ssz.ErrIncorrectListSize 1879 return 1880 } 1881 for i := uint64(0); i < num; i++ { 1882 if err = b.ProposerSlashings[i].HashTreeRootWith(hh); err != nil { 1883 return 1884 } 1885 } 1886 hh.MerkleizeWithMixin(subIndx, num, 16) 1887 } 1888 1889 // Field (4) 'AttesterSlashings' 1890 { 1891 subIndx := hh.Index() 1892 num := uint64(len(b.AttesterSlashings)) 1893 if num > 2 { 1894 err = ssz.ErrIncorrectListSize 1895 return 1896 } 1897 for i := uint64(0); i < num; i++ { 1898 if err = b.AttesterSlashings[i].HashTreeRootWith(hh); err != nil { 1899 return 1900 } 1901 } 1902 hh.MerkleizeWithMixin(subIndx, num, 2) 1903 } 1904 1905 // Field (5) 'Attestations' 1906 { 1907 subIndx := hh.Index() 1908 num := uint64(len(b.Attestations)) 1909 if num > 128 { 1910 err = ssz.ErrIncorrectListSize 1911 return 1912 } 1913 for i := uint64(0); i < num; i++ { 1914 if err = b.Attestations[i].HashTreeRootWith(hh); err != nil { 1915 return 1916 } 1917 } 1918 hh.MerkleizeWithMixin(subIndx, num, 128) 1919 } 1920 1921 // Field (6) 'Deposits' 1922 { 1923 subIndx := hh.Index() 1924 num := uint64(len(b.Deposits)) 1925 if num > 16 { 1926 err = ssz.ErrIncorrectListSize 1927 return 1928 } 1929 for i := uint64(0); i < num; i++ { 1930 if err = b.Deposits[i].HashTreeRootWith(hh); err != nil { 1931 return 1932 } 1933 } 1934 hh.MerkleizeWithMixin(subIndx, num, 16) 1935 } 1936 1937 // Field (7) 'VoluntaryExits' 1938 { 1939 subIndx := hh.Index() 1940 num := uint64(len(b.VoluntaryExits)) 1941 if num > 16 { 1942 err = ssz.ErrIncorrectListSize 1943 return 1944 } 1945 for i := uint64(0); i < num; i++ { 1946 if err = b.VoluntaryExits[i].HashTreeRootWith(hh); err != nil { 1947 return 1948 } 1949 } 1950 hh.MerkleizeWithMixin(subIndx, num, 16) 1951 } 1952 1953 // Field (8) 'SyncCommitteeBits' 1954 if len(b.SyncCommitteeBits) != 64 { 1955 err = ssz.ErrBytesLength 1956 return 1957 } 1958 hh.PutBytes(b.SyncCommitteeBits) 1959 1960 // Field (9) 'SyncCommitteeSignature' 1961 if len(b.SyncCommitteeSignature) != 96 { 1962 err = ssz.ErrBytesLength 1963 return 1964 } 1965 hh.PutBytes(b.SyncCommitteeSignature) 1966 1967 hh.Merkleize(indx) 1968 return 1969 } 1970 1971 // MarshalSSZ ssz marshals the ProposerSlashing object 1972 func (p *ProposerSlashing) MarshalSSZ() ([]byte, error) { 1973 return ssz.MarshalSSZ(p) 1974 } 1975 1976 // MarshalSSZTo ssz marshals the ProposerSlashing object to a target array 1977 func (p *ProposerSlashing) MarshalSSZTo(buf []byte) (dst []byte, err error) { 1978 dst = buf 1979 1980 // Field (0) 'SignedHeader_1' 1981 if p.SignedHeader_1 == nil { 1982 p.SignedHeader_1 = new(SignedBeaconBlockHeader) 1983 } 1984 if dst, err = p.SignedHeader_1.MarshalSSZTo(dst); err != nil { 1985 return 1986 } 1987 1988 // Field (1) 'SignedHeader_2' 1989 if p.SignedHeader_2 == nil { 1990 p.SignedHeader_2 = new(SignedBeaconBlockHeader) 1991 } 1992 if dst, err = p.SignedHeader_2.MarshalSSZTo(dst); err != nil { 1993 return 1994 } 1995 1996 return 1997 } 1998 1999 // UnmarshalSSZ ssz unmarshals the ProposerSlashing object 2000 func (p *ProposerSlashing) UnmarshalSSZ(buf []byte) error { 2001 var err error 2002 size := uint64(len(buf)) 2003 if size != 416 { 2004 return ssz.ErrSize 2005 } 2006 2007 // Field (0) 'SignedHeader_1' 2008 if p.SignedHeader_1 == nil { 2009 p.SignedHeader_1 = new(SignedBeaconBlockHeader) 2010 } 2011 if err = p.SignedHeader_1.UnmarshalSSZ(buf[0:208]); err != nil { 2012 return err 2013 } 2014 2015 // Field (1) 'SignedHeader_2' 2016 if p.SignedHeader_2 == nil { 2017 p.SignedHeader_2 = new(SignedBeaconBlockHeader) 2018 } 2019 if err = p.SignedHeader_2.UnmarshalSSZ(buf[208:416]); err != nil { 2020 return err 2021 } 2022 2023 return err 2024 } 2025 2026 // SizeSSZ returns the ssz encoded size in bytes for the ProposerSlashing object 2027 func (p *ProposerSlashing) SizeSSZ() (size int) { 2028 size = 416 2029 return 2030 } 2031 2032 // HashTreeRoot ssz hashes the ProposerSlashing object 2033 func (p *ProposerSlashing) HashTreeRoot() ([32]byte, error) { 2034 return ssz.HashWithDefaultHasher(p) 2035 } 2036 2037 // HashTreeRootWith ssz hashes the ProposerSlashing object with a hasher 2038 func (p *ProposerSlashing) HashTreeRootWith(hh *ssz.Hasher) (err error) { 2039 indx := hh.Index() 2040 2041 // Field (0) 'SignedHeader_1' 2042 if err = p.SignedHeader_1.HashTreeRootWith(hh); err != nil { 2043 return 2044 } 2045 2046 // Field (1) 'SignedHeader_2' 2047 if err = p.SignedHeader_2.HashTreeRootWith(hh); err != nil { 2048 return 2049 } 2050 2051 hh.Merkleize(indx) 2052 return 2053 } 2054 2055 // MarshalSSZ ssz marshals the AttesterSlashing object 2056 func (a *AttesterSlashing) MarshalSSZ() ([]byte, error) { 2057 return ssz.MarshalSSZ(a) 2058 } 2059 2060 // MarshalSSZTo ssz marshals the AttesterSlashing object to a target array 2061 func (a *AttesterSlashing) MarshalSSZTo(buf []byte) (dst []byte, err error) { 2062 dst = buf 2063 offset := int(8) 2064 2065 // Offset (0) 'Attestation_1' 2066 dst = ssz.WriteOffset(dst, offset) 2067 if a.Attestation_1 == nil { 2068 a.Attestation_1 = new(IndexedAttestation) 2069 } 2070 offset += a.Attestation_1.SizeSSZ() 2071 2072 // Offset (1) 'Attestation_2' 2073 dst = ssz.WriteOffset(dst, offset) 2074 if a.Attestation_2 == nil { 2075 a.Attestation_2 = new(IndexedAttestation) 2076 } 2077 offset += a.Attestation_2.SizeSSZ() 2078 2079 // Field (0) 'Attestation_1' 2080 if dst, err = a.Attestation_1.MarshalSSZTo(dst); err != nil { 2081 return 2082 } 2083 2084 // Field (1) 'Attestation_2' 2085 if dst, err = a.Attestation_2.MarshalSSZTo(dst); err != nil { 2086 return 2087 } 2088 2089 return 2090 } 2091 2092 // UnmarshalSSZ ssz unmarshals the AttesterSlashing object 2093 func (a *AttesterSlashing) UnmarshalSSZ(buf []byte) error { 2094 var err error 2095 size := uint64(len(buf)) 2096 if size < 8 { 2097 return ssz.ErrSize 2098 } 2099 2100 tail := buf 2101 var o0, o1 uint64 2102 2103 // Offset (0) 'Attestation_1' 2104 if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { 2105 return ssz.ErrOffset 2106 } 2107 2108 if o0 < 8 { 2109 return ssz.ErrInvalidVariableOffset 2110 } 2111 2112 // Offset (1) 'Attestation_2' 2113 if o1 = ssz.ReadOffset(buf[4:8]); o1 > size || o0 > o1 { 2114 return ssz.ErrOffset 2115 } 2116 2117 // Field (0) 'Attestation_1' 2118 { 2119 buf = tail[o0:o1] 2120 if a.Attestation_1 == nil { 2121 a.Attestation_1 = new(IndexedAttestation) 2122 } 2123 if err = a.Attestation_1.UnmarshalSSZ(buf); err != nil { 2124 return err 2125 } 2126 } 2127 2128 // Field (1) 'Attestation_2' 2129 { 2130 buf = tail[o1:] 2131 if a.Attestation_2 == nil { 2132 a.Attestation_2 = new(IndexedAttestation) 2133 } 2134 if err = a.Attestation_2.UnmarshalSSZ(buf); err != nil { 2135 return err 2136 } 2137 } 2138 return err 2139 } 2140 2141 // SizeSSZ returns the ssz encoded size in bytes for the AttesterSlashing object 2142 func (a *AttesterSlashing) SizeSSZ() (size int) { 2143 size = 8 2144 2145 // Field (0) 'Attestation_1' 2146 if a.Attestation_1 == nil { 2147 a.Attestation_1 = new(IndexedAttestation) 2148 } 2149 size += a.Attestation_1.SizeSSZ() 2150 2151 // Field (1) 'Attestation_2' 2152 if a.Attestation_2 == nil { 2153 a.Attestation_2 = new(IndexedAttestation) 2154 } 2155 size += a.Attestation_2.SizeSSZ() 2156 2157 return 2158 } 2159 2160 // HashTreeRoot ssz hashes the AttesterSlashing object 2161 func (a *AttesterSlashing) HashTreeRoot() ([32]byte, error) { 2162 return ssz.HashWithDefaultHasher(a) 2163 } 2164 2165 // HashTreeRootWith ssz hashes the AttesterSlashing object with a hasher 2166 func (a *AttesterSlashing) HashTreeRootWith(hh *ssz.Hasher) (err error) { 2167 indx := hh.Index() 2168 2169 // Field (0) 'Attestation_1' 2170 if err = a.Attestation_1.HashTreeRootWith(hh); err != nil { 2171 return 2172 } 2173 2174 // Field (1) 'Attestation_2' 2175 if err = a.Attestation_2.HashTreeRootWith(hh); err != nil { 2176 return 2177 } 2178 2179 hh.Merkleize(indx) 2180 return 2181 } 2182 2183 // MarshalSSZ ssz marshals the Deposit object 2184 func (d *Deposit) MarshalSSZ() ([]byte, error) { 2185 return ssz.MarshalSSZ(d) 2186 } 2187 2188 // MarshalSSZTo ssz marshals the Deposit object to a target array 2189 func (d *Deposit) MarshalSSZTo(buf []byte) (dst []byte, err error) { 2190 dst = buf 2191 2192 // Field (0) 'Proof' 2193 if len(d.Proof) != 33 { 2194 err = ssz.ErrVectorLength 2195 return 2196 } 2197 for ii := 0; ii < 33; ii++ { 2198 if len(d.Proof[ii]) != 32 { 2199 err = ssz.ErrBytesLength 2200 return 2201 } 2202 dst = append(dst, d.Proof[ii]...) 2203 } 2204 2205 // Field (1) 'Data' 2206 if d.Data == nil { 2207 d.Data = new(Deposit_Data) 2208 } 2209 if dst, err = d.Data.MarshalSSZTo(dst); err != nil { 2210 return 2211 } 2212 2213 return 2214 } 2215 2216 // UnmarshalSSZ ssz unmarshals the Deposit object 2217 func (d *Deposit) UnmarshalSSZ(buf []byte) error { 2218 var err error 2219 size := uint64(len(buf)) 2220 if size != 1240 { 2221 return ssz.ErrSize 2222 } 2223 2224 // Field (0) 'Proof' 2225 d.Proof = make([][]byte, 33) 2226 for ii := 0; ii < 33; ii++ { 2227 if cap(d.Proof[ii]) == 0 { 2228 d.Proof[ii] = make([]byte, 0, len(buf[0:1056][ii*32:(ii+1)*32])) 2229 } 2230 d.Proof[ii] = append(d.Proof[ii], buf[0:1056][ii*32:(ii+1)*32]...) 2231 } 2232 2233 // Field (1) 'Data' 2234 if d.Data == nil { 2235 d.Data = new(Deposit_Data) 2236 } 2237 if err = d.Data.UnmarshalSSZ(buf[1056:1240]); err != nil { 2238 return err 2239 } 2240 2241 return err 2242 } 2243 2244 // SizeSSZ returns the ssz encoded size in bytes for the Deposit object 2245 func (d *Deposit) SizeSSZ() (size int) { 2246 size = 1240 2247 return 2248 } 2249 2250 // HashTreeRoot ssz hashes the Deposit object 2251 func (d *Deposit) HashTreeRoot() ([32]byte, error) { 2252 return ssz.HashWithDefaultHasher(d) 2253 } 2254 2255 // HashTreeRootWith ssz hashes the Deposit object with a hasher 2256 func (d *Deposit) HashTreeRootWith(hh *ssz.Hasher) (err error) { 2257 indx := hh.Index() 2258 2259 // Field (0) 'Proof' 2260 { 2261 if len(d.Proof) != 33 { 2262 err = ssz.ErrVectorLength 2263 return 2264 } 2265 subIndx := hh.Index() 2266 for _, i := range d.Proof { 2267 if len(i) != 32 { 2268 err = ssz.ErrBytesLength 2269 return 2270 } 2271 hh.Append(i) 2272 } 2273 hh.Merkleize(subIndx) 2274 } 2275 2276 // Field (1) 'Data' 2277 if err = d.Data.HashTreeRootWith(hh); err != nil { 2278 return 2279 } 2280 2281 hh.Merkleize(indx) 2282 return 2283 } 2284 2285 // MarshalSSZ ssz marshals the VoluntaryExit object 2286 func (v *VoluntaryExit) MarshalSSZ() ([]byte, error) { 2287 return ssz.MarshalSSZ(v) 2288 } 2289 2290 // MarshalSSZTo ssz marshals the VoluntaryExit object to a target array 2291 func (v *VoluntaryExit) MarshalSSZTo(buf []byte) (dst []byte, err error) { 2292 dst = buf 2293 2294 // Field (0) 'Epoch' 2295 dst = ssz.MarshalUint64(dst, uint64(v.Epoch)) 2296 2297 // Field (1) 'ValidatorIndex' 2298 dst = ssz.MarshalUint64(dst, uint64(v.ValidatorIndex)) 2299 2300 return 2301 } 2302 2303 // UnmarshalSSZ ssz unmarshals the VoluntaryExit object 2304 func (v *VoluntaryExit) UnmarshalSSZ(buf []byte) error { 2305 var err error 2306 size := uint64(len(buf)) 2307 if size != 16 { 2308 return ssz.ErrSize 2309 } 2310 2311 // Field (0) 'Epoch' 2312 v.Epoch = github_com_prysmaticlabs_eth2_types.Epoch(ssz.UnmarshallUint64(buf[0:8])) 2313 2314 // Field (1) 'ValidatorIndex' 2315 v.ValidatorIndex = github_com_prysmaticlabs_eth2_types.ValidatorIndex(ssz.UnmarshallUint64(buf[8:16])) 2316 2317 return err 2318 } 2319 2320 // SizeSSZ returns the ssz encoded size in bytes for the VoluntaryExit object 2321 func (v *VoluntaryExit) SizeSSZ() (size int) { 2322 size = 16 2323 return 2324 } 2325 2326 // HashTreeRoot ssz hashes the VoluntaryExit object 2327 func (v *VoluntaryExit) HashTreeRoot() ([32]byte, error) { 2328 return ssz.HashWithDefaultHasher(v) 2329 } 2330 2331 // HashTreeRootWith ssz hashes the VoluntaryExit object with a hasher 2332 func (v *VoluntaryExit) HashTreeRootWith(hh *ssz.Hasher) (err error) { 2333 indx := hh.Index() 2334 2335 // Field (0) 'Epoch' 2336 hh.PutUint64(uint64(v.Epoch)) 2337 2338 // Field (1) 'ValidatorIndex' 2339 hh.PutUint64(uint64(v.ValidatorIndex)) 2340 2341 hh.Merkleize(indx) 2342 return 2343 } 2344 2345 // MarshalSSZ ssz marshals the SignedVoluntaryExit object 2346 func (s *SignedVoluntaryExit) MarshalSSZ() ([]byte, error) { 2347 return ssz.MarshalSSZ(s) 2348 } 2349 2350 // MarshalSSZTo ssz marshals the SignedVoluntaryExit object to a target array 2351 func (s *SignedVoluntaryExit) MarshalSSZTo(buf []byte) (dst []byte, err error) { 2352 dst = buf 2353 2354 // Field (0) 'Message' 2355 if s.Message == nil { 2356 s.Message = new(VoluntaryExit) 2357 } 2358 if dst, err = s.Message.MarshalSSZTo(dst); err != nil { 2359 return 2360 } 2361 2362 // Field (1) 'Signature' 2363 if len(s.Signature) != 96 { 2364 err = ssz.ErrBytesLength 2365 return 2366 } 2367 dst = append(dst, s.Signature...) 2368 2369 return 2370 } 2371 2372 // UnmarshalSSZ ssz unmarshals the SignedVoluntaryExit object 2373 func (s *SignedVoluntaryExit) UnmarshalSSZ(buf []byte) error { 2374 var err error 2375 size := uint64(len(buf)) 2376 if size != 112 { 2377 return ssz.ErrSize 2378 } 2379 2380 // Field (0) 'Message' 2381 if s.Message == nil { 2382 s.Message = new(VoluntaryExit) 2383 } 2384 if err = s.Message.UnmarshalSSZ(buf[0:16]); err != nil { 2385 return err 2386 } 2387 2388 // Field (1) 'Signature' 2389 if cap(s.Signature) == 0 { 2390 s.Signature = make([]byte, 0, len(buf[16:112])) 2391 } 2392 s.Signature = append(s.Signature, buf[16:112]...) 2393 2394 return err 2395 } 2396 2397 // SizeSSZ returns the ssz encoded size in bytes for the SignedVoluntaryExit object 2398 func (s *SignedVoluntaryExit) SizeSSZ() (size int) { 2399 size = 112 2400 return 2401 } 2402 2403 // HashTreeRoot ssz hashes the SignedVoluntaryExit object 2404 func (s *SignedVoluntaryExit) HashTreeRoot() ([32]byte, error) { 2405 return ssz.HashWithDefaultHasher(s) 2406 } 2407 2408 // HashTreeRootWith ssz hashes the SignedVoluntaryExit object with a hasher 2409 func (s *SignedVoluntaryExit) HashTreeRootWith(hh *ssz.Hasher) (err error) { 2410 indx := hh.Index() 2411 2412 // Field (0) 'Message' 2413 if err = s.Message.HashTreeRootWith(hh); err != nil { 2414 return 2415 } 2416 2417 // Field (1) 'Signature' 2418 if len(s.Signature) != 96 { 2419 err = ssz.ErrBytesLength 2420 return 2421 } 2422 hh.PutBytes(s.Signature) 2423 2424 hh.Merkleize(indx) 2425 return 2426 } 2427 2428 // MarshalSSZ ssz marshals the Eth1Data object 2429 func (e *Eth1Data) MarshalSSZ() ([]byte, error) { 2430 return ssz.MarshalSSZ(e) 2431 } 2432 2433 // MarshalSSZTo ssz marshals the Eth1Data object to a target array 2434 func (e *Eth1Data) MarshalSSZTo(buf []byte) (dst []byte, err error) { 2435 dst = buf 2436 2437 // Field (0) 'DepositRoot' 2438 if len(e.DepositRoot) != 32 { 2439 err = ssz.ErrBytesLength 2440 return 2441 } 2442 dst = append(dst, e.DepositRoot...) 2443 2444 // Field (1) 'DepositCount' 2445 dst = ssz.MarshalUint64(dst, e.DepositCount) 2446 2447 // Field (2) 'BlockHash' 2448 if len(e.BlockHash) != 32 { 2449 err = ssz.ErrBytesLength 2450 return 2451 } 2452 dst = append(dst, e.BlockHash...) 2453 2454 return 2455 } 2456 2457 // UnmarshalSSZ ssz unmarshals the Eth1Data object 2458 func (e *Eth1Data) UnmarshalSSZ(buf []byte) error { 2459 var err error 2460 size := uint64(len(buf)) 2461 if size != 72 { 2462 return ssz.ErrSize 2463 } 2464 2465 // Field (0) 'DepositRoot' 2466 if cap(e.DepositRoot) == 0 { 2467 e.DepositRoot = make([]byte, 0, len(buf[0:32])) 2468 } 2469 e.DepositRoot = append(e.DepositRoot, buf[0:32]...) 2470 2471 // Field (1) 'DepositCount' 2472 e.DepositCount = ssz.UnmarshallUint64(buf[32:40]) 2473 2474 // Field (2) 'BlockHash' 2475 if cap(e.BlockHash) == 0 { 2476 e.BlockHash = make([]byte, 0, len(buf[40:72])) 2477 } 2478 e.BlockHash = append(e.BlockHash, buf[40:72]...) 2479 2480 return err 2481 } 2482 2483 // SizeSSZ returns the ssz encoded size in bytes for the Eth1Data object 2484 func (e *Eth1Data) SizeSSZ() (size int) { 2485 size = 72 2486 return 2487 } 2488 2489 // HashTreeRoot ssz hashes the Eth1Data object 2490 func (e *Eth1Data) HashTreeRoot() ([32]byte, error) { 2491 return ssz.HashWithDefaultHasher(e) 2492 } 2493 2494 // HashTreeRootWith ssz hashes the Eth1Data object with a hasher 2495 func (e *Eth1Data) HashTreeRootWith(hh *ssz.Hasher) (err error) { 2496 indx := hh.Index() 2497 2498 // Field (0) 'DepositRoot' 2499 if len(e.DepositRoot) != 32 { 2500 err = ssz.ErrBytesLength 2501 return 2502 } 2503 hh.PutBytes(e.DepositRoot) 2504 2505 // Field (1) 'DepositCount' 2506 hh.PutUint64(e.DepositCount) 2507 2508 // Field (2) 'BlockHash' 2509 if len(e.BlockHash) != 32 { 2510 err = ssz.ErrBytesLength 2511 return 2512 } 2513 hh.PutBytes(e.BlockHash) 2514 2515 hh.Merkleize(indx) 2516 return 2517 } 2518 2519 // MarshalSSZ ssz marshals the BeaconBlockHeader object 2520 func (b *BeaconBlockHeader) MarshalSSZ() ([]byte, error) { 2521 return ssz.MarshalSSZ(b) 2522 } 2523 2524 // MarshalSSZTo ssz marshals the BeaconBlockHeader object to a target array 2525 func (b *BeaconBlockHeader) MarshalSSZTo(buf []byte) (dst []byte, err error) { 2526 dst = buf 2527 2528 // Field (0) 'Slot' 2529 dst = ssz.MarshalUint64(dst, uint64(b.Slot)) 2530 2531 // Field (1) 'ProposerIndex' 2532 dst = ssz.MarshalUint64(dst, uint64(b.ProposerIndex)) 2533 2534 // Field (2) 'ParentRoot' 2535 if len(b.ParentRoot) != 32 { 2536 err = ssz.ErrBytesLength 2537 return 2538 } 2539 dst = append(dst, b.ParentRoot...) 2540 2541 // Field (3) 'StateRoot' 2542 if len(b.StateRoot) != 32 { 2543 err = ssz.ErrBytesLength 2544 return 2545 } 2546 dst = append(dst, b.StateRoot...) 2547 2548 // Field (4) 'BodyRoot' 2549 if len(b.BodyRoot) != 32 { 2550 err = ssz.ErrBytesLength 2551 return 2552 } 2553 dst = append(dst, b.BodyRoot...) 2554 2555 return 2556 } 2557 2558 // UnmarshalSSZ ssz unmarshals the BeaconBlockHeader object 2559 func (b *BeaconBlockHeader) UnmarshalSSZ(buf []byte) error { 2560 var err error 2561 size := uint64(len(buf)) 2562 if size != 112 { 2563 return ssz.ErrSize 2564 } 2565 2566 // Field (0) 'Slot' 2567 b.Slot = github_com_prysmaticlabs_eth2_types.Slot(ssz.UnmarshallUint64(buf[0:8])) 2568 2569 // Field (1) 'ProposerIndex' 2570 b.ProposerIndex = github_com_prysmaticlabs_eth2_types.ValidatorIndex(ssz.UnmarshallUint64(buf[8:16])) 2571 2572 // Field (2) 'ParentRoot' 2573 if cap(b.ParentRoot) == 0 { 2574 b.ParentRoot = make([]byte, 0, len(buf[16:48])) 2575 } 2576 b.ParentRoot = append(b.ParentRoot, buf[16:48]...) 2577 2578 // Field (3) 'StateRoot' 2579 if cap(b.StateRoot) == 0 { 2580 b.StateRoot = make([]byte, 0, len(buf[48:80])) 2581 } 2582 b.StateRoot = append(b.StateRoot, buf[48:80]...) 2583 2584 // Field (4) 'BodyRoot' 2585 if cap(b.BodyRoot) == 0 { 2586 b.BodyRoot = make([]byte, 0, len(buf[80:112])) 2587 } 2588 b.BodyRoot = append(b.BodyRoot, buf[80:112]...) 2589 2590 return err 2591 } 2592 2593 // SizeSSZ returns the ssz encoded size in bytes for the BeaconBlockHeader object 2594 func (b *BeaconBlockHeader) SizeSSZ() (size int) { 2595 size = 112 2596 return 2597 } 2598 2599 // HashTreeRoot ssz hashes the BeaconBlockHeader object 2600 func (b *BeaconBlockHeader) HashTreeRoot() ([32]byte, error) { 2601 return ssz.HashWithDefaultHasher(b) 2602 } 2603 2604 // HashTreeRootWith ssz hashes the BeaconBlockHeader object with a hasher 2605 func (b *BeaconBlockHeader) HashTreeRootWith(hh *ssz.Hasher) (err error) { 2606 indx := hh.Index() 2607 2608 // Field (0) 'Slot' 2609 hh.PutUint64(uint64(b.Slot)) 2610 2611 // Field (1) 'ProposerIndex' 2612 hh.PutUint64(uint64(b.ProposerIndex)) 2613 2614 // Field (2) 'ParentRoot' 2615 if len(b.ParentRoot) != 32 { 2616 err = ssz.ErrBytesLength 2617 return 2618 } 2619 hh.PutBytes(b.ParentRoot) 2620 2621 // Field (3) 'StateRoot' 2622 if len(b.StateRoot) != 32 { 2623 err = ssz.ErrBytesLength 2624 return 2625 } 2626 hh.PutBytes(b.StateRoot) 2627 2628 // Field (4) 'BodyRoot' 2629 if len(b.BodyRoot) != 32 { 2630 err = ssz.ErrBytesLength 2631 return 2632 } 2633 hh.PutBytes(b.BodyRoot) 2634 2635 hh.Merkleize(indx) 2636 return 2637 } 2638 2639 // MarshalSSZ ssz marshals the SignedBeaconBlockHeader object 2640 func (s *SignedBeaconBlockHeader) MarshalSSZ() ([]byte, error) { 2641 return ssz.MarshalSSZ(s) 2642 } 2643 2644 // MarshalSSZTo ssz marshals the SignedBeaconBlockHeader object to a target array 2645 func (s *SignedBeaconBlockHeader) MarshalSSZTo(buf []byte) (dst []byte, err error) { 2646 dst = buf 2647 2648 // Field (0) 'Message' 2649 if s.Message == nil { 2650 s.Message = new(BeaconBlockHeader) 2651 } 2652 if dst, err = s.Message.MarshalSSZTo(dst); err != nil { 2653 return 2654 } 2655 2656 // Field (1) 'Signature' 2657 if len(s.Signature) != 96 { 2658 err = ssz.ErrBytesLength 2659 return 2660 } 2661 dst = append(dst, s.Signature...) 2662 2663 return 2664 } 2665 2666 // UnmarshalSSZ ssz unmarshals the SignedBeaconBlockHeader object 2667 func (s *SignedBeaconBlockHeader) UnmarshalSSZ(buf []byte) error { 2668 var err error 2669 size := uint64(len(buf)) 2670 if size != 208 { 2671 return ssz.ErrSize 2672 } 2673 2674 // Field (0) 'Message' 2675 if s.Message == nil { 2676 s.Message = new(BeaconBlockHeader) 2677 } 2678 if err = s.Message.UnmarshalSSZ(buf[0:112]); err != nil { 2679 return err 2680 } 2681 2682 // Field (1) 'Signature' 2683 if cap(s.Signature) == 0 { 2684 s.Signature = make([]byte, 0, len(buf[112:208])) 2685 } 2686 s.Signature = append(s.Signature, buf[112:208]...) 2687 2688 return err 2689 } 2690 2691 // SizeSSZ returns the ssz encoded size in bytes for the SignedBeaconBlockHeader object 2692 func (s *SignedBeaconBlockHeader) SizeSSZ() (size int) { 2693 size = 208 2694 return 2695 } 2696 2697 // HashTreeRoot ssz hashes the SignedBeaconBlockHeader object 2698 func (s *SignedBeaconBlockHeader) HashTreeRoot() ([32]byte, error) { 2699 return ssz.HashWithDefaultHasher(s) 2700 } 2701 2702 // HashTreeRootWith ssz hashes the SignedBeaconBlockHeader object with a hasher 2703 func (s *SignedBeaconBlockHeader) HashTreeRootWith(hh *ssz.Hasher) (err error) { 2704 indx := hh.Index() 2705 2706 // Field (0) 'Message' 2707 if err = s.Message.HashTreeRootWith(hh); err != nil { 2708 return 2709 } 2710 2711 // Field (1) 'Signature' 2712 if len(s.Signature) != 96 { 2713 err = ssz.ErrBytesLength 2714 return 2715 } 2716 hh.PutBytes(s.Signature) 2717 2718 hh.Merkleize(indx) 2719 return 2720 } 2721 2722 // MarshalSSZ ssz marshals the IndexedAttestation object 2723 func (i *IndexedAttestation) MarshalSSZ() ([]byte, error) { 2724 return ssz.MarshalSSZ(i) 2725 } 2726 2727 // MarshalSSZTo ssz marshals the IndexedAttestation object to a target array 2728 func (i *IndexedAttestation) MarshalSSZTo(buf []byte) (dst []byte, err error) { 2729 dst = buf 2730 offset := int(228) 2731 2732 // Offset (0) 'AttestingIndices' 2733 dst = ssz.WriteOffset(dst, offset) 2734 offset += len(i.AttestingIndices) * 8 2735 2736 // Field (1) 'Data' 2737 if i.Data == nil { 2738 i.Data = new(AttestationData) 2739 } 2740 if dst, err = i.Data.MarshalSSZTo(dst); err != nil { 2741 return 2742 } 2743 2744 // Field (2) 'Signature' 2745 if len(i.Signature) != 96 { 2746 err = ssz.ErrBytesLength 2747 return 2748 } 2749 dst = append(dst, i.Signature...) 2750 2751 // Field (0) 'AttestingIndices' 2752 if len(i.AttestingIndices) > 2048 { 2753 err = ssz.ErrListTooBig 2754 return 2755 } 2756 for ii := 0; ii < len(i.AttestingIndices); ii++ { 2757 dst = ssz.MarshalUint64(dst, i.AttestingIndices[ii]) 2758 } 2759 2760 return 2761 } 2762 2763 // UnmarshalSSZ ssz unmarshals the IndexedAttestation object 2764 func (i *IndexedAttestation) UnmarshalSSZ(buf []byte) error { 2765 var err error 2766 size := uint64(len(buf)) 2767 if size < 228 { 2768 return ssz.ErrSize 2769 } 2770 2771 tail := buf 2772 var o0 uint64 2773 2774 // Offset (0) 'AttestingIndices' 2775 if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { 2776 return ssz.ErrOffset 2777 } 2778 2779 if o0 < 228 { 2780 return ssz.ErrInvalidVariableOffset 2781 } 2782 2783 // Field (1) 'Data' 2784 if i.Data == nil { 2785 i.Data = new(AttestationData) 2786 } 2787 if err = i.Data.UnmarshalSSZ(buf[4:132]); err != nil { 2788 return err 2789 } 2790 2791 // Field (2) 'Signature' 2792 if cap(i.Signature) == 0 { 2793 i.Signature = make([]byte, 0, len(buf[132:228])) 2794 } 2795 i.Signature = append(i.Signature, buf[132:228]...) 2796 2797 // Field (0) 'AttestingIndices' 2798 { 2799 buf = tail[o0:] 2800 num, err := ssz.DivideInt2(len(buf), 8, 2048) 2801 if err != nil { 2802 return err 2803 } 2804 i.AttestingIndices = ssz.ExtendUint64(i.AttestingIndices, num) 2805 for ii := 0; ii < num; ii++ { 2806 i.AttestingIndices[ii] = ssz.UnmarshallUint64(buf[ii*8 : (ii+1)*8]) 2807 } 2808 } 2809 return err 2810 } 2811 2812 // SizeSSZ returns the ssz encoded size in bytes for the IndexedAttestation object 2813 func (i *IndexedAttestation) SizeSSZ() (size int) { 2814 size = 228 2815 2816 // Field (0) 'AttestingIndices' 2817 size += len(i.AttestingIndices) * 8 2818 2819 return 2820 } 2821 2822 // HashTreeRoot ssz hashes the IndexedAttestation object 2823 func (i *IndexedAttestation) HashTreeRoot() ([32]byte, error) { 2824 return ssz.HashWithDefaultHasher(i) 2825 } 2826 2827 // HashTreeRootWith ssz hashes the IndexedAttestation object with a hasher 2828 func (i *IndexedAttestation) HashTreeRootWith(hh *ssz.Hasher) (err error) { 2829 indx := hh.Index() 2830 2831 // Field (0) 'AttestingIndices' 2832 { 2833 if len(i.AttestingIndices) > 2048 { 2834 err = ssz.ErrListTooBig 2835 return 2836 } 2837 subIndx := hh.Index() 2838 for _, i := range i.AttestingIndices { 2839 hh.AppendUint64(i) 2840 } 2841 hh.FillUpTo32() 2842 numItems := uint64(len(i.AttestingIndices)) 2843 hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(2048, numItems, 8)) 2844 } 2845 2846 // Field (1) 'Data' 2847 if err = i.Data.HashTreeRootWith(hh); err != nil { 2848 return 2849 } 2850 2851 // Field (2) 'Signature' 2852 if len(i.Signature) != 96 { 2853 err = ssz.ErrBytesLength 2854 return 2855 } 2856 hh.PutBytes(i.Signature) 2857 2858 hh.Merkleize(indx) 2859 return 2860 } 2861 2862 // MarshalSSZ ssz marshals the Deposit_Data object 2863 func (d *Deposit_Data) MarshalSSZ() ([]byte, error) { 2864 return ssz.MarshalSSZ(d) 2865 } 2866 2867 // MarshalSSZTo ssz marshals the Deposit_Data object to a target array 2868 func (d *Deposit_Data) MarshalSSZTo(buf []byte) (dst []byte, err error) { 2869 dst = buf 2870 2871 // Field (0) 'Pubkey' 2872 if len(d.Pubkey) != 48 { 2873 err = ssz.ErrBytesLength 2874 return 2875 } 2876 dst = append(dst, d.Pubkey...) 2877 2878 // Field (1) 'WithdrawalCredentials' 2879 if len(d.WithdrawalCredentials) != 32 { 2880 err = ssz.ErrBytesLength 2881 return 2882 } 2883 dst = append(dst, d.WithdrawalCredentials...) 2884 2885 // Field (2) 'Amount' 2886 dst = ssz.MarshalUint64(dst, d.Amount) 2887 2888 // Field (3) 'Signature' 2889 if len(d.Signature) != 96 { 2890 err = ssz.ErrBytesLength 2891 return 2892 } 2893 dst = append(dst, d.Signature...) 2894 2895 return 2896 } 2897 2898 // UnmarshalSSZ ssz unmarshals the Deposit_Data object 2899 func (d *Deposit_Data) UnmarshalSSZ(buf []byte) error { 2900 var err error 2901 size := uint64(len(buf)) 2902 if size != 184 { 2903 return ssz.ErrSize 2904 } 2905 2906 // Field (0) 'Pubkey' 2907 if cap(d.Pubkey) == 0 { 2908 d.Pubkey = make([]byte, 0, len(buf[0:48])) 2909 } 2910 d.Pubkey = append(d.Pubkey, buf[0:48]...) 2911 2912 // Field (1) 'WithdrawalCredentials' 2913 if cap(d.WithdrawalCredentials) == 0 { 2914 d.WithdrawalCredentials = make([]byte, 0, len(buf[48:80])) 2915 } 2916 d.WithdrawalCredentials = append(d.WithdrawalCredentials, buf[48:80]...) 2917 2918 // Field (2) 'Amount' 2919 d.Amount = ssz.UnmarshallUint64(buf[80:88]) 2920 2921 // Field (3) 'Signature' 2922 if cap(d.Signature) == 0 { 2923 d.Signature = make([]byte, 0, len(buf[88:184])) 2924 } 2925 d.Signature = append(d.Signature, buf[88:184]...) 2926 2927 return err 2928 } 2929 2930 // SizeSSZ returns the ssz encoded size in bytes for the Deposit_Data object 2931 func (d *Deposit_Data) SizeSSZ() (size int) { 2932 size = 184 2933 return 2934 } 2935 2936 // HashTreeRoot ssz hashes the Deposit_Data object 2937 func (d *Deposit_Data) HashTreeRoot() ([32]byte, error) { 2938 return ssz.HashWithDefaultHasher(d) 2939 } 2940 2941 // HashTreeRootWith ssz hashes the Deposit_Data object with a hasher 2942 func (d *Deposit_Data) HashTreeRootWith(hh *ssz.Hasher) (err error) { 2943 indx := hh.Index() 2944 2945 // Field (0) 'Pubkey' 2946 if len(d.Pubkey) != 48 { 2947 err = ssz.ErrBytesLength 2948 return 2949 } 2950 hh.PutBytes(d.Pubkey) 2951 2952 // Field (1) 'WithdrawalCredentials' 2953 if len(d.WithdrawalCredentials) != 32 { 2954 err = ssz.ErrBytesLength 2955 return 2956 } 2957 hh.PutBytes(d.WithdrawalCredentials) 2958 2959 // Field (2) 'Amount' 2960 hh.PutUint64(d.Amount) 2961 2962 // Field (3) 'Signature' 2963 if len(d.Signature) != 96 { 2964 err = ssz.ErrBytesLength 2965 return 2966 } 2967 hh.PutBytes(d.Signature) 2968 2969 hh.Merkleize(indx) 2970 return 2971 } 2972 2973 // MarshalSSZ ssz marshals the Validator object 2974 func (v *Validator) MarshalSSZ() ([]byte, error) { 2975 return ssz.MarshalSSZ(v) 2976 } 2977 2978 // MarshalSSZTo ssz marshals the Validator object to a target array 2979 func (v *Validator) MarshalSSZTo(buf []byte) (dst []byte, err error) { 2980 dst = buf 2981 2982 // Field (0) 'Pubkey' 2983 if len(v.Pubkey) != 48 { 2984 err = ssz.ErrBytesLength 2985 return 2986 } 2987 dst = append(dst, v.Pubkey...) 2988 2989 // Field (1) 'WithdrawalCredentials' 2990 if len(v.WithdrawalCredentials) != 32 { 2991 err = ssz.ErrBytesLength 2992 return 2993 } 2994 dst = append(dst, v.WithdrawalCredentials...) 2995 2996 // Field (2) 'EffectiveBalance' 2997 dst = ssz.MarshalUint64(dst, v.EffectiveBalance) 2998 2999 // Field (3) 'Slashed' 3000 dst = ssz.MarshalBool(dst, v.Slashed) 3001 3002 // Field (4) 'ActivationEligibilityEpoch' 3003 dst = ssz.MarshalUint64(dst, uint64(v.ActivationEligibilityEpoch)) 3004 3005 // Field (5) 'ActivationEpoch' 3006 dst = ssz.MarshalUint64(dst, uint64(v.ActivationEpoch)) 3007 3008 // Field (6) 'ExitEpoch' 3009 dst = ssz.MarshalUint64(dst, uint64(v.ExitEpoch)) 3010 3011 // Field (7) 'WithdrawableEpoch' 3012 dst = ssz.MarshalUint64(dst, uint64(v.WithdrawableEpoch)) 3013 3014 return 3015 } 3016 3017 // UnmarshalSSZ ssz unmarshals the Validator object 3018 func (v *Validator) UnmarshalSSZ(buf []byte) error { 3019 var err error 3020 size := uint64(len(buf)) 3021 if size != 121 { 3022 return ssz.ErrSize 3023 } 3024 3025 // Field (0) 'Pubkey' 3026 if cap(v.Pubkey) == 0 { 3027 v.Pubkey = make([]byte, 0, len(buf[0:48])) 3028 } 3029 v.Pubkey = append(v.Pubkey, buf[0:48]...) 3030 3031 // Field (1) 'WithdrawalCredentials' 3032 if cap(v.WithdrawalCredentials) == 0 { 3033 v.WithdrawalCredentials = make([]byte, 0, len(buf[48:80])) 3034 } 3035 v.WithdrawalCredentials = append(v.WithdrawalCredentials, buf[48:80]...) 3036 3037 // Field (2) 'EffectiveBalance' 3038 v.EffectiveBalance = ssz.UnmarshallUint64(buf[80:88]) 3039 3040 // Field (3) 'Slashed' 3041 v.Slashed = ssz.UnmarshalBool(buf[88:89]) 3042 3043 // Field (4) 'ActivationEligibilityEpoch' 3044 v.ActivationEligibilityEpoch = github_com_prysmaticlabs_eth2_types.Epoch(ssz.UnmarshallUint64(buf[89:97])) 3045 3046 // Field (5) 'ActivationEpoch' 3047 v.ActivationEpoch = github_com_prysmaticlabs_eth2_types.Epoch(ssz.UnmarshallUint64(buf[97:105])) 3048 3049 // Field (6) 'ExitEpoch' 3050 v.ExitEpoch = github_com_prysmaticlabs_eth2_types.Epoch(ssz.UnmarshallUint64(buf[105:113])) 3051 3052 // Field (7) 'WithdrawableEpoch' 3053 v.WithdrawableEpoch = github_com_prysmaticlabs_eth2_types.Epoch(ssz.UnmarshallUint64(buf[113:121])) 3054 3055 return err 3056 } 3057 3058 // SizeSSZ returns the ssz encoded size in bytes for the Validator object 3059 func (v *Validator) SizeSSZ() (size int) { 3060 size = 121 3061 return 3062 } 3063 3064 // HashTreeRoot ssz hashes the Validator object 3065 func (v *Validator) HashTreeRoot() ([32]byte, error) { 3066 return ssz.HashWithDefaultHasher(v) 3067 } 3068 3069 // HashTreeRootWith ssz hashes the Validator object with a hasher 3070 func (v *Validator) HashTreeRootWith(hh *ssz.Hasher) (err error) { 3071 indx := hh.Index() 3072 3073 // Field (0) 'Pubkey' 3074 if len(v.Pubkey) != 48 { 3075 err = ssz.ErrBytesLength 3076 return 3077 } 3078 hh.PutBytes(v.Pubkey) 3079 3080 // Field (1) 'WithdrawalCredentials' 3081 if len(v.WithdrawalCredentials) != 32 { 3082 err = ssz.ErrBytesLength 3083 return 3084 } 3085 hh.PutBytes(v.WithdrawalCredentials) 3086 3087 // Field (2) 'EffectiveBalance' 3088 hh.PutUint64(v.EffectiveBalance) 3089 3090 // Field (3) 'Slashed' 3091 hh.PutBool(v.Slashed) 3092 3093 // Field (4) 'ActivationEligibilityEpoch' 3094 hh.PutUint64(uint64(v.ActivationEligibilityEpoch)) 3095 3096 // Field (5) 'ActivationEpoch' 3097 hh.PutUint64(uint64(v.ActivationEpoch)) 3098 3099 // Field (6) 'ExitEpoch' 3100 hh.PutUint64(uint64(v.ExitEpoch)) 3101 3102 // Field (7) 'WithdrawableEpoch' 3103 hh.PutUint64(uint64(v.WithdrawableEpoch)) 3104 3105 hh.Merkleize(indx) 3106 return 3107 }