Commit 19de5d65 authored by Ubuntu's avatar Ubuntu

add tx as any grpc

parent e6fdb174
...@@ -94,13 +94,13 @@ message Transaction{ ...@@ -94,13 +94,13 @@ message Transaction{
message TransactionStd{ message TransactionStd{
TxProof tx_proof=1; TxProof tx_proof=1;
int64 timeout_block_num =2; int64 timeout_block_num =2;
EthTx tx =3; StdTx tx =3;
} }
message TransactionEth{ message TransactionEth{
TxProof tx_proof=1; TxProof tx_proof=1;
int64 timeout_block_num =2; int64 timeout_block_num =2;
StdTx tx =3; EthTx tx =3;
} }
//3. bytes //3. bytes
......
...@@ -720,7 +720,7 @@ type TransactionStd struct { ...@@ -720,7 +720,7 @@ type TransactionStd struct {
TxProof *TxProof `protobuf:"bytes,1,opt,name=tx_proof,json=txProof,proto3" json:"tx_proof,omitempty"` 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"` 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 *TransactionStd) Reset() { func (x *TransactionStd) Reset() {
...@@ -769,7 +769,7 @@ func (x *TransactionStd) GetTimeoutBlockNum() int64 { ...@@ -769,7 +769,7 @@ func (x *TransactionStd) GetTimeoutBlockNum() int64 {
return 0 return 0
} }
func (x *TransactionStd) GetTx() *EthTx { func (x *TransactionStd) GetTx() *StdTx {
if x != nil { if x != nil {
return x.Tx return x.Tx
} }
...@@ -783,7 +783,7 @@ type TransactionEth struct { ...@@ -783,7 +783,7 @@ type TransactionEth struct {
TxProof *TxProof `protobuf:"bytes,1,opt,name=tx_proof,json=txProof,proto3" json:"tx_proof,omitempty"` 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"` 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 *TransactionEth) Reset() { func (x *TransactionEth) Reset() {
...@@ -832,7 +832,7 @@ func (x *TransactionEth) GetTimeoutBlockNum() int64 { ...@@ -832,7 +832,7 @@ func (x *TransactionEth) GetTimeoutBlockNum() int64 {
return 0 return 0
} }
func (x *TransactionEth) GetTx() *StdTx { func (x *TransactionEth) GetTx() *EthTx {
if x != nil { if x != nil {
return x.Tx return x.Tx
} }
...@@ -993,7 +993,7 @@ var file_base_v1_resource_proto_rawDesc = []byte{ ...@@ -993,7 +993,7 @@ var file_base_v1_resource_proto_rawDesc = []byte{
0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x6e, 0x75, 0x6d, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0f, 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, 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, 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, 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, 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, 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, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x54,
...@@ -1002,7 +1002,7 @@ var file_base_v1_resource_proto_rawDesc = []byte{ ...@@ -1002,7 +1002,7 @@ var file_base_v1_resource_proto_rawDesc = []byte{
0x5f, 0x6e, 0x75, 0x6d, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0f, 0x74, 0x69, 0x6d, 0x65, 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, 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, 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, 0x7b, 0x0a, 0x10, 0x54, 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, 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, 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, 0x0b, 0x32, 0x10, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x78, 0x50, 0x72,
...@@ -1066,9 +1066,9 @@ var file_base_v1_resource_proto_depIdxs = []int32{ ...@@ -1066,9 +1066,9 @@ var file_base_v1_resource_proto_depIdxs = []int32{
8, // 8: base.v1.Transaction.tx_proof:type_name -> base.v1.TxProof 8, // 8: base.v1.Transaction.tx_proof:type_name -> base.v1.TxProof
14, // 9: base.v1.Transaction.tx:type_name -> google.protobuf.Any 14, // 9: base.v1.Transaction.tx:type_name -> google.protobuf.Any
8, // 10: base.v1.TransactionStd.tx_proof:type_name -> base.v1.TxProof 8, // 10: base.v1.TransactionStd.tx_proof:type_name -> base.v1.TxProof
4, // 11: base.v1.TransactionStd.tx:type_name -> base.v1.EthTx 7, // 11: base.v1.TransactionStd.tx:type_name -> base.v1.StdTx
8, // 12: base.v1.TransactionEth.tx_proof:type_name -> base.v1.TxProof 8, // 12: base.v1.TransactionEth.tx_proof:type_name -> base.v1.TxProof
7, // 13: base.v1.TransactionEth.tx:type_name -> base.v1.StdTx 4, // 13: base.v1.TransactionEth.tx:type_name -> base.v1.EthTx
8, // 14: base.v1.TransactionBytes.tx_proof:type_name -> base.v1.TxProof 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 output_type
15, // [15:15] is the sub-list for method input_type 15, // [15:15] is the sub-list for method input_type
......
...@@ -33,42 +33,50 @@ var file_ring_v1_service_proto_rawDesc = []byte{ ...@@ -33,42 +33,50 @@ var file_ring_v1_service_proto_rawDesc = []byte{
0x69, 0x6e, 0x67, 0x2f, 0x76, 0x31, 0x2f, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x5f, 0x72, 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, 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, 0x73, 0x65, 0x2f, 0x76, 0x31, 0x2f, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x2e, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x32, 0x94, 0x01, 0x0a, 0x0b, 0x52, 0x69, 0x6e, 0x67, 0x53, 0x65, 0x72, 0x72, 0x6f, 0x74, 0x6f, 0x32, 0xe0, 0x01, 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, 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, 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, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x74, 0x68, 0x54, 0x78, 0x1a, 0x23, 0x2e, 0x72, 0x69, 0x6e,
0x67, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x6e, 0x64, 0x52, 0x61, 0x77, 0x54, 0x72, 0x61, 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, 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, 0x00, 0x12, 0x4a, 0x0a, 0x0b, 0x53, 0x65, 0x6e, 0x64, 0x54, 0x78, 0x41, 0x73, 0x41, 0x6e, 0x79,
0x67, 0x2e, 0x76, 0x31, 0x2e, 0x4e, 0x6f, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x12, 0x14, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73,
0x74, 0x1a, 0x16, 0x2e, 0x72, 0x69, 0x6e, 0x67, 0x2e, 0x76, 0x31, 0x2e, 0x4e, 0x6f, 0x6e, 0x63, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x1a, 0x23, 0x2e, 0x72, 0x69, 0x6e, 0x67, 0x2e, 0x76, 0x31,
0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0xa7, 0x01, 0x0a, 0x0b, 0x2e, 0x53, 0x65, 0x6e, 0x64, 0x52, 0x61, 0x77, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74,
0x63, 0x6f, 0x6d, 0x2e, 0x72, 0x69, 0x6e, 0x67, 0x2e, 0x76, 0x31, 0x42, 0x0c, 0x53, 0x65, 0x72, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x38, 0x0a,
0x76, 0x69, 0x63, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x4d, 0x67, 0x69, 0x74, 0x05, 0x4e, 0x6f, 0x6e, 0x63, 0x65, 0x12, 0x15, 0x2e, 0x72, 0x69, 0x6e, 0x67, 0x2e, 0x76, 0x31,
0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x43, 0x61, 0x64, 0x75, 0x63, 0x65, 0x75, 0x73, 0x2e, 0x4e, 0x6f, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e,
0x4d, 0x65, 0x74, 0x61, 0x76, 0x65, 0x72, 0x73, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x72, 0x69, 0x6e, 0x67, 0x2e, 0x76, 0x31, 0x2e, 0x4e, 0x6f, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x73,
0x6c, 0x2f, 0x6d, 0x65, 0x74, 0x61, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2f, 0x67, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0xa7, 0x01, 0x0a, 0x0b, 0x63, 0x6f, 0x6d, 0x2e,
0x65, 0x6e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6f, 0x2f, 0x72, 0x69, 0x6e, 0x67, 0x72, 0x69, 0x6e, 0x67, 0x2e, 0x76, 0x31, 0x42, 0x0c, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65,
0x2f, 0x76, 0x31, 0x3b, 0x72, 0x69, 0x6e, 0x67, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x52, 0x58, 0x58, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x4d, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e,
0xaa, 0x02, 0x07, 0x52, 0x69, 0x6e, 0x67, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x07, 0x52, 0x69, 0x6e, 0x63, 0x6f, 0x6d, 0x2f, 0x43, 0x61, 0x64, 0x75, 0x63, 0x65, 0x75, 0x73, 0x4d, 0x65, 0x74, 0x61,
0x67, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x13, 0x52, 0x69, 0x6e, 0x67, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x76, 0x65, 0x72, 0x73, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2f, 0x6d, 0x65,
0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x08, 0x52, 0x69, 0x6e, 0x74, 0x61, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x70,
0x67, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 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{}{ var file_ring_v1_service_proto_goTypes = []interface{}{
(*v1.EthTx)(nil), // 0: base.v1.EthTx (*v1.EthTx)(nil), // 0: base.v1.EthTx
(*NonceRequest)(nil), // 1: ring.v1.NonceRequest (*v1.Transaction)(nil), // 1: base.v1.Transaction
(*SendRawTransactionResponse)(nil), // 2: ring.v1.SendRawTransactionResponse (*NonceRequest)(nil), // 2: ring.v1.NonceRequest
(*NonceResponse)(nil), // 3: ring.v1.NonceResponse (*SendRawTransactionResponse)(nil), // 3: ring.v1.SendRawTransactionResponse
(*NonceResponse)(nil), // 4: ring.v1.NonceResponse
} }
var file_ring_v1_service_proto_depIdxs = []int32{ var file_ring_v1_service_proto_depIdxs = []int32{
0, // 0: ring.v1.RingService.SendRawTransaction:input_type -> base.v1.EthTx 0, // 0: ring.v1.RingService.SendRawTransaction:input_type -> base.v1.EthTx
1, // 1: ring.v1.RingService.Nonce:input_type -> ring.v1.NonceRequest 1, // 1: ring.v1.RingService.SendTxAsAny:input_type -> base.v1.Transaction
2, // 2: ring.v1.RingService.SendRawTransaction:output_type -> ring.v1.SendRawTransactionResponse 2, // 2: ring.v1.RingService.Nonce:input_type -> ring.v1.NonceRequest
3, // 3: ring.v1.RingService.Nonce:output_type -> ring.v1.NonceResponse 3, // 3: ring.v1.RingService.SendRawTransaction:output_type -> ring.v1.SendRawTransactionResponse
2, // [2:4] is the sub-list for method output_type 3, // 4: ring.v1.RingService.SendTxAsAny:output_type -> ring.v1.SendRawTransactionResponse
0, // [0:2] is the sub-list for method input_type 4, // 5: ring.v1.RingService.Nonce:output_type -> ring.v1.NonceResponse
3, // [3:6] is the sub-list for method output_type
0, // [0:3] 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 type_name
0, // [0:0] is the sub-list for extension extendee 0, // [0:0] is the sub-list for extension extendee
0, // [0:0] is the sub-list for field type_name 0, // [0:0] is the sub-list for field type_name
......
...@@ -25,6 +25,8 @@ const _ = grpc.SupportPackageIsVersion7 ...@@ -25,6 +25,8 @@ const _ = grpc.SupportPackageIsVersion7
type RingServiceClient interface { type RingServiceClient interface {
// account info service // account info service
SendRawTransaction(ctx context.Context, in *v1.EthTx, opts ...grpc.CallOption) (*SendRawTransactionResponse, error) SendRawTransaction(ctx context.Context, in *v1.EthTx, opts ...grpc.CallOption) (*SendRawTransactionResponse, error)
SendTxAsAny(ctx context.Context, in *v1.Transaction, opts ...grpc.CallOption) (*SendRawTransactionResponse, error)
// rpc SendRawTransaction(base.v1.EthTx) returns (SendRawTransactionResponse) {};
Nonce(ctx context.Context, in *NonceRequest, opts ...grpc.CallOption) (*NonceResponse, error) Nonce(ctx context.Context, in *NonceRequest, opts ...grpc.CallOption) (*NonceResponse, error)
} }
...@@ -45,6 +47,15 @@ func (c *ringServiceClient) SendRawTransaction(ctx context.Context, in *v1.EthTx ...@@ -45,6 +47,15 @@ func (c *ringServiceClient) SendRawTransaction(ctx context.Context, in *v1.EthTx
return out, nil return out, nil
} }
func (c *ringServiceClient) SendTxAsAny(ctx context.Context, in *v1.Transaction, opts ...grpc.CallOption) (*SendRawTransactionResponse, error) {
out := new(SendRawTransactionResponse)
err := c.cc.Invoke(ctx, "/ring.v1.RingService/SendTxAsAny", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *ringServiceClient) Nonce(ctx context.Context, in *NonceRequest, opts ...grpc.CallOption) (*NonceResponse, error) { func (c *ringServiceClient) Nonce(ctx context.Context, in *NonceRequest, opts ...grpc.CallOption) (*NonceResponse, error) {
out := new(NonceResponse) out := new(NonceResponse)
err := c.cc.Invoke(ctx, "/ring.v1.RingService/Nonce", in, out, opts...) err := c.cc.Invoke(ctx, "/ring.v1.RingService/Nonce", in, out, opts...)
...@@ -60,6 +71,8 @@ func (c *ringServiceClient) Nonce(ctx context.Context, in *NonceRequest, opts .. ...@@ -60,6 +71,8 @@ func (c *ringServiceClient) Nonce(ctx context.Context, in *NonceRequest, opts ..
type RingServiceServer interface { type RingServiceServer interface {
// account info service // account info service
SendRawTransaction(context.Context, *v1.EthTx) (*SendRawTransactionResponse, error) SendRawTransaction(context.Context, *v1.EthTx) (*SendRawTransactionResponse, error)
SendTxAsAny(context.Context, *v1.Transaction) (*SendRawTransactionResponse, error)
// rpc SendRawTransaction(base.v1.EthTx) returns (SendRawTransactionResponse) {};
Nonce(context.Context, *NonceRequest) (*NonceResponse, error) Nonce(context.Context, *NonceRequest) (*NonceResponse, error)
mustEmbedUnimplementedRingServiceServer() mustEmbedUnimplementedRingServiceServer()
} }
...@@ -71,6 +84,9 @@ type UnimplementedRingServiceServer struct { ...@@ -71,6 +84,9 @@ type UnimplementedRingServiceServer struct {
func (UnimplementedRingServiceServer) SendRawTransaction(context.Context, *v1.EthTx) (*SendRawTransactionResponse, error) { func (UnimplementedRingServiceServer) SendRawTransaction(context.Context, *v1.EthTx) (*SendRawTransactionResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method SendRawTransaction not implemented") return nil, status.Errorf(codes.Unimplemented, "method SendRawTransaction not implemented")
} }
func (UnimplementedRingServiceServer) SendTxAsAny(context.Context, *v1.Transaction) (*SendRawTransactionResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method SendTxAsAny not implemented")
}
func (UnimplementedRingServiceServer) Nonce(context.Context, *NonceRequest) (*NonceResponse, error) { func (UnimplementedRingServiceServer) Nonce(context.Context, *NonceRequest) (*NonceResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method Nonce not implemented") return nil, status.Errorf(codes.Unimplemented, "method Nonce not implemented")
} }
...@@ -105,6 +121,24 @@ func _RingService_SendRawTransaction_Handler(srv interface{}, ctx context.Contex ...@@ -105,6 +121,24 @@ func _RingService_SendRawTransaction_Handler(srv interface{}, ctx context.Contex
return interceptor(ctx, in, info, handler) return interceptor(ctx, in, info, handler)
} }
func _RingService_SendTxAsAny_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(v1.Transaction)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(RingServiceServer).SendTxAsAny(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/ring.v1.RingService/SendTxAsAny",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(RingServiceServer).SendTxAsAny(ctx, req.(*v1.Transaction))
}
return interceptor(ctx, in, info, handler)
}
func _RingService_Nonce_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { func _RingService_Nonce_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(NonceRequest) in := new(NonceRequest)
if err := dec(in); err != nil { if err := dec(in); err != nil {
...@@ -134,6 +168,10 @@ var RingService_ServiceDesc = grpc.ServiceDesc{ ...@@ -134,6 +168,10 @@ var RingService_ServiceDesc = grpc.ServiceDesc{
MethodName: "SendRawTransaction", MethodName: "SendRawTransaction",
Handler: _RingService_SendRawTransaction_Handler, Handler: _RingService_SendRawTransaction_Handler,
}, },
{
MethodName: "SendTxAsAny",
Handler: _RingService_SendTxAsAny_Handler,
},
{ {
MethodName: "Nonce", MethodName: "Nonce",
Handler: _RingService_Nonce_Handler, Handler: _RingService_Nonce_Handler,
......
...@@ -3,6 +3,7 @@ package main_test ...@@ -3,6 +3,7 @@ package main_test
import ( import (
"context" "context"
"crypto/ecdsa" "crypto/ecdsa"
"fmt"
//"encoding/hex" //"encoding/hex"
"math/big" "math/big"
...@@ -10,10 +11,10 @@ import ( ...@@ -10,10 +11,10 @@ import (
"testing" "testing"
"time" "time"
"sync"
"google.golang.org/grpc" "google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure" "google.golang.org/grpc/credentials/insecure"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/types/known/anypb"
base "github.com/CaduceusMetaverseProtocol/metaprotocol/gen/proto/go/base/v1" base "github.com/CaduceusMetaverseProtocol/metaprotocol/gen/proto/go/base/v1"
ring "github.com/CaduceusMetaverseProtocol/metaprotocol/gen/proto/go/ring/v1" ring "github.com/CaduceusMetaverseProtocol/metaprotocol/gen/proto/go/ring/v1"
...@@ -34,41 +35,52 @@ type RingServer struct { ...@@ -34,41 +35,52 @@ type RingServer struct {
func (*RingServer) SendRawTransaction(ctx context.Context, req *base.EthTx) (*ring.SendRawTransactionResponse, error) { func (*RingServer) SendRawTransaction(ctx context.Context, req *base.EthTx) (*ring.SendRawTransactionResponse, error) {
// txHashAsBytes, err := hex.DecodeString("0xba8e1c42813d24f48b4c785fb893dcf9d9635c660701af1a7f84734f320e8dea") return &ring.SendRawTransactionResponse{}, nil
}
// if err != nil { func (*RingServer) SendTxAsAny(ctx context.Context, req *base.Transaction) (*ring.SendRawTransactionResponse, error) {
// return nil, err
// }
// _ = txHashAsBytes
return &ring.SendRawTransactionResponse{}, nil return &ring.SendRawTransactionResponse{}, nil
} }
var once sync.Once func TestGrpcServer(t *testing.T) {
func BenchmarkEthTx(b *testing.B) {
b.ReportAllocs()
onceFunc := func() { //onceFunc := func() {
lis, err := net.Listen("tcp", ":9006") lis, err := net.Listen("tcp", ":9006")
if err != nil { if err != nil {
b.Fatal(err) t.Fatal(err)
} }
s := grpc.NewServer() s := grpc.NewServer()
ring.RegisterRingServiceServer(s, &RingServer{}) ring.RegisterRingServiceServer(s, &RingServer{})
go func() { //go func() {
err = s.Serve(lis) err = s.Serve(lis)
if err != nil { if err != nil {
b.Fatal(err) t.Fatal(err)
}
}()
} }
//}()
//}
//once.Do(onceFunc)
}
once.Do(onceFunc) func pricedTransaction(to common.Address, nonce uint64, gaslimit uint64, gasprice *big.Int, key *ecdsa.PrivateKey) *types.Transaction {
tx, _ := types.SignTx(types.NewTransaction(nonce, to, big.NewInt(100), gaslimit, gasprice, nil), types.HomesteadSigner{}, key)
return tx
}
// go test -v -run EthTx -bench=. -benchtime=3s
// go test -v -run TestGrpcServer -timeout 0
//BenchmarkAny
// go test -v -run Any -bench=. -benchtime=3s
func BenchmarkAny(b *testing.B) {
b.ReportAllocs()
b.RunParallel(func(pb *testing.PB) { b.RunParallel(func(pb *testing.PB) {
...@@ -118,12 +130,22 @@ func BenchmarkEthTx(b *testing.B) { ...@@ -118,12 +130,22 @@ func BenchmarkEthTx(b *testing.B) {
// The loop body is executed b.N times total across all goroutines. // 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}) res, err := c.SendRawTransaction(ctx, &base.EthTx{Inner: &inner})
if err != nil { if err != nil {
b.Fatal(err) b.Fatal(err)
} }
if err != nil {
b.Fatal(err)
}
_ = res _ = res
//b.Logf("Greeting: %v\n", res) //b.Logf("Greeting: %v\n", res)
...@@ -132,9 +154,75 @@ func BenchmarkEthTx(b *testing.B) { ...@@ -132,9 +154,75 @@ func BenchmarkEthTx(b *testing.B) {
}) })
} }
func pricedTransaction(to common.Address, nonce uint64, gaslimit uint64, gasprice *big.Int, key *ecdsa.PrivateKey) *types.Transaction { func pbany(v interface{}) (*anypb.Any, error) {
tx, _ := types.SignTx(types.NewTransaction(nonce, to, big.NewInt(100), gaslimit, gasprice, nil), types.HomesteadSigner{}, key) pv, ok := v.(proto.Message)
return tx if !ok {
return &anypb.Any{}, fmt.Errorf("%v is not proto.Message", pv)
}
return anypb.New(pv)
} }
// go test -bench=. func BenchmarkEthTx(b *testing.B) {
b.ReportAllocs()
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
conn, err := grpc.Dial("127.0.0.1:9006", grpc.WithTransportCredentials(insecure.NewCredentials()))
if err != nil {
b.Fatal(err)
}
defer conn.Close()
c := ring.NewRingServiceClient(conn)
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(),
GasLimit: tx.Gas(),
Payload: tx.Data(),
}
v, r, sigs := tx.RawSignatureValues()
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
// 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})
if err != nil {
b.Fatal(err)
}
_ = res
//b.Logf("Greeting: %v\n", res)
}
})
}
...@@ -11,6 +11,10 @@ service RingService{ ...@@ -11,6 +11,10 @@ service RingService{
// account info service // account info service
rpc SendRawTransaction(base.v1.EthTx) returns (SendRawTransactionResponse) {}; rpc SendRawTransaction(base.v1.EthTx) returns (SendRawTransactionResponse) {};
rpc SendTxAsAny(base.v1.Transaction) returns (SendRawTransactionResponse) {};
//rpc SendRawTransaction(base.v1.EthTx) returns (SendRawTransactionResponse) {};
rpc Nonce(NonceRequest) returns (NonceResponse) {}; rpc Nonce(NonceRequest) returns (NonceResponse) {};
} }
\ No newline at end of file
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