From f762213e8c081dbdb5e28f626ffd6b21eb401a93 Mon Sep 17 00:00:00 2001 From: chaozhu Date: Fri, 9 Dec 2022 16:04:30 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat(freezeV2):=20merge=20feature=20?= =?UTF-8?q?=E2=80=98stake=202.0=E2=80=99=20into=20release=20v4.7.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/api.proto | 77 ++++++++++++++++++++++++++++ core/Tron.proto | 30 +++++++++++ core/contract/balance_contract.proto | 31 +++++++++++ 3 files changed, 138 insertions(+) diff --git a/api/api.proto b/api/api.proto index bc8f77dec..e1dc83a23 100644 --- a/api/api.proto +++ b/api/api.proto @@ -224,6 +224,10 @@ service Wallet { //Use this function instead of FreezeBalance. rpc FreezeBalance2 (FreezeBalanceContract) returns (TransactionExtention) { } + //Use this function when FreezeBalanceV2. + rpc FreezeBalanceV2 (FreezeBalanceV2Contract) returns (TransactionExtention) { + } + //Please use UnfreezeBalance2 instead of this function. rpc UnfreezeBalance (UnfreezeBalanceContract) returns (Transaction) { option (google.api.http) = { @@ -237,6 +241,10 @@ service Wallet { //Use this function instead of UnfreezeBalance. rpc UnfreezeBalance2 (UnfreezeBalanceContract) returns (TransactionExtention) { } + //Use this function when UnfreezeBalanceV2. + rpc UnfreezeBalanceV2 (UnfreezeBalanceV2Contract) returns (TransactionExtention) { + } + //Please use UnfreezeAsset2 instead of this function. rpc UnfreezeAsset (UnfreezeAssetContract) returns (Transaction) { option (google.api.http) = { @@ -263,6 +271,16 @@ service Wallet { //Use this function instead of WithdrawBalance. rpc WithdrawBalance2 (WithdrawBalanceContract) returns (TransactionExtention) { } + + rpc WithdrawExpireUnfreeze (WithdrawExpireUnfreezeContract) returns (TransactionExtention) { + } + + rpc DelegateResource (DelegateResourceContract) returns (TransactionExtention) { + } + + rpc UnDelegateResource (UnDelegateResourceContract) returns (TransactionExtention) { + } + //Please use UpdateAsset2 instead of this function. rpc UpdateAsset (UpdateAssetContract) returns (Transaction) { option (google.api.http) = { @@ -479,9 +497,26 @@ service Wallet { rpc GetDelegatedResource (DelegatedResourceMessage) returns (DelegatedResourceList) { }; + rpc GetDelegatedResourceV2 (DelegatedResourceMessage) returns (DelegatedResourceList) { + }; + rpc GetDelegatedResourceAccountIndex (BytesMessage) returns (DelegatedResourceAccountIndex) { }; + rpc GetDelegatedResourceAccountIndexV2 (BytesMessage) returns (DelegatedResourceAccountIndex) { + }; + + rpc GetCanDelegatedMaxSize (CanDelegatedMaxSizeRequestMessage) returns (CanDelegatedMaxSizeResponseMessage) { + }; + + rpc GetAvailableUnfreezeCount (GetAvailableUnfreezeCountRequestMessage) + returns (GetAvailableUnfreezeCountResponseMessage) { + }; + + rpc GetCanWithdrawUnfreezeAmount (CanWithdrawUnfreezeAmountRequestMessage) + returns (CanWithdrawUnfreezeAmountResponseMessage) { + } + rpc ListProposals (EmptyMessage) returns (ProposalList) { option (google.api.http) = { post: "/wallet/listproposals" @@ -883,9 +918,26 @@ service WalletSolidity { rpc GetDelegatedResource (DelegatedResourceMessage) returns (DelegatedResourceList) { }; + rpc GetDelegatedResourceV2 (DelegatedResourceMessage) returns (DelegatedResourceList) { + }; + rpc GetDelegatedResourceAccountIndex (BytesMessage) returns (DelegatedResourceAccountIndex) { }; + rpc GetDelegatedResourceAccountIndexV2 (BytesMessage) returns (DelegatedResourceAccountIndex) { + }; + + rpc GetCanDelegatedMaxSize (CanDelegatedMaxSizeRequestMessage) returns (CanDelegatedMaxSizeResponseMessage) { + }; + + rpc GetAvailableUnfreezeCount (GetAvailableUnfreezeCountRequestMessage) + returns (GetAvailableUnfreezeCountResponseMessage) { + }; + + rpc GetCanWithdrawUnfreezeAmount (CanWithdrawUnfreezeAmountRequestMessage) + returns (CanWithdrawUnfreezeAmountResponseMessage) { + } + rpc GetExchangeById (BytesMessage) returns (Exchange) { }; @@ -1100,6 +1152,31 @@ message DelegatedResourceList { repeated DelegatedResource delegatedResource = 1; } +message GetAvailableUnfreezeCountRequestMessage { + bytes owner_address = 1; +} +message GetAvailableUnfreezeCountResponseMessage { + int64 count = 1; +} + +//GetCanDelegatedMaxSize +message CanDelegatedMaxSizeRequestMessage { + int32 type = 1; + bytes owner_address = 2; +} +message CanDelegatedMaxSizeResponseMessage { + int64 max_size = 1; +} + +//GetCanWithdrawUnfreezeAmount +message CanWithdrawUnfreezeAmountRequestMessage { + bytes owner_address = 1; + int64 timestamp = 2; +} +message CanWithdrawUnfreezeAmountResponseMessage { + int64 amount = 1; +} + // Gossip node list message NodeList { repeated Node nodes = 1; diff --git a/core/Tron.proto b/core/Tron.proto index 493b07bd0..6458049c7 100644 --- a/core/Tron.proto +++ b/core/Tron.proto @@ -2,6 +2,7 @@ syntax = "proto3"; import "google/protobuf/any.proto"; import "core/Discover.proto"; +import "core/contract/common.proto"; package protocol; @@ -191,6 +192,8 @@ message Account { // the identity of this account, case insensitive bytes account_id = 23; + int64 net_window_size = 24; + message AccountResource { // energy resource, get from frozen int64 energy_usage = 1; @@ -208,12 +211,31 @@ message Account { int64 storage_usage = 7; int64 latest_exchange_storage_time = 8; + int64 energy_window_size = 9; + + int64 delegated_frozenV2_balance_for_energy = 10; + int64 acquired_delegated_frozenV2_balance_for_energy = 11; } AccountResource account_resource = 26; bytes codeHash = 30; Permission owner_permission = 31; Permission witness_permission = 32; repeated Permission active_permission = 33; + + message FreezeV2 { + ResourceCode type = 1; + int64 amount = 2; + } + message UnFreezeV2 { + ResourceCode type = 1; + int64 unfreeze_amount = 3; + int64 unfreeze_expire_time = 4; + } + repeated FreezeV2 frozenV2 = 34; + repeated UnFreezeV2 unfrozenV2 = 35; + + int64 delegated_frozenV2_balance_for_bandwidth = 36; + int64 acquired_delegated_frozenV2_balance_for_bandwidth = 37; } message Key { @@ -346,6 +368,11 @@ message Transaction { ShieldedTransferContract = 51; MarketSellAssetContract = 52; MarketCancelOrderContract = 53; + FreezeBalanceV2Contract = 54; + UnfreezeBalanceV2Contract = 55; + WithdrawExpireUnfreezeContract = 56; + DelegateResourceContract = 57; + UnDelegateResourceContract = 58; } ContractType type = 1; google.protobuf.Any parameter = 2; @@ -393,6 +420,7 @@ message Transaction { bytes orderId = 25; repeated MarketOrderDetail orderDetails = 26; + int64 withdraw_expire_amount = 27; } message raw { @@ -451,6 +479,8 @@ message TransactionInfo { bytes orderId = 25; repeated MarketOrderDetail orderDetails = 26; int64 packingFee = 27; + + int64 withdraw_expire_amount = 28; } message TransactionRet { diff --git a/core/contract/balance_contract.proto b/core/contract/balance_contract.proto index 293f62bed..90a2dfaa4 100644 --- a/core/contract/balance_contract.proto +++ b/core/contract/balance_contract.proto @@ -80,3 +80,34 @@ message AccountBalanceResponse { int64 balance = 1; BlockBalanceTrace.BlockIdentifier block_identifier = 2; } + +message FreezeBalanceV2Contract { + bytes owner_address = 1; + int64 frozen_balance = 2; + ResourceCode resource = 3; +} + +message UnfreezeBalanceV2Contract { + bytes owner_address = 1; + int64 unfreeze_balance = 2; + ResourceCode resource = 3; +} + +message WithdrawExpireUnfreezeContract { + bytes owner_address = 1; +} + +message DelegateResourceContract { + bytes owner_address = 1; + ResourceCode resource = 2; + int64 balance = 3; + bytes receiver_address = 4; + bool lock = 5; +} + +message UnDelegateResourceContract { + bytes owner_address = 1; + ResourceCode resource = 2; + int64 balance = 3; + bytes receiver_address = 4; +} \ No newline at end of file From 8dce3d38fa3a9dba7fb034603067c6e5d69efbfa Mon Sep 17 00:00:00 2001 From: liukai Date: Tue, 10 Jan 2023 21:48:49 +0800 Subject: [PATCH 2/2] feat(stake): add api --- api/api.proto | 14 +++++++++++++- core/Tron.proto | 3 ++- core/contract/smart_contract.proto | 8 ++++++++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/api/api.proto b/api/api.proto index e1dc83a23..95871f5aa 100644 --- a/api/api.proto +++ b/api/api.proto @@ -42,7 +42,7 @@ service Wallet { }; rpc GetAccountBalance (AccountBalanceRequest) returns (AccountBalanceResponse) { - option (google.api.http) = { + option (google.api.http) = { post: "/wallet/getaccountbalance" body: "*" additional_bindings { @@ -480,6 +480,9 @@ service Wallet { rpc TriggerConstantContract (TriggerSmartContract) returns (TransactionExtention) { } + rpc EstimateEnergy (TriggerSmartContract) returns (EstimateEnergyMessage) { + } + rpc ClearContractABI (ClearABIContract) returns (TransactionExtention) { } @@ -1009,6 +1012,9 @@ service WalletSolidity { rpc TriggerConstantContract (TriggerSmartContract) returns (TransactionExtention) { } + rpc EstimateEnergy (TriggerSmartContract) returns (EstimateEnergyMessage) { + } + rpc GetTransactionInfoByBlockNum (NumberMessage) returns (TransactionInfoList) { } @@ -1310,6 +1316,12 @@ message TransactionExtention { int64 energy_used = 5; repeated TransactionInfo.Log logs = 6; repeated InternalTransaction internal_transactions = 7; + int64 energy_penalty = 8; +} + +message EstimateEnergyMessage { + Return result = 1; + int64 energy_required = 2; } message BlockExtention { diff --git a/core/Tron.proto b/core/Tron.proto index 6458049c7..e6aac408f 100644 --- a/core/Tron.proto +++ b/core/Tron.proto @@ -321,6 +321,7 @@ message ResourceReceipt { int64 net_usage = 5; int64 net_fee = 6; Transaction.Result.contractResult result = 7; + int64 energy_penalty_total = 8; } message MarketOrderDetail { @@ -580,7 +581,7 @@ enum ReasonCode { TOO_MANY_PEERS = 0x04; DUPLICATE_PEER = 0x05; INCOMPATIBLE_PROTOCOL = 0x06; - NULL_IDENTITY = 0x07; + RANDOM_ELIMINATION = 0x07; PEER_QUITING = 0x08; UNEXPECTED_IDENTITY = 0x09; LOCAL_IDENTITY = 0x0A; diff --git a/core/contract/smart_contract.proto b/core/contract/smart_contract.proto index 4e9a70aae..84598edd0 100644 --- a/core/contract/smart_contract.proto +++ b/core/contract/smart_contract.proto @@ -55,6 +55,13 @@ message SmartContract { int64 origin_energy_limit = 8; bytes code_hash = 9; bytes trx_hash = 10; + int32 version = 11; +} + +message ContractState { + int64 energy_usage = 1; + int64 energy_factor = 2; + int64 update_cycle = 3; } message CreateSmartContract { @@ -93,4 +100,5 @@ message UpdateEnergyLimitContract { message SmartContractDataWrapper { SmartContract smart_contract = 1; bytes runtimecode = 2; + ContractState contract_state = 3; }