Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 3 additions & 3 deletions cumulus/client/network/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ impl RelayChainInterface for DummyRelayChainInterface {
persisted_validation_data_hash: PHash::random(),
pov_hash: PHash::random(),
erasure_root: PHash::random(),
signature: sp_core::sr25519::Signature([0u8; 64]).into(),
signature: sp_core::sr25519::Signature::default().into(),
validation_code_hash: ValidationCodeHash::from(PHash::random()),
},
commitments: CandidateCommitments {
Expand Down Expand Up @@ -325,7 +325,7 @@ async fn make_gossip_message_and_header(
persisted_validation_data_hash: PHash::random(),
pov_hash: PHash::random(),
erasure_root: PHash::random(),
signature: sp_core::sr25519::Signature([0u8; 64]).into(),
signature: sp_core::sr25519::Signature::default().into(),
para_head: polkadot_parachain_primitives::primitives::HeadData(header.encode()).hash(),
validation_code_hash: ValidationCodeHash::from(PHash::random()),
},
Expand Down Expand Up @@ -516,7 +516,7 @@ async fn check_statement_seconded() {
persisted_validation_data_hash: PHash::random(),
pov_hash: PHash::random(),
erasure_root: PHash::random(),
signature: sp_core::sr25519::Signature([0u8; 64]).into(),
signature: sp_core::sr25519::Signature::default().into(),
validation_code_hash: ValidationCodeHash::from(PHash::random()),
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,12 +190,7 @@ fn construct_extrinsic(
);
let payload = SignedPayload::new(call.clone(), extra.clone()).unwrap();
let signature = payload.using_encoded(|e| sender.sign(e));
UncheckedExtrinsic::new_signed(
call,
account_id.into(),
Signature::Sr25519(signature.clone()),
extra,
)
UncheckedExtrinsic::new_signed(call, account_id.into(), Signature::Sr25519(signature), extra)
}

fn construct_and_apply_extrinsic(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,7 @@ fn construct_extrinsic(
);
let payload = SignedPayload::new(call.clone(), extra.clone()).unwrap();
let signature = payload.using_encoded(|e| sender.sign(e));
UncheckedExtrinsic::new_signed(
call,
account_id.into(),
Signature::Sr25519(signature.clone()),
extra,
)
UncheckedExtrinsic::new_signed(call, account_id.into(), Signature::Sr25519(signature), extra)
}

fn construct_and_apply_extrinsic(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,7 @@ fn construct_extrinsic(
);
let payload = SignedPayload::new(call.clone(), extra.clone()).unwrap();
let signature = payload.using_encoded(|e| sender.sign(e));
UncheckedExtrinsic::new_signed(
call,
account_id.into(),
Signature::Sr25519(signature.clone()),
extra,
)
UncheckedExtrinsic::new_signed(call, account_id.into(), Signature::Sr25519(signature), extra)
}

fn construct_and_apply_extrinsic(
Expand Down
4 changes: 2 additions & 2 deletions polkadot/node/service/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ fn westend_sign_call(
runtime::UncheckedExtrinsic::new_signed(
call,
sp_runtime::AccountId32::from(acc.public()).into(),
polkadot_core_primitives::Signature::Sr25519(signature.clone()),
polkadot_core_primitives::Signature::Sr25519(signature),
extra,
)
.into()
Expand Down Expand Up @@ -274,7 +274,7 @@ fn rococo_sign_call(
runtime::UncheckedExtrinsic::new_signed(
call,
sp_runtime::AccountId32::from(acc.public()).into(),
polkadot_core_primitives::Signature::Sr25519(signature.clone()),
polkadot_core_primitives::Signature::Sr25519(signature),
extra,
)
.into()
Expand Down
2 changes: 1 addition & 1 deletion polkadot/node/test/service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ pub fn construct_extrinsic(
UncheckedExtrinsic::new_signed(
function.clone(),
polkadot_test_runtime::Address::Id(caller.public().into()),
polkadot_primitives::Signature::Sr25519(signature.clone()),
polkadot_primitives::Signature::Sr25519(signature),
extra.clone(),
)
}
Expand Down
4 changes: 2 additions & 2 deletions polkadot/primitives/src/v6/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1953,11 +1953,11 @@ mod tests {
descriptor: CandidateDescriptor {
para_id: 0.into(),
relay_parent: zeros,
collator: CollatorId::from(sr25519::Public::from_raw([0; 32])),
collator: CollatorId::from(sr25519::Public::default()),
persisted_validation_data_hash: zeros,
pov_hash: zeros,
erasure_root: zeros,
signature: CollatorSignature::from(sr25519::Signature([0u8; 64])),
signature: CollatorSignature::from(sr25519::Signature::default()),
para_head: zeros,
validation_code_hash: ValidationCode(vec![1, 2, 3, 4, 5, 6, 7, 8, 9]).hash(),
},
Expand Down
6 changes: 3 additions & 3 deletions polkadot/primitives/test-helpers/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,17 +136,17 @@ pub fn dummy_head_data() -> HeadData {

/// Create a meaningless collator id.
pub fn dummy_collator() -> CollatorId {
CollatorId::from(sr25519::Public::from_raw([0; 32]))
CollatorId::from(sr25519::Public::default())
}

/// Create a meaningless validator id.
pub fn dummy_validator() -> ValidatorId {
ValidatorId::from(sr25519::Public::from_raw([0; 32]))
ValidatorId::from(sr25519::Public::default())
}

/// Create a meaningless collator signature.
pub fn dummy_collator_signature() -> CollatorSignature {
CollatorSignature::from(sr25519::Signature([0u8; 64]))
CollatorSignature::from(sr25519::Signature::default())
}

/// Create a meaningless persisted validation data.
Expand Down
4 changes: 2 additions & 2 deletions polkadot/runtime/common/src/purchase.rs
Original file line number Diff line number Diff line change
Expand Up @@ -425,8 +425,8 @@ pub mod pallet {
impl<T: Config> Pallet<T> {
fn verify_signature(who: &T::AccountId, signature: &[u8]) -> Result<(), DispatchError> {
// sr25519 always expects a 64 byte signature.
let signature: AnySignature = sr25519::Signature::from_slice(signature)
.ok_or(Error::<T>::InvalidSignature)?
let signature: AnySignature = sr25519::Signature::try_from(signature)
.map_err(|_| Error::<T>::InvalidSignature)?
.into();

// In Polkadot, the AccountId is always the same as the 32 byte public key.
Expand Down
2 changes: 1 addition & 1 deletion polkadot/runtime/parachains/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ impl<T: paras_inherent::Config> BenchBuilder<T> {
persisted_validation_data_hash: Default::default(),
pov_hash: Default::default(),
erasure_root: Default::default(),
signature: CollatorSignature::from(sr25519::Signature([42u8; 64])),
signature: CollatorSignature::from(sr25519::Signature::from_raw([42u8; 64])),
para_head: Default::default(),
validation_code_hash: mock_validation_code().hash(),
}
Expand Down
2 changes: 1 addition & 1 deletion substrate/client/authority-discovery/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ fn cryptos_are_compatible() {
let sp_core_signature = sp_core_secret.sign(message); // no error expected...

assert!(sp_core::ed25519::Pair::verify(
&sp_core::ed25519::Signature::from_slice(&libp2p_signature).unwrap(),
&sp_core::ed25519::Signature::try_from(libp2p_signature.as_slice()).unwrap(),
message,
&sp_core_public
));
Expand Down
4 changes: 2 additions & 2 deletions substrate/client/executor/runtime-test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ sp_core::wasm_export_functions! {
sig.copy_from_slice(&input[32..96]);

let msg = b"all ok!";
ed25519_verify(&ed25519::Signature(sig), &msg[..], &ed25519::Public(pubkey))
ed25519_verify(&ed25519::Signature::from(sig), &msg[..], &ed25519::Public::from(pubkey))
}

fn test_sr25519_verify(input: Vec<u8>) -> bool {
Expand All @@ -192,7 +192,7 @@ sp_core::wasm_export_functions! {
sig.copy_from_slice(&input[32..96]);

let msg = b"all ok!";
sr25519_verify(&sr25519::Signature(sig), &msg[..], &sr25519::Public(pubkey))
sr25519_verify(&sr25519::Signature::from(sig), &msg[..], &sr25519::Public::from(pubkey))
}

fn test_ordered_trie_root() -> Vec<u8> {
Expand Down
4 changes: 2 additions & 2 deletions substrate/client/service/test/src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2226,11 +2226,11 @@ fn reorg_triggers_a_notification_even_for_sources_that_should_not_trigger_notifi
#[test]
fn use_dalek_ext_works() {
fn zero_ed_pub() -> sp_core::ed25519::Public {
sp_core::ed25519::Public([0u8; 32])
sp_core::ed25519::Public::default()
}

fn zero_ed_sig() -> sp_core::ed25519::Signature {
sp_core::ed25519::Signature::from_raw([0u8; 64])
sp_core::ed25519::Signature::default()
}

let mut client = TestClientBuilder::new().build();
Expand Down
6 changes: 3 additions & 3 deletions substrate/frame/contracts/src/exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1466,14 +1466,14 @@ where

fn sr25519_verify(&self, signature: &[u8; 64], message: &[u8], pub_key: &[u8; 32]) -> bool {
sp_io::crypto::sr25519_verify(
&SR25519Signature(*signature),
&SR25519Signature::from(*signature),
message,
&SR25519Public(*pub_key),
&SR25519Public::from(*pub_key),
)
}

fn ecdsa_to_eth_address(&self, pk: &[u8; 33]) -> Result<[u8; 20], ()> {
ECDSAPublic(*pk).to_eth_address()
ECDSAPublic::from(*pk).to_eth_address()
}

#[cfg(test)]
Expand Down
8 changes: 4 additions & 4 deletions substrate/frame/sassafras/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ mod benchmarks {
TicketsIds::<T>::insert((epoch_tag as u8, i), id);
let body = TicketBody {
attempt_idx: i,
erased_public: EphemeralPublic([i as u8; 32]),
revealed_public: EphemeralPublic([i as u8; 32]),
erased_public: EphemeralPublic::from([i as u8; 32]),
revealed_public: EphemeralPublic::from([i as u8; 32]),
};
TicketsData::<T>::set(id, Some(body));
});
Expand Down Expand Up @@ -236,8 +236,8 @@ mod benchmarks {
.map(|i| {
let body = TicketBody {
attempt_idx: i,
erased_public: EphemeralPublic([i as u8; 32]),
revealed_public: EphemeralPublic([i as u8; 32]),
erased_public: EphemeralPublic::from([i as u8; 32]),
revealed_public: EphemeralPublic::from([i as u8; 32]),
};
let id_bytes = crate::hashing::blake2_128(&i.to_le_bytes());
let id = TicketId::from_le_bytes(id_bytes);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ error[E0277]: the trait bound `Bar: WrapperTypeDecode` is not satisfied
|
= help: the following other types implement trait `WrapperTypeDecode`:
Box<T>
Rc<T>
frame_support::sp_runtime::sp_application_crypto::sp_core::Bytes
Rc<T>
Arc<T>
= note: required for `Bar` to implement `Decode`
= note: required for `Bar` to implement `FullCodec`
Expand Down Expand Up @@ -65,8 +65,8 @@ error[E0277]: the trait bound `Bar: WrapperTypeEncode` is not satisfied
bytes::bytes::Bytes
Cow<'a, T>
parity_scale_codec::Ref<'a, T, U>
Rc<T>
frame_support::sp_runtime::sp_application_crypto::sp_core::Bytes
Rc<T>
Arc<T>
Vec<T>
and $N others
Expand Down Expand Up @@ -106,8 +106,8 @@ error[E0277]: the trait bound `Bar: WrapperTypeDecode` is not satisfied
|
= help: the following other types implement trait `WrapperTypeDecode`:
Box<T>
Rc<T>
frame_support::sp_runtime::sp_application_crypto::sp_core::Bytes
Rc<T>
Arc<T>
= note: required for `Bar` to implement `Decode`
= note: required for `Bar` to implement `FullCodec`
Expand Down Expand Up @@ -148,8 +148,8 @@ error[E0277]: the trait bound `Bar: WrapperTypeEncode` is not satisfied
bytes::bytes::Bytes
Cow<'a, T>
parity_scale_codec::Ref<'a, T, U>
Rc<T>
frame_support::sp_runtime::sp_application_crypto::sp_core::Bytes
Rc<T>
Arc<T>
Vec<T>
and $N others
Expand All @@ -168,8 +168,8 @@ error[E0277]: the trait bound `Bar: WrapperTypeDecode` is not satisfied
|
= help: the following other types implement trait `WrapperTypeDecode`:
Box<T>
Rc<T>
frame_support::sp_runtime::sp_application_crypto::sp_core::Bytes
Rc<T>
Arc<T>
= note: required for `Bar` to implement `Decode`
= note: required for `Bar` to implement `FullCodec`
Expand Down Expand Up @@ -210,8 +210,8 @@ error[E0277]: the trait bound `Bar: WrapperTypeEncode` is not satisfied
bytes::bytes::Bytes
Cow<'a, T>
parity_scale_codec::Ref<'a, T, U>
Rc<T>
frame_support::sp_runtime::sp_application_crypto::sp_core::Bytes
Rc<T>
Arc<T>
Vec<T>
and $N others
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ error[E0277]: the trait bound `Bar: WrapperTypeDecode` is not satisfied
|
= help: the following other types implement trait `WrapperTypeDecode`:
Box<T>
Rc<T>
frame_support::sp_runtime::sp_application_crypto::sp_core::Bytes
Rc<T>
Arc<T>
= note: required for `Bar` to implement `Decode`
= note: required for `Bar` to implement `FullCodec`
Expand Down Expand Up @@ -65,8 +65,8 @@ error[E0277]: the trait bound `Bar: WrapperTypeEncode` is not satisfied
bytes::bytes::Bytes
Cow<'a, T>
parity_scale_codec::Ref<'a, T, U>
Rc<T>
frame_support::sp_runtime::sp_application_crypto::sp_core::Bytes
Rc<T>
Arc<T>
Vec<T>
and $N others
Expand Down Expand Up @@ -106,8 +106,8 @@ error[E0277]: the trait bound `Bar: WrapperTypeDecode` is not satisfied
|
= help: the following other types implement trait `WrapperTypeDecode`:
Box<T>
Rc<T>
frame_support::sp_runtime::sp_application_crypto::sp_core::Bytes
Rc<T>
Arc<T>
= note: required for `Bar` to implement `Decode`
= note: required for `Bar` to implement `FullCodec`
Expand Down Expand Up @@ -148,8 +148,8 @@ error[E0277]: the trait bound `Bar: WrapperTypeEncode` is not satisfied
bytes::bytes::Bytes
Cow<'a, T>
parity_scale_codec::Ref<'a, T, U>
Rc<T>
frame_support::sp_runtime::sp_application_crypto::sp_core::Bytes
Rc<T>
Arc<T>
Vec<T>
and $N others
Expand All @@ -168,8 +168,8 @@ error[E0277]: the trait bound `Bar: WrapperTypeDecode` is not satisfied
|
= help: the following other types implement trait `WrapperTypeDecode`:
Box<T>
Rc<T>
frame_support::sp_runtime::sp_application_crypto::sp_core::Bytes
Rc<T>
Arc<T>
= note: required for `Bar` to implement `Decode`
= note: required for `Bar` to implement `FullCodec`
Expand Down Expand Up @@ -210,8 +210,8 @@ error[E0277]: the trait bound `Bar: WrapperTypeEncode` is not satisfied
bytes::bytes::Bytes
Cow<'a, T>
parity_scale_codec::Ref<'a, T, U>
Rc<T>
frame_support::sp_runtime::sp_application_crypto::sp_core::Bytes
Rc<T>
Arc<T>
Vec<T>
and $N others
Expand Down
Loading