-
Notifications
You must be signed in to change notification settings - Fork 221
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Description --- We allow here only a configured (in Consensus constants) number of validator nodes to be active in an epoch, so this way we avoid having way too much validators appear at the same time. All the validator nodes are saved to the blockchain database, when there is a new validator node registration UTXO, but with a different `start epoch` that is calculated from the already saved validator nodes. There is a new gRPC method called `GetValidatorNodeChanges`, where we can ask base node to give back all the validator node additions and deletions in the given start/end height range. When Layer-2 scans new blocks and sees that there is a change in the validator node set, simply calls this new grpc method and adds/removes validator nodes. This way base node controls fully how many nodes are registered at which epoch. Motivation and Context --- Layer-2 validator nodes are registered all at once when they were added to the chain with a special UTXO, but it allows to register too many nodes at the same time, so consensus can catch up much slower. How Has This Been Tested? --- What process can a PR reviewer use to test or verify this change? --- <!-- Checklist --> <!-- 1. Is the title of your PR in the form that would make nice release notes? The title, excluding the conventional commit tag, will be included exactly as is in the CHANGELOG, so please think about it carefully. --> Breaking Changes --- - [x] None - [ ] Requires data directory on base node to be deleted - [ ] Requires hard fork - [ ] Other - Please specify <!-- Does this include a breaking change? If so, include this line as a footer --> <!-- BREAKING CHANGE: Description what the user should do, e.g. delete a database, resync the chain --> --------- Co-authored-by: Stan Bondi <[email protected]>
- Loading branch information
Showing
27 changed files
with
754 additions
and
385 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
20 changes: 20 additions & 0 deletions
20
applications/minotari_app_grpc/src/conversions/validator_node_change.rs
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,20 @@ | ||
// Copyright 2024 The Tari Project | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
|
||
use tari_core::base_node::comms_interface::{ValidatorNodeChange, ValidatorNodeChangeState}; | ||
use tari_utilities::ByteArray; | ||
|
||
impl From<&ValidatorNodeChange> for crate::tari_rpc::ValidatorNodeChange { | ||
fn from(node_change: &ValidatorNodeChange) -> Self { | ||
Self { | ||
public_key: node_change.public_key.to_vec(), | ||
state: match node_change.state { | ||
ValidatorNodeChangeState::ADD => crate::tari_rpc::ValidatorNodeChangeState::Add.into(), | ||
ValidatorNodeChangeState::REMOVE => crate::tari_rpc::ValidatorNodeChangeState::Remove.into(), | ||
}, | ||
start_height: node_change.height, | ||
registration: Some((&node_change.registration).into()), | ||
minimum_value_promise: node_change.minimum_value_promise.into(), | ||
} | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
applications/minotari_app_grpc/src/conversions/validator_node_registration.rs
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,28 @@ | ||
// Copyright 2024 The Tari Project | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
|
||
use tari_core::transactions::transaction_components::ValidatorNodeRegistration; | ||
use tari_utilities::ByteArray; | ||
|
||
impl From<&ValidatorNodeRegistration> for crate::tari_rpc::ValidatorNodeRegistration { | ||
fn from(registration: &ValidatorNodeRegistration) -> Self { | ||
Self { | ||
public_key: registration.public_key().to_vec(), | ||
signature: Some(crate::tari_rpc::Signature { | ||
public_nonce: registration.signature().get_public_nonce().to_vec(), | ||
signature: registration.signature().get_signature().to_vec(), | ||
}), | ||
claim_public_key: registration.claim_public_key().to_vec(), | ||
sidechain_id: match registration.sidechain_id() { | ||
None => vec![], | ||
Some(id) => id.to_vec(), | ||
}, | ||
sidechain_id_knowledge_proof: registration.sidechain_id_knowledge_proof().map(|signature| { | ||
crate::tari_rpc::Signature { | ||
public_nonce: signature.get_public_nonce().to_vec(), | ||
signature: signature.get_signature().to_vec(), | ||
} | ||
}), | ||
} | ||
} | ||
} |
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
Oops, something went wrong.