From 5c2ebec369110b40c9a13e39a555d2154af23fb9 Mon Sep 17 00:00:00 2001 From: terence tsao Date: Sat, 20 Aug 2022 13:04:44 -0700 Subject: [PATCH] Can build --- beacon-chain/blockchain/BUILD.bazel | 1 + beacon-chain/blockchain/process_block.go | 1 + beacon-chain/node/BUILD.bazel | 1 + beacon-chain/node/node.go | 1 + beacon-chain/rpc/eth/beacon/blocks.go | 5 ++-- beacon-chain/sync/initial-sync/BUILD.bazel | 2 ++ .../sync/initial-sync/blocks_fetcher.go | 25 +++++++++++-------- .../sync/initial-sync/blocks_queue.go | 3 ++- beacon-chain/sync/rpc_chunked_response.go | 4 +-- beacon-chain/sync/subscriber_beacon_blocks.go | 2 +- beacon-chain/sync/validate_beacon_blocks.go | 3 ++- go.sum | 4 --- .../eth/service/beacon_chain_service.pb.gw.go | 1 - .../eth/service/beacon_debug_service.pb.gw.go | 1 - proto/eth/service/validator_service.pb.gw.go | 1 - 15 files changed, 30 insertions(+), 25 deletions(-) diff --git a/beacon-chain/blockchain/BUILD.bazel b/beacon-chain/blockchain/BUILD.bazel index 95c1761e80d9..49756698eb05 100644 --- a/beacon-chain/blockchain/BUILD.bazel +++ b/beacon-chain/blockchain/BUILD.bazel @@ -62,6 +62,7 @@ go_library( "//config/features:go_default_library", "//config/fieldparams:go_default_library", "//config/params:go_default_library", + "//consensus-types/blobs:go_default_library", "//consensus-types/blocks:go_default_library", "//consensus-types/interfaces:go_default_library", "//consensus-types/primitives:go_default_library", diff --git a/beacon-chain/blockchain/process_block.go b/beacon-chain/blockchain/process_block.go index 980ebb901011..b12c3a0bbe62 100644 --- a/beacon-chain/blockchain/process_block.go +++ b/beacon-chain/blockchain/process_block.go @@ -17,6 +17,7 @@ import ( "github.com/prysmaticlabs/prysm/v3/beacon-chain/state" "github.com/prysmaticlabs/prysm/v3/config/features" "github.com/prysmaticlabs/prysm/v3/config/params" + "github.com/prysmaticlabs/prysm/v3/consensus-types/blobs" consensusblocks "github.com/prysmaticlabs/prysm/v3/consensus-types/blocks" "github.com/prysmaticlabs/prysm/v3/consensus-types/interfaces" types "github.com/prysmaticlabs/prysm/v3/consensus-types/primitives" diff --git a/beacon-chain/node/BUILD.bazel b/beacon-chain/node/BUILD.bazel index bff6d8c61fff..1bbbc8fa798e 100644 --- a/beacon-chain/node/BUILD.bazel +++ b/beacon-chain/node/BUILD.bazel @@ -16,6 +16,7 @@ go_library( ], deps = [ "//api/gateway:go_default_library", + "//async:go_default_library", "//async/event:go_default_library", "//beacon-chain/blockchain:go_default_library", "//beacon-chain/builder:go_default_library", diff --git a/beacon-chain/node/node.go b/beacon-chain/node/node.go index 109cb4ffc7c0..1c7325af8467 100644 --- a/beacon-chain/node/node.go +++ b/beacon-chain/node/node.go @@ -19,6 +19,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/pkg/errors" apigateway "github.com/prysmaticlabs/prysm/v3/api/gateway" + "github.com/prysmaticlabs/prysm/v3/async" "github.com/prysmaticlabs/prysm/v3/async/event" "github.com/prysmaticlabs/prysm/v3/beacon-chain/blockchain" "github.com/prysmaticlabs/prysm/v3/beacon-chain/builder" diff --git a/beacon-chain/rpc/eth/beacon/blocks.go b/beacon-chain/rpc/eth/beacon/blocks.go index 5c560138d298..e379bcef41da 100644 --- a/beacon-chain/rpc/eth/beacon/blocks.go +++ b/beacon-chain/rpc/eth/beacon/blocks.go @@ -23,6 +23,7 @@ import ( ethpbv1 "github.com/prysmaticlabs/prysm/v3/proto/eth/v1" ethpbv2 "github.com/prysmaticlabs/prysm/v3/proto/eth/v2" "github.com/prysmaticlabs/prysm/v3/proto/migration" + ethpb "github.com/prysmaticlabs/prysm/v3/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/v3/time/slots" "go.opencensus.io/trace" "google.golang.org/grpc/codes" @@ -535,8 +536,8 @@ func (bs *Server) GetBlockV2(ctx context.Context, req *ethpbv2.BlockRequestV2) ( } return ðpbv2.BlockResponseV2{ Version: ethpbv2.Version_EIP4844, - Data: ðpbv2.SignedBeaconBlockContainerV2{ - Message: ðpbv2.SignedBeaconBlockContainerV2_Eip4844Block{Eip4844Block: v2Blk}, + Data: ðpbv2.SignedBeaconBlockContainer{ + Message: ðpbv2.SignedBeaconBlockContainer_Eip4844Block{Eip4844Block: v2Blk}, Signature: blk.Signature(), }, ExecutionOptimistic: isOptimistic, diff --git a/beacon-chain/sync/initial-sync/BUILD.bazel b/beacon-chain/sync/initial-sync/BUILD.bazel index febdbe55f908..d5accdc50684 100644 --- a/beacon-chain/sync/initial-sync/BUILD.bazel +++ b/beacon-chain/sync/initial-sync/BUILD.bazel @@ -29,6 +29,8 @@ go_library( "//beacon-chain/sync:go_default_library", "//cmd/beacon-chain/flags:go_default_library", "//config/params:go_default_library", + "//consensus-types/blobs:go_default_library", + "//consensus-types/blocks:go_default_library", "//consensus-types/interfaces:go_default_library", "//consensus-types/primitives:go_default_library", "//crypto/rand:go_default_library", diff --git a/beacon-chain/sync/initial-sync/blocks_fetcher.go b/beacon-chain/sync/initial-sync/blocks_fetcher.go index 4153827c0f89..341cecb99646 100644 --- a/beacon-chain/sync/initial-sync/blocks_fetcher.go +++ b/beacon-chain/sync/initial-sync/blocks_fetcher.go @@ -15,9 +15,12 @@ import ( prysmsync "github.com/prysmaticlabs/prysm/v3/beacon-chain/sync" "github.com/prysmaticlabs/prysm/v3/cmd/beacon-chain/flags" "github.com/prysmaticlabs/prysm/v3/config/params" + "github.com/prysmaticlabs/prysm/v3/consensus-types/blobs" + "github.com/prysmaticlabs/prysm/v3/consensus-types/blocks" "github.com/prysmaticlabs/prysm/v3/consensus-types/interfaces" types "github.com/prysmaticlabs/prysm/v3/consensus-types/primitives" "github.com/prysmaticlabs/prysm/v3/crypto/rand" + "github.com/prysmaticlabs/prysm/v3/encoding/bytesutil" p2ppb "github.com/prysmaticlabs/prysm/v3/proto/prysm/v1alpha1" "github.com/sirupsen/logrus" "go.opencensus.io/trace" @@ -107,7 +110,7 @@ type fetchRequestResponse struct { start types.Slot count uint64 blocks []interfaces.SignedBeaconBlock - sidecars []*ethpb.BlobsSidecar + sidecars []*p2ppb.BlobsSidecar err error } @@ -249,7 +252,7 @@ func (f *blocksFetcher) handleRequest(ctx context.Context, start types.Slot, cou start: start, count: count, blocks: []interfaces.SignedBeaconBlock{}, - sidecars: []*ethpb.BlobsSidecar{}, + sidecars: []*p2ppb.BlobsSidecar{}, err: nil, } @@ -283,7 +286,7 @@ func (f *blocksFetcher) fetchBlocksFromPeer( ctx context.Context, start types.Slot, count uint64, peers []peer.ID, -) ([]interfaces.SignedBeaconBlock, []*ethpb.BlobsSidecar, peer.ID, error) { +) ([]interfaces.SignedBeaconBlock, []*p2ppb.BlobsSidecar, peer.ID, error) { ctx, span := trace.StartSpan(ctx, "initialsync.fetchBlocksFromPeer") defer span.End() @@ -298,7 +301,7 @@ func (f *blocksFetcher) fetchBlocksFromPeer( Count: count, } - var sidecars []*ethpb.BlobsSidecar + var sidecars []*p2ppb.BlobsSidecar for i := 0; i < len(peers); i++ { blocks, err := f.requestBlocks(ctx, req, peers[i]) if err == nil { @@ -387,7 +390,7 @@ func (f *blocksFetcher) requestSidecars( req *p2ppb.BlobsSidecarsByRangeRequest, pid peer.ID, blkRefs []interfaces.SignedBeaconBlock, -) ([]*ethpb.BlobsSidecar, error) { +) ([]*p2ppb.BlobsSidecar, error) { if ctx.Err() != nil { return nil, ctx.Err() } @@ -410,7 +413,7 @@ func (f *blocksFetcher) requestSidecars( f.rateLimiter.Add(pid.String(), int64(req.Count)) l.Unlock() - var sidecarProcessor func(*ethpb.BlobsSidecar) error + var sidecarProcessor func(*p2ppb.BlobsSidecar) error if blkRefs != nil { sidecarProcessor = sidecarVerifier(blkRefs) } @@ -431,9 +434,9 @@ func (f *blocksFetcher) waitForBandwidth(pid peer.ID) error { return nil } -func checkBlocksForAvailableSidecars(blks []interfaces.SignedBeaconBlock, sidecars []*ethpb.BlobsSidecar) error { +func checkBlocksForAvailableSidecars(blks []interfaces.SignedBeaconBlock, sidecars []*p2ppb.BlobsSidecar) error { for _, b := range blks { - if cb.IsPreEIP4844Version(b.Version()) { + if blocks.IsPreEIP4844Version(b.Version()) { continue } blobKzgs, err := b.Block().Body().BlobKzgs() @@ -461,10 +464,10 @@ func checkBlocksForAvailableSidecars(blks []interfaces.SignedBeaconBlock, sideca return nil } -func sidecarVerifier(blks []interfaces.SignedBeaconBlock) func(*ethpb.BlobsSidecar) error { - return func(sidecar *ethpb.BlobsSidecar) error { +func sidecarVerifier(blks []interfaces.SignedBeaconBlock) func(*p2ppb.BlobsSidecar) error { + return func(sidecar *p2ppb.BlobsSidecar) error { for _, b := range blks { - if cb.IsPreEIP4844Version(b.Version()) { + if blocks.IsPreEIP4844Version(b.Version()) { continue } blobKzgs, err := b.Block().Body().BlobKzgs() diff --git a/beacon-chain/sync/initial-sync/blocks_queue.go b/beacon-chain/sync/initial-sync/blocks_queue.go index 786723a49f0a..ea32ddc58ba5 100644 --- a/beacon-chain/sync/initial-sync/blocks_queue.go +++ b/beacon-chain/sync/initial-sync/blocks_queue.go @@ -6,6 +6,7 @@ import ( "time" "github.com/libp2p/go-libp2p-core/peer" + p2ppb "github.com/prysmaticlabs/prysm/v3/proto/prysm/v1alpha1" "github.com/prysmaticlabs/prysm/v3/beacon-chain/db" "github.com/prysmaticlabs/prysm/v3/beacon-chain/p2p" @@ -91,7 +92,7 @@ type blocksQueue struct { type blocksQueueFetchedData struct { pid peer.ID blocks []interfaces.SignedBeaconBlock - sidecars []*ethpb.BlobsSidecar + sidecars []*p2ppb.BlobsSidecar } // newBlocksQueue creates initialized priority queue. diff --git a/beacon-chain/sync/rpc_chunked_response.go b/beacon-chain/sync/rpc_chunked_response.go index eb42034b4ff4..6390518c2872 100644 --- a/beacon-chain/sync/rpc_chunked_response.go +++ b/beacon-chain/sync/rpc_chunked_response.go @@ -100,7 +100,7 @@ func WriteBlobsSidecarChunk(stream libp2pcore.Stream, chain blockchain.ChainInfo return err } -func ReadChunkedBlobsSidecar(stream libp2pcore.Stream, chain blockchain.ChainInfoFetcher, p2p p2p.P2P, isFirstChunk bool) (*pb.BlobsSidecar, error) { +func ReadChunkedBlobsSidecar(stream libp2pcore.Stream, chain blockchain.ChainInfoFetcher, p2p p2p.P2P, isFirstChunk bool) (*ethpb.BlobsSidecar, error) { var ( code uint8 errMsg string @@ -127,7 +127,7 @@ func ReadChunkedBlobsSidecar(stream libp2pcore.Stream, chain blockchain.ChainInf if len(rpcCtx) != 0 { return nil, errors.New("unexpected fork digest in stream") } - sidecar := new(pb.BlobsSidecar) + sidecar := new(ethpb.BlobsSidecar) err = p2p.Encoding().DecodeWithMaxLength(stream, sidecar) return sidecar, err } diff --git a/beacon-chain/sync/subscriber_beacon_blocks.go b/beacon-chain/sync/subscriber_beacon_blocks.go index f777d80bfdb2..4ac02df43c21 100644 --- a/beacon-chain/sync/subscriber_beacon_blocks.go +++ b/beacon-chain/sync/subscriber_beacon_blocks.go @@ -30,7 +30,7 @@ func (s *Service) beaconBlockSubscriber(ctx context.Context, msg proto.Message) return err } - var sidecar *eth.BlobsSidecar + var sidecar *ethpb.BlobsSidecar contains, err := blobs.BlockContainsKZGs(block) if err != nil { return err diff --git a/beacon-chain/sync/validate_beacon_blocks.go b/beacon-chain/sync/validate_beacon_blocks.go index c7863fd449ce..750c24d8cb44 100644 --- a/beacon-chain/sync/validate_beacon_blocks.go +++ b/beacon-chain/sync/validate_beacon_blocks.go @@ -23,6 +23,7 @@ import ( types "github.com/prysmaticlabs/prysm/v3/consensus-types/primitives" "github.com/prysmaticlabs/prysm/v3/encoding/bytesutil" "github.com/prysmaticlabs/prysm/v3/monitoring/tracing" + "github.com/prysmaticlabs/prysm/v3/runtime/version" prysmTime "github.com/prysmaticlabs/prysm/v3/time" "github.com/prysmaticlabs/prysm/v3/time/slots" "github.com/sirupsen/logrus" @@ -281,7 +282,7 @@ func (s *Service) validateEIP4844BeaconBlock(ctx context.Context, parentState st return errors.New("execution payload is nil") } - if b.IsPreEIP4844Version(blk.Version()) { + if consensusblocks.IsPreEIP4844Version(blk.Version()) { return nil } diff --git a/go.sum b/go.sum index a7566c850f98..3a2b26d4f201 100644 --- a/go.sum +++ b/go.sum @@ -1139,10 +1139,6 @@ github.com/prysmaticlabs/go-bitfield v0.0.0-20210108222456-8e92c3709aa0/go.mod h github.com/prysmaticlabs/go-bitfield v0.0.0-20210809151128-385d8c5e3fb7 h1:0tVE4tdWQK9ZpYygoV7+vS6QkDvQVySboMVEIxBJmXw= github.com/prysmaticlabs/go-bitfield v0.0.0-20210809151128-385d8c5e3fb7/go.mod h1:wmuf/mdK4VMD+jA9ThwcUKjg3a2XWM9cVfFYjDyY4j4= github.com/prysmaticlabs/gohashtree v0.0.0-20220517220438-192ee5ae6982/go.mod h1:4pWaT30XoEx1j8KNJf3TV+E3mQkaufn7mf+jRNb/Fuk= -github.com/prysmaticlabs/gohashtree v0.0.1-alpha.0.20220303211031-f753e083138c h1:920mmUNkTZ9zIWXjArGv6iU45b85gjUvq/4L1ZHWVYQ= -github.com/prysmaticlabs/gohashtree v0.0.1-alpha.0.20220303211031-f753e083138c/go.mod h1:4pWaT30XoEx1j8KNJf3TV+E3mQkaufn7mf+jRNb/Fuk= -github.com/prysmaticlabs/grpc-gateway/v2 v2.3.1-0.20220428175429-ee99f663f83d h1:X89lsbPFK9rUDa8mxXazgAT34jlXdCHZrn8kdptFbBU= -github.com/prysmaticlabs/grpc-gateway/v2 v2.3.1-0.20220428175429-ee99f663f83d/go.mod h1:IOyTYjcIO0rkmnGBfJTL0NJ11exy/Tc2QEuv7hCXp24= github.com/prysmaticlabs/gohashtree v0.0.2-alpha h1:hk5ZsDQuSkyUMhTd55qB396P1+dtyIKiSwMmYE/hyEU= github.com/prysmaticlabs/gohashtree v0.0.2-alpha/go.mod h1:4pWaT30XoEx1j8KNJf3TV+E3mQkaufn7mf+jRNb/Fuk= github.com/prysmaticlabs/grpc-gateway/v2 v2.3.1-0.20220721162526-0d1c40b5f064 h1:elSfkWAcpL94zg7B9J2ozu+WcbMxD1rZ3rzUjYAy6R8= diff --git a/proto/eth/service/beacon_chain_service.pb.gw.go b/proto/eth/service/beacon_chain_service.pb.gw.go index 6816dcfa2eca..411f9bd6c5ef 100755 --- a/proto/eth/service/beacon_chain_service.pb.gw.go +++ b/proto/eth/service/beacon_chain_service.pb.gw.go @@ -18,7 +18,6 @@ import ( "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" "github.com/grpc-ecosystem/grpc-gateway/v2/utilities" github_com_prysmaticlabs_prysm_v3_consensus_types_primitives "github.com/prysmaticlabs/prysm/v3/consensus-types/primitives" - "github.com/prysmaticlabs/prysm/v3/proto/eth/v1" v1 "github.com/prysmaticlabs/prysm/v3/proto/eth/v1" "github.com/prysmaticlabs/prysm/v3/proto/eth/v2" "google.golang.org/grpc" diff --git a/proto/eth/service/beacon_debug_service.pb.gw.go b/proto/eth/service/beacon_debug_service.pb.gw.go index a67197941383..92ee1da42744 100755 --- a/proto/eth/service/beacon_debug_service.pb.gw.go +++ b/proto/eth/service/beacon_debug_service.pb.gw.go @@ -18,7 +18,6 @@ import ( "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" "github.com/grpc-ecosystem/grpc-gateway/v2/utilities" github_com_prysmaticlabs_prysm_v3_consensus_types_primitives "github.com/prysmaticlabs/prysm/v3/consensus-types/primitives" - "github.com/prysmaticlabs/prysm/v3/proto/eth/v1" v1 "github.com/prysmaticlabs/prysm/v3/proto/eth/v1" "github.com/prysmaticlabs/prysm/v3/proto/eth/v2" "google.golang.org/grpc" diff --git a/proto/eth/service/validator_service.pb.gw.go b/proto/eth/service/validator_service.pb.gw.go index ca61014d141d..f7fe6315b0f8 100755 --- a/proto/eth/service/validator_service.pb.gw.go +++ b/proto/eth/service/validator_service.pb.gw.go @@ -18,7 +18,6 @@ import ( "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" "github.com/grpc-ecosystem/grpc-gateway/v2/utilities" github_com_prysmaticlabs_prysm_v3_consensus_types_primitives "github.com/prysmaticlabs/prysm/v3/consensus-types/primitives" - "github.com/prysmaticlabs/prysm/v3/proto/eth/v1" v1 "github.com/prysmaticlabs/prysm/v3/proto/eth/v1" "github.com/prysmaticlabs/prysm/v3/proto/eth/v2" "google.golang.org/grpc"