diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 15fd5e580..f2410a9ce 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -18,7 +18,7 @@ package utils import ( - optimisticGrpc "buf.build/gen/go/astria/execution-apis/grpc/go/astria/bundle/v1alpha1/bundlev1alpha1grpc" + optimisticGrpc "buf.build/gen/go/astria/execution-apis/grpc/go/astria/auction/v1alpha1/auctionv1alpha1grpc" "context" "crypto/ecdsa" "encoding/hex" @@ -2003,8 +2003,8 @@ func RegisterGraphQLService(stack *node.Node, backend ethapi.Backend, filterSyst // RegisterGRPCServices adds the gRPC API to the node. // It was done this way so that our grpc execution server can access the ethapi.Backend -func RegisterGRPCServices(stack *node.Node, execServ astriaGrpc.ExecutionServiceServer, optimisticExecutionServ optimisticGrpc.OptimisticExecutionServiceServer, bundleStreamingServ optimisticGrpc.BundleServiceServer, cfg *node.Config) { - if err := node.NewGRPCServerHandler(stack, execServ, optimisticExecutionServ, bundleStreamingServ, cfg); err != nil { +func RegisterGRPCServices(stack *node.Node, execServ astriaGrpc.ExecutionServiceServer, optimisticExecutionServ optimisticGrpc.OptimisticExecutionServiceServer, auctionServiceServer optimisticGrpc.AuctionServiceServer, cfg *node.Config) { + if err := node.NewGRPCServerHandler(stack, execServ, optimisticExecutionServ, auctionServiceServer, cfg); err != nil { Fatalf("Failed to register the gRPC service: %v", err) } } diff --git a/go.mod b/go.mod index 44aeb9066..c9445016e 100644 --- a/go.mod +++ b/go.mod @@ -3,10 +3,10 @@ module github.com/ethereum/go-ethereum go 1.21 require ( - buf.build/gen/go/astria/execution-apis/grpc/go v1.5.1-00000000000000-e09c7fd3fe26.1 - buf.build/gen/go/astria/execution-apis/protocolbuffers/go v1.35.2-00000000000000-e09c7fd3fe26.1 - buf.build/gen/go/astria/primitives/protocolbuffers/go v1.35.2-00000000000000-2f2e9ce53f59.1 - buf.build/gen/go/astria/sequencerblock-apis/protocolbuffers/go v1.35.2-00000000000000-0eda7df0ee38.1 + buf.build/gen/go/astria/execution-apis/grpc/go v1.5.1-00000000000000-1f40f333891d.2 + buf.build/gen/go/astria/execution-apis/protocolbuffers/go v1.36.2-00000000000000-1f40f333891d.1 + buf.build/gen/go/astria/primitives/protocolbuffers/go v1.36.2-00000000000000-9a039a6ed8db.1 + buf.build/gen/go/astria/sequencerblock-apis/protocolbuffers/go v1.36.2-00000000000000-e54e1c9ad405.1 github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.2.0 github.com/Microsoft/go-winio v0.6.1 github.com/VictoriaMetrics/fastcache v1.12.1 @@ -79,7 +79,7 @@ require ( golang.org/x/time v0.5.0 golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d google.golang.org/grpc v1.64.1 - google.golang.org/protobuf v1.35.2 + google.golang.org/protobuf v1.36.2 gopkg.in/natefinch/lumberjack.v2 v2.0.0 gopkg.in/yaml.v3 v3.0.1 ) diff --git a/go.sum b/go.sum index 5ad9748dd..78e748f2d 100644 --- a/go.sum +++ b/go.sum @@ -1,3 +1,5 @@ +buf.build/gen/go/astria/execution-apis/grpc/go v1.5.1-00000000000000-1f40f333891d.2 h1:9rMXnvPR2EX56tMIqbhOK+DvqKjWb++p5s1/bookIl8= +buf.build/gen/go/astria/execution-apis/grpc/go v1.5.1-00000000000000-1f40f333891d.2/go.mod h1:hdCXwnxpMeoqXK5LCQ6gLMcmMLUDX8T9+hbxYrtj+wQ= buf.build/gen/go/astria/execution-apis/grpc/go v1.5.1-00000000000000-cc31a327d543.1 h1:wOry49zAbse0G4mt2tFTwa4P2AUMuYCR/0mYcPrpcbs= buf.build/gen/go/astria/execution-apis/grpc/go v1.5.1-00000000000000-cc31a327d543.1/go.mod h1:+pVCkEpJNp2JtooS8NiydT7bO9+hu11XUZ5Z47DPtXo= buf.build/gen/go/astria/execution-apis/grpc/go v1.5.1-00000000000000-e09c7fd3fe26.1 h1:gS4erruX5XeMN0MZ7xe4JmEIR3uCWrvzG5HGV725WiI= @@ -10,14 +12,26 @@ buf.build/gen/go/astria/execution-apis/protocolbuffers/go v1.35.1-20241017141511 buf.build/gen/go/astria/execution-apis/protocolbuffers/go v1.35.1-20241017141511-7e4bcc0ebba5.1/go.mod h1:U4LUlabiYNYBd1pqYS9o8SsHjBRoEBysrfRVnebzJH0= buf.build/gen/go/astria/execution-apis/protocolbuffers/go v1.35.2-00000000000000-e09c7fd3fe26.1 h1:Twi169wrd7ssCnK27Bymlytv5LmvwFV0zhKhJ64nCYM= buf.build/gen/go/astria/execution-apis/protocolbuffers/go v1.35.2-00000000000000-e09c7fd3fe26.1/go.mod h1:PWzMbPHJ+Y31iNFrtSc5vy/wvm2805ZXyDZndzzFLa0= +buf.build/gen/go/astria/execution-apis/protocolbuffers/go v1.36.1-00000000000000-1f40f333891d.1 h1:CSMft5/33d/88j3ziC4zid4DOP7X1Xv71I6pW3BUOvA= +buf.build/gen/go/astria/execution-apis/protocolbuffers/go v1.36.1-00000000000000-1f40f333891d.1/go.mod h1:7azHjtjY3sk38xuZGlf2X6DpAPgQMoeZZMix+JkqsdU= +buf.build/gen/go/astria/execution-apis/protocolbuffers/go v1.36.2-00000000000000-1f40f333891d.1 h1:cRvRFDg3/KPgEB2+8/orNwCWBhZO0wVZKij4TTKBj9w= +buf.build/gen/go/astria/execution-apis/protocolbuffers/go v1.36.2-00000000000000-1f40f333891d.1/go.mod h1:oB3M+Fq9RgyUWGMqYk2FqRobQpdH1yZQZ9TYOoc4yIw= buf.build/gen/go/astria/primitives/protocolbuffers/go v1.35.1-20240911152449-eeebd3decdce.1 h1:kG4riHqlF9X6iZ1Oxs5/6ul6aue7MS+A6DK6HAchuTk= buf.build/gen/go/astria/primitives/protocolbuffers/go v1.35.1-20240911152449-eeebd3decdce.1/go.mod h1:n9L7X3VAj4od4VHf2ScJuHARUUQTSxJqtRHZk/7Ptt0= buf.build/gen/go/astria/primitives/protocolbuffers/go v1.35.2-00000000000000-2f2e9ce53f59.1 h1:C1bT0G1In6Z6tBERd1XqwDjdxTK+PatSOJYlVk5Is60= buf.build/gen/go/astria/primitives/protocolbuffers/go v1.35.2-00000000000000-2f2e9ce53f59.1/go.mod h1:I9FcB1oNqT1nI+ny0GD8gF9YrIYrHmczgNu6MTE9fAo= +buf.build/gen/go/astria/primitives/protocolbuffers/go v1.36.1-00000000000000-9a039a6ed8db.1 h1:v+RKpd5zE6rqOMA44OLRpDLPYlakjmddvmFFrKxzb48= +buf.build/gen/go/astria/primitives/protocolbuffers/go v1.36.1-00000000000000-9a039a6ed8db.1/go.mod h1:HnX2FkSKZuD3zPFBR+Q17WzloqvIbFd0pYE++or/x2Q= +buf.build/gen/go/astria/primitives/protocolbuffers/go v1.36.2-00000000000000-9a039a6ed8db.1 h1:inT/lOAbHunpGP9YLqtAQNssrxEIgH/OmxXNwbXjUqs= +buf.build/gen/go/astria/primitives/protocolbuffers/go v1.36.2-00000000000000-9a039a6ed8db.1/go.mod h1:Lk1TBSGhOGvbtj0lb7eTeq+Z4N86/67Ay+WWxbqhh6s= buf.build/gen/go/astria/sequencerblock-apis/protocolbuffers/go v1.35.1-20241017141511-71aab1871615.1 h1:hPMoxTiT7jJjnIbWqneBbL05VeVOTD9UeC/qdvzHL8g= buf.build/gen/go/astria/sequencerblock-apis/protocolbuffers/go v1.35.1-20241017141511-71aab1871615.1/go.mod h1:2uasRFMH+a3DaF34c1o+w7/YtYnoknmARyYpb9W2QIc= buf.build/gen/go/astria/sequencerblock-apis/protocolbuffers/go v1.35.2-00000000000000-0eda7df0ee38.1 h1:uJm/22xugluY5AL2NkIDbNEFBxzN6UcI8vts/bGEDBs= buf.build/gen/go/astria/sequencerblock-apis/protocolbuffers/go v1.35.2-00000000000000-0eda7df0ee38.1/go.mod h1:1Z9P18WNTOT+KvLlc0+2FkcBJ7l5eRUUFcnOxHmLeRA= +buf.build/gen/go/astria/sequencerblock-apis/protocolbuffers/go v1.36.1-00000000000000-e54e1c9ad405.1 h1:querphz/TCGphT0qGG4DJo6p8qAsfL5/8SEBgfemVhk= +buf.build/gen/go/astria/sequencerblock-apis/protocolbuffers/go v1.36.1-00000000000000-e54e1c9ad405.1/go.mod h1:D6ou7OxkQXmiZDDNNrT147dA9wC9rhJPchCIfVbw9wM= +buf.build/gen/go/astria/sequencerblock-apis/protocolbuffers/go v1.36.2-00000000000000-e54e1c9ad405.1 h1:n2embOKwJS+YIyjHRDvOAo7c/kuv3fw9U+gQ/g2Yis8= +buf.build/gen/go/astria/sequencerblock-apis/protocolbuffers/go v1.36.2-00000000000000-e54e1c9ad405.1/go.mod h1:dHPKfn7RW6FSo7EkD0LqPhZUmRm5NXMB+tWvTrTnZTQ= cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= @@ -923,6 +937,10 @@ google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFyt google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= google.golang.org/protobuf v1.35.2 h1:8Ar7bF+apOIoThw1EdZl0p1oWvMqTHmpA2fRTyZO8io= google.golang.org/protobuf v1.35.2/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= +google.golang.org/protobuf v1.36.1 h1:yBPeRvTftaleIgM3PZ/WBIZ7XM/eEYAaEyCwvyjq/gk= +google.golang.org/protobuf v1.36.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= +google.golang.org/protobuf v1.36.2 h1:R8FeyR1/eLmkutZOM5CWghmo5itiG9z0ktFlTVLuTmU= +google.golang.org/protobuf v1.36.2/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/grpc/optimistic/server.go b/grpc/optimistic/server.go index 4d229c9f6..52cf8116c 100644 --- a/grpc/optimistic/server.go +++ b/grpc/optimistic/server.go @@ -1,8 +1,8 @@ package optimistic import ( - optimisticGrpc "buf.build/gen/go/astria/execution-apis/grpc/go/astria/bundle/v1alpha1/bundlev1alpha1grpc" - optimsticPb "buf.build/gen/go/astria/execution-apis/protocolbuffers/go/astria/bundle/v1alpha1" + optimisticGrpc "buf.build/gen/go/astria/execution-apis/grpc/go/astria/auction/v1alpha1/auctionv1alpha1grpc" + optimsticPb "buf.build/gen/go/astria/execution-apis/protocolbuffers/go/astria/auction/v1alpha1" astriaPb "buf.build/gen/go/astria/execution-apis/protocolbuffers/go/astria/execution/v1" "context" "errors" @@ -28,7 +28,7 @@ import ( type OptimisticServiceV1Alpha1 struct { optimisticGrpc.UnimplementedOptimisticExecutionServiceServer - optimisticGrpc.UnimplementedBundleServiceServer + optimisticGrpc.UnimplementedAuctionServiceServer sharedServiceContainer *shared.SharedServiceContainer @@ -54,8 +54,8 @@ func NewOptimisticServiceV1Alpha(sharedServiceContainer *shared.SharedServiceCon return optimisticService } -func (o *OptimisticServiceV1Alpha1) GetBundleStream(_ *optimsticPb.GetBundleStreamRequest, stream optimisticGrpc.BundleService_GetBundleStreamServer) error { - log.Debug("GetBundleStream called") +func (o *OptimisticServiceV1Alpha1) GetBidStream(_ *optimsticPb.GetBidStreamRequest, stream optimisticGrpc.AuctionService_GetBidStreamServer) error { + log.Debug("GetBidStream called") pendingTxEventCh := make(chan core.NewTxsEvent) pendingTxEvent := o.Eth().TxPool().SubscribeTransactions(pendingTxEventCh, false) @@ -69,7 +69,7 @@ func (o *OptimisticServiceV1Alpha1) GetBundleStream(_ *optimsticPb.GetBundleStre optimisticBlock := o.Eth().BlockChain().CurrentOptimisticBlock() for _, pendingTx := range pendingTxs.Txs { - bundle := optimsticPb.Bundle{} + bid := optimsticPb.Bid{} totalCost := big.NewInt(0) effectiveTip := cmath.BigMin(pendingTx.GasTipCap(), new(big.Int).Sub(pendingTx.GasFeeCap(), optimisticBlock.BaseFee)) @@ -82,16 +82,16 @@ func (o *OptimisticServiceV1Alpha1) GetBundleStream(_ *optimsticPb.GetBundleStre } marshalledTxs = append(marshalledTxs, marshalledTx) - bundle.Fee = totalCost.Uint64() - bundle.Transactions = marshalledTxs - bundle.BaseSequencerBlockHash = *o.currentOptimisticSequencerBlock.Load() - bundle.PrevRollupBlockHash = optimisticBlock.Hash().Bytes() + bid.Fee = totalCost.Uint64() + bid.Transactions = marshalledTxs + bid.SequencerParentBlockHash = *o.currentOptimisticSequencerBlock.Load() + bid.RollupParentBlockHash = optimisticBlock.Hash().Bytes() txsStreamedCount.Inc(1) - err = stream.Send(&optimsticPb.GetBundleStreamResponse{Bundle: &bundle}) + err = stream.Send(&optimsticPb.GetBidStreamResponse{Bid: &bid}) if err != nil { - log.Error("error sending bundle over stream", "err", err) - return status.Error(codes.Internal, shared.WrapError(err, "error sending bundle over stream").Error()) + log.Error("error sending bid over stream", "err", err) + return status.Error(codes.Internal, shared.WrapError(err, "error sending bid over stream").Error()) } } diff --git a/grpc/optimistic/server_test.go b/grpc/optimistic/server_test.go index b0dd97720..538b0433b 100644 --- a/grpc/optimistic/server_test.go +++ b/grpc/optimistic/server_test.go @@ -1,7 +1,7 @@ package optimistic import ( - optimsticPb "buf.build/gen/go/astria/execution-apis/protocolbuffers/go/astria/bundle/v1alpha1" + optimsticPb "buf.build/gen/go/astria/execution-apis/protocolbuffers/go/astria/auction/v1alpha1" astriaPb "buf.build/gen/go/astria/execution-apis/protocolbuffers/go/astria/execution/v1" primitivev1 "buf.build/gen/go/astria/primitives/protocolbuffers/go/astria/primitive/v1" sequencerblockv1 "buf.build/gen/go/astria/sequencerblock-apis/protocolbuffers/go/astria/sequencerblock/v1" @@ -193,7 +193,7 @@ func TestOptimisticServiceServerV1Alpha1_ExecuteOptimisticBlock(t *testing.T) { } } -func TestNewOptimisticServiceServerV1Alpha_StreamBundles(t *testing.T) { +func TestNewOptimisticServiceServerV1Alpha_StreamBids(t *testing.T) { ethservice, sharedService, _, _ := shared.SetupSharedService(t, 10) optimisticServiceV1Alpha1 := SetupOptimisticService(t, sharedService) @@ -286,13 +286,13 @@ func TestNewOptimisticServiceServerV1Alpha_StreamBundles(t *testing.T) { require.Equal(t, pending, 0, "Mempool should have 0 pending txs") require.Equal(t, queued, 0, "Mempool should have 0 queued txs") - mockServerSideStreaming := MockServerSideStreaming[optimsticPb.GetBundleStreamResponse]{ - sentResponses: []*optimsticPb.GetBundleStreamResponse{}, + mockServerSideStreaming := MockServerSideStreaming[optimsticPb.GetBidStreamResponse]{ + sentResponses: []*optimsticPb.GetBidStreamResponse{}, } errorCh = make(chan error) go func() { - errorCh <- optimisticServiceV1Alpha1.GetBundleStream(&optimsticPb.GetBundleStreamRequest{}, &mockServerSideStreaming) + errorCh <- optimisticServiceV1Alpha1.GetBidStream(&optimsticPb.GetBidStreamRequest{}, &mockServerSideStreaming) }() stateDb, err := ethservice.BlockChain().StateAt(currentOptimisticBlock.Root) @@ -341,19 +341,19 @@ func TestNewOptimisticServiceServerV1Alpha_StreamBundles(t *testing.T) { txIndx := 0 for _, resp := range mockServerSideStreaming.sentResponses { - bundle := resp.GetBundle() + bid := resp.GetBid() - require.Len(t, bundle.Transactions, 1, "Bundle should have 1 tx") + require.Len(t, bid.Transactions, 1, "Bid should have 1 tx") - receivedTx := bundle.Transactions[0] + receivedTx := bid.Transactions[0] sentTx := txs[txIndx] marshalledSentTx, err := sentTx.MarshalBinary() require.Nil(t, err, "Failed to marshal tx") require.True(t, bytes.Equal(receivedTx, marshalledSentTx), "Received tx does not match sent tx") txIndx += 1 - require.True(t, bytes.Equal(bundle.PrevRollupBlockHash, currentOptimisticBlock.Hash().Bytes()), "PrevRollupBlockHash should match the current optimistic block hash") - require.True(t, bytes.Equal(bundle.BaseSequencerBlockHash, *optimisticServiceV1Alpha1.currentOptimisticSequencerBlock.Load()), "BaseSequencerBlockHash should match the current optimistic sequencer block hash") + require.True(t, bytes.Equal(bid.RollupParentBlockHash, currentOptimisticBlock.Hash().Bytes()), "PrevRollupBlockHash should match the current optimistic block hash") + require.True(t, bytes.Equal(bid.SequencerParentBlockHash, *optimisticServiceV1Alpha1.currentOptimisticSequencerBlock.Load()), "BaseSequencerBlockHash should match the current optimistic sequencer block hash") } } diff --git a/grpc/optimistic/validation.go b/grpc/optimistic/validation.go index a59420d73..cbd6c62e6 100644 --- a/grpc/optimistic/validation.go +++ b/grpc/optimistic/validation.go @@ -1,7 +1,7 @@ package optimistic import ( - optimsticPb "buf.build/gen/go/astria/execution-apis/protocolbuffers/go/astria/bundle/v1alpha1" + optimsticPb "buf.build/gen/go/astria/execution-apis/protocolbuffers/go/astria/auction/v1alpha1" "fmt" ) diff --git a/grpc/shared/validation.go b/grpc/shared/validation.go index f7464f8d3..c90cadee7 100644 --- a/grpc/shared/validation.go +++ b/grpc/shared/validation.go @@ -1,7 +1,7 @@ package shared import ( - bundlev1alpha1 "buf.build/gen/go/astria/execution-apis/protocolbuffers/go/astria/bundle/v1alpha1" + auctionv1alpha1 "buf.build/gen/go/astria/execution-apis/protocolbuffers/go/astria/auction/v1alpha1" primitivev1 "buf.build/gen/go/astria/primitives/protocolbuffers/go/astria/primitive/v1" sequencerblockv1 "buf.build/gen/go/astria/sequencerblock-apis/protocolbuffers/go/astria/sequencerblock/v1" "bytes" @@ -128,7 +128,7 @@ func validateAndUnmarshallSequenceAction(tx *sequencerblockv1.RollupData) (*type return ethTx, nil } -func unmarshallAllocationTxs(allocation *bundlev1alpha1.Allocation, prevBlockHash []byte, auctioneerBech32Address string, addressPrefix string) (types.Transactions, error) { +func unmarshallAllocationTxs(allocation *auctionv1alpha1.Allocation, prevBlockHash []byte, auctioneerBech32Address string, addressPrefix string) (types.Transactions, error) { unbundlingStart := time.Now() defer allocationUnbundlingTimer.UpdateSince(unbundlingStart) @@ -137,7 +137,7 @@ func unmarshallAllocationTxs(allocation *bundlev1alpha1.Allocation, prevBlockHas log.Debug("Found a potential allocation in the rollup data. Checking if it is valid.", "prevBlockHash", common.BytesToHash(prevBlockHash).String(), "auctioneerBech32Address", auctioneerBech32Address) - if !bytes.Equal(payload.GetPrevRollupBlockHash(), prevBlockHash) { + if !bytes.Equal(payload.GetRollupParentBlockHash(), prevBlockHash) { allocationsWithInvalidPrevBlockHash.Inc(1) return nil, errors.New("prev block hash in allocation does not match the previous block hash") } @@ -164,8 +164,8 @@ func unmarshallAllocationTxs(allocation *bundlev1alpha1.Allocation, prevBlockHas return nil, fmt.Errorf("signature in allocation does not match the public key") } - log.Debug("Allocation is valid. Unmarshalling the transactions in the bundle.") - // unmarshall the transactions in the bundle + log.Debug("Allocation is valid. Unmarshalling the transactions in the bid.") + // unmarshall the transactions in the bid for _, allocationTx := range payload.GetTransactions() { ethtx := new(types.Transaction) err := ethtx.UnmarshalBinary(allocationTx) @@ -188,8 +188,8 @@ func UnbundleRollupDataTransactions(txs []*sequencerblockv1.RollupData, height u processedTxs := types.Transactions{} allocationTxs := types.Transactions{} - // we just return the allocation here and do not unmarshall the transactions in the bundle if we find it - var allocation *bundlev1alpha1.Allocation + // we just return the allocation here and do not unmarshall the transactions in the bid if we find it + var allocation *auctionv1alpha1.Allocation for _, tx := range txs { if deposit := tx.GetDeposit(); deposit != nil { depositTx, err := validateAndUnmarshalDepositTx(deposit, height, bridgeAddresses, bridgeAllowedAssets) @@ -204,7 +204,7 @@ func UnbundleRollupDataTransactions(txs []*sequencerblockv1.RollupData, height u // check if sequence data is of type Allocation if allocation == nil { // TODO - check if we can avoid a temp value - tempAllocation := &bundlev1alpha1.Allocation{} + tempAllocation := &auctionv1alpha1.Allocation{} err := proto.Unmarshal(sequenceData, tempAllocation) if err == nil { unmarshalledAllocationTxs, err := unmarshallAllocationTxs(tempAllocation, prevBlockHash, auctioneerBech32Address, addressPrefix) diff --git a/grpc/shared/validation_test.go b/grpc/shared/validation_test.go index 4bf274090..3ae96a2e4 100644 --- a/grpc/shared/validation_test.go +++ b/grpc/shared/validation_test.go @@ -1,7 +1,7 @@ package shared import ( - bundlev1alpha1 "buf.build/gen/go/astria/execution-apis/protocolbuffers/go/astria/bundle/v1alpha1" + bidv1alpha1 "buf.build/gen/go/astria/execution-apis/protocolbuffers/go/astria/auction/v1alpha1" "bytes" "crypto/ecdsa" "crypto/ed25519" @@ -88,11 +88,11 @@ func TestUnmarshallAllocationTxs(t *testing.T) { validMarshalledTx3, err := tx3.MarshalBinary() require.NoError(t, err, "failed to marshal valid tx: %v", err) - validPayload := &bundlev1alpha1.Bundle{ - Fee: 100, - Transactions: [][]byte{validMarshalledTx1, validMarshalledTx2, validMarshalledTx3}, - BaseSequencerBlockHash: []byte("sequencer block hash"), - PrevRollupBlockHash: []byte("prev rollup block hash"), + validPayload := &bidv1alpha1.Bid{ + Fee: 100, + Transactions: [][]byte{validMarshalledTx1, validMarshalledTx2, validMarshalledTx3}, + SequencerParentBlockHash: []byte("sequencer block hash"), + RollupParentBlockHash: []byte("prev rollup block hash"), } marshalledAllocation, err := proto.Marshal(validPayload) @@ -106,7 +106,7 @@ func TestUnmarshallAllocationTxs(t *testing.T) { tests := []struct { description string - allocation *bundlev1alpha1.Allocation + allocation *bidv1alpha1.Allocation prevBlockHash []byte expectedOutput types.Transactions // just check if error contains the string since error contains other details @@ -114,15 +114,15 @@ func TestUnmarshallAllocationTxs(t *testing.T) { }{ { description: "previous block hash mismatch", - allocation: &bundlev1alpha1.Allocation{ + allocation: &bidv1alpha1.Allocation{ // TODO - add signature and public key validation Signature: make([]byte, 0), PublicKey: make([]byte, 0), - Payload: &bundlev1alpha1.Bundle{ - Fee: 100, - Transactions: [][]byte{[]byte("unmarshallable tx")}, - BaseSequencerBlockHash: []byte("sequencer block hash"), - PrevRollupBlockHash: []byte("prev rollup block hash"), + Payload: &bidv1alpha1.Bid{ + Fee: 100, + Transactions: [][]byte{[]byte("unmarshallable tx")}, + SequencerParentBlockHash: []byte("sequencer block hash"), + RollupParentBlockHash: []byte("prev rollup block hash"), }, }, prevBlockHash: []byte("not prev rollup block hash"), @@ -131,14 +131,14 @@ func TestUnmarshallAllocationTxs(t *testing.T) { }, { description: "public key doesn't match", - allocation: &bundlev1alpha1.Allocation{ + allocation: &bidv1alpha1.Allocation{ Signature: []byte("invalid signature"), PublicKey: []byte("invalid public key"), - Payload: &bundlev1alpha1.Bundle{ - Fee: 100, - Transactions: [][]byte{[]byte("unmarshallable tx")}, - BaseSequencerBlockHash: []byte("sequencer block hash"), - PrevRollupBlockHash: []byte("prev rollup block hash"), + Payload: &bidv1alpha1.Bid{ + Fee: 100, + Transactions: [][]byte{[]byte("unmarshallable tx")}, + SequencerParentBlockHash: []byte("sequencer block hash"), + RollupParentBlockHash: []byte("prev rollup block hash"), }, }, prevBlockHash: []byte("prev rollup block hash"), @@ -147,14 +147,14 @@ func TestUnmarshallAllocationTxs(t *testing.T) { }, { description: "invalid signature", - allocation: &bundlev1alpha1.Allocation{ + allocation: &bidv1alpha1.Allocation{ Signature: []byte("invalid signature"), PublicKey: auctioneerPubKey, - Payload: &bundlev1alpha1.Bundle{ - Fee: 100, - Transactions: [][]byte{[]byte("unmarshallable tx")}, - BaseSequencerBlockHash: []byte("sequencer block hash"), - PrevRollupBlockHash: []byte("prev rollup block hash"), + Payload: &bidv1alpha1.Bid{ + Fee: 100, + Transactions: [][]byte{[]byte("unmarshallable tx")}, + SequencerParentBlockHash: []byte("sequencer block hash"), + RollupParentBlockHash: []byte("prev rollup block hash"), }, }, prevBlockHash: []byte("prev rollup block hash"), @@ -163,7 +163,7 @@ func TestUnmarshallAllocationTxs(t *testing.T) { }, { description: "valid allocation", - allocation: &bundlev1alpha1.Allocation{ + allocation: &bidv1alpha1.Allocation{ Signature: signedAllocation, PublicKey: auctioneerPubKey, Payload: validPayload, @@ -394,11 +394,11 @@ func TestUnbundleRollupData(t *testing.T) { validMarshalledTx5, err := tx5.MarshalBinary() require.NoError(t, err, "failed to marshal valid tx: %v", err) - payload := &bundlev1alpha1.Bundle{ - Fee: 100, - Transactions: [][]byte{validMarshalledTx1, validMarshalledTx2, validMarshalledTx3}, - BaseSequencerBlockHash: baseSequencerBlockHash, - PrevRollupBlockHash: prevRollupBlockHash, + payload := &bidv1alpha1.Bid{ + Fee: 100, + Transactions: [][]byte{validMarshalledTx1, validMarshalledTx2, validMarshalledTx3}, + SequencerParentBlockHash: baseSequencerBlockHash, + RollupParentBlockHash: prevRollupBlockHash, } marshalledPayload, err := proto.Marshal(payload) @@ -409,7 +409,7 @@ func TestUnbundleRollupData(t *testing.T) { }) require.NoError(t, err, "failed to sign payload: %v", err) - allocation := &bundlev1alpha1.Allocation{ + allocation := &bidv1alpha1.Allocation{ Signature: signedPayload, PublicKey: auctioneerPubKey, Payload: payload, @@ -492,11 +492,11 @@ func TestUnbundleRollupDataWithDuplicateAllocations(t *testing.T) { validMarshalledTx5, err := tx5.MarshalBinary() require.NoError(t, err, "failed to marshal valid tx: %v", err) - payload := &bundlev1alpha1.Bundle{ - Fee: 100, - Transactions: [][]byte{validMarshalledTx1, validMarshalledTx2, validMarshalledTx3}, - BaseSequencerBlockHash: baseSequencerBlockHash, - PrevRollupBlockHash: prevRollupBlockHash, + payload := &bidv1alpha1.Bid{ + Fee: 100, + Transactions: [][]byte{validMarshalledTx1, validMarshalledTx2, validMarshalledTx3}, + SequencerParentBlockHash: baseSequencerBlockHash, + RollupParentBlockHash: prevRollupBlockHash, } marshalledPayload, err := proto.Marshal(payload) @@ -507,7 +507,7 @@ func TestUnbundleRollupDataWithDuplicateAllocations(t *testing.T) { }) require.NoError(t, err, "failed to sign payload: %v", err) - allocation := &bundlev1alpha1.Allocation{ + allocation := &bidv1alpha1.Allocation{ Signature: signedPayload, PublicKey: auctioneerPubKey, Payload: payload, @@ -607,11 +607,11 @@ func TestUnbundleRollupDataWithDuplicateInvalidAllocations(t *testing.T) { invalidMarshalledTx2, err := invalidTx2.MarshalBinary() require.NoError(t, err, "failed to marshal valid tx: %v", err) - payload := &bundlev1alpha1.Bundle{ - Fee: 100, - Transactions: [][]byte{validMarshalledTx1, validMarshalledTx2, validMarshalledTx3}, - BaseSequencerBlockHash: baseSequencerBlockHash, - PrevRollupBlockHash: prevRollupBlockHash, + payload := &bidv1alpha1.Bid{ + Fee: 100, + Transactions: [][]byte{validMarshalledTx1, validMarshalledTx2, validMarshalledTx3}, + SequencerParentBlockHash: baseSequencerBlockHash, + RollupParentBlockHash: prevRollupBlockHash, } marshalledPayload, err := proto.Marshal(payload) @@ -622,11 +622,11 @@ func TestUnbundleRollupDataWithDuplicateInvalidAllocations(t *testing.T) { }) require.NoError(t, err, "failed to sign allocation: %v", err) - invalidPayload := &bundlev1alpha1.Bundle{ - Fee: 100, - Transactions: [][]byte{invalidMarshalledTx1, invalidMarshalledTx2}, - BaseSequencerBlockHash: baseSequencerBlockHash, - PrevRollupBlockHash: prevRollupBlockHash, + invalidPayload := &bidv1alpha1.Bid{ + Fee: 100, + Transactions: [][]byte{invalidMarshalledTx1, invalidMarshalledTx2}, + SequencerParentBlockHash: baseSequencerBlockHash, + RollupParentBlockHash: prevRollupBlockHash, } marshalledInvalidPayload, err := proto.Marshal(invalidPayload) require.NoError(t, err, "failed to marshal invalid allocation: %v", err) @@ -637,7 +637,7 @@ func TestUnbundleRollupDataWithDuplicateInvalidAllocations(t *testing.T) { }) require.NoError(t, err, "failed to sign allocation: %v", err) - allocation := &bundlev1alpha1.Allocation{ + allocation := &bidv1alpha1.Allocation{ Signature: signedPayload, PublicKey: auctioneerPubKey, Payload: payload, @@ -646,7 +646,7 @@ func TestUnbundleRollupDataWithDuplicateInvalidAllocations(t *testing.T) { marshalledAllocation, err := proto.Marshal(allocation) require.NoError(t, err, "failed to marshal allocation: %v", err) - invalidAllocation := &bundlev1alpha1.Allocation{ + invalidAllocation := &bidv1alpha1.Allocation{ Signature: signedInvalidPayload, // trying to spoof the actual auctioneer key PublicKey: auctioneerPubKey, diff --git a/node/grpcstack.go b/node/grpcstack.go index b3a34c2ca..15000f9ab 100644 --- a/node/grpcstack.go +++ b/node/grpcstack.go @@ -1,7 +1,7 @@ package node import ( - optimisticGrpc "buf.build/gen/go/astria/execution-apis/grpc/go/astria/bundle/v1alpha1/bundlev1alpha1grpc" + optimisticGrpc "buf.build/gen/go/astria/execution-apis/grpc/go/astria/auction/v1alpha1/auctionv1alpha1grpc" "net" "sync" @@ -19,7 +19,7 @@ type GRPCServerHandler struct { execServer *grpc.Server executionServiceServerV1a2 *astriaGrpc.ExecutionServiceServer optimisticExecServ *optimisticGrpc.OptimisticExecutionServiceServer - streamBundleServ *optimisticGrpc.BundleServiceServer + auctionServiceServ *optimisticGrpc.AuctionServiceServer enableAuctioneer bool } @@ -27,7 +27,7 @@ type GRPCServerHandler struct { // NewServer creates a new gRPC server. // It registers the execution service server. // It registers the gRPC server with the node so it can be stopped on shutdown. -func NewGRPCServerHandler(node *Node, execServ astriaGrpc.ExecutionServiceServer, optimisticExecServ optimisticGrpc.OptimisticExecutionServiceServer, streamBundleServ optimisticGrpc.BundleServiceServer, cfg *Config) error { +func NewGRPCServerHandler(node *Node, execServ astriaGrpc.ExecutionServiceServer, optimisticExecServ optimisticGrpc.OptimisticExecutionServiceServer, auctionServiceServ optimisticGrpc.AuctionServiceServer, cfg *Config) error { execServer := grpc.NewServer() log.Info("gRPC server enabled", "endpoint", cfg.GRPCEndpoint()) @@ -37,14 +37,14 @@ func NewGRPCServerHandler(node *Node, execServ astriaGrpc.ExecutionServiceServer execServer: execServer, executionServiceServerV1a2: &execServ, optimisticExecServ: &optimisticExecServ, - streamBundleServ: &streamBundleServ, + auctionServiceServ: &auctionServiceServ, enableAuctioneer: cfg.EnableAuctioneer, } astriaGrpc.RegisterExecutionServiceServer(execServer, execServ) if cfg.EnableAuctioneer { optimisticGrpc.RegisterOptimisticExecutionServiceServer(execServer, optimisticExecServ) - optimisticGrpc.RegisterBundleServiceServer(execServer, streamBundleServ) + optimisticGrpc.RegisterAuctionServiceServer(execServer, auctionServiceServ) } node.RegisterGRPCServer(serverHandler)