Skip to content

Commit

Permalink
linting
Browse files Browse the repository at this point in the history
  • Loading branch information
avalonche committed Jul 11, 2023
1 parent d998368 commit c1ca05d
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 50 deletions.
41 changes: 21 additions & 20 deletions spec/versionedsubmitblockrequest.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (

"github.com/attestantio/go-builder-client/api/bellatrix"
"github.com/attestantio/go-builder-client/api/capella"
v1 "github.com/attestantio/go-builder-client/api/v1"
consensusspec "github.com/attestantio/go-eth2-client/spec"
consensusbellatrix "github.com/attestantio/go-eth2-client/spec/bellatrix"
consensuscapella "github.com/attestantio/go-eth2-client/spec/capella"
Expand All @@ -46,7 +47,7 @@ func (v *VersionedSubmitBlockRequest) IsEmpty() bool {
}
}

// Slot returns the slot of the request
// Slot returns the slot of the request.
func (v *VersionedSubmitBlockRequest) Slot() (uint64, error) {
if v == nil {
return 0, errors.New("nil struct")
Expand Down Expand Up @@ -154,8 +155,8 @@ func (v *VersionedSubmitBlockRequest) ProposerFeeRecipient() (consensusbellatrix
}
}

// ProposerPubkey returns the proposer fee recipient of the request.
func (v *VersionedSubmitBlockRequest) ProposerPubkey() (phase0.BLSPubKey, error) {
// ProposerPubKey returns the proposer fee recipient of the request.
func (v *VersionedSubmitBlockRequest) ProposerPubKey() (phase0.BLSPubKey, error) {
if v == nil {
return phase0.BLSPubKey{}, errors.New("nil struct")
}
Expand Down Expand Up @@ -235,30 +236,30 @@ func (v *VersionedSubmitBlockRequest) Value() (*uint256.Int, error) {
}
}

// MessageHashTreeRoot returns the hash tree root of the message of the bid.
func (v *VersionedSubmitBlockRequest) MessageHashTreeRoot() (phase0.Root, error) {
// BidTrace returns the bid trace of the request.
func (v *VersionedSubmitBlockRequest) BidTrace() (*v1.BidTrace, error) {
if v == nil {
return phase0.Root{}, errors.New("nil struct")
return nil, errors.New("nil struct")
}
switch v.Version {
case consensusspec.DataVersionBellatrix:
if v.Bellatrix == nil {
return phase0.Root{}, errors.New("no data")
return nil, errors.New("no data")
}
if v.Bellatrix.Message == nil {
return phase0.Root{}, errors.New("no data message")
return nil, errors.New("no data message")
}
return v.Bellatrix.Message.HashTreeRoot()
return v.Bellatrix.Message, nil
case consensusspec.DataVersionCapella:
if v.Capella == nil {
return phase0.Root{}, errors.New("no data")
return nil, errors.New("no data")
}
if v.Capella.Message == nil {
return phase0.Root{}, errors.New("no data message")
return nil, errors.New("no data message")
}
return v.Capella.Message.HashTreeRoot()
return v.Capella.Message, nil
default:
return phase0.Root{}, errors.New("unsupported version")
return nil, errors.New("unsupported version")
}
}

Expand All @@ -283,7 +284,7 @@ func (v *VersionedSubmitBlockRequest) Signature() (phase0.BLSSignature, error) {
}
}

// ExecutionPayloadBlockHash returns the block hash of the payload
// ExecutionPayloadBlockHash returns the block hash of the payload.
func (v *VersionedSubmitBlockRequest) ExecutionPayloadBlockHash() (phase0.Hash32, error) {
if v == nil {
return phase0.Hash32{}, errors.New("nil struct")
Expand All @@ -310,7 +311,7 @@ func (v *VersionedSubmitBlockRequest) ExecutionPayloadBlockHash() (phase0.Hash32
}
}

// ExecutionPayloadParentHash returns the block hash of the payload
// ExecutionPayloadParentHash returns the block hash of the payload.
func (v *VersionedSubmitBlockRequest) ExecutionPayloadParentHash() (phase0.Hash32, error) {
if v == nil {
return phase0.Hash32{}, errors.New("nil struct")
Expand All @@ -337,7 +338,7 @@ func (v *VersionedSubmitBlockRequest) ExecutionPayloadParentHash() (phase0.Hash3
}
}

// PrevRandao returns the prev randao of the payload
// PrevRandao returns the prev randao of the payload.
func (v *VersionedSubmitBlockRequest) PrevRandao() (phase0.Hash32, error) {
if v == nil {
return phase0.Hash32{}, errors.New("nil struct")
Expand All @@ -364,7 +365,7 @@ func (v *VersionedSubmitBlockRequest) PrevRandao() (phase0.Hash32, error) {
}
}

// GasLimit returns the prev randao of the payload
// GasLimit returns the prev randao of the payload.
func (v *VersionedSubmitBlockRequest) GasLimit() (uint64, error) {
if v == nil {
return 0, errors.New("nil struct")
Expand All @@ -391,7 +392,7 @@ func (v *VersionedSubmitBlockRequest) GasLimit() (uint64, error) {
}
}

// GasUsed returns the prev randao of the payload
// GasUsed returns the prev randao of the payload.
func (v *VersionedSubmitBlockRequest) GasUsed() (uint64, error) {
if v == nil {
return 0, errors.New("nil struct")
Expand Down Expand Up @@ -472,7 +473,7 @@ func (v *VersionedSubmitBlockRequest) Timestamp() (uint64, error) {
}
}

// Transactions returns the transactions of the payload
// Transactions returns the transactions of the payload.
func (v *VersionedSubmitBlockRequest) Transactions() ([]consensusbellatrix.Transaction, error) {
if v == nil {
return nil, errors.New("nil struct")
Expand All @@ -499,7 +500,7 @@ func (v *VersionedSubmitBlockRequest) Transactions() ([]consensusbellatrix.Trans
}
}

// Withdrawals returns the withdrawals of the payload
// Withdrawals returns the withdrawals of the payload.
func (v *VersionedSubmitBlockRequest) Withdrawals() ([]*consensuscapella.Withdrawal, error) {
if v == nil {
return nil, errors.New("nil struct")
Expand Down
62 changes: 32 additions & 30 deletions spec/versionedsubmitblockrequest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (

"github.com/attestantio/go-builder-client/api/bellatrix"
"github.com/attestantio/go-builder-client/api/capella"
apiv1 "github.com/attestantio/go-builder-client/api/v1"
v1 "github.com/attestantio/go-builder-client/api/v1"
"github.com/attestantio/go-builder-client/spec"
consensusspec "github.com/attestantio/go-eth2-client/spec"
consensusbellatrix "github.com/attestantio/go-eth2-client/spec/bellatrix"
Expand Down Expand Up @@ -98,7 +98,7 @@ func TestVersionedSubmitBlockRequestSlot(t *testing.T) {
request: &spec.VersionedSubmitBlockRequest{
Version: consensusspec.DataVersionBellatrix,
Bellatrix: &bellatrix.SubmitBlockRequest{
Message: &apiv1.BidTrace{
Message: &v1.BidTrace{
Slot: 12345,
},
},
Expand All @@ -125,7 +125,7 @@ func TestVersionedSubmitBlockRequestSlot(t *testing.T) {
request: &spec.VersionedSubmitBlockRequest{
Version: consensusspec.DataVersionCapella,
Capella: &capella.SubmitBlockRequest{
Message: &apiv1.BidTrace{
Message: &v1.BidTrace{
Slot: 12345,
},
},
Expand Down Expand Up @@ -185,7 +185,7 @@ func TestVersionedSubmitBlockRequestBlockHash(t *testing.T) {
request: &spec.VersionedSubmitBlockRequest{
Version: consensusspec.DataVersionBellatrix,
Bellatrix: &bellatrix.SubmitBlockRequest{
Message: &apiv1.BidTrace{
Message: &v1.BidTrace{
BlockHash: phase0.Hash32{
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
Expand Down Expand Up @@ -218,7 +218,7 @@ func TestVersionedSubmitBlockRequestBlockHash(t *testing.T) {
request: &spec.VersionedSubmitBlockRequest{
Version: consensusspec.DataVersionCapella,
Capella: &capella.SubmitBlockRequest{
Message: &apiv1.BidTrace{
Message: &v1.BidTrace{
BlockHash: phase0.Hash32{
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
Expand Down Expand Up @@ -284,7 +284,7 @@ func TestVersionedSubmitBlockRequestBuilder(t *testing.T) {
request: &spec.VersionedSubmitBlockRequest{
Version: consensusspec.DataVersionBellatrix,
Bellatrix: &bellatrix.SubmitBlockRequest{
Message: &apiv1.BidTrace{
Message: &v1.BidTrace{
BuilderPubkey: phase0.BLSPubKey{
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
Expand Down Expand Up @@ -319,7 +319,7 @@ func TestVersionedSubmitBlockRequestBuilder(t *testing.T) {
request: &spec.VersionedSubmitBlockRequest{
Version: consensusspec.DataVersionCapella,
Capella: &capella.SubmitBlockRequest{
Message: &apiv1.BidTrace{
Message: &v1.BidTrace{
BuilderPubkey: phase0.BLSPubKey{
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
Expand Down Expand Up @@ -387,7 +387,7 @@ func TestVersionedSubmitBlockRequestProposerFeeRecipient(t *testing.T) {
request: &spec.VersionedSubmitBlockRequest{
Version: consensusspec.DataVersionBellatrix,
Bellatrix: &bellatrix.SubmitBlockRequest{
Message: &apiv1.BidTrace{
Message: &v1.BidTrace{
ProposerFeeRecipient: consensusbellatrix.ExecutionAddress{
0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a,
0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a,
Expand Down Expand Up @@ -420,7 +420,7 @@ func TestVersionedSubmitBlockRequestProposerFeeRecipient(t *testing.T) {
request: &spec.VersionedSubmitBlockRequest{
Version: consensusspec.DataVersionCapella,
Capella: &capella.SubmitBlockRequest{
Message: &apiv1.BidTrace{
Message: &v1.BidTrace{
ProposerFeeRecipient: consensusbellatrix.ExecutionAddress{
0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a,
0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a,
Expand Down Expand Up @@ -448,7 +448,7 @@ func TestVersionedSubmitBlockRequestProposerFeeRecipient(t *testing.T) {
}
}

func TestVersionedSubmitBlockRequestProposerPubkey(t *testing.T) {
func TestVersionedSubmitBlockRequestProposerPubKey(t *testing.T) {
tests := []struct {
name string
request *spec.VersionedSubmitBlockRequest
Expand Down Expand Up @@ -486,7 +486,7 @@ func TestVersionedSubmitBlockRequestProposerPubkey(t *testing.T) {
request: &spec.VersionedSubmitBlockRequest{
Version: consensusspec.DataVersionBellatrix,
Bellatrix: &bellatrix.SubmitBlockRequest{
Message: &apiv1.BidTrace{
Message: &v1.BidTrace{
ProposerPubkey: phase0.BLSPubKey{
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
Expand Down Expand Up @@ -521,7 +521,7 @@ func TestVersionedSubmitBlockRequestProposerPubkey(t *testing.T) {
request: &spec.VersionedSubmitBlockRequest{
Version: consensusspec.DataVersionCapella,
Capella: &capella.SubmitBlockRequest{
Message: &apiv1.BidTrace{
Message: &v1.BidTrace{
ProposerPubkey: phase0.BLSPubKey{
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
Expand All @@ -540,7 +540,7 @@ func TestVersionedSubmitBlockRequestProposerPubkey(t *testing.T) {

for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
res, err := test.request.ProposerPubkey()
res, err := test.request.ProposerPubKey()
if test.err != "" {
require.EqualError(t, err, test.err)
} else {
Expand Down Expand Up @@ -589,7 +589,7 @@ func TestVersionedSubmitBlockRequestParentHash(t *testing.T) {
request: &spec.VersionedSubmitBlockRequest{
Version: consensusspec.DataVersionBellatrix,
Bellatrix: &bellatrix.SubmitBlockRequest{
Message: &apiv1.BidTrace{
Message: &v1.BidTrace{
ParentHash: phase0.Hash32{
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
Expand Down Expand Up @@ -622,7 +622,7 @@ func TestVersionedSubmitBlockRequestParentHash(t *testing.T) {
request: &spec.VersionedSubmitBlockRequest{
Version: consensusspec.DataVersionCapella,
Capella: &capella.SubmitBlockRequest{
Message: &apiv1.BidTrace{
Message: &v1.BidTrace{
ParentHash: phase0.Hash32{
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
Expand Down Expand Up @@ -688,7 +688,7 @@ func TestVersionedSubmitBlockRequestValue(t *testing.T) {
request: &spec.VersionedSubmitBlockRequest{
Version: consensusspec.DataVersionBellatrix,
Bellatrix: &bellatrix.SubmitBlockRequest{
Message: &apiv1.BidTrace{
Message: &v1.BidTrace{
Value: uint256.NewInt(12345),
},
},
Expand All @@ -715,7 +715,7 @@ func TestVersionedSubmitBlockRequestValue(t *testing.T) {
request: &spec.VersionedSubmitBlockRequest{
Version: consensusspec.DataVersionCapella,
Capella: &capella.SubmitBlockRequest{
Message: &apiv1.BidTrace{
Message: &v1.BidTrace{
Value: uint256.NewInt(12345),
},
},
Expand All @@ -737,11 +737,11 @@ func TestVersionedSubmitBlockRequestValue(t *testing.T) {
}
}

func TestVersionedSubmitBlockRequestMessageHashTreeRoot(t *testing.T) {
func TestVersionedSubmitBlockRequestBidTrace(t *testing.T) {
tests := []struct {
name string
request *spec.VersionedSubmitBlockRequest
res phase0.Root
res *v1.BidTrace
err string
}{
{
Expand Down Expand Up @@ -775,14 +775,15 @@ func TestVersionedSubmitBlockRequestMessageHashTreeRoot(t *testing.T) {
request: &spec.VersionedSubmitBlockRequest{
Version: consensusspec.DataVersionBellatrix,
Bellatrix: &bellatrix.SubmitBlockRequest{
Message: &apiv1.BidTrace{
Message: &v1.BidTrace{
Slot: 123,
Value: uint256.NewInt(12345),
},
},
},
res: phase0.Root{
0x6e, 0x21, 0x57, 0xbe, 0x11, 0xe5, 0xda, 0xc3, 0x30, 0x6b, 0xd6, 0x41, 0x61, 0x17, 0x93, 0x30,
0x53, 0xe8, 0x7d, 0x66, 0xb2, 0xfc, 0xcd, 0x7b, 0xd1, 0x7f, 0x27, 0xee, 0x90, 0xb4, 0x6c, 0x7c,
res: &v1.BidTrace{
Slot: 123,
Value: uint256.NewInt(12345),
},
},
{
Expand All @@ -805,21 +806,22 @@ func TestVersionedSubmitBlockRequestMessageHashTreeRoot(t *testing.T) {
request: &spec.VersionedSubmitBlockRequest{
Version: consensusspec.DataVersionCapella,
Capella: &capella.SubmitBlockRequest{
Message: &apiv1.BidTrace{
Message: &v1.BidTrace{
Slot: 123,
Value: uint256.NewInt(12345),
},
},
},
res: phase0.Root{
0x6e, 0x21, 0x57, 0xbe, 0x11, 0xe5, 0xda, 0xc3, 0x30, 0x6b, 0xd6, 0x41, 0x61, 0x17, 0x93, 0x30,
0x53, 0xe8, 0x7d, 0x66, 0xb2, 0xfc, 0xcd, 0x7b, 0xd1, 0x7f, 0x27, 0xee, 0x90, 0xb4, 0x6c, 0x7c,
res: &v1.BidTrace{
Slot: 123,
Value: uint256.NewInt(12345),
},
},
}

for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
res, err := test.request.MessageHashTreeRoot()
res, err := test.request.BidTrace()
if test.err != "" {
require.EqualError(t, err, test.err)
} else {
Expand Down Expand Up @@ -1775,7 +1777,7 @@ func TestVersionedSubmitBlockRequestString(t *testing.T) {
request: &spec.VersionedSubmitBlockRequest{
Version: consensusspec.DataVersionBellatrix,
Bellatrix: &bellatrix.SubmitBlockRequest{
Message: &apiv1.BidTrace{
Message: &v1.BidTrace{
Slot: 123,
Value: uint256.NewInt(12345),
},
Expand Down Expand Up @@ -1807,7 +1809,7 @@ func TestVersionedSubmitBlockRequestString(t *testing.T) {
request: &spec.VersionedSubmitBlockRequest{
Version: consensusspec.DataVersionCapella,
Capella: &capella.SubmitBlockRequest{
Message: &apiv1.BidTrace{
Message: &v1.BidTrace{
Slot: 123,
Value: uint256.NewInt(12345),
},
Expand Down

0 comments on commit c1ca05d

Please sign in to comment.