Skip to content

Commit

Permalink
Make attestantio import names consistent (#560)
Browse files Browse the repository at this point in the history
  • Loading branch information
jtraglia authored and metachris committed Jan 11, 2024
1 parent 14ed275 commit 09ea881
Show file tree
Hide file tree
Showing 7 changed files with 132 additions and 132 deletions.
18 changes: 9 additions & 9 deletions cmd/test-cli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import (
"os"
"strconv"

"github.com/attestantio/go-builder-client/api"
"github.com/attestantio/go-builder-client/spec"
"github.com/attestantio/go-eth2-client/api/v1/capella"
builderApi "github.com/attestantio/go-builder-client/api"
builderSpec "github.com/attestantio/go-builder-client/spec"
eth2ApiV1Capella "github.com/attestantio/go-eth2-client/api/v1/capella"
"github.com/attestantio/go-eth2-client/spec/altair"
"github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/ethereum/go-ethereum/common"
Expand Down Expand Up @@ -44,7 +44,7 @@ func doRegisterValidator(v validatorPrivateData, boostEndpoint string, builderSi
log.WithError(err).Info("Registered validator")
}

func doGetHeader(v validatorPrivateData, boostEndpoint string, beaconNode Beacon, engineEndpoint string, builderSigningDomain phase0.Domain) spec.VersionedSignedBuilderBid {
func doGetHeader(v validatorPrivateData, boostEndpoint string, beaconNode Beacon, engineEndpoint string, builderSigningDomain phase0.Domain) builderSpec.VersionedSignedBuilderBid {
// Mergemock needs to call forkchoice update before getHeader, for non-mergemock beacon node this is a no-op
err := beaconNode.onGetHeader()
if err != nil {
Expand All @@ -71,7 +71,7 @@ func doGetHeader(v validatorPrivateData, boostEndpoint string, beaconNode Beacon

uri := fmt.Sprintf("%s/eth/v1/builder/header/%d/%s/%s", boostEndpoint, currentBlock.Slot+1, currentBlockHash, v.Pk.String())

var getHeaderResp spec.VersionedSignedBuilderBid
var getHeaderResp builderSpec.VersionedSignedBuilderBid
if _, err := server.SendHTTPRequest(context.TODO(), *http.DefaultClient, http.MethodGet, uri, "test-cli", nil, nil, &getHeaderResp); err != nil {
log.WithError(err).WithField("currentBlockHash", currentBlockHash).Fatal("Could not get header")
}
Expand All @@ -95,12 +95,12 @@ func doGetHeader(v validatorPrivateData, boostEndpoint string, beaconNode Beacon
func doGetPayload(v validatorPrivateData, boostEndpoint string, beaconNode Beacon, engineEndpoint string, builderSigningDomain, proposerSigningDomain phase0.Domain) {
header := doGetHeader(v, boostEndpoint, beaconNode, engineEndpoint, builderSigningDomain)

blindedBeaconBlock := capella.BlindedBeaconBlock{
blindedBeaconBlock := eth2ApiV1Capella.BlindedBeaconBlock{
Slot: 0,
ProposerIndex: 0,
ParentRoot: phase0.Root{},
StateRoot: phase0.Root{},
Body: &capella.BlindedBeaconBlockBody{
Body: &eth2ApiV1Capella.BlindedBeaconBlockBody{
RANDAOReveal: phase0.BLSSignature{},
ETH1Data: &phase0.ETH1Data{},
Graffiti: phase0.Hash32{},
Expand All @@ -119,11 +119,11 @@ func doGetPayload(v validatorPrivateData, boostEndpoint string, beaconNode Beaco
log.WithError(err).Fatal("could not sign blinded beacon block")
}

payload := capella.SignedBlindedBeaconBlock{
payload := eth2ApiV1Capella.SignedBlindedBeaconBlock{
Message: &blindedBeaconBlock,
Signature: signature,
}
var respPayload api.VersionedExecutionPayload
var respPayload builderApi.VersionedExecutionPayload
if _, err := server.SendHTTPRequest(context.TODO(), *http.DefaultClient, http.MethodPost, boostEndpoint+"/eth/v1/builder/blinded_blocks", "test-cli", nil, payload, &respPayload); err != nil {
log.WithError(err).Fatal("could not get payload")
}
Expand Down
14 changes: 7 additions & 7 deletions cmd/test-cli/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"os"
"time"

apiv1 "github.com/attestantio/go-builder-client/api/v1"
builderApiV1 "github.com/attestantio/go-builder-client/api/v1"
"github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/flashbots/go-boost-utils/bls"
Expand Down Expand Up @@ -52,29 +52,29 @@ func newRandomValidator(gasLimit uint64, feeRecipient string) validatorPrivateDa
return validatorPrivateData{bls.SecretKeyToBytes(sk), bls.PublicKeyToBytes(pk), hexutil.Uint64(gasLimit), feeRecipient}
}

func (v *validatorPrivateData) PrepareRegistrationMessage(builderSigningDomain phase0.Domain) ([]apiv1.SignedValidatorRegistration, error) {
func (v *validatorPrivateData) PrepareRegistrationMessage(builderSigningDomain phase0.Domain) ([]builderApiV1.SignedValidatorRegistration, error) {
pk := phase0.BLSPubKey{}
if len(v.Pk) != len(pk) {
return []apiv1.SignedValidatorRegistration{}, errInvalidLength
return []builderApiV1.SignedValidatorRegistration{}, errInvalidLength
}
copy(pk[:], v.Pk)

addr, err := utils.HexToAddress(v.FeeRecipientHex)
if err != nil {
return []apiv1.SignedValidatorRegistration{}, err
return []builderApiV1.SignedValidatorRegistration{}, err
}
msg := apiv1.ValidatorRegistration{
msg := builderApiV1.ValidatorRegistration{
FeeRecipient: addr,
Timestamp: time.Now(),
Pubkey: pk,
GasLimit: uint64(v.GasLimit),
}
signature, err := v.Sign(&msg, builderSigningDomain)
if err != nil {
return []apiv1.SignedValidatorRegistration{}, err
return []builderApiV1.SignedValidatorRegistration{}, err
}

return []apiv1.SignedValidatorRegistration{{
return []builderApiV1.SignedValidatorRegistration{{
Message: &msg,
Signature: signature,
}}, nil
Expand Down
54 changes: 27 additions & 27 deletions server/mock_relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ import (
"testing"
"time"

"github.com/attestantio/go-builder-client/api"
apicapella "github.com/attestantio/go-builder-client/api/capella"
apideneb "github.com/attestantio/go-builder-client/api/deneb"
apiv1 "github.com/attestantio/go-builder-client/api/v1"
"github.com/attestantio/go-builder-client/spec"
consensusspec "github.com/attestantio/go-eth2-client/spec"
builderApi "github.com/attestantio/go-builder-client/api"
builderApiCapella "github.com/attestantio/go-builder-client/api/capella"
builderApiDeneb "github.com/attestantio/go-builder-client/api/deneb"
builderApiV1 "github.com/attestantio/go-builder-client/api/v1"
builderSpec "github.com/attestantio/go-builder-client/spec"
"github.com/attestantio/go-eth2-client/spec"
"github.com/attestantio/go-eth2-client/spec/capella"
"github.com/attestantio/go-eth2-client/spec/deneb"
"github.com/attestantio/go-eth2-client/spec/phase0"
Expand Down Expand Up @@ -59,8 +59,8 @@ type mockRelay struct {
handlerOverrideGetPayload func(w http.ResponseWriter, req *http.Request)

// Default responses placeholders, used if overrider does not exist
GetHeaderResponse *spec.VersionedSignedBuilderBid
GetPayloadResponse *api.VersionedSubmitBlindedBlockResponse
GetHeaderResponse *builderSpec.VersionedSignedBuilderBid
GetPayloadResponse *builderApi.VersionedSubmitBlindedBlockResponse

// Server section
Server *httptest.Server
Expand Down Expand Up @@ -141,7 +141,7 @@ func (m *mockRelay) handleStatus(w http.ResponseWriter, _ *http.Request) {
fmt.Fprintf(w, `{}`)
}

// By default, handleRegisterValidator returns a default apiv1.SignedValidatorRegistration
// By default, handleRegisterValidator returns a default builderApiV1.SignedValidatorRegistration
func (m *mockRelay) handleRegisterValidator(w http.ResponseWriter, req *http.Request) {
m.mu.Lock()
defer m.mu.Unlock()
Expand All @@ -154,7 +154,7 @@ func (m *mockRelay) handleRegisterValidator(w http.ResponseWriter, req *http.Req

// defaultHandleRegisterValidator returns the default handler for handleRegisterValidator
func (m *mockRelay) defaultHandleRegisterValidator(w http.ResponseWriter, req *http.Request) {
payload := []apiv1.SignedValidatorRegistration{}
payload := []builderApiV1.SignedValidatorRegistration{}
if err := DecodeJSON(req.Body, &payload); err != nil {
http.Error(w, err.Error(), http.StatusBadRequest)
return
Expand All @@ -166,11 +166,11 @@ func (m *mockRelay) defaultHandleRegisterValidator(w http.ResponseWriter, req *h

// MakeGetHeaderResponse is used to create the default or can be used to create a custom response to the getHeader
// method
func (m *mockRelay) MakeGetHeaderResponse(value uint64, blockHash, parentHash, publicKey string, version consensusspec.DataVersion) *spec.VersionedSignedBuilderBid {
func (m *mockRelay) MakeGetHeaderResponse(value uint64, blockHash, parentHash, publicKey string, version spec.DataVersion) *builderSpec.VersionedSignedBuilderBid {
switch version {
case consensusspec.DataVersionCapella:
case spec.DataVersionCapella:
// Fill the payload with custom values.
message := &apicapella.BuilderBid{
message := &builderApiCapella.BuilderBid{
Header: &capella.ExecutionPayloadHeader{
BlockHash: _HexToHash(blockHash),
ParentHash: _HexToHash(parentHash),
Expand All @@ -184,15 +184,15 @@ func (m *mockRelay) MakeGetHeaderResponse(value uint64, blockHash, parentHash, p
signature, err := ssz.SignMessage(message, ssz.DomainBuilder, m.secretKey)
require.NoError(m.t, err)

return &spec.VersionedSignedBuilderBid{
Version: consensusspec.DataVersionCapella,
Capella: &apicapella.SignedBuilderBid{
return &builderSpec.VersionedSignedBuilderBid{
Version: spec.DataVersionCapella,
Capella: &builderApiCapella.SignedBuilderBid{
Message: message,
Signature: signature,
},
}
case consensusspec.DataVersionDeneb:
message := &apideneb.BuilderBid{
case spec.DataVersionDeneb:
message := &builderApiDeneb.BuilderBid{
Header: &deneb.ExecutionPayloadHeader{
BlockHash: _HexToHash(blockHash),
ParentHash: _HexToHash(parentHash),
Expand All @@ -201,21 +201,21 @@ func (m *mockRelay) MakeGetHeaderResponse(value uint64, blockHash, parentHash, p
},
Value: uint256.NewInt(value),
Pubkey: _HexToPubkey(publicKey),
BlindedBlobsBundle: &apideneb.BlindedBlobsBundle{},
BlindedBlobsBundle: &builderApiDeneb.BlindedBlobsBundle{},
}

// Sign the message.
signature, err := ssz.SignMessage(message, ssz.DomainBuilder, m.secretKey)
require.NoError(m.t, err)

return &spec.VersionedSignedBuilderBid{
Version: consensusspec.DataVersionDeneb,
Deneb: &apideneb.SignedBuilderBid{
return &builderSpec.VersionedSignedBuilderBid{
Version: spec.DataVersionDeneb,
Deneb: &builderApiDeneb.SignedBuilderBid{
Message: message,
Signature: signature,
},
}
case consensusspec.DataVersionUnknown, consensusspec.DataVersionPhase0, consensusspec.DataVersionAltair, consensusspec.DataVersionBellatrix:
case spec.DataVersionUnknown, spec.DataVersionPhase0, spec.DataVersionAltair, spec.DataVersionBellatrix:
return nil
}
return nil
Expand Down Expand Up @@ -245,7 +245,7 @@ func (m *mockRelay) defaultHandleGetHeader(w http.ResponseWriter) {
"0xe28385e7bd68df656cd0042b74b69c3104b5356ed1f20eb69f1f925df47a3ab7",
"0xe28385e7bd68df656cd0042b74b69c3104b5356ed1f20eb69f1f925df47a3ab7",
"0x8a1d7b8dd64e0aafe7ea7b6c95065c9364cf99d38470c12ee807d55f7de1529ad29ce2c422e0b65e3d5a05c02caca249",
consensusspec.DataVersionCapella,
spec.DataVersionCapella,
)
if m.GetHeaderResponse != nil {
response = m.GetHeaderResponse
Expand All @@ -259,8 +259,8 @@ func (m *mockRelay) defaultHandleGetHeader(w http.ResponseWriter) {

// MakeGetPayloadResponse is used to create the default or can be used to create a custom response to the getPayload
// method
func (m *mockRelay) MakeGetPayloadResponse(parentHash, blockHash, feeRecipient string, blockNumber uint64, version consensusspec.DataVersion) *api.VersionedSubmitBlindedBlockResponse {
return &api.VersionedSubmitBlindedBlockResponse{
func (m *mockRelay) MakeGetPayloadResponse(parentHash, blockHash, feeRecipient string, blockNumber uint64, version spec.DataVersion) *builderApi.VersionedSubmitBlindedBlockResponse {
return &builderApi.VersionedSubmitBlindedBlockResponse{
Version: version,
Capella: &capella.ExecutionPayload{
ParentHash: _HexToHash(parentHash),
Expand Down Expand Up @@ -296,7 +296,7 @@ func (m *mockRelay) defaultHandleGetPayload(w http.ResponseWriter) {
"0x534809bd2b6832edff8d8ce4cb0e50068804fd1ef432c8362ad708a74fdc0e46",
"0xdb65fEd33dc262Fe09D9a2Ba8F80b329BA25f941",
12345,
consensusspec.DataVersionCapella,
spec.DataVersionCapella,
)

if m.GetPayloadResponse != nil {
Expand Down
4 changes: 2 additions & 2 deletions server/mock_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package server
import (
"testing"

capellaapi "github.com/attestantio/go-builder-client/api/capella"
builderApiCapella "github.com/attestantio/go-builder-client/api/capella"
"github.com/attestantio/go-eth2-client/spec/bellatrix"
"github.com/attestantio/go-eth2-client/spec/capella"
"github.com/attestantio/go-eth2-client/spec/phase0"
Expand Down Expand Up @@ -202,7 +202,7 @@ func TestHexToSignature(t *testing.T) {

publicKey := hexutil.Encode(bls.PublicKeyToBytes(blsPublicKey))

message := &capellaapi.BuilderBid{
message := &builderApiCapella.BuilderBid{
Header: &capella.ExecutionPayloadHeader{
BlockHash: _HexToHash("0xe28385e7bd68df656cd0042b74b69c3104b5356ed1f20eb69f1f925df47a3ab7"),
},
Expand Down
Loading

0 comments on commit 09ea881

Please sign in to comment.