Skip to content

Commit

Permalink
feat(HIP-904): allow maxAutomaticTokenAssociations to support -1 value (
Browse files Browse the repository at this point in the history
#1887)

Signed-off-by: Nikita Lebedev <nikita.lebedev@limechain.tech>
  • Loading branch information
thenswan authored Jul 10, 2024
1 parent c020b01 commit b0bdfc7
Show file tree
Hide file tree
Showing 25 changed files with 3,530 additions and 2,495 deletions.
8 changes: 4 additions & 4 deletions sdk/src/main/java/com/hedera/hashgraph/sdk/RequestType.java
Original file line number Diff line number Diff line change
Expand Up @@ -415,9 +415,9 @@ public enum RequestType {
NODE_DELETE(HederaFunctionality.NodeDelete),

/**
* Get Node information
* Transfer one or more token balances held by the requesting account to the treasury for each token type.
*/
NODE_GET_INFO(HederaFunctionality.NodeGetInfo);
TOKEN_REJECT(HederaFunctionality.TokenReject);

final HederaFunctionality code;

Expand Down Expand Up @@ -505,7 +505,7 @@ static RequestType valueOf(HederaFunctionality code) {
case NodeCreate -> NODE_CREATE;
case NodeUpdate -> NODE_UPDATE;
case NodeDelete -> NODE_DELETE;
case NodeGetInfo -> NODE_GET_INFO;
case TokenReject -> TOKEN_REJECT;
default -> throw new IllegalStateException("(BUG) unhandled HederaFunctionality");
};
}
Expand Down Expand Up @@ -591,7 +591,7 @@ public String toString() {
case NODE_CREATE -> "NODE_CREATE";
case NODE_UPDATE -> "NODE_UPDATE";
case NODE_DELETE -> "NODE_DELETE";
case NODE_GET_INFO -> "NODE_GET_INFO";
case TOKEN_REJECT -> "TOKEN_REJECT";
};
}
}
125 changes: 114 additions & 11 deletions sdk/src/main/java/com/hedera/hashgraph/sdk/Status.java
Original file line number Diff line number Diff line change
Expand Up @@ -1552,50 +1552,140 @@ public enum Status {
TOKEN_HAS_NO_ADMIN_KEY(ResponseCodeEnum.TOKEN_HAS_NO_ADMIN_KEY),

/**
* The node has been marked as deleted
* A transaction failed because the consensus node identified is
* deleted from the address book.
*/
NODE_DELETED(ResponseCodeEnum.NODE_DELETED),

/**
* A node is not found during update and delete node transaction
* A transaction failed because the consensus node identified is not valid or
* does not exist in state.
*/
INVALID_NODE_ID(ResponseCodeEnum.INVALID_NODE_ID),

/**
* gossip_endpoint has a fully qualified domain name instead of ip
* A transaction failed because one or more entries in the list of
* service endpoints for the `gossip_endpoint` field is invalid.<br/>
* The most common cause for this response is a service endpoint that has
* the domain name (DNS) set rather than address and port.
*/
INVALID_GOSSIP_ENDPOINT(ResponseCodeEnum.INVALID_GOSSIP_ENDPOINT),

/**
* The node account_id is invalid
* A transaction failed because the node account identifier provided
* does not exist or is not valid.<br/>
* One common source of this error is providing a node account identifier
* using the "alias" form rather than "numeric" form.
*/
INVALID_NODE_ACCOUNT_ID(ResponseCodeEnum.INVALID_NODE_ACCOUNT_ID),

/**
* The node description is invalid
* A transaction failed because the description field cannot be encoded
* as UTF-8 or is more than 100 bytes when encoded.
*/
INVALID_NODE_DESCRIPTION(ResponseCodeEnum.INVALID_NODE_DESCRIPTION),

/**
* service_endpoint is invalid
* A transaction failed because one or more entries in the list of
* service endpoints for the `service_endpoint` field is invalid.<br/>
* The most common cause for this response is a service endpoint that has
* the domain name (DNS) set rather than address and port.
*/
INVALID_SERVICE_ENDPOINT(ResponseCodeEnum.INVALID_SERVICE_ENDPOINT),

/**
* gossip_ca_certificate is invalid
* A transaction failed because the TLS certificate provided for the
* node is missing or invalid.<br/>
* The certificate MUST be a TLS certificate of a type permitted for gossip
* signatures.<br/>
* The value presented MUST be a UTF-8 NFKD encoding of the TLS
* certificate.<br/>
* The certificate encoded MUST be in PEM format.<br/>
* The `gossip_ca_certificate` field is REQUIRED and MUST NOT be empty.
*/
INVALID_GOSSIP_CAE_CERTIFICATE(ResponseCodeEnum.INVALID_GOSSIP_CAE_CERTIFICATE),
INVALID_GOSSIP_CA_CERTIFICATE(ResponseCodeEnum.INVALID_GOSSIP_CA_CERTIFICATE),

/**
* grpc_certificate_hash is invalid
* A transaction failed because the hash provided for the gRPC certificate
* is present but invalid.<br/>
* The `grpc_certificate_hash` MUST be a SHA-384 hash.<br/>
* The input hashed MUST be a UTF-8 NFKD encoding of the actual TLS
* certificate.<br/>
* The certificate to be encoded MUST be in PEM format.
*/
INVALID_GRPC_CERTIFICATE(ResponseCodeEnum.INVALID_GRPC_CERTIFICATE),

/**
* The maximum automatic associations value is not valid.<br/>
* The most common cause for this error is a value less than `-1`.
*/
INVALID_MAX_AUTO_ASSOCIATIONS(ResponseCodeEnum.INVALID_MAX_AUTO_ASSOCIATIONS);
INVALID_MAX_AUTO_ASSOCIATIONS(ResponseCodeEnum.INVALID_MAX_AUTO_ASSOCIATIONS),

/**
* The maximum number of nodes allowed in the address book have been created.
*/
MAX_NODES_CREATED(ResponseCodeEnum.MAX_NODES_CREATED),

/**
* In ServiceEndpoint, domain_name and ipAddressV4 are mutually exclusive
*/
IP_FQDN_CANNOT_BE_SET_FOR_SAME_ENDPOINT(ResponseCodeEnum.IP_FQDN_CANNOT_BE_SET_FOR_SAME_ENDPOINT),

/**
* Fully qualified domain name is not allowed in gossip_endpoint
*/
GOSSIP_ENDPOINT_CANNOT_HAVE_FQDN(ResponseCodeEnum.GOSSIP_ENDPOINT_CANNOT_HAVE_FQDN),

/**
* In ServiceEndpoint, domain_name size too large
*/
FQDN_SIZE_TOO_LARGE(ResponseCodeEnum.FQDN_SIZE_TOO_LARGE),

/**
* ServiceEndpoint is invalid
*/
INVALID_ENDPOINT(ResponseCodeEnum.INVALID_ENDPOINT),

/**
* The number of gossip endpoints exceeds the limit
*/
GOSSIP_ENDPOINTS_EXCEEDED_LIMIT(ResponseCodeEnum.GOSSIP_ENDPOINTS_EXCEEDED_LIMIT),

/**
* The transaction attempted to use duplicate `TokenReference`.<br/>
* This affects `TokenReject` attempting to reject same token reference more than once.
*/
TOKEN_REFERENCE_REPEATED(ResponseCodeEnum.TOKEN_REFERENCE_REPEATED),

/**
* The account id specified as the owner in `TokenReject` is invalid or does not exist.
*/
INVALID_OWNER_ID(ResponseCodeEnum.INVALID_OWNER_ID),

/**
* The transaction attempted to use more than the allowed number of `TokenReference`.
*/
TOKEN_REFERENCE_LIST_SIZE_LIMIT_EXCEEDED(ResponseCodeEnum.TOKEN_REFERENCE_LIST_SIZE_LIMIT_EXCEEDED),

/**
* The number of service endpoints exceeds the limit
*/
SERVICE_ENDPOINTS_EXCEEDED_LIMIT(ResponseCodeEnum.SERVICE_ENDPOINTS_EXCEEDED_LIMIT),

/**
* The IPv4 address is invalid
*/
INVALID_IPV4_ADDRESS(ResponseCodeEnum.INVALID_IPV4_ADDRESS),

/**
* The transaction attempted to use empty `TokenReference` list.
*/
EMPTY_TOKEN_REFERENCE_LIST(ResponseCodeEnum.EMPTY_TOKEN_REFERENCE_LIST),

/**
* The node account is not allowed to be updated
*/
UPDATE_NODE_ACCOUNT_NOT_ALLOWED(ResponseCodeEnum.UPDATE_NODE_ACCOUNT_NOT_ALLOWED);

final ResponseCodeEnum code;

Expand Down Expand Up @@ -1907,9 +1997,22 @@ static Status valueOf(ResponseCodeEnum code) {
case INVALID_NODE_ACCOUNT_ID -> INVALID_NODE_ACCOUNT_ID;
case INVALID_NODE_DESCRIPTION -> INVALID_NODE_DESCRIPTION;
case INVALID_SERVICE_ENDPOINT -> INVALID_SERVICE_ENDPOINT;
case INVALID_GOSSIP_CAE_CERTIFICATE -> INVALID_GOSSIP_CAE_CERTIFICATE;
case INVALID_GOSSIP_CA_CERTIFICATE -> INVALID_GOSSIP_CA_CERTIFICATE;
case INVALID_GRPC_CERTIFICATE -> INVALID_GRPC_CERTIFICATE;
case INVALID_MAX_AUTO_ASSOCIATIONS -> INVALID_MAX_AUTO_ASSOCIATIONS;
case MAX_NODES_CREATED -> MAX_NODES_CREATED;
case IP_FQDN_CANNOT_BE_SET_FOR_SAME_ENDPOINT -> IP_FQDN_CANNOT_BE_SET_FOR_SAME_ENDPOINT;
case GOSSIP_ENDPOINT_CANNOT_HAVE_FQDN -> GOSSIP_ENDPOINT_CANNOT_HAVE_FQDN;
case FQDN_SIZE_TOO_LARGE -> FQDN_SIZE_TOO_LARGE;
case INVALID_ENDPOINT -> INVALID_ENDPOINT;
case GOSSIP_ENDPOINTS_EXCEEDED_LIMIT -> GOSSIP_ENDPOINTS_EXCEEDED_LIMIT;
case TOKEN_REFERENCE_REPEATED -> TOKEN_REFERENCE_REPEATED;
case INVALID_OWNER_ID -> INVALID_OWNER_ID;
case TOKEN_REFERENCE_LIST_SIZE_LIMIT_EXCEEDED -> TOKEN_REFERENCE_LIST_SIZE_LIMIT_EXCEEDED;
case SERVICE_ENDPOINTS_EXCEEDED_LIMIT -> SERVICE_ENDPOINTS_EXCEEDED_LIMIT;
case INVALID_IPV4_ADDRESS -> INVALID_IPV4_ADDRESS;
case EMPTY_TOKEN_REFERENCE_LIST -> EMPTY_TOKEN_REFERENCE_LIST;
case UPDATE_NODE_ACCOUNT_NOT_ALLOWED -> UPDATE_NODE_ACCOUNT_NOT_ALLOWED;
case UNRECOGNIZED ->
// NOTE: Protobuf deserialization will not give us the code on the wire
throw new IllegalArgumentException(
Expand Down
143 changes: 118 additions & 25 deletions sdk/src/main/proto/address_book_service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ syntax = "proto3";
package proto;

/*
* Hedera Network Services Protobuf
*
* Copyright (C) 2024 Hedera Hashgraph, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -29,37 +27,132 @@ import "transaction_response.proto";
import "transaction.proto";

/**
* Transactions for the AddressBook Service, those HAPI APIs facilitate changes to the nodes used across the Hedera network.
* All those transactions needs to be signed by the Hedera Council. Steps needed below:
* 1. The node operator creates and signs the transaction with their key (the key on the node operator account)
* 2. The node operator hands this transaction to Alex, who then gives it to the council to sign
* 3. When signed and submitted, the server will verify that account 2 keys have signed, and the keys on the operator account have signed.
* Hedera council should have ability to make all edits in addition to add/remove nodes
* The Address Book service provides the ability for Hedera network node
* administrators to add, update, and remove consensus nodes. This addition,
* update, or removal of a consensus node requires governing council approval,
* but each node operator may update their own operational attributes without
* additional approval, reducing overhead for routine operations.
*
* Most operations are `privileged operations` and require governing council
* approval.
*
* ### For a node creation transaction.
* - The node operator SHALL create a `createNode` transaction.
* - The node operator SHALL sign this transaction with the active `key` for
* the account to be assigned as the "node account".
* - The node operator MUST deliver the signed transaction to the Hedera
* council representative.
* - The Hedera council representative SHALL arrange for council members to
* review and sign the transaction.
* - Once sufficient council members have signed the transaction, the
* Hedera council representative SHALL submit the transaction to the
* network.
* - Upon receipt of a valid and signed node creation transaction the network
* software SHALL
* - Validate the threshold signature for the Hedera governing council
* - Validate the signature of the active `key` for the account to be
* assigned as the "node account".
* - Create the new node in state, this new node SHALL NOT be active in the
* network at this time.
* - When executing the next `freeze` transaction with `freeze_type` set to
* `PREPARE_UPGRADE`, update network configuration and bring the
* new node to an active status within the network. The node to be added
* SHALL be active in the network following this upgrade.
*
* ### For a node deletion transaction.
* - The node operator or Hedera council representative SHALL create a
* `deleteNode` transaction.
* - If the node operator creates the transaction
* - The node operator MUST sign this transaction with the active `key`
* for the account assigned as the "node account".
* - The node operator SHALL deliver the signed transaction to the Hedera
* council representative.
* - The Hedera council representative SHALL arrange for council members to
* review and sign the transaction.
* - Once sufficient council members have signed the transaction, the
* Hedera council representative SHALL submit the transaction to the
* network.
* - Upon receipt of a valid and signed node deletion transaction the network
* software SHALL
* - Validate the threshold signature for the Hedera governing council
* - Remove the existing node from network state. The node SHALL still
* be active in the network at this time.
* - When executing the next `freeze` transaction with `freeze_type` set to
* `PREPARE_UPGRADE`, update network configuration and remove the
* node to be deleted from the network. The node to be deleted SHALL NOT
* be active in the network following this upgrade.
*
* ### For a node update transaction.
* - The node operator or Hedera council representative SHALL create an
* `updateNode` transaction.
* - If the node operator creates the transaction
* - The node operator MUST sign this transaction with the active `key`
* for the account assigned as the current "node account".
* - If the transaction changes the value of the "node account" the
* node operator MUST _also_ sign this transaction with the active `key`
* for the account to be assigned as the new "node account".
* - The node operator SHALL submit the transaction to the
* network. Hedera council approval SHALL NOT be sought for this
* transaction
* - If the Hedera council representative creates the transaction
* - The Hedera council representative SHALL arrange for council members
* to review and sign the transaction.
* - Once sufficient council members have signed the transaction, the
* Hedera council representative SHALL submit the transaction to the
* network.
* - Upon receipt of a valid and signed node update transaction the network
* software SHALL
* - If the transaction is signed by the Hedera governing council
* - Validate the threshold signature for the Hedera governing council
* - If the transaction is signed by the active `key` for the node account
* - Validate the signature of the active `key` for the account assigned
* as the "node account".
* - If the transaction modifies the value of the "node account",
* - Validate the signature of the _new_ `key` for the account to be
* assigned as the new "node account".
* - Modify the node information held in network state with the changes
* requested in the update transaction. The node changes SHALL NOT be
* applied to network configuration, and SHALL NOT affect network
* operation at this time.
* - When executing the next `freeze` transaction with `freeze_type` set to
* `PREPARE_UPGRADE`, update network configuration according to the
* modified information in network state. The requested changes SHALL
* affect network operation following this upgrade.
*/
service AddressBookService {
/**
* Prepare to add a new node to the network.
* When a valid council member initiates a HAPI transaction to add a new node,
* then the network should acknowledge the transaction and update the network’s Address Book within 24 hours.
* The added node will not be active until the network is upgraded.
*/
rpc createNode (Transaction) returns (TransactionResponse);

/**
* Prepare to delete the node to the network.
* The deleted node will not be deleted until the network is upgraded.
* Such a deleted node can never be reused.
* A transaction to create a new consensus node in the network.
* address book.
* <p>
* This transaction, once complete, SHALL add a new consensus node to the
* network state.<br/>
* The new consensus node SHALL remain in state, but SHALL NOT participate
* in network consensus until the network updates the network configuration.
* <p>
* Hedera governing council authorization is REQUIRED for this transaction.
*/
rpc deleteNode (Transaction) returns (TransactionResponse);
rpc createNode (proto.Transaction) returns (proto.TransactionResponse);

/**
* Prepare to update the node to the network.
* The node will not be updated until the network is upgraded.
* A transaction to remove a consensus node from the network address
* book.
* <p>
* This transaction, once complete, SHALL remove the identified consensus
* node from the network state.
* <p>
* Hedera governing council authorization is REQUIRED for this transaction.
*/
rpc updateNode (Transaction) returns (TransactionResponse);
rpc deleteNode (proto.Transaction) returns (proto.TransactionResponse);

/**
* Retrieves the node information by node Id.
* A transaction to update an existing consensus node from the network
* address book.
* <p>
* This transaction, once complete, SHALL modify the identified consensus
* node state as requested.
* <p>
* This transaction MAY be authorized by either the node operator OR the
* Hedera governing council.
*/
rpc getNodeInfo (Query) returns (Response);
rpc updateNode (proto.Transaction) returns (proto.TransactionResponse);
}
Loading

0 comments on commit b0bdfc7

Please sign in to comment.