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

Add isActiveAuthority and GrandpaKeyPair fields to AbstractState #714

Merged
merged 7 commits into from
Jan 27, 2025

Conversation

Grigorov-Georgi
Copy link
Collaborator

@Grigorov-Georgi Grigorov-Georgi commented Jan 24, 2025

Description

  • Refactor keyStore.getKey() to return Pair<publicKey, privateKey>, where the keys are of type byte[] in order to work for both SR25519(Babe) and ED25519(Grandpa) key pairs.
  • Add a method to convert from Pair<byte[], byte[]> to Schnorrkel.KeyPair object
  • Add isActiveAuthority and grandpaKeyPair static fields to AbstractState and methods for setting and unsetting them.

Fixes #713

@Grigorov-Georgi Grigorov-Georgi changed the title Add NodeRoleManager Add Authority Status and GrandpaKeyPair fields to AbstractState Jan 27, 2025
@Grigorov-Georgi Grigorov-Georgi changed the title Add Authority Status and GrandpaKeyPair fields to AbstractState Add isActiveAuthority and GrandpaKeyPair fields to AbstractState Jan 27, 2025
@Grigorov-Georgi Grigorov-Georgi marked this pull request as ready for review January 27, 2025 12:26
Comment on lines +10 to +18
@Getter
protected boolean initialized;

@Getter
private static SyncMode syncMode;
@Getter
protected boolean initialized;
private static boolean isActiveAuthority = false;
@Getter
private static Pair<byte[], byte[]> grandpaKeyPair = null;
Copy link
Member

Choose a reason for hiding this comment

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

If every single field needs a getter than you should put the annotation on the class

Copy link
Collaborator Author

@Grigorov-Georgi Grigorov-Georgi Jan 27, 2025

Choose a reason for hiding this comment

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

"This annotation can also be applied to a class, in which case it'll be as if all non-static fields that don't already have a Getter annotation have the annotation." taken from lombok documentation for Getter. I tried applying it only to the class, but it doesn't generate getters for the static fields.

Comment on lines 33 to 36
public static void unsetAuthorityStatus() {
isActiveAuthority = false;
grandpaKeyPair = null;
}
Copy link
Member

Choose a reason for hiding this comment

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

I like "clear" better than "unset"

@Grigorov-Georgi Grigorov-Georgi merged commit b7b105a into dev Jan 27, 2025
3 checks passed
@Grigorov-Georgi Grigorov-Georgi deleted the 713-create-node-role-manager branch January 27, 2025 15:13
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.

Check and store if we are a grandpa authority for sets.
3 participants