Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
d32b4c6
Merged BEEFY primitives with generic signature and keyset commitment …
drskalman Jun 5, 2023
df8e8db
- Add bls-experimental feature to application-crypto and beefy primit…
drskalman Jun 6, 2023
126e578
Make beefy primitive tests compile
drskalman Jun 6, 2023
60dd180
move bls related beefy primitives code and test behind bls-experiment…
drskalman Jun 9, 2023
dabafab
Make BEEFY clients complies with BEEFY API depending on AuthorityId
drskalman Jun 10, 2023
b38a963
- Rename `BeefyAuthoritySet.root` → `BeefyAuthoritySet.keyset_commitm…
drskalman Jun 13, 2023
6115388
Merge remote-tracking branch 'origin/master' into skalman-multiple-si…
drskalman Jun 13, 2023
e6d72b8
Merge remote-tracking branch 'origin/master' into skalman-multiple-si…
drskalman Jun 13, 2023
a4dc019
Merge remote-tracking branch 'origin/master' into skalman-multiple-si…
drskalman Jun 13, 2023
c979bce
Commit Cargo lock remove ark-serialize from BEEFY primitives
drskalman Jun 14, 2023
735ef20
Use Codec instead of Encode + Decode in primitives/consensus/beefy/sr…
drskalman Jun 20, 2023
0d35588
- Make `BeefyApi` generic over Signature type.
drskalman Jun 20, 2023
323629f
Merge branch 'skalman-multiple-signature-scheme-beefy-primitves' of h…
drskalman Jun 20, 2023
d48a9f8
Unmake BeefyAPI generic over Signature. Recover Signature type from A…
drskalman Jun 21, 2023
4396720
- dont use hex or hex-literal use array-bytes instead in beefy primit…
drskalman Jun 21, 2023
89b61b1
Move the definition of BEEFY key type from `primitives/beefy` to `cry…
drskalman Jun 26, 2023
ba7a49a
- Add bls377_generate_new to `sp-io` and `application_crypto::bls`.
drskalman Jun 26, 2023
9744dd7
Implement PassBy for `bls::Public` manually
drskalman Jul 13, 2023
77cb1f8
Merge branch 'master' into skalman-multiple-signature-scheme-beefy-pr…
drskalman Jul 17, 2023
5cd0a4b
fix Beefy `KEY_TYPE` in `frame/beefy` tests to come from `sp-core::ke…
drskalman Jul 17, 2023
c735486
specify both generic for `hex2array_unchecked` in `sp-core/bls.rs`
drskalman Jul 17, 2023
186d956
Rename `crypto`→`ecdsa_crypto` in `primitives/consensus/beefy/src/tes…
drskalman Jul 18, 2023
bb7352d
remove commented-out code in `primitives/consensus/beefy/src/commitme…
drskalman Jul 18, 2023
59ec2ff
Fix inconsistency in panic message in `primitives/io/src/lib.rs`
drskalman Jul 18, 2023
91a0580
Remove redundant feature activation in `primitives/io/Cargo.toml`
drskalman Jul 18, 2023
d1a16ae
- make `w3f-bls` a dev-dependancy only for beefy primitives.
drskalman Jul 19, 2023
a8b23e2
Merge branch 'skalman-multiple-signature-scheme-beefy-primitves' of h…
drskalman Jul 19, 2023
4c5c55b
export BEEFY KEY_TYPE from primitives/consensus/beefy
drskalman Jul 20, 2023
4d19dab
- implement `BeefyAuthorityId` for `bls_crypto::AuthorityId`.
drskalman Jul 20, 2023
086ee43
Remove BEEFY `ecdsa_n_bls_crypto` for now for later re-introduction
drskalman Jul 24, 2023
f162e75
Merge branch 'paritytech:master' into skalman-multiple-signature-sche…
drskalman Jul 24, 2023
3b06837
Make commitment and witness BEEFY tests not use Keystore.
drskalman Jul 24, 2023
13fec09
put `bls_beefy_verify_works` test under `bls-experimental` flag.
drskalman Jul 24, 2023
671adc9
Merge remote-tracking branch 'origin/master' into skalman-multiple-si…
drskalman Jul 25, 2023
8ddc8fa
bump up Runtime `BeefyAPI` to version 3 due to introducing generic Au…
drskalman Jul 25, 2023
27bbe30
reuse code and encapsulate w3f-bls backend in sp-core as most as poss…
drskalman Jul 27, 2023
127baa5
Merge branch 'skalman-multiple-signature-scheme-beefy-primitves' of h…
drskalman Jul 27, 2023
d339f9e
Make comments in primities BEEFY `commitment.rs` and `witness.rs``tes…
drskalman Jul 27, 2023
abedbce
Merge branch 'master' of https://github.com/paritytech/substrate into…
drskalman Jul 27, 2023
80ce8d9
Use master dep versions
davxy Jul 31, 2023
3d2dad1
Trivial change. Mostly to trigger CI
davxy Jul 31, 2023
9f56a01
Apply suggestions from code review
davxy Aug 1, 2023
eca7ba1
Merge branch 'master' into skalman-multiple-signature-scheme-beefy-pr…
davxy Aug 1, 2023
d5c625a
Merge branch 'master' into skalman-multiple-signature-scheme-beefy-pr…
davxy Aug 2, 2023
b27a29a
Fix Cargo.toml
davxy Aug 2, 2023
39dcd11
Trigger CI with cumulus companion
davxy Aug 2, 2023
e38cf1a
Trigger CI after polkadot companion change
davxy Aug 2, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions client/consensus/beefy/src/communication/gossip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ use crate::{
LOG_TARGET,
};
use sp_consensus_beefy::{
crypto::{AuthorityId, Signature},
ecdsa_crypto::{AuthorityId, Signature},
ValidatorSet, ValidatorSetId, VoteMessage,
};

Expand Down Expand Up @@ -476,9 +476,10 @@ pub(crate) mod tests {
use super::*;
use crate::keystore::BeefyKeystore;
use sc_network_test::Block;
use sp_application_crypto::key_types::BEEFY as BEEFY_KEY_TYPE;
use sp_consensus_beefy::{
crypto::Signature, known_payloads, Commitment, Keyring, MmrRootHash, Payload,
SignedCommitment, VoteMessage, KEY_TYPE,
ecdsa_crypto::Signature, known_payloads, Commitment, Keyring, MmrRootHash, Payload,
SignedCommitment, VoteMessage,
};
use sp_keystore::{testing::MemoryKeystore, Keystore};

Expand Down Expand Up @@ -536,7 +537,7 @@ pub(crate) mod tests {

pub fn sign_commitment<BN: Encode>(who: &Keyring, commitment: &Commitment<BN>) -> Signature {
let store = MemoryKeystore::new();
store.ecdsa_generate_new(KEY_TYPE, Some(&who.to_seed())).unwrap();
store.ecdsa_generate_new(BEEFY_KEY_TYPE, Some(&who.to_seed())).unwrap();
let beefy_keystore: BeefyKeystore = Some(store.into()).into();
beefy_keystore.sign(&who.public(), &commitment.encode()).unwrap()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use sc_network::{
request_responses::{IfDisconnected, RequestFailure},
NetworkRequest, PeerId, ProtocolName,
};
use sp_consensus_beefy::{crypto::AuthorityId, ValidatorSet};
use sp_consensus_beefy::{ecdsa_crypto::AuthorityId, ValidatorSet};
use sp_runtime::traits::{Block, NumberFor};
use std::{collections::VecDeque, result::Result, sync::Arc};

Expand Down
6 changes: 3 additions & 3 deletions client/consensus/beefy/src/import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use log::debug;

use sp_api::{ProvideRuntimeApi, TransactionFor};
use sp_consensus::Error as ConsensusError;
use sp_consensus_beefy::{BeefyApi, BEEFY_ENGINE_ID};
use sp_consensus_beefy::{ecdsa_crypto::AuthorityId, BeefyApi, BEEFY_ENGINE_ID};
use sp_runtime::{
traits::{Block as BlockT, Header as HeaderT, NumberFor},
EncodedJustification,
Expand Down Expand Up @@ -83,7 +83,7 @@ where
Block: BlockT,
BE: Backend<Block>,
Runtime: ProvideRuntimeApi<Block>,
Runtime::Api: BeefyApi<Block> + Send,
Runtime::Api: BeefyApi<Block, AuthorityId> + Send,
{
fn decode_and_verify(
&self,
Expand Down Expand Up @@ -125,7 +125,7 @@ where
> + Send
+ Sync,
Runtime: ProvideRuntimeApi<Block> + Send + Sync,
Runtime::Api: BeefyApi<Block>,
Runtime::Api: BeefyApi<Block, AuthorityId>,
{
type Error = ConsensusError;
type Transaction = TransactionFor<Runtime, Block>;
Expand Down
2 changes: 1 addition & 1 deletion client/consensus/beefy/src/justification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use crate::keystore::BeefyKeystore;
use codec::{DecodeAll, Encode};
use sp_consensus::Error as ConsensusError;
use sp_consensus_beefy::{
crypto::{AuthorityId, Signature},
ecdsa_crypto::{AuthorityId, Signature},
ValidatorSet, ValidatorSetId, VersionedFinalityProof,
};
use sp_runtime::traits::{Block as BlockT, NumberFor};
Expand Down
71 changes: 45 additions & 26 deletions client/consensus/beefy/src/keystore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

use sp_application_crypto::RuntimeAppPublic;
use sp_application_crypto::{key_types::BEEFY as BEEFY_KEY_TYPE, RuntimeAppPublic};
use sp_core::keccak_256;
use sp_keystore::KeystorePtr;

use log::warn;

use sp_consensus_beefy::{
crypto::{Public, Signature},
BeefyAuthorityId, KEY_TYPE,
ecdsa_crypto::{Public, Signature},
BeefyAuthorityId,
};

use crate::{error, LOG_TARGET};
Expand All @@ -50,7 +50,7 @@ impl BeefyKeystore {
// we do check for multiple private keys as a key store sanity check.
let public: Vec<Public> = keys
.iter()
.filter(|k| store.has_keys(&[(k.to_raw_vec(), KEY_TYPE)]))
.filter(|k| store.has_keys(&[(k.to_raw_vec(), BEEFY_KEY_TYPE)]))
.cloned()
.collect();

Expand Down Expand Up @@ -78,7 +78,7 @@ impl BeefyKeystore {
let public = public.as_ref();

let sig = store
.ecdsa_sign_prehashed(KEY_TYPE, public, &msg)
.ecdsa_sign_prehashed(BEEFY_KEY_TYPE, public, &msg)
.map_err(|e| error::Error::Keystore(e.to_string()))?
.ok_or_else(|| error::Error::Signature("ecdsa_sign_prehashed() failed".to_string()))?;

Expand All @@ -96,7 +96,7 @@ impl BeefyKeystore {
let store = self.0.clone().ok_or_else(|| error::Error::Keystore("no Keystore".into()))?;

let pk: Vec<Public> =
store.ecdsa_public_keys(KEY_TYPE).drain(..).map(Public::from).collect();
store.ecdsa_public_keys(BEEFY_KEY_TYPE).drain(..).map(Public::from).collect();

Ok(pk)
}
Expand All @@ -117,7 +117,7 @@ impl From<Option<KeystorePtr>> for BeefyKeystore {

#[cfg(test)]
pub mod tests {
use sp_consensus_beefy::{crypto, Keyring};
use sp_consensus_beefy::{ecdsa_crypto, Keyring};
use sp_core::{ecdsa, Pair};
use sp_keystore::testing::MemoryKeystore;

Expand Down Expand Up @@ -156,35 +156,51 @@ pub mod tests {

#[test]
fn pair_works() {
let want = crypto::Pair::from_string("//Alice", None).expect("Pair failed").to_raw_vec();
let want = ecdsa_crypto::Pair::from_string("//Alice", None)
.expect("Pair failed")
.to_raw_vec();
let got = Keyring::Alice.pair().to_raw_vec();
assert_eq!(want, got);

let want = crypto::Pair::from_string("//Bob", None).expect("Pair failed").to_raw_vec();
let want = ecdsa_crypto::Pair::from_string("//Bob", None)
.expect("Pair failed")
.to_raw_vec();
let got = Keyring::Bob.pair().to_raw_vec();
assert_eq!(want, got);

let want = crypto::Pair::from_string("//Charlie", None).expect("Pair failed").to_raw_vec();
let want = ecdsa_crypto::Pair::from_string("//Charlie", None)
.expect("Pair failed")
.to_raw_vec();
let got = Keyring::Charlie.pair().to_raw_vec();
assert_eq!(want, got);

let want = crypto::Pair::from_string("//Dave", None).expect("Pair failed").to_raw_vec();
let want = ecdsa_crypto::Pair::from_string("//Dave", None)
.expect("Pair failed")
.to_raw_vec();
let got = Keyring::Dave.pair().to_raw_vec();
assert_eq!(want, got);

let want = crypto::Pair::from_string("//Eve", None).expect("Pair failed").to_raw_vec();
let want = ecdsa_crypto::Pair::from_string("//Eve", None)
.expect("Pair failed")
.to_raw_vec();
let got = Keyring::Eve.pair().to_raw_vec();
assert_eq!(want, got);

let want = crypto::Pair::from_string("//Ferdie", None).expect("Pair failed").to_raw_vec();
let want = ecdsa_crypto::Pair::from_string("//Ferdie", None)
.expect("Pair failed")
.to_raw_vec();
let got = Keyring::Ferdie.pair().to_raw_vec();
assert_eq!(want, got);

let want = crypto::Pair::from_string("//One", None).expect("Pair failed").to_raw_vec();
let want = ecdsa_crypto::Pair::from_string("//One", None)
.expect("Pair failed")
.to_raw_vec();
let got = Keyring::One.pair().to_raw_vec();
assert_eq!(want, got);

let want = crypto::Pair::from_string("//Two", None).expect("Pair failed").to_raw_vec();
let want = ecdsa_crypto::Pair::from_string("//Two", None)
.expect("Pair failed")
.to_raw_vec();
let got = Keyring::Two.pair().to_raw_vec();
assert_eq!(want, got);
}
Expand All @@ -193,8 +209,8 @@ pub mod tests {
fn authority_id_works() {
let store = keystore();

let alice: crypto::Public = store
.ecdsa_generate_new(KEY_TYPE, Some(&Keyring::Alice.to_seed()))
let alice: ecdsa_crypto::Public = store
.ecdsa_generate_new(BEEFY_KEY_TYPE, Some(&Keyring::Alice.to_seed()))
.ok()
.unwrap()
.into();
Expand All @@ -219,8 +235,8 @@ pub mod tests {
fn sign_works() {
let store = keystore();

let alice: crypto::Public = store
.ecdsa_generate_new(KEY_TYPE, Some(&Keyring::Alice.to_seed()))
let alice: ecdsa_crypto::Public = store
.ecdsa_generate_new(BEEFY_KEY_TYPE, Some(&Keyring::Alice.to_seed()))
.ok()
.unwrap()
.into();
Expand All @@ -239,7 +255,10 @@ pub mod tests {
fn sign_error() {
let store = keystore();

store.ecdsa_generate_new(KEY_TYPE, Some(&Keyring::Bob.to_seed())).ok().unwrap();
store
.ecdsa_generate_new(BEEFY_KEY_TYPE, Some(&Keyring::Bob.to_seed()))
.ok()
.unwrap();

let store: BeefyKeystore = Some(store).into();

Expand Down Expand Up @@ -268,8 +287,8 @@ pub mod tests {
fn verify_works() {
let store = keystore();

let alice: crypto::Public = store
.ecdsa_generate_new(KEY_TYPE, Some(&Keyring::Alice.to_seed()))
let alice: ecdsa_crypto::Public = store
.ecdsa_generate_new(BEEFY_KEY_TYPE, Some(&Keyring::Alice.to_seed()))
.ok()
.unwrap()
.into();
Expand Down Expand Up @@ -305,11 +324,11 @@ pub mod tests {
let _ = add_key(TEST_TYPE, None);

// BEEFY keys
let _ = add_key(KEY_TYPE, Some(Keyring::Dave.to_seed().as_str()));
let _ = add_key(KEY_TYPE, Some(Keyring::Eve.to_seed().as_str()));
let _ = add_key(BEEFY_KEY_TYPE, Some(Keyring::Dave.to_seed().as_str()));
let _ = add_key(BEEFY_KEY_TYPE, Some(Keyring::Eve.to_seed().as_str()));

let key1: crypto::Public = add_key(KEY_TYPE, None).into();
let key2: crypto::Public = add_key(KEY_TYPE, None).into();
let key1: ecdsa_crypto::Public = add_key(BEEFY_KEY_TYPE, None).into();
let key2: ecdsa_crypto::Public = add_key(BEEFY_KEY_TYPE, None).into();

let store: BeefyKeystore = Some(store).into();

Expand Down
15 changes: 8 additions & 7 deletions client/consensus/beefy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ use sp_blockchain::{
};
use sp_consensus::{Error as ConsensusError, SyncOracle};
use sp_consensus_beefy::{
crypto::AuthorityId, BeefyApi, MmrRootHash, PayloadProvider, ValidatorSet, BEEFY_ENGINE_ID,
ecdsa_crypto::AuthorityId, BeefyApi, MmrRootHash, PayloadProvider, ValidatorSet,
BEEFY_ENGINE_ID,
};
use sp_keystore::KeystorePtr;
use sp_mmr_primitives::MmrApi;
Expand Down Expand Up @@ -142,7 +143,7 @@ where
+ Send
+ Sync,
RuntimeApi: ProvideRuntimeApi<B> + Send + Sync,
RuntimeApi::Api: BeefyApi<B>,
RuntimeApi::Api: BeefyApi<B, AuthorityId>,
{
// Voter -> RPC links
let (to_rpc_justif_sender, from_voter_justif_stream) =
Expand Down Expand Up @@ -224,7 +225,7 @@ pub async fn start_beefy_gadget<B, BE, C, N, P, R, S>(
C: Client<B, BE> + BlockBackend<B>,
P: PayloadProvider<B>,
R: ProvideRuntimeApi<B>,
R::Api: BeefyApi<B> + MmrApi<B, MmrRootHash, NumberFor<B>>,
R::Api: BeefyApi<B, AuthorityId> + MmrApi<B, MmrRootHash, NumberFor<B>>,
N: GossipNetwork<B> + NetworkRequest + Send + Sync + 'static,
S: GossipSyncing<B> + SyncOracle + 'static,
{
Expand Down Expand Up @@ -339,7 +340,7 @@ where
B: Block,
BE: Backend<B>,
R: ProvideRuntimeApi<B>,
R::Api: BeefyApi<B>,
R::Api: BeefyApi<B, AuthorityId>,
{
// Initialize voter state from AUX DB if compatible.
crate::aux_schema::load_persistent(backend)?
Expand Down Expand Up @@ -374,7 +375,7 @@ where
B: Block,
BE: Backend<B>,
R: ProvideRuntimeApi<B>,
R::Api: BeefyApi<B>,
R::Api: BeefyApi<B, AuthorityId>,
{
let beefy_genesis = runtime
.runtime_api()
Expand Down Expand Up @@ -478,7 +479,7 @@ async fn wait_for_runtime_pallet<B, R>(
where
B: Block,
R: ProvideRuntimeApi<B>,
R::Api: BeefyApi<B>,
R::Api: BeefyApi<B, AuthorityId>,
{
info!(target: LOG_TARGET, "🥩 BEEFY gadget waiting for BEEFY pallet to become available...");
loop {
Expand Down Expand Up @@ -518,7 +519,7 @@ fn expect_validator_set<B, R>(
where
B: Block,
R: ProvideRuntimeApi<B>,
R::Api: BeefyApi<B>,
R::Api: BeefyApi<B, AuthorityId>,
{
runtime
.runtime_api()
Expand Down
2 changes: 1 addition & 1 deletion client/consensus/beefy/src/round.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use crate::LOG_TARGET;
use codec::{Decode, Encode};
use log::debug;
use sp_consensus_beefy::{
crypto::{AuthorityId, Signature},
ecdsa_crypto::{AuthorityId, Signature},
Commitment, EquivocationProof, SignedCommitment, ValidatorSet, ValidatorSetId, VoteMessage,
};
use sp_runtime::traits::{Block, NumberFor};
Expand Down
11 changes: 6 additions & 5 deletions client/consensus/beefy/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,15 @@ use sc_network_test::{
use sc_utils::notification::NotificationReceiver;
use serde::{Deserialize, Serialize};
use sp_api::{ApiRef, ProvideRuntimeApi};
use sp_application_crypto::key_types::BEEFY as BEEFY_KEY_TYPE;
use sp_consensus::BlockOrigin;
use sp_consensus_beefy::{
crypto::{AuthorityId, Signature},
ecdsa_crypto::{AuthorityId, Signature},
known_payloads,
mmr::{find_mmr_root_digest, MmrRootProvider},
BeefyApi, Commitment, ConsensusLog, EquivocationProof, Keyring as BeefyKeyring, MmrRootHash,
OpaqueKeyOwnershipProof, Payload, SignedCommitment, ValidatorSet, ValidatorSetId,
VersionedFinalityProof, VoteMessage, BEEFY_ENGINE_ID, KEY_TYPE as BeefyKeyType,
VersionedFinalityProof, VoteMessage, BEEFY_ENGINE_ID,
};
use sp_core::H256;
use sp_keystore::{testing::MemoryKeystore, Keystore, KeystorePtr};
Expand Down Expand Up @@ -293,7 +294,7 @@ impl ProvideRuntimeApi<Block> for TestApi {
}
}
sp_api::mock_impl_runtime_apis! {
impl BeefyApi<Block> for RuntimeApi {
impl BeefyApi<Block, AuthorityId> for RuntimeApi {
fn beefy_genesis() -> Option<NumberFor<Block>> {
Some(self.inner.beefy_genesis)
}
Expand Down Expand Up @@ -352,7 +353,7 @@ pub(crate) fn make_beefy_ids(keys: &[BeefyKeyring]) -> Vec<AuthorityId> {
pub(crate) fn create_beefy_keystore(authority: BeefyKeyring) -> KeystorePtr {
let keystore = MemoryKeystore::new();
keystore
.ecdsa_generate_new(BeefyKeyType, Some(&authority.to_seed()))
.ecdsa_generate_new(BEEFY_KEY_TYPE, Some(&authority.to_seed()))
.expect("Creates authority key");
keystore.into()
}
Expand Down Expand Up @@ -386,7 +387,7 @@ fn initialize_beefy<API>(
) -> impl Future<Output = ()>
where
API: ProvideRuntimeApi<Block> + Sync + Send,
API::Api: BeefyApi<Block> + MmrApi<Block, MmrRootHash, NumberFor<Block>>,
API::Api: BeefyApi<Block, AuthorityId> + MmrApi<Block, MmrRootHash, NumberFor<Block>>,
{
let tasks = FuturesUnordered::new();

Expand Down
Loading