Skip to content

Commit

Permalink
chore: Remove inexact-weight TSS implementation (#17214)
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Tinker <[email protected]>
  • Loading branch information
tinker-michaelj authored Jan 7, 2025
1 parent 4f476f9 commit 7e8fc98
Show file tree
Hide file tree
Showing 126 changed files with 733 additions and 9,241 deletions.

This file was deleted.

24 changes: 4 additions & 20 deletions hapi/hedera-protobufs/services/basic_types.proto
Original file line number Diff line number Diff line change
Expand Up @@ -1193,6 +1193,10 @@ message SignatureMap {
* The transactions and queries supported by Hedera Hashgraph.
*/
enum HederaFunctionality {
// FUTURE - Uncomment when https://github.com/hashgraph/pbj/issues/339 is fixed;
// currently the PBJ-generated unit tests fail when using reserved ordinals
// reserved 96, 97, 98, 99;

/**
* Unused - The first value is unused because this default value is
* ambiguous with an "unset" value and therefore should not be used.
Expand Down Expand Up @@ -1644,26 +1648,6 @@ enum HederaFunctionality {
*/
TokenClaimAirdrop = 95;

/**
* A message produced as part of Threshold Signature Scheme (TSS) processing.
*/
TssMessage = 96;

/**
* Submit a vote as part of the Threshold Signature Scheme (TSS) processing.
*/
TssVote = 97;

/**
* Submit a node signature as part of the Threshold Signature Scheme (TSS) processing.
*/
TssShareSignature = 98;

/**
* Submit a node public tss encryption key as part of the Threshold Signature Scheme (TSS).
*/
TssEncryptionKey = 99;

/**
* Submit a signature of a state root hash gossiped to other nodes
*/
Expand Down
29 changes: 3 additions & 26 deletions hapi/hedera-protobufs/services/transaction_body.proto
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,6 @@ import "node_create.proto";
import "node_update.proto";
import "node_delete.proto";

import "auxiliary/tss/tss_message.proto";
import "auxiliary/tss/tss_vote.proto";
import "auxiliary/tss/tss_share_signature.proto";
import "auxiliary/tss/tss_encryption_key.proto";

import "event/state_signature_transaction.proto";

/**
Expand All @@ -124,7 +119,9 @@ import "event/state_signature_transaction.proto";
* various parameters required to process a transaction.
*/
message TransactionBody {
reserved 30; // removed prior to earliest available history.
reserved 30, 61, 62, 63, 64;

reserved "tssMessage", "tssVote", "tssShareSignature", "tssEncryptionKey";

/**
* A transaction identifier.<br/>
Expand Down Expand Up @@ -559,26 +556,6 @@ message TransactionBody {
*/
TokenClaimAirdropTransactionBody tokenClaimAirdrop = 60;

/**
* A transaction body for a `tssMessage` request.
*/
com.hedera.hapi.services.auxiliary.tss.TssMessageTransactionBody tssMessage = 61;

/**
* A transaction body for a `tssVote` request.
*/
com.hedera.hapi.services.auxiliary.tss.TssVoteTransactionBody tssVote = 62;

/**
* A transaction body for node signature as part of the Threshold Signature Scheme (TSS) processing.
*/
com.hedera.hapi.services.auxiliary.tss.TssShareSignatureTransactionBody tssShareSignature = 63;

/**
* A transaction body for a 'tssEncryptionKey` request
*/
com.hedera.hapi.services.auxiliary.tss.TssEncryptionKeyTransactionBody tssEncryptionKey = 64;

/**
* A transaction body for signature of a state root hash gossiped to other nodes
*/
Expand Down
35 changes: 6 additions & 29 deletions hapi/internal-protobufs/network/network.proto
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ package com.hedera.node.internal.network;
* limitations under the License.
*/

import "auxiliary/tss/tss_message.proto";
import "state/addressbook/node.proto";
import "state/roster/roster.proto";

Expand Down Expand Up @@ -65,32 +64,16 @@ option java_multiple_files = true;
* resets.
*/
message Network {
reserved 2;

/**
* The metadata of the nodes in the network.
*/
repeated NodeMetadata node_metadata = 1;

/**
* A list of TSS messages that have been generated by the nodes in
* a target network that is receiving a "transplant state". <br/>
* This gives the capability to preserve the ledger id of the target network
* even if the transplant state has no keys or roster entries in common with
* the target.
* <p>
* This MUST be exactly the ordered list of TSS messages used to generate
* the target network's ledger id; and must generate the same ledger id
* given below.
*/
repeated com.hedera.hapi.services.auxiliary.tss.TssMessageTransactionBody tss_messages = 2;

/**
* A public key.<br/>
* This key both identifies the ledger and can be used to verify ledger
* signatures on a block root hash.
* <p>
* This value MUST be set.<br/>
* This value MUST NOT be empty.<br/>
* This value MUST contain a valid public key.
* If set, the hash of the first roster that adopted TSS.<br/>
* A public input to every hinTS verification key proof.
*/
bytes ledger_id = 3;
}
Expand All @@ -99,6 +82,8 @@ message Network {
* The full information needed for a single node in the network state.
*/
message NodeMetadata {
reserved 3;

/**
* The node's entry in the current roster at the time of the network snapshot;
* required to validate the network's ledger id if set.
Expand All @@ -114,12 +99,4 @@ message NodeMetadata {
* in the network state.<br/>
*/
com.hedera.hapi.node.state.addressbook.Node node = 2;

/**
* An elliptic curve public encryption key.<br/>
* If set, the public part of a prescribed TSS encryption key for the node.
* This is currently a BN254 elliptic curve, but this type may be subject to
* change in the future.
*/
bytes tss_encryption_key = 3;
}
6 changes: 1 addition & 5 deletions hapi/src/main/java/com/hedera/hapi/util/HapiUtils.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2023-2024 Hedera Hashgraph, LLC
* Copyright (C) 2023-2025 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.
Expand Down Expand Up @@ -232,10 +232,6 @@ public static HederaFunctionality functionOf(final TransactionBody txn) throws U
case TOKEN_AIRDROP -> HederaFunctionality.TOKEN_AIRDROP;
case TOKEN_CANCEL_AIRDROP -> HederaFunctionality.TOKEN_CANCEL_AIRDROP;
case TOKEN_CLAIM_AIRDROP -> HederaFunctionality.TOKEN_CLAIM_AIRDROP;
case TSS_MESSAGE -> HederaFunctionality.TSS_MESSAGE;
case TSS_VOTE -> HederaFunctionality.TSS_VOTE;
case TSS_SHARE_SIGNATURE -> HederaFunctionality.TSS_SHARE_SIGNATURE;
case TSS_ENCRYPTION_KEY -> HederaFunctionality.TSS_ENCRYPTION_KEY;
case STATE_SIGNATURE_TRANSACTION -> HederaFunctionality.STATE_SIGNATURE_TRANSACTION;
case UNSET -> throw new UnknownHederaFunctionality();
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2024 Hedera Hashgraph, LLC
* Copyright (C) 2024-2025 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.
Expand All @@ -20,9 +20,8 @@
import static com.hedera.hapi.block.stream.output.StateIdentifier.STATE_ID_BLOCK_STREAM_INFO;
import static com.hedera.hapi.block.stream.output.StateIdentifier.STATE_ID_PLATFORM_STATE;
import static com.hedera.node.app.blocks.BlockStreamManager.ZERO_BLOCK_HASH;
import static com.hedera.node.app.blocks.MockBlockHashSigner.MOCK_BLOCK_HASH_SIGNER;
import static com.hedera.node.app.blocks.schemas.V0560BlockStreamSchema.BLOCK_STREAM_INFO_KEY;
import static com.hedera.node.app.spi.AppContext.Gossip.UNAVAILABLE_GOSSIP;
import static com.hedera.node.app.workflows.standalone.TransactionExecutors.DEFAULT_NODE_INFO;
import static java.util.Objects.requireNonNull;
import static java.util.concurrent.CompletableFuture.completedFuture;

Expand All @@ -43,19 +42,13 @@
import com.hedera.node.app.blocks.schemas.V0560BlockStreamSchema;
import com.hedera.node.app.config.ConfigProviderImpl;
import com.hedera.node.app.fixtures.state.FakeState;
import com.hedera.node.app.services.AppContextImpl;
import com.hedera.node.app.spi.AppContext;
import com.hedera.node.app.spi.signatures.SignatureVerifier;
import com.hedera.node.app.tss.TssBaseServiceImpl;
import com.hedera.node.app.tss.TssLibraryImpl;
import com.hedera.node.config.ConfigProvider;
import com.hedera.pbj.runtime.OneOf;
import com.hedera.pbj.runtime.ParseException;
import com.hedera.pbj.runtime.io.buffer.BufferedData;
import com.hedera.pbj.runtime.io.buffer.Bytes;
import com.swirlds.common.crypto.Hash;
import com.swirlds.common.metrics.noop.NoOpMetrics;
import com.swirlds.metrics.api.Metrics;
import com.swirlds.platform.state.service.PlatformStateService;
import com.swirlds.platform.state.service.schemas.V0540PlatformStateSchema;
import com.swirlds.platform.system.Round;
Expand Down Expand Up @@ -105,7 +98,6 @@ public class BlockStreamManagerBenchmark {
private static final String SAMPLE_BLOCK = "sample.blk.gz";
private static final Instant FAKE_CONSENSUS_NOW = Instant.ofEpochSecond(1_234_567L, 890);
private static final Timestamp FAKE_CONSENSUS_TIME = new Timestamp(1_234_567L, 890);
private static final Metrics NO_OP_METRICS = new NoOpMetrics();
private static final SemanticVersion VERSION = new SemanticVersion(0, 56, 0, "", "");

public static void main(String... args) throws Exception {
Expand All @@ -120,29 +112,12 @@ public static void main(String... args) throws Exception {
"blockStream.hashCombineBatchSize", "64",
"blockStream.serializationBatchSize", "32"));
private final List<BlockItem> roundItems = new ArrayList<>();
final AppContext appContext = new AppContextImpl(
Instant::now,
fakeSignatureVerifier(),
UNAVAILABLE_GOSSIP,
configProvider::getConfiguration,
() -> DEFAULT_NODE_INFO,
() -> NO_OP_METRICS,
(split, snapshots) -> {
throw new UnsupportedOperationException();
});
private final TssBaseServiceImpl tssBaseService = new TssBaseServiceImpl(
appContext,
ForkJoinPool.commonPool(),
ForkJoinPool.commonPool(),
new TssLibraryImpl(appContext),
ForkJoinPool.commonPool(),
new NoOpMetrics());
private final BlockStreamManagerImpl subject = new BlockStreamManagerImpl(
MOCK_BLOCK_HASH_SIGNER,
NoopBlockItemWriter::new,
// BaosBlockItemWriter::new,
ForkJoinPool.commonPool(),
configProvider,
tssBaseService,
new FakeBoundaryStateChangeListener(),
new InitialStateHash(completedFuture(FAKE_START_OF_BLOCK_STATE_HASH), FIRST_ROUND_NO - 1),
VERSION);
Expand All @@ -165,7 +140,6 @@ public void setup() throws IOException, ParseException {
addServiceSingleton(new V0560BlockStreamSchema(ignore -> {}), BlockStreamService.NAME, BlockStreamInfo.DEFAULT);
addServiceSingleton(new V0540PlatformStateSchema(), PlatformStateService.NAME, platformState);
subject.initLastBlockHash(ZERO_BLOCK_HASH);
tssBaseService.registerLedgerSignatureConsumer(subject);
}

@Benchmark
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Copyright (C) 2024-2025 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.
*/

package com.hedera.node.app.blocks;

import static com.hedera.node.app.hapi.utils.CommonUtils.noThrowSha384HashOf;
import static java.util.Objects.requireNonNull;

import com.hedera.pbj.runtime.io.buffer.Bytes;
import edu.umd.cs.findbugs.annotations.NonNull;
import java.util.concurrent.CompletableFuture;

/**
* A mock implementation of the {@link BlockHashSigner} that "signs" block hashes by
* scheduling their SHA-384 hash.
*/
public enum MockBlockHashSigner implements BlockHashSigner {
MOCK_BLOCK_HASH_SIGNER;

@Override
public boolean isReady() {
return true;
}

@Override
public CompletableFuture<Bytes> signFuture(@NonNull final Bytes blockHash) {
requireNonNull(blockHash);
return CompletableFuture.supplyAsync(() -> noThrowSha384HashOf(blockHash));
}
}
Loading

0 comments on commit 7e8fc98

Please sign in to comment.