From 2bbbee4c9b70bbd715f59b4e16ad969caec3fa0c Mon Sep 17 00:00:00 2001 From: Neeharika Sompalli <52669918+Neeharika-Sompalli@users.noreply.github.com> Date: Thu, 8 Jun 2023 15:21:23 -0500 Subject: [PATCH] Add `StakingNodeInfo` for MerkleStakingInfo (#277) add staking node info --- services/state/token/staking_node_info.proto | 91 ++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 services/state/token/staking_node_info.proto diff --git a/services/state/token/staking_node_info.proto b/services/state/token/staking_node_info.proto new file mode 100644 index 00000000..1be146f5 --- /dev/null +++ b/services/state/token/staking_node_info.proto @@ -0,0 +1,91 @@ +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"; +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 staking info entity in the network Merkle tree. + * + * As with all network entities, staking info is per node and has an unique entity number represented as shard.realm.X. + */ +message StakingNodeInfo { + /** + * The unique entity number of the node. The shard and realm numbers are implied, based on the network + * this entity came from. + */ + int64 node_number = 1; + /** + * The minimum stake on this node that is required for this node to have a non-zero weight to + * participate in the network consensus. + */ + int64 min_stake = 2; + /** + * The maximum stake on this node that is considered to calculate its weight to participate in the network consensus. + */ + int64 max_stake = 3; + /** + * The sum of balances of all accounts staked to this node who have opted to receive rewards. + */ + int64 stake_to_reward = 4; + /** + * The sum of balances of all accounts staked to this node who have opted to decline rewards. + */ + int64 stake_to_not_reward = 5; + /** + * The snapshot of stake_to_reward value at the beginning of the current staking period. + * This is needed for calculating rewards for current staking period without considering changes to + * stake_to_reward in the current staking period. It is reset at the beginning of every period. + */ + int64 stake_reward_start = 6; + /** + * Tracks how much stake from stakeRewardStart will have unclaimed rewards due to accounts changing their staking + * metadata in a way that disqualifies them for the current period; It is reset at the beginning of every period + */ + int64 unclaimed_stake_reward_start = 7; + /** + * The total amount of effective hbar staked to this node. This is sum of stake_to_reward and stake_to_not_reward. + * If the sum is greater than max_stake, then the effective stake is max_stake. + * If the sum is less than min_stake, then the effective stake is 0. + */ + int64 stake = 8; + /** + * An running sum of reward rates per hbar for the last 365+1 staking periods. The first element is the + * is the reward up to and including the last full period that finished before the present. Second element is + * the reward up to and including the period before that + */ + repeated int64 reward_sum_history = 9; + /** + * The consensus weight of this node in the network. This is computed based on the stake of this node + * at midnight UTC of the current day. If the stake of this node is less than minStake, then the weight is 0. + * Sum of all weights of nodes in the network should be less than 500. + * If the stake of this node A is greater than minStake, then the weight of this node A is calculated as: + * (node A stake * 500/ total stake of all nodes) + */ + int32 weight = 10; +}