Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make attestantio import names consistent #510

Merged
merged 3 commits into from
Sep 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions common/ssz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"os"
"testing"

"github.com/attestantio/go-builder-client/api/capella"
"github.com/attestantio/go-builder-client/spec"
builderApiCapella "github.com/attestantio/go-builder-client/api/capella"
builderSpec "github.com/attestantio/go-builder-client/spec"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/stretchr/testify/require"
)
Expand Down Expand Up @@ -45,7 +45,7 @@ func TestSSZBuilderSubmission(t *testing.T) {
}

func TestSSZGetHeaderResponse(t *testing.T) {
payload := new(spec.VersionedSignedBuilderBid)
payload := new(builderSpec.VersionedSignedBuilderBid)

byteValue, err := os.ReadFile("../testdata/getHeaderResponseCapella_Mainnet.json")
require.NoError(t, err)
Expand All @@ -72,14 +72,14 @@ func BenchmarkDecoding(b *testing.B) {
sszBytes, err := os.ReadFile("../testdata/getHeaderResponseCapella_Mainnet.ssz")
require.NoError(b, err)

payload := new(spec.VersionedSignedBuilderBid)
payload := new(builderSpec.VersionedSignedBuilderBid)
b.Run("json", func(b *testing.B) {
for i := 0; i < b.N; i++ {
err = json.Unmarshal(jsonBytes, &payload)
require.NoError(b, err)
}
})
payload.Capella = new(capella.SignedBuilderBid)
payload.Capella = new(builderApiCapella.SignedBuilderBid)
b.Run("ssz", func(b *testing.B) {
for i := 0; i < b.N; i++ {
err = payload.Capella.UnmarshalSSZ(sszBytes)
Expand Down
78 changes: 39 additions & 39 deletions common/test_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ import (
"testing"
"time"

"github.com/attestantio/go-builder-client/api"
"github.com/attestantio/go-builder-client/api/capella"
"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/bellatrix"
consensuscapella "github.com/attestantio/go-eth2-client/spec/capella"
consensusdeneb "github.com/attestantio/go-eth2-client/spec/deneb"
"github.com/attestantio/go-eth2-client/spec/capella"
"github.com/attestantio/go-eth2-client/spec/deneb"
"github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/flashbots/go-boost-utils/bls"
"github.com/flashbots/go-boost-utils/ssz"
Expand Down Expand Up @@ -66,8 +66,8 @@ func _HexToHash(s string) (ret phase0.Hash32) {
return ret
}

var ValidPayloadRegisterValidator = apiv1.SignedValidatorRegistration{
Message: &apiv1.ValidatorRegistration{
var ValidPayloadRegisterValidator = builderApiV1.SignedValidatorRegistration{
Message: &builderApiV1.ValidatorRegistration{
FeeRecipient: _HexToAddress("0xdb65fEd33dc262Fe09D9a2Ba8F80b329BA25f941"),
Timestamp: time.Unix(1606824043, 0),
GasLimit: 30000000,
Expand All @@ -78,43 +78,43 @@ var ValidPayloadRegisterValidator = apiv1.SignedValidatorRegistration{
"0xaf12df007a0c78abb5575067e5f8b089cfcc6227e4a91db7dd8cf517fe86fb944ead859f0781277d9b78c672e4a18c5d06368b603374673cf2007966cece9540f3a1b3f6f9e1bf421d779c4e8010368e6aac134649c7a009210780d401a778a5"),
}

func TestBuilderSubmitBlockRequest(sk *bls.SecretKey, bid *BidTraceV2, version consensusspec.DataVersion) VersionedSubmitBlockRequest {
func TestBuilderSubmitBlockRequest(sk *bls.SecretKey, bid *BidTraceV2, version spec.DataVersion) VersionedSubmitBlockRequest {
signature, err := ssz.SignMessage(bid, ssz.DomainBuilder, sk)
check(err, " SignMessage: ", bid, sk)
if version == consensusspec.DataVersionDeneb {
if version == spec.DataVersionDeneb {
return VersionedSubmitBlockRequest{
VersionedSubmitBlockRequest: spec.VersionedSubmitBlockRequest{ //nolint:exhaustruct
Version: consensusspec.DataVersionDeneb,
Deneb: &deneb.SubmitBlockRequest{
VersionedSubmitBlockRequest: builderSpec.VersionedSubmitBlockRequest{ //nolint:exhaustruct
Version: spec.DataVersionDeneb,
Deneb: &builderApiDeneb.SubmitBlockRequest{
Message: &bid.BidTrace,
Signature: [96]byte(signature),
ExecutionPayload: &consensusdeneb.ExecutionPayload{ //nolint:exhaustruct
ExecutionPayload: &deneb.ExecutionPayload{ //nolint:exhaustruct
Transactions: []bellatrix.Transaction{[]byte{0x03}},
Timestamp: bid.Slot * 12, // 12 seconds per slot.
PrevRandao: _HexToHash("0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2"),
Withdrawals: []*consensuscapella.Withdrawal{},
Withdrawals: []*capella.Withdrawal{},
BaseFeePerGas: uint256.NewInt(0),
},
BlobsBundle: &deneb.BlobsBundle{
Commitments: []consensusdeneb.KzgCommitment{},
Proofs: []consensusdeneb.KzgProof{},
Blobs: []consensusdeneb.Blob{},
BlobsBundle: &builderApiDeneb.BlobsBundle{
Commitments: []deneb.KzgCommitment{},
Proofs: []deneb.KzgProof{},
Blobs: []deneb.Blob{},
},
},
},
}
}
return VersionedSubmitBlockRequest{
VersionedSubmitBlockRequest: spec.VersionedSubmitBlockRequest{ //nolint:exhaustruct
Version: consensusspec.DataVersionCapella,
Capella: &capella.SubmitBlockRequest{
VersionedSubmitBlockRequest: builderSpec.VersionedSubmitBlockRequest{ //nolint:exhaustruct
Version: spec.DataVersionCapella,
Capella: &builderApiCapella.SubmitBlockRequest{
Message: &bid.BidTrace,
Signature: [96]byte(signature),
ExecutionPayload: &consensuscapella.ExecutionPayload{ //nolint:exhaustruct
ExecutionPayload: &capella.ExecutionPayload{ //nolint:exhaustruct
Transactions: []bellatrix.Transaction{[]byte{0x03}},
Timestamp: bid.Slot * 12, // 12 seconds per slot.
PrevRandao: _HexToHash("0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2"),
Withdrawals: []*consensuscapella.Withdrawal{},
Withdrawals: []*capella.Withdrawal{},
},
},
},
Expand All @@ -126,13 +126,13 @@ type CreateTestBlockSubmissionOpts struct {
relayPk phase0.BLSPubKey
domain phase0.Domain

Version consensusspec.DataVersion
Version spec.DataVersion
Slot uint64
ParentHash string
ProposerPubkey string
}

func CreateTestBlockSubmission(t *testing.T, builderPubkey string, value *uint256.Int, opts *CreateTestBlockSubmissionOpts) (payload *VersionedSubmitBlockRequest, getPayloadResponse *api.VersionedSubmitBlindedBlockResponse, getHeaderResponse *spec.VersionedSignedBuilderBid) {
func CreateTestBlockSubmission(t *testing.T, builderPubkey string, value *uint256.Int, opts *CreateTestBlockSubmissionOpts) (payload *VersionedSubmitBlockRequest, getPayloadResponse *builderApi.VersionedSubmitBlindedBlockResponse, getHeaderResponse *builderSpec.VersionedSignedBuilderBid) {
t.Helper()
var err error

Expand All @@ -142,7 +142,7 @@ func CreateTestBlockSubmission(t *testing.T, builderPubkey string, value *uint25
domain := phase0.Domain{}
proposerPk := phase0.BLSPubKey{}
parentHash := phase0.Hash32{}
version := consensusspec.DataVersionCapella
version := spec.DataVersionCapella

if opts != nil {
relaySk = opts.relaySk
Expand All @@ -160,43 +160,43 @@ func CreateTestBlockSubmission(t *testing.T, builderPubkey string, value *uint25
require.NoError(t, err)
}

if opts.Version != consensusspec.DataVersionUnknown {
if opts.Version != spec.DataVersionUnknown {
version = opts.Version
}
}

builderPk, err := StrToPhase0Pubkey(builderPubkey)
require.NoError(t, err)

bidTrace := &apiv1.BidTrace{ //nolint:exhaustruct
bidTrace := &builderApiV1.BidTrace{ //nolint:exhaustruct
BuilderPubkey: builderPk,
Value: value,
Slot: slot,
ParentHash: parentHash,
ProposerPubkey: proposerPk,
}

if version == consensusspec.DataVersionDeneb {
if version == spec.DataVersionDeneb {
payload = &VersionedSubmitBlockRequest{
VersionedSubmitBlockRequest: spec.VersionedSubmitBlockRequest{ //nolint:exhaustruct
VersionedSubmitBlockRequest: builderSpec.VersionedSubmitBlockRequest{ //nolint:exhaustruct
Version: version,
Deneb: &deneb.SubmitBlockRequest{
Deneb: &builderApiDeneb.SubmitBlockRequest{
Message: bidTrace,
ExecutionPayload: &consensusdeneb.ExecutionPayload{ //nolint:exhaustruct
ExecutionPayload: &deneb.ExecutionPayload{ //nolint:exhaustruct
BaseFeePerGas: uint256.NewInt(0),
},
BlobsBundle: &deneb.BlobsBundle{}, //nolint:exhaustruct
BlobsBundle: &builderApiDeneb.BlobsBundle{}, //nolint:exhaustruct
Signature: phase0.BLSSignature{},
},
},
}
} else {
payload = &VersionedSubmitBlockRequest{
VersionedSubmitBlockRequest: spec.VersionedSubmitBlockRequest{ //nolint:exhaustruct
VersionedSubmitBlockRequest: builderSpec.VersionedSubmitBlockRequest{ //nolint:exhaustruct
Version: version,
Capella: &capella.SubmitBlockRequest{
Capella: &builderApiCapella.SubmitBlockRequest{
Message: bidTrace,
ExecutionPayload: &consensuscapella.ExecutionPayload{}, //nolint:exhaustruct
ExecutionPayload: &capella.ExecutionPayload{}, //nolint:exhaustruct
Signature: phase0.BLSSignature{},
},
},
Expand Down
24 changes: 12 additions & 12 deletions common/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import (
"os"
"strings"

apiv1 "github.com/attestantio/go-builder-client/api/v1"
consensusbellatrix "github.com/attestantio/go-eth2-client/spec/bellatrix"
consensuscapella "github.com/attestantio/go-eth2-client/spec/capella"
builderApiV1 "github.com/attestantio/go-builder-client/api/v1"
"github.com/attestantio/go-eth2-client/spec/bellatrix"
"github.com/attestantio/go-eth2-client/spec/capella"
"github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/flashbots/go-boost-utils/ssz"
boostTypes "github.com/flashbots/go-boost-utils/types"
Expand Down Expand Up @@ -163,13 +163,13 @@ func (p PubkeyHex) String() string {
}

type BuilderGetValidatorsResponseEntry struct {
Slot uint64 `json:"slot,string"`
ValidatorIndex uint64 `json:"validator_index,string"`
Entry *apiv1.SignedValidatorRegistration `json:"entry"`
Slot uint64 `json:"slot,string"`
ValidatorIndex uint64 `json:"validator_index,string"`
Entry *builderApiV1.SignedValidatorRegistration `json:"entry"`
}

type BidTraceV2 struct {
apiv1.BidTrace
builderApiV1.BidTrace
BlockNumber uint64 `db:"block_number" json:"block_number,string"`
NumTx uint64 `db:"num_tx" json:"num_tx,string"`
}
Expand Down Expand Up @@ -216,7 +216,7 @@ func (b *BidTraceV2) UnmarshalJSON(data []byte) error {
b.NumTx = params.NumTx
b.BlockNumber = params.BlockNumber

bidTrace := new(apiv1.BidTrace)
bidTrace := new(builderApiV1.BidTrace)
err = json.Unmarshal(data, bidTrace)
if err != nil {
return err
Expand Down Expand Up @@ -303,22 +303,22 @@ func (b *BidTraceV2WithTimestampJSON) ToCSVRecord() []string {
}

type BlockSubmissionInfo struct {
BidTrace *apiv1.BidTrace
BidTrace *builderApiV1.BidTrace
Slot uint64
BlockHash phase0.Hash32
ParentHash phase0.Hash32
ExecutionPayloadBlockHash phase0.Hash32
ExecutionPayloadParentHash phase0.Hash32
Builder phase0.BLSPubKey
Proposer phase0.BLSPubKey
ProposerFeeRecipient consensusbellatrix.ExecutionAddress
ProposerFeeRecipient bellatrix.ExecutionAddress
GasUsed uint64
GasLimit uint64
Timestamp uint64
BlockNumber uint64
Value *uint256.Int
PrevRandao phase0.Hash32
Signature phase0.BLSSignature
Transactions []consensusbellatrix.Transaction
Withdrawals []*consensuscapella.Withdrawal
Transactions []bellatrix.Transaction
Withdrawals []*capella.Withdrawal
}
Loading
Loading