Skip to content
Open
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
5,480 changes: 3,528 additions & 1,952 deletions Cargo.lock

Large diffs are not rendered by default.

242 changes: 121 additions & 121 deletions Cargo.toml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion base/src/header_extension/builder_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ impl HeaderExtensionBuilderData {
) -> Self {
let opaques: Vec<OpaqueExtrinsic> = extrinsics
.iter()
.filter_map(|e| OpaqueExtrinsic::from_bytes(e).ok())
.filter_map(|e| OpaqueExtrinsic::try_from_encoded_extrinsic(e).ok())
.collect();

Self::from_opaque_extrinsics::<F>(block, &opaques)
Expand Down
2 changes: 1 addition & 1 deletion blob/benches/submit_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ use divan::Bencher;
use sp_api::ApiError;
use sp_core::crypto::AccountId32;
use sp_core::crypto::KeyTypeId;
use sp_core::keccak_256;
use sp_core::H256;
use sp_io::hashing::keccak_256;
use sp_runtime::transaction_validity::TransactionSource;
use sp_runtime::transaction_validity::TransactionValidity;
use std::sync::Arc;
Expand Down
3 changes: 2 additions & 1 deletion blob/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ use sc_service::TFullClient;
use scale_info::TypeInfo;
use serde::{Deserialize, Serialize};
use sp_authority_discovery::AuthorityId;
use sp_core::{blake2_256, H256};
use sp_core::H256;
use sp_io::hashing::blake2_256;
use sp_runtime::{
traits::{Block as BlockT, Hash as HashT, HashingFor},
AccountId32,
Expand Down
5 changes: 3 additions & 2 deletions blob/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ use sp_api::ProvideRuntimeApi;
use sp_authority_discovery::AuthorityId;
use sp_core::sr25519::{Public, Signature};
use sp_core::H256;
use sp_core::{crypto::KeyTypeId, sr25519, twox_128};
use sp_core::{crypto::KeyTypeId, sr25519};
use sp_io::hashing::{blake2_256, twox_128};
use sp_runtime::generic::Preamble;
use sp_runtime::MultiAddress;
use sp_runtime::{
Expand Down Expand Up @@ -128,7 +129,7 @@ pub fn designated_prover_index(
input[..32].copy_from_slice(finalized_block_hash.as_bytes());
input[32..].copy_from_slice(blob_hash.as_bytes());

let h = sp_core::blake2_256(&input);
let h = blake2_256(&input);
u32::from_le_bytes(h[..4].try_into().unwrap()) % nb_validators_per_blob
}

Expand Down
2 changes: 1 addition & 1 deletion blob/src/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ use codec::{Decode, Encode};
use da_control::Call;
use da_runtime::RuntimeCall;
use da_runtime::UncheckedExtrinsic;
use sp_core::keccak_256;
use sp_core::H256;
use sp_io::hashing::keccak_256;
use sp_runtime::transaction_validity::TransactionSource;
use std::sync::Arc;

Expand Down
59 changes: 31 additions & 28 deletions client/basic-authorship/src/basic_authorship.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ use sc_telemetry::{telemetry, TelemetryHandle, CONSENSUS_INFO};
use sc_transaction_pool_api::{InPoolTransaction, TransactionPool, TxInvalidityReportMap};
use sp_api::{ApiExt, CallApiAt, ProvideRuntimeApi};
use sp_blockchain::{ApplyExtrinsicFailed::Validity, Error::ApplyExtrinsicFailed, HeaderBackend};
use sp_consensus::{DisableProofRecording, EnableProofRecording, ProofRecording, Proposal};
use sp_consensus::{Proposal, ProposeArgs};
use sp_core::{traits::SpawnNamed, H256};
use sp_inherents::InherentData;
use sp_runtime::{
traits::{BlakeTwo256, Block as BlockT, Hash as HashT, Header as HeaderT},
Digest, Percent, SaturatedConversion,
Percent, SaturatedConversion,
};
use sp_transaction_pool::runtime_api::TaggedTransactionQueue;
use std::{collections::BTreeMap, marker::PhantomData, pin::Pin, sync::Arc, time};
Expand All @@ -66,6 +66,17 @@ const DEFAULT_SOFT_DEADLINE_PERCENT: Percent = Percent::from_percent(50);

const LOG_TARGET: &'static str = "basic-authorship";

/// Marker used to preserve the existing proposer-factory API without recording a proof by
/// default. Proof recording itself is supplied through [`ProposeArgs`].
pub struct DisableProofRecording;

/// Marker used to preserve the existing proof-recording proposer-factory constructor.
pub struct EnableProofRecording;

pub trait ProofRecording: Send + Sync + 'static {}
impl ProofRecording for DisableProofRecording {}
impl ProofRecording for EnableProofRecording {}

/// [`Proposer`] factory.
pub struct ProposerFactory<A, C, PR> {
spawn_handle: Box<dyn SpawnNamed>,
Expand Down Expand Up @@ -302,31 +313,21 @@ where
+ BlobApi<Block>,
PR: ProofRecording,
{
type Proposal =
Pin<Box<dyn Future<Output = Result<Proposal<Block, PR::Proof>, Self::Error>> + Send>>;
type Proposal = Pin<Box<dyn Future<Output = Result<Proposal<Block>, Self::Error>> + Send>>;
type Error = sp_blockchain::Error;
type ProofRecording = PR;
type Proof = PR::Proof;

fn propose(
self,
inherent_data: InherentData,
inherent_digests: Digest,
max_duration: time::Duration,
block_size_limit: Option<usize>,
) -> Self::Proposal {
fn propose(self, args: ProposeArgs<Block>) -> Self::Proposal {
let (tx, rx) = oneshot::channel();
let spawn_handle = self.spawn_handle.clone();
let max_duration = args.max_duration;

spawn_handle.spawn_blocking(
"basic-authorship-proposer",
None,
Box::pin(async move {
// leave some time for evaluation and block finalization (33%)
let deadline = (self.now)() + max_duration - max_duration / 3;
let res = self
.propose_with(inherent_data, inherent_digests, deadline, block_size_limit)
.await;
let res = self.propose_with(args, deadline).await;
if tx.send(res).is_err() {
trace!(
target: LOG_TARGET,
Expand Down Expand Up @@ -366,17 +367,24 @@ where
{
async fn propose_with(
self,
inherent_data: InherentData,
inherent_digests: Digest,
args: ProposeArgs<Block>,
deadline: time::Instant,
block_size_limit: Option<usize>,
) -> Result<Proposal<Block, PR::Proof>, sp_blockchain::Error> {
) -> Result<Proposal<Block>, sp_blockchain::Error> {
let ProposeArgs {
inherent_data,
inherent_digests,
block_size_limit,
storage_proof_recorder,
extra_extensions,
..
} = args;
let block_timer = time::Instant::now();
let mut block_builder = BlockBuilderBuilder::new(&*self.client)
.on_parent_block(self.parent_hash)
.with_parent_block_number(self.parent_number)
.with_proof_recording(PR::ENABLED)
.with_proof_recorder(storage_proof_recorder)
.with_inherent_digests(inherent_digests)
.with_extra_extensions(extra_extensions)
.build()?;

self.client.init_post_inherent_data();
Expand All @@ -391,16 +399,12 @@ where

self.apply_post_inherents(&mut block_builder, blob_txs_summary, total_blob_size)?;

let (block, storage_changes, proof) = block_builder.build()?.into_inner();
let (block, storage_changes) = block_builder.build()?.into_inner();
let block_took = block_timer.elapsed();

let proof =
PR::into_proof(proof).map_err(|e| sp_blockchain::Error::Application(Box::new(e)))?;

self.print_summary(&block, end_reason, block_took, block_timer.elapsed());
Ok(Proposal {
block,
proof,
storage_changes,
})
}
Expand Down Expand Up @@ -574,8 +578,7 @@ where
let pending_tx_data = (**pending_tx.data()).clone();
let pending_tx_hash = pending_tx.hash().clone();

let block_size =
block_builder.estimate_block_size(self.include_proof_in_block_size_estimation);
let block_size = block_builder.estimate_block_size();
if block_size + pending_tx_data.encoded_size() > block_size_limit {
pending_iterator.report_invalid(&pending_tx);
if skipped < MAX_SKIPPED_TRANSACTIONS {
Expand Down
4 changes: 2 additions & 2 deletions node/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ impl frame_benchmarking_cli::ExtrinsicBuilder for RemarkBuilder {
SystemCall::remark { remark: vec![] },
Some(nonce),
);
OpaqueExtrinsic::from_bytes(&extrinsic.encode())
OpaqueExtrinsic::try_from_encoded_extrinsic(&extrinsic.encode())
.map_err(|_| "`AppUncheckedExtrinsic` cannot be decoded as `OpaqueExtrinsic`")
}
}
Expand Down Expand Up @@ -111,7 +111,7 @@ impl frame_benchmarking_cli::ExtrinsicBuilder for TransferKeepAliveBuilder {
},
Some(nonce),
);
OpaqueExtrinsic::from_bytes(&extrinsic.encode())
OpaqueExtrinsic::try_from_encoded_extrinsic(&extrinsic.encode())
.map_err(|_| "`AppUncheckedExtrinsic` cannot be decoded as `OpaqueExtrinsic`")
}
}
Expand Down
7 changes: 7 additions & 0 deletions node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ pub fn new_partial(
config,
telemetry.as_ref().map(|(_, telemetry)| telemetry.handle()),
executor,
vec![Arc::new(sc_consensus_grandpa::GrandpaPruningFilter)],
)?;
let client = Arc::new(client);

Expand Down Expand Up @@ -411,6 +412,7 @@ pub fn new_partial_light(
config,
telemetry.as_ref().map(|(_, t)| t.handle()),
executor,
vec![Arc::new(sc_consensus_grandpa::GrandpaPruningFilter)],
)?;
let client = Arc::new(client);

Expand Down Expand Up @@ -595,6 +597,7 @@ pub fn new_full_base<N: NetworkBackend<Block, <Block as BlockT>::Hash>>(
client: client.clone(),
transaction_pool: transaction_pool.clone(),
spawn_handle: task_manager.spawn_handle(),
spawn_essential_handle: task_manager.spawn_essential_handle(),
import_queue,
block_announce_validator_builder: None,
warp_sync_config: Some(WarpSyncConfig::WithProvider(warp_sync)),
Expand Down Expand Up @@ -667,6 +670,7 @@ pub fn new_full_base<N: NetworkBackend<Block, <Block as BlockT>::Hash>>(
Some(t) => Some(t),
None => None,
},
tracing_execute_block: None,
})?;

if let Some(hwbench) = hwbench {
Expand Down Expand Up @@ -733,6 +737,7 @@ pub fn new_full_base<N: NetworkBackend<Block, <Block as BlockT>::Hash>>(
sp_transaction_storage_proof::registration::new_data_provider(
&*client_clone,
&parent,
100_800,
)?;

Ok((slot, timestamp, storage_proof))
Expand Down Expand Up @@ -993,6 +998,7 @@ pub fn new_light_node<N: NetworkBackend<Block, <Block as BlockT>::Hash>>(
client: client.clone(),
transaction_pool: transaction_pool.clone(),
spawn_handle: task_manager.spawn_handle(),
spawn_essential_handle: task_manager.spawn_essential_handle(),
import_queue,
block_announce_validator_builder: None,
// In an deployed network, light clients should ideally use warp sync.
Expand Down Expand Up @@ -1085,6 +1091,7 @@ pub fn new_light_node<N: NetworkBackend<Block, <Block as BlockT>::Hash>>(
tx_handler_controller,
sync_service: sync_service.clone(),
telemetry: telemetry.as_mut(),
tracing_execute_block: None,
})?;

log::info!(
Expand Down
2 changes: 1 addition & 1 deletion pallets/dactr/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,7 @@ mod clear_blob_offence_records {
new_test_ext().execute_with(|| {
let alice: RuntimeOrigin = RawOrigin::Signed(ALICE).into();
let res = DataAvailability::clear_blob_offence_records(alice);
assert_noop!(res, frame_support::error::BadOrigin);
assert_noop!(res, sp_runtime::DispatchError::BadOrigin);
});
}
}
38 changes: 7 additions & 31 deletions pallets/dactr/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub type AppKeyFor<T> = BoundedVec<u8, <T as Config>::MaxAppKeyLength>;
pub type AppDataFor<T> = BoundedVec<u8, <T as Config>::MaxAppDataLength>;

#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
#[derive(Clone, Encode, Decode, TypeInfo, PartialEq, RuntimeDebug, MaxEncodedLen)]
#[derive(Clone, Encode, Decode, TypeInfo, PartialEq, Debug, MaxEncodedLen)]
pub struct AppKeyInfo<Acc: PartialEq> {
/// Owner of the key
pub owner: Acc,
Expand Down Expand Up @@ -54,7 +54,7 @@ impl<AccountId> SessionDataProvider<AccountId> for () {
}
}

#[derive(Clone, Encode, Decode, DecodeWithMemTracking, TypeInfo, PartialEq, RuntimeDebug)]
#[derive(Clone, Encode, Decode, DecodeWithMemTracking, TypeInfo, PartialEq, Debug)]
pub struct BlobTxSummaryRuntime {
pub hash: H256,
pub tx_index: u32,
Expand Down Expand Up @@ -141,15 +141,7 @@ impl Default for BlobRuntimeParameters {
/// Structure used when there is an offence reported by validators client side.
/// They all need some vouching from accusing validators and it needs to reach a threshold to be considered valid.
#[derive(
RuntimeDebug,
Clone,
PartialEq,
Eq,
Encode,
Decode,
DecodeWithMemTracking,
MaxEncodedLen,
TypeInfo,
Debug, Clone, PartialEq, Eq, Encode, Decode, DecodeWithMemTracking, MaxEncodedLen, TypeInfo,
)]
pub enum BlobOffenceKind {
SummaryNbBlobMismatch,
Expand All @@ -162,15 +154,7 @@ pub enum BlobOffenceKind {
}

#[derive(
RuntimeDebug,
Clone,
PartialEq,
Eq,
Encode,
Decode,
DecodeWithMemTracking,
MaxEncodedLen,
TypeInfo,
Debug, Clone, PartialEq, Eq, Encode, Decode, DecodeWithMemTracking, MaxEncodedLen, TypeInfo,
)]
pub struct ValidatorVoucher {
pub session_index: u32,
Expand All @@ -189,15 +173,7 @@ impl ValidatorVoucher {
}

#[derive(
RuntimeDebug,
Clone,
PartialEq,
Eq,
Encode,
Decode,
DecodeWithMemTracking,
MaxEncodedLen,
TypeInfo,
Debug, Clone, PartialEq, Eq, Encode, Decode, DecodeWithMemTracking, MaxEncodedLen, TypeInfo,
)]
pub struct OffenceKey {
pub block_hash: H256,
Expand Down Expand Up @@ -235,7 +211,7 @@ impl OffenceKey {
}
}

#[derive(RuntimeDebug, PartialEq, Eq, Encode, Decode, MaxEncodedLen, TypeInfo)]
#[derive(Debug, PartialEq, Eq, Encode, Decode, MaxEncodedLen, TypeInfo)]
#[scale_info(skip_type_params(T))]
pub struct OffenceRecord<T: Config> {
/// What type of offence this record represents.
Expand Down Expand Up @@ -342,7 +318,7 @@ impl<T: Config> OffenceRecord<T> {
}
}

#[derive(Clone, Encode, Decode, RuntimeDebug, PartialEq, Eq, TypeInfo)]
#[derive(Clone, Encode, Decode, Debug, PartialEq, Eq, TypeInfo)]
pub struct BlobOffence<Offender> {
pub kind: BlobOffenceKind,
pub key: OffenceKey,
Expand Down
4 changes: 2 additions & 2 deletions pallets/system/src/extensions/authorize_call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use frame_support::{
Decode, DecodeWithMemTracking, DispatchResult, Encode, TransactionSource, TypeInfo, Weight,
},
traits::Authorize,
CloneNoBound, EqNoBound, PartialEqNoBound, RuntimeDebugNoBound,
CloneNoBound, DebugNoBound, EqNoBound, PartialEqNoBound,
};
use sp_runtime::{
traits::{
Expand All @@ -44,7 +44,7 @@ use sp_runtime::{
EqNoBound,
PartialEqNoBound,
TypeInfo,
RuntimeDebugNoBound,
DebugNoBound,
DecodeWithMemTracking,
)]
#[scale_info(skip_type_params(T))]
Expand Down
Loading