Skip to content

Commit

Permalink
feat: Pull protos from services (#2611)
Browse files Browse the repository at this point in the history
* refactor: Migrated the protobufs submodule directory to services repo

Signed-off-by: ivaylogarnev-limechain <[email protected]>

* refactor: Removed submodule tagging, Taskfile refactor

Signed-off-by: ivaylogarnev-limechain <[email protected]>

* fix: Fixed the deletion of submodule

Signed-off-by: ivaylogarnev-limechain <[email protected]>

* refactor: Changed some changed protobufs namings

Signed-off-by: ivaylogarnev-limechain <[email protected]>

* fix: Added protobufs for services/streams and removed them from .gitignore

Signed-off-by: ivaylogarnev-limechain <[email protected]>

* fix: Added newly introduced request type

Signed-off-by: ivaylogarnev-limechain <[email protected]>

* fix: Fixed Status code naming

Signed-off-by: ivaylogarnev-limechain <[email protected]>

* fix: Added new status codes and updated protos

Signed-off-by: ivaylogarnev-limechain <[email protected]>

---------

Signed-off-by: ivaylogarnev-limechain <[email protected]>
Co-authored-by: ivaylonikolov7 <[email protected]>
  • Loading branch information
ivaylogarnev-limechain and ivaylonikolov7 authored Dec 2, 2024
1 parent cba5d67 commit 7865bc3
Show file tree
Hide file tree
Showing 156 changed files with 17,742 additions and 22 deletions.
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "packages/proto/src/proto"]
path = packages/proto/src/proto
url = https://github.com/hashgraph/hedera-protobufs.git
[submodule "packages/proto/src/services"]
path = packages/proto/src/services
url = https://github.com/hashgraph/hedera-services.git
1 change: 1 addition & 0 deletions packages/proto/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
src/proto.js
src/proto.d.ts
src/services
50 changes: 33 additions & 17 deletions packages/proto/Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,39 @@ tasks:
docs:
cmds:
- npx typedoc
--excludeInternal
--excludePrivate
--excludeProtected
--out docs
--validation.invalidLink
--entryPoints src/index.js src/browser.js src/native.js

"install:submodules":
--excludeInternal
--excludePrivate
--excludeProtected
--out docs
--validation.invalidLink
--entryPoints src/index.js src/browser.js src/native.js

install:submodules:
cmds:
- git submodule update --init --recursive --remote

move:protobufs:
after:
- "install:submodules"
desc: "Move protobufs from src/services/hapi/hedera-protobufs/services to src/proto"
cmds:
- rm -rf src/proto/services
- mv src/services/hapi/hedera-protobufs/services src/proto/
- rm -rf src/proto/streams
- mv src/services/hapi/hedera-protobufs/streams src/proto/
- echo "Protobufs moved successfully!"
- task "delete:submodule"

delete:submodule:
cmds:
- git submodule update --init
status:
- test -e src/proto/.git
- find src/services -mindepth 1 -delete
- echo "Submodule contents removed successfully, folder retained."

install:
deps:
- "install:submodules"
cmds:
- task "move:protobufs"
- pnpm i > /dev/null

build:
Expand Down Expand Up @@ -74,14 +90,14 @@ tasks:
- build

update:
dir: src/proto
dir: src/services
vars:
latest_tag:
sh: git -c versionsort.suffix=-alpha
-c versionsort.suffix=-beta
-c versionsort.suffix=-rc
tag -l --sort=version:refname|tail -1
proto: '{{.proto | default .latest_tag}}'
sh: git -c versionsort.suffix=-alpha
-c versionsort.suffix=-beta
-c versionsort.suffix=-rc
tag -l --sort=version:refname|tail -1
proto: "{{.proto | default .latest_tag}}"
cmds:
- echo "Protobuf version set to {{.proto}}"
- git fetch origin
Expand Down
1 change: 0 additions & 1 deletion packages/proto/src/proto
Submodule proto deleted from d88484
100 changes: 100 additions & 0 deletions packages/proto/src/proto/mirror/consensus_service.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
/*-
* ‌
* Hedera Mirror Node
* ​
* Copyright (C) 2019 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.
* ‍
*/

syntax = "proto3";

package com.hedera.mirror.api.proto;

/**
* Required for the reactor-grpc generator to work correctly
*/
option java_multiple_files = true;

option java_package = "com.hedera.mirror.api.proto";

import "basic_types.proto";
import "timestamp.proto";
import "consensus_submit_message.proto";

message ConsensusTopicQuery {
/**
* A required topic ID to retrieve messages for.
*/
.proto.TopicID topicID = 1;

/**
* Include messages which reached consensus on or after this time. Defaults to current time if
* not set.
*/
.proto.Timestamp consensusStartTime = 2;

/**
* Include messages which reached consensus before this time. If not set it will receive
* indefinitely.
*/
.proto.Timestamp consensusEndTime = 3;

/**
* The maximum number of messages to receive before stopping. If not set or set to zero it will
* return messages indefinitely.
*/
uint64 limit = 4;
}

message ConsensusTopicResponse {
/**
* The time at which the transaction reached consensus
*/
.proto.Timestamp consensusTimestamp = 1;

/**
* The message body originally in the ConsensusSubmitMessageTransactionBody. Message size will
* be less than 6KiB.
*/
bytes message = 2;

/**
* The running hash (SHA384) of every message.
*/
bytes runningHash = 3;

/**
* Starts at 1 for first submitted message. Incremented on each submitted message.
*/
uint64 sequenceNumber = 4;

/**
* Version of the SHA-384 digest used to update the running hash.
*/
uint64 runningHashVersion = 5;

/**
* Optional information of the current chunk in a fragmented message.
*/
.proto.ConsensusMessageChunkInfo chunkInfo = 6;
}

/**
* The Mirror Service provides the ability to query a stream of Hedera Consensus Service (HCS)
* messages for an HCS Topic via a specific (possibly open-ended) time range.
*/
service ConsensusService {
rpc subscribeTopic (ConsensusTopicQuery) returns (stream ConsensusTopicResponse);
}
57 changes: 57 additions & 0 deletions packages/proto/src/proto/mirror/mirror_network_service.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*-
* ‌
* Hedera Mirror Node
* ​
* Copyright (C) 2019-2022 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.
* ‍
*/

syntax = "proto3";

package com.hedera.mirror.api.proto;

option java_multiple_files = true; // Required for the reactor-grpc generator to work correctly
option java_package = "com.hedera.mirror.api.proto";

import "basic_types.proto";
import "timestamp.proto";

/**
* Request object to query an address book for its list of nodes
*/
message AddressBookQuery {
/**
* The ID of the address book file on the network. Can be either 0.0.101 or 0.0.102.
*/
.proto.FileID file_id = 1;

/**
* The maximum number of node addresses to receive before stopping. If not set or set to zero it will return all node addresses in the database.
*/
int32 limit = 2;
}

/**
* Provides cross network APIs like address book queries
*/
service NetworkService {
/*
* Query for an address book and return its nodes. The nodes are returned in ascending order by node ID. The
* response is not guaranteed to be a byte-for-byte equivalent to the NodeAddress in the Hedera file on
* the network since it is reconstructed from a normalized database table.
*/
rpc getNodes (AddressBookQuery) returns (stream .proto.NodeAddress);
}

19 changes: 19 additions & 0 deletions packages/proto/src/proto/sdk/transaction_list.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
syntax = "proto3";

package proto;

option java_package = "com.hedera.hashgraph.sdk.proto";
option java_multiple_files = true;

import "transaction.proto";

/**
* A simple protobuf wrapper to store a list of transactions. This is used by
* `Transaction.[from|to]Bytes()` in the SDKs. The reason the SDK needs a list of transactions is
* because it holds onto a transaction per node. So if a transaction is to be submitted to nodes 3
* and 4 the SDK Transaction type would contain a list of 2 protobuf transactions, one for node 3
* and one for node 4.
*/
message TransactionList {
repeated Transaction transaction_list = 1;
}
Loading

0 comments on commit 7865bc3

Please sign in to comment.