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

New cli command to change federation parameters #167

Closed

Conversation

Naviabheeman
Copy link
Contributor

@Naviabheeman Naviabheeman commented Sep 12, 2023

New command with name federation is added to register or unregister changes in the federation.
Only register is implemented in the PR. Register creates a file named federationchange.dat with the given xfield parameters in the directory $HOME/.tapyrus_signer.
federationchange.dat file contains all pending xfield changes encoded in hex and sorted by height <height><xfield>
tests use the file path ./target/federationchange_test.dat

…ion through xfield

Add tests to verify aggregated-public-key and max-block-size and the file dump
separate filename from the code by making it a separate constant
register and unregister commands write to one file now.
fix formatting in federation change command
Cargo.toml Outdated
@@ -7,7 +7,7 @@ edition = "2018"

[dependencies]
http = "0.1.17"
tapyrus = { git = "https://github.com/chaintope/rust-tapyrus", tag = "v0.4.5", features = ["use-serde", "rand"] }
tapyrus = { git = "https://github.com/chaintope/rust-tapyrus", tag = "v0.4.7", features = ["use-serde", "rand"] }
Copy link
Contributor

Choose a reason for hiding this comment

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

Since it's published to crates.io, you don't need to set a repository url like other libraries.

}

let xfield_public_key: XField = match matches.value_of("aggregated-public-key") {
Some(key) => match tapyrus::PublicKey::from_str(key) {
Copy link
Contributor

Choose a reason for hiding this comment

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

You need to check whether it is a compressed public key or not.

let xfield_public_key: XField = match matches.value_of("aggregated-public-key") {
Some(key) => match tapyrus::PublicKey::from_str(key) {
Ok(public_key) => XField::AggregatePublicKey(public_key),
Err(_) => XField::None,
Copy link
Contributor

Choose a reason for hiding this comment

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

If parsing fails, an error should be returned along with the cause.

let xfield_max_block_size: XField = match matches.value_of("max-block-size") {
Some(s) => match s.parse::<u32>() {
Ok(x) => XField::MaxBlockSize(x),
Err(_) => XField::None,
Copy link
Contributor

Choose a reason for hiding this comment

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

If parsing fails, an error should be returned along with the cause.

);
assert!(res.is_ok());
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Please add a test for the result file in case of multiple registrations.

// -V, --version Prints version information
//
//OPTIONS:
// --aggregated-public-key <aggregated-public-key> aggregated public key of the new federation
Copy link
Contributor

Choose a reason for hiding this comment

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

If you update the aggregated public key with --aggregated-public-key, don't you also need the threshold and node-vss described in federations.toml?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh! this needs further discussion. I'll describe in the issue

@Naviabheeman
Copy link
Contributor Author

closed as the implementation is different now and c new command is not needed

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.

2 participants