-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Added states for TssService (#15622)
Signed-off-by: Thomas Moran <[email protected]> Signed-off-by: Neeharika-Sompalli <[email protected]> Signed-off-by: Neeharika Sompalli <[email protected]> Co-authored-by: Thomas Moran <[email protected]> Co-authored-by: Joseph S. <[email protected]> Co-authored-by: Matt Hess <[email protected]>
- Loading branch information
1 parent
a086d3b
commit b19b06f
Showing
11 changed files
with
171 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
hedera-node/hedera-app/src/main/java/com/hedera/node/app/tss/schemas/V0560TSSSchema.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
* Copyright (C) 2024 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.tss.schemas; | ||
|
||
import com.hedera.hapi.node.base.SemanticVersion; | ||
import com.hedera.hapi.node.state.tss.TssMessageMapKey; | ||
import com.hedera.hapi.node.state.tss.TssVoteMapKey; | ||
import com.hedera.hapi.node.tss.TssMessageTransactionBody; | ||
import com.hedera.hapi.node.tss.TssVoteTransactionBody; | ||
import com.swirlds.state.spi.Schema; | ||
import com.swirlds.state.spi.StateDefinition; | ||
import edu.umd.cs.findbugs.annotations.NonNull; | ||
import java.util.Set; | ||
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; | ||
|
||
/** | ||
* Schema for the TSS service. | ||
*/ | ||
public class V0560TSSSchema extends Schema { | ||
private static final Logger log = LogManager.getLogger(V0560TSSSchema.class); | ||
public static final String TSS_MESSAGE_MAP_KEY = "TSS_MESSAGES"; | ||
public static final String TSS_VOTE_MAP_KEY = "TSS_VOTES"; | ||
/** | ||
* This will at most be equal to the number of nodes in the network. | ||
*/ | ||
private static final long MAX_TSS_MESSAGES = 65_536L; | ||
/** | ||
* This will at most be equal to the number of nodes in the network. | ||
*/ | ||
private static final long MAX_TSS_VOTES = 65_536L; | ||
|
||
/** | ||
* The version of the schema. | ||
*/ | ||
private static final SemanticVersion VERSION = | ||
SemanticVersion.newBuilder().major(0).minor(56).patch(0).build(); | ||
/** | ||
* Create a new instance | ||
*/ | ||
public V0560TSSSchema() { | ||
super(VERSION); | ||
} | ||
|
||
@NonNull | ||
@Override | ||
public Set<StateDefinition> statesToCreate() { | ||
return Set.of( | ||
StateDefinition.onDisk( | ||
TSS_MESSAGE_MAP_KEY, | ||
TssMessageMapKey.PROTOBUF, | ||
TssMessageTransactionBody.PROTOBUF, | ||
MAX_TSS_MESSAGES), | ||
StateDefinition.onDisk( | ||
TSS_VOTE_MAP_KEY, TssVoteMapKey.PROTOBUF, TssVoteTransactionBody.PROTOBUF, MAX_TSS_VOTES)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
hedera-node/hedera-app/src/test/java/com/hedera/node/app/tss/schemas/V0560TSSSchemaTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Copyright (C) 2024 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.tss.schemas; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import com.swirlds.state.spi.StateDefinition; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
public class V0560TSSSchemaTest { | ||
private V0560TSSSchema subject; | ||
|
||
@BeforeEach | ||
void setUp() { | ||
subject = new V0560TSSSchema(); | ||
} | ||
|
||
@Test | ||
void registersExpectedSchema() { | ||
final var statesToCreate = subject.statesToCreate(); | ||
assertThat(statesToCreate.size()).isEqualTo(2); | ||
final var iter = | ||
statesToCreate.stream().map(StateDefinition::stateKey).sorted().iterator(); | ||
assertEquals(V0560TSSSchema.TSS_MESSAGE_MAP_KEY, iter.next()); | ||
assertEquals(V0560TSSSchema.TSS_VOTE_MAP_KEY, iter.next()); | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
hedera-node/hedera-config/src/main/java/com/hedera/node/config/data/TssConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright (C) 2023-2024 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.config.data; | ||
|
||
import com.hedera.node.config.NetworkProperty; | ||
import com.swirlds.config.api.ConfigData; | ||
import com.swirlds.config.api.ConfigProperty; | ||
|
||
/** | ||
* Configuration for the TSS service. | ||
* @param maxSharesPerNode The maximum number of shares that can be assigned to a node. | ||
* @param keyActiveRoster A test-only configuration; set this to true to enable the process that will key the candidate roster with TSS key material. | ||
*/ | ||
@ConfigData("tss") | ||
public record TssConfig( | ||
@ConfigProperty(defaultValue = "3") @NetworkProperty long maxSharesPerNode, | ||
@ConfigProperty(defaultValue = "false") @NetworkProperty boolean keyActiveRoster, | ||
@ConfigProperty(defaultValue = "false") @NetworkProperty boolean enableLedgerId) {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters