diff --git a/Cargo.lock b/Cargo.lock index 954eb6749..551685168 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4682,9 +4682,9 @@ dependencies = [ [[package]] name = "hermit-abi" -version = "0.3.4" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d3d0e0f38255e7fa3cf31335b3a56f05febd18025f4db5ef7a0cfb4f8da651f" +checksum = "d0c62115964e08cb8039170eb33c1d0e2388a256930279edca206fff675f82c3" [[package]] name = "hex" @@ -5083,7 +5083,7 @@ version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" dependencies = [ - "hermit-abi 0.3.4", + "hermit-abi 0.3.5", "libc", "windows-sys 0.48.0", ] @@ -5118,7 +5118,7 @@ version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0bad00257d07be169d870ab665980b06cdb366d792ad690bf2e76876dc503455" dependencies = [ - "hermit-abi 0.3.4", + "hermit-abi 0.3.5", "rustix 0.38.31", "windows-sys 0.52.0", ] @@ -6746,7 +6746,7 @@ version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" dependencies = [ - "hermit-abi 0.3.4", + "hermit-abi 0.3.5", "libc", ] @@ -7136,6 +7136,7 @@ dependencies = [ name = "pallet-dkg" version = "0.6.1" dependencies = [ + "blst", "elliptic-curve", "frame-benchmarking", "frame-support", @@ -8630,9 +8631,9 @@ checksum = "626dec3cac7cc0e1577a2ec3fc496277ec2baa084bebad95bb6fdbfae235f84c" [[package]] name = "polling" -version = "3.3.2" +version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "545c980a3880efd47b2e262f6a4bb6daad6555cf3367aa9c4e52895f69537a41" +checksum = "30054e72317ab98eddd8561db0f6524df3367636884b7b21b703e4b280a84a14" dependencies = [ "cfg-if", "concurrent-queue", @@ -13761,13 +13762,12 @@ checksum = "69758bda2e78f098e4ccb393021a0963bb3442eac05f135c30f61b7370bbafae" [[package]] name = "tempfile" -version = "3.9.0" +version = "3.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01ce4141aa927a6d1bd34a041795abd0db1cccba5d5f24b009f694bdf3a1f3fa" +checksum = "a365e8cd18e44762ef95d87f284f4b5cd04107fec2ff3052bd6a3e6069669e67" dependencies = [ "cfg-if", "fastrand", - "redox_syscall 0.4.1", "rustix 0.38.31", "windows-sys 0.52.0", ] @@ -15312,7 +15312,7 @@ dependencies = [ [[package]] name = "webb" version = "0.8.4" -source = "git+https://github.com/webb-tools/webb-rs.git#4fec9228812f55a7b4239cc489bb011a844d67df" +source = "git+https://github.com/webb-tools/webb-rs.git#1f0d2635971b2d9c36af4bc0bd1501d0b2a1e675" dependencies = [ "async-trait", "ethers", @@ -15498,7 +15498,7 @@ dependencies = [ [[package]] name = "webb-proposal-derive" version = "0.1.0" -source = "git+https://github.com/webb-tools/webb-rs.git#4fec9228812f55a7b4239cc489bb011a844d67df" +source = "git+https://github.com/webb-tools/webb-rs.git#1f0d2635971b2d9c36af4bc0bd1501d0b2a1e675" dependencies = [ "ethers-core", "quote", @@ -15508,7 +15508,7 @@ dependencies = [ [[package]] name = "webb-proposals" version = "0.8.0" -source = "git+https://github.com/webb-tools/webb-rs.git#4fec9228812f55a7b4239cc489bb011a844d67df" +source = "git+https://github.com/webb-tools/webb-rs.git#1f0d2635971b2d9c36af4bc0bd1501d0b2a1e675" dependencies = [ "frame-support", "hex", diff --git a/Cargo.toml b/Cargo.toml index 8972e4ec0..96304833a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -77,6 +77,8 @@ hex = { version = "0.4.3", default-features = false } paste = "1.0.6" slices = "0.2.0" schnorrkel = { version = "0.9.1", default-features = false } +blst = "0.3.11" + tangle-testnet-runtime = { package = "tangle-testnet-runtime", path = "runtime/testnet" } tangle-runtime = { package = "tangle-runtime", path = "runtime/mainnet" } diff --git a/pallets/dkg/Cargo.toml b/pallets/dkg/Cargo.toml index 3f254cd27..243d2c9ed 100644 --- a/pallets/dkg/Cargo.toml +++ b/pallets/dkg/Cargo.toml @@ -30,6 +30,7 @@ frost-ristretto255 = { package = "frost-ristretto255", workspace = true, default frost-secp256k1 = { package = "frost-secp256k1", workspace = true, default-features = false } frost-p256 = { package = "frost-p256", workspace = true, default-features = false } frost-p384 = { package = "frost-p384", workspace = true, default-features = false } +blst = { workspace = true, default-features = false, features = ["portable", "no-threads"] } # FROST RedJubjub is not yet no_std compatible # TODO: Update this once it is. diff --git a/pallets/dkg/frost/frost-ed25519/Cargo.toml b/pallets/dkg/frost/frost-ed25519/Cargo.toml index bac59934e..7a868082d 100644 --- a/pallets/dkg/frost/frost-ed25519/Cargo.toml +++ b/pallets/dkg/frost/frost-ed25519/Cargo.toml @@ -22,7 +22,7 @@ description = "A Schnorr signature scheme over Ed25519 that supports FROST." parity-scale-codec = { workspace = true } curve25519-dalek = { version = "=4.1.1", default-features = false } frost-core = { workspace = true } -rand_core = { version = "0.6", default-features = false, optional = true } +rand_core = { version = "0.6", optional = true } sha2 = { version = "0.10.2", default-features = false } subtle = { workspace = true } diff --git a/pallets/dkg/frost/frost-ed448/Cargo.toml b/pallets/dkg/frost/frost-ed448/Cargo.toml index d630b0320..b547b8579 100644 --- a/pallets/dkg/frost/frost-ed448/Cargo.toml +++ b/pallets/dkg/frost/frost-ed448/Cargo.toml @@ -26,7 +26,7 @@ rustdoc-args = ["--cfg", "docsrs"] parity-scale-codec = { workspace = true } ed448-goldilocks = { git = "https://github.com/drewstone/Ed448-Goldilocks.git", branch = "drew/zeroize", package = "ed448-goldilocks-plus", default-features = false } frost-core = { workspace = true } -rand_core = { version = "0.6", default-features = false, optional = true } +rand_core = { version = "0.6", optional = true } sha3 = { version = "0.10", default-features = false } subtle = { workspace = true } diff --git a/pallets/dkg/frost/frost-p256/Cargo.toml b/pallets/dkg/frost/frost-p256/Cargo.toml index 5fdcfec14..9bb2f4392 100644 --- a/pallets/dkg/frost/frost-p256/Cargo.toml +++ b/pallets/dkg/frost/frost-p256/Cargo.toml @@ -22,7 +22,7 @@ description = "A Schnorr signature scheme over Ed25519 that supports FROST." parity-scale-codec = { workspace = true } p256 = { version = "0.13.0", features = ["hash2curve", "alloc"], default-features = false } frost-core = { workspace = true } -rand_core = { version = "0.6", default-features = false, optional = true } +rand_core = { version = "0.6", optional = true } sha2 = { version = "0.10.2", default-features = false } subtle = { workspace = true } diff --git a/pallets/dkg/frost/frost-p384/Cargo.toml b/pallets/dkg/frost/frost-p384/Cargo.toml index 99ba088d4..8ba33a0c0 100644 --- a/pallets/dkg/frost/frost-p384/Cargo.toml +++ b/pallets/dkg/frost/frost-p384/Cargo.toml @@ -26,7 +26,7 @@ rustdoc-args = ["--cfg", "docsrs"] parity-scale-codec = { workspace = true } p384 = { version = "0.13.0", features = ["hash2curve", "alloc"], git = "https://github.com/LIT-Protocol/elliptic-curves.git", default-features = false } frost-core = { workspace = true } -rand_core = { version = "0.6", default-features = false, optional = true } +rand_core = { version = "0.6", optional = true } sha2 = { version = "0.10.2", default-features = false } subtle = { workspace = true } diff --git a/pallets/dkg/frost/frost-redjubjub/Cargo.toml b/pallets/dkg/frost/frost-redjubjub/Cargo.toml index 4c9abcad7..4c1aea245 100644 --- a/pallets/dkg/frost/frost-redjubjub/Cargo.toml +++ b/pallets/dkg/frost/frost-redjubjub/Cargo.toml @@ -29,7 +29,7 @@ parity-scale-codec = { workspace = true } jubjub = { version = "0.10", git = "https://github.com/LIT-Protocol/jubjub.git", features = ["alloc"], default-features = false } group = { version = "0.13", features = ["alloc"], default-features = false } frost-core = { workspace = true } -rand_core = { version = "0.6", default-features = false, optional = true } +rand_core = { version = "0.6", optional = true } sha2 = { version = "0.10.2", default-features = false } subtle = { workspace = true } diff --git a/pallets/dkg/frost/frost-ristretto255/Cargo.toml b/pallets/dkg/frost/frost-ristretto255/Cargo.toml index 1fc70b978..cf8fbe2cd 100644 --- a/pallets/dkg/frost/frost-ristretto255/Cargo.toml +++ b/pallets/dkg/frost/frost-ristretto255/Cargo.toml @@ -22,7 +22,7 @@ description = "A Schnorr signature scheme over Ed25519 that supports FROST." parity-scale-codec = { workspace = true } curve25519-dalek = { version = "=4.1.1", default-features = false } frost-core = { workspace = true } -rand_core = { version = "0.6", default-features = false, optional = true } +rand_core = { version = "0.6", optional = true } sha2 = { version = "0.10.2", default-features = false } subtle = { workspace = true } diff --git a/pallets/dkg/frost/frost-secp256k1/Cargo.toml b/pallets/dkg/frost/frost-secp256k1/Cargo.toml index 05bac10a9..6e60167bc 100644 --- a/pallets/dkg/frost/frost-secp256k1/Cargo.toml +++ b/pallets/dkg/frost/frost-secp256k1/Cargo.toml @@ -26,7 +26,7 @@ rustdoc-args = ["--cfg", "docsrs"] parity-scale-codec = { workspace = true } k256 = { version = "0.13.0", features = ["arithmetic", "expose-field", "hash2curve", "alloc"], default-features = false } frost-core = { workspace = true } -rand_core = { version = "0.6", default-features = false, optional = true } +rand_core = { version = "0.6", optional = true } sha2 = { version = "0.10.2", default-features = false } subtle = { workspace = true } diff --git a/pallets/dkg/frost/src/lib.rs b/pallets/dkg/frost/src/lib.rs index 3497c1585..63990c603 100644 --- a/pallets/dkg/frost/src/lib.rs +++ b/pallets/dkg/frost/src/lib.rs @@ -35,6 +35,7 @@ pub mod verifying_key; #[cfg(feature = "std")] use rand_core::{CryptoRng, RngCore}; +#[cfg(feature = "std")] use traits::{Ciphersuite, Field, Group, Scalar}; /// Generates a random nonzero scalar. diff --git a/pallets/dkg/frost/src/signing_key.rs b/pallets/dkg/frost/src/signing_key.rs index 400235603..f5bf75495 100644 --- a/pallets/dkg/frost/src/signing_key.rs +++ b/pallets/dkg/frost/src/signing_key.rs @@ -1,14 +1,15 @@ //! Schnorr signature signing keys use crate::{ - challenge::challenge, error::Error, - signature::Signature, traits::{Ciphersuite, Field, Group, Scalar}, util::scalar_is_valid, verifying_key::VerifyingKey, }; +#[cfg(feature = "std")] +use crate::{challenge::challenge, signature::Signature}; + #[cfg(feature = "std")] use crate::random_nonzero; #[cfg(feature = "std")] diff --git a/pallets/dkg/src/functions.rs b/pallets/dkg/src/functions.rs index c6a8d464a..9d5192968 100644 --- a/pallets/dkg/src/functions.rs +++ b/pallets/dkg/src/functions.rs @@ -119,6 +119,7 @@ impl Pallet { DigitalSignatureScheme::Ecdsa => verify_generated_dkg_key_ecdsa::(data), DigitalSignatureScheme::SchnorrSr25519 => verify_generated_dkg_key_schnorr_sr25519::(data), + DigitalSignatureScheme::Bls381 => verify_generated_dkg_key_ecdsa::(data), _ => Err(Error::::InvalidSignature.into()), } } @@ -145,6 +146,7 @@ impl Pallet { &data.signature, &data.signing_key, ), + DigitalSignatureScheme::Bls381 => Self::verify_bls_signature(&data), DigitalSignatureScheme::SchnorrEd25519 | DigitalSignatureScheme::SchnorrEd448 | DigitalSignatureScheme::SchnorrP256 | @@ -197,4 +199,32 @@ impl Pallet { _ => Err(Error::::InvalidSignature.into()), // unimplemented } } + + /// Verifies the DKG signature result for BLS signatures. + /// + /// This function uses the BLS signature algorithm to verify the provided signature + /// based on the message data, signature, and signing key in the DKG signature result. + /// + /// # Arguments + /// + /// * `data` - The DKG signature result containing the message data, BLS signature, and signing + /// key. + fn verify_bls_signature( + data: &DKGTSSSignatureResult, + ) -> DispatchResult { + let public_key = blst::min_pk::PublicKey::deserialize(&data.signing_key) + .map_err(|_err| Error::::InvalidBlsPublicKey)?; + let signature = blst::min_pk::Signature::deserialize(&data.signature) + .map_err(|_err| Error::::InvalidSignatureData)?; + let dst = &mut [0u8; 48]; + let signed_data = &data.data; + + if signature.verify(true, signed_data, dst, &[], &public_key, true) != + blst::BLST_ERROR::BLST_SUCCESS + { + return Err(Error::::InvalidSignature.into()) + } + + Ok(()) + } } diff --git a/pallets/dkg/src/lib.rs b/pallets/dkg/src/lib.rs index a0c0973df..a26b6fddd 100644 --- a/pallets/dkg/src/lib.rs +++ b/pallets/dkg/src/lib.rs @@ -128,6 +128,8 @@ pub mod pallet { SigningKeyMismatch, /// Invalid participant public key InvalidParticipantPublicKey, + /// Invalid BLS public key + InvalidBlsPublicKey, } #[pallet::call] diff --git a/pallets/dkg/src/tests.rs b/pallets/dkg/src/tests.rs index ffd415c10..bd7bea622 100644 --- a/pallets/dkg/src/tests.rs +++ b/pallets/dkg/src/tests.rs @@ -68,7 +68,104 @@ fn set_fees_works() { } #[test] -fn dkg_key_verifcation_works_for_ecdsa() { +fn dkg_key_verification_works_for_bls() { + new_test_ext().execute_with(|| { + let job_to_verify = DKGTSSKeySubmissionResult { + signature_scheme: DigitalSignatureScheme::Bls381, + key: vec![].try_into().unwrap(), + participants: vec![].try_into().unwrap(), + signatures: vec![].try_into().unwrap(), + threshold: 2, + }; + + // Should fail for empty participants + assert_noop!( + DKG::verify(JobResult::DKGPhaseOne(job_to_verify)), + Error::::NoParticipantsFound + ); + + let job_to_verify = DKGTSSKeySubmissionResult { + signature_scheme: DigitalSignatureScheme::Bls381, + key: vec![].try_into().unwrap(), + participants: vec![mock_pub_key_ecdsa().as_mut().to_vec().try_into().unwrap()] + .try_into() + .unwrap(), + signatures: vec![].try_into().unwrap(), + threshold: 2, + }; + + // Should fail for empty keys/signatures + assert_noop!( + DKG::verify(JobResult::DKGPhaseOne(job_to_verify)), + Error::::NoSignaturesFound + ); + + // setup key/signature + let mut pub_key = mock_pub_key_ecdsa(); + let signature = mock_signature_ecdsa(pub_key, pub_key); + + let job_to_verify = DKGTSSKeySubmissionResult { + signature_scheme: DigitalSignatureScheme::Bls381, + key: vec![].try_into().unwrap(), + participants: vec![mock_pub_key_ecdsa().as_mut().to_vec().try_into().unwrap()] + .try_into() + .unwrap(), + signatures: vec![signature.clone().try_into().unwrap()].try_into().unwrap(), + threshold: 1, + }; + + // should fail for less than threshold + assert_noop!( + DKG::verify(JobResult::DKGPhaseOne(job_to_verify)), + Error::::NotEnoughSigners + ); + + let job_to_verify = DKGTSSKeySubmissionResult { + signature_scheme: DigitalSignatureScheme::Bls381, + key: pub_key.0.to_vec().try_into().unwrap(), + participants: vec![pub_key.as_mut().to_vec().try_into().unwrap()].try_into().unwrap(), + signatures: vec![ + signature.clone().try_into().unwrap(), + signature.clone().try_into().unwrap(), + ] + .try_into() + .unwrap(), + threshold: 1, + }; + + // should fail for duplicate signers + assert_noop!( + DKG::verify(JobResult::DKGPhaseOne(job_to_verify)), + Error::::DuplicateSignature + ); + + // works correctly when all params as expected + let mut participant_one = mock_pub_key_ecdsa(); + let mut participant_two = mock_pub_key_ecdsa(); + let signature_one = mock_signature_ecdsa(participant_one, participant_one); + let signature_two = mock_signature_ecdsa(participant_two, participant_one); + let job_to_verify = DKGTSSKeySubmissionResult { + signature_scheme: DigitalSignatureScheme::Bls381, + key: participant_one.to_raw_vec().try_into().unwrap(), + participants: vec![ + participant_one.as_mut().to_vec().try_into().unwrap(), + participant_two.as_mut().to_vec().try_into().unwrap(), + ] + .try_into() + .unwrap(), + signatures: vec![signature_two.try_into().unwrap(), signature_one.try_into().unwrap()] + .try_into() + .unwrap(), + threshold: 1, + }; + + // should fail for signing different keys + assert_ok!(DKG::verify(JobResult::DKGPhaseOne(job_to_verify)),); + }) +} + +#[test] +fn dkg_key_verification_works_for_ecdsa() { new_test_ext().execute_with(|| { let job_to_verify = DKGTSSKeySubmissionResult { signature_scheme: DigitalSignatureScheme::Ecdsa, @@ -311,8 +408,54 @@ fn dkg_key_verifcation_works_for_schnorr_when_n_equals_t() { }); } +const BLS_SECRET_KEY: [u8; 32] = [ + 25, 192, 46, 5, 150, 93, 249, 180, 243, 38, 104, 158, 250, 226, 60, 6, 248, 5, 232, 52, 111, + 140, 82, 20, 226, 220, 135, 137, 186, 203, 181, 133, +]; + +const BLS_DATA_TO_SIGN: &[u8; 13] = b"Hello, world!"; + +#[test] +fn dkg_signature_verification_works_bls() { + new_test_ext().execute_with(|| { + let secret_key = blst::min_pk::SecretKey::deserialize(&BLS_SECRET_KEY).unwrap(); + let pub_key = secret_key.sk_to_pk(); + + let dst = &mut [0u8; 192]; + let signature = secret_key.sign(BLS_DATA_TO_SIGN, dst, &[]); + + let job_to_verify: DKGTSSSignatureResult = + DKGTSSSignatureResult { + signature_scheme: DigitalSignatureScheme::Bls381, + signature: signature.serialize().to_vec().try_into().unwrap(), + data: pub_key.serialize().to_vec().try_into().unwrap(), + signing_key: pub_key.serialize()[..10].to_vec().try_into().unwrap(), /* Provide invalid input */ + }; + + // Should fail for an invalid public key + assert_noop!( + DKG::verify(JobResult::DKGPhaseTwo(job_to_verify)), + Error::::InvalidBlsPublicKey + ); + + let job_to_verify: DKGTSSSignatureResult = + DKGTSSSignatureResult { + signature_scheme: DigitalSignatureScheme::Bls381, + signature: signature.serialize()[..10].to_vec().try_into().unwrap(), /* Pass invalid signature */ + data: pub_key.serialize().to_vec().try_into().unwrap(), + signing_key: pub_key.serialize().to_vec().try_into().unwrap(), + }; + + // Should fail for an invalid public key + assert_noop!( + DKG::verify(JobResult::DKGPhaseTwo(job_to_verify)), + Error::::InvalidSignatureData + ); + }); +} + #[test] -fn dkg_signature_verifcation_works_ecdsa() { +fn dkg_signature_verification_works_ecdsa() { new_test_ext().execute_with(|| { // setup key/signature let pub_key = mock_pub_key_ecdsa(); @@ -345,7 +488,7 @@ fn dkg_signature_verifcation_works_ecdsa() { } #[test] -fn dkg_signature_verifcation_works_schnorr() { +fn dkg_signature_verification_works_schnorr() { new_test_ext().execute_with(|| { // setup key/signature let pub_key = mock_pub_key_sr25519(); diff --git a/pallets/jobs/src/functions.rs b/pallets/jobs/src/functions.rs index b504ab8d3..251c87026 100644 --- a/pallets/jobs/src/functions.rs +++ b/pallets/jobs/src/functions.rs @@ -363,6 +363,7 @@ impl Pallet { .map_err(|_| Error::::InvalidValidator)?; participant_keys.push(pub_key); } + let signing_key = match phase_one_result.result { JobResult::DKGPhaseOne(result) => result.key, _ => return Err(Error::::InvalidJobPhase.into()), diff --git a/primitives/ext/src/lib.rs b/primitives/ext/src/lib.rs index 4f538a839..57351aaf2 100644 --- a/primitives/ext/src/lib.rs +++ b/primitives/ext/src/lib.rs @@ -25,10 +25,13 @@ #![cfg_attr(not(feature = "std"), no_std)] use sp_runtime_interface::runtime_interface; +#[cfg(feature = "std")] use parity_scale_codec::Decode; use sp_std::vec::Vec; -use evm_tracing_events::{Event, EvmEvent, GasometerEvent, RuntimeEvent, StepEventFilter}; +use evm_tracing_events::StepEventFilter; +#[cfg(feature = "std")] +use evm_tracing_events::{Event, EvmEvent, GasometerEvent, RuntimeEvent}; #[runtime_interface] pub trait Ext { diff --git a/primitives/rpc/debug/src/lib.rs b/primitives/rpc/debug/src/lib.rs index 5e019ea43..559013a43 100644 --- a/primitives/rpc/debug/src/lib.rs +++ b/primitives/rpc/debug/src/lib.rs @@ -16,7 +16,9 @@ #![cfg_attr(not(feature = "std"), no_std)] -use ethereum::{TransactionV0 as LegacyTransaction, TransactionV2 as Transaction}; +#[cfg(feature = "std")] +use ethereum::TransactionV0 as LegacyTransaction; +use ethereum::TransactionV2 as Transaction; use ethereum_types::H256; use parity_scale_codec::{Decode, Encode}; use sp_std::vec::Vec; diff --git a/runtime/mainnet/src/lib.rs b/runtime/mainnet/src/lib.rs index 273bdc7c7..7cda36a57 100644 --- a/runtime/mainnet/src/lib.rs +++ b/runtime/mainnet/src/lib.rs @@ -21,6 +21,8 @@ #[cfg(feature = "std")] include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs")); +pub use tangle_primitives::jobs::JobResult; + mod filters; pub mod frontier_evm; pub mod impls; @@ -61,7 +63,8 @@ use sp_runtime::{ transaction_validity::{ TransactionPriority, TransactionSource, TransactionValidity, TransactionValidityError, }, - ApplyExtrinsicResult, FixedPointNumber, FixedU128, Perquintill, SaturatedConversion, + ApplyExtrinsicResult, FixedPointNumber, FixedU128, Perquintill, RuntimeDebug, + SaturatedConversion, }; use sp_staking::currency_to_vote::U128CurrencyToVote; use tangle_primitives::jobs::{traits::JobToFee, JobSubmission}; @@ -1158,21 +1161,29 @@ impl JobToFee for Moc parameter_types! { pub const JobsPalletId: PalletId = PalletId(*b"py/jobss"); - #[derive(Clone, Debug, Eq, PartialEq, Encode, Decode, sp_runtime::Serialize, TypeInfo)] + #[derive(Clone, Eq, PartialEq, TypeInfo, Encode, Decode, RuntimeDebug)] + #[derive(Serialize, Deserialize)] pub const MaxParticipants: u32 = 10; - #[derive(Clone, Debug, Eq, PartialEq, Encode, Decode, sp_runtime::Serialize, TypeInfo)] + #[derive(Clone, Eq, PartialEq, TypeInfo, Encode, Decode, RuntimeDebug)] + #[derive(Serialize, Deserialize)] pub const MaxSubmissionLen: u32 = 256; - #[derive(Clone, Debug, Eq, PartialEq, Encode, Decode, sp_runtime::Serialize, TypeInfo)] + #[derive(Clone, Eq, PartialEq, TypeInfo, Encode, Decode, RuntimeDebug)] + #[derive(Serialize, Deserialize)] pub const MaxKeyLen: u32 = 256; - #[derive(Clone, Debug, Eq, PartialEq, Encode, Decode, sp_runtime::Serialize, TypeInfo)] + #[derive(Clone, Eq, PartialEq, TypeInfo, Encode, Decode, RuntimeDebug)] + #[derive(Serialize, Deserialize)] pub const MaxDataLen: u32 = 256; - #[derive(Clone, Debug, Eq, PartialEq, Encode, Decode, sp_runtime::Serialize, TypeInfo)] + #[derive(Clone, Eq, PartialEq, TypeInfo, Encode, Decode, RuntimeDebug)] + #[derive(Serialize, Deserialize)] pub const MaxSignatureLen: u32 = 256; - #[derive(Clone, Debug, Eq, PartialEq, Encode, Decode, sp_runtime::Serialize, TypeInfo)] + #[derive(Clone, Eq, PartialEq, TypeInfo, Encode, Decode, RuntimeDebug)] + #[derive(Serialize, Deserialize)] pub const MaxProofLen: u32 = 256; - #[derive(Clone, Debug, Eq, PartialEq, TypeInfo)] + #[derive(Clone, Eq, PartialEq, TypeInfo, Encode, Decode, RuntimeDebug)] + #[derive(Serialize, Deserialize)] pub const MaxActiveJobsPerValidator: u32 = 100; - #[derive(Clone, Debug, Eq, PartialEq, TypeInfo)] + #[derive(Clone, Eq, PartialEq, TypeInfo, Encode, Decode, RuntimeDebug)] + #[derive(Serialize, Deserialize)] pub const MaxRolesPerValidator: u32 = 100; } diff --git a/runtime/testnet/Cargo.toml b/runtime/testnet/Cargo.toml index 545d3866a..971e7504d 100644 --- a/runtime/testnet/Cargo.toml +++ b/runtime/testnet/Cargo.toml @@ -135,6 +135,7 @@ rpc-primitives-txpool = { workspace = true } [features] default = ["std", "with-rocksdb-weights", "evm-tracing"] +local-testing = [] runtime-benchmarks = [ "hex-literal", "frame-benchmarking", diff --git a/runtime/testnet/src/lib.rs b/runtime/testnet/src/lib.rs index 274a08a21..afe812712 100644 --- a/runtime/testnet/src/lib.rs +++ b/runtime/testnet/src/lib.rs @@ -1142,14 +1142,25 @@ impl } } +#[cfg(feature = "local-testing")] parameter_types! { - pub const JobsPalletId: PalletId = PalletId(*b"py/jobss"); #[derive(Clone, RuntimeDebug, Eq, PartialEq, TypeInfo, Encode, Decode)] #[derive(Serialize, Deserialize)] - pub const MaxParticipants: u32 = 10; + pub const MaxSubmissionLen: u32 = 60_000_000; +} + +#[cfg(not(feature = "local-testing"))] +parameter_types! { #[derive(Clone, RuntimeDebug, Eq, PartialEq, TypeInfo, Encode, Decode)] #[derive(Serialize, Deserialize)] pub const MaxSubmissionLen: u32 = 256; +} + +parameter_types! { + pub const JobsPalletId: PalletId = PalletId(*b"py/jobss"); + #[derive(Clone, RuntimeDebug, Eq, PartialEq, TypeInfo, Encode, Decode)] + #[derive(Serialize, Deserialize)] + pub const MaxParticipants: u32 = 10; #[derive(Clone, RuntimeDebug, Eq, PartialEq, TypeInfo, Encode, Decode)] #[derive(Serialize, Deserialize)] pub const MaxKeyLen: u32 = 256;