From d9596a847b1a82009c1a49723c9e7eeedfa829c1 Mon Sep 17 00:00:00 2001 From: alok Date: Wed, 4 Oct 2023 00:39:32 +0530 Subject: [PATCH 1/3] feat: add RPC api for searchers and initialize preconf --- buf.gen.yaml | 8 + cmd/main.go | 6 + gen/go/rpc/searcherapi/v1/searcherapi.pb.go | 279 ++++++++++++++++++ .../rpc/searcherapi/v1/searcherapi_grpc.pb.go | 136 +++++++++ go.mod | 10 +- go.sum | 8 +- pkg/node/node.go | 38 +++ pkg/preconfirmation/preconfirmation.go | 146 +++++---- pkg/preconfirmation/preconfirmation_test.go | 66 ++--- pkg/searcherapi/api.go | 67 +++++ pkg/topology/topology.go | 2 +- rpc/searcherapi/v1/buf.yaml | 7 + rpc/searcherapi/v1/searcherapi.proto | 23 ++ 13 files changed, 695 insertions(+), 101 deletions(-) create mode 100644 buf.gen.yaml create mode 100644 gen/go/rpc/searcherapi/v1/searcherapi.pb.go create mode 100644 gen/go/rpc/searcherapi/v1/searcherapi_grpc.pb.go create mode 100644 pkg/searcherapi/api.go create mode 100644 rpc/searcherapi/v1/buf.yaml create mode 100644 rpc/searcherapi/v1/searcherapi.proto diff --git a/buf.gen.yaml b/buf.gen.yaml new file mode 100644 index 00000000..70c08eeb --- /dev/null +++ b/buf.gen.yaml @@ -0,0 +1,8 @@ +version: v1 +plugins: + - plugin: buf.build/protocolbuffers/go:v1.31.0 + out: gen/go + opt: paths=source_relative + - plugin: buf.build/grpc/go + out: gen/go + opt: paths=source_relative diff --git a/cmd/main.go b/cmd/main.go index 5836f67f..72731a8f 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -16,6 +16,7 @@ import ( const ( defaultP2PPort = 13522 defaultHTTPPort = 13523 + defaultRPCPort = 13524 ) var ( @@ -88,6 +89,7 @@ type config struct { PeerType string `yaml:"peer_type" json:"peer_type"` P2PPort int `yaml:"p2p_port" json:"p2p_port"` HTTPPort int `yaml:"http_port" json:"http_port"` + RPCPort int `yaml:"rpc_port" json:"http_port"` LogFmt string `yaml:"log_fmt" json:"log_fmt"` LogLevel string `yaml:"log_level" json:"log_level"` Bootnodes []string `yaml:"bootnodes" json:"bootnodes"` @@ -114,6 +116,10 @@ func checkConfig(cfg *config) error { cfg.HTTPPort = defaultHTTPPort } + if cfg.RPCPort == 0 { + cfg.RPCPort = defaultRPCPort + } + if cfg.LogFmt == "" { cfg.LogFmt = "text" } diff --git a/gen/go/rpc/searcherapi/v1/searcherapi.pb.go b/gen/go/rpc/searcherapi/v1/searcherapi.pb.go new file mode 100644 index 00000000..7191a1b7 --- /dev/null +++ b/gen/go/rpc/searcherapi/v1/searcherapi.pb.go @@ -0,0 +1,279 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.31.0 +// protoc (unknown) +// source: rpc/searcherapi/v1/searcherapi.proto + +package searcherapiv1 + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type Bid struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + TxnHash string `protobuf:"bytes,1,opt,name=txn_hash,json=txnHash,proto3" json:"txn_hash,omitempty"` + BidAmt int64 `protobuf:"varint,2,opt,name=bid_amt,json=bidAmt,proto3" json:"bid_amt,omitempty"` + BlockNumber int64 `protobuf:"varint,3,opt,name=block_number,json=blockNumber,proto3" json:"block_number,omitempty"` +} + +func (x *Bid) Reset() { + *x = Bid{} + if protoimpl.UnsafeEnabled { + mi := &file_rpc_searcherapi_v1_searcherapi_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Bid) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Bid) ProtoMessage() {} + +func (x *Bid) ProtoReflect() protoreflect.Message { + mi := &file_rpc_searcherapi_v1_searcherapi_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Bid.ProtoReflect.Descriptor instead. +func (*Bid) Descriptor() ([]byte, []int) { + return file_rpc_searcherapi_v1_searcherapi_proto_rawDescGZIP(), []int{0} +} + +func (x *Bid) GetTxnHash() string { + if x != nil { + return x.TxnHash + } + return "" +} + +func (x *Bid) GetBidAmt() int64 { + if x != nil { + return x.BidAmt + } + return 0 +} + +func (x *Bid) GetBlockNumber() int64 { + if x != nil { + return x.BlockNumber + } + return 0 +} + +type Commitment struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Bid *Bid `protobuf:"bytes,1,opt,name=bid,proto3" json:"bid,omitempty"` + BidHash []byte `protobuf:"bytes,4,opt,name=bid_hash,json=bidHash,proto3" json:"bid_hash,omitempty"` + Signature []byte `protobuf:"bytes,5,opt,name=signature,proto3" json:"signature,omitempty"` + DataHash []byte `protobuf:"bytes,6,opt,name=data_hash,json=dataHash,proto3" json:"data_hash,omitempty"` + CommitmentSignature []byte `protobuf:"bytes,7,opt,name=commitment_signature,json=commitmentSignature,proto3" json:"commitment_signature,omitempty"` +} + +func (x *Commitment) Reset() { + *x = Commitment{} + if protoimpl.UnsafeEnabled { + mi := &file_rpc_searcherapi_v1_searcherapi_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Commitment) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Commitment) ProtoMessage() {} + +func (x *Commitment) ProtoReflect() protoreflect.Message { + mi := &file_rpc_searcherapi_v1_searcherapi_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Commitment.ProtoReflect.Descriptor instead. +func (*Commitment) Descriptor() ([]byte, []int) { + return file_rpc_searcherapi_v1_searcherapi_proto_rawDescGZIP(), []int{1} +} + +func (x *Commitment) GetBid() *Bid { + if x != nil { + return x.Bid + } + return nil +} + +func (x *Commitment) GetBidHash() []byte { + if x != nil { + return x.BidHash + } + return nil +} + +func (x *Commitment) GetSignature() []byte { + if x != nil { + return x.Signature + } + return nil +} + +func (x *Commitment) GetDataHash() []byte { + if x != nil { + return x.DataHash + } + return nil +} + +func (x *Commitment) GetCommitmentSignature() []byte { + if x != nil { + return x.CommitmentSignature + } + return nil +} + +var File_rpc_searcherapi_v1_searcherapi_proto protoreflect.FileDescriptor + +var file_rpc_searcherapi_v1_searcherapi_proto_rawDesc = []byte{ + 0x0a, 0x24, 0x72, 0x70, 0x63, 0x2f, 0x73, 0x65, 0x61, 0x72, 0x63, 0x68, 0x65, 0x72, 0x61, 0x70, + 0x69, 0x2f, 0x76, 0x31, 0x2f, 0x73, 0x65, 0x61, 0x72, 0x63, 0x68, 0x65, 0x72, 0x61, 0x70, 0x69, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x11, 0x72, 0x70, 0x63, 0x2e, 0x73, 0x65, 0x61, 0x63, + 0x68, 0x65, 0x72, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x22, 0x5c, 0x0a, 0x03, 0x42, 0x69, 0x64, + 0x12, 0x19, 0x0a, 0x08, 0x74, 0x78, 0x6e, 0x5f, 0x68, 0x61, 0x73, 0x68, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x07, 0x74, 0x78, 0x6e, 0x48, 0x61, 0x73, 0x68, 0x12, 0x17, 0x0a, 0x07, 0x62, + 0x69, 0x64, 0x5f, 0x61, 0x6d, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x62, 0x69, + 0x64, 0x41, 0x6d, 0x74, 0x12, 0x21, 0x0a, 0x0c, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x6e, 0x75, + 0x6d, 0x62, 0x65, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0b, 0x62, 0x6c, 0x6f, 0x63, + 0x6b, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x22, 0xbf, 0x01, 0x0a, 0x0a, 0x43, 0x6f, 0x6d, 0x6d, + 0x69, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x28, 0x0a, 0x03, 0x62, 0x69, 0x64, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x73, 0x65, 0x61, 0x63, 0x68, 0x65, + 0x72, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x42, 0x69, 0x64, 0x52, 0x03, 0x62, 0x69, 0x64, + 0x12, 0x19, 0x0a, 0x08, 0x62, 0x69, 0x64, 0x5f, 0x68, 0x61, 0x73, 0x68, 0x18, 0x04, 0x20, 0x01, + 0x28, 0x0c, 0x52, 0x07, 0x62, 0x69, 0x64, 0x48, 0x61, 0x73, 0x68, 0x12, 0x1c, 0x0a, 0x09, 0x73, + 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, + 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x64, 0x61, 0x74, + 0x61, 0x5f, 0x68, 0x61, 0x73, 0x68, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x08, 0x64, 0x61, + 0x74, 0x61, 0x48, 0x61, 0x73, 0x68, 0x12, 0x31, 0x0a, 0x14, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, + 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x18, 0x07, + 0x20, 0x01, 0x28, 0x0c, 0x52, 0x13, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x6d, 0x65, 0x6e, 0x74, + 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x32, 0x50, 0x0a, 0x08, 0x53, 0x65, 0x61, + 0x72, 0x63, 0x68, 0x65, 0x72, 0x12, 0x44, 0x0a, 0x07, 0x53, 0x65, 0x6e, 0x64, 0x42, 0x69, 0x64, + 0x12, 0x16, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x73, 0x65, 0x61, 0x63, 0x68, 0x65, 0x72, 0x61, 0x70, + 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x42, 0x69, 0x64, 0x1a, 0x1d, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x73, + 0x65, 0x61, 0x63, 0x68, 0x65, 0x72, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6d, + 0x6d, 0x69, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x22, 0x00, 0x30, 0x01, 0x42, 0x46, 0x5a, 0x44, 0x67, + 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x70, 0x72, 0x69, 0x6d, 0x65, 0x76, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2f, 0x6d, 0x65, 0x76, 0x2d, 0x63, 0x6f, 0x6d, + 0x6d, 0x69, 0x74, 0x2f, 0x72, 0x70, 0x63, 0x2f, 0x73, 0x65, 0x61, 0x63, 0x68, 0x65, 0x72, 0x61, + 0x70, 0x69, 0x2f, 0x76, 0x31, 0x3b, 0x73, 0x65, 0x61, 0x72, 0x63, 0x68, 0x65, 0x72, 0x61, 0x70, + 0x69, 0x76, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_rpc_searcherapi_v1_searcherapi_proto_rawDescOnce sync.Once + file_rpc_searcherapi_v1_searcherapi_proto_rawDescData = file_rpc_searcherapi_v1_searcherapi_proto_rawDesc +) + +func file_rpc_searcherapi_v1_searcherapi_proto_rawDescGZIP() []byte { + file_rpc_searcherapi_v1_searcherapi_proto_rawDescOnce.Do(func() { + file_rpc_searcherapi_v1_searcherapi_proto_rawDescData = protoimpl.X.CompressGZIP(file_rpc_searcherapi_v1_searcherapi_proto_rawDescData) + }) + return file_rpc_searcherapi_v1_searcherapi_proto_rawDescData +} + +var file_rpc_searcherapi_v1_searcherapi_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_rpc_searcherapi_v1_searcherapi_proto_goTypes = []interface{}{ + (*Bid)(nil), // 0: rpc.seacherapi.v1.Bid + (*Commitment)(nil), // 1: rpc.seacherapi.v1.Commitment +} +var file_rpc_searcherapi_v1_searcherapi_proto_depIdxs = []int32{ + 0, // 0: rpc.seacherapi.v1.Commitment.bid:type_name -> rpc.seacherapi.v1.Bid + 0, // 1: rpc.seacherapi.v1.Searcher.SendBid:input_type -> rpc.seacherapi.v1.Bid + 1, // 2: rpc.seacherapi.v1.Searcher.SendBid:output_type -> rpc.seacherapi.v1.Commitment + 2, // [2:3] is the sub-list for method output_type + 1, // [1:2] is the sub-list for method input_type + 1, // [1:1] is the sub-list for extension type_name + 1, // [1:1] is the sub-list for extension extendee + 0, // [0:1] is the sub-list for field type_name +} + +func init() { file_rpc_searcherapi_v1_searcherapi_proto_init() } +func file_rpc_searcherapi_v1_searcherapi_proto_init() { + if File_rpc_searcherapi_v1_searcherapi_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_rpc_searcherapi_v1_searcherapi_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Bid); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_rpc_searcherapi_v1_searcherapi_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Commitment); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_rpc_searcherapi_v1_searcherapi_proto_rawDesc, + NumEnums: 0, + NumMessages: 2, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_rpc_searcherapi_v1_searcherapi_proto_goTypes, + DependencyIndexes: file_rpc_searcherapi_v1_searcherapi_proto_depIdxs, + MessageInfos: file_rpc_searcherapi_v1_searcherapi_proto_msgTypes, + }.Build() + File_rpc_searcherapi_v1_searcherapi_proto = out.File + file_rpc_searcherapi_v1_searcherapi_proto_rawDesc = nil + file_rpc_searcherapi_v1_searcherapi_proto_goTypes = nil + file_rpc_searcherapi_v1_searcherapi_proto_depIdxs = nil +} diff --git a/gen/go/rpc/searcherapi/v1/searcherapi_grpc.pb.go b/gen/go/rpc/searcherapi/v1/searcherapi_grpc.pb.go new file mode 100644 index 00000000..75e8201a --- /dev/null +++ b/gen/go/rpc/searcherapi/v1/searcherapi_grpc.pb.go @@ -0,0 +1,136 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.3.0 +// - protoc (unknown) +// source: rpc/searcherapi/v1/searcherapi.proto + +package searcherapiv1 + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.32.0 or later. +const _ = grpc.SupportPackageIsVersion7 + +const ( + Searcher_SendBid_FullMethodName = "/rpc.seacherapi.v1.Searcher/SendBid" +) + +// SearcherClient is the client API for Searcher service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type SearcherClient interface { + SendBid(ctx context.Context, in *Bid, opts ...grpc.CallOption) (Searcher_SendBidClient, error) +} + +type searcherClient struct { + cc grpc.ClientConnInterface +} + +func NewSearcherClient(cc grpc.ClientConnInterface) SearcherClient { + return &searcherClient{cc} +} + +func (c *searcherClient) SendBid(ctx context.Context, in *Bid, opts ...grpc.CallOption) (Searcher_SendBidClient, error) { + stream, err := c.cc.NewStream(ctx, &Searcher_ServiceDesc.Streams[0], Searcher_SendBid_FullMethodName, opts...) + if err != nil { + return nil, err + } + x := &searcherSendBidClient{stream} + if err := x.ClientStream.SendMsg(in); err != nil { + return nil, err + } + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + return x, nil +} + +type Searcher_SendBidClient interface { + Recv() (*Commitment, error) + grpc.ClientStream +} + +type searcherSendBidClient struct { + grpc.ClientStream +} + +func (x *searcherSendBidClient) Recv() (*Commitment, error) { + m := new(Commitment) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +// SearcherServer is the server API for Searcher service. +// All implementations must embed UnimplementedSearcherServer +// for forward compatibility +type SearcherServer interface { + SendBid(*Bid, Searcher_SendBidServer) error + mustEmbedUnimplementedSearcherServer() +} + +// UnimplementedSearcherServer must be embedded to have forward compatible implementations. +type UnimplementedSearcherServer struct { +} + +func (UnimplementedSearcherServer) SendBid(*Bid, Searcher_SendBidServer) error { + return status.Errorf(codes.Unimplemented, "method SendBid not implemented") +} +func (UnimplementedSearcherServer) mustEmbedUnimplementedSearcherServer() {} + +// UnsafeSearcherServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to SearcherServer will +// result in compilation errors. +type UnsafeSearcherServer interface { + mustEmbedUnimplementedSearcherServer() +} + +func RegisterSearcherServer(s grpc.ServiceRegistrar, srv SearcherServer) { + s.RegisterService(&Searcher_ServiceDesc, srv) +} + +func _Searcher_SendBid_Handler(srv interface{}, stream grpc.ServerStream) error { + m := new(Bid) + if err := stream.RecvMsg(m); err != nil { + return err + } + return srv.(SearcherServer).SendBid(m, &searcherSendBidServer{stream}) +} + +type Searcher_SendBidServer interface { + Send(*Commitment) error + grpc.ServerStream +} + +type searcherSendBidServer struct { + grpc.ServerStream +} + +func (x *searcherSendBidServer) Send(m *Commitment) error { + return x.ServerStream.SendMsg(m) +} + +// Searcher_ServiceDesc is the grpc.ServiceDesc for Searcher service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var Searcher_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "rpc.seacherapi.v1.Searcher", + HandlerType: (*SearcherServer)(nil), + Methods: []grpc.MethodDesc{}, + Streams: []grpc.StreamDesc{ + { + StreamName: "SendBid", + Handler: _Searcher_SendBid_Handler, + ServerStreams: true, + }, + }, + Metadata: "rpc/searcherapi/v1/searcherapi.proto", +} diff --git a/go.mod b/go.mod index b71303b5..9335d5a8 100644 --- a/go.mod +++ b/go.mod @@ -8,11 +8,12 @@ require ( github.com/libp2p/go-msgio v0.3.0 github.com/multiformats/go-multiaddr v0.11.0 github.com/prometheus/client_golang v1.17.0 - github.com/stretchr/testify v1.8.4 github.com/urfave/cli/v2 v2.25.7 github.com/vmihailenco/msgpack/v5 v5.4.0 golang.org/x/crypto v0.13.0 golang.org/x/sync v0.3.0 + google.golang.org/grpc v1.58.2 + google.golang.org/protobuf v1.31.0 gopkg.in/yaml.v2 v2.4.0 ) @@ -29,7 +30,6 @@ require ( github.com/coreos/go-systemd/v22 v22.5.0 // indirect github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect github.com/crate-crypto/go-kzg-4844 v0.3.0 // indirect - github.com/davecgh/go-spew v1.1.1 // indirect github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c // indirect github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect github.com/docker/go-units v0.5.0 // indirect @@ -85,7 +85,6 @@ require ( github.com/opencontainers/runtime-spec v1.1.0 // indirect github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 // indirect github.com/pkg/errors v0.9.1 // indirect - github.com/pmezard/go-difflib v1.0.0 // indirect github.com/prometheus/client_model v0.4.1-0.20230718164431-9a2bf3000d16 // indirect github.com/prometheus/common v0.44.0 // indirect github.com/prometheus/procfs v0.11.1 // indirect @@ -105,12 +104,11 @@ require ( go.uber.org/zap v1.25.0 // indirect golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63 // indirect golang.org/x/mod v0.12.0 // indirect - golang.org/x/net v0.14.0 // indirect + golang.org/x/net v0.15.0 // indirect golang.org/x/sys v0.12.0 // indirect golang.org/x/text v0.13.0 // indirect golang.org/x/tools v0.12.1-0.20230815132531-74c255bcf846 // indirect - google.golang.org/protobuf v1.31.0 // indirect - gopkg.in/yaml.v3 v3.0.1 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20231002182017-d307bd883b97 // indirect lukechampine.com/blake3 v1.2.1 // indirect rsc.io/tmplfunc v0.0.3 // indirect ) diff --git a/go.sum b/go.sum index 67ebaaff..9e7af4c8 100644 --- a/go.sum +++ b/go.sum @@ -457,8 +457,8 @@ golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwY golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= 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.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14= -golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI= +golang.org/x/net v0.15.0 h1:ugBLEUaxABaB5AJqW9enI0ACdci2RUd4eP51NTBvuJ8= +golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20181017192945-9dcd33a902f4/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20181203162652-d668ce993890/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -533,10 +533,14 @@ google.golang.org/genproto v0.0.0-20180831171423-11092d34479b/go.mod h1:JiN7NxoA google.golang.org/genproto v0.0.0-20181029155118-b69ba1387ce2/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20181202183823-bd91e49a0898/go.mod h1:7Ep/1NZk928CDR8SjdVbjWNpdIf6nzjE3BTgJDr2Atg= google.golang.org/genproto v0.0.0-20190306203927-b5d61aea6440/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto/googleapis/rpc v0.0.0-20231002182017-d307bd883b97 h1:6GQBEOdGkX6MMTLT9V+TjtIRZCw9VPD5Z+yHY9wMgS0= +google.golang.org/genproto/googleapis/rpc v0.0.0-20231002182017-d307bd883b97/go.mod h1:v7nGkzlmW8P3n/bKmWBn2WpBjpOEx8Q6gMueudAmKfY= google.golang.org/grpc v1.14.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= google.golang.org/grpc v1.16.0/go.mod h1:0JHn/cJsOMiMfNA9+DeHDlAU7KAAB5GDlYFpa9MZMio= google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= +google.golang.org/grpc v1.58.2 h1:SXUpjxeVF3FKrTYQI4f4KvbGD5u2xccdYdurwowix5I= +google.golang.org/grpc v1.58.2/go.mod h1:tgX3ZQDlNJGU96V6yHh1T/JeoBQ2TXdr43YbYSsCJk0= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= diff --git a/pkg/node/node.go b/pkg/node/node.go index cef1cd08..6201c596 100644 --- a/pkg/node/node.go +++ b/pkg/node/node.go @@ -6,15 +6,21 @@ import ( "fmt" "io" "log/slog" + "net" "net/http" + "github.com/ethereum/go-ethereum/common" + searcherapiv1 "github.com/primevprotocol/mev-commit/gen/go/rpc/searcherapi/v1" "github.com/primevprotocol/mev-commit/pkg/apiserver" "github.com/primevprotocol/mev-commit/pkg/debugapi" "github.com/primevprotocol/mev-commit/pkg/discovery" "github.com/primevprotocol/mev-commit/pkg/p2p" "github.com/primevprotocol/mev-commit/pkg/p2p/libp2p" + "github.com/primevprotocol/mev-commit/pkg/preconfirmation" "github.com/primevprotocol/mev-commit/pkg/register" + "github.com/primevprotocol/mev-commit/pkg/searcherapi" "github.com/primevprotocol/mev-commit/pkg/topology" + "google.golang.org/grpc" ) type Options struct { @@ -25,6 +31,7 @@ type Options struct { Logger *slog.Logger P2PPort int HTTPPort int + RPCPort int Bootnodes []string } @@ -87,6 +94,31 @@ func NewNode(opts *Options) (*Node, error) { }() closers = append(closers, server) + switch opts.PeerType { + case p2p.PeerTypeBuilder.String(): + preconf := preconfirmation.New(topo, p2pSvc, opts.PrivKey, nil, opts.Logger) + p2pSvc.AddProtocol(preconf.Protocol()) + + case p2p.PeerTypeSearcher.String(): + lis, err := net.Listen("tcp", fmt.Sprintf(":%d", opts.RPCPort)) + if err != nil { + return nil, err + } + + preconf := preconfirmation.New(topo, p2pSvc, opts.PrivKey, dummyUserStore{}, opts.Logger) + grpcServer := grpc.NewServer() + searcherAPI := searcherapi.NewService(preconf, opts.Logger) + searcherapiv1.RegisterSearcherServer(grpcServer, searcherAPI) + + go func() { + err := grpcServer.Serve(lis) + if err != nil { + opts.Logger.Error("failed to start grpc server", "err", err) + } + }() + closers = append(closers, lis) + } + return &Node{closers: closers}, nil } @@ -98,3 +130,9 @@ func (n *Node) Close() error { return err } + +type dummyUserStore struct{} + +func (dummyUserStore) CheckUserRegistred(_ *common.Address) bool { + return true +} diff --git a/pkg/preconfirmation/preconfirmation.go b/pkg/preconfirmation/preconfirmation.go index c3c9d052..33d6010b 100644 --- a/pkg/preconfirmation/preconfirmation.go +++ b/pkg/preconfirmation/preconfirmation.go @@ -4,7 +4,9 @@ import ( "context" "crypto/ecdsa" "errors" + "log/slog" "math/big" + "sync" "github.com/ethereum/go-ethereum/common" "github.com/primevprotocol/mev-commit/pkg/p2p" @@ -22,21 +24,31 @@ type Preconfirmation struct { signer preconf.Signer topo Topology streamer p2p.Streamer - cs CommitmentsStore us UserStore + logger *slog.Logger } type Topology interface { GetPeers(topology.Query) []p2p.Peer } -func New(topo Topology, streamer p2p.Streamer, key *ecdsa.PrivateKey, us UserStore, cs CommitmentsStore) *Preconfirmation { +type UserStore interface { + CheckUserRegistred(*common.Address) bool +} + +func New( + topo Topology, + streamer p2p.Streamer, + key *ecdsa.PrivateKey, + us UserStore, + logger *slog.Logger, +) *Preconfirmation { return &Preconfirmation{ topo: topo, streamer: streamer, signer: preconf.PrivateKeySigner{PrivKey: key}, us: us, - cs: cs, + logger: logger, } } @@ -53,70 +65,92 @@ func (p *Preconfirmation) Protocol() p2p.ProtocolSpec { } } -// BidHash -> map of preconfs -// Key: BidHash -// Value: List of preconfs -// var commitments map[string][]preconf.PreconfCommitment -type CommitmentsStore interface { - GetCommitments(bidHash []byte) ([]preconf.PreconfCommitment, error) - AddCommitment(bidHash []byte, commitment *preconf.PreconfCommitment) error -} - -type UserStore interface { - CheckUserRegistred(*common.Address) bool -} - // SendBid is meant to be called by the searcher to construct and send bids to the builder. // It takes the txnHash, the bid amount in wei and the maximum valid block number. // It waits for commitments from all builders and then returns. -// TODO(@ckartik): construct seperate go-routine to wait for commitments, with a context that cancels if a timeout is reached. -// // It returns an error if the bid is not valid. -func (p *Preconfirmation) SendBid(ctx context.Context, txnHash string, bidamt *big.Int, blockNumber *big.Int) error { - signedBid, err := preconf.ConstructSignedBid(bidamt, txnHash, blockNumber, p.signer) +func (p *Preconfirmation) SendBid( + ctx context.Context, + txnHash string, + bidAmt *big.Int, + blockNumber *big.Int, +) (chan *preconf.PreconfCommitment, error) { + signedBid, err := preconf.ConstructSignedBid(bidAmt, txnHash, blockNumber, p.signer) if err != nil { - return err + p.logger.Error("constructing signed bid", "err", err, "txnHash", txnHash) + return nil, err } builders := p.topo.GetPeers(topology.Query{Type: p2p.PeerTypeBuilder}) + if len(builders) == 0 { + p.logger.Error("no builders available", "txnHash", txnHash) + return nil, errors.New("no builders available") + } - // TODO(@ckartik): Push into a channel and process in parallel - for _, builder := range builders { - // Create a new connection - builderStream, err := p.streamer.NewStream(ctx, builder, ProtocolName, ProtocolVersion, "bid") - if err != nil { - return err - } - - r, w := msgpack.NewReaderWriter[preconf.PreconfCommitment, preconf.PreConfBid](builderStream) - err = w.WriteMsg(ctx, signedBid) - if err != nil { - return err - } - - commitment, err := r.ReadMsg(ctx) - if err != nil { - return err - } - - // Process commitment as a searcher - _, err = commitment.VerifyBuilderSignature() - if err != nil { - return err - } - _, err = commitment.VerifySearcherSignature() - if err != nil { - return err - } - - // Verify the bid details correspond. - err = p.cs.AddCommitment(signedBid.BidHash, commitment) - if err != nil { - return err - } + // Create a new channel to receive commitments + commitments := make(chan *preconf.PreconfCommitment, len(builders)) + + wg := sync.WaitGroup{} + for idx := range builders { + wg.Add(1) + go func(builder p2p.Peer) { + defer wg.Done() + + logger := p.logger.With("builder", builder, "bid", txnHash) + + builderStream, err := p.streamer.NewStream( + ctx, + builder, + ProtocolName, + ProtocolVersion, + "bid", + ) + if err != nil { + logger.Error("creating stream", "err", err) + return + } + + r, w := msgpack.NewReaderWriter[preconf.PreconfCommitment, preconf.PreConfBid](builderStream) + err = w.WriteMsg(ctx, signedBid) + if err != nil { + logger.Error("writing message", "err", err) + return + } + + commitment, err := r.ReadMsg(ctx) + if err != nil { + logger.Error("reading message", "err", err) + return + } + + // Process commitment as a searcher + _, err = commitment.VerifyBuilderSignature() + if err != nil { + logger.Error("verifying builder signature", "err", err) + return + } + + _, err = commitment.VerifySearcherSignature() + if err != nil { + logger.Error("verifying searcher signature", "err", err) + return + } + + select { + case commitments <- commitment: + case <-ctx.Done(): + logger.Error("context cancelled", "err", ctx.Err()) + return + } + }(builders[idx]) } - return nil + go func() { + wg.Wait() + close(commitments) + }() + + return commitments, nil } var ErrInvalidSearcherTypeForBid = errors.New("invalid searcher type for bid") diff --git a/pkg/preconfirmation/preconfirmation_test.go b/pkg/preconfirmation/preconfirmation_test.go index 62e0bd12..4e0eba7a 100644 --- a/pkg/preconfirmation/preconfirmation_test.go +++ b/pkg/preconfirmation/preconfirmation_test.go @@ -2,8 +2,10 @@ package preconfirmation_test import ( "context" + "io" + "log/slog" "math/big" - "sync" + "os" "testing" "github.com/ethereum/go-ethereum/common" @@ -15,47 +17,27 @@ import ( "github.com/primevprotocol/mev-commit/pkg/topology" ) -type testTopo struct { - mu sync.Mutex - peers []p2p.Peer -} - -func (t *testTopo) AddPeers(peers ...p2p.Peer) { - t.mu.Lock() - defer t.mu.Unlock() - - t.peers = append(t.peers, peers...) -} +type testTopo struct{} func (t *testTopo) GetPeers(q topology.Query) []p2p.Peer { - t.mu.Lock() - defer t.mu.Unlock() - return []p2p.Peer{{EthAddress: common.HexToAddress("0x2"), Type: p2p.PeerTypeBuilder}} } -func (t *testTopo) Connected(p2p.Peer) { -} +type testCommitmentStore struct{} -func (t *testTopo) Disconnected(p2p.Peer) { -} - -type testCommitmentStore struct { -} - -func (t *testCommitmentStore) GetCommitments(bidHash []byte) ([]preconf.PreconfCommitment, error) { - return []preconf.PreconfCommitment{}, nil -} +type testUserStore struct{} -func (t *testCommitmentStore) AddCommitment(bidHash []byte, commitment *preconf.PreconfCommitment) error { - return nil +func (t *testUserStore) CheckUserRegistred(_ *common.Address) bool { + return true } -type testUserStore struct { -} +func newTestLogger(t *testing.T, w io.Writer) *slog.Logger { + t.Helper() -func (t *testUserStore) CheckUserRegistred(_ *common.Address) bool { - return true + testLogger := slog.NewTextHandler(w, &slog.HandlerOptions{ + Level: slog.LevelDebug, + }) + return slog.New(testLogger) } func TestPreconfBidSubmission(t *testing.T) { @@ -77,17 +59,29 @@ func TestPreconfBidSubmission(t *testing.T) { topo := &testTopo{} us := &testUserStore{} - cs := &testCommitmentStore{} key, _ := crypto.GenerateKey() - p := preconfirmation.New(topo, svc, key, us, cs) + p := preconfirmation.New(topo, svc, key, us, newTestLogger(t, os.Stdout)) - // svc.SetPeerHandler(client, p.Protocol()) svc.SetPeerHandler(server, p.Protocol()) - err := p.SendBid(context.Background(), "0x4c03a845396b770ad41b975d6bd3bf8c2bd5cca36867a3301f9598f2e3e9518d", big.NewInt(10), big.NewInt(10)) + respC, err := p.SendBid( + context.Background(), + "0x4c03a845396b770ad41b975d6bd3bf8c2bd5cca36867a3301f9598f2e3e9518d", + big.NewInt(10), + big.NewInt(10), + ) if err != nil { t.Fatal(err) } + resp := <-respC + + if resp.DataHash == nil { + t.Fatal("datahash is nil") + } + + if resp.CommitmentSignature == nil { + t.Fatal("commitment signature is nil") + } }) } diff --git a/pkg/searcherapi/api.go b/pkg/searcherapi/api.go new file mode 100644 index 00000000..60156fbf --- /dev/null +++ b/pkg/searcherapi/api.go @@ -0,0 +1,67 @@ +package searcherapi + +import ( + "context" + "log/slog" + "math/big" + + searcherapiv1 "github.com/primevprotocol/mev-commit/gen/go/rpc/searcherapi/v1" + "github.com/primevprotocol/mev-commit/pkg/structures/preconf" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +type Service struct { + searcherapiv1.UnimplementedSearcherServer + sender PreconfSender + logger *slog.Logger +} + +func NewService(sender PreconfSender, logger *slog.Logger) *Service { + return &Service{ + sender: sender, + logger: logger, + } +} + +type PreconfSender interface { + SendBid(context.Context, string, *big.Int, *big.Int) (chan *preconf.PreconfCommitment, error) +} + +func (s *Service) SendBid( + bid *searcherapiv1.Bid, + srv searcherapiv1.Searcher_SendBidServer, +) error { + + respC, err := s.sender.SendBid( + srv.Context(), + bid.TxnHash, + big.NewInt(bid.BidAmt), + big.NewInt(bid.BlockNumber), + ) + if err != nil { + s.logger.Error("error sending bid", "err", err) + return status.Errorf(codes.Internal, "error sending bid: %v", err) + } + + for resp := range respC { + err := srv.Send(&searcherapiv1.Commitment{ + Bid: &searcherapiv1.Bid{ + TxnHash: resp.TxnHash, + BidAmt: resp.Bid.Int64(), + BlockNumber: resp.Blocknumber.Int64(), + }, + BidHash: resp.BidHash, + Signature: resp.Signature, + DataHash: resp.DataHash, + CommitmentSignature: resp.CommitmentSignature, + }) + if err != nil { + s.logger.Error("error sending commitment", "err", err) + return err + } + s.logger.Debug("sent commitment", "bid", resp.TxnHash) + } + + return nil +} diff --git a/pkg/topology/topology.go b/pkg/topology/topology.go index 7bf9c878..b55cac26 100644 --- a/pkg/topology/topology.go +++ b/pkg/topology/topology.go @@ -79,6 +79,7 @@ func (t *topology) Connected(p p2p.Peer) { } if p.Type == p2p.PeerTypeBuilder { + t.logger.Info("builder connected broadcasting to previous searchers", "peer", p) // If the peer is a builder, we want to broadcast to the searcher peers peersToBroadcastTo := t.GetPeers(Query{Type: p2p.PeerTypeSearcher}) builderUnderlay, err := t.addressbook.GetPeerInfo(p) @@ -95,7 +96,6 @@ func (t *topology) Connected(p p2p.Peer) { }) if err != nil { t.logger.Error("failed to broadcast peer", "err", err, "peer", peer) - continue } } } diff --git a/rpc/searcherapi/v1/buf.yaml b/rpc/searcherapi/v1/buf.yaml new file mode 100644 index 00000000..1a519456 --- /dev/null +++ b/rpc/searcherapi/v1/buf.yaml @@ -0,0 +1,7 @@ +version: v1 +breaking: + use: + - FILE +lint: + use: + - DEFAULT diff --git a/rpc/searcherapi/v1/searcherapi.proto b/rpc/searcherapi/v1/searcherapi.proto new file mode 100644 index 00000000..4bc54833 --- /dev/null +++ b/rpc/searcherapi/v1/searcherapi.proto @@ -0,0 +1,23 @@ +syntax = "proto3"; + +package rpc.seacherapi.v1; + +option go_package = "github.com/primevprotocol/mev-commit/rpc/seacherapi/v1;searcherapiv1"; + +service Searcher { + rpc SendBid(Bid) returns (stream Commitment) {} +} + +message Bid { + string txn_hash = 1; + int64 bid_amt = 2; + int64 block_number = 3; +}; + +message Commitment { + Bid bid = 1; + bytes bid_hash = 4; + bytes signature = 5; + bytes data_hash = 6; + bytes commitment_signature = 7; +}; From 1e65b9838802c0daf0cb24c84d98b731d1962327 Mon Sep 17 00:00:00 2001 From: alok Date: Wed, 4 Oct 2023 00:44:08 +0530 Subject: [PATCH 2/3] fix: rebase --- go.mod | 4 ++++ pkg/preconfirmation/preconfirmation_test.go | 1 - pkg/searcherapi/api.go | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/go.mod b/go.mod index 9335d5a8..227135bb 100644 --- a/go.mod +++ b/go.mod @@ -8,6 +8,7 @@ require ( github.com/libp2p/go-msgio v0.3.0 github.com/multiformats/go-multiaddr v0.11.0 github.com/prometheus/client_golang v1.17.0 + github.com/stretchr/testify v1.8.4 github.com/urfave/cli/v2 v2.25.7 github.com/vmihailenco/msgpack/v5 v5.4.0 golang.org/x/crypto v0.13.0 @@ -30,6 +31,7 @@ require ( github.com/coreos/go-systemd/v22 v22.5.0 // indirect github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect github.com/crate-crypto/go-kzg-4844 v0.3.0 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c // indirect github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect github.com/docker/go-units v0.5.0 // indirect @@ -85,6 +87,7 @@ require ( github.com/opencontainers/runtime-spec v1.1.0 // indirect github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 // indirect github.com/pkg/errors v0.9.1 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect github.com/prometheus/client_model v0.4.1-0.20230718164431-9a2bf3000d16 // indirect github.com/prometheus/common v0.44.0 // indirect github.com/prometheus/procfs v0.11.1 // indirect @@ -109,6 +112,7 @@ require ( golang.org/x/text v0.13.0 // indirect golang.org/x/tools v0.12.1-0.20230815132531-74c255bcf846 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20231002182017-d307bd883b97 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect lukechampine.com/blake3 v1.2.1 // indirect rsc.io/tmplfunc v0.0.3 // indirect ) diff --git a/pkg/preconfirmation/preconfirmation_test.go b/pkg/preconfirmation/preconfirmation_test.go index 4e0eba7a..f736b056 100644 --- a/pkg/preconfirmation/preconfirmation_test.go +++ b/pkg/preconfirmation/preconfirmation_test.go @@ -12,7 +12,6 @@ import ( "github.com/ethereum/go-ethereum/crypto" "github.com/primevprotocol/mev-commit/pkg/p2p" p2ptest "github.com/primevprotocol/mev-commit/pkg/p2p/testing" - "github.com/primevprotocol/mev-commit/pkg/preconf" "github.com/primevprotocol/mev-commit/pkg/preconfirmation" "github.com/primevprotocol/mev-commit/pkg/topology" ) diff --git a/pkg/searcherapi/api.go b/pkg/searcherapi/api.go index 60156fbf..a609e808 100644 --- a/pkg/searcherapi/api.go +++ b/pkg/searcherapi/api.go @@ -6,7 +6,7 @@ import ( "math/big" searcherapiv1 "github.com/primevprotocol/mev-commit/gen/go/rpc/searcherapi/v1" - "github.com/primevprotocol/mev-commit/pkg/structures/preconf" + "github.com/primevprotocol/mev-commit/pkg/preconf" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" ) From 72a1db0f556a1d6323e68f1c01c319abebf9e26a Mon Sep 17 00:00:00 2001 From: alok Date: Wed, 4 Oct 2023 01:16:06 +0530 Subject: [PATCH 3/3] fix: lint --- cmd/main.go | 3 ++- pkg/preconfirmation/preconfirmation_test.go | 2 -- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/cmd/main.go b/cmd/main.go index 72731a8f..600e83ca 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -89,7 +89,7 @@ type config struct { PeerType string `yaml:"peer_type" json:"peer_type"` P2PPort int `yaml:"p2p_port" json:"p2p_port"` HTTPPort int `yaml:"http_port" json:"http_port"` - RPCPort int `yaml:"rpc_port" json:"http_port"` + RPCPort int `yaml:"rpc_port" json:"rpc_port"` LogFmt string `yaml:"log_fmt" json:"log_fmt"` LogLevel string `yaml:"log_level" json:"log_level"` Bootnodes []string `yaml:"bootnodes" json:"bootnodes"` @@ -165,6 +165,7 @@ func start(c *cli.Context) error { PeerType: cfg.PeerType, P2PPort: cfg.P2PPort, HTTPPort: cfg.HTTPPort, + RPCPort: cfg.RPCPort, Logger: logger, Bootnodes: cfg.Bootnodes, }) diff --git a/pkg/preconfirmation/preconfirmation_test.go b/pkg/preconfirmation/preconfirmation_test.go index f736b056..856166c5 100644 --- a/pkg/preconfirmation/preconfirmation_test.go +++ b/pkg/preconfirmation/preconfirmation_test.go @@ -22,8 +22,6 @@ func (t *testTopo) GetPeers(q topology.Query) []p2p.Peer { return []p2p.Peer{{EthAddress: common.HexToAddress("0x2"), Type: p2p.PeerTypeBuilder}} } -type testCommitmentStore struct{} - type testUserStore struct{} func (t *testUserStore) CheckUserRegistred(_ *common.Address) bool {