Skip to content

Commit

Permalink
node: use limiting proposer
Browse files Browse the repository at this point in the history
  • Loading branch information
rphmeier committed Dec 28, 2023
1 parent 64dd5ed commit 8ddc329
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 8 deletions.
15 changes: 15 additions & 0 deletions sugondat-chain/node/src/proposer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,21 @@ pub struct BlockLimitingProposer<P> {
transaction_pool: Arc<sc_transaction_pool::FullPool<Block, ParachainClient>>,
}

impl<P> BlockLimitingProposer<P> {
/// Create a new block-limiting proposer.
pub fn new(
inner: P,
para_id: ParaId,
transaction_pool: Arc<sc_transaction_pool::FullPool<Block, ParachainClient>>,
) -> Self {
BlockLimitingProposer {
inner,
para_id,
transaction_pool,
}
}
}

#[async_trait::async_trait]
impl<P: ProposerInterface<Block> + Send> ProposerInterface<Block> for BlockLimitingProposer<P> {
async fn propose(
Expand Down
22 changes: 14 additions & 8 deletions sugondat-chain/node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ use sc_transaction_pool_api::OffchainTransactionPoolFactory;
use sp_keystore::KeystorePtr;
use substrate_prometheus_endpoint::Registry;

use crate::proposer::BlockLimitingProposer;

// This is fine, even for the Kusama and Polkadot parachains.
//
// Runtime API invocations are one of the dumbest things in Substrate:
Expand Down Expand Up @@ -389,15 +391,19 @@ fn start_consensus(

let slot_duration = cumulus_client_consensus_aura::slot_duration(&*client)?;

let proposer_factory = sc_basic_authorship::ProposerFactory::with_proof_recording(
task_manager.spawn_handle(),
client.clone(),
transaction_pool,
prometheus_registry,
telemetry.clone(),
);
let proposer = {
let proposer_factory = sc_basic_authorship::ProposerFactory::with_proof_recording(
task_manager.spawn_handle(),
client.clone(),
transaction_pool.clone(),
prometheus_registry,
telemetry.clone(),
);

let proposer = Proposer::new(proposer_factory);
let proposer = Proposer::new(proposer_factory);

BlockLimitingProposer::new(proposer, para_id, transaction_pool)
};

let collator_service = CollatorService::new(
client.clone(),
Expand Down

0 comments on commit 8ddc329

Please sign in to comment.