Skip to content

Commit

Permalink
Remove capella types
Browse files Browse the repository at this point in the history
  • Loading branch information
avalonche committed Apr 26, 2024
1 parent 74a8ecb commit db7675e
Show file tree
Hide file tree
Showing 13 changed files with 87 additions and 726 deletions.
16 changes: 8 additions & 8 deletions cmd/test-cli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

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"
eth2ApiV1Deneb "github.com/attestantio/go-eth2-client/api/v1/deneb"
"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 @@ -75,12 +75,12 @@ func doGetHeader(v validatorPrivateData, boostEndpoint string, beaconNode Beacon
log.WithError(err).WithField("currentBlockHash", currentBlockHash).Fatal("Could not get header")
}

if getHeaderResp.Capella.Message == nil {
if getHeaderResp.Deneb.Message == nil {
log.Fatal("Did not receive correct header")
}
log.WithField("header", *getHeaderResp.Capella.Message).Info("Got header from boost")
log.WithField("header", *getHeaderResp.Deneb.Message).Info("Got header from boost")

ok, err := ssz.VerifySignature(getHeaderResp.Capella.Message, builderSigningDomain, getHeaderResp.Capella.Message.Pubkey[:], getHeaderResp.Capella.Signature[:])
ok, err := ssz.VerifySignature(getHeaderResp.Deneb.Message, builderSigningDomain, getHeaderResp.Deneb.Message.Pubkey[:], getHeaderResp.Deneb.Signature[:])
if err != nil {
log.WithError(err).Fatal("Could not verify builder bid signature")
}
Expand All @@ -94,12 +94,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 := eth2ApiV1Capella.BlindedBeaconBlock{
blindedBeaconBlock := eth2ApiV1Deneb.BlindedBeaconBlock{
Slot: 0,
ProposerIndex: 0,
ParentRoot: phase0.Root{},
StateRoot: phase0.Root{},
Body: &eth2ApiV1Capella.BlindedBeaconBlockBody{
Body: &eth2ApiV1Deneb.BlindedBeaconBlockBody{
RANDAOReveal: phase0.BLSSignature{},
ETH1Data: &phase0.ETH1Data{},
Graffiti: phase0.Hash32{},
Expand All @@ -109,7 +109,7 @@ func doGetPayload(v validatorPrivateData, boostEndpoint string, beaconNode Beaco
Deposits: []*phase0.Deposit{},
VoluntaryExits: []*phase0.SignedVoluntaryExit{},
SyncAggregate: &altair.SyncAggregate{},
ExecutionPayloadHeader: header.Capella.Message.Header,
ExecutionPayloadHeader: header.Deneb.Message.Header,
},
}

Expand All @@ -118,7 +118,7 @@ func doGetPayload(v validatorPrivateData, boostEndpoint string, beaconNode Beaco
log.WithError(err).Fatal("could not sign blinded beacon block")
}

payload := eth2ApiV1Capella.SignedBlindedBeaconBlock{
payload := eth2ApiV1Deneb.SignedBlindedBeaconBlock{
Message: &blindedBeaconBlock,
Signature: signature,
}
Expand Down
10 changes: 5 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ require (

require (
github.com/StackExchange/wmi v1.2.1 // indirect
github.com/attestantio/go-builder-client v0.4.2
github.com/attestantio/go-eth2-client v0.19.10
github.com/attestantio/go-builder-client v0.4.5
github.com/attestantio/go-eth2-client v0.21.1
github.com/btcsuite/btcd v0.22.0-beta // indirect
github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
Expand All @@ -69,7 +69,7 @@ require (
github.com/ferranbt/fastssz v0.1.3 // indirect
github.com/go-ole/go-ole v1.3.0 // indirect
github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect
github.com/klauspost/cpuid/v2 v2.2.6 // indirect
github.com/klauspost/cpuid/v2 v2.2.7 // indirect
github.com/mattn/go-runewidth v0.0.13 // indirect
github.com/minio/sha256-simd v1.0.1 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
Expand All @@ -82,8 +82,8 @@ require (
github.com/tklauser/numcpus v0.6.1 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.25.0 // indirect
golang.org/x/crypto v0.18.0 // indirect
golang.org/x/sys v0.16.0 // indirect
golang.org/x/crypto v0.21.0 // indirect
golang.org/x/sys v0.18.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
24 changes: 12 additions & 12 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ github.com/VictoriaMetrics/fastcache v1.12.1/go.mod h1:tX04vaqcNoQeGLD+ra5pU5sWk
github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII=
github.com/ajg/form v1.5.1/go.mod h1:uL1WgH+h2mgNtvBq0339dVnzXdBETtL2LeUXaIv25UY=
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
github.com/attestantio/go-builder-client v0.4.2 h1:EycfAFqQV+ooc2z6hmTsbuH4TCLknr0aO0nHLHLMpJM=
github.com/attestantio/go-builder-client v0.4.2/go.mod h1:e02i/WO4fjs3/u9oIZEjiC8CK1Qyxy4cpiMMGKx4VqQ=
github.com/attestantio/go-eth2-client v0.19.10 h1:NLs9mcBvZpBTZ3du7Ey2NHQoj8d3UePY7pFBXX6C6qs=
github.com/attestantio/go-eth2-client v0.19.10/go.mod h1:TTz7YF6w4z6ahvxKiHuGPn6DbQn7gH6HPuWm/DEQeGE=
github.com/attestantio/go-builder-client v0.4.5 h1:L11DGcQbMMNNYLJyme2aLeruNK3lXZ7M9QzvpoMPNPs=
github.com/attestantio/go-builder-client v0.4.5/go.mod h1:ZMmatuguvfy/JRHF8eFUy9RQgkHzdslCCVMofiywRkE=
github.com/attestantio/go-eth2-client v0.21.1 h1:yvsMd/azPUbxiJzWZhgqfOJJRNF1zLvAJpcBXTHzyh8=
github.com/attestantio/go-eth2-client v0.21.1/go.mod h1:Tb412NpzhsC0sbtpXS4D51y5se6nDkWAi6amsJrqX9c=
github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g=
github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A=
github.com/benbjohnson/clock v1.3.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
Expand Down Expand Up @@ -221,8 +221,8 @@ github.com/klauspost/compress v1.9.7/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0
github.com/klauspost/compress v1.15.15 h1:EF27CXIuDsYJ6mmvtBRlEuB2UVOqHG1tAXgZ7yIO+lw=
github.com/klauspost/compress v1.15.15/go.mod h1:ZcK2JAFqKOpnBlxcLsJzYfrS9X1akm9fHZNnD9+Vo/4=
github.com/klauspost/cpuid v1.2.1/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek=
github.com/klauspost/cpuid/v2 v2.2.6 h1:ndNyv040zDGIDh8thGkXYjnFtiN02M1PVVF+JE/48xc=
github.com/klauspost/cpuid/v2 v2.2.6/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws=
github.com/klauspost/cpuid/v2 v2.2.7 h1:ZWSB3igEs+d0qvnxR/ZBzXVmxkgt8DdzP6m9pfuVLDM=
github.com/klauspost/cpuid/v2 v2.2.7/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
Expand Down Expand Up @@ -396,8 +396,8 @@ golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37/go.mod h1:LzIPMQfyMNhhGPh
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.18.0 h1:PGVlW0xEltQnzFZ55hkuX5+KLyrMYhHld1YHO4AKcdc=
golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg=
golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA=
golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa h1:FRnLl4eNAQl8hwxVVC17teOw8kdjVDVAiFMtgUdTSRQ=
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa/go.mod h1:zk2irFbV9DP96SEBUUAy67IdHUaZuSnrz1n472HUCLE=
Expand Down Expand Up @@ -429,8 +429,8 @@ golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwY
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
golang.org/x/net v0.0.0-20211008194852-3b03d305991f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.18.0 h1:mIYleuAkSbHh0tCv7RvjL3F6ZVbLjq4+R7zbOn3Kokg=
golang.org/x/net v0.18.0/go.mod h1:/czyP5RqHAH4odGYxBJ1qz0+CE5WZ+2j1YgoEo8F2jQ=
golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4=
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
Expand Down Expand Up @@ -477,8 +477,8 @@ golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU=
golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4=
golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
Expand Down
50 changes: 17 additions & 33 deletions server/mock/mock_relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"time"

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"
Expand Down Expand Up @@ -172,29 +171,6 @@ func (m *Relay) defaultHandleRegisterValidator(w http.ResponseWriter, req *http.
// method
func (m *Relay) MakeGetHeaderResponse(value uint64, blockHash, parentHash, publicKey string, version spec.DataVersion) *builderSpec.VersionedSignedBuilderBid {
switch version {
case spec.DataVersionCapella:
// Fill the payload with custom values.
message := &builderApiCapella.BuilderBid{
Header: &capella.ExecutionPayloadHeader{
BlockHash: HexToHash(blockHash),
ParentHash: HexToHash(parentHash),
WithdrawalsRoot: phase0.Root{},
},
Value: uint256.NewInt(value),
Pubkey: HexToPubkey(publicKey),
}

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

return &builderSpec.VersionedSignedBuilderBid{
Version: spec.DataVersionCapella,
Capella: &builderApiCapella.SignedBuilderBid{
Message: message,
Signature: signature,
},
}
case spec.DataVersionDeneb:
message := &builderApiDeneb.BuilderBid{
Header: &deneb.ExecutionPayloadHeader{
Expand All @@ -219,7 +195,7 @@ func (m *Relay) MakeGetHeaderResponse(value uint64, blockHash, parentHash, publi
Signature: signature,
},
}
case spec.DataVersionUnknown, spec.DataVersionPhase0, spec.DataVersionAltair, spec.DataVersionBellatrix:
case spec.DataVersionUnknown, spec.DataVersionPhase0, spec.DataVersionAltair, spec.DataVersionBellatrix, spec.DataVersionCapella:
return nil
}
return nil
Expand Down Expand Up @@ -249,7 +225,7 @@ func (m *Relay) defaultHandleGetHeader(w http.ResponseWriter) {
"0xe28385e7bd68df656cd0042b74b69c3104b5356ed1f20eb69f1f925df47a3ab7",
"0xe28385e7bd68df656cd0042b74b69c3104b5356ed1f20eb69f1f925df47a3ab7",
"0x8a1d7b8dd64e0aafe7ea7b6c95065c9364cf99d38470c12ee807d55f7de1529ad29ce2c422e0b65e3d5a05c02caca249",
spec.DataVersionCapella,
spec.DataVersionDeneb,
)
if m.GetHeaderResponse != nil {
response = m.GetHeaderResponse
Expand All @@ -266,12 +242,20 @@ func (m *Relay) defaultHandleGetHeader(w http.ResponseWriter) {
func (m *Relay) MakeGetPayloadResponse(parentHash, blockHash, feeRecipient string, blockNumber uint64, version spec.DataVersion) *builderApi.VersionedSubmitBlindedBlockResponse {
return &builderApi.VersionedSubmitBlindedBlockResponse{
Version: version,
Capella: &capella.ExecutionPayload{
ParentHash: HexToHash(parentHash),
BlockHash: HexToHash(blockHash),
BlockNumber: blockNumber,
FeeRecipient: HexToAddress(feeRecipient),
Withdrawals: make([]*capella.Withdrawal, 0),
Deneb: &builderApiDeneb.ExecutionPayloadAndBlobsBundle{
ExecutionPayload: &deneb.ExecutionPayload{
ParentHash: HexToHash(parentHash),
BlockHash: HexToHash(blockHash),
BlockNumber: blockNumber,
FeeRecipient: HexToAddress(feeRecipient),
BaseFeePerGas: uint256.NewInt(0),
Withdrawals: make([]*capella.Withdrawal, 0),
},
BlobsBundle: &builderApiDeneb.BlobsBundle{
Blobs: make([]deneb.Blob, 0),
Commitments: make([]deneb.KZGCommitment, 0),
Proofs: make([]deneb.KZGProof, 0),
},
},
}
}
Expand Down Expand Up @@ -300,7 +284,7 @@ func (m *Relay) DefaultHandleGetPayload(w http.ResponseWriter) {
"0x534809bd2b6832edff8d8ce4cb0e50068804fd1ef432c8362ad708a74fdc0e46",
"0xdb65fEd33dc262Fe09D9a2Ba8F80b329BA25f941",
12345,
spec.DataVersionCapella,
spec.DataVersionDeneb,
)

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

builderApiCapella "github.com/attestantio/go-builder-client/api/capella"
builderApiDeneb "github.com/attestantio/go-builder-client/api/deneb"
"github.com/attestantio/go-eth2-client/spec/bellatrix"
"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/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
Expand Down Expand Up @@ -205,9 +205,10 @@ func TestHexToSignature(t *testing.T) {

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

message := &builderApiCapella.BuilderBid{
Header: &capella.ExecutionPayloadHeader{
BlockHash: HexToHash("0xe28385e7bd68df656cd0042b74b69c3104b5356ed1f20eb69f1f925df47a3ab7"),
message := &builderApiDeneb.BuilderBid{
Header: &deneb.ExecutionPayloadHeader{
BlockHash: HexToHash("0xe28385e7bd68df656cd0042b74b69c3104b5356ed1f20eb69f1f925df47a3ab7"),
BaseFeePerGas: uint256.NewInt(0),
},
Value: uint256.NewInt(12345),
Pubkey: HexToPubkey(publicKey),
Expand Down
Loading

0 comments on commit db7675e

Please sign in to comment.