Add signals pallet

Resolves #353

Implements code such that:

- 80% of validators (by stake) must be in favor of a signal for the network to
  be
- 80% of networks (by stake) must be in favor of a signal for it to be locked
  in
- After a signal has been locked in for two weeks, the network halts

The intention is to:

1) Not allow validators to unilaterally declare new consensus rules.

No method of declaring new consensus rules is provided by this pallet. Solely a
way to deprecate the current rules, with a signaled for successor. All nodes
must then individually decide whether or not to download and run a new node
which has new rules, and if so, which rules.

2) Not place blobs on chain.

Even if they'd be reproducible, it's just a lot of data to chuck on the
blockchain.
This commit is contained in:
Luke Parker
2023-10-21 20:06:53 -04:00
parent b66203ae3f
commit 1bff2a0447
10 changed files with 556 additions and 38 deletions

View File

@@ -84,7 +84,10 @@ pub mod pallet {
fn keys_for_network<T: Config>(
network: NetworkId,
) -> Result<(Session, Option<Public>, Option<Public>), InvalidTransaction> {
let session = ValidatorSets::<T>::session(network);
// If there's no session set, and therefore no keys set, then this must be an invalid signature
let Some(session) = ValidatorSets::<T>::session(network) else {
Err(InvalidTransaction::BadProof)?
};
let mut set = ValidatorSet { session, network };
let latest = ValidatorSets::<T>::keys(set).map(|keys| keys.0);
let prior = if set.session.0 != 0 {
@@ -93,7 +96,6 @@ pub mod pallet {
} else {
None
};
// If there's no keys set, then this must be an invalid signature
if prior.is_none() && latest.is_none() {
Err(InvalidTransaction::BadProof)?;
}