From 8f63739b09e16137b3df4a88d15f10fe098ecf17 Mon Sep 17 00:00:00 2001 From: Neeha <52669918+Neeharika-Sompalli@users.noreply.github.com> Date: Wed, 12 Apr 2023 18:15:32 -0500 Subject: [PATCH 01/17] Initial draft of PBJ types for token state (#263) * Add HCS state proto Signed-off-by: Michael Tinker * Add running hash, delete EntityNumber Signed-off-by: Michael Tinker * add account and token * add account and token * add token * add tokenRelation * add some javadocs * add some javadocs * address review comments * fix missing import * address comments * address review comments * Update services/state/token/account.proto Co-authored-by: Richard Bair * Update services/state/token/account.proto Co-authored-by: Richard Bair * address some review comments * move back under services * change package name * some docs and revert java package name * revert docs * add javadocs * add javadocs * re-order the first 16 --------- Signed-off-by: Michael Tinker Co-authored-by: Michael Tinker Co-authored-by: Richard Bair --- README.md | 8 + services/state/token/account.proto | 185 ++++++++++++++++++++++ services/state/token/token.proto | 164 +++++++++++++++++++ services/state/token/token_relation.proto | 73 +++++++++ 4 files changed, 430 insertions(+) create mode 100644 services/state/token/account.proto create mode 100644 services/state/token/token.proto create mode 100644 services/state/token/token_relation.proto diff --git a/README.md b/README.md index f0ea718b..f608afd1 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,14 @@ must be paid in ℏ from a cryptocurrency account. The payer authorizes a fee by signing an appropriate transaction with a sufficient subset of the Ed25519 key(s) associated to their account. +## Overview of state +State directory and its subdirectories contain the protobuf files that define the state of the network. +The state is divided into the following subdirectories, based on the service modules: +1. [Token](services/state/token) - The state of the Token service. +2. [Consensus](services/state/consensus) - The state of the Consensus service. + +The state directory and its subdirectories are in preview and are subject to change. + # For Developers ## Branching diff --git a/services/state/token/account.proto b/services/state/token/account.proto new file mode 100644 index 00000000..2f21bac7 --- /dev/null +++ b/services/state/token/account.proto @@ -0,0 +1,185 @@ +syntax = "proto3"; + +package proto; + +/*- + * ‌ + * Hedera Network Services Protobuf + * ​ + * Copyright (C) 2018 - 2023 Hedera Hashgraph, LLC + * ​ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ‍ + */ + +import "basic_types.proto"; +import "crypto_approve_allowance.proto"; + +option java_package = "com.hederahashgraph.api.proto.java"; +// <<>> This comment is special code for setting PBJ Compiler java package +option java_multiple_files = true; + +/** + * First-draft representation of a Hedera Token Service account entity in the network Merkle tree. + * + * As with all network entities, account has an unique entity number represented as shard.realm.X. + * X can be an alias public key or an EVM address or a number. + * + */ + +message Account { + /** + * The unique entity number of the account. The shard and realm numbers are implied, based on the network + * this entity came from. + */ + int64 account_number = 1; + /** + * The alias to use for this account, if any. + */ + bytes alias = 2; + /** + * (Optional) The key to be used to sign transactions from the account, if any. + * This key will not be set for hollow accounts until the account is finalized. + * This key should be set on all the accounts, except for immutable accounts (0.0.800 and 0.0.801). + */ + Key key = 3; + /** + * The expiration time of the account, in seconds since the epoch. + */ + int64 expiry = 4; + /** + * The balance of the account, in tiny-bars. + */ + int64 tinybar_balance = 5; + /** + * An optional description of the account with UTF-8 encoding up to 100 bytes. + */ + string memo = 6; + /** + * A boolean marking if the account has been deleted. + */ + bool deleted = 7; + /** + * The amount of hbars staked to the account. + */ + int64 staked_to_me = 8; + /** + * If this account stakes to another account, its value will be -1. It will + * be set to the time when the account starts staking to a node. + */ + int64 stake_period_start = 9; + /** + * The node number or the account number this account is staked to. + * It is negative if staking to a node and positive if staking to an account and 0 if not staking to anyone. + * When staking to a node, it is stored as -node-1 to differentiate node 0. + */ + int64 staked_number = 10; + /** + * A boolean marking if the account declines rewards. + */ + bool decline_reward = 11; + /** + * A boolean marking if the account requires a receiver signature. + */ + bool receiver_sig_required = 12; + /** + * The token ID of the head of the linked list from token relations map for the account. + */ + int64 head_token_number = 13; + /** + * The NftId of the head of the linked list from unique tokens map for the account. + */ + int64 head_nft_id = 14; + /** + * The serial number of the head NftId of the linked list from unique tokens map for the account. + */ + int64 head_nft_serial_number = 15; + /** + * The number of NFTs owned by the account. + */ + int64 number_owned_nfts = 16; + /** + * The maximum number of tokens that can be auto-associated with the account. + */ + int32 max_auto_associations = 17; + /** + * The number of used auto-association slots. + */ + int32 used_auto_associations = 18; + /** + * The number of tokens associated with the account. This number is used for + * fee calculation during renewal of the account. + */ + int32 number_associations = 19; + /** + * A boolean marking if the account is a smart contract. + */ + bool smart_contract = 20; + /** + * The number of tokens with a positive balance associated with the account. + * If the account has positive balance in a token, it can not be deleted. + */ + int32 number_positive_balances = 21; + /** + * The nonce of the account, used for Ethereum interoperability. + */ + int64 ethereum_nonce = 22; + /** + * The amount of hbars staked to the account at the start of the last rewarded period. + */ + int64 stake_at_start_of_last_rewarded_period = 23; + /** + * (Optional) The number of an auto-renew account, in the same shard and realm as the account, that + * has signed a transaction allowing the network to use its balance to automatically extend the account's + * expiration time when it passes. + */ + int64 auto_renew_account_number = 24; + /** + * The number of seconds the network should automatically extend the account's expiration by, if the + * account has a valid auto-renew account, and is not deleted upon expiration. + * If this is not provided in a allowed range on account creation, the transaction will fail with INVALID_AUTO_RENEWAL_PERIOD. + * The default values for the minimum period and maximum period are 30 days and 90 days, respectively. + */ + int64 auto_renew_secs = 25; + /** + * If this account is a smart-contract, number of key-value pairs stored on the contract. + * This is used to determine the storage rent for the contract. + */ + int32 contract_kv_pairs_number = 26; + /** + * (Optional) List of crypto allowances approved by the account. + */ + repeated CryptoAllowance crypto_allowances = 27; + /** + * (Optional) List of non-fungible token allowances approved by the account. + */ + repeated NftAllowance nft_allowances = 28; + + /** + * (Optional) List of fungible token allowances approved by the account. + */ + repeated TokenAllowance token_allowances = 29; + /** + * The number of tokens for which this account is treasury + */ + uint32 number_treasury_titles = 30; + /** + * A flag indicating if the account is expired and pending removal. + * Only the entity expiration system task toggles this flag when it reaches this account + * and finds it expired. Before setting the flag the system task checks if the account has + * an auto-renew account with balance. This is done to prevent a zero-balance account with a funded + * auto-renew account from being treated as expired in the interval between its expiration + * and the time the system task actually auto-renews it. + */ + bool expired_and_pending_removal = 31; +} diff --git a/services/state/token/token.proto b/services/state/token/token.proto new file mode 100644 index 00000000..a54258a5 --- /dev/null +++ b/services/state/token/token.proto @@ -0,0 +1,164 @@ +syntax = "proto3"; + +package proto; + +/*- + * ‌ + * Hedera Network Services Protobuf + * ​ + * Copyright (C) 2018 - 2023 Hedera Hashgraph, LLC + * ​ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ‍ + */ + +import "basic_types.proto"; +import "custom_fees.proto"; + +option java_package = "com.hederahashgraph.api.proto.java"; +// <<>> This comment is special code for setting PBJ Compiler java package +option java_multiple_files = true; + +/** + * First-draft representation of a Hedera Token Service token entity in the network Merkle tree. + * + * As with all network entities, a token has a unique entity number, which is usually given along + * with the network's shard and realm in the form of a shard.realm.number id. + */ + +message Token { + /** + * The unique entity number of this token. + */ + int64 token_number = 1; + /** + * The human-readable name of this token and its not necessarily unique. Maximum length allowed is 100 bytes. + */ + string name = 2; + /** + * The human-readable symbol for the token. It is not necessarily unique. Maximum length allowed is 100 bytes. + */ + string symbol = 3; + /** + * The number of decimal places of this token. If decimals are 8 or 11, then the number of whole + * tokens can be at most a few billions or millions, respectively. For example, it could match + * Bitcoin (21 million whole tokens with 8 decimals) or hbars (50 billion whole tokens with 8 decimals). + * It could even match Bitcoin with milli-satoshis (21 million whole tokens with 11 decimals). + */ + int32 decimals = 4; + /** + * The total supply of this token. + */ + int64 total_supply = 5; + /** + * The treasury account number of this token. This account receives the initial supply of + * tokens as-well as the tokens from the Token Mint operation once executed. The balance + * of the treasury account is decreased when the Token Burn operation is executed. + */ + int64 treasury_account_number = 6; + /** + * (Optional) The admin key of this token. If this key is set, the token is mutable. + * A mutable token can be modified. + * If this key is not set on token creation, it cannot be modified. + */ + Key admin_key = 7; + /** + * (Optional) The kyc key of this token. + * If this key is not set on token creation, it can only be set if the token has admin key set. + */ + Key kyc_key = 8; + /** + * (Optional) The freeze key of this token. This key is needed for freezing the token. + * If this key is not set on token creation, it can only be set if the token has admin key set. + */ + Key freeze_key = 9; + /** + * (Optional) The wipe key of this token. This key is needed for wiping the token. + * If this key is not set on token creation, it can only be set if the token has admin key set. + */ + Key wipe_key = 10; + /** + * (Optional) The supply key of this token. This key is needed for minting or burning token. + * If this key is not set on token creation, it can only be set if the token has admin key set. + */ + Key supply_key = 11; + /** + * (Optional) The fee schedule key of this token. This key should be set, in order to make any + * changes to the custom fee schedule. + * If this key is not set on token creation, it can only be set if the token has admin key set. + */ + Key fee_schedule_key = 12; + /** + * (Optional) The pause key of this token. This key is needed for pausing the token. + * If this key is not set on token creation, it can only be set if the token has admin key set. + */ + Key pause_key = 13; + /** + * The last used serial number of this token. + */ + int64 last_used_serial_number = 14; + /** + * The flag indicating if this token is deleted. + */ + bool deleted = 15; + /** + * The type of this token. A token can be either FUNGIBLE_COMMON or NON_FUNGIBLE_UNIQUE. + * If it has been omitted during token creation, FUNGIBLE_COMMON type is used. + */ + TokenType token_type = 16; + /** + * The supply type of this token.A token can have either INFINITE or FINITE supply type. + * If it has been omitted during token creation, INFINITE type is used. + */ + TokenSupplyType supply_type = 17; + /** + * The number of the account (if any) that the network will attempt to charge for the + * token's auto-renewal upon expiration. + */ + int64 auto_renew_account_number = 18; + /** + * The number of seconds the network should automatically extend the token's expiration by, if the + * token has a valid auto-renew account, and is not deleted upon expiration. + * If this is not provided in a allowed range on token creation, the transaction will fail with INVALID_AUTO_RENEWAL_PERIOD. + * The default values for the minimum period and maximum period are 30 days and 90 days, respectively. + */ + int64 auto_renew_secs = 19; + /** + * The expiration time of the token, in seconds since the epoch. + */ + int64 expiry = 20; + /** + * An optional description of the token with UTF-8 encoding up to 100 bytes. + */ + string memo = 21; + /** + * The maximum supply of this token. + */ + int64 max_supply = 22; + /** + * The flag indicating if this token is paused. + */ + bool paused = 23; + /** + * The flag indicating if this token has accounts associated to it that are frozen by default. + */ + bool accounts_frozen_by_default = 24; + /** + * The flag indicating if this token has accounts associated to it that are KYC granted by default. + */ + bool accounts_kyc_granted_by_default = 25; + /** + * (Optional) The custom fees of this token. + */ + repeated CustomFee custom_fees = 26; +} diff --git a/services/state/token/token_relation.proto b/services/state/token/token_relation.proto new file mode 100644 index 00000000..cefcb5cb --- /dev/null +++ b/services/state/token/token_relation.proto @@ -0,0 +1,73 @@ +syntax = "proto3"; + +package proto; + +/*- + * ‌ + * Hedera Network Services Protobuf + * ​ + * Copyright (C) 2018 - 2023 Hedera Hashgraph, LLC + * ​ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ‍ + */ + +import "basic_types.proto"; + +option java_package = "com.hederahashgraph.api.proto.java"; +// <<>> This comment is special code for setting PBJ Compiler java package +option java_multiple_files = true; +/** + * First-draft representation of a Hedera Token Service token relationship entity in the network Merkle tree. + * + * As with all network entities, a token relationship has a unique entity number pair, which is represented + * with the account and the token involved in the relationship. + */ +message TokenRelation { + /** + * The token involved in this relation.It takes only positive + */ + int64 token_number = 1; + /** + * The account involved in this association. + */ + int64 account_number = 2; + /** + * The balance of the token relationship. + */ + int64 balance = 3; + /** + * The flags specifying the token relationship is frozen or not. + */ + bool frozen = 4; + /** + * The flag indicating if the token relationship has been granted KYC. + */ + bool kyc_granted = 5; + /** + * The flag indicating if the token relationship was deleted. + */ + bool deleted = 6; + /** + * The flag indicating if the token relationship was created using automatic association. + */ + bool automatic_association = 7; + /** + * The previous token number of account's association linked list + */ + int64 previous_token = 8; + /** + * The next token number of account's association linked list + */ + int64 next_token = 9; +} From 618854f3ea4a666c40c27d9fda848ed6a5c5f37b Mon Sep 17 00:00:00 2001 From: Lev Povolotsky <16233475+povolev15@users.noreply.github.com> Date: Fri, 14 Apr 2023 11:59:00 -0400 Subject: [PATCH 02/17] file proto (#267) * 265 - file proto Signed-off-by: Lev Povolotsky * 265 - packaging Signed-off-by: Lev Povolotsky * 265 - comments Signed-off-by: Lev Povolotsky --------- Signed-off-by: Lev Povolotsky --- services/state/file/file.proto | 64 ++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 services/state/file/file.proto diff --git a/services/state/file/file.proto b/services/state/file/file.proto new file mode 100644 index 00000000..87d5cced --- /dev/null +++ b/services/state/file/file.proto @@ -0,0 +1,64 @@ +syntax = "proto3"; + +package proto; + +/*- + * ‌ + * Hedera Network Services Protobuf + * ​ + * Copyright (C) 2018 - 2023 Hedera Hashgraph, LLC + * ​ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ‍ + */ + +import "basic_types.proto"; +import "timestamp.proto"; + +option java_package = "com.hederahashgraph.api.proto.java"; +// <<>> This comment is special code for setting PBJ Compiler java package +option java_multiple_files = true; + +/** + * First-draft representation of a Hedera Token Service file in the network Merkle tree. + * + * As with all network entities, a file has a unique entity number, which is usually given along + * with the network's shard and realm in the form of a shard.realm.number id. + */ +message File { + /** + * The file's unique entity number in the Merkle state. + */ + int64 file_number = 1; + /** + * The file's consensus expiration time in seconds since the epoch. + */ + int64 expiration_time = 2; + /** + * All keys at the top level of a key list must sign to create or modify the file. Any one of + * the keys at the top level key list can sign to delete the file. + */ + KeyList keys = 3; + /** + * The bytes that are the contents of the file + */ + bytes contents = 4; + /** + * The memo associated with the file (UTF-8 encoding max 100 bytes) + */ + string memo = 5; + /** + * Whether this file is deleted. + */ + bool deleted = 6; +} \ No newline at end of file From 7bbf1d53fee037171140bf7713a0771b228cfe4a Mon Sep 17 00:00:00 2001 From: Neeha <52669918+Neeharika-Sompalli@users.noreply.github.com> Date: Tue, 18 Apr 2023 13:41:02 -0500 Subject: [PATCH 03/17] Change allowance maps on `Account` PBJ Object (#269) * change allowances * change allowances * change allowances * change allowances * change allowances * change allowances --- services/state/token/account.proto | 40 +++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/services/state/token/account.proto b/services/state/token/account.proto index 2f21bac7..8205281b 100644 --- a/services/state/token/account.proto +++ b/services/state/token/account.proto @@ -158,17 +158,24 @@ message Account { int32 contract_kv_pairs_number = 26; /** * (Optional) List of crypto allowances approved by the account. + * It contains account number for which the allowance is approved to and + * the amount approved for that account. */ - repeated CryptoAllowance crypto_allowances = 27; + repeated AccountCryptoAllowance crypto_allowances = 27; /** - * (Optional) List of non-fungible token allowances approved by the account. + * (Optional) List of non-fungible token allowances approved for all by the account. + * It contains account number approved for spending all serial numbers for the given + * NFT token number using approved_for_all flag. + * Allowances for a specific serial number is stored in the NFT itself in state. */ - repeated NftAllowance nft_allowances = 28; + repeated AccountTokenAllowance approve_for_all_nft_allowances = 28; /** * (Optional) List of fungible token allowances approved by the account. + * It contains account number for which the allowance is approved to and the token number. + * It also contains and the amount approved for that account. */ - repeated TokenAllowance token_allowances = 29; + repeated AccountFungibleTokenAllowance token_allowances = 29; /** * The number of tokens for which this account is treasury */ @@ -183,3 +190,28 @@ message Account { */ bool expired_and_pending_removal = 31; } + +/** + * Allowance granted by this account to another account for a specific token. + */ +message AccountTokenAllowance { + int64 token_num = 1; + int64 account_num = 2; +} + +/** + * Allowance granted by this account to another account for a specific fungible token. + * This also contains the amount of the token that is approved for the account. + */ +message AccountFungibleTokenAllowance { + AccountTokenAllowance token_allowance_key = 1; + int64 amount = 2; +} + +/** + * Allowance granted by this account to another account for an amount of hbars. + */ +message AccountCryptoAllowance { + int64 account_num = 1; + int64 amount = 2; +} From f6aadf0f53e6faf572468be268e701442b089b8a Mon Sep 17 00:00:00 2001 From: Lev Povolotsky <16233475+povolev15@users.noreply.github.com> Date: Mon, 1 May 2023 08:54:40 -0400 Subject: [PATCH 04/17] fix some comments on file proto (#268) * 265 - file proto Signed-off-by: Lev Povolotsky * 265 - packaging Signed-off-by: Lev Povolotsky * 265 - comments Signed-off-by: Lev Povolotsky * 265 - comments fix Signed-off-by: Lev Povolotsky --------- Signed-off-by: Lev Povolotsky --- services/state/file/file.proto | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/services/state/file/file.proto b/services/state/file/file.proto index 87d5cced..15cad7ea 100644 --- a/services/state/file/file.proto +++ b/services/state/file/file.proto @@ -45,8 +45,7 @@ message File { */ int64 expiration_time = 2; /** - * All keys at the top level of a key list must sign to create or modify the file. Any one of - * the keys at the top level key list can sign to delete the file. + * All keys at the top level of a key list must sign to create, modify and delete the file. */ KeyList keys = 3; /** From d3367679eaee894cd2d82667c4f9e42beb91311b Mon Sep 17 00:00:00 2001 From: Neeha <52669918+Neeharika-Sompalli@users.noreply.github.com> Date: Mon, 8 May 2023 09:52:31 -0500 Subject: [PATCH 05/17] Add missing fields in Account (#270) * add missing fields and change allowance names * change to bits * address review comments * address review comments * address review comments --- services/state/token/account.proto | 50 +++++++++++++++++++++++++----- 1 file changed, 42 insertions(+), 8 deletions(-) diff --git a/services/state/token/account.proto b/services/state/token/account.proto index 8205281b..fa8171b7 100644 --- a/services/state/token/account.proto +++ b/services/state/token/account.proto @@ -23,7 +23,6 @@ package proto; */ import "basic_types.proto"; -import "crypto_approve_allowance.proto"; option java_package = "com.hederahashgraph.api.proto.java"; // <<>> This comment is special code for setting PBJ Compiler java package @@ -168,7 +167,7 @@ message Account { * NFT token number using approved_for_all flag. * Allowances for a specific serial number is stored in the NFT itself in state. */ - repeated AccountTokenAllowance approve_for_all_nft_allowances = 28; + repeated AccountApprovalForAllAllowance approve_for_all_nft_allowances = 28; /** * (Optional) List of fungible token allowances approved by the account. @@ -189,29 +188,64 @@ message Account { * and the time the system task actually auto-renews it. */ bool expired_and_pending_removal = 31; + /** + * The first key in the doubly-linked list of this contract's storage mappings; + * It will be null if if the account is not a contract or the contract has no storage mappings. + */ + Int256Value first_contract_storage_key = 32; } /** - * Allowance granted by this account to another account for a specific token. + * Allowance granted by this account to a spender for a specific non-fungible token + * using ApproveForAll. This allows spender to spend all serial numbers for the given + * non-fungible token number. */ -message AccountTokenAllowance { +message AccountApprovalForAllAllowance { int64 token_num = 1; - int64 account_num = 2; + int64 spender_num = 2; } /** * Allowance granted by this account to another account for a specific fungible token. * This also contains the amount of the token that is approved for the account. + * This allows spender to spend the amount of tokens approved for the account. */ message AccountFungibleTokenAllowance { - AccountTokenAllowance token_allowance_key = 1; - int64 amount = 2; + int64 token_num = 1; + int64 spender_num = 2; + int64 amount = 3; } /** * Allowance granted by this account to another account for an amount of hbars. + * This allows spender to spend the amount of hbars approved for the account. */ message AccountCryptoAllowance { - int64 account_num = 1; + int64 spender_num = 1; int64 amount = 2; } +/** + * Message representing a uint256 value. + */ +message Int256Value { + /** + * The number low-order bytes in the 256-bits that contain ones + */ + int32 non_zero_bits = 1; + /** + * The first 64 bits of a int256 value + */ + int64 first_long = 2; + /** + * The second 64 bits of a int256 value + */ + int64 second_long = 3; + /** + * The first 64 bits of a int256 value + */ + int64 third_long = 4; + /** + * The first 64 bits of a int256 value + */ + int64 fourth_long = 5; +} From ad7d2c0857e004957bba7ded8b278b8faf378f58 Mon Sep 17 00:00:00 2001 From: Richard Bair Date: Tue, 23 May 2023 08:35:27 -0700 Subject: [PATCH 06/17] Add the TransactionRecordEntry type for the record cache. --- services/state/recordcache/recordcache.proto | 47 ++++++++++++++++++++ services/transaction.proto | 2 +- 2 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 services/state/recordcache/recordcache.proto diff --git a/services/state/recordcache/recordcache.proto b/services/state/recordcache/recordcache.proto new file mode 100644 index 00000000..a72d93f5 --- /dev/null +++ b/services/state/recordcache/recordcache.proto @@ -0,0 +1,47 @@ +syntax = "proto3"; + +package proto; + +/*- + * ‌ + * Hedera Network Services Protobuf + * ​ + * Copyright (C) 2018 - 2023 Hedera Hashgraph, LLC + * ​ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ‍ + */ + +import "transaction_record.proto"; + +option java_package = "com.hederahashgraph.api.proto.java"; +// <<>> This comment is special code for setting PBJ Compiler java package +option java_multiple_files = true; + +/** + * As transactions are handled and records and receipts are created, they are stored in state for a configured time + * limit (perhaps, for example, 3 minutes). During this time window, any client can query the node and get the record + * or receipt for the transaction. The TransactionRecordEntry is the object stored in state with this information. + */ +message TransactionRecordEntry { + /** + * The ID of the node that submitted the transaction to consensus. The ID is the ID of the node as known by the + * address book. Valid node IDs are in the range 0..2^63-1, inclusive. + */ + int64 node_id = 1; + + /** + * The transaction record for the transaction. + */ + TransactionRecord transaction_record = 2; +} diff --git a/services/transaction.proto b/services/transaction.proto index a47569f1..940a6f54 100644 --- a/services/transaction.proto +++ b/services/transaction.proto @@ -42,7 +42,7 @@ import "transaction_body.proto"; */ message Transaction { /** - * the body of the transaction, which needs to be signed + * The body of the transaction, which needs to be signed */ TransactionBody body = 1 [deprecated = true]; From 4a6c9ff7b038b5dbf29c2b59cd855af372fa617b Mon Sep 17 00:00:00 2001 From: Richard Bair Date: Wed, 24 May 2023 08:00:52 -0700 Subject: [PATCH 07/17] Add payer account ID --- services/state/recordcache/recordcache.proto | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/services/state/recordcache/recordcache.proto b/services/state/recordcache/recordcache.proto index a72d93f5..b68d1c2c 100644 --- a/services/state/recordcache/recordcache.proto +++ b/services/state/recordcache/recordcache.proto @@ -22,6 +22,7 @@ package proto; * ‍ */ +import "basic_types.proto"; import "transaction_record.proto"; option java_package = "com.hederahashgraph.api.proto.java"; @@ -40,8 +41,15 @@ message TransactionRecordEntry { */ int64 node_id = 1; + /** + * The AccountID of the payer of the transaction. This may be the same as the account ID within the Transaction ID + * of the record, or it may be the account ID of the node that submitted the transaction to consensus if the account + * ID in the Transaction ID is not able to pay. + */ + AccountID payer_account_id = 2; + /** * The transaction record for the transaction. */ - TransactionRecord transaction_record = 2; + TransactionRecord transaction_record = 3; } From c858be60c3a51adc40bcbdc97cc24a7f56a02fb9 Mon Sep 17 00:00:00 2001 From: Michael Tinker Date: Thu, 1 Jun 2023 11:43:58 -0500 Subject: [PATCH 08/17] Include `ContractService` state types (#273) * Add bytecode and storage slot representations Signed-off-by: Michael Tinker * Add Nft type Signed-off-by: Michael Tinker * Add EntityNumber Signed-off-by: Michael Tinker * Use bytes instead of Int256Value Signed-off-by: Michael Tinker * Fix typo Signed-off-by: Michael Tinker * Remove superfluous Int256Value type Signed-off-by: Michael Tinker * Rename Id -> UniqueTokenId Signed-off-by: Michael Tinker * Don't store code_hash, can be cached on load Signed-off-by: Michael Tinker --------- Signed-off-by: Michael Tinker --- services/state/common.proto | 49 ++++++++++++++ services/state/contract/bytecode.proto | 37 +++++++++++ services/state/contract/storage_slot.proto | 70 ++++++++++++++++++++ services/state/token/account.proto | 28 +------- services/state/token/nft.proto | 77 ++++++++++++++++++++++ 5 files changed, 235 insertions(+), 26 deletions(-) create mode 100644 services/state/common.proto create mode 100644 services/state/contract/bytecode.proto create mode 100644 services/state/contract/storage_slot.proto create mode 100644 services/state/token/nft.proto diff --git a/services/state/common.proto b/services/state/common.proto new file mode 100644 index 00000000..a39447fe --- /dev/null +++ b/services/state/common.proto @@ -0,0 +1,49 @@ +syntax = "proto3"; + +package proto; + +/*- + * ‌ + * Hedera Network Services Protobuf + * ​ + * Copyright (C) 2018 - 2023 Hedera Hashgraph, LLC + * ​ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ‍ + */ + +option java_package = "com.hederahashgraph.api.proto.java"; +// <<>> This comment is special code for setting PBJ Compiler java package +option java_multiple_files = true; + +/** + * A single 64-bit number identifying a Hedera native entity. + */ +message EntityNumber { + int64 number = 1; +} + +/** + * Identifier for a unique token (or "NFT"), used by both contract and token services. + */ +message UniqueTokenId { + /** + * The number of the unique token type this NFT is an instance of. + */ + int64 token_type_number = 1; + + /** + * The serial number of this NFT within its token type. + */ + int64 serial_number = 2; +} diff --git a/services/state/contract/bytecode.proto b/services/state/contract/bytecode.proto new file mode 100644 index 00000000..d144a195 --- /dev/null +++ b/services/state/contract/bytecode.proto @@ -0,0 +1,37 @@ +syntax = "proto3"; + +package proto; + +/*- + * ‌ + * Hedera Network Services Protobuf + * ​ + * Copyright (C) 2018 - 2023 Hedera Hashgraph, LLC + * ​ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ‍ + */ + +option java_package = "com.hederahashgraph.api.proto.java"; +// <<>> This comment is special code for setting PBJ Compiler java package +option java_multiple_files = true; + +/** + * The bytecode for a contract id. + */ +message Bytecode { + /** + * The raw bytes (not hex-encoded) of a contract's bytecode. + */ + bytes code = 1; +} diff --git a/services/state/contract/storage_slot.proto b/services/state/contract/storage_slot.proto new file mode 100644 index 00000000..5511d112 --- /dev/null +++ b/services/state/contract/storage_slot.proto @@ -0,0 +1,70 @@ +syntax = "proto3"; + +package proto; + +/*- + * ‌ + * Hedera Network Services Protobuf + * ​ + * Copyright (C) 2018 - 2023 Hedera Hashgraph, LLC + * ​ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ‍ + */ + +import "state/common.proto"; + +option java_package = "com.hederahashgraph.api.proto.java"; +// <<>> This comment is special code for setting PBJ Compiler java package +option java_multiple_files = true; + +/** + * The key of a storage slot. A slot is scoped to a specific contract number. + * + * For each contract, its EVM storage is a mapping of 256-bit keys (or "words") to 256-bit values. + */ +message SlotKey { + /** + * The number of the contract whose storage this slot belongs to. + */ + int64 contract_number = 1; + + /** + * The EVM key of this slot, when left-padded with zeros to form a 256-bit word. + */ + bytes key = 2; +} + +/** + * The value of a contract storage slot. For the EVM, this is a single word. + * + * But because we need to be able to iterate through all the storage slots for an + * expired contract when purging it from state, our slot values also include the words + * of the previous and next keys in this contract's storage "list". + */ +message SlotValue { + /** + * The EVM value in this slot, when left-padded with zeros to form a 256-bit word. + */ + bytes value = 1; + + /** + * The word of the previous key in this contract's storage list (if any). + */ + bytes previous_key = 2; + + /** + * The word of the next key in this contract's storage list (if any). + */ + bytes next_key = 3; +} diff --git a/services/state/token/account.proto b/services/state/token/account.proto index fa8171b7..c34c80b2 100644 --- a/services/state/token/account.proto +++ b/services/state/token/account.proto @@ -22,6 +22,7 @@ package proto; * ‍ */ +import "state/common.proto"; import "basic_types.proto"; option java_package = "com.hederahashgraph.api.proto.java"; @@ -192,7 +193,7 @@ message Account { * The first key in the doubly-linked list of this contract's storage mappings; * It will be null if if the account is not a contract or the contract has no storage mappings. */ - Int256Value first_contract_storage_key = 32; + bytes first_contract_storage_key = 32; } /** @@ -224,28 +225,3 @@ message AccountCryptoAllowance { int64 spender_num = 1; int64 amount = 2; } -/** - * Message representing a uint256 value. - */ -message Int256Value { - /** - * The number low-order bytes in the 256-bits that contain ones - */ - int32 non_zero_bits = 1; - /** - * The first 64 bits of a int256 value - */ - int64 first_long = 2; - /** - * The second 64 bits of a int256 value - */ - int64 second_long = 3; - /** - * The first 64 bits of a int256 value - */ - int64 third_long = 4; - /** - * The first 64 bits of a int256 value - */ - int64 fourth_long = 5; -} diff --git a/services/state/token/nft.proto b/services/state/token/nft.proto new file mode 100644 index 00000000..aacb6775 --- /dev/null +++ b/services/state/token/nft.proto @@ -0,0 +1,77 @@ +syntax = "proto3"; + +package proto; + +/*- + * ‌ + * Hedera Network Services Protobuf + * ​ + * Copyright (C) 2018 - 2023 Hedera Hashgraph, LLC + * ​ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ‍ + */ + +import "timestamp.proto"; +import "state/common.proto"; + +option java_package = "com.hederahashgraph.api.proto.java"; +// <<>> This comment is special code for setting PBJ Compiler java package +option java_multiple_files = true; + +/** + * First-draft representation of a Hedera Token Service NFT in the network Merkle tree. + */ +message Nft { + + /** + * The id of this NFT. + */ + UniqueTokenId id = 1; + + /** + * The number of the account or contract that owns this NFT. + * + * If this number is zero in state, the NFT is owned by its token type's current treasury. + */ + int64 owner_number = 2; + + /** + * The number of the account or contract approved to spend this NFT. + * + * If this number is zero, there is no approved spender. + */ + int64 spender_number = 3; + + /** + * The consensus time of the TokenMint that created this NFT. + */ + Timestamp mint_time = 4; + + /** + * The metadata of this NFT, up to 100 bytes; usually the UTF-8 encoding of a URI. + */ + bytes metadata = 5; + + /** + * If the owner of this NFT is not its token treasury, the id of the previous NFT + * in the owner's "doubly-linked list" of owned NFTs (if any). + */ + UniqueTokenId owner_previous_nft_id = 6; + + /** + * If the owner of this NFT is not its token treasury, the id of the next NFT in + * the owner's "doubly-linked list" of owned NFTs (if any). + */ + UniqueTokenId owner_next_nft_id = 7; +} From 96774e98748aa369a9c8ed091d5a18a55f25069c Mon Sep 17 00:00:00 2001 From: Jasper Potts <1466205+jasperpotts@users.noreply.github.com> Date: Thu, 1 Jun 2023 15:49:59 -0700 Subject: [PATCH 09/17] Added state for blocks and running hashes (#276) * Added state for blocks and running hashes Signed-off-by: jasperpotts --------- Signed-off-by: jasperpotts Co-authored-by: jasperpotts --- services/state/blockrecords/block_info.proto | 50 +++++++++++++++++++ .../state/blockrecords/running_hashes.proto | 50 +++++++++++++++++++ 2 files changed, 100 insertions(+) create mode 100644 services/state/blockrecords/block_info.proto create mode 100644 services/state/blockrecords/running_hashes.proto diff --git a/services/state/blockrecords/block_info.proto b/services/state/blockrecords/block_info.proto new file mode 100644 index 00000000..304a32d7 --- /dev/null +++ b/services/state/blockrecords/block_info.proto @@ -0,0 +1,50 @@ +syntax = "proto3"; + +package proto; + +/*- + * ‌ + * Hedera Network Services Protobuf + * ​ + * Copyright (C) 2018 - 2023 Hedera Hashgraph, LLC + * ​ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ‍ + */ + +import "timestamp.proto"; + +option java_package = "com.hederahashgraph.api.proto.java"; +// <<>> This comment is special code for setting PBJ Compiler java package +option java_multiple_files = true; + +/** + * Information about the most recently completed and last 256 blocks. + */ +message BlockInfo { + /** + * The last block number, this is the last completed immutable block. + */ + int64 last_block_no = 1; + /** + * The consensus time of the first transaction of the last block, this is the last completed immutable block. + */ + Timestamp first_cons_time_of_last_block = 2; + /** + * SHA384 48 byte hashes of the last 256 blocks in single byte array. + * First 48 bytes is the oldest block. + * Last 48 bytes is the newest block, which is the last fully completed immutable block. + * If we are shortly after genesis and there are less than 256 blocks then this could contain less than 256 hashes. + */ + bytes block_hashes = 3; +} diff --git a/services/state/blockrecords/running_hashes.proto b/services/state/blockrecords/running_hashes.proto new file mode 100644 index 00000000..8d2ae4c5 --- /dev/null +++ b/services/state/blockrecords/running_hashes.proto @@ -0,0 +1,50 @@ +syntax = "proto3"; + +package proto; + +/*- + * ‌ + * Hedera Network Services Protobuf + * ​ + * Copyright (C) 2018 - 2023 Hedera Hashgraph, LLC + * ​ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ‍ + */ + +option java_package = "com.hederahashgraph.api.proto.java"; +// <<>> This comment is special code for setting PBJ Compiler java package +option java_multiple_files = true; + +/** + * The running hash of a transaction records and the previous 3 running hashes. All hashes are 48 bytes SHA384 hashes. If the + * running hashes do not exist yet then they will be default values witch is empty bytes object or zero length byte array. + */ +message RunningHashes { + /** + * A running hash of all record stream items + */ + bytes running_hash = 1; + /** + * The previous running hash of all record stream items + */ + bytes n_minus_1_running_hash = 2; + /** + * The previous, previous running hash of all record stream items + */ + bytes n_minus_2_running_hash = 3; + /** + * The previous, previous, previous running hash of all record stream items + */ + bytes n_minus_3_running_hash = 4; +} From c696944c6ac98bb643ad6794ca614e9ef91c882e Mon Sep 17 00:00:00 2001 From: Neeharika-Sompalli Date: Thu, 8 Jun 2023 16:26:01 -0500 Subject: [PATCH 10/17] add ids instead --- services/state/common.proto | 10 +++++++++- services/state/token/account.proto | 19 ++++++++++--------- services/state/token/nft.proto | 4 ++-- services/state/token/token.proto | 5 +++-- services/state/token/token_relation.proto | 8 ++++---- 5 files changed, 28 insertions(+), 18 deletions(-) diff --git a/services/state/common.proto b/services/state/common.proto index a39447fe..e4860b33 100644 --- a/services/state/common.proto +++ b/services/state/common.proto @@ -33,6 +33,14 @@ message EntityNumber { int64 number = 1; } +/** + * A single 64-bit number identifying a Hedera native entity. + */ +message EntityIDPair { + AccountID account_id = 1; + TokenID token_id = 2; +} + /** * Identifier for a unique token (or "NFT"), used by both contract and token services. */ @@ -40,7 +48,7 @@ message UniqueTokenId { /** * The number of the unique token type this NFT is an instance of. */ - int64 token_type_number = 1; + TokenID token_id = 1; /** * The serial number of this NFT within its token type. diff --git a/services/state/token/account.proto b/services/state/token/account.proto index c34c80b2..b0d4936d 100644 --- a/services/state/token/account.proto +++ b/services/state/token/account.proto @@ -41,6 +41,7 @@ message Account { /** * The unique entity number of the account. The shard and realm numbers are implied, based on the network * this entity came from. + * FUTURE : Need to validate if this is needed */ int64 account_number = 1; /** @@ -95,11 +96,11 @@ message Account { /** * The token ID of the head of the linked list from token relations map for the account. */ - int64 head_token_number = 13; + TokenID head_token_id = 13; /** * The NftId of the head of the linked list from unique tokens map for the account. */ - int64 head_nft_id = 14; + UniqueTokenId head_nft_id = 14; /** * The serial number of the head NftId of the linked list from unique tokens map for the account. */ @@ -139,11 +140,11 @@ message Account { */ int64 stake_at_start_of_last_rewarded_period = 23; /** - * (Optional) The number of an auto-renew account, in the same shard and realm as the account, that + * (Optional) The id of an auto-renew account, in the same shard and realm as the account, that * has signed a transaction allowing the network to use its balance to automatically extend the account's * expiration time when it passes. */ - int64 auto_renew_account_number = 24; + AccountID auto_renew_account_id = 24; /** * The number of seconds the network should automatically extend the account's expiration by, if the * account has a valid auto-renew account, and is not deleted upon expiration. @@ -202,8 +203,8 @@ message Account { * non-fungible token number. */ message AccountApprovalForAllAllowance { - int64 token_num = 1; - int64 spender_num = 2; + TokenID token_id = 1; + AccountID spender_id = 2; } /** @@ -212,8 +213,8 @@ message AccountApprovalForAllAllowance { * This allows spender to spend the amount of tokens approved for the account. */ message AccountFungibleTokenAllowance { - int64 token_num = 1; - int64 spender_num = 2; + TokenID token_id = 1; + AccountID spender_id = 2; int64 amount = 3; } @@ -222,6 +223,6 @@ message AccountFungibleTokenAllowance { * This allows spender to spend the amount of hbars approved for the account. */ message AccountCryptoAllowance { - int64 spender_num = 1; + AccountID spender_id = 1; int64 amount = 2; } diff --git a/services/state/token/nft.proto b/services/state/token/nft.proto index aacb6775..1ad8c35d 100644 --- a/services/state/token/nft.proto +++ b/services/state/token/nft.proto @@ -44,14 +44,14 @@ message Nft { * * If this number is zero in state, the NFT is owned by its token type's current treasury. */ - int64 owner_number = 2; + AccountID owner_id = 2; /** * The number of the account or contract approved to spend this NFT. * * If this number is zero, there is no approved spender. */ - int64 spender_number = 3; + AccountID spender_id = 3; /** * The consensus time of the TokenMint that created this NFT. diff --git a/services/state/token/token.proto b/services/state/token/token.proto index a54258a5..066a0e9f 100644 --- a/services/state/token/token.proto +++ b/services/state/token/token.proto @@ -39,6 +39,7 @@ option java_multiple_files = true; message Token { /** * The unique entity number of this token. + * FUTURE : Need to validate if this is needed */ int64 token_number = 1; /** @@ -65,7 +66,7 @@ message Token { * tokens as-well as the tokens from the Token Mint operation once executed. The balance * of the treasury account is decreased when the Token Burn operation is executed. */ - int64 treasury_account_number = 6; + AccountID treasury_account_id = 6; /** * (Optional) The admin key of this token. If this key is set, the token is mutable. * A mutable token can be modified. @@ -125,7 +126,7 @@ message Token { * The number of the account (if any) that the network will attempt to charge for the * token's auto-renewal upon expiration. */ - int64 auto_renew_account_number = 18; + AccountID auto_renew_account_id = 18; /** * The number of seconds the network should automatically extend the token's expiration by, if the * token has a valid auto-renew account, and is not deleted upon expiration. diff --git a/services/state/token/token_relation.proto b/services/state/token/token_relation.proto index cefcb5cb..f078430c 100644 --- a/services/state/token/token_relation.proto +++ b/services/state/token/token_relation.proto @@ -37,11 +37,11 @@ message TokenRelation { /** * The token involved in this relation.It takes only positive */ - int64 token_number = 1; + TokenID token_id = 1; /** * The account involved in this association. */ - int64 account_number = 2; + AccountID account_id = 2; /** * The balance of the token relationship. */ @@ -65,9 +65,9 @@ message TokenRelation { /** * The previous token number of account's association linked list */ - int64 previous_token = 8; + TokenID previous_token = 8; /** * The next token number of account's association linked list */ - int64 next_token = 9; + TokenID next_token = 9; } From 1f12fc005ba002dfc8d8527c39af345d1dfa80ad Mon Sep 17 00:00:00 2001 From: Neeharika-Sompalli Date: Thu, 8 Jun 2023 16:29:54 -0500 Subject: [PATCH 11/17] add ids instead --- services/state/common.proto | 1 + services/state/token/nft.proto | 1 + services/state/token/token.proto | 1 + 3 files changed, 3 insertions(+) diff --git a/services/state/common.proto b/services/state/common.proto index e4860b33..930150a0 100644 --- a/services/state/common.proto +++ b/services/state/common.proto @@ -21,6 +21,7 @@ package proto; * limitations under the License. * ‍ */ +import "basic_types.proto"; option java_package = "com.hederahashgraph.api.proto.java"; // <<>> This comment is special code for setting PBJ Compiler java package diff --git a/services/state/token/nft.proto b/services/state/token/nft.proto index 1ad8c35d..ff4c7340 100644 --- a/services/state/token/nft.proto +++ b/services/state/token/nft.proto @@ -24,6 +24,7 @@ package proto; import "timestamp.proto"; import "state/common.proto"; +import "basic_types.proto"; option java_package = "com.hederahashgraph.api.proto.java"; // <<>> This comment is special code for setting PBJ Compiler java package diff --git a/services/state/token/token.proto b/services/state/token/token.proto index 066a0e9f..dea90c8a 100644 --- a/services/state/token/token.proto +++ b/services/state/token/token.proto @@ -24,6 +24,7 @@ package proto; import "basic_types.proto"; import "custom_fees.proto"; +import "basic_types.proto"; option java_package = "com.hederahashgraph.api.proto.java"; // <<>> This comment is special code for setting PBJ Compiler java package From 9895c5669f7f3cf5d1c2eea23af33f50dfa0fdd8 Mon Sep 17 00:00:00 2001 From: Neeharika-Sompalli Date: Thu, 8 Jun 2023 16:33:35 -0500 Subject: [PATCH 12/17] add ids instead --- services/state/common.proto | 2 +- services/state/token/nft.proto | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/services/state/common.proto b/services/state/common.proto index 930150a0..846b0fd7 100644 --- a/services/state/common.proto +++ b/services/state/common.proto @@ -35,7 +35,7 @@ message EntityNumber { } /** - * A single 64-bit number identifying a Hedera native entity. + * Pair of AccountID and TokenID to represent TokenRelation */ message EntityIDPair { AccountID account_id = 1; diff --git a/services/state/token/nft.proto b/services/state/token/nft.proto index ff4c7340..583475f0 100644 --- a/services/state/token/nft.proto +++ b/services/state/token/nft.proto @@ -22,9 +22,9 @@ package proto; * ‍ */ +import "basic_types.proto"; import "timestamp.proto"; import "state/common.proto"; -import "basic_types.proto"; option java_package = "com.hederahashgraph.api.proto.java"; // <<>> This comment is special code for setting PBJ Compiler java package From aa2608ed23e3bd423a8b7182c6172d9b14c262b2 Mon Sep 17 00:00:00 2001 From: Neeharika-Sompalli Date: Thu, 8 Jun 2023 17:52:05 -0500 Subject: [PATCH 13/17] change order of fields --- services/state/token/account.proto | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/services/state/token/account.proto b/services/state/token/account.proto index b0d4936d..1e449b29 100644 --- a/services/state/token/account.proto +++ b/services/state/token/account.proto @@ -45,31 +45,31 @@ message Account { */ int64 account_number = 1; /** - * The alias to use for this account, if any. + * The balance of the account, in tiny-bars. */ - bytes alias = 2; + int64 tinybar_balance = 2; /** - * (Optional) The key to be used to sign transactions from the account, if any. - * This key will not be set for hollow accounts until the account is finalized. - * This key should be set on all the accounts, except for immutable accounts (0.0.800 and 0.0.801). + * A boolean marking if the account has been deleted. */ - Key key = 3; + bool deleted = 3; /** * The expiration time of the account, in seconds since the epoch. */ int64 expiry = 4; /** - * The balance of the account, in tiny-bars. + * The alias to use for this account, if any. */ - int64 tinybar_balance = 5; + bytes alias = 5; /** - * An optional description of the account with UTF-8 encoding up to 100 bytes. + * (Optional) The key to be used to sign transactions from the account, if any. + * This key will not be set for hollow accounts until the account is finalized. + * This key should be set on all the accounts, except for immutable accounts (0.0.800 and 0.0.801). */ - string memo = 6; + Key key = 6; /** - * A boolean marking if the account has been deleted. + * An optional description of the account with UTF-8 encoding up to 100 bytes. */ - bool deleted = 7; + string memo = 7; /** * The amount of hbars staked to the account. */ From a94bdf4bb572ecda975911ba45aa3a4868a41034 Mon Sep 17 00:00:00 2001 From: Neeharika-Sompalli Date: Thu, 8 Jun 2023 18:01:38 -0500 Subject: [PATCH 14/17] remove import --- services/state/token/token.proto | 1 - 1 file changed, 1 deletion(-) diff --git a/services/state/token/token.proto b/services/state/token/token.proto index dea90c8a..066a0e9f 100644 --- a/services/state/token/token.proto +++ b/services/state/token/token.proto @@ -24,7 +24,6 @@ package proto; import "basic_types.proto"; import "custom_fees.proto"; -import "basic_types.proto"; option java_package = "com.hederahashgraph.api.proto.java"; // <<>> This comment is special code for setting PBJ Compiler java package From b37fa80208f1b4162ce5b2471886a2def7b6b46f Mon Sep 17 00:00:00 2001 From: Neeharika-Sompalli Date: Thu, 8 Jun 2023 18:08:45 -0500 Subject: [PATCH 15/17] docs --- services/state/common.proto | 2 +- services/state/token/account.proto | 2 +- services/state/token/nft.proto | 4 ++-- services/state/token/token.proto | 4 ++-- services/state/token/token_relation.proto | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/services/state/common.proto b/services/state/common.proto index 846b0fd7..c60fa550 100644 --- a/services/state/common.proto +++ b/services/state/common.proto @@ -47,7 +47,7 @@ message EntityIDPair { */ message UniqueTokenId { /** - * The number of the unique token type this NFT is an instance of. + * The id of the unique token this NFT is an instance of. */ TokenID token_id = 1; diff --git a/services/state/token/account.proto b/services/state/token/account.proto index 1e449b29..593c72db 100644 --- a/services/state/token/account.proto +++ b/services/state/token/account.proto @@ -200,7 +200,7 @@ message Account { /** * Allowance granted by this account to a spender for a specific non-fungible token * using ApproveForAll. This allows spender to spend all serial numbers for the given - * non-fungible token number. + * non-fungible token id. */ message AccountApprovalForAllAllowance { TokenID token_id = 1; diff --git a/services/state/token/nft.proto b/services/state/token/nft.proto index 583475f0..d31aeacd 100644 --- a/services/state/token/nft.proto +++ b/services/state/token/nft.proto @@ -41,14 +41,14 @@ message Nft { UniqueTokenId id = 1; /** - * The number of the account or contract that owns this NFT. + * The account or contract id that owns this NFT. * * If this number is zero in state, the NFT is owned by its token type's current treasury. */ AccountID owner_id = 2; /** - * The number of the account or contract approved to spend this NFT. + * The account or contract id approved to spend this NFT. * * If this number is zero, there is no approved spender. */ diff --git a/services/state/token/token.proto b/services/state/token/token.proto index 066a0e9f..e67bb2f3 100644 --- a/services/state/token/token.proto +++ b/services/state/token/token.proto @@ -62,7 +62,7 @@ message Token { */ int64 total_supply = 5; /** - * The treasury account number of this token. This account receives the initial supply of + * The treasury account id of this token. This account receives the initial supply of * tokens as-well as the tokens from the Token Mint operation once executed. The balance * of the treasury account is decreased when the Token Burn operation is executed. */ @@ -123,7 +123,7 @@ message Token { */ TokenSupplyType supply_type = 17; /** - * The number of the account (if any) that the network will attempt to charge for the + * The account id (if any) that the network will attempt to charge for the * token's auto-renewal upon expiration. */ AccountID auto_renew_account_id = 18; diff --git a/services/state/token/token_relation.proto b/services/state/token/token_relation.proto index f078430c..44ba191e 100644 --- a/services/state/token/token_relation.proto +++ b/services/state/token/token_relation.proto @@ -63,11 +63,11 @@ message TokenRelation { */ bool automatic_association = 7; /** - * The previous token number of account's association linked list + * The previous token id of account's association linked list */ TokenID previous_token = 8; /** - * The next token number of account's association linked list + * The next token id of account's association linked list */ TokenID next_token = 9; } From 85c3446ab44fc5b21916eff0a76bd5dcc281a4a7 Mon Sep 17 00:00:00 2001 From: Neeharika-Sompalli Date: Thu, 8 Jun 2023 19:13:33 -0500 Subject: [PATCH 16/17] change to ids for account and token --- services/state/token/account.proto | 4 ++-- services/state/token/token.proto | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/services/state/token/account.proto b/services/state/token/account.proto index 593c72db..34d75b70 100644 --- a/services/state/token/account.proto +++ b/services/state/token/account.proto @@ -39,11 +39,11 @@ option java_multiple_files = true; message Account { /** - * The unique entity number of the account. The shard and realm numbers are implied, based on the network + * The unique entity id of the account. The shard and realm numbers are implied, based on the network * this entity came from. * FUTURE : Need to validate if this is needed */ - int64 account_number = 1; + AccountID account_id = 1; /** * The balance of the account, in tiny-bars. */ diff --git a/services/state/token/token.proto b/services/state/token/token.proto index e67bb2f3..44cebc62 100644 --- a/services/state/token/token.proto +++ b/services/state/token/token.proto @@ -38,10 +38,10 @@ option java_multiple_files = true; message Token { /** - * The unique entity number of this token. + * The unique entity id of this token. * FUTURE : Need to validate if this is needed */ - int64 token_number = 1; + TokenID token_id = 1; /** * The human-readable name of this token and its not necessarily unique. Maximum length allowed is 100 bytes. */ From e1e3aa24a6d6558eba65790c802843e7c01d39f0 Mon Sep 17 00:00:00 2001 From: Neeharika-Sompalli Date: Fri, 9 Jun 2023 08:04:57 -0500 Subject: [PATCH 17/17] change to ids for topic and file also --- services/state/consensus/topic.proto | 8 ++++---- services/state/file/file.proto | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/services/state/consensus/topic.proto b/services/state/consensus/topic.proto index 6288e2f8..10823adb 100644 --- a/services/state/consensus/topic.proto +++ b/services/state/consensus/topic.proto @@ -51,9 +51,9 @@ option java_multiple_files = true; */ message Topic { /** - * The topic's unique entity number in the Merkle state. + * The topic's unique entity id in the Merkle state. */ - int64 topic_number = 1; + TopicID topic_id = 1; /** * The number of messages sent to the topic. */ @@ -68,10 +68,10 @@ message Topic { */ int64 auto_renew_period = 4; /** - * The number of the account (if any) that the network will attempt to charge for the + * The id of the account (if any) that the network will attempt to charge for the * topic's auto-renewal upon expiration. */ - int64 auto_renew_account_number = 5; + AccountID auto_renew_account_id = 5; /** * Whether this topic is deleted. */ diff --git a/services/state/file/file.proto b/services/state/file/file.proto index 15cad7ea..de3ec63f 100644 --- a/services/state/file/file.proto +++ b/services/state/file/file.proto @@ -37,9 +37,9 @@ option java_multiple_files = true; */ message File { /** - * The file's unique entity number in the Merkle state. + * The file's unique entity id in the Merkle state. */ - int64 file_number = 1; + FileID file_id = 1; /** * The file's consensus expiration time in seconds since the epoch. */