Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
MetaProtocol
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nebula
MetaProtocol
Commits
f2a034dd
Commit
f2a034dd
authored
Nov 30, 2022
by
Ubuntu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
generate tx in init func
parent
ccb54d9b
Changes
7
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
273 additions
and
217 deletions
+273
-217
resource.proto
baseapi/base/v1/resource.proto
+11
-5
resource.pb.go
gen/proto/go/base/v1/resource.pb.go
+66
-59
service.pb.go
gen/proto/go/ring/v1/service.pb.go
+53
-45
service_grpc.pb.go
gen/proto/go/ring/v1/service_grpc.pb.go
+49
-13
grcp-tx_test.go
grcp-tx_test.go
+91
-92
main.go
main.go
+0
-1
service.proto
ringapi/ring/v1/service.proto
+3
-2
No files found.
baseapi/base/v1/resource.proto
View file @
f2a034dd
...
...
@@ -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
;
}
...
...
gen/proto/go/base/v1/resource.pb.go
View file @
f2a034dd
This diff is collapsed.
Click to expand it.
gen/proto/go/ring/v1/service.pb.go
View file @
f2a034dd
...
...
@@ -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
...
...
gen/proto/go/ring/v1/service_grpc.pb.go
View file @
f2a034dd
...
...
@@ -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
)
Send
RawTransaction
(
ctx
context
.
Context
,
in
*
v1
.
EthTx
,
opts
...
grpc
.
CallOption
)
(
*
SendRawTransactionResponse
,
error
)
{
func
(
c
*
ringServiceClient
)
Send
TxAsEth
(
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_Send
RawTransaction
_Handler
(
srv
interface
{},
ctx
context
.
Context
,
dec
func
(
interface
{})
error
,
interceptor
grpc
.
UnaryServerInterceptor
)
(
interface
{},
error
)
{
in
:=
new
(
v1
.
EthTx
)
func
_RingService_Send
TxAsEth
_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
)
.
Send
RawTransaction
(
ctx
,
in
)
return
srv
.
(
RingServiceServer
)
.
Send
TxAsEth
(
ctx
,
in
)
}
info
:=
&
grpc
.
UnaryServerInfo
{
Server
:
srv
,
FullMethod
:
"/ring.v1.RingService/Send
RawTransaction
"
,
FullMethod
:
"/ring.v1.RingService/Send
TxAsEth
"
,
}
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"
,
...
...
grcp-tx_test.go
View file @
f2a034dd
...
...
@@ -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
(),
}
//publicKey := local.Public()
//publicKeyECDSA, _ := publicKey.(*ecdsa.PublicKey)
//fromAddress := crypto.PubkeyToAddress(*publicKeyECDSA)
//b.Log(fromAddress)
v
,
r
,
sigs
:=
tx
.
RawSignatureValues
()
remote
,
_
:=
crypto
.
GenerateKey
()
inner
.
V
=
v
.
Bytes
()
inner
.
R
=
r
.
Bytes
()
inner
.
S
=
sigs
.
Bytes
()
inner
.
Amount
=
tx
.
Value
()
.
Bytes
()
tx
:=
pricedTransaction
(
crypto
.
PubkeyToAddress
(
remote
.
PublicKey
),
0
,
100000
,
big
.
NewInt
(
1
),
local
)
addr
:=
base
.
Address
{
Address
:
tx
.
To
()
.
Bytes
()}
// inner := base.EthTxData{
// AccountNonce: tx.Nonce(),
// Price: tx.GasPrice().Bytes(),
// GasLimit: tx.Gas(),
// Payload: tx.Data(),
// }
inner
.
Recipient
=
&
addr
// v, r, sigs := tx.RawSignatureValues()
ethTx
:=
base
.
EthTx
{
Inner
:
&
inner
}
// inner.V = v.Bytes()
// inner.R = r.Bytes()
// inner.S = sigs.Bytes()
// inner.Amount = tx.Value().Bytes()
ethTxAsAny
,
err
:=
pbany
(
ethTx
)
// addr := base.Address{Address: tx.To().Bytes()}
res
,
err
:=
c
.
SendTxAsAny
(
ctx
,
&
base
.
Transaction
{
Tx
:
ethTxAsAny
})
// inner.Recipient = &addr
if
err
!=
nil
{
b
.
Fatal
(
err
)
}
// Each goroutine has its own bytes.Buffer.
_
=
res
// The loop body is executed b.N times total across all goroutines.
}
})
}
//res, err := c.SendRawTransaction(ctx, &base.EthTx{Inner: &inner})
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
BenchmarkBytesEth
(
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
()
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)
}
})
}
main.go
View file @
f2a034dd
...
...
@@ -35,7 +35,6 @@ type TxCheckServer struct {
txchecker
.
UnimplementedTxCheckerServiceServer
}
type
RingServer
struct
{
metaring
.
UnimplementedRingServiceServer
}
...
...
ringapi/ring/v1/service.proto
View file @
f2a034dd
...
...
@@ -10,10 +10,11 @@ import "base/v1/resource.proto";
service
RingService
{
// account info service
rpc
Send
RawTransaction
(
base.v1.EthTx
)
returns
(
SendRawTransactionResponse
)
{};
rpc
Send
TxAsEth
(
base.v1.TransactionEth
)
returns
(
SendRawTransactionResponse
)
{};
rpc
SendTxAs
Any
(
base.v1.Transaction
)
returns
(
SendRawTransactionResponse
)
{};
rpc
SendTxAs
Std
(
base.v1.TransactionStd
)
returns
(
SendRawTransactionResponse
)
{};
rpc
SendTxAsAny
(
base.v1.Transaction
)
returns
(
SendRawTransactionResponse
)
{};
rpc
SendTxAsBytes
(
base.v1.TransactionBytes
)
returns
(
SendRawTransactionResponse
)
{};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment