Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Remove TssEncryptionKeyTransaction's from state #16772

Draft
wants to merge 46 commits into
base: develop
Choose a base branch
from

Conversation

petreze
Copy link
Contributor

@petreze petreze commented Nov 25, 2024

Description:
This PR aims to clear any TssEncryptionKeyTransactionBody from state if the node id mapped to the transaction body is not present in any of the active rosters or a candidate roster. This cleanup is added on restart() of RostersSchema, so that the state changes are present in the block stream.

Related issue(s):

Fixes #16570

Notes for reviewer:

Checklist

  • Documented (Code comments, README, etc.)
  • Tested (unit, integration, etc.)

derektriley and others added 15 commits November 13, 2024 12:50
Signed-off-by: Derek Riley <[email protected]>
Signed-off-by: Derek Riley <[email protected]>
Signed-off-by: Derek Riley <[email protected]>
Signed-off-by: Derek Riley <[email protected]>
# Conflicts:
#	hedera-node/hedera-app/src/main/java/com/hedera/node/app/Hedera.java
#	hedera-node/hedera-app/src/main/java/com/hedera/node/app/HederaInjectionComponent.java
#	hedera-node/hedera-app/src/main/java/com/hedera/node/app/ServicesMain.java
#	hedera-node/hedera-app/src/main/java/com/hedera/node/app/tss/TssBaseService.java
#	hedera-node/hedera-app/src/main/java/com/hedera/node/app/tss/stores/ReadableTssStore.java
#	hedera-node/hedera-app/src/main/java/com/hedera/node/app/tss/stores/ReadableTssStoreImpl.java
#	hedera-node/hedera-app/src/main/java/com/hedera/node/app/workflows/handle/HandleWorkflow.java
#	hedera-node/hedera-app/src/test/java/com/hedera/node/app/components/IngestComponentTest.java
#	hedera-node/hedera-app/src/testFixtures/java/com/hedera/node/app/fixtures/state/FakePlatform.java
#	hedera-node/hedera-config/src/main/java/com/hedera/node/config/data/NetworkAdminConfig.java
#	hedera-node/test-clients/src/main/java/com/hedera/services/bdd/junit/hedera/embedded/fakes/FakeTssBaseService.java
#	platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/system/Platform.java
#	platform-sdk/swirlds-platform-core/src/main/java/module-info.java
Signed-off-by: Petar Tonev <[email protected]>
Signed-off-by: Petar Tonev <[email protected]>
# Conflicts:
#	platform-sdk/swirlds-platform-core/src/main/java/com/swirlds/platform/crypto/CryptoStatic.java
@petreze petreze added this to the v0.58 milestone Nov 25, 2024
@petreze petreze self-assigned this Nov 25, 2024
petreze and others added 12 commits November 25, 2024 16:35
Signed-off-by: Petar Tonev <[email protected]>
Signed-off-by: Petar Tonev <[email protected]>
# Conflicts:
#	hapi/hedera-protobufs/block/stream/output/state_changes.proto
#	hedera-node/hedera-app/src/main/java/com/hedera/node/app/blocks/impl/KVStateChangeListener.java
#	hedera-node/hedera-app/src/main/java/com/hedera/node/app/workflows/handle/HandleWorkflow.java
#	hedera-node/hedera-app/src/test/java/com/hedera/node/app/components/IngestComponentTest.java
#	hedera-node/test-clients/src/main/java/com/hedera/services/bdd/junit/support/validators/block/StateChangesValidator.java
Signed-off-by: Derek Riley <[email protected]>
Signed-off-by: Derek Riley <[email protected]>
Signed-off-by: Derek Riley <[email protected]>
Signed-off-by: Derek Riley <[email protected]>
Signed-off-by: Derek Riley <[email protected]>
Copy link
Member

@jsync-swirlds jsync-swirlds left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The use of a transaction body as a state value seems a bit odd and slightly concerning; perhaps we can simplify that?
Also a few small documentation items.

@@ -384,6 +385,11 @@ enum StateIdentifier {
*/
STATE_ID_SCHEDULED_USAGES = 34;

/**
* A state identifier for TSS Encryption Key
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Indentation is off.

/**
* A TSS Encryption Key Transaction Body value.
*/
com.hedera.hapi.services.auxiliary.tss.TssEncryptionKeyTransactionBody tss_encryption_key_value = 20;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems very odd and concerning. Are we truly storing full transaction bodies in state? If we are, I would recommend changing that, particularly as this message only has one field (of bytes).
We could more clearly store the bytes as a value in state with the same "key" used (is it Node ID?) to avoid the added wrapper message and also reduce potential confusion.

*/
message TssEncryptionKeyTransactionBody {
/**
* The raw bytes of the public TSS encryption key of the node sending the transaction.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* The raw bytes of the public TSS encryption key of the node sending the transaction.
* An array of public TSS key bytes.<br/>
* This is the raw bytes of the public TSS encryption key for
* the node sending the transaction.

option java_multiple_files = true;

/**
* A transaction body for sending the public TSS encryption key.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is missing requirements, detail, and block stream effects.

final var tssStore = context.storeFactory().writableStore(WritableTssStore.class);
final var nodeEntityNumber =
EntityNumber.newBuilder().number(context.creatorInfo().nodeId()).build();
tssStore.put(nodeEntityNumber, op);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of storing the entire transaction body, could we just store the bytes of the encryption key (which is the only field in the body)?
That would reduce state size and also make the block stream a little smaller.

@mxtartaglia-sl
Copy link
Contributor

I want to note that the serialization mechanism for the keys is being reworked based on a decision to be compatible with Ethereum's format. While we work on the necessary modifications, the tss-library API will continue supporting the old formats. Still, the production-ready version will not be compatible with the uploaded files in this pr.
Can the files still be changed once the modification is complete? Or should we hold off on this PR until that time?

Copy link
Contributor Author

@petreze petreze left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the notice Maxi, I will put that on hold and mark it as a draft until finished. There are also other things for clarification until ready for a review

@petreze petreze marked this pull request as draft November 29, 2024 10:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Clean up/Data Lifecycle of TssEncryptionKey in State
4 participants