Commit f2a034dd authored by Ubuntu's avatar Ubuntu

generate tx in init func

parent ccb54d9b
......@@ -91,23 +91,29 @@ message Transaction{
//2. eth std: proto3 eth tx --> grpc --->proto3 eth tx
// proto3 std tx --> grpc --->proto3 std tx
message TransactionStd{
message TransactionEth{
TxProof tx_proof=1;
int64 timeout_block_num =2;
StdTx tx =3;
EthTx tx =3;
}
message TransactionEth{
message TransactionStd{
TxProof tx_proof=1;
int64 timeout_block_num =2;
EthTx tx =3;
StdTx tx =3;
}
//3. bytes
message TransactionBytes{
TxProof tx_proof=1;
int64 timeout_block_num =2;
bytes tx =3; // EthTx StdTx
bytes tx =3; // EthTx StdTx // proto3 定义的交易,没有对应的函数转bytes。
bytes from =4;
}
......
......@@ -711,20 +711,18 @@ func (x *Transaction) GetTx() *anypb.Any {
return nil
}
// 2. eth std: proto3 eth tx --> grpc --->proto3 eth tx
// proto3 std tx --> grpc --->proto3 std tx
type TransactionStd struct {
type TransactionEth struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
TxProof *TxProof `protobuf:"bytes,1,opt,name=tx_proof,json=txProof,proto3" json:"tx_proof,omitempty"`
TimeoutBlockNum int64 `protobuf:"varint,2,opt,name=timeout_block_num,json=timeoutBlockNum,proto3" json:"timeout_block_num,omitempty"`
Tx *StdTx `protobuf:"bytes,3,opt,name=tx,proto3" json:"tx,omitempty"`
Tx *EthTx `protobuf:"bytes,3,opt,name=tx,proto3" json:"tx,omitempty"`
}
func (x *TransactionStd) Reset() {
*x = TransactionStd{}
func (x *TransactionEth) Reset() {
*x = TransactionEth{}
if protoimpl.UnsafeEnabled {
mi := &file_base_v1_resource_proto_msgTypes[10]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
......@@ -732,13 +730,13 @@ func (x *TransactionStd) Reset() {
}
}
func (x *TransactionStd) String() string {
func (x *TransactionEth) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*TransactionStd) ProtoMessage() {}
func (*TransactionEth) ProtoMessage() {}
func (x *TransactionStd) ProtoReflect() protoreflect.Message {
func (x *TransactionEth) ProtoReflect() protoreflect.Message {
mi := &file_base_v1_resource_proto_msgTypes[10]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
......@@ -750,44 +748,44 @@ func (x *TransactionStd) ProtoReflect() protoreflect.Message {
return mi.MessageOf(x)
}
// Deprecated: Use TransactionStd.ProtoReflect.Descriptor instead.
func (*TransactionStd) Descriptor() ([]byte, []int) {
// Deprecated: Use TransactionEth.ProtoReflect.Descriptor instead.
func (*TransactionEth) Descriptor() ([]byte, []int) {
return file_base_v1_resource_proto_rawDescGZIP(), []int{10}
}
func (x *TransactionStd) GetTxProof() *TxProof {
func (x *TransactionEth) GetTxProof() *TxProof {
if x != nil {
return x.TxProof
}
return nil
}
func (x *TransactionStd) GetTimeoutBlockNum() int64 {
func (x *TransactionEth) GetTimeoutBlockNum() int64 {
if x != nil {
return x.TimeoutBlockNum
}
return 0
}
func (x *TransactionStd) GetTx() *StdTx {
func (x *TransactionEth) GetTx() *EthTx {
if x != nil {
return x.Tx
}
return nil
}
type TransactionEth struct {
type TransactionStd struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
TxProof *TxProof `protobuf:"bytes,1,opt,name=tx_proof,json=txProof,proto3" json:"tx_proof,omitempty"`
TimeoutBlockNum int64 `protobuf:"varint,2,opt,name=timeout_block_num,json=timeoutBlockNum,proto3" json:"timeout_block_num,omitempty"`
Tx *EthTx `protobuf:"bytes,3,opt,name=tx,proto3" json:"tx,omitempty"`
Tx *StdTx `protobuf:"bytes,3,opt,name=tx,proto3" json:"tx,omitempty"`
}
func (x *TransactionEth) Reset() {
*x = TransactionEth{}
func (x *TransactionStd) Reset() {
*x = TransactionStd{}
if protoimpl.UnsafeEnabled {
mi := &file_base_v1_resource_proto_msgTypes[11]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
......@@ -795,13 +793,13 @@ func (x *TransactionEth) Reset() {
}
}
func (x *TransactionEth) String() string {
func (x *TransactionStd) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*TransactionEth) ProtoMessage() {}
func (*TransactionStd) ProtoMessage() {}
func (x *TransactionEth) ProtoReflect() protoreflect.Message {
func (x *TransactionStd) ProtoReflect() protoreflect.Message {
mi := &file_base_v1_resource_proto_msgTypes[11]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
......@@ -813,26 +811,26 @@ func (x *TransactionEth) ProtoReflect() protoreflect.Message {
return mi.MessageOf(x)
}
// Deprecated: Use TransactionEth.ProtoReflect.Descriptor instead.
func (*TransactionEth) Descriptor() ([]byte, []int) {
// Deprecated: Use TransactionStd.ProtoReflect.Descriptor instead.
func (*TransactionStd) Descriptor() ([]byte, []int) {
return file_base_v1_resource_proto_rawDescGZIP(), []int{11}
}
func (x *TransactionEth) GetTxProof() *TxProof {
func (x *TransactionStd) GetTxProof() *TxProof {
if x != nil {
return x.TxProof
}
return nil
}
func (x *TransactionEth) GetTimeoutBlockNum() int64 {
func (x *TransactionStd) GetTimeoutBlockNum() int64 {
if x != nil {
return x.TimeoutBlockNum
}
return 0
}
func (x *TransactionEth) GetTx() *EthTx {
func (x *TransactionStd) GetTx() *StdTx {
if x != nil {
return x.Tx
}
......@@ -847,7 +845,8 @@ type TransactionBytes struct {
TxProof *TxProof `protobuf:"bytes,1,opt,name=tx_proof,json=txProof,proto3" json:"tx_proof,omitempty"`
TimeoutBlockNum int64 `protobuf:"varint,2,opt,name=timeout_block_num,json=timeoutBlockNum,proto3" json:"timeout_block_num,omitempty"`
Tx []byte `protobuf:"bytes,3,opt,name=tx,proto3" json:"tx,omitempty"` // EthTx StdTx
Tx []byte `protobuf:"bytes,3,opt,name=tx,proto3" json:"tx,omitempty"` // EthTx StdTx // proto3 定义的交易,没有对应的函数转bytes。
From []byte `protobuf:"bytes,4,opt,name=from,proto3" json:"from,omitempty"`
}
func (x *TransactionBytes) Reset() {
......@@ -903,6 +902,13 @@ func (x *TransactionBytes) GetTx() []byte {
return nil
}
func (x *TransactionBytes) GetFrom() []byte {
if x != nil {
return x.From
}
return nil
}
var File_base_v1_resource_proto protoreflect.FileDescriptor
var file_base_v1_resource_proto_rawDesc = []byte{
......@@ -986,42 +992,43 @@ var file_base_v1_resource_proto_rawDesc = []byte{
0x02, 0x74, 0x78, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67,
0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52,
0x02, 0x74, 0x78, 0x22, 0x89, 0x01, 0x0a, 0x0e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74,
0x69, 0x6f, 0x6e, 0x53, 0x74, 0x64, 0x12, 0x2b, 0x0a, 0x08, 0x74, 0x78, 0x5f, 0x70, 0x72, 0x6f,
0x69, 0x6f, 0x6e, 0x45, 0x74, 0x68, 0x12, 0x2b, 0x0a, 0x08, 0x74, 0x78, 0x5f, 0x70, 0x72, 0x6f,
0x6f, 0x66, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e,
0x76, 0x31, 0x2e, 0x54, 0x78, 0x50, 0x72, 0x6f, 0x6f, 0x66, 0x52, 0x07, 0x74, 0x78, 0x50, 0x72,
0x6f, 0x6f, 0x66, 0x12, 0x2a, 0x0a, 0x11, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x5f, 0x62,
0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x6e, 0x75, 0x6d, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0f,
0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x4e, 0x75, 0x6d, 0x12,
0x1e, 0x0a, 0x02, 0x74, 0x78, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x62, 0x61,
0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x74, 0x64, 0x54, 0x78, 0x52, 0x02, 0x74, 0x78, 0x22,
0x89, 0x01, 0x0a, 0x0e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x45,
0x74, 0x68, 0x12, 0x2b, 0x0a, 0x08, 0x74, 0x78, 0x5f, 0x70, 0x72, 0x6f, 0x6f, 0x66, 0x18, 0x01,
0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x74, 0x68, 0x54, 0x78, 0x52, 0x02, 0x74, 0x78, 0x22,
0x89, 0x01, 0x0a, 0x0e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x53,
0x74, 0x64, 0x12, 0x2b, 0x0a, 0x08, 0x74, 0x78, 0x5f, 0x70, 0x72, 0x6f, 0x6f, 0x66, 0x18, 0x01,
0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x54,
0x78, 0x50, 0x72, 0x6f, 0x6f, 0x66, 0x52, 0x07, 0x74, 0x78, 0x50, 0x72, 0x6f, 0x6f, 0x66, 0x12,
0x2a, 0x0a, 0x11, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b,
0x5f, 0x6e, 0x75, 0x6d, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0f, 0x74, 0x69, 0x6d, 0x65,
0x6f, 0x75, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x4e, 0x75, 0x6d, 0x12, 0x1e, 0x0a, 0x02, 0x74,
0x78, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76,
0x31, 0x2e, 0x45, 0x74, 0x68, 0x54, 0x78, 0x52, 0x02, 0x74, 0x78, 0x22, 0x7b, 0x0a, 0x10, 0x54,
0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x79, 0x74, 0x65, 0x73, 0x12,
0x2b, 0x0a, 0x08, 0x74, 0x78, 0x5f, 0x70, 0x72, 0x6f, 0x6f, 0x66, 0x18, 0x01, 0x20, 0x01, 0x28,
0x0b, 0x32, 0x10, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x78, 0x50, 0x72,
0x6f, 0x6f, 0x66, 0x52, 0x07, 0x74, 0x78, 0x50, 0x72, 0x6f, 0x6f, 0x66, 0x12, 0x2a, 0x0a, 0x11,
0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x6e, 0x75,
0x6d, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0f, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74,
0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x4e, 0x75, 0x6d, 0x12, 0x0e, 0x0a, 0x02, 0x74, 0x78, 0x18, 0x03,
0x20, 0x01, 0x28, 0x0c, 0x52, 0x02, 0x74, 0x78, 0x42, 0xa8, 0x01, 0x0a, 0x0b, 0x63, 0x6f, 0x6d,
0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x42, 0x0d, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72,
0x63, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x4d, 0x67, 0x69, 0x74, 0x68, 0x75,
0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x43, 0x61, 0x64, 0x75, 0x63, 0x65, 0x75, 0x73, 0x4d, 0x65,
0x74, 0x61, 0x76, 0x65, 0x72, 0x73, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2f,
0x6d, 0x65, 0x74, 0x61, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2f, 0x67, 0x65, 0x6e,
0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6f, 0x2f, 0x62, 0x61, 0x73, 0x65, 0x2f, 0x76,
0x31, 0x3b, 0x62, 0x61, 0x73, 0x65, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x42, 0x58, 0x58, 0xaa, 0x02,
0x07, 0x42, 0x61, 0x73, 0x65, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x07, 0x42, 0x61, 0x73, 0x65, 0x5c,
0x56, 0x31, 0xe2, 0x02, 0x13, 0x42, 0x61, 0x73, 0x65, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42,
0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x08, 0x42, 0x61, 0x73, 0x65, 0x3a,
0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x31, 0x2e, 0x53, 0x74, 0x64, 0x54, 0x78, 0x52, 0x02, 0x74, 0x78, 0x22, 0x8f, 0x01, 0x0a, 0x10,
0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x79, 0x74, 0x65, 0x73,
0x12, 0x2b, 0x0a, 0x08, 0x74, 0x78, 0x5f, 0x70, 0x72, 0x6f, 0x6f, 0x66, 0x18, 0x01, 0x20, 0x01,
0x28, 0x0b, 0x32, 0x10, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x78, 0x50,
0x72, 0x6f, 0x6f, 0x66, 0x52, 0x07, 0x74, 0x78, 0x50, 0x72, 0x6f, 0x6f, 0x66, 0x12, 0x2a, 0x0a,
0x11, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x6e,
0x75, 0x6d, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0f, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75,
0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x4e, 0x75, 0x6d, 0x12, 0x0e, 0x0a, 0x02, 0x74, 0x78, 0x18,
0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x02, 0x74, 0x78, 0x12, 0x12, 0x0a, 0x04, 0x66, 0x72, 0x6f,
0x6d, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x66, 0x72, 0x6f, 0x6d, 0x42, 0xa8, 0x01,
0x0a, 0x0b, 0x63, 0x6f, 0x6d, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x42, 0x0d, 0x52,
0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x4d,
0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x43, 0x61, 0x64, 0x75, 0x63,
0x65, 0x75, 0x73, 0x4d, 0x65, 0x74, 0x61, 0x76, 0x65, 0x72, 0x73, 0x65, 0x50, 0x72, 0x6f, 0x74,
0x6f, 0x63, 0x6f, 0x6c, 0x2f, 0x6d, 0x65, 0x74, 0x61, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f,
0x6c, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6f, 0x2f, 0x62,
0x61, 0x73, 0x65, 0x2f, 0x76, 0x31, 0x3b, 0x62, 0x61, 0x73, 0x65, 0x76, 0x31, 0xa2, 0x02, 0x03,
0x42, 0x58, 0x58, 0xaa, 0x02, 0x07, 0x42, 0x61, 0x73, 0x65, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x07,
0x42, 0x61, 0x73, 0x65, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x13, 0x42, 0x61, 0x73, 0x65, 0x5c, 0x56,
0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x08,
0x42, 0x61, 0x73, 0x65, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
......@@ -1048,8 +1055,8 @@ var file_base_v1_resource_proto_goTypes = []interface{}{
(*StdTx)(nil), // 7: base.v1.StdTx
(*TxProof)(nil), // 8: base.v1.TxProof
(*Transaction)(nil), // 9: base.v1.Transaction
(*TransactionStd)(nil), // 10: base.v1.TransactionStd
(*TransactionEth)(nil), // 11: base.v1.TransactionEth
(*TransactionEth)(nil), // 10: base.v1.TransactionEth
(*TransactionStd)(nil), // 11: base.v1.TransactionStd
(*TransactionBytes)(nil), // 12: base.v1.TransactionBytes
(*timestamppb.Timestamp)(nil), // 13: google.protobuf.Timestamp
(*anypb.Any)(nil), // 14: google.protobuf.Any
......@@ -1065,10 +1072,10 @@ var file_base_v1_resource_proto_depIdxs = []int32{
13, // 7: base.v1.StdTx.time:type_name -> google.protobuf.Timestamp
8, // 8: base.v1.Transaction.tx_proof:type_name -> base.v1.TxProof
14, // 9: base.v1.Transaction.tx:type_name -> google.protobuf.Any
8, // 10: base.v1.TransactionStd.tx_proof:type_name -> base.v1.TxProof
7, // 11: base.v1.TransactionStd.tx:type_name -> base.v1.StdTx
8, // 12: base.v1.TransactionEth.tx_proof:type_name -> base.v1.TxProof
4, // 13: base.v1.TransactionEth.tx:type_name -> base.v1.EthTx
8, // 10: base.v1.TransactionEth.tx_proof:type_name -> base.v1.TxProof
4, // 11: base.v1.TransactionEth.tx:type_name -> base.v1.EthTx
8, // 12: base.v1.TransactionStd.tx_proof:type_name -> base.v1.TxProof
7, // 13: base.v1.TransactionStd.tx:type_name -> base.v1.StdTx
8, // 14: base.v1.TransactionBytes.tx_proof:type_name -> base.v1.TxProof
15, // [15:15] is the sub-list for method output_type
15, // [15:15] is the sub-list for method input_type
......@@ -1204,7 +1211,7 @@ func file_base_v1_resource_proto_init() {
}
}
file_base_v1_resource_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*TransactionStd); i {
switch v := v.(*TransactionEth); i {
case 0:
return &v.state
case 1:
......@@ -1216,7 +1223,7 @@ func file_base_v1_resource_proto_init() {
}
}
file_base_v1_resource_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*TransactionEth); i {
switch v := v.(*TransactionStd); i {
case 0:
return &v.state
case 1:
......
......@@ -33,58 +33,66 @@ var file_ring_v1_service_proto_rawDesc = []byte{
0x69, 0x6e, 0x67, 0x2f, 0x76, 0x31, 0x2f, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x5f, 0x72,
0x65, 0x71, 0x5f, 0x72, 0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x16, 0x62, 0x61,
0x73, 0x65, 0x2f, 0x76, 0x31, 0x2f, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x2e, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x32, 0xb3, 0x02, 0x0a, 0x0b, 0x52, 0x69, 0x6e, 0x67, 0x53, 0x65, 0x72,
0x76, 0x69, 0x63, 0x65, 0x12, 0x4b, 0x0a, 0x12, 0x53, 0x65, 0x6e, 0x64, 0x52, 0x61, 0x77, 0x54,
0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x0e, 0x2e, 0x62, 0x61, 0x73,
0x65, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x74, 0x68, 0x54, 0x78, 0x1a, 0x23, 0x2e, 0x72, 0x69, 0x6e,
0x72, 0x6f, 0x74, 0x6f, 0x32, 0x84, 0x03, 0x0a, 0x0b, 0x52, 0x69, 0x6e, 0x67, 0x53, 0x65, 0x72,
0x76, 0x69, 0x63, 0x65, 0x12, 0x4d, 0x0a, 0x0b, 0x53, 0x65, 0x6e, 0x64, 0x54, 0x78, 0x41, 0x73,
0x45, 0x74, 0x68, 0x12, 0x17, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x72,
0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x45, 0x74, 0x68, 0x1a, 0x23, 0x2e, 0x72,
0x69, 0x6e, 0x67, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x6e, 0x64, 0x52, 0x61, 0x77, 0x54, 0x72,
0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
0x65, 0x22, 0x00, 0x12, 0x4d, 0x0a, 0x0b, 0x53, 0x65, 0x6e, 0x64, 0x54, 0x78, 0x41, 0x73, 0x53,
0x74, 0x64, 0x12, 0x17, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x72, 0x61,
0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x64, 0x1a, 0x23, 0x2e, 0x72, 0x69,
0x6e, 0x67, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x6e, 0x64, 0x52, 0x61, 0x77, 0x54, 0x72, 0x61,
0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
0x22, 0x00, 0x12, 0x4a, 0x0a, 0x0b, 0x53, 0x65, 0x6e, 0x64, 0x54, 0x78, 0x41, 0x73, 0x41, 0x6e,
0x79, 0x12, 0x14, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x72, 0x61, 0x6e,
0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x1a, 0x23, 0x2e, 0x72, 0x69, 0x6e, 0x67, 0x2e, 0x76,
0x31, 0x2e, 0x53, 0x65, 0x6e, 0x64, 0x52, 0x61, 0x77, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63,
0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x51,
0x0a, 0x0d, 0x53, 0x65, 0x6e, 0x64, 0x54, 0x78, 0x41, 0x73, 0x42, 0x79, 0x74, 0x65, 0x73, 0x12,
0x19, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61,
0x63, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x79, 0x74, 0x65, 0x73, 0x1a, 0x23, 0x2e, 0x72, 0x69, 0x6e,
0x67, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x6e, 0x64, 0x52, 0x61, 0x77, 0x54, 0x72, 0x61, 0x6e,
0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22,
0x00, 0x12, 0x4a, 0x0a, 0x0b, 0x53, 0x65, 0x6e, 0x64, 0x54, 0x78, 0x41, 0x73, 0x41, 0x6e, 0x79,
0x12, 0x14, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73,
0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x1a, 0x23, 0x2e, 0x72, 0x69, 0x6e, 0x67, 0x2e, 0x76, 0x31,
0x2e, 0x53, 0x65, 0x6e, 0x64, 0x52, 0x61, 0x77, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74,
0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x51, 0x0a,
0x0d, 0x53, 0x65, 0x6e, 0x64, 0x54, 0x78, 0x41, 0x73, 0x42, 0x79, 0x74, 0x65, 0x73, 0x12, 0x19,
0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63,
0x74, 0x69, 0x6f, 0x6e, 0x42, 0x79, 0x74, 0x65, 0x73, 0x1a, 0x23, 0x2e, 0x72, 0x69, 0x6e, 0x67,
0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x6e, 0x64, 0x52, 0x61, 0x77, 0x54, 0x72, 0x61, 0x6e, 0x73,
0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00,
0x12, 0x38, 0x0a, 0x05, 0x4e, 0x6f, 0x6e, 0x63, 0x65, 0x12, 0x15, 0x2e, 0x72, 0x69, 0x6e, 0x67,
0x2e, 0x76, 0x31, 0x2e, 0x4e, 0x6f, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
0x1a, 0x16, 0x2e, 0x72, 0x69, 0x6e, 0x67, 0x2e, 0x76, 0x31, 0x2e, 0x4e, 0x6f, 0x6e, 0x63, 0x65,
0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0xa7, 0x01, 0x0a, 0x0b, 0x63,
0x6f, 0x6d, 0x2e, 0x72, 0x69, 0x6e, 0x67, 0x2e, 0x76, 0x31, 0x42, 0x0c, 0x53, 0x65, 0x72, 0x76,
0x69, 0x63, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x4d, 0x67, 0x69, 0x74, 0x68,
0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x43, 0x61, 0x64, 0x75, 0x63, 0x65, 0x75, 0x73, 0x4d,
0x65, 0x74, 0x61, 0x76, 0x65, 0x72, 0x73, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c,
0x2f, 0x6d, 0x65, 0x74, 0x61, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2f, 0x67, 0x65,
0x6e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6f, 0x2f, 0x72, 0x69, 0x6e, 0x67, 0x2f,
0x76, 0x31, 0x3b, 0x72, 0x69, 0x6e, 0x67, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x52, 0x58, 0x58, 0xaa,
0x02, 0x07, 0x52, 0x69, 0x6e, 0x67, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x07, 0x52, 0x69, 0x6e, 0x67,
0x5c, 0x56, 0x31, 0xe2, 0x02, 0x13, 0x52, 0x69, 0x6e, 0x67, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50,
0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x08, 0x52, 0x69, 0x6e, 0x67,
0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x00, 0x12, 0x38, 0x0a, 0x05, 0x4e, 0x6f, 0x6e, 0x63, 0x65, 0x12, 0x15, 0x2e, 0x72, 0x69, 0x6e,
0x67, 0x2e, 0x76, 0x31, 0x2e, 0x4e, 0x6f, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
0x74, 0x1a, 0x16, 0x2e, 0x72, 0x69, 0x6e, 0x67, 0x2e, 0x76, 0x31, 0x2e, 0x4e, 0x6f, 0x6e, 0x63,
0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0xa7, 0x01, 0x0a, 0x0b,
0x63, 0x6f, 0x6d, 0x2e, 0x72, 0x69, 0x6e, 0x67, 0x2e, 0x76, 0x31, 0x42, 0x0c, 0x53, 0x65, 0x72,
0x76, 0x69, 0x63, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x4d, 0x67, 0x69, 0x74,
0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x43, 0x61, 0x64, 0x75, 0x63, 0x65, 0x75, 0x73,
0x4d, 0x65, 0x74, 0x61, 0x76, 0x65, 0x72, 0x73, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f,
0x6c, 0x2f, 0x6d, 0x65, 0x74, 0x61, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2f, 0x67,
0x65, 0x6e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6f, 0x2f, 0x72, 0x69, 0x6e, 0x67,
0x2f, 0x76, 0x31, 0x3b, 0x72, 0x69, 0x6e, 0x67, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x52, 0x58, 0x58,
0xaa, 0x02, 0x07, 0x52, 0x69, 0x6e, 0x67, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x07, 0x52, 0x69, 0x6e,
0x67, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x13, 0x52, 0x69, 0x6e, 0x67, 0x5c, 0x56, 0x31, 0x5c, 0x47,
0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x08, 0x52, 0x69, 0x6e,
0x67, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var file_ring_v1_service_proto_goTypes = []interface{}{
(*v1.EthTx)(nil), // 0: base.v1.EthTx
(*v1.Transaction)(nil), // 1: base.v1.Transaction
(*v1.TransactionBytes)(nil), // 2: base.v1.TransactionBytes
(*NonceRequest)(nil), // 3: ring.v1.NonceRequest
(*SendRawTransactionResponse)(nil), // 4: ring.v1.SendRawTransactionResponse
(*NonceResponse)(nil), // 5: ring.v1.NonceResponse
(*v1.TransactionEth)(nil), // 0: base.v1.TransactionEth
(*v1.TransactionStd)(nil), // 1: base.v1.TransactionStd
(*v1.Transaction)(nil), // 2: base.v1.Transaction
(*v1.TransactionBytes)(nil), // 3: base.v1.TransactionBytes
(*NonceRequest)(nil), // 4: ring.v1.NonceRequest
(*SendRawTransactionResponse)(nil), // 5: ring.v1.SendRawTransactionResponse
(*NonceResponse)(nil), // 6: ring.v1.NonceResponse
}
var file_ring_v1_service_proto_depIdxs = []int32{
0, // 0: ring.v1.RingService.SendRawTransaction:input_type -> base.v1.EthTx
1, // 1: ring.v1.RingService.SendTxAsAny:input_type -> base.v1.Transaction
2, // 2: ring.v1.RingService.SendTxAsBytes:input_type -> base.v1.TransactionBytes
3, // 3: ring.v1.RingService.Nonce:input_type -> ring.v1.NonceRequest
4, // 4: ring.v1.RingService.SendRawTransaction:output_type -> ring.v1.SendRawTransactionResponse
4, // 5: ring.v1.RingService.SendTxAsAny:output_type -> ring.v1.SendRawTransactionResponse
4, // 6: ring.v1.RingService.SendTxAsBytes:output_type -> ring.v1.SendRawTransactionResponse
5, // 7: ring.v1.RingService.Nonce:output_type -> ring.v1.NonceResponse
4, // [4:8] is the sub-list for method output_type
0, // [0:4] is the sub-list for method input_type
0, // 0: ring.v1.RingService.SendTxAsEth:input_type -> base.v1.TransactionEth
1, // 1: ring.v1.RingService.SendTxAsStd:input_type -> base.v1.TransactionStd
2, // 2: ring.v1.RingService.SendTxAsAny:input_type -> base.v1.Transaction
3, // 3: ring.v1.RingService.SendTxAsBytes:input_type -> base.v1.TransactionBytes
4, // 4: ring.v1.RingService.Nonce:input_type -> ring.v1.NonceRequest
5, // 5: ring.v1.RingService.SendTxAsEth:output_type -> ring.v1.SendRawTransactionResponse
5, // 6: ring.v1.RingService.SendTxAsStd:output_type -> ring.v1.SendRawTransactionResponse
5, // 7: ring.v1.RingService.SendTxAsAny:output_type -> ring.v1.SendRawTransactionResponse
5, // 8: ring.v1.RingService.SendTxAsBytes:output_type -> ring.v1.SendRawTransactionResponse
6, // 9: ring.v1.RingService.Nonce:output_type -> ring.v1.NonceResponse
5, // [5:10] is the sub-list for method output_type
0, // [0:5] is the sub-list for method input_type
0, // [0:0] is the sub-list for extension type_name
0, // [0:0] is the sub-list for extension extendee
0, // [0:0] is the sub-list for field type_name
......
......@@ -24,7 +24,8 @@ const _ = grpc.SupportPackageIsVersion7
// 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 RingServiceClient interface {
// account info service
SendRawTransaction(ctx context.Context, in *v1.EthTx, opts ...grpc.CallOption) (*SendRawTransactionResponse, error)
SendTxAsEth(ctx context.Context, in *v1.TransactionEth, opts ...grpc.CallOption) (*SendRawTransactionResponse, error)
SendTxAsStd(ctx context.Context, in *v1.TransactionStd, opts ...grpc.CallOption) (*SendRawTransactionResponse, error)
SendTxAsAny(ctx context.Context, in *v1.Transaction, opts ...grpc.CallOption) (*SendRawTransactionResponse, error)
SendTxAsBytes(ctx context.Context, in *v1.TransactionBytes, opts ...grpc.CallOption) (*SendRawTransactionResponse, error)
// rpc SendRawTransaction(base.v1.EthTx) returns (SendRawTransactionResponse) {};
......@@ -39,9 +40,18 @@ func NewRingServiceClient(cc grpc.ClientConnInterface) RingServiceClient {
return &ringServiceClient{cc}
}
func (c *ringServiceClient) SendRawTransaction(ctx context.Context, in *v1.EthTx, opts ...grpc.CallOption) (*SendRawTransactionResponse, error) {
func (c *ringServiceClient) SendTxAsEth(ctx context.Context, in *v1.TransactionEth, opts ...grpc.CallOption) (*SendRawTransactionResponse, error) {
out := new(SendRawTransactionResponse)
err := c.cc.Invoke(ctx, "/ring.v1.RingService/SendRawTransaction", in, out, opts...)
err := c.cc.Invoke(ctx, "/ring.v1.RingService/SendTxAsEth", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *ringServiceClient) SendTxAsStd(ctx context.Context, in *v1.TransactionStd, opts ...grpc.CallOption) (*SendRawTransactionResponse, error) {
out := new(SendRawTransactionResponse)
err := c.cc.Invoke(ctx, "/ring.v1.RingService/SendTxAsStd", in, out, opts...)
if err != nil {
return nil, err
}
......@@ -80,7 +90,8 @@ func (c *ringServiceClient) Nonce(ctx context.Context, in *NonceRequest, opts ..
// for forward compatibility
type RingServiceServer interface {
// account info service
SendRawTransaction(context.Context, *v1.EthTx) (*SendRawTransactionResponse, error)
SendTxAsEth(context.Context, *v1.TransactionEth) (*SendRawTransactionResponse, error)
SendTxAsStd(context.Context, *v1.TransactionStd) (*SendRawTransactionResponse, error)
SendTxAsAny(context.Context, *v1.Transaction) (*SendRawTransactionResponse, error)
SendTxAsBytes(context.Context, *v1.TransactionBytes) (*SendRawTransactionResponse, error)
// rpc SendRawTransaction(base.v1.EthTx) returns (SendRawTransactionResponse) {};
......@@ -92,8 +103,11 @@ type RingServiceServer interface {
type UnimplementedRingServiceServer struct {
}
func (UnimplementedRingServiceServer) SendRawTransaction(context.Context, *v1.EthTx) (*SendRawTransactionResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method SendRawTransaction not implemented")
func (UnimplementedRingServiceServer) SendTxAsEth(context.Context, *v1.TransactionEth) (*SendRawTransactionResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method SendTxAsEth not implemented")
}
func (UnimplementedRingServiceServer) SendTxAsStd(context.Context, *v1.TransactionStd) (*SendRawTransactionResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method SendTxAsStd not implemented")
}
func (UnimplementedRingServiceServer) SendTxAsAny(context.Context, *v1.Transaction) (*SendRawTransactionResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method SendTxAsAny not implemented")
......@@ -117,20 +131,38 @@ func RegisterRingServiceServer(s grpc.ServiceRegistrar, srv RingServiceServer) {
s.RegisterService(&RingService_ServiceDesc, srv)
}
func _RingService_SendRawTransaction_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(v1.EthTx)
func _RingService_SendTxAsEth_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(v1.TransactionEth)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(RingServiceServer).SendRawTransaction(ctx, in)
return srv.(RingServiceServer).SendTxAsEth(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/ring.v1.RingService/SendRawTransaction",
FullMethod: "/ring.v1.RingService/SendTxAsEth",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(RingServiceServer).SendRawTransaction(ctx, req.(*v1.EthTx))
return srv.(RingServiceServer).SendTxAsEth(ctx, req.(*v1.TransactionEth))
}
return interceptor(ctx, in, info, handler)
}
func _RingService_SendTxAsStd_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(v1.TransactionStd)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(RingServiceServer).SendTxAsStd(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/ring.v1.RingService/SendTxAsStd",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(RingServiceServer).SendTxAsStd(ctx, req.(*v1.TransactionStd))
}
return interceptor(ctx, in, info, handler)
}
......@@ -197,8 +229,12 @@ var RingService_ServiceDesc = grpc.ServiceDesc{
HandlerType: (*RingServiceServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "SendRawTransaction",
Handler: _RingService_SendRawTransaction_Handler,
MethodName: "SendTxAsEth",
Handler: _RingService_SendTxAsEth_Handler,
},
{
MethodName: "SendTxAsStd",
Handler: _RingService_SendTxAsStd_Handler,
},
{
MethodName: "SendTxAsAny",
......
......@@ -4,6 +4,7 @@ import (
"context"
"crypto/ecdsa"
"fmt"
"sync"
//"encoding/hex"
"math/big"
......@@ -33,7 +34,12 @@ type RingServer struct {
ring.UnimplementedRingServiceServer
}
func (*RingServer) SendRawTransaction(ctx context.Context, req *base.EthTx) (*ring.SendRawTransactionResponse, error) {
func (*RingServer) SendTxAsEth(ctx context.Context, req *base.TransactionEth) (*ring.SendRawTransactionResponse, error) {
return &ring.SendRawTransactionResponse{}, nil
}
func (*RingServer) SendTxAsStd(ctx context.Context, req *base.TransactionStd) (*ring.SendRawTransactionResponse, error) {
return &ring.SendRawTransactionResponse{}, nil
}
......@@ -50,8 +56,6 @@ func (*RingServer) SendTxAsBytes(ctx context.Context, req *base.TransactionBytes
func TestGrpcServer(t *testing.T) {
//onceFunc := func() {
lis, err := net.Listen("tcp", ":9006")
if err != nil {
t.Fatal(err)
......@@ -61,16 +65,10 @@ func TestGrpcServer(t *testing.T) {
ring.RegisterRingServiceServer(s, &RingServer{})
//go func() {
err = s.Serve(lis)
if err != nil {
t.Fatal(err)
}
//}()
//}
//once.Do(onceFunc)
}
func pricedTransaction(to common.Address, nonce uint64, gaslimit uint64, gasprice *big.Int, key *ecdsa.PrivateKey) *types.Transaction {
......@@ -84,7 +82,30 @@ func pricedTransaction(to common.Address, nonce uint64, gaslimit uint64, gaspric
//BenchmarkAny
// go test -v -run Any -bench=. -benchtime=3s
func BenchmarkAny(b *testing.B) {
var once sync.Once
var tx *types.Transaction
var fromAddr common.Address
// var local, remote *ecdsa.PrivateKey
func int() {
local, _ := crypto.HexToECDSA("FD5CC6F5E7E2805E920AC5DC83D5AF1106F9C92F0C04F9D5E1FD4261B4B4464A")
publicKey := local.Public()
publicKeyECDSA, _ := publicKey.(*ecdsa.PublicKey)
fromAddr = crypto.PubkeyToAddress(*publicKeyECDSA)
//b.Log(fromAddress)
remote, _ := crypto.GenerateKey()
tx = pricedTransaction(crypto.PubkeyToAddress(remote.PublicKey), 0, 100000, big.NewInt(1), local)
}
func BenchmarkEthTx(b *testing.B) {
b.ReportAllocs()
b.RunParallel(func(pb *testing.PB) {
......@@ -102,17 +123,6 @@ func BenchmarkAny(b *testing.B) {
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
defer cancel()
local, _ := crypto.HexToECDSA("FD5CC6F5E7E2805E920AC5DC83D5AF1106F9C92F0C04F9D5E1FD4261B4B4464A")
//publicKey := local.Public()
//publicKeyECDSA, _ := publicKey.(*ecdsa.PublicKey)
//fromAddress := crypto.PubkeyToAddress(*publicKeyECDSA)
//b.Log(fromAddress)
remote, _ := crypto.GenerateKey()
tx := pricedTransaction(crypto.PubkeyToAddress(remote.PublicKey), 0, 100000, big.NewInt(1), local)
inner := base.EthTxData{
AccountNonce: tx.Nonce(),
Price: tx.GasPrice().Bytes(),
......@@ -130,22 +140,9 @@ func BenchmarkAny(b *testing.B) {
addr := base.Address{Address: tx.To().Bytes()}
inner.Recipient = &addr
inner.From = fromAddr.Bytes()
// Each goroutine has its own bytes.Buffer.
// The loop body is executed b.N times total across all goroutines.
ethTx := base.EthTx{Inner: &inner}
ethTxAsAny, err := pbany(ethTx)
c.SendTxAsAny(ctx, &base.Transaction{Tx: ethTxAsAny})
res, err := c.SendRawTransaction(ctx, &base.EthTx{Inner: &inner})
if err != nil {
b.Fatal(err)
}
res, err := c.SendTxAsEth(ctx, &base.TransactionEth{Tx: &base.EthTx{Inner: &inner}})
if err != nil {
b.Fatal(err)
......@@ -153,21 +150,12 @@ func BenchmarkAny(b *testing.B) {
_ = res
//b.Logf("Greeting: %v\n", res)
}
})
}
func pbany(v interface{}) (*anypb.Any, error) {
pv, ok := v.(proto.Message)
if !ok {
return &anypb.Any{}, fmt.Errorf("%v is not proto.Message", pv)
}
return anypb.New(pv)
}
func BenchmarkStdTx(b *testing.B) {
func BenchmarkEthTx(b *testing.B) {
b.ReportAllocs()
b.RunParallel(func(pb *testing.PB) {
......@@ -185,18 +173,7 @@ func BenchmarkEthTx(b *testing.B) {
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
defer cancel()
local, _ := crypto.HexToECDSA("FD5CC6F5E7E2805E920AC5DC83D5AF1106F9C92F0C04F9D5E1FD4261B4B4464A")
//publicKey := local.Public()
//publicKeyECDSA, _ := publicKey.(*ecdsa.PublicKey)
//fromAddress := crypto.PubkeyToAddress(*publicKeyECDSA)
//b.Log(fromAddress)
remote, _ := crypto.GenerateKey()
tx := pricedTransaction(crypto.PubkeyToAddress(remote.PublicKey), 0, 100000, big.NewInt(1), local)
inner := base.EthTxData{
inner := base.StdTxData{
AccountNonce: tx.Nonce(),
Price: tx.GasPrice().Bytes(),
GasLimit: tx.Gas(),
......@@ -213,12 +190,9 @@ func BenchmarkEthTx(b *testing.B) {
addr := base.Address{Address: tx.To().Bytes()}
inner.Recipient = &addr
inner.From = fromAddr.Bytes()
// Each goroutine has its own bytes.Buffer.
// The loop body is executed b.N times total across all goroutines.
res, err := c.SendRawTransaction(ctx, &base.EthTx{Inner: &inner})
res, err := c.SendTxAsStd(ctx, &base.TransactionStd{Tx: &base.StdTx{Inner: &inner}})
if err != nil {
b.Fatal(err)
......@@ -226,15 +200,16 @@ func BenchmarkEthTx(b *testing.B) {
_ = res
//b.Logf("Greeting: %v\n", res)
}
})
}
func BenchmarkBytes(b *testing.B) {
func BenchmarkAnyTx(b *testing.B) {
b.ReportAllocs()
// The loop body is executed b.N times total across all goroutines.
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
......@@ -250,40 +225,66 @@ func BenchmarkBytes(b *testing.B) {
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
defer cancel()
local, _ := crypto.HexToECDSA("FD5CC6F5E7E2805E920AC5DC83D5AF1106F9C92F0C04F9D5E1FD4261B4B4464A")
inner := base.EthTxData{
AccountNonce: tx.Nonce(),
Price: tx.GasPrice().Bytes(),
GasLimit: tx.Gas(),
Payload: tx.Data(),
}
v, r, sigs := tx.RawSignatureValues()
//publicKey := local.Public()
//publicKeyECDSA, _ := publicKey.(*ecdsa.PublicKey)
//fromAddress := crypto.PubkeyToAddress(*publicKeyECDSA)
//b.Log(fromAddress)
inner.V = v.Bytes()
inner.R = r.Bytes()
inner.S = sigs.Bytes()
inner.Amount = tx.Value().Bytes()
addr := base.Address{Address: tx.To().Bytes()}
inner.Recipient = &addr
ethTx := base.EthTx{Inner: &inner}
ethTxAsAny, err := pbany(ethTx)
res, err := c.SendTxAsAny(ctx, &base.Transaction{Tx: ethTxAsAny})
if err != nil {
b.Fatal(err)
}
remote, _ := crypto.GenerateKey()
_ = res
tx := pricedTransaction(crypto.PubkeyToAddress(remote.PublicKey), 0, 100000, big.NewInt(1), local)
}
})
}
// inner := base.EthTxData{
// AccountNonce: tx.Nonce(),
// Price: tx.GasPrice().Bytes(),
// GasLimit: tx.Gas(),
// Payload: tx.Data(),
// }
func pbany(v interface{}) (*anypb.Any, error) {
pv, ok := v.(proto.Message)
if !ok {
return &anypb.Any{}, fmt.Errorf("%v is not proto.Message", pv)
}
return anypb.New(pv)
}
// v, r, sigs := tx.RawSignatureValues()
func BenchmarkBytesEth(b *testing.B) {
// inner.V = v.Bytes()
// inner.R = r.Bytes()
// inner.S = sigs.Bytes()
// inner.Amount = tx.Value().Bytes()
b.ReportAllocs()
// addr := base.Address{Address: tx.To().Bytes()}
b.RunParallel(func(pb *testing.PB) {
// inner.Recipient = &addr
for pb.Next() {
// Each goroutine has its own bytes.Buffer.
conn, err := grpc.Dial("127.0.0.1:9006", grpc.WithTransportCredentials(insecure.NewCredentials()))
if err != nil {
b.Fatal(err)
}
defer conn.Close()
// The loop body is executed b.N times total across all goroutines.
c := ring.NewRingServiceClient(conn)
//res, err := c.SendRawTransaction(ctx, &base.EthTx{Inner: &inner})
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
defer cancel()
txAsBytes, err := tx.MarshalBinary()
......@@ -291,7 +292,7 @@ func BenchmarkBytes(b *testing.B) {
b.Fatal(err)
}
res, err := c.SendTxAsBytes(ctx, &base.TransactionBytes{Tx: txAsBytes})
res, err := c.SendTxAsBytes(ctx, &base.TransactionBytes{Tx: txAsBytes, From: fromAddr[:]})
if err != nil {
b.Fatal(err)
......@@ -299,8 +300,6 @@ func BenchmarkBytes(b *testing.B) {
_ = res
//b.Logf("Greeting: %v\n", res)
}
})
}
......@@ -35,7 +35,6 @@ type TxCheckServer struct {
txchecker.UnimplementedTxCheckerServiceServer
}
type RingServer struct {
metaring.UnimplementedRingServiceServer
}
......
......@@ -10,10 +10,11 @@ import "base/v1/resource.proto";
service RingService{
// account info service
rpc SendRawTransaction(base.v1.EthTx) returns (SendRawTransactionResponse) {};
rpc SendTxAsEth(base.v1.TransactionEth) returns (SendRawTransactionResponse) {};
rpc SendTxAsAny(base.v1.Transaction) returns (SendRawTransactionResponse) {};
rpc SendTxAsStd(base.v1.TransactionStd) returns (SendRawTransactionResponse) {};
rpc SendTxAsAny(base.v1.Transaction) returns (SendRawTransactionResponse) {};
rpc SendTxAsBytes(base.v1.TransactionBytes) returns (SendRawTransactionResponse) {};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment