mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-08 23:18:15 -05:00
Massive code cleanup (#10913)
* Massive code cleanup * fix test issues * remove GetGenesis mock expectations * unused receiver * rename unused params Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
This commit is contained in:
@@ -3,7 +3,7 @@ package bellatrix
|
||||
import (
|
||||
"bytes"
|
||||
|
||||
field_params "github.com/prysmaticlabs/prysm/config/fieldparams"
|
||||
fieldparams "github.com/prysmaticlabs/prysm/config/fieldparams"
|
||||
"github.com/prysmaticlabs/prysm/encoding/bytesutil"
|
||||
"github.com/prysmaticlabs/prysm/encoding/ssz"
|
||||
enginev1 "github.com/prysmaticlabs/prysm/proto/engine/v1"
|
||||
@@ -38,28 +38,28 @@ func IsEmptyPayload(p *enginev1.ExecutionPayload) bool {
|
||||
if p == nil {
|
||||
return true
|
||||
}
|
||||
if !bytes.Equal(p.ParentHash, make([]byte, field_params.RootLength)) {
|
||||
if !bytes.Equal(p.ParentHash, make([]byte, fieldparams.RootLength)) {
|
||||
return false
|
||||
}
|
||||
if !bytes.Equal(p.FeeRecipient, make([]byte, field_params.FeeRecipientLength)) {
|
||||
if !bytes.Equal(p.FeeRecipient, make([]byte, fieldparams.FeeRecipientLength)) {
|
||||
return false
|
||||
}
|
||||
if !bytes.Equal(p.StateRoot, make([]byte, field_params.RootLength)) {
|
||||
if !bytes.Equal(p.StateRoot, make([]byte, fieldparams.RootLength)) {
|
||||
return false
|
||||
}
|
||||
if !bytes.Equal(p.ReceiptsRoot, make([]byte, field_params.RootLength)) {
|
||||
if !bytes.Equal(p.ReceiptsRoot, make([]byte, fieldparams.RootLength)) {
|
||||
return false
|
||||
}
|
||||
if !bytes.Equal(p.LogsBloom, make([]byte, field_params.LogsBloomLength)) {
|
||||
if !bytes.Equal(p.LogsBloom, make([]byte, fieldparams.LogsBloomLength)) {
|
||||
return false
|
||||
}
|
||||
if !bytes.Equal(p.PrevRandao, make([]byte, field_params.RootLength)) {
|
||||
if !bytes.Equal(p.PrevRandao, make([]byte, fieldparams.RootLength)) {
|
||||
return false
|
||||
}
|
||||
if !bytes.Equal(p.BaseFeePerGas, make([]byte, field_params.RootLength)) {
|
||||
if !bytes.Equal(p.BaseFeePerGas, make([]byte, fieldparams.RootLength)) {
|
||||
return false
|
||||
}
|
||||
if !bytes.Equal(p.BlockHash, make([]byte, field_params.RootLength)) {
|
||||
if !bytes.Equal(p.BlockHash, make([]byte, fieldparams.RootLength)) {
|
||||
return false
|
||||
}
|
||||
if len(p.Transactions) != 0 {
|
||||
@@ -84,31 +84,31 @@ func IsEmptyPayload(p *enginev1.ExecutionPayload) bool {
|
||||
}
|
||||
|
||||
func IsEmptyHeader(h *enginev1.ExecutionPayloadHeader) bool {
|
||||
if !bytes.Equal(h.ParentHash, make([]byte, field_params.RootLength)) {
|
||||
if !bytes.Equal(h.ParentHash, make([]byte, fieldparams.RootLength)) {
|
||||
return false
|
||||
}
|
||||
if !bytes.Equal(h.FeeRecipient, make([]byte, field_params.FeeRecipientLength)) {
|
||||
if !bytes.Equal(h.FeeRecipient, make([]byte, fieldparams.FeeRecipientLength)) {
|
||||
return false
|
||||
}
|
||||
if !bytes.Equal(h.StateRoot, make([]byte, field_params.RootLength)) {
|
||||
if !bytes.Equal(h.StateRoot, make([]byte, fieldparams.RootLength)) {
|
||||
return false
|
||||
}
|
||||
if !bytes.Equal(h.ReceiptsRoot, make([]byte, field_params.RootLength)) {
|
||||
if !bytes.Equal(h.ReceiptsRoot, make([]byte, fieldparams.RootLength)) {
|
||||
return false
|
||||
}
|
||||
if !bytes.Equal(h.LogsBloom, make([]byte, field_params.LogsBloomLength)) {
|
||||
if !bytes.Equal(h.LogsBloom, make([]byte, fieldparams.LogsBloomLength)) {
|
||||
return false
|
||||
}
|
||||
if !bytes.Equal(h.PrevRandao, make([]byte, field_params.RootLength)) {
|
||||
if !bytes.Equal(h.PrevRandao, make([]byte, fieldparams.RootLength)) {
|
||||
return false
|
||||
}
|
||||
if !bytes.Equal(h.BaseFeePerGas, make([]byte, field_params.RootLength)) {
|
||||
if !bytes.Equal(h.BaseFeePerGas, make([]byte, fieldparams.RootLength)) {
|
||||
return false
|
||||
}
|
||||
if !bytes.Equal(h.BlockHash, make([]byte, field_params.RootLength)) {
|
||||
if !bytes.Equal(h.BlockHash, make([]byte, fieldparams.RootLength)) {
|
||||
return false
|
||||
}
|
||||
if !bytes.Equal(h.TransactionsRoot, make([]byte, field_params.RootLength)) {
|
||||
if !bytes.Equal(h.TransactionsRoot, make([]byte, fieldparams.RootLength)) {
|
||||
return false
|
||||
}
|
||||
if len(h.ExtraData) != 0 {
|
||||
|
||||
@@ -14,32 +14,32 @@ var _ fssz.Unmarshaler = (*Domain)(nil)
|
||||
type Domain []byte
|
||||
|
||||
// HashTreeRoot --
|
||||
func (e Domain) HashTreeRoot() ([32]byte, error) {
|
||||
return fssz.HashWithDefaultHasher(e)
|
||||
func (d Domain) HashTreeRoot() ([32]byte, error) {
|
||||
return fssz.HashWithDefaultHasher(d)
|
||||
}
|
||||
|
||||
// HashTreeRootWith --
|
||||
func (e Domain) HashTreeRootWith(hh *fssz.Hasher) error {
|
||||
hh.PutBytes(e[:])
|
||||
func (d Domain) HashTreeRootWith(hh *fssz.Hasher) error {
|
||||
hh.PutBytes(d[:])
|
||||
return nil
|
||||
}
|
||||
|
||||
// UnmarshalSSZ --
|
||||
func (e *Domain) UnmarshalSSZ(buf []byte) error {
|
||||
if len(buf) != e.SizeSSZ() {
|
||||
return fmt.Errorf("expected buffer of length %d received %d", e.SizeSSZ(), len(buf))
|
||||
func (d *Domain) UnmarshalSSZ(buf []byte) error {
|
||||
if len(buf) != d.SizeSSZ() {
|
||||
return fmt.Errorf("expected buffer of length %d received %d", d.SizeSSZ(), len(buf))
|
||||
}
|
||||
|
||||
var b [32]byte
|
||||
item := Domain(b[:])
|
||||
copy(item, buf)
|
||||
*e = item
|
||||
*d = item
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalSSZTo --
|
||||
func (e *Domain) MarshalSSZTo(dst []byte) ([]byte, error) {
|
||||
marshalled, err := e.MarshalSSZ()
|
||||
func (d *Domain) MarshalSSZTo(dst []byte) ([]byte, error) {
|
||||
marshalled, err := d.MarshalSSZ()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -47,11 +47,11 @@ func (e *Domain) MarshalSSZTo(dst []byte) ([]byte, error) {
|
||||
}
|
||||
|
||||
// MarshalSSZ --
|
||||
func (e *Domain) MarshalSSZ() ([]byte, error) {
|
||||
return *e, nil
|
||||
func (d *Domain) MarshalSSZ() ([]byte, error) {
|
||||
return *d, nil
|
||||
}
|
||||
|
||||
// SizeSSZ --
|
||||
func (e *Domain) SizeSSZ() int {
|
||||
func (_ *Domain) SizeSSZ() int {
|
||||
return 32
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package types
|
||||
|
||||
import (
|
||||
fmt "fmt"
|
||||
"fmt"
|
||||
|
||||
fssz "github.com/ferranbt/fastssz"
|
||||
"github.com/prysmaticlabs/prysm/math"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package types
|
||||
|
||||
import (
|
||||
fmt "fmt"
|
||||
"fmt"
|
||||
|
||||
fssz "github.com/ferranbt/fastssz"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user