From 163e260ac984f14c62f5636d33229839a9e1bf47 Mon Sep 17 00:00:00 2001 From: Vickixiaodong Date: Tue, 19 Dec 2017 23:28:41 +0800 Subject: [PATCH 01/75] add java-tron --- core/TronBlock.proto | 14 ++++++++++++++ core/TronBlockHeader.proto | 17 +++++++++++++++++ core/TronTXInput.proto | 13 +++++++++++++ core/TronTXOutput.proto | 11 +++++++++++ core/TronTXOutputs.proto | 12 ++++++++++++ core/TronTransaction.proto | 15 +++++++++++++++ 6 files changed, 82 insertions(+) create mode 100644 core/TronBlock.proto create mode 100644 core/TronBlockHeader.proto create mode 100644 core/TronTXInput.proto create mode 100644 core/TronTXOutput.proto create mode 100644 core/TronTXOutputs.proto create mode 100644 core/TronTransaction.proto diff --git a/core/TronBlock.proto b/core/TronBlock.proto new file mode 100644 index 00000000000..76e536f2744 --- /dev/null +++ b/core/TronBlock.proto @@ -0,0 +1,14 @@ +syntax = "proto3"; + +package protos; + +import "core/TronTransaction.proto"; +import "core/TronBlockHeader.proto"; + +option java_package = "org.tron.protos.core"; //Specify the name of the package that generated the Java file +option java_outer_classname = "TronBlock"; //Specify the class name of the generated Java file + +message Block { + repeated Transaction transactions = 1; + BlockHeader blockHeader = 2; +} \ No newline at end of file diff --git a/core/TronBlockHeader.proto b/core/TronBlockHeader.proto new file mode 100644 index 00000000000..43fc9e4823d --- /dev/null +++ b/core/TronBlockHeader.proto @@ -0,0 +1,17 @@ +syntax = "proto3"; + +package protos; + +option java_package = "org.tron.protos.core"; //Specify the name of the package that generated the Java file +option java_outer_classname = "TronBlockHeader"; //Specify the class name of the generated Java file + +message BlockHeader{ + int64 timestamp = 1; + bytes txTrieRoot = 2; + bytes parentHash = 3; + bytes hash = 4; + bytes nonce = 5; + bytes difficulty = 6; + bool isPoW = 7; + int64 number = 8; +} \ No newline at end of file diff --git a/core/TronTXInput.proto b/core/TronTXInput.proto new file mode 100644 index 00000000000..c4058a2241e --- /dev/null +++ b/core/TronTXInput.proto @@ -0,0 +1,13 @@ +syntax = "proto3"; + +package protos; + +option java_package = "org.tron.protos.core"; //Specify the name of the package that generated the Java file +option java_outer_classname = "TronTXInput"; //Specify the class name of the generated Java file + +message TXInput { + bytes txID = 1; + int64 vout = 2; + bytes signature = 3; + bytes pubKey = 4; +} \ No newline at end of file diff --git a/core/TronTXOutput.proto b/core/TronTXOutput.proto new file mode 100644 index 00000000000..f5fb3dba387 --- /dev/null +++ b/core/TronTXOutput.proto @@ -0,0 +1,11 @@ +syntax = "proto3"; + +package protos; + +option java_package = "org.tron.protos.core"; //Specify the name of the package that generated the Java file +option java_outer_classname = "TronTXOutput"; //Specify the class name of the generated Java file + +message TXOutput { + int64 value = 1; + bytes pubKeyHash = 2; +} \ No newline at end of file diff --git a/core/TronTXOutputs.proto b/core/TronTXOutputs.proto new file mode 100644 index 00000000000..2abc448960c --- /dev/null +++ b/core/TronTXOutputs.proto @@ -0,0 +1,12 @@ +syntax = "proto3"; + +package protos; + +import "core/TronTXOutput.proto"; + +option java_package = "org.tron.protos.core"; //Specify the name of the package that generated the Java file +option java_outer_classname = "TronTXOutputs"; //Specify the class name of the generated Java file + +message TXOutputs { + repeated TXOutput outputs = 1; +} \ No newline at end of file diff --git a/core/TronTransaction.proto b/core/TronTransaction.proto new file mode 100644 index 00000000000..5f8e5c903fa --- /dev/null +++ b/core/TronTransaction.proto @@ -0,0 +1,15 @@ +syntax = "proto3"; + +package protos; + +import "core/TronTXInput.proto"; +import "core/TronTXOutput.proto"; + +option java_package = "org.tron.protos.core"; //Specify the name of the package that generated the Java file +option java_outer_classname = "TronTransaction"; //Specify the class name of the generated Java file + +message Transaction { + bytes id = 1; + repeated TXInput vin = 2; + repeated TXOutput vout = 3; +} \ No newline at end of file From 99dc8e316ab241883d10553edd0ab4cd0537995d Mon Sep 17 00:00:00 2001 From: sasaxie Date: Tue, 2 Jan 2018 21:08:59 +0800 Subject: [PATCH 02/75] :sparkles:feat: genesis block can load from json file --- core/TronBlockHeader.proto | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/core/TronBlockHeader.proto b/core/TronBlockHeader.proto index 43fc9e4823d..bbb1be9fe9b 100644 --- a/core/TronBlockHeader.proto +++ b/core/TronBlockHeader.proto @@ -12,6 +12,5 @@ message BlockHeader{ bytes hash = 4; bytes nonce = 5; bytes difficulty = 6; - bool isPoW = 7; - int64 number = 8; + int64 number = 7; } \ No newline at end of file From ac542ee383bd84d6e5f1c1e5894c9aac6d763600 Mon Sep 17 00:00:00 2001 From: zhaohong229 Date: Fri, 19 Jan 2018 16:13:30 +0800 Subject: [PATCH 03/75] 1. java-tron refactor a. add common package for base libraries, incluing network, storage, crypto b. add program package for runnable application c. move all core libraries of blockchain to core package 2. add third-party libs, inlcuding grpc, gossip 3. add tron rpcapi module --- api/api.proto | 20 ++++++++++++++++++++ core/TronBlock.proto | 26 +++++++++++++------------- core/TronBlockHeader.proto | 30 +++++++++++++++--------------- core/TronTXInput.proto | 24 ++++++++++++------------ core/TronTXOutput.proto | 20 ++++++++++---------- core/TronTXOutputs.proto | 22 +++++++++++----------- core/TronTransaction.proto | 28 ++++++++++++++-------------- 7 files changed, 95 insertions(+), 75 deletions(-) create mode 100644 api/api.proto diff --git a/api/api.proto b/api/api.proto new file mode 100644 index 00000000000..01476c9d63e --- /dev/null +++ b/api/api.proto @@ -0,0 +1,20 @@ +syntax = "proto3"; +package proto; +option java_package = "org.tron.api"; //Specify the name of the package that generated the Java file +option java_outer_classname = "GrpcAPI"; //Specify the class name of the generated Java file + +// just a example +service Wallet { + // get account balance + rpc GetBalance (Balance) returns (Balance) {}; + // rpc GetBalance2 () returns (Balance) +}; +message Balance { + int32 balance = 1; +}; +// end just a example + + + + + diff --git a/core/TronBlock.proto b/core/TronBlock.proto index 76e536f2744..00f0fadbd48 100644 --- a/core/TronBlock.proto +++ b/core/TronBlock.proto @@ -1,14 +1,14 @@ -syntax = "proto3"; - -package protos; - -import "core/TronTransaction.proto"; -import "core/TronBlockHeader.proto"; - -option java_package = "org.tron.protos.core"; //Specify the name of the package that generated the Java file -option java_outer_classname = "TronBlock"; //Specify the class name of the generated Java file - -message Block { - repeated Transaction transactions = 1; - BlockHeader blockHeader = 2; +syntax = "proto3"; + +package protos; + +import "core/TronTransaction.proto"; +import "core/TronBlockHeader.proto"; + +option java_package = "org.tron.protos.core"; //Specify the name of the package that generated the Java file +option java_outer_classname = "TronBlock"; //Specify the class name of the generated Java file + +message Block { + repeated Transaction transactions = 1; + BlockHeader blockHeader = 2; } \ No newline at end of file diff --git a/core/TronBlockHeader.proto b/core/TronBlockHeader.proto index bbb1be9fe9b..cfd059cc64c 100644 --- a/core/TronBlockHeader.proto +++ b/core/TronBlockHeader.proto @@ -1,16 +1,16 @@ -syntax = "proto3"; - -package protos; - -option java_package = "org.tron.protos.core"; //Specify the name of the package that generated the Java file -option java_outer_classname = "TronBlockHeader"; //Specify the class name of the generated Java file - -message BlockHeader{ - int64 timestamp = 1; - bytes txTrieRoot = 2; - bytes parentHash = 3; - bytes hash = 4; - bytes nonce = 5; - bytes difficulty = 6; - int64 number = 7; +syntax = "proto3"; + +package protos; + +option java_package = "org.tron.protos.core"; //Specify the name of the package that generated the Java file +option java_outer_classname = "TronBlockHeader"; //Specify the class name of the generated Java file + +message BlockHeader{ + int64 timestamp = 1; + bytes txTrieRoot = 2; + bytes parentHash = 3; + bytes hash = 4; + bytes nonce = 5; + bytes difficulty = 6; + int64 number = 7; } \ No newline at end of file diff --git a/core/TronTXInput.proto b/core/TronTXInput.proto index c4058a2241e..f98187ace90 100644 --- a/core/TronTXInput.proto +++ b/core/TronTXInput.proto @@ -1,13 +1,13 @@ -syntax = "proto3"; - -package protos; - -option java_package = "org.tron.protos.core"; //Specify the name of the package that generated the Java file -option java_outer_classname = "TronTXInput"; //Specify the class name of the generated Java file - -message TXInput { - bytes txID = 1; - int64 vout = 2; - bytes signature = 3; - bytes pubKey = 4; +syntax = "proto3"; + +package protos; + +option java_package = "org.tron.protos.core"; //Specify the name of the package that generated the Java file +option java_outer_classname = "TronTXInput"; //Specify the class name of the generated Java file + +message TXInput { + bytes txID = 1; + int64 vout = 2; + bytes signature = 3; + bytes pubKey = 4; } \ No newline at end of file diff --git a/core/TronTXOutput.proto b/core/TronTXOutput.proto index f5fb3dba387..6521e4adb20 100644 --- a/core/TronTXOutput.proto +++ b/core/TronTXOutput.proto @@ -1,11 +1,11 @@ -syntax = "proto3"; - -package protos; - -option java_package = "org.tron.protos.core"; //Specify the name of the package that generated the Java file -option java_outer_classname = "TronTXOutput"; //Specify the class name of the generated Java file - -message TXOutput { - int64 value = 1; - bytes pubKeyHash = 2; +syntax = "proto3"; + +package protos; + +option java_package = "org.tron.protos.core"; //Specify the name of the package that generated the Java file +option java_outer_classname = "TronTXOutput"; //Specify the class name of the generated Java file + +message TXOutput { + int64 value = 1; + bytes pubKeyHash = 2; } \ No newline at end of file diff --git a/core/TronTXOutputs.proto b/core/TronTXOutputs.proto index 2abc448960c..01b57168239 100644 --- a/core/TronTXOutputs.proto +++ b/core/TronTXOutputs.proto @@ -1,12 +1,12 @@ -syntax = "proto3"; - -package protos; - -import "core/TronTXOutput.proto"; - -option java_package = "org.tron.protos.core"; //Specify the name of the package that generated the Java file -option java_outer_classname = "TronTXOutputs"; //Specify the class name of the generated Java file - -message TXOutputs { - repeated TXOutput outputs = 1; +syntax = "proto3"; + +package protos; + +import "core/TronTXOutput.proto"; + +option java_package = "org.tron.protos.core"; //Specify the name of the package that generated the Java file +option java_outer_classname = "TronTXOutputs"; //Specify the class name of the generated Java file + +message TXOutputs { + repeated TXOutput outputs = 1; } \ No newline at end of file diff --git a/core/TronTransaction.proto b/core/TronTransaction.proto index 5f8e5c903fa..66f525e062d 100644 --- a/core/TronTransaction.proto +++ b/core/TronTransaction.proto @@ -1,15 +1,15 @@ -syntax = "proto3"; - -package protos; - -import "core/TronTXInput.proto"; -import "core/TronTXOutput.proto"; - -option java_package = "org.tron.protos.core"; //Specify the name of the package that generated the Java file -option java_outer_classname = "TronTransaction"; //Specify the class name of the generated Java file - -message Transaction { - bytes id = 1; - repeated TXInput vin = 2; - repeated TXOutput vout = 3; +syntax = "proto3"; + +package protos; + +import "core/TronTXInput.proto"; +import "core/TronTXOutput.proto"; + +option java_package = "org.tron.protos.core"; //Specify the name of the package that generated the Java file +option java_outer_classname = "TronTransaction"; //Specify the class name of the generated Java file + +message Transaction { + bytes id = 1; + repeated TXInput vin = 2; + repeated TXOutput vout = 3; } \ No newline at end of file From 985bcfe95bd8b16d2871afac71a63b327baa904b Mon Sep 17 00:00:00 2001 From: olivier Date: Wed, 24 Jan 2018 00:30:02 +0800 Subject: [PATCH 04/75] add message protocol --- core/Tron.proto | 22 ++++++++++++++++++++++ core/TronInventoryItems.proto | 14 ++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 core/Tron.proto create mode 100644 core/TronInventoryItems.proto diff --git a/core/Tron.proto b/core/Tron.proto new file mode 100644 index 00000000000..f93fe6e03ae --- /dev/null +++ b/core/Tron.proto @@ -0,0 +1,22 @@ +syntax = "proto3"; + +package protos; + +import "core/TronTransaction.proto"; +import "core/TronBlockHeader.proto"; +import "core/TronBlock.proto"; + +option java_package = "org.tron.protos.core"; //Specify the name of the package that generated the Java file +option java_outer_classname = "Tron"; //Specify the class name of the generated Java file + +message Blocks { + repeated Block blocks = 1; +} + +message BlockHeaders { + repeated BlockHeader blockHeaders = 1; +} + +message Transactions { + repeated Transaction transactions = 1; +} \ No newline at end of file diff --git a/core/TronInventoryItems.proto b/core/TronInventoryItems.proto new file mode 100644 index 00000000000..64bef6f2f85 --- /dev/null +++ b/core/TronInventoryItems.proto @@ -0,0 +1,14 @@ +syntax = "proto3"; + +package protos; + +import "core/TronTransaction.proto"; +import "core/TronBlockHeader.proto"; + +option java_package = "org.tron.protos.core"; //Specify the name of the package that generated the Java file +option java_outer_classname = "TronInventoryItems"; //Specify the class name of the generated Java file + +message InventoryItems { + int32 type = 1; + repeated bytes items = 2; +} \ No newline at end of file From 0495eb19f375c42a6822706fbe8c83b9148bd921 Mon Sep 17 00:00:00 2001 From: olivier Date: Tue, 30 Jan 2018 23:29:32 +0800 Subject: [PATCH 05/75] refactor and code the main loopls --- api/api.proto | 31 ++++++++++------- core/Tron.proto | 65 +++++++++++++++++++++++++++++------ core/TronBlock.proto | 14 -------- core/TronBlockHeader.proto | 16 --------- core/TronInventoryItems.proto | 14 -------- core/TronTXInput.proto | 13 ------- core/TronTXOutput.proto | 11 ------ core/TronTXOutputs.proto | 12 ------- core/TronTransaction.proto | 15 -------- 9 files changed, 72 insertions(+), 119 deletions(-) delete mode 100644 core/TronBlock.proto delete mode 100644 core/TronBlockHeader.proto delete mode 100644 core/TronInventoryItems.proto delete mode 100644 core/TronTXInput.proto delete mode 100644 core/TronTXOutput.proto delete mode 100644 core/TronTXOutputs.proto delete mode 100644 core/TronTransaction.proto diff --git a/api/api.proto b/api/api.proto index 01476c9d63e..817928a51fd 100644 --- a/api/api.proto +++ b/api/api.proto @@ -1,20 +1,25 @@ syntax = "proto3"; -package proto; +package protocal; +import "core/Tron.proto"; + option java_package = "org.tron.api"; //Specify the name of the package that generated the Java file option java_outer_classname = "GrpcAPI"; //Specify the class name of the generated Java file -// just a example service Wallet { - // get account balance - rpc GetBalance (Balance) returns (Balance) {}; - // rpc GetBalance2 () returns (Balance) -}; -message Balance { - int32 balance = 1; + rpc GetBalance (Account) returns (Account) {}; + rpc CreateTransaction(Coin) returns (Transaction) {}; + rpc BroadcastTransaction(Transaction) returns (Return) {}; }; -// end just a example - - - - +message Return { + bool result = 1; +} +message Coin { + bytes from = 1; + bytes to = 2; + int64 amount = 3; +}; +message Account { + int64 balance = 1; + bytes address = 2; +}; \ No newline at end of file diff --git a/core/Tron.proto b/core/Tron.proto index f93fe6e03ae..f71ac2388ac 100644 --- a/core/Tron.proto +++ b/core/Tron.proto @@ -1,22 +1,65 @@ syntax = "proto3"; -package protos; +package protocal; -import "core/TronTransaction.proto"; -import "core/TronBlockHeader.proto"; -import "core/TronBlock.proto"; +option java_package = "org.tron.protos"; //Specify the name of the package that generated the Java file +option java_outer_classname = "Protocal"; //Specify the class name of the generated Java file -option java_package = "org.tron.protos.core"; //Specify the name of the package that generated the Java file -option java_outer_classname = "Tron"; //Specify the class name of the generated Java file -message Blocks { - repeated Block blocks = 1; +message Transaction { + message TXOutput { + int64 value = 1; + bytes pubKeyHash = 2; + } + + message TXInput { + bytes txID = 1; + int64 vout = 2; + bytes signature = 3; + bytes pubKey = 4; + } + + bytes id = 1; + repeated TXInput vin = 2; + repeated TXOutput vout = 3; } -message BlockHeaders { - repeated BlockHeader blockHeaders = 1; +message BlockHeader{ + int64 timestamp = 1; + bytes txTrieRoot = 2; + bytes parentHash = 3; + bytes hash = 4; + bytes nonce = 5; + bytes difficulty = 6; + int64 number = 7; } -message Transactions { +message Block { repeated Transaction transactions = 1; + BlockHeader blockHeader = 2; +} + +message Inventory { + enum InventoryType //枚举消息类型 + { + TRX = 0; + BLOCK = 1; + } + InventoryType type = 1; + repeated bytes ids = 2; +} + +message Items { + enum ItemType //枚举消息类型 + { + ERR= 0; //proto3版本中,首成员必须为0,成员不应有相同的值 + TRX = 1; + BLOCK = 2; + BLOCKHEADER = 3; + } + + ItemType type = 1; + repeated Block blocks = 2; + repeated BlockHeader blockHeaders = 3; + repeated Transaction transactions = 4; } \ No newline at end of file diff --git a/core/TronBlock.proto b/core/TronBlock.proto deleted file mode 100644 index 00f0fadbd48..00000000000 --- a/core/TronBlock.proto +++ /dev/null @@ -1,14 +0,0 @@ -syntax = "proto3"; - -package protos; - -import "core/TronTransaction.proto"; -import "core/TronBlockHeader.proto"; - -option java_package = "org.tron.protos.core"; //Specify the name of the package that generated the Java file -option java_outer_classname = "TronBlock"; //Specify the class name of the generated Java file - -message Block { - repeated Transaction transactions = 1; - BlockHeader blockHeader = 2; -} \ No newline at end of file diff --git a/core/TronBlockHeader.proto b/core/TronBlockHeader.proto deleted file mode 100644 index cfd059cc64c..00000000000 --- a/core/TronBlockHeader.proto +++ /dev/null @@ -1,16 +0,0 @@ -syntax = "proto3"; - -package protos; - -option java_package = "org.tron.protos.core"; //Specify the name of the package that generated the Java file -option java_outer_classname = "TronBlockHeader"; //Specify the class name of the generated Java file - -message BlockHeader{ - int64 timestamp = 1; - bytes txTrieRoot = 2; - bytes parentHash = 3; - bytes hash = 4; - bytes nonce = 5; - bytes difficulty = 6; - int64 number = 7; -} \ No newline at end of file diff --git a/core/TronInventoryItems.proto b/core/TronInventoryItems.proto deleted file mode 100644 index 64bef6f2f85..00000000000 --- a/core/TronInventoryItems.proto +++ /dev/null @@ -1,14 +0,0 @@ -syntax = "proto3"; - -package protos; - -import "core/TronTransaction.proto"; -import "core/TronBlockHeader.proto"; - -option java_package = "org.tron.protos.core"; //Specify the name of the package that generated the Java file -option java_outer_classname = "TronInventoryItems"; //Specify the class name of the generated Java file - -message InventoryItems { - int32 type = 1; - repeated bytes items = 2; -} \ No newline at end of file diff --git a/core/TronTXInput.proto b/core/TronTXInput.proto deleted file mode 100644 index f98187ace90..00000000000 --- a/core/TronTXInput.proto +++ /dev/null @@ -1,13 +0,0 @@ -syntax = "proto3"; - -package protos; - -option java_package = "org.tron.protos.core"; //Specify the name of the package that generated the Java file -option java_outer_classname = "TronTXInput"; //Specify the class name of the generated Java file - -message TXInput { - bytes txID = 1; - int64 vout = 2; - bytes signature = 3; - bytes pubKey = 4; -} \ No newline at end of file diff --git a/core/TronTXOutput.proto b/core/TronTXOutput.proto deleted file mode 100644 index 6521e4adb20..00000000000 --- a/core/TronTXOutput.proto +++ /dev/null @@ -1,11 +0,0 @@ -syntax = "proto3"; - -package protos; - -option java_package = "org.tron.protos.core"; //Specify the name of the package that generated the Java file -option java_outer_classname = "TronTXOutput"; //Specify the class name of the generated Java file - -message TXOutput { - int64 value = 1; - bytes pubKeyHash = 2; -} \ No newline at end of file diff --git a/core/TronTXOutputs.proto b/core/TronTXOutputs.proto deleted file mode 100644 index 01b57168239..00000000000 --- a/core/TronTXOutputs.proto +++ /dev/null @@ -1,12 +0,0 @@ -syntax = "proto3"; - -package protos; - -import "core/TronTXOutput.proto"; - -option java_package = "org.tron.protos.core"; //Specify the name of the package that generated the Java file -option java_outer_classname = "TronTXOutputs"; //Specify the class name of the generated Java file - -message TXOutputs { - repeated TXOutput outputs = 1; -} \ No newline at end of file diff --git a/core/TronTransaction.proto b/core/TronTransaction.proto deleted file mode 100644 index 66f525e062d..00000000000 --- a/core/TronTransaction.proto +++ /dev/null @@ -1,15 +0,0 @@ -syntax = "proto3"; - -package protos; - -import "core/TronTXInput.proto"; -import "core/TronTXOutput.proto"; - -option java_package = "org.tron.protos.core"; //Specify the name of the package that generated the Java file -option java_outer_classname = "TronTransaction"; //Specify the class name of the generated Java file - -message Transaction { - bytes id = 1; - repeated TXInput vin = 2; - repeated TXOutput vout = 3; -} \ No newline at end of file From cc23898f49e4bf8e85e3367225bab9eb7d067731 Mon Sep 17 00:00:00 2001 From: zhaohong Date: Wed, 31 Jan 2018 00:04:21 +0800 Subject: [PATCH 06/75] design database and protocal --- core/Tron.proto | 9 ++++++++- core/TronBlock.proto | 14 ++++++++++++++ core/TronBlockHeader.proto | 16 ++++++++++++++++ core/TronInventoryItems.proto | 14 ++++++++++++++ core/TronTXInput.proto | 13 +++++++++++++ core/TronTXOutput.proto | 11 +++++++++++ core/TronTXOutputs.proto | 12 ++++++++++++ core/TronTransaction.proto | 15 +++++++++++++++ core/TronTransactionAndlockSript.proto | 12 ++++++++++++ 9 files changed, 115 insertions(+), 1 deletion(-) create mode 100644 core/TronBlock.proto create mode 100644 core/TronBlockHeader.proto create mode 100644 core/TronInventoryItems.proto create mode 100644 core/TronTXInput.proto create mode 100644 core/TronTXOutput.proto create mode 100644 core/TronTXOutputs.proto create mode 100644 core/TronTransaction.proto create mode 100644 core/TronTransactionAndlockSript.proto diff --git a/core/Tron.proto b/core/Tron.proto index f71ac2388ac..a93768b4cb9 100644 --- a/core/Tron.proto +++ b/core/Tron.proto @@ -6,6 +6,12 @@ option java_package = "org.tron.protos"; //Specify the name of the package that option java_outer_classname = "Protocal"; //Specify the class name of the generated Java file + +enum TranscationType { + Transfer = 0; + DeployContract = 1; +} + message Transaction { message TXOutput { int64 value = 1; @@ -31,7 +37,8 @@ message BlockHeader{ bytes hash = 4; bytes nonce = 5; bytes difficulty = 6; - int64 number = 7; + uint64 number = 7; + uint64 witness_id = 8; } message Block { diff --git a/core/TronBlock.proto b/core/TronBlock.proto new file mode 100644 index 00000000000..00f0fadbd48 --- /dev/null +++ b/core/TronBlock.proto @@ -0,0 +1,14 @@ +syntax = "proto3"; + +package protos; + +import "core/TronTransaction.proto"; +import "core/TronBlockHeader.proto"; + +option java_package = "org.tron.protos.core"; //Specify the name of the package that generated the Java file +option java_outer_classname = "TronBlock"; //Specify the class name of the generated Java file + +message Block { + repeated Transaction transactions = 1; + BlockHeader blockHeader = 2; +} \ No newline at end of file diff --git a/core/TronBlockHeader.proto b/core/TronBlockHeader.proto new file mode 100644 index 00000000000..cfd059cc64c --- /dev/null +++ b/core/TronBlockHeader.proto @@ -0,0 +1,16 @@ +syntax = "proto3"; + +package protos; + +option java_package = "org.tron.protos.core"; //Specify the name of the package that generated the Java file +option java_outer_classname = "TronBlockHeader"; //Specify the class name of the generated Java file + +message BlockHeader{ + int64 timestamp = 1; + bytes txTrieRoot = 2; + bytes parentHash = 3; + bytes hash = 4; + bytes nonce = 5; + bytes difficulty = 6; + int64 number = 7; +} \ No newline at end of file diff --git a/core/TronInventoryItems.proto b/core/TronInventoryItems.proto new file mode 100644 index 00000000000..64bef6f2f85 --- /dev/null +++ b/core/TronInventoryItems.proto @@ -0,0 +1,14 @@ +syntax = "proto3"; + +package protos; + +import "core/TronTransaction.proto"; +import "core/TronBlockHeader.proto"; + +option java_package = "org.tron.protos.core"; //Specify the name of the package that generated the Java file +option java_outer_classname = "TronInventoryItems"; //Specify the class name of the generated Java file + +message InventoryItems { + int32 type = 1; + repeated bytes items = 2; +} \ No newline at end of file diff --git a/core/TronTXInput.proto b/core/TronTXInput.proto new file mode 100644 index 00000000000..f98187ace90 --- /dev/null +++ b/core/TronTXInput.proto @@ -0,0 +1,13 @@ +syntax = "proto3"; + +package protos; + +option java_package = "org.tron.protos.core"; //Specify the name of the package that generated the Java file +option java_outer_classname = "TronTXInput"; //Specify the class name of the generated Java file + +message TXInput { + bytes txID = 1; + int64 vout = 2; + bytes signature = 3; + bytes pubKey = 4; +} \ No newline at end of file diff --git a/core/TronTXOutput.proto b/core/TronTXOutput.proto new file mode 100644 index 00000000000..6521e4adb20 --- /dev/null +++ b/core/TronTXOutput.proto @@ -0,0 +1,11 @@ +syntax = "proto3"; + +package protos; + +option java_package = "org.tron.protos.core"; //Specify the name of the package that generated the Java file +option java_outer_classname = "TronTXOutput"; //Specify the class name of the generated Java file + +message TXOutput { + int64 value = 1; + bytes pubKeyHash = 2; +} \ No newline at end of file diff --git a/core/TronTXOutputs.proto b/core/TronTXOutputs.proto new file mode 100644 index 00000000000..01b57168239 --- /dev/null +++ b/core/TronTXOutputs.proto @@ -0,0 +1,12 @@ +syntax = "proto3"; + +package protos; + +import "core/TronTXOutput.proto"; + +option java_package = "org.tron.protos.core"; //Specify the name of the package that generated the Java file +option java_outer_classname = "TronTXOutputs"; //Specify the class name of the generated Java file + +message TXOutputs { + repeated TXOutput outputs = 1; +} \ No newline at end of file diff --git a/core/TronTransaction.proto b/core/TronTransaction.proto new file mode 100644 index 00000000000..66f525e062d --- /dev/null +++ b/core/TronTransaction.proto @@ -0,0 +1,15 @@ +syntax = "proto3"; + +package protos; + +import "core/TronTXInput.proto"; +import "core/TronTXOutput.proto"; + +option java_package = "org.tron.protos.core"; //Specify the name of the package that generated the Java file +option java_outer_classname = "TronTransaction"; //Specify the class name of the generated Java file + +message Transaction { + bytes id = 1; + repeated TXInput vin = 2; + repeated TXOutput vout = 3; +} \ No newline at end of file diff --git a/core/TronTransactionAndlockSript.proto b/core/TronTransactionAndlockSript.proto new file mode 100644 index 00000000000..1f7bdc0212a --- /dev/null +++ b/core/TronTransactionAndlockSript.proto @@ -0,0 +1,12 @@ +syntax = "proto3"; + +package protos; +import "core/TronTransaction.proto"; + +option java_package = "org.tron.protos.core"; //Specify the name of the package that generated the Java file +option java_outer_classname = "TronTransactionAndlockSript"; //Specify the class name of the generated Java file + +message TransactionAndlockSript{ + Transaction transaction = 1; + repeated bytes pubKeyHash = 2; +} \ No newline at end of file From 5a2f0298334b6e44b21d4461ed715017bdb1f047 Mon Sep 17 00:00:00 2001 From: zhaohong Date: Wed, 31 Jan 2018 13:12:46 +0800 Subject: [PATCH 07/75] add message txoutputs --- core/Tron.proto | 93 +++++++++++++++++++++++++------------------------ 1 file changed, 48 insertions(+), 45 deletions(-) diff --git a/core/Tron.proto b/core/Tron.proto index a93768b4cb9..ba6fd76a833 100644 --- a/core/Tron.proto +++ b/core/Tron.proto @@ -6,67 +6,70 @@ option java_package = "org.tron.protos"; //Specify the name of the package that option java_outer_classname = "Protocal"; //Specify the class name of the generated Java file - enum TranscationType { Transfer = 0; - DeployContract = 1; + DeployContract = 1; } -message Transaction { - message TXOutput { - int64 value = 1; - bytes pubKeyHash = 2; - } +message TXOutput { + int64 value = 1; + bytes pubKeyHash = 2; +} - message TXInput { - bytes txID = 1; - int64 vout = 2; - bytes signature = 3; - bytes pubKey = 4; - } +message TXInput { + bytes txID = 1; + int64 vout = 2; + bytes signature = 3; + bytes pubKey = 4; +} - bytes id = 1; - repeated TXInput vin = 2; - repeated TXOutput vout = 3; +message TXOutputs { + repeated TXOutput outputs = 1; +} + +message Transaction { + bytes id = 1; + repeated TXInput vin = 2; + repeated TXOutput vout = 3; } -message BlockHeader{ - int64 timestamp = 1; - bytes txTrieRoot = 2; - bytes parentHash = 3; - bytes hash = 4; - bytes nonce = 5; - bytes difficulty = 6; - uint64 number = 7; - uint64 witness_id = 8; +message BlockHeader { + int64 timestamp = 1; + bytes txTrieRoot = 2; + bytes parentHash = 3; + bytes hash = 4; + bytes nonce = 5; + bytes difficulty = 6; + uint64 number = 7; + uint64 witness_id = 8; } message Block { - repeated Transaction transactions = 1; - BlockHeader blockHeader = 2; + repeated Transaction transactions = 1; + BlockHeader blockHeader = 2; } message Inventory { - enum InventoryType //枚举消息类型 - { - TRX = 0; - BLOCK = 1; - } - InventoryType type = 1; - repeated bytes ids = 2; + enum InventoryType //枚举消息类型 + { + TRX = 0; + BLOCK = 1; + } + InventoryType type = 1; + repeated bytes ids = 2; } message Items { - enum ItemType //枚举消息类型 - { - ERR= 0; //proto3版本中,首成员必须为0,成员不应有相同的值 - TRX = 1; - BLOCK = 2; - BLOCKHEADER = 3; - } + enum ItemType //枚举消息类型 + { + ERR = 0; //proto3版本中,首成员必须为0,成员不应有相同的值 + TRX = 1; + BLOCK = 2; + BLOCKHEADER = 3; + } - ItemType type = 1; - repeated Block blocks = 2; - repeated BlockHeader blockHeaders = 3; - repeated Transaction transactions = 4; + ItemType type = 1; + repeated Block blocks = 2; + repeated BlockHeader blockHeaders = 3; + repeated Transaction transactions = 4; } \ No newline at end of file From 6d5175bd84ccffd47c115316381ea168f0a73ea2 Mon Sep 17 00:00:00 2001 From: sasaxie Date: Wed, 31 Jan 2018 21:37:22 +0800 Subject: [PATCH 08/75] remove useless proto file --- core/TronBlock.proto | 14 -------------- core/TronBlockHeader.proto | 16 ---------------- core/TronTXInput.proto | 13 ------------- core/TronTXOutput.proto | 11 ----------- core/TronTXOutputs.proto | 12 ------------ core/TronTransaction.proto | 15 --------------- core/TronTransactionAndlockSript.proto | 12 ------------ 7 files changed, 93 deletions(-) delete mode 100644 core/TronBlock.proto delete mode 100644 core/TronBlockHeader.proto delete mode 100644 core/TronTXInput.proto delete mode 100644 core/TronTXOutput.proto delete mode 100644 core/TronTXOutputs.proto delete mode 100644 core/TronTransaction.proto delete mode 100644 core/TronTransactionAndlockSript.proto diff --git a/core/TronBlock.proto b/core/TronBlock.proto deleted file mode 100644 index 00f0fadbd48..00000000000 --- a/core/TronBlock.proto +++ /dev/null @@ -1,14 +0,0 @@ -syntax = "proto3"; - -package protos; - -import "core/TronTransaction.proto"; -import "core/TronBlockHeader.proto"; - -option java_package = "org.tron.protos.core"; //Specify the name of the package that generated the Java file -option java_outer_classname = "TronBlock"; //Specify the class name of the generated Java file - -message Block { - repeated Transaction transactions = 1; - BlockHeader blockHeader = 2; -} \ No newline at end of file diff --git a/core/TronBlockHeader.proto b/core/TronBlockHeader.proto deleted file mode 100644 index cfd059cc64c..00000000000 --- a/core/TronBlockHeader.proto +++ /dev/null @@ -1,16 +0,0 @@ -syntax = "proto3"; - -package protos; - -option java_package = "org.tron.protos.core"; //Specify the name of the package that generated the Java file -option java_outer_classname = "TronBlockHeader"; //Specify the class name of the generated Java file - -message BlockHeader{ - int64 timestamp = 1; - bytes txTrieRoot = 2; - bytes parentHash = 3; - bytes hash = 4; - bytes nonce = 5; - bytes difficulty = 6; - int64 number = 7; -} \ No newline at end of file diff --git a/core/TronTXInput.proto b/core/TronTXInput.proto deleted file mode 100644 index f98187ace90..00000000000 --- a/core/TronTXInput.proto +++ /dev/null @@ -1,13 +0,0 @@ -syntax = "proto3"; - -package protos; - -option java_package = "org.tron.protos.core"; //Specify the name of the package that generated the Java file -option java_outer_classname = "TronTXInput"; //Specify the class name of the generated Java file - -message TXInput { - bytes txID = 1; - int64 vout = 2; - bytes signature = 3; - bytes pubKey = 4; -} \ No newline at end of file diff --git a/core/TronTXOutput.proto b/core/TronTXOutput.proto deleted file mode 100644 index 6521e4adb20..00000000000 --- a/core/TronTXOutput.proto +++ /dev/null @@ -1,11 +0,0 @@ -syntax = "proto3"; - -package protos; - -option java_package = "org.tron.protos.core"; //Specify the name of the package that generated the Java file -option java_outer_classname = "TronTXOutput"; //Specify the class name of the generated Java file - -message TXOutput { - int64 value = 1; - bytes pubKeyHash = 2; -} \ No newline at end of file diff --git a/core/TronTXOutputs.proto b/core/TronTXOutputs.proto deleted file mode 100644 index 01b57168239..00000000000 --- a/core/TronTXOutputs.proto +++ /dev/null @@ -1,12 +0,0 @@ -syntax = "proto3"; - -package protos; - -import "core/TronTXOutput.proto"; - -option java_package = "org.tron.protos.core"; //Specify the name of the package that generated the Java file -option java_outer_classname = "TronTXOutputs"; //Specify the class name of the generated Java file - -message TXOutputs { - repeated TXOutput outputs = 1; -} \ No newline at end of file diff --git a/core/TronTransaction.proto b/core/TronTransaction.proto deleted file mode 100644 index 66f525e062d..00000000000 --- a/core/TronTransaction.proto +++ /dev/null @@ -1,15 +0,0 @@ -syntax = "proto3"; - -package protos; - -import "core/TronTXInput.proto"; -import "core/TronTXOutput.proto"; - -option java_package = "org.tron.protos.core"; //Specify the name of the package that generated the Java file -option java_outer_classname = "TronTransaction"; //Specify the class name of the generated Java file - -message Transaction { - bytes id = 1; - repeated TXInput vin = 2; - repeated TXOutput vout = 3; -} \ No newline at end of file diff --git a/core/TronTransactionAndlockSript.proto b/core/TronTransactionAndlockSript.proto deleted file mode 100644 index 1f7bdc0212a..00000000000 --- a/core/TronTransactionAndlockSript.proto +++ /dev/null @@ -1,12 +0,0 @@ -syntax = "proto3"; - -package protos; -import "core/TronTransaction.proto"; - -option java_package = "org.tron.protos.core"; //Specify the name of the package that generated the Java file -option java_outer_classname = "TronTransactionAndlockSript"; //Specify the class name of the generated Java file - -message TransactionAndlockSript{ - Transaction transaction = 1; - repeated bytes pubKeyHash = 2; -} \ No newline at end of file From 6f6e00c44941a828b872d4c4b56f584aba092315 Mon Sep 17 00:00:00 2001 From: sasaxie Date: Wed, 31 Jan 2018 21:47:50 +0800 Subject: [PATCH 09/75] rename proto package name --- core/TronInventoryItems.proto | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/core/TronInventoryItems.proto b/core/TronInventoryItems.proto index 64bef6f2f85..899a3ca4f4b 100644 --- a/core/TronInventoryItems.proto +++ b/core/TronInventoryItems.proto @@ -1,14 +1,13 @@ syntax = "proto3"; -package protos; +package protocal; -import "core/TronTransaction.proto"; -import "core/TronBlockHeader.proto"; +import "core/Tron.proto"; -option java_package = "org.tron.protos.core"; //Specify the name of the package that generated the Java file +option java_package = "org.tron.protos"; //Specify the name of the package that generated the Java file option java_outer_classname = "TronInventoryItems"; //Specify the class name of the generated Java file message InventoryItems { - int32 type = 1; - repeated bytes items = 2; + int32 type = 1; + repeated bytes items = 2; } \ No newline at end of file From 072f15ccab0cc7ce8493bb66f2ce7b54432a9c7b Mon Sep 17 00:00:00 2001 From: zhaohong Date: Thu, 1 Feb 2018 14:45:41 +0800 Subject: [PATCH 10/75] add account proto. --- api/api.proto | 13 ++++++------- core/Tron.proto | 10 ++++++++++ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/api/api.proto b/api/api.proto index 817928a51fd..a249d40008f 100644 --- a/api/api.proto +++ b/api/api.proto @@ -6,9 +6,12 @@ option java_package = "org.tron.api"; //Specify the name of the package that gen option java_outer_classname = "GrpcAPI"; //Specify the class name of the generated Java file service Wallet { - rpc GetBalance (Account) returns (Account) {}; - rpc CreateTransaction(Coin) returns (Transaction) {}; - rpc BroadcastTransaction(Transaction) returns (Return) {}; + rpc GetBalance (Account) returns (Account) { + }; + rpc CreateTransaction (Coin) returns (Transaction) { + }; + rpc BroadcastTransaction (Transaction) returns (Return) { + }; }; message Return { @@ -18,8 +21,4 @@ message Coin { bytes from = 1; bytes to = 2; int64 amount = 3; -}; -message Account { - int64 balance = 1; - bytes address = 2; }; \ No newline at end of file diff --git a/core/Tron.proto b/core/Tron.proto index ba6fd76a833..e6b5bf321d9 100644 --- a/core/Tron.proto +++ b/core/Tron.proto @@ -5,6 +5,16 @@ package protocal; option java_package = "org.tron.protos"; //Specify the name of the package that generated the Java file option java_outer_classname = "Protocal"; //Specify the class name of the generated Java file +// Account + +message Account { + bytes address = 1; + int64 balance = 2; + repeated string votes = 3; + map asset = 4; +} + +// Transcation enum TranscationType { Transfer = 0; From 28211b9beb0dca70b7c41ed256bda1b30bcff9c5 Mon Sep 17 00:00:00 2001 From: olivier Date: Thu, 1 Feb 2018 15:52:25 +0800 Subject: [PATCH 11/75] impelement a part of sync blocks code --- core/Tron.proto | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/core/Tron.proto b/core/Tron.proto index e6b5bf321d9..5ca80a7b222 100644 --- a/core/Tron.proto +++ b/core/Tron.proto @@ -6,19 +6,20 @@ option java_package = "org.tron.protos"; //Specify the name of the package that option java_outer_classname = "Protocal"; //Specify the class name of the generated Java file // Account - message Account { bytes address = 1; int64 balance = 2; repeated string votes = 3; map asset = 4; + int32 type = 5; } // Transcation - enum TranscationType { Transfer = 0; DeployContract = 1; + CreateAccount = 2; + VoteWitess = 3; } message TXOutput { @@ -39,8 +40,11 @@ message TXOutputs { message Transaction { bytes id = 1; - repeated TXInput vin = 2; - repeated TXOutput vout = 3; + TranscationType type = 2; + repeated TXInput vin = 3; + repeated TXOutput vout = 4; + bytes data = 10; + bytes scripts = 12; } message BlockHeader { @@ -54,11 +58,15 @@ message BlockHeader { uint64 witness_id = 8; } +// block + message Block { repeated Transaction transactions = 1; BlockHeader blockHeader = 2; } +// Inventory + message Inventory { enum InventoryType //枚举消息类型 { @@ -69,6 +77,7 @@ message Inventory { repeated bytes ids = 2; } + message Items { enum ItemType //枚举消息类型 { From 9f92ace58da1311d0d95910560970f8686611a2b Mon Sep 17 00:00:00 2001 From: zhaohong Date: Thu, 1 Feb 2018 17:41:38 +0800 Subject: [PATCH 12/75] add account and trx type proto --- core/Tron.proto | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/core/Tron.proto b/core/Tron.proto index 5ca80a7b222..28952caf9e8 100644 --- a/core/Tron.proto +++ b/core/Tron.proto @@ -14,14 +14,16 @@ message Account { int32 type = 5; } -// Transcation -enum TranscationType { - Transfer = 0; - DeployContract = 1; - CreateAccount = 2; - VoteWitess = 3; +// Contract +message Contract { + bytes address = 1; + bytes scripts = 2; + string name = 3; } +// Transcation + + message TXOutput { int64 value = 1; bytes pubKeyHash = 2; @@ -39,6 +41,13 @@ message TXOutputs { } message Transaction { + enum TranscationType { + Transfer = 0; + DeployContract = 1; + CreateAccount = 2; + VoteWitess = 3; + } + bytes id = 1; TranscationType type = 2; repeated TXInput vin = 3; From 96473ca9b580570543b2409ed098a8e5b65d6877 Mon Sep 17 00:00:00 2001 From: zhaohong Date: Thu, 1 Feb 2018 21:04:25 +0800 Subject: [PATCH 13/75] add witness to tron proto. --- core/Tron.proto | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/core/Tron.proto b/core/Tron.proto index 28952caf9e8..23f79784f27 100644 --- a/core/Tron.proto +++ b/core/Tron.proto @@ -21,8 +21,18 @@ message Contract { string name = 3; } -// Transcation +// Witness +message Witness { + bytes address = 1; + int64 voteCount = 2; + bytes pubKey = 3; + string url = 4; + int64 totalProduced = 5; + int64 totalMissed = 6; + int64 latestBlockNum = 7; +} +// Transcation message TXOutput { int64 value = 1; From dc5398505bf03f3e8d983c40329268c20b5a4006 Mon Sep 17 00:00:00 2001 From: zhaohong Date: Fri, 2 Feb 2018 21:01:27 +0800 Subject: [PATCH 14/75] add basic loop in witness service. --- core/Tron.proto | 1 - 1 file changed, 1 deletion(-) diff --git a/core/Tron.proto b/core/Tron.proto index 23f79784f27..709e51a0e5f 100644 --- a/core/Tron.proto +++ b/core/Tron.proto @@ -57,7 +57,6 @@ message Transaction { CreateAccount = 2; VoteWitess = 3; } - bytes id = 1; TranscationType type = 2; repeated TXInput vin = 3; From 19bc3930da2a3889f61c8bc00a9fc4a3984ccd50 Mon Sep 17 00:00:00 2001 From: Marcus Date: Sat, 3 Feb 2018 13:07:37 +0800 Subject: [PATCH 15/75] Initial commit --- LICENSE | 165 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ README.md | 1 + 2 files changed, 166 insertions(+) create mode 100644 LICENSE create mode 100644 README.md diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000000..65c5ca88a67 --- /dev/null +++ b/LICENSE @@ -0,0 +1,165 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. diff --git a/README.md b/README.md new file mode 100644 index 00000000000..945f854c941 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +# protocal \ No newline at end of file From 74378f7d7f85dd78aef498de4764a98cfe993cd5 Mon Sep 17 00:00:00 2001 From: Marcus Date: Sat, 3 Feb 2018 13:40:03 +0800 Subject: [PATCH 16/75] Update README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 945f854c941..dccfcb46a3b 100644 --- a/README.md +++ b/README.md @@ -1 +1,2 @@ -# protocal \ No newline at end of file +# protocal +the protocals of tron From 20199900e6bfb7ef4c512c5b54cbd2c3a7a8c4a3 Mon Sep 17 00:00:00 2001 From: Marcus Date: Sat, 3 Feb 2018 13:48:14 +0800 Subject: [PATCH 17/75] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index dccfcb46a3b..f03417595ac 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,2 @@ # protocal -the protocals of tron +the protocals of tron, including message and api. From 95c7c9111a83e1bc560683dd24409b37ea63a5cf Mon Sep 17 00:00:00 2001 From: Marcus Date: Sat, 3 Feb 2018 14:05:07 +0800 Subject: [PATCH 18/75] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index dccfcb46a3b..e34517e809e 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,2 @@ # protocal -the protocals of tron +the protocals of tron including api and message. From 1578f84a52eb9ed5353fefe9c2a33d4b820f2b6e Mon Sep 17 00:00:00 2001 From: Marcus Date: Sat, 3 Feb 2018 14:58:46 +0800 Subject: [PATCH 19/75] Update README.md --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index e34517e809e..c9843d3226c 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,6 @@ # protocal the protocals of tron including api and message. + +java-tron and wallet-cli + +git subtree pull --prefix src/main/protos/ protocal master From 1b456b23724b6bd61d547fca481b65fb9dde2a0b Mon Sep 17 00:00:00 2001 From: Heng Zhang Date: Mon, 5 Feb 2018 20:16:48 +0800 Subject: [PATCH 20/75] commit add block witness address. --- core/Tron.proto | 1 + 1 file changed, 1 insertion(+) diff --git a/core/Tron.proto b/core/Tron.proto index 709e51a0e5f..601d27382c9 100644 --- a/core/Tron.proto +++ b/core/Tron.proto @@ -74,6 +74,7 @@ message BlockHeader { bytes difficulty = 6; uint64 number = 7; uint64 witness_id = 8; + bytes witness_address = 9; } // block From 5f297f63a749445dcc94f54fbc8fa37bc47c3d25 Mon Sep 17 00:00:00 2001 From: Heng Zhang Date: Mon, 5 Feb 2018 20:16:48 +0800 Subject: [PATCH 21/75] commit add block witness address. --- core/Tron.proto | 1 + 1 file changed, 1 insertion(+) diff --git a/core/Tron.proto b/core/Tron.proto index 709e51a0e5f..601d27382c9 100644 --- a/core/Tron.proto +++ b/core/Tron.proto @@ -74,6 +74,7 @@ message BlockHeader { bytes difficulty = 6; uint64 number = 7; uint64 witness_id = 8; + bytes witness_address = 9; } // block From 2dfcc7fea5e15c54c2a85b4cee49278d8ac7f416 Mon Sep 17 00:00:00 2001 From: Marcus Date: Mon, 5 Feb 2018 20:54:39 +0800 Subject: [PATCH 22/75] Update README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index c9843d3226c..e1700c3cdb1 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -# protocal -the protocals of tron including api and message. +# protocol +the protocol of tron including api and message. java-tron and wallet-cli -git subtree pull --prefix src/main/protos/ protocal master +git subtree pull --prefix src/main/protos/ protocol master From fefc1a9e18ac43af19633b767ce494b7757f5ad0 Mon Sep 17 00:00:00 2001 From: zhaohong Date: Fri, 9 Feb 2018 17:28:03 +0800 Subject: [PATCH 23/75] add a script to generate java code. --- gen.sh | 1 + 1 file changed, 1 insertion(+) create mode 100644 gen.sh diff --git a/gen.sh b/gen.sh new file mode 100644 index 00000000000..f08b36865de --- /dev/null +++ b/gen.sh @@ -0,0 +1 @@ +protoc --java_out=./ ./core/*.proto ./api/*.proto \ No newline at end of file From 964cc6dfd464b1a7fac87b6e5327665ee81dbbda Mon Sep 17 00:00:00 2001 From: zhaohong Date: Fri, 9 Feb 2018 17:30:58 +0800 Subject: [PATCH 24/75] add any type as contract parameter. --- core/Contract.proto | 28 ++++++++++++++++++++++++++++ core/Tron.proto | 4 ++++ 2 files changed, 32 insertions(+) create mode 100644 core/Contract.proto diff --git a/core/Contract.proto b/core/Contract.proto new file mode 100644 index 00000000000..8bc5282e2eb --- /dev/null +++ b/core/Contract.proto @@ -0,0 +1,28 @@ +syntax = "proto3"; + +package protocal; + +option java_package = "org.tron.protos"; //Specify the name of the package that generated the Java file +option java_outer_classname = "Contract"; //Specify the class name of the generated Java file + + +message VoteContract{ + bytes address = 1; + repeated bytes voidAddress = 2; + bool support = 3; +} + +message TransferContract{ + +} + + +message DeployContract{ + bytes address = 1; + bytes script = 2; +} + + +message CustomContract { + +} \ No newline at end of file diff --git a/core/Tron.proto b/core/Tron.proto index 709e51a0e5f..7a939241a37 100644 --- a/core/Tron.proto +++ b/core/Tron.proto @@ -1,7 +1,10 @@ syntax = "proto3"; +import "google/protobuf/any.proto"; + package protocal; + option java_package = "org.tron.protos"; //Specify the name of the package that generated the Java file option java_outer_classname = "Protocal"; //Specify the class name of the generated Java file @@ -62,6 +65,7 @@ message Transaction { repeated TXInput vin = 3; repeated TXOutput vout = 4; bytes data = 10; + repeated google.protobuf.Any parameter = 11; bytes scripts = 12; } From 052e9ed93fe982a5a7162aac4d406aaf80926fc4 Mon Sep 17 00:00:00 2001 From: zhaohong Date: Fri, 23 Feb 2018 21:10:35 +0800 Subject: [PATCH 25/75] add witness_signature --- core/Tron.proto | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/Tron.proto b/core/Tron.proto index 16201d8ab37..2bafe54a0c4 100644 --- a/core/Tron.proto +++ b/core/Tron.proto @@ -69,6 +69,7 @@ message Transaction { bytes scripts = 12; } + message BlockHeader { int64 timestamp = 1; bytes txTrieRoot = 2; @@ -79,6 +80,7 @@ message BlockHeader { uint64 number = 7; uint64 witness_id = 8; bytes witness_address = 9; + bytes witness_signature = 12; } // block From 2a39480b9c9ba857a509ec7c4567c57dfcbeed69 Mon Sep 17 00:00:00 2001 From: zhaohong Date: Sat, 24 Feb 2018 16:20:05 +0800 Subject: [PATCH 26/75] add hash field to trans. --- core/Tron.proto | 1 + 1 file changed, 1 insertion(+) diff --git a/core/Tron.proto b/core/Tron.proto index 2bafe54a0c4..6cb1853703d 100644 --- a/core/Tron.proto +++ b/core/Tron.proto @@ -64,6 +64,7 @@ message Transaction { TranscationType type = 2; repeated TXInput vin = 3; repeated TXOutput vout = 4; + bytes hash = 5; bytes data = 10; repeated google.protobuf.Any parameter = 11; bytes scripts = 12; From 0145fa6e5766eafe6e6a6888f70ea4b9e67753a2 Mon Sep 17 00:00:00 2001 From: zhaohong Date: Mon, 26 Feb 2018 15:43:27 +0800 Subject: [PATCH 27/75] add vote and assetIssue contract. --- core/Contract.proto | 14 +++++++++++++- core/Tron.proto | 1 + 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/core/Contract.proto b/core/Contract.proto index 8bc5282e2eb..9de3bb193c4 100644 --- a/core/Contract.proto +++ b/core/Contract.proto @@ -8,8 +8,20 @@ option java_outer_classname = "Contract"; //Specify the class name of the genera message VoteContract{ bytes address = 1; - repeated bytes voidAddress = 2; + repeated bytes vote_address = 2; bool support = 3; + int32 count = 5; +} + +message AssetIssueContract { + bytes name = 1; + int64 total_supply = 2; + int32 trx_num = 3; + int32 num = 4; + int64 start_time = 5; + int64 end_time = 6; + int32 decay_ratio = 7; + } message TransferContract{ diff --git a/core/Tron.proto b/core/Tron.proto index 6cb1853703d..079264d3673 100644 --- a/core/Tron.proto +++ b/core/Tron.proto @@ -59,6 +59,7 @@ message Transaction { DeployContract = 1; CreateAccount = 2; VoteWitess = 3; + AssetIssue = 4; } bytes id = 1; TranscationType type = 2; From 47ff9f8a4c5302e6fb252d9c86b8127aedaf0564 Mon Sep 17 00:00:00 2001 From: zhaohong Date: Mon, 26 Feb 2018 15:48:21 +0800 Subject: [PATCH 28/75] add vote and assetIssue contract. --- core/Contract.proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/Contract.proto b/core/Contract.proto index 9de3bb193c4..791f7bb334d 100644 --- a/core/Contract.proto +++ b/core/Contract.proto @@ -1,6 +1,6 @@ syntax = "proto3"; -package protocal; +package protocol; option java_package = "org.tron.protos"; //Specify the name of the package that generated the Java file option java_outer_classname = "Contract"; //Specify the class name of the generated Java file From 2274dea2de0c40b83bcc28cef7f37506e4f739e7 Mon Sep 17 00:00:00 2001 From: Heng Zhang Date: Mon, 26 Feb 2018 16:39:09 +0800 Subject: [PATCH 29/75] feat: add travis CI to creat protoc files --- .travis.yml | 7 +++++++ README.md | 4 +++- 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000000..a928ef61597 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,7 @@ +--- +sudo: required +language: java +jdk: oraclejdk8 + +script: + - protoc --java_out=./ ./core/*.proto ./api/*.proto \ No newline at end of file diff --git a/README.md b/README.md index e1700c3cdb1..c04fbf6968a 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,6 @@ -# protocol +# protocol [![Build Status](https://travis-ci.org/tronprotocol/protocol.svg?branch=master)](https://travis-ci.org/tronprotocol/protocol) + + the protocol of tron including api and message. java-tron and wallet-cli From 8a0a27c0f39363eb4ed05dad77db20ebf8168fc9 Mon Sep 17 00:00:00 2001 From: Heng Zhang Date: Mon, 26 Feb 2018 16:42:46 +0800 Subject: [PATCH 30/75] feat: add ignore list --- .gitignore | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000000..91e0319e8df --- /dev/null +++ b/.gitignore @@ -0,0 +1,52 @@ +# IDEA +.idea +*iml +.DS_Store + +# gradle +.gradle +build + +# log +logs +consensus-logs + +# lombok +out + +# levelDB +tron-data +database* + +# database +database + +# doc +doc + +# gossip +pernodedata.* +ringstate.* +shareddata.* + +# svn +.svn + +# protobuf generated classes +src/main/gen + +src/main/java/org/tron/core/bftconsensus +src/test/java/org/tron/consensus2 +src/main/java/META-INF/ +src/main/resources/META-INF/ +/bin/ + +# Eclipse IDE specific files and folders +/.project +/.classpath +/.settings/ +/.apt_generated/ + +# output directory +/output-directory/ + From 394c88a158ba302a507684fe039e09651c34a8e3 Mon Sep 17 00:00:00 2001 From: zhaohong Date: Mon, 26 Feb 2018 16:57:09 +0800 Subject: [PATCH 31/75] add asset issue api. --- api/api.proto | 22 +++++++++++++++++++++- core/Tron.proto | 23 +++++++++++++++++------ 2 files changed, 38 insertions(+), 7 deletions(-) diff --git a/api/api.proto b/api/api.proto index a249d40008f..15b8e0288f1 100644 --- a/api/api.proto +++ b/api/api.proto @@ -1,19 +1,39 @@ syntax = "proto3"; -package protocal; +package protocol; + import "core/Tron.proto"; +import "core/Contract.proto"; option java_package = "org.tron.api"; //Specify the name of the package that generated the Java file option java_outer_classname = "GrpcAPI"; //Specify the class name of the generated Java file service Wallet { + rpc GetBalance (Account) returns (Account) { + }; rpc CreateTransaction (Coin) returns (Transaction) { + }; + rpc BroadcastTransaction (Transaction) returns (Return) { + + }; + + rpc CreateAccount(Account) returns (Account) { + + }; + + rpc CreateAssetIssue(AssetIssueContract) returns (AssetIssueContract) { + }; }; + + + + + message Return { bool result = 1; } diff --git a/core/Tron.proto b/core/Tron.proto index 079264d3673..6dee14e153e 100644 --- a/core/Tron.proto +++ b/core/Tron.proto @@ -2,7 +2,7 @@ syntax = "proto3"; import "google/protobuf/any.proto"; -package protocal; +package protocol; option java_package = "org.tron.protos"; //Specify the name of the package that generated the Java file @@ -10,11 +10,20 @@ option java_outer_classname = "Protocal"; //Specify the class name of the genera // Account message Account { - bytes address = 1; - int64 balance = 2; - repeated string votes = 3; - map asset = 4; - int32 type = 5; + + enum AccountType { + Normal = 0; + AssertIssue = 1; + Contract = 2; + } + + bytes accout_name = 1; + AccountType type = 2; + bytes address = 3; + int64 balance = 4; + repeated string votes = 5; + map asset = 6; + } // Contract @@ -54,6 +63,7 @@ message TXOutputs { } message Transaction { + enum TranscationType { Transfer = 0; DeployContract = 1; @@ -61,6 +71,7 @@ message Transaction { VoteWitess = 3; AssetIssue = 4; } + bytes id = 1; TranscationType type = 2; repeated TXInput vin = 3; From 82545da3f30b88a47731875831659f94867abd50 Mon Sep 17 00:00:00 2001 From: Heng Zhang Date: Mon, 26 Feb 2018 17:46:29 +0800 Subject: [PATCH 32/75] fix: add shell to install-protobuf --- .gitignore | 48 --------------------------------------------- .travis.yml | 22 ++++++++++++++++----- install-protobuf.sh | 10 ++++++++++ 3 files changed, 27 insertions(+), 53 deletions(-) create mode 100755 install-protobuf.sh diff --git a/.gitignore b/.gitignore index 91e0319e8df..1554c5edd92 100644 --- a/.gitignore +++ b/.gitignore @@ -2,51 +2,3 @@ .idea *iml .DS_Store - -# gradle -.gradle -build - -# log -logs -consensus-logs - -# lombok -out - -# levelDB -tron-data -database* - -# database -database - -# doc -doc - -# gossip -pernodedata.* -ringstate.* -shareddata.* - -# svn -.svn - -# protobuf generated classes -src/main/gen - -src/main/java/org/tron/core/bftconsensus -src/test/java/org/tron/consensus2 -src/main/java/META-INF/ -src/main/resources/META-INF/ -/bin/ - -# Eclipse IDE specific files and folders -/.project -/.classpath -/.settings/ -/.apt_generated/ - -# output directory -/output-directory/ - diff --git a/.travis.yml b/.travis.yml index a928ef61597..3f1e4c4709b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,19 @@ ---- -sudo: required -language: java -jdk: oraclejdk8 +language: ruby +cache: + directories: + - $HOME/protobuf + +sudo: false + +before_install: + - bash install-protobuf.sh + +# check what has been installed by listing contents of protobuf folder +before_script: + - ls -R $HOME/protobuf + +# let's use protobuf script: - - protoc --java_out=./ ./core/*.proto ./api/*.proto \ No newline at end of file + - $HOME/protobuf/bin/protoc --java_out=./ ./core/*.proto ./api/*.proto + - ls -l \ No newline at end of file diff --git a/install-protobuf.sh b/install-protobuf.sh new file mode 100755 index 00000000000..b5f27a2957a --- /dev/null +++ b/install-protobuf.sh @@ -0,0 +1,10 @@ +#!/bin/sh +set -e +# check to see if protobuf folder is empty +if [ ! -d "$HOME/protobuf/lib" ]; then + wget https://github.com/google/protobuf/releases/download/v3.5.1/protobuf-java-3.5.1.tar.gz + tar -xzvf protobuf-java-3.5.1.tar.gz + cd protobuf-java-3.5.1 && ./configure --prefix=$HOME/protobuf && make && make install +else + echo "Using cached directory." +fi From 715d0bf184df7c59f9a3cef481e1b28c5f4a3faf Mon Sep 17 00:00:00 2001 From: Heng Zhang Date: Mon, 26 Feb 2018 17:51:54 +0800 Subject: [PATCH 33/75] Update install-protobuf.sh change protoc folder name --- install-protobuf.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install-protobuf.sh b/install-protobuf.sh index b5f27a2957a..29e5536ee6d 100755 --- a/install-protobuf.sh +++ b/install-protobuf.sh @@ -4,7 +4,7 @@ set -e if [ ! -d "$HOME/protobuf/lib" ]; then wget https://github.com/google/protobuf/releases/download/v3.5.1/protobuf-java-3.5.1.tar.gz tar -xzvf protobuf-java-3.5.1.tar.gz - cd protobuf-java-3.5.1 && ./configure --prefix=$HOME/protobuf && make && make install + cd protobuf-3.5.1 && ./configure --prefix=$HOME/protobuf && make && make install else echo "Using cached directory." fi From 5f8e99dd06676031901a4db5bb4b47873fa0f917 Mon Sep 17 00:00:00 2001 From: Heng Zhang Date: Mon, 26 Feb 2018 18:14:06 +0800 Subject: [PATCH 34/75] Update api.proto test: ERR --- api/api.proto | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/api.proto b/api/api.proto index 15b8e0288f1..ee63f360380 100644 --- a/api/api.proto +++ b/api/api.proto @@ -39,6 +39,6 @@ message Return { } message Coin { bytes from = 1; - bytes to = 2; + bytes to = 1; int64 amount = 3; -}; \ No newline at end of file +}; From 470593905435a088cb409f6e461cf5381b4f027f Mon Sep 17 00:00:00 2001 From: Heng Zhang Date: Mon, 26 Feb 2018 18:16:16 +0800 Subject: [PATCH 35/75] Update api.proto test CI --- api/api.proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/api.proto b/api/api.proto index ee63f360380..437fcc81edd 100644 --- a/api/api.proto +++ b/api/api.proto @@ -39,6 +39,6 @@ message Return { } message Coin { bytes from = 1; - bytes to = 1; + bytes to = 2; int64 amount = 3; }; From 3d92cf337b9f1ea429718815d8dfdcc16c160b63 Mon Sep 17 00:00:00 2001 From: zhaohong Date: Mon, 26 Feb 2018 18:31:05 +0800 Subject: [PATCH 36/75] redesign block header, add raw item. --- core/Tron.proto | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/core/Tron.proto b/core/Tron.proto index 6dee14e153e..00a9414e61a 100644 --- a/core/Tron.proto +++ b/core/Tron.proto @@ -52,10 +52,14 @@ message TXOutput { } message TXInput { - bytes txID = 1; - int64 vout = 2; + message raw { + bytes txID = 1; + int64 vout = 2; + bytes pubKey = 4; + } + bytes signature = 3; - bytes pubKey = 4; + } message TXOutputs { @@ -76,7 +80,7 @@ message Transaction { TranscationType type = 2; repeated TXInput vin = 3; repeated TXOutput vout = 4; - bytes hash = 5; + //bytes hash = 5; bytes data = 10; repeated google.protobuf.Any parameter = 11; bytes scripts = 12; @@ -84,23 +88,27 @@ message Transaction { message BlockHeader { - int64 timestamp = 1; - bytes txTrieRoot = 2; - bytes parentHash = 3; - bytes hash = 4; - bytes nonce = 5; - bytes difficulty = 6; - uint64 number = 7; - uint64 witness_id = 8; - bytes witness_address = 9; + + message raw { + int64 timestamp = 1; + bytes txTrieRoot = 2; + bytes parentHash = 3; + bytes nonce = 5; + bytes difficulty = 6; + uint64 number = 7; + uint64 witness_id = 8; + bytes witness_address = 9; + } + bytes witness_signature = 12; + } // block message Block { repeated Transaction transactions = 1; - BlockHeader blockHeader = 2; + BlockHeader block_header = 2; } // Inventory @@ -127,6 +135,6 @@ message Items { ItemType type = 1; repeated Block blocks = 2; - repeated BlockHeader blockHeaders = 3; + repeated BlockHeader block_headers = 3; repeated Transaction transactions = 4; } \ No newline at end of file From 6c2fa86d9d3a79f4d40c34341362c01516abf0ce Mon Sep 17 00:00:00 2001 From: zhaohong Date: Mon, 26 Feb 2018 19:33:12 +0800 Subject: [PATCH 37/75] redesign block header --- core/Tron.proto | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/core/Tron.proto b/core/Tron.proto index 6dee14e153e..db54e8bab4a 100644 --- a/core/Tron.proto +++ b/core/Tron.proto @@ -84,16 +84,18 @@ message Transaction { message BlockHeader { - int64 timestamp = 1; - bytes txTrieRoot = 2; - bytes parentHash = 3; - bytes hash = 4; - bytes nonce = 5; - bytes difficulty = 6; - uint64 number = 7; - uint64 witness_id = 8; - bytes witness_address = 9; - bytes witness_signature = 12; + message raw { + int64 timestamp = 1; + bytes txTrieRoot = 2; + bytes parentHash = 3; + bytes nonce = 5; + bytes difficulty = 6; + uint64 number = 7; + uint64 witness_id = 8; + bytes witness_address = 9; + }; + raw raw_data = 1; + bytes witness_signature = 2; } // block From 70079027c841bbe28d3350b1df95b9a135d8feab Mon Sep 17 00:00:00 2001 From: zhaohong Date: Mon, 26 Feb 2018 20:03:06 +0800 Subject: [PATCH 38/75] revert TxInput --- core/Tron.proto | 1 + 1 file changed, 1 insertion(+) diff --git a/core/Tron.proto b/core/Tron.proto index db54e8bab4a..6c81b4b6edb 100644 --- a/core/Tron.proto +++ b/core/Tron.proto @@ -51,6 +51,7 @@ message TXOutput { bytes pubKeyHash = 2; } + message TXInput { bytes txID = 1; int64 vout = 2; From 6a418c459294d43004a2389a0fef184c4df3a3d7 Mon Sep 17 00:00:00 2001 From: zhaohong Date: Mon, 26 Feb 2018 20:46:59 +0800 Subject: [PATCH 39/75] add raw to TxInput --- core/Tron.proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/Tron.proto b/core/Tron.proto index f21ab634283..32a8d024b07 100644 --- a/core/Tron.proto +++ b/core/Tron.proto @@ -58,7 +58,7 @@ message TXInput { int64 vout = 2; bytes pubKey = 4; } - + raw data = 1; bytes signature = 3; } From 697d7429d9d841c6465802be7fadcd3552cfa976 Mon Sep 17 00:00:00 2001 From: zhaohong Date: Mon, 26 Feb 2018 21:04:56 +0800 Subject: [PATCH 40/75] code style. --- core/Tron.proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/Tron.proto b/core/Tron.proto index 32a8d024b07..69df5031147 100644 --- a/core/Tron.proto +++ b/core/Tron.proto @@ -58,7 +58,7 @@ message TXInput { int64 vout = 2; bytes pubKey = 4; } - raw data = 1; + raw raw_data = 1; bytes signature = 3; } From 5b738cabd4eea7f3cf40a082bd47987e9686d9cd Mon Sep 17 00:00:00 2001 From: sasaxie Date: Tue, 27 Feb 2018 12:35:59 +0800 Subject: [PATCH 41/75] remove useless properties --- core/Tron.proto | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/Tron.proto b/core/Tron.proto index 69df5031147..19f3045b176 100644 --- a/core/Tron.proto +++ b/core/Tron.proto @@ -93,8 +93,8 @@ message BlockHeader { int64 timestamp = 1; bytes txTrieRoot = 2; bytes parentHash = 3; - bytes nonce = 5; - bytes difficulty = 6; + //bytes nonce = 5; + //bytes difficulty = 6; uint64 number = 7; uint64 witness_id = 8; bytes witness_address = 9; @@ -136,4 +136,4 @@ message Items { repeated Block blocks = 2; repeated BlockHeader block_headers = 3; repeated Transaction transactions = 4; -} \ No newline at end of file +} From aa6a38d59256a23ec4c2d7e9c149414127b8fadd Mon Sep 17 00:00:00 2001 From: zhaohong Date: Tue, 27 Feb 2018 19:46:39 +0800 Subject: [PATCH 42/75] add some new protocol like AssetIssue, Account. --- api/api.proto | 16 ++++------------ core/Contract.proto | 40 +++++++++++++++++++++++++++++----------- core/Tron.proto | 12 ++++++------ 3 files changed, 39 insertions(+), 29 deletions(-) diff --git a/api/api.proto b/api/api.proto index 437fcc81edd..a968106a3e5 100644 --- a/api/api.proto +++ b/api/api.proto @@ -12,7 +12,7 @@ service Wallet { rpc GetBalance (Account) returns (Account) { }; - rpc CreateTransaction (Coin) returns (Transaction) { + rpc CreateTransaction (TransferContract) returns (Transaction) { }; @@ -20,25 +20,17 @@ service Wallet { }; - rpc CreateAccount(Account) returns (Account) { + rpc CreateAccount(Account) returns (Transaction) { }; - rpc CreateAssetIssue(AssetIssueContract) returns (AssetIssueContract) { + rpc CreateAssetIssue(AssetIssueContract) returns (Transaction) { }; -}; - - - +}; message Return { bool result = 1; } -message Coin { - bytes from = 1; - bytes to = 2; - int64 amount = 3; -}; diff --git a/core/Contract.proto b/core/Contract.proto index 791f7bb334d..ac62c4ee193 100644 --- a/core/Contract.proto +++ b/core/Contract.proto @@ -6,13 +6,38 @@ option java_package = "org.tron.protos"; //Specify the name of the package that option java_outer_classname = "Contract"; //Specify the class name of the generated Java file -message VoteContract{ +message TransferContract{ + bytes from_address = 1; + bytes to_address = 2; + int64 amount = 3; +} + +message TransferAssertContract{ + bytes assert_name =1; + bytes from_address = 2; + bytes to_address = 3; + int64 amount = 4; +} + + +message VoteAssetContract{ + bytes address = 1; + repeated bytes vote_address = 2; + bool support = 3; + int32 count = 5; +} + +message VoteWitnessContract{ bytes address = 1; repeated bytes vote_address = 2; bool support = 3; int32 count = 5; } +message WitnessContract{ + +} + message AssetIssueContract { bytes name = 1; int64 total_supply = 2; @@ -21,20 +46,13 @@ message AssetIssueContract { int64 start_time = 5; int64 end_time = 6; int32 decay_ratio = 7; - + int32 vote_score = 8; + bytes description = 10; + bytes url =20; } -message TransferContract{ - -} - - message DeployContract{ bytes address = 1; bytes script = 2; } - -message CustomContract { - -} \ No newline at end of file diff --git a/core/Tron.proto b/core/Tron.proto index 69df5031147..d5b91ff5df4 100644 --- a/core/Tron.proto +++ b/core/Tron.proto @@ -75,19 +75,19 @@ message Transaction { CreateAccount = 2; VoteWitess = 3; AssetIssue = 4; + VoteAsset = 5; } bytes id = 1; TranscationType type = 2; repeated TXInput vin = 3; repeated TXOutput vout = 4; - //bytes hash = 5; bytes data = 10; repeated google.protobuf.Any parameter = 11; - bytes scripts = 12; + repeated bytes signature = 14; + bytes scripts = 16; } - message BlockHeader { message raw { int64 timestamp = 1; @@ -113,7 +113,7 @@ message Block { // Inventory message Inventory { - enum InventoryType //枚举消息类型 + enum InventoryType { TRX = 0; BLOCK = 1; @@ -124,9 +124,9 @@ message Inventory { message Items { - enum ItemType //枚举消息类型 + enum ItemType { - ERR = 0; //proto3版本中,首成员必须为0,成员不应有相同的值 + ERR = 0; TRX = 1; BLOCK = 2; BLOCKHEADER = 3; From b6e4490846d77c483379596c1b22a7488513f171 Mon Sep 17 00:00:00 2001 From: zhaohong Date: Wed, 28 Feb 2018 16:13:11 +0800 Subject: [PATCH 43/75] improve the transaction protocol. --- api/api.proto | 3 +-- core/Contract.proto | 28 ++++++++++++++++++++++++++-- core/Tron.proto | 19 ++++++++++--------- 3 files changed, 37 insertions(+), 13 deletions(-) diff --git a/api/api.proto b/api/api.proto index a968106a3e5..f7aa336b5d2 100644 --- a/api/api.proto +++ b/api/api.proto @@ -20,7 +20,7 @@ service Wallet { }; - rpc CreateAccount(Account) returns (Transaction) { + rpc CreateAccount(AccountCreateContract) returns (Transaction) { }; @@ -28,7 +28,6 @@ service Wallet { }; - }; message Return { diff --git a/core/Contract.proto b/core/Contract.proto index ac62c4ee193..c8436a1de07 100644 --- a/core/Contract.proto +++ b/core/Contract.proto @@ -1,3 +1,18 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + syntax = "proto3"; package protocol; @@ -5,6 +20,13 @@ package protocol; option java_package = "org.tron.protos"; //Specify the name of the package that generated the Java file option java_outer_classname = "Contract"; //Specify the class name of the generated Java file +import "core/Tron.proto"; + +message AccountCreateContract{ + AccountType type = 1; + bytes accout_name = 2; + bytes address = 3; +} message TransferContract{ bytes from_address = 1; @@ -34,8 +56,10 @@ message VoteWitnessContract{ int32 count = 5; } -message WitnessContract{ - +message WitnessCreateContract{ + bytes account_address = 1; + bytes private_key = 2; + bytes url = 12; } message AssetIssueContract { diff --git a/core/Tron.proto b/core/Tron.proto index e5706cbcb55..fcb632cdaa5 100644 --- a/core/Tron.proto +++ b/core/Tron.proto @@ -8,15 +8,15 @@ package protocol; option java_package = "org.tron.protos"; //Specify the name of the package that generated the Java file option java_outer_classname = "Protocal"; //Specify the class name of the generated Java file -// Account -message Account { - enum AccountType { - Normal = 0; - AssertIssue = 1; - Contract = 2; - } +enum AccountType { + Normal = 0; + AssertIssue = 1; + Contract = 2; +} +// Account +message Account { bytes accout_name = 1; AccountType type = 2; bytes address = 3; @@ -80,8 +80,9 @@ message Transaction { bytes id = 1; TranscationType type = 2; - repeated TXInput vin = 3; - repeated TXOutput vout = 4; + repeated TXInput vin = 5; + repeated TXOutput vout = 7; + int64 expiration = 8; bytes data = 10; repeated google.protobuf.Any parameter = 11; repeated bytes signature = 14; From 08006dd06ea80a60a9dbfcf278bb236b04f1ca16 Mon Sep 17 00:00:00 2001 From: zhaohong Date: Wed, 28 Feb 2018 16:21:59 +0800 Subject: [PATCH 44/75] fix the enum type to be compatible with cpp. --- core/Tron.proto | 6 ------ core/TronInventoryItems.proto | 2 -- 2 files changed, 8 deletions(-) diff --git a/core/Tron.proto b/core/Tron.proto index fcb632cdaa5..58f27347172 100644 --- a/core/Tron.proto +++ b/core/Tron.proto @@ -26,12 +26,6 @@ message Account { } -// Contract -message Contract { - bytes address = 1; - bytes scripts = 2; - string name = 3; -} // Witness message Witness { diff --git a/core/TronInventoryItems.proto b/core/TronInventoryItems.proto index 899a3ca4f4b..41bbe9745c2 100644 --- a/core/TronInventoryItems.proto +++ b/core/TronInventoryItems.proto @@ -2,8 +2,6 @@ syntax = "proto3"; package protocal; -import "core/Tron.proto"; - option java_package = "org.tron.protos"; //Specify the name of the package that generated the Java file option java_outer_classname = "TronInventoryItems"; //Specify the class name of the generated Java file From 4b0ae6e7b9c0fe78c7cca2b8ef51e4cb1bfe7b66 Mon Sep 17 00:00:00 2001 From: zhaohong Date: Wed, 28 Feb 2018 20:50:49 +0800 Subject: [PATCH 45/75] improve the design transaction protocol to support mutil contract. --- core/Contract.proto | 37 ++++++++++++++++++++----------------- core/Tron.proto | 29 +++++++++++++---------------- 2 files changed, 33 insertions(+), 33 deletions(-) diff --git a/core/Contract.proto b/core/Contract.proto index c8436a1de07..e6216247fff 100644 --- a/core/Contract.proto +++ b/core/Contract.proto @@ -25,58 +25,61 @@ import "core/Tron.proto"; message AccountCreateContract{ AccountType type = 1; bytes accout_name = 2; - bytes address = 3; + bytes owner_address = 3; + + } message TransferContract{ - bytes from_address = 1; + bytes owner_address = 1; bytes to_address = 2; int64 amount = 3; } message TransferAssertContract{ bytes assert_name =1; - bytes from_address = 2; + bytes owner_address = 2; bytes to_address = 3; int64 amount = 4; } message VoteAssetContract{ - bytes address = 1; + bytes owner_address = 1; repeated bytes vote_address = 2; bool support = 3; int32 count = 5; } message VoteWitnessContract{ - bytes address = 1; + bytes owner_address = 1; repeated bytes vote_address = 2; bool support = 3; int32 count = 5; } message WitnessCreateContract{ - bytes account_address = 1; + bytes owner_address = 1; bytes private_key = 2; bytes url = 12; } message AssetIssueContract { - bytes name = 1; - int64 total_supply = 2; - int32 trx_num = 3; - int32 num = 4; - int64 start_time = 5; - int64 end_time = 6; - int32 decay_ratio = 7; - int32 vote_score = 8; - bytes description = 10; - bytes url =20; + bytes owner_address =1; + bytes name = 2; + int64 total_supply = 4; + int32 trx_num = 6; + int32 num = 8; + int64 start_time = 9; + int64 end_time = 10; + int32 decay_ratio = 15; + int32 vote_score = 16; + bytes description = 20; + bytes url =21; } message DeployContract{ - bytes address = 1; + bytes owner_address = 1; bytes script = 2; } diff --git a/core/Tron.proto b/core/Tron.proto index 58f27347172..83f38ec1f0e 100644 --- a/core/Tron.proto +++ b/core/Tron.proto @@ -47,13 +47,10 @@ message TXOutput { message TXInput { - message raw { bytes txID = 1; int64 vout = 2; - bytes pubKey = 4; - } - raw raw_data = 1; - bytes signature = 3; + bytes pubKey = 3; + bytes signature = 4; } @@ -62,7 +59,6 @@ message TXOutputs { } message Transaction { - enum TranscationType { Transfer = 0; DeployContract = 1; @@ -71,16 +67,17 @@ message Transaction { AssetIssue = 4; VoteAsset = 5; } - - bytes id = 1; - TranscationType type = 2; - repeated TXInput vin = 5; - repeated TXOutput vout = 7; - int64 expiration = 8; - bytes data = 10; - repeated google.protobuf.Any parameter = 11; - repeated bytes signature = 14; - bytes scripts = 16; + message raw { + TranscationType type = 2; + repeated TXInput vin = 5; + repeated TXOutput vout = 7; + int64 expiration = 8; + bytes data = 10; + repeated google.protobuf.Any parameter = 11; + bytes scripts = 16; + } + raw raw_data =1 ; + repeated bytes signature = 5; } message BlockHeader { From 066ccbbed566fc5e38459323e9a594b606ecfd12 Mon Sep 17 00:00:00 2001 From: zhaohong Date: Wed, 28 Feb 2018 21:03:34 +0800 Subject: [PATCH 46/75] redesign TXInput protocol. --- core/Tron.proto | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/core/Tron.proto b/core/Tron.proto index 83f38ec1f0e..ef00a8ee645 100644 --- a/core/Tron.proto +++ b/core/Tron.proto @@ -47,10 +47,13 @@ message TXOutput { message TXInput { + message raw { bytes txID = 1; int64 vout = 2; bytes pubKey = 3; - bytes signature = 4; + } + raw raw_data = 1; + bytes signature = 4; } From d0edfbc7d3f9b5b2e7b68fc14b4d19f35cbd4d66 Mon Sep 17 00:00:00 2001 From: zhaohong Date: Thu, 1 Mar 2018 11:55:49 +0800 Subject: [PATCH 47/75] improve Contract protocol. --- core/Tron.proto | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/core/Tron.proto b/core/Tron.proto index ef00a8ee645..60b536d88ef 100644 --- a/core/Tron.proto +++ b/core/Tron.proto @@ -63,12 +63,22 @@ message TXOutputs { message Transaction { enum TranscationType { - Transfer = 0; - DeployContract = 1; - CreateAccount = 2; - VoteWitess = 3; - AssetIssue = 4; - VoteAsset = 5; + Utxo = 0; + Contract = 1; + } + message Contract{ + enum ContractType{ + AccountCreateContract = 0; + TransferContract = 1; + TransferAssertContract = 2; + VoteAssetContract = 3; + VoteWitnessContract = 4; + WitnessCreateContract = 5; + AssetIssueContract = 6; + DeployContract = 7; + } + ContractType type = 1; + google.protobuf.Any parameter = 11; } message raw { TranscationType type = 2; @@ -76,7 +86,7 @@ message Transaction { repeated TXOutput vout = 7; int64 expiration = 8; bytes data = 10; - repeated google.protobuf.Any parameter = 11; + repeated Contract contract = 11; bytes scripts = 16; } raw raw_data =1 ; From d9a8eacaced38b6aee967b736b24f7a1c34298f4 Mon Sep 17 00:00:00 2001 From: zhaohong Date: Thu, 1 Mar 2018 14:05:27 +0800 Subject: [PATCH 48/75] rename Contract to ContractType --- core/Tron.proto | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/Tron.proto b/core/Tron.proto index 60b536d88ef..97f4bd43f1e 100644 --- a/core/Tron.proto +++ b/core/Tron.proto @@ -63,8 +63,8 @@ message TXOutputs { message Transaction { enum TranscationType { - Utxo = 0; - Contract = 1; + UtxoType = 0; + ContractType = 1; } message Contract{ enum ContractType{ From b2d3275a559a7bfe14ad87f07262bea8ec2ef48d Mon Sep 17 00:00:00 2001 From: Heng Zhang Date: Fri, 2 Mar 2018 17:54:39 +0800 Subject: [PATCH 49/75] fix: Word Spelling --- core/Contract.proto | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/core/Contract.proto b/core/Contract.proto index e6216247fff..098c257b3cf 100644 --- a/core/Contract.proto +++ b/core/Contract.proto @@ -22,50 +22,48 @@ option java_outer_classname = "Contract"; //Specify the class name of the genera import "core/Tron.proto"; -message AccountCreateContract{ +message AccountCreateContract { AccountType type = 1; - bytes accout_name = 2; + bytes account_name = 2; bytes owner_address = 3; - - } -message TransferContract{ +message TransferContract { bytes owner_address = 1; bytes to_address = 2; int64 amount = 3; } -message TransferAssertContract{ - bytes assert_name =1; +message TransferAssertContract { + bytes assert_name = 1; bytes owner_address = 2; bytes to_address = 3; int64 amount = 4; } -message VoteAssetContract{ +message VoteAssetContract { bytes owner_address = 1; repeated bytes vote_address = 2; bool support = 3; int32 count = 5; } -message VoteWitnessContract{ +message VoteWitnessContract { bytes owner_address = 1; repeated bytes vote_address = 2; bool support = 3; int32 count = 5; } -message WitnessCreateContract{ +message WitnessCreateContract { bytes owner_address = 1; bytes private_key = 2; bytes url = 12; } message AssetIssueContract { - bytes owner_address =1; + bytes owner_address = 1; bytes name = 2; int64 total_supply = 4; int32 trx_num = 6; @@ -75,10 +73,10 @@ message AssetIssueContract { int32 decay_ratio = 15; int32 vote_score = 16; bytes description = 20; - bytes url =21; + bytes url = 21; } -message DeployContract{ +message DeployContract { bytes owner_address = 1; bytes script = 2; } From 91dbb46191c9763f2a447ff360df7a8f44c71a6f Mon Sep 17 00:00:00 2001 From: Heng Zhang Date: Fri, 2 Mar 2018 17:55:24 +0800 Subject: [PATCH 50/75] feat: add vote message. --- core/Tron.proto | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/core/Tron.proto b/core/Tron.proto index 97f4bd43f1e..07dc9eefe5c 100644 --- a/core/Tron.proto +++ b/core/Tron.proto @@ -17,16 +17,19 @@ enum AccountType { // Account message Account { + message Vote { + bytes vote_address = 1; + int64 vote_count = 2; + } bytes accout_name = 1; AccountType type = 2; bytes address = 3; int64 balance = 4; - repeated string votes = 5; + repeated Vote votes = 5; map asset = 6; } - // Witness message Witness { bytes address = 1; @@ -66,8 +69,8 @@ message Transaction { UtxoType = 0; ContractType = 1; } - message Contract{ - enum ContractType{ + message Contract { + enum ContractType { AccountCreateContract = 0; TransferContract = 1; TransferAssertContract = 2; @@ -78,7 +81,7 @@ message Transaction { DeployContract = 7; } ContractType type = 1; - google.protobuf.Any parameter = 11; + google.protobuf.Any parameter = 2; } message raw { TranscationType type = 2; @@ -89,7 +92,7 @@ message Transaction { repeated Contract contract = 11; bytes scripts = 16; } - raw raw_data =1 ; + raw raw_data = 1; repeated bytes signature = 5; } @@ -118,8 +121,7 @@ message Block { // Inventory message Inventory { - enum InventoryType - { + enum InventoryType { TRX = 0; BLOCK = 1; } @@ -129,8 +131,7 @@ message Inventory { message Items { - enum ItemType - { + enum ItemType { ERR = 0; TRX = 1; BLOCK = 2; From 74bf3a79e6b46141c2174017f311c0c30b6d0d10 Mon Sep 17 00:00:00 2001 From: Heng Zhang Date: Mon, 5 Mar 2018 16:13:05 +0800 Subject: [PATCH 51/75] feat: add CreateWitness and VoteWitnessAccount api. --- api/api.proto | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/api/api.proto b/api/api.proto index f7aa336b5d2..04b3610ea37 100644 --- a/api/api.proto +++ b/api/api.proto @@ -20,14 +20,24 @@ service Wallet { }; - rpc CreateAccount(AccountCreateContract) returns (Transaction) { + rpc CreateAccount (AccountCreateContract) returns (Transaction) { }; - rpc CreateAssetIssue(AssetIssueContract) returns (Transaction) { + rpc VoteWitnessAccount (VoteWitnessContract) returns (Transaction) { }; + rpc CreateAssetIssue (AssetIssueContract) returns (Transaction) { + + }; + + + rpc CreateWitness (WitnessCreateContract) returns (Transaction) { + + }; + + }; message Return { From 30c866df93526ddf7e8823e2ddb82412c1142536 Mon Sep 17 00:00:00 2001 From: zhaohong Date: Tue, 6 Mar 2018 17:55:36 +0800 Subject: [PATCH 52/75] fixs typo. aasert->asset --- core/Tron.proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/Tron.proto b/core/Tron.proto index 07dc9eefe5c..765edf96d12 100644 --- a/core/Tron.proto +++ b/core/Tron.proto @@ -11,7 +11,7 @@ option java_outer_classname = "Protocal"; //Specify the class name of the genera enum AccountType { Normal = 0; - AssertIssue = 1; + AssetIssue = 1; Contract = 2; } From 3958deb31eceee64eea35407d1d4fef280bf883c Mon Sep 17 00:00:00 2001 From: sean-liu55 Date: Wed, 7 Mar 2018 10:45:48 +0800 Subject: [PATCH 53/75] minor change --- core/Contract.proto | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/Contract.proto b/core/Contract.proto index 098c257b3cf..defb17e8509 100644 --- a/core/Contract.proto +++ b/core/Contract.proto @@ -53,12 +53,12 @@ message VoteWitnessContract { bytes owner_address = 1; repeated bytes vote_address = 2; bool support = 3; - int32 count = 5; + repeated int32 count = 5; } message WitnessCreateContract { bytes owner_address = 1; - bytes private_key = 2; + bytes public_key = 2; bytes url = 12; } From 2f2d6bc60b45e3fb06c62fb1642794e1dce10fd3 Mon Sep 17 00:00:00 2001 From: Heng Zhang Date: Wed, 7 Mar 2018 11:56:35 +0800 Subject: [PATCH 54/75] refactor: Use VoteWitnessContract Vote message. --- core/Contract.proto | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/core/Contract.proto b/core/Contract.proto index defb17e8509..21d7640aaf3 100644 --- a/core/Contract.proto +++ b/core/Contract.proto @@ -50,10 +50,13 @@ message VoteAssetContract { } message VoteWitnessContract { + message Vote { + bytes vote_address = 1; + int64 vote_count = 2; + } bytes owner_address = 1; - repeated bytes vote_address = 2; + repeated Vote votes = 2; bool support = 3; - repeated int32 count = 5; } message WitnessCreateContract { From 458783edf3d88fd74fccdae79b182ae3f033ffa7 Mon Sep 17 00:00:00 2001 From: sean-liu55 Date: Wed, 7 Mar 2018 12:23:23 +0800 Subject: [PATCH 55/75] minor change --- core/Contract.proto | 1 - 1 file changed, 1 deletion(-) diff --git a/core/Contract.proto b/core/Contract.proto index 21d7640aaf3..8b3fff1167f 100644 --- a/core/Contract.proto +++ b/core/Contract.proto @@ -61,7 +61,6 @@ message VoteWitnessContract { message WitnessCreateContract { bytes owner_address = 1; - bytes public_key = 2; bytes url = 12; } From 9069d35f7e48036338ce29590f210531838f17b4 Mon Sep 17 00:00:00 2001 From: zhaohong Date: Wed, 7 Mar 2018 14:26:05 +0800 Subject: [PATCH 56/75] add blockInventory protocol. --- core/Tron.proto | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/core/Tron.proto b/core/Tron.proto index 07dc9eefe5c..41830f29c07 100644 --- a/core/Tron.proto +++ b/core/Tron.proto @@ -103,8 +103,8 @@ message BlockHeader { bytes parentHash = 3; //bytes nonce = 5; //bytes difficulty = 6; - uint64 number = 7; - uint64 witness_id = 8; + int64 number = 7; + int64 witness_id = 8; bytes witness_address = 9; } raw raw_data = 1; @@ -120,6 +120,21 @@ message Block { // Inventory +message BlockInventory { + enum Type { + SYNC = 0; + ADVTISE = 1; + FETCH = 2; + } + + message BlockId { + bytes hash = 1; + int64 number = 2; + } + repeated BlockId ids = 1; + Type type = 2; +} + message Inventory { enum InventoryType { TRX = 0; @@ -129,7 +144,6 @@ message Inventory { repeated bytes ids = 2; } - message Items { enum ItemType { ERR = 0; From 3ad4309b69019de0d90acab57a8c49199d27239d Mon Sep 17 00:00:00 2001 From: AhnSinYong Date: Thu, 8 Mar 2018 12:49:19 +0900 Subject: [PATCH 57/75] - Fix spelling errors --- core/Tron.proto | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/core/Tron.proto b/core/Tron.proto index 357b2acb3b0..61dc1889462 100644 --- a/core/Tron.proto +++ b/core/Tron.proto @@ -6,7 +6,7 @@ package protocol; option java_package = "org.tron.protos"; //Specify the name of the package that generated the Java file -option java_outer_classname = "Protocal"; //Specify the class name of the generated Java file +option java_outer_classname = "Protocol"; //Specify the class name of the generated Java file enum AccountType { @@ -21,13 +21,12 @@ message Account { bytes vote_address = 1; int64 vote_count = 2; } - bytes accout_name = 1; + bytes account_name = 1; AccountType type = 2; bytes address = 3; int64 balance = 4; repeated Vote votes = 5; map asset = 6; - } // Witness @@ -41,14 +40,12 @@ message Witness { int64 latestBlockNum = 7; } -// Transcation - +// Transaction message TXOutput { int64 value = 1; bytes pubKeyHash = 2; } - message TXInput { message raw { bytes txID = 1; @@ -57,7 +54,6 @@ message TXInput { } raw raw_data = 1; bytes signature = 4; - } message TXOutputs { @@ -65,7 +61,7 @@ message TXOutputs { } message Transaction { - enum TranscationType { + enum TransactionType { UtxoType = 0; ContractType = 1; } @@ -84,7 +80,7 @@ message Transaction { google.protobuf.Any parameter = 2; } message raw { - TranscationType type = 2; + TransactionType type = 2; repeated TXInput vin = 5; repeated TXOutput vout = 7; int64 expiration = 8; @@ -112,14 +108,12 @@ message BlockHeader { } // block - message Block { repeated Transaction transactions = 1; BlockHeader block_header = 2; } // Inventory - message BlockInventory { enum Type { SYNC = 0; From e7aacda2beb736ec7672da5bf3bfed16635b58f2 Mon Sep 17 00:00:00 2001 From: AhnSinYong Date: Thu, 8 Mar 2018 13:05:19 +0900 Subject: [PATCH 58/75] - Fix spelling errors --- core/TronInventoryItems.proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/TronInventoryItems.proto b/core/TronInventoryItems.proto index 41bbe9745c2..fb16f1d5431 100644 --- a/core/TronInventoryItems.proto +++ b/core/TronInventoryItems.proto @@ -1,6 +1,6 @@ syntax = "proto3"; -package protocal; +package protocol; option java_package = "org.tron.protos"; //Specify the name of the package that generated the Java file option java_outer_classname = "TronInventoryItems"; //Specify the class name of the generated Java file From 4df6a1834f137b5a771b9336c5acba49ae8c24ba Mon Sep 17 00:00:00 2001 From: sean-liu55 Date: Thu, 8 Mar 2018 15:04:18 +0800 Subject: [PATCH 59/75] add query api --- api/api.proto | 8 +++++++- core/Tron.proto | 8 ++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/api/api.proto b/api/api.proto index 04b3610ea37..71de6279634 100644 --- a/api/api.proto +++ b/api/api.proto @@ -20,6 +20,10 @@ service Wallet { }; + rpc ListAccounts () returns (AccountList) { + + }; + rpc CreateAccount (AccountCreateContract) returns (Transaction) { }; @@ -32,12 +36,14 @@ service Wallet { }; + rpc ListWitnesses () returns (WitnessList) { + + }; rpc CreateWitness (WitnessCreateContract) returns (Transaction) { }; - }; message Return { diff --git a/core/Tron.proto b/core/Tron.proto index 41830f29c07..f59d7160249 100644 --- a/core/Tron.proto +++ b/core/Tron.proto @@ -30,6 +30,10 @@ message Account { } +message AccountList{ + repeated Account accounts = 1; +} + // Witness message Witness { bytes address = 1; @@ -41,6 +45,10 @@ message Witness { int64 latestBlockNum = 7; } +message WitnessList{ + repeated Witness witnesses = 1; +} + // Transcation message TXOutput { From c5f242e91aaf8f73025a2bf370f15874b1bfc517 Mon Sep 17 00:00:00 2001 From: sean-liu55 Date: Thu, 8 Mar 2018 17:11:03 +0800 Subject: [PATCH 60/75] add NullMessage --- api/api.proto | 4 ++-- core/Tron.proto | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/api/api.proto b/api/api.proto index 71de6279634..7d18eaaa70c 100644 --- a/api/api.proto +++ b/api/api.proto @@ -20,7 +20,7 @@ service Wallet { }; - rpc ListAccounts () returns (AccountList) { + rpc ListAccounts (NullMessage) returns (AccountList) { }; @@ -36,7 +36,7 @@ service Wallet { }; - rpc ListWitnesses () returns (WitnessList) { + rpc ListWitnesses (NullMessage) returns (WitnessList) { }; diff --git a/core/Tron.proto b/core/Tron.proto index f59d7160249..01d7609ea6d 100644 --- a/core/Tron.proto +++ b/core/Tron.proto @@ -49,6 +49,9 @@ message WitnessList{ repeated Witness witnesses = 1; } +message NullMessage{ +} + // Transcation message TXOutput { From 52e073be9ae4aa32c250a6898f6fb3a43bd3befb Mon Sep 17 00:00:00 2001 From: sean-liu55 Date: Thu, 8 Mar 2018 18:03:39 +0800 Subject: [PATCH 61/75] move struct --- api/api.proto | 15 +++++++++++++-- core/Tron.proto | 10 +--------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/api/api.proto b/api/api.proto index 7d18eaaa70c..46ae224d24d 100644 --- a/api/api.proto +++ b/api/api.proto @@ -20,7 +20,7 @@ service Wallet { }; - rpc ListAccounts (NullMessage) returns (AccountList) { + rpc ListAccounts (EmptyMessage) returns (AccountList) { }; @@ -36,7 +36,7 @@ service Wallet { }; - rpc ListWitnesses (NullMessage) returns (WitnessList) { + rpc ListWitnesses (EmptyMessage) returns (WitnessList) { }; @@ -49,3 +49,14 @@ service Wallet { message Return { bool result = 1; } + +message AccountList{ + repeated Account accounts = 1; +} + +message WitnessList{ + repeated Witness witnesses = 1; +} + +message EmptyMessage{ +} diff --git a/core/Tron.proto b/core/Tron.proto index 01d7609ea6d..1152e27400f 100644 --- a/core/Tron.proto +++ b/core/Tron.proto @@ -30,9 +30,7 @@ message Account { } -message AccountList{ - repeated Account accounts = 1; -} + // Witness message Witness { @@ -45,12 +43,6 @@ message Witness { int64 latestBlockNum = 7; } -message WitnessList{ - repeated Witness witnesses = 1; -} - -message NullMessage{ -} // Transcation From 82785c7cf3845261e9baac4598cb0920a6cbae97 Mon Sep 17 00:00:00 2001 From: sasaxie Date: Fri, 9 Mar 2018 14:14:50 +0800 Subject: [PATCH 62/75] add gossip node info message --- api/api.proto | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/api/api.proto b/api/api.proto index 46ae224d24d..77e4be1938c 100644 --- a/api/api.proto +++ b/api/api.proto @@ -44,19 +44,38 @@ service Wallet { }; + rpc ListNodes (EmptyMessage) returns (NodeList) { + + } }; message Return { bool result = 1; } -message AccountList{ +message AccountList { repeated Account accounts = 1; } -message WitnessList{ +message WitnessList { repeated Witness witnesses = 1; } -message EmptyMessage{ +// Gossip node list +message NodeList { + repeated Node nodes = 1; +} + +// Gossip node +message Node { + Address address = 1; +} + +// Gossip node address +message Address { + bytes host = 1; + int32 port = 2; +} + +message EmptyMessage { } From 8592e309520ec9714445c50dae08663b77e11c1f Mon Sep 17 00:00:00 2001 From: sean-liu55 Date: Fri, 9 Mar 2018 19:36:43 +0800 Subject: [PATCH 63/75] add latestSlotNum in witness message --- core/Tron.proto | 1 + 1 file changed, 1 insertion(+) diff --git a/core/Tron.proto b/core/Tron.proto index 20612740a00..eb3e11785b4 100644 --- a/core/Tron.proto +++ b/core/Tron.proto @@ -40,6 +40,7 @@ message Witness { int64 totalProduced = 5; int64 totalMissed = 6; int64 latestBlockNum = 7; + int64 latestSlotNum = 8; } From d72ac6c22eac8c6872e236b9c4519df6e64a3c67 Mon Sep 17 00:00:00 2001 From: sean-liu55 Date: Fri, 9 Mar 2018 19:41:32 +0800 Subject: [PATCH 64/75] add latestSlotNum in witness message --- core/Tron.proto | 1 + 1 file changed, 1 insertion(+) diff --git a/core/Tron.proto b/core/Tron.proto index e0fc96ecb0e..78a3cfc08a9 100644 --- a/core/Tron.proto +++ b/core/Tron.proto @@ -41,6 +41,7 @@ message Witness { int64 totalProduced = 5; int64 totalMissed = 6; int64 latestBlockNum = 7; + int64 latestSlotNum = 8; } From ecf2ef4e18df11f77bece474d9f3c7067d0e8588 Mon Sep 17 00:00:00 2001 From: sean-liu55 Date: Fri, 9 Mar 2018 20:20:44 +0800 Subject: [PATCH 65/75] add latestSlotNum in witness message --- core/Tron.proto | 1 - 1 file changed, 1 deletion(-) diff --git a/core/Tron.proto b/core/Tron.proto index 78a3cfc08a9..e0fc96ecb0e 100644 --- a/core/Tron.proto +++ b/core/Tron.proto @@ -41,7 +41,6 @@ message Witness { int64 totalProduced = 5; int64 totalMissed = 6; int64 latestBlockNum = 7; - int64 latestSlotNum = 8; } From 4c528b1e45b6dd2cf82354eb7fe20626639bf2e3 Mon Sep 17 00:00:00 2001 From: Heng Zhang Date: Sat, 10 Mar 2018 19:03:28 +0800 Subject: [PATCH 66/75] feat: add isJobs Witness. --- core/Tron.proto | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/Tron.proto b/core/Tron.proto index 41830f29c07..9d5bc6a9373 100644 --- a/core/Tron.proto +++ b/core/Tron.proto @@ -39,11 +39,13 @@ message Witness { int64 totalProduced = 5; int64 totalMissed = 6; int64 latestBlockNum = 7; + bool isJobs = 8; } // Transcation -message TXOutput { +message + TXOutput { int64 value = 1; bytes pubKeyHash = 2; } From 8f3e1052f34abd1ba46b129187c9aef5559c38c3 Mon Sep 17 00:00:00 2001 From: Heng Zhang Date: Sat, 10 Mar 2018 19:23:17 +0800 Subject: [PATCH 67/75] Merge branch 'master' of https://github.com/tronprotocol/protocol # Conflicts: # core/Tron.proto --- core/Tron.proto | 1 + 1 file changed, 1 insertion(+) diff --git a/core/Tron.proto b/core/Tron.proto index 78a3cfc08a9..48d2b9a5ec7 100644 --- a/core/Tron.proto +++ b/core/Tron.proto @@ -42,6 +42,7 @@ message Witness { int64 totalMissed = 6; int64 latestBlockNum = 7; int64 latestSlotNum = 8; + bool isJobs = 9; } From 0d9b284f0edbc67638ac99239d8435d554862bd2 Mon Sep 17 00:00:00 2001 From: Heng Zhang Date: Sat, 10 Mar 2018 19:24:35 +0800 Subject: [PATCH 68/75] Merge branch 'master' of https://github.com/tronprotocol/protocol # Conflicts: # core/Tron.proto --- core/Tron.proto | 3 --- 1 file changed, 3 deletions(-) diff --git a/core/Tron.proto b/core/Tron.proto index 48d2b9a5ec7..c7bd89e63da 100644 --- a/core/Tron.proto +++ b/core/Tron.proto @@ -30,8 +30,6 @@ message Account { } - - // Witness message Witness { bytes address = 1; @@ -45,7 +43,6 @@ message Witness { bool isJobs = 9; } - // Transcation message TXOutput { From 053280ab16378167a5d25bba4c2c7101e280706f Mon Sep 17 00:00:00 2001 From: olivier Date: Mon, 12 Mar 2018 16:41:54 +0800 Subject: [PATCH 69/75] add chain inv --- core/Tron.proto | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/core/Tron.proto b/core/Tron.proto index c7bd89e63da..63b25d951a2 100644 --- a/core/Tron.proto +++ b/core/Tron.proto @@ -117,6 +117,15 @@ message Block { BlockHeader block_header = 2; } +message ChainInventory { + message BlockId { + bytes hash = 1; + int64 number = 2; + } + repteated BlockId ids = 1; + int64 remain_num = 2; +} + // Inventory message BlockInventory { enum Type { From fde469d6edccd009193f4518b810a710e562b980 Mon Sep 17 00:00:00 2001 From: zhaohong Date: Mon, 12 Mar 2018 16:46:45 +0800 Subject: [PATCH 70/75] fix typos --- core/Tron.proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/Tron.proto b/core/Tron.proto index 63b25d951a2..4b5d5446c7e 100644 --- a/core/Tron.proto +++ b/core/Tron.proto @@ -122,7 +122,7 @@ message ChainInventory { bytes hash = 1; int64 number = 2; } - repteated BlockId ids = 1; + repeated BlockId ids = 1; int64 remain_num = 2; } From e5db43ebcc7b4ecdea126ce882687c80264af82b Mon Sep 17 00:00:00 2001 From: zhaohong Date: Mon, 12 Mar 2018 20:15:33 +0800 Subject: [PATCH 71/75] add ret to transaction. --- core/Tron.proto | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/core/Tron.proto b/core/Tron.proto index 4b5d5446c7e..a5b3698489c 100644 --- a/core/Tron.proto +++ b/core/Tron.proto @@ -83,6 +83,16 @@ message Transaction { ContractType type = 1; google.protobuf.Any parameter = 2; } + + message Result { + enum code { + SUCESS = 0; + FAILED = 1; + } + int64 fee = 1; + code ret = 2; + } + message raw { TransactionType type = 2; repeated TXInput vin = 5; @@ -92,8 +102,10 @@ message Transaction { repeated Contract contract = 11; bytes scripts = 16; } + raw raw_data = 1; - repeated bytes signature = 5; + repeated bytes signature = 2; + repeated Result ret = 5; } message BlockHeader { From bb3a5787144ab455f70576971fc07588a03c9982 Mon Sep 17 00:00:00 2001 From: Matt Yue Date: Wed, 14 Mar 2018 18:41:43 +0800 Subject: [PATCH 72/75] improve code readability --- .gitignore | 4 + .travis.yml | 19 ++++ LICENSE | 165 +++++++++++++++++++++++++++++++ README.md | 8 ++ api/api.proto | 81 ++++++++++++++++ core/Contract.proto | 85 ++++++++++++++++ core/Tron.proto | 178 ++++++++++++++++++++++++++++++++++ core/TronInventoryItems.proto | 11 +++ install-protobuf.sh | 10 ++ 9 files changed, 561 insertions(+) create mode 100644 .gitignore create mode 100644 .travis.yml create mode 100644 LICENSE create mode 100644 README.md create mode 100644 api/api.proto create mode 100644 core/Contract.proto create mode 100644 core/Tron.proto create mode 100644 core/TronInventoryItems.proto create mode 100755 install-protobuf.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000000..1554c5edd92 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +# IDEA +.idea +*iml +.DS_Store diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000000..3f1e4c4709b --- /dev/null +++ b/.travis.yml @@ -0,0 +1,19 @@ +language: ruby + +cache: + directories: + - $HOME/protobuf + +sudo: false + +before_install: + - bash install-protobuf.sh + +# check what has been installed by listing contents of protobuf folder +before_script: + - ls -R $HOME/protobuf + +# let's use protobuf +script: + - $HOME/protobuf/bin/protoc --java_out=./ ./core/*.proto ./api/*.proto + - ls -l \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000000..65c5ca88a67 --- /dev/null +++ b/LICENSE @@ -0,0 +1,165 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. diff --git a/README.md b/README.md new file mode 100644 index 00000000000..c04fbf6968a --- /dev/null +++ b/README.md @@ -0,0 +1,8 @@ +# protocol [![Build Status](https://travis-ci.org/tronprotocol/protocol.svg?branch=master)](https://travis-ci.org/tronprotocol/protocol) + + +the protocol of tron including api and message. + +java-tron and wallet-cli + +git subtree pull --prefix src/main/protos/ protocol master diff --git a/api/api.proto b/api/api.proto new file mode 100644 index 00000000000..77e4be1938c --- /dev/null +++ b/api/api.proto @@ -0,0 +1,81 @@ +syntax = "proto3"; +package protocol; + +import "core/Tron.proto"; +import "core/Contract.proto"; + +option java_package = "org.tron.api"; //Specify the name of the package that generated the Java file +option java_outer_classname = "GrpcAPI"; //Specify the class name of the generated Java file + +service Wallet { + + rpc GetBalance (Account) returns (Account) { + + }; + rpc CreateTransaction (TransferContract) returns (Transaction) { + + }; + + rpc BroadcastTransaction (Transaction) returns (Return) { + + }; + + rpc ListAccounts (EmptyMessage) returns (AccountList) { + + }; + + rpc CreateAccount (AccountCreateContract) returns (Transaction) { + + }; + + rpc VoteWitnessAccount (VoteWitnessContract) returns (Transaction) { + + }; + + rpc CreateAssetIssue (AssetIssueContract) returns (Transaction) { + + }; + + rpc ListWitnesses (EmptyMessage) returns (WitnessList) { + + }; + + rpc CreateWitness (WitnessCreateContract) returns (Transaction) { + + }; + + rpc ListNodes (EmptyMessage) returns (NodeList) { + + } +}; + +message Return { + bool result = 1; +} + +message AccountList { + repeated Account accounts = 1; +} + +message WitnessList { + repeated Witness witnesses = 1; +} + +// Gossip node list +message NodeList { + repeated Node nodes = 1; +} + +// Gossip node +message Node { + Address address = 1; +} + +// Gossip node address +message Address { + bytes host = 1; + int32 port = 2; +} + +message EmptyMessage { +} diff --git a/core/Contract.proto b/core/Contract.proto new file mode 100644 index 00000000000..8b3fff1167f --- /dev/null +++ b/core/Contract.proto @@ -0,0 +1,85 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +syntax = "proto3"; + +package protocol; + +option java_package = "org.tron.protos"; //Specify the name of the package that generated the Java file +option java_outer_classname = "Contract"; //Specify the class name of the generated Java file + +import "core/Tron.proto"; + +message AccountCreateContract { + AccountType type = 1; + bytes account_name = 2; + bytes owner_address = 3; +} + +message TransferContract { + bytes owner_address = 1; + bytes to_address = 2; + int64 amount = 3; +} + +message TransferAssertContract { + bytes assert_name = 1; + bytes owner_address = 2; + bytes to_address = 3; + int64 amount = 4; +} + + +message VoteAssetContract { + bytes owner_address = 1; + repeated bytes vote_address = 2; + bool support = 3; + int32 count = 5; +} + +message VoteWitnessContract { + message Vote { + bytes vote_address = 1; + int64 vote_count = 2; + } + bytes owner_address = 1; + repeated Vote votes = 2; + bool support = 3; +} + +message WitnessCreateContract { + bytes owner_address = 1; + bytes url = 12; +} + +message AssetIssueContract { + bytes owner_address = 1; + bytes name = 2; + int64 total_supply = 4; + int32 trx_num = 6; + int32 num = 8; + int64 start_time = 9; + int64 end_time = 10; + int32 decay_ratio = 15; + int32 vote_score = 16; + bytes description = 20; + bytes url = 21; +} + +message DeployContract { + bytes owner_address = 1; + bytes script = 2; +} + diff --git a/core/Tron.proto b/core/Tron.proto new file mode 100644 index 00000000000..a5b3698489c --- /dev/null +++ b/core/Tron.proto @@ -0,0 +1,178 @@ +syntax = "proto3"; + +import "google/protobuf/any.proto"; + +package protocol; + + +option java_package = "org.tron.protos"; //Specify the name of the package that generated the Java file +option java_outer_classname = "Protocol"; //Specify the class name of the generated Java file + + +enum AccountType { + Normal = 0; + AssetIssue = 1; + Contract = 2; +} + +// Account +message Account { + message Vote { + bytes vote_address = 1; + int64 vote_count = 2; + } + bytes account_name = 1; + AccountType type = 2; + bytes address = 3; + int64 balance = 4; + repeated Vote votes = 5; + map asset = 6; + +} + +// Witness +message Witness { + bytes address = 1; + int64 voteCount = 2; + bytes pubKey = 3; + string url = 4; + int64 totalProduced = 5; + int64 totalMissed = 6; + int64 latestBlockNum = 7; + int64 latestSlotNum = 8; + bool isJobs = 9; +} + +// Transcation + +message TXOutput { + int64 value = 1; + bytes pubKeyHash = 2; +} + +message TXInput { + message raw { + bytes txID = 1; + int64 vout = 2; + bytes pubKey = 3; + } + raw raw_data = 1; + bytes signature = 4; +} + +message TXOutputs { + repeated TXOutput outputs = 1; +} + +message Transaction { + enum TransactionType { + UtxoType = 0; + ContractType = 1; + } + message Contract { + enum ContractType { + AccountCreateContract = 0; + TransferContract = 1; + TransferAssertContract = 2; + VoteAssetContract = 3; + VoteWitnessContract = 4; + WitnessCreateContract = 5; + AssetIssueContract = 6; + DeployContract = 7; + } + ContractType type = 1; + google.protobuf.Any parameter = 2; + } + + message Result { + enum code { + SUCESS = 0; + FAILED = 1; + } + int64 fee = 1; + code ret = 2; + } + + message raw { + TransactionType type = 2; + repeated TXInput vin = 5; + repeated TXOutput vout = 7; + int64 expiration = 8; + bytes data = 10; + repeated Contract contract = 11; + bytes scripts = 16; + } + + raw raw_data = 1; + repeated bytes signature = 2; + repeated Result ret = 5; +} + +message BlockHeader { + message raw { + int64 timestamp = 1; + bytes txTrieRoot = 2; + bytes parentHash = 3; + //bytes nonce = 5; + //bytes difficulty = 6; + int64 number = 7; + int64 witness_id = 8; + bytes witness_address = 9; + } + raw raw_data = 1; + bytes witness_signature = 2; +} + +// block +message Block { + repeated Transaction transactions = 1; + BlockHeader block_header = 2; +} + +message ChainInventory { + message BlockId { + bytes hash = 1; + int64 number = 2; + } + repeated BlockId ids = 1; + int64 remain_num = 2; +} + +// Inventory +message BlockInventory { + enum Type { + SYNC = 0; + ADVTISE = 1; + FETCH = 2; + } + + message BlockId { + bytes hash = 1; + int64 number = 2; + } + repeated BlockId ids = 1; + Type type = 2; +} + +message Inventory { + enum InventoryType { + TRX = 0; + BLOCK = 1; + } + InventoryType type = 1; + repeated bytes ids = 2; +} + +message Items { + enum ItemType { + ERR = 0; + TRX = 1; + BLOCK = 2; + BLOCKHEADER = 3; + } + + ItemType type = 1; + repeated Block blocks = 2; + repeated BlockHeader block_headers = 3; + repeated Transaction transactions = 4; +} diff --git a/core/TronInventoryItems.proto b/core/TronInventoryItems.proto new file mode 100644 index 00000000000..fb16f1d5431 --- /dev/null +++ b/core/TronInventoryItems.proto @@ -0,0 +1,11 @@ +syntax = "proto3"; + +package protocol; + +option java_package = "org.tron.protos"; //Specify the name of the package that generated the Java file +option java_outer_classname = "TronInventoryItems"; //Specify the class name of the generated Java file + +message InventoryItems { + int32 type = 1; + repeated bytes items = 2; +} \ No newline at end of file diff --git a/install-protobuf.sh b/install-protobuf.sh new file mode 100755 index 00000000000..29e5536ee6d --- /dev/null +++ b/install-protobuf.sh @@ -0,0 +1,10 @@ +#!/bin/sh +set -e +# check to see if protobuf folder is empty +if [ ! -d "$HOME/protobuf/lib" ]; then + wget https://github.com/google/protobuf/releases/download/v3.5.1/protobuf-java-3.5.1.tar.gz + tar -xzvf protobuf-java-3.5.1.tar.gz + cd protobuf-3.5.1 && ./configure --prefix=$HOME/protobuf && make && make install +else + echo "Using cached directory." +fi From f57f01460905e7522830b83f16fb1c333ec97b31 Mon Sep 17 00:00:00 2001 From: zhaohong Date: Wed, 14 Mar 2018 19:02:39 +0800 Subject: [PATCH 73/75] add latest_opration_time to account protocol. --- core/Tron.proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/Tron.proto b/core/Tron.proto index a5b3698489c..fc48f122c51 100644 --- a/core/Tron.proto +++ b/core/Tron.proto @@ -27,7 +27,7 @@ message Account { int64 balance = 4; repeated Vote votes = 5; map asset = 6; - + int64 latest_opration_time = 10; } // Witness From 164d8bde8a767ea4959d5be3371e9f777f54a894 Mon Sep 17 00:00:00 2001 From: olivier Date: Wed, 14 Mar 2018 22:21:04 +0800 Subject: [PATCH 74/75] remove dupicated number refresh --- .gitignore | 4 + .travis.yml | 19 ++++ LICENSE | 165 +++++++++++++++++++++++++++++++ README.md | 8 ++ api/api.proto | 81 ++++++++++++++++ core/Contract.proto | 85 ++++++++++++++++ core/Tron.proto | 178 ++++++++++++++++++++++++++++++++++ core/TronInventoryItems.proto | 11 +++ install-protobuf.sh | 10 ++ 9 files changed, 561 insertions(+) create mode 100644 .gitignore create mode 100644 .travis.yml create mode 100644 LICENSE create mode 100644 README.md create mode 100644 api/api.proto create mode 100644 core/Contract.proto create mode 100644 core/Tron.proto create mode 100644 core/TronInventoryItems.proto create mode 100755 install-protobuf.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000000..1554c5edd92 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +# IDEA +.idea +*iml +.DS_Store diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000000..3f1e4c4709b --- /dev/null +++ b/.travis.yml @@ -0,0 +1,19 @@ +language: ruby + +cache: + directories: + - $HOME/protobuf + +sudo: false + +before_install: + - bash install-protobuf.sh + +# check what has been installed by listing contents of protobuf folder +before_script: + - ls -R $HOME/protobuf + +# let's use protobuf +script: + - $HOME/protobuf/bin/protoc --java_out=./ ./core/*.proto ./api/*.proto + - ls -l \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000000..65c5ca88a67 --- /dev/null +++ b/LICENSE @@ -0,0 +1,165 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. diff --git a/README.md b/README.md new file mode 100644 index 00000000000..c04fbf6968a --- /dev/null +++ b/README.md @@ -0,0 +1,8 @@ +# protocol [![Build Status](https://travis-ci.org/tronprotocol/protocol.svg?branch=master)](https://travis-ci.org/tronprotocol/protocol) + + +the protocol of tron including api and message. + +java-tron and wallet-cli + +git subtree pull --prefix src/main/protos/ protocol master diff --git a/api/api.proto b/api/api.proto new file mode 100644 index 00000000000..77e4be1938c --- /dev/null +++ b/api/api.proto @@ -0,0 +1,81 @@ +syntax = "proto3"; +package protocol; + +import "core/Tron.proto"; +import "core/Contract.proto"; + +option java_package = "org.tron.api"; //Specify the name of the package that generated the Java file +option java_outer_classname = "GrpcAPI"; //Specify the class name of the generated Java file + +service Wallet { + + rpc GetBalance (Account) returns (Account) { + + }; + rpc CreateTransaction (TransferContract) returns (Transaction) { + + }; + + rpc BroadcastTransaction (Transaction) returns (Return) { + + }; + + rpc ListAccounts (EmptyMessage) returns (AccountList) { + + }; + + rpc CreateAccount (AccountCreateContract) returns (Transaction) { + + }; + + rpc VoteWitnessAccount (VoteWitnessContract) returns (Transaction) { + + }; + + rpc CreateAssetIssue (AssetIssueContract) returns (Transaction) { + + }; + + rpc ListWitnesses (EmptyMessage) returns (WitnessList) { + + }; + + rpc CreateWitness (WitnessCreateContract) returns (Transaction) { + + }; + + rpc ListNodes (EmptyMessage) returns (NodeList) { + + } +}; + +message Return { + bool result = 1; +} + +message AccountList { + repeated Account accounts = 1; +} + +message WitnessList { + repeated Witness witnesses = 1; +} + +// Gossip node list +message NodeList { + repeated Node nodes = 1; +} + +// Gossip node +message Node { + Address address = 1; +} + +// Gossip node address +message Address { + bytes host = 1; + int32 port = 2; +} + +message EmptyMessage { +} diff --git a/core/Contract.proto b/core/Contract.proto new file mode 100644 index 00000000000..8b3fff1167f --- /dev/null +++ b/core/Contract.proto @@ -0,0 +1,85 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +syntax = "proto3"; + +package protocol; + +option java_package = "org.tron.protos"; //Specify the name of the package that generated the Java file +option java_outer_classname = "Contract"; //Specify the class name of the generated Java file + +import "core/Tron.proto"; + +message AccountCreateContract { + AccountType type = 1; + bytes account_name = 2; + bytes owner_address = 3; +} + +message TransferContract { + bytes owner_address = 1; + bytes to_address = 2; + int64 amount = 3; +} + +message TransferAssertContract { + bytes assert_name = 1; + bytes owner_address = 2; + bytes to_address = 3; + int64 amount = 4; +} + + +message VoteAssetContract { + bytes owner_address = 1; + repeated bytes vote_address = 2; + bool support = 3; + int32 count = 5; +} + +message VoteWitnessContract { + message Vote { + bytes vote_address = 1; + int64 vote_count = 2; + } + bytes owner_address = 1; + repeated Vote votes = 2; + bool support = 3; +} + +message WitnessCreateContract { + bytes owner_address = 1; + bytes url = 12; +} + +message AssetIssueContract { + bytes owner_address = 1; + bytes name = 2; + int64 total_supply = 4; + int32 trx_num = 6; + int32 num = 8; + int64 start_time = 9; + int64 end_time = 10; + int32 decay_ratio = 15; + int32 vote_score = 16; + bytes description = 20; + bytes url = 21; +} + +message DeployContract { + bytes owner_address = 1; + bytes script = 2; +} + diff --git a/core/Tron.proto b/core/Tron.proto new file mode 100644 index 00000000000..a5b3698489c --- /dev/null +++ b/core/Tron.proto @@ -0,0 +1,178 @@ +syntax = "proto3"; + +import "google/protobuf/any.proto"; + +package protocol; + + +option java_package = "org.tron.protos"; //Specify the name of the package that generated the Java file +option java_outer_classname = "Protocol"; //Specify the class name of the generated Java file + + +enum AccountType { + Normal = 0; + AssetIssue = 1; + Contract = 2; +} + +// Account +message Account { + message Vote { + bytes vote_address = 1; + int64 vote_count = 2; + } + bytes account_name = 1; + AccountType type = 2; + bytes address = 3; + int64 balance = 4; + repeated Vote votes = 5; + map asset = 6; + +} + +// Witness +message Witness { + bytes address = 1; + int64 voteCount = 2; + bytes pubKey = 3; + string url = 4; + int64 totalProduced = 5; + int64 totalMissed = 6; + int64 latestBlockNum = 7; + int64 latestSlotNum = 8; + bool isJobs = 9; +} + +// Transcation + +message TXOutput { + int64 value = 1; + bytes pubKeyHash = 2; +} + +message TXInput { + message raw { + bytes txID = 1; + int64 vout = 2; + bytes pubKey = 3; + } + raw raw_data = 1; + bytes signature = 4; +} + +message TXOutputs { + repeated TXOutput outputs = 1; +} + +message Transaction { + enum TransactionType { + UtxoType = 0; + ContractType = 1; + } + message Contract { + enum ContractType { + AccountCreateContract = 0; + TransferContract = 1; + TransferAssertContract = 2; + VoteAssetContract = 3; + VoteWitnessContract = 4; + WitnessCreateContract = 5; + AssetIssueContract = 6; + DeployContract = 7; + } + ContractType type = 1; + google.protobuf.Any parameter = 2; + } + + message Result { + enum code { + SUCESS = 0; + FAILED = 1; + } + int64 fee = 1; + code ret = 2; + } + + message raw { + TransactionType type = 2; + repeated TXInput vin = 5; + repeated TXOutput vout = 7; + int64 expiration = 8; + bytes data = 10; + repeated Contract contract = 11; + bytes scripts = 16; + } + + raw raw_data = 1; + repeated bytes signature = 2; + repeated Result ret = 5; +} + +message BlockHeader { + message raw { + int64 timestamp = 1; + bytes txTrieRoot = 2; + bytes parentHash = 3; + //bytes nonce = 5; + //bytes difficulty = 6; + int64 number = 7; + int64 witness_id = 8; + bytes witness_address = 9; + } + raw raw_data = 1; + bytes witness_signature = 2; +} + +// block +message Block { + repeated Transaction transactions = 1; + BlockHeader block_header = 2; +} + +message ChainInventory { + message BlockId { + bytes hash = 1; + int64 number = 2; + } + repeated BlockId ids = 1; + int64 remain_num = 2; +} + +// Inventory +message BlockInventory { + enum Type { + SYNC = 0; + ADVTISE = 1; + FETCH = 2; + } + + message BlockId { + bytes hash = 1; + int64 number = 2; + } + repeated BlockId ids = 1; + Type type = 2; +} + +message Inventory { + enum InventoryType { + TRX = 0; + BLOCK = 1; + } + InventoryType type = 1; + repeated bytes ids = 2; +} + +message Items { + enum ItemType { + ERR = 0; + TRX = 1; + BLOCK = 2; + BLOCKHEADER = 3; + } + + ItemType type = 1; + repeated Block blocks = 2; + repeated BlockHeader block_headers = 3; + repeated Transaction transactions = 4; +} diff --git a/core/TronInventoryItems.proto b/core/TronInventoryItems.proto new file mode 100644 index 00000000000..fb16f1d5431 --- /dev/null +++ b/core/TronInventoryItems.proto @@ -0,0 +1,11 @@ +syntax = "proto3"; + +package protocol; + +option java_package = "org.tron.protos"; //Specify the name of the package that generated the Java file +option java_outer_classname = "TronInventoryItems"; //Specify the class name of the generated Java file + +message InventoryItems { + int32 type = 1; + repeated bytes items = 2; +} \ No newline at end of file diff --git a/install-protobuf.sh b/install-protobuf.sh new file mode 100755 index 00000000000..29e5536ee6d --- /dev/null +++ b/install-protobuf.sh @@ -0,0 +1,10 @@ +#!/bin/sh +set -e +# check to see if protobuf folder is empty +if [ ! -d "$HOME/protobuf/lib" ]; then + wget https://github.com/google/protobuf/releases/download/v3.5.1/protobuf-java-3.5.1.tar.gz + tar -xzvf protobuf-java-3.5.1.tar.gz + cd protobuf-3.5.1 && ./configure --prefix=$HOME/protobuf && make && make install +else + echo "Using cached directory." +fi From 7f4f3027ecee8eeed856a626816f4271cb305853 Mon Sep 17 00:00:00 2001 From: sean-liu55 Date: Thu, 15 Mar 2018 10:54:02 +0800 Subject: [PATCH 75/75] rm duplicate instance --- .gitignore | 4 + .travis.yml | 19 ++++ LICENSE | 165 +++++++++++++++++++++++++++++++ README.md | 8 ++ api/api.proto | 81 ++++++++++++++++ core/Contract.proto | 85 ++++++++++++++++ core/Tron.proto | 178 ++++++++++++++++++++++++++++++++++ core/TronInventoryItems.proto | 11 +++ install-protobuf.sh | 10 ++ 9 files changed, 561 insertions(+) create mode 100644 .gitignore create mode 100644 .travis.yml create mode 100644 LICENSE create mode 100644 README.md create mode 100644 api/api.proto create mode 100644 core/Contract.proto create mode 100644 core/Tron.proto create mode 100644 core/TronInventoryItems.proto create mode 100755 install-protobuf.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000000..1554c5edd92 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +# IDEA +.idea +*iml +.DS_Store diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000000..3f1e4c4709b --- /dev/null +++ b/.travis.yml @@ -0,0 +1,19 @@ +language: ruby + +cache: + directories: + - $HOME/protobuf + +sudo: false + +before_install: + - bash install-protobuf.sh + +# check what has been installed by listing contents of protobuf folder +before_script: + - ls -R $HOME/protobuf + +# let's use protobuf +script: + - $HOME/protobuf/bin/protoc --java_out=./ ./core/*.proto ./api/*.proto + - ls -l \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000000..65c5ca88a67 --- /dev/null +++ b/LICENSE @@ -0,0 +1,165 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. diff --git a/README.md b/README.md new file mode 100644 index 00000000000..c04fbf6968a --- /dev/null +++ b/README.md @@ -0,0 +1,8 @@ +# protocol [![Build Status](https://travis-ci.org/tronprotocol/protocol.svg?branch=master)](https://travis-ci.org/tronprotocol/protocol) + + +the protocol of tron including api and message. + +java-tron and wallet-cli + +git subtree pull --prefix src/main/protos/ protocol master diff --git a/api/api.proto b/api/api.proto new file mode 100644 index 00000000000..77e4be1938c --- /dev/null +++ b/api/api.proto @@ -0,0 +1,81 @@ +syntax = "proto3"; +package protocol; + +import "core/Tron.proto"; +import "core/Contract.proto"; + +option java_package = "org.tron.api"; //Specify the name of the package that generated the Java file +option java_outer_classname = "GrpcAPI"; //Specify the class name of the generated Java file + +service Wallet { + + rpc GetBalance (Account) returns (Account) { + + }; + rpc CreateTransaction (TransferContract) returns (Transaction) { + + }; + + rpc BroadcastTransaction (Transaction) returns (Return) { + + }; + + rpc ListAccounts (EmptyMessage) returns (AccountList) { + + }; + + rpc CreateAccount (AccountCreateContract) returns (Transaction) { + + }; + + rpc VoteWitnessAccount (VoteWitnessContract) returns (Transaction) { + + }; + + rpc CreateAssetIssue (AssetIssueContract) returns (Transaction) { + + }; + + rpc ListWitnesses (EmptyMessage) returns (WitnessList) { + + }; + + rpc CreateWitness (WitnessCreateContract) returns (Transaction) { + + }; + + rpc ListNodes (EmptyMessage) returns (NodeList) { + + } +}; + +message Return { + bool result = 1; +} + +message AccountList { + repeated Account accounts = 1; +} + +message WitnessList { + repeated Witness witnesses = 1; +} + +// Gossip node list +message NodeList { + repeated Node nodes = 1; +} + +// Gossip node +message Node { + Address address = 1; +} + +// Gossip node address +message Address { + bytes host = 1; + int32 port = 2; +} + +message EmptyMessage { +} diff --git a/core/Contract.proto b/core/Contract.proto new file mode 100644 index 00000000000..8b3fff1167f --- /dev/null +++ b/core/Contract.proto @@ -0,0 +1,85 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +syntax = "proto3"; + +package protocol; + +option java_package = "org.tron.protos"; //Specify the name of the package that generated the Java file +option java_outer_classname = "Contract"; //Specify the class name of the generated Java file + +import "core/Tron.proto"; + +message AccountCreateContract { + AccountType type = 1; + bytes account_name = 2; + bytes owner_address = 3; +} + +message TransferContract { + bytes owner_address = 1; + bytes to_address = 2; + int64 amount = 3; +} + +message TransferAssertContract { + bytes assert_name = 1; + bytes owner_address = 2; + bytes to_address = 3; + int64 amount = 4; +} + + +message VoteAssetContract { + bytes owner_address = 1; + repeated bytes vote_address = 2; + bool support = 3; + int32 count = 5; +} + +message VoteWitnessContract { + message Vote { + bytes vote_address = 1; + int64 vote_count = 2; + } + bytes owner_address = 1; + repeated Vote votes = 2; + bool support = 3; +} + +message WitnessCreateContract { + bytes owner_address = 1; + bytes url = 12; +} + +message AssetIssueContract { + bytes owner_address = 1; + bytes name = 2; + int64 total_supply = 4; + int32 trx_num = 6; + int32 num = 8; + int64 start_time = 9; + int64 end_time = 10; + int32 decay_ratio = 15; + int32 vote_score = 16; + bytes description = 20; + bytes url = 21; +} + +message DeployContract { + bytes owner_address = 1; + bytes script = 2; +} + diff --git a/core/Tron.proto b/core/Tron.proto new file mode 100644 index 00000000000..a5b3698489c --- /dev/null +++ b/core/Tron.proto @@ -0,0 +1,178 @@ +syntax = "proto3"; + +import "google/protobuf/any.proto"; + +package protocol; + + +option java_package = "org.tron.protos"; //Specify the name of the package that generated the Java file +option java_outer_classname = "Protocol"; //Specify the class name of the generated Java file + + +enum AccountType { + Normal = 0; + AssetIssue = 1; + Contract = 2; +} + +// Account +message Account { + message Vote { + bytes vote_address = 1; + int64 vote_count = 2; + } + bytes account_name = 1; + AccountType type = 2; + bytes address = 3; + int64 balance = 4; + repeated Vote votes = 5; + map asset = 6; + +} + +// Witness +message Witness { + bytes address = 1; + int64 voteCount = 2; + bytes pubKey = 3; + string url = 4; + int64 totalProduced = 5; + int64 totalMissed = 6; + int64 latestBlockNum = 7; + int64 latestSlotNum = 8; + bool isJobs = 9; +} + +// Transcation + +message TXOutput { + int64 value = 1; + bytes pubKeyHash = 2; +} + +message TXInput { + message raw { + bytes txID = 1; + int64 vout = 2; + bytes pubKey = 3; + } + raw raw_data = 1; + bytes signature = 4; +} + +message TXOutputs { + repeated TXOutput outputs = 1; +} + +message Transaction { + enum TransactionType { + UtxoType = 0; + ContractType = 1; + } + message Contract { + enum ContractType { + AccountCreateContract = 0; + TransferContract = 1; + TransferAssertContract = 2; + VoteAssetContract = 3; + VoteWitnessContract = 4; + WitnessCreateContract = 5; + AssetIssueContract = 6; + DeployContract = 7; + } + ContractType type = 1; + google.protobuf.Any parameter = 2; + } + + message Result { + enum code { + SUCESS = 0; + FAILED = 1; + } + int64 fee = 1; + code ret = 2; + } + + message raw { + TransactionType type = 2; + repeated TXInput vin = 5; + repeated TXOutput vout = 7; + int64 expiration = 8; + bytes data = 10; + repeated Contract contract = 11; + bytes scripts = 16; + } + + raw raw_data = 1; + repeated bytes signature = 2; + repeated Result ret = 5; +} + +message BlockHeader { + message raw { + int64 timestamp = 1; + bytes txTrieRoot = 2; + bytes parentHash = 3; + //bytes nonce = 5; + //bytes difficulty = 6; + int64 number = 7; + int64 witness_id = 8; + bytes witness_address = 9; + } + raw raw_data = 1; + bytes witness_signature = 2; +} + +// block +message Block { + repeated Transaction transactions = 1; + BlockHeader block_header = 2; +} + +message ChainInventory { + message BlockId { + bytes hash = 1; + int64 number = 2; + } + repeated BlockId ids = 1; + int64 remain_num = 2; +} + +// Inventory +message BlockInventory { + enum Type { + SYNC = 0; + ADVTISE = 1; + FETCH = 2; + } + + message BlockId { + bytes hash = 1; + int64 number = 2; + } + repeated BlockId ids = 1; + Type type = 2; +} + +message Inventory { + enum InventoryType { + TRX = 0; + BLOCK = 1; + } + InventoryType type = 1; + repeated bytes ids = 2; +} + +message Items { + enum ItemType { + ERR = 0; + TRX = 1; + BLOCK = 2; + BLOCKHEADER = 3; + } + + ItemType type = 1; + repeated Block blocks = 2; + repeated BlockHeader block_headers = 3; + repeated Transaction transactions = 4; +} diff --git a/core/TronInventoryItems.proto b/core/TronInventoryItems.proto new file mode 100644 index 00000000000..fb16f1d5431 --- /dev/null +++ b/core/TronInventoryItems.proto @@ -0,0 +1,11 @@ +syntax = "proto3"; + +package protocol; + +option java_package = "org.tron.protos"; //Specify the name of the package that generated the Java file +option java_outer_classname = "TronInventoryItems"; //Specify the class name of the generated Java file + +message InventoryItems { + int32 type = 1; + repeated bytes items = 2; +} \ No newline at end of file diff --git a/install-protobuf.sh b/install-protobuf.sh new file mode 100755 index 00000000000..29e5536ee6d --- /dev/null +++ b/install-protobuf.sh @@ -0,0 +1,10 @@ +#!/bin/sh +set -e +# check to see if protobuf folder is empty +if [ ! -d "$HOME/protobuf/lib" ]; then + wget https://github.com/google/protobuf/releases/download/v3.5.1/protobuf-java-3.5.1.tar.gz + tar -xzvf protobuf-java-3.5.1.tar.gz + cd protobuf-3.5.1 && ./configure --prefix=$HOME/protobuf && make && make install +else + echo "Using cached directory." +fi