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
7 changes: 7 additions & 0 deletions prdoc/pr_10252.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
title: '[pallet-revive] use run_instant_seal_and_finalize in dev-node'
doc:
- audience: Runtime Dev
description: Fix finalized block in revive-dev-node with instant-seal
crates:
- name: pallet-revive-eth-rpc
bump: patch
2 changes: 1 addition & 1 deletion substrate/frame/revive/dev-node/node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ pub fn new_full<Network: sc_network::NetworkBackend<Block, <Block as BlockT>::Ha
create_inherent_data_providers: timestamp_provider,
};

let authorship_future = sc_consensus_manual_seal::run_instant_seal(params);
let authorship_future = sc_consensus_manual_seal::run_instant_seal_and_finalize(params);

task_manager.spawn_essential_handle().spawn_blocking(
"instant-seal",
Expand Down
8 changes: 4 additions & 4 deletions substrate/frame/revive/rpc/src/block_info_provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use tokio::sync::RwLock;
#[async_trait]
pub trait BlockInfoProvider: Send + Sync {
/// Update the latest block
async fn update_latest(&self, block: SubstrateBlock, subscription_type: SubscriptionType);
async fn update_latest(&self, block: Arc<SubstrateBlock>, subscription_type: SubscriptionType);

/// Return the latest finalized block.
async fn latest_finalized_block(&self) -> Arc<SubstrateBlock>;
Expand Down Expand Up @@ -86,12 +86,12 @@ impl SubxtBlockInfoProvider {

#[async_trait]
impl BlockInfoProvider for SubxtBlockInfoProvider {
async fn update_latest(&self, block: SubstrateBlock, subscription_type: SubscriptionType) {
async fn update_latest(&self, block: Arc<SubstrateBlock>, subscription_type: SubscriptionType) {
let mut latest = match subscription_type {
SubscriptionType::FinalizedBlocks => self.latest_finalized_block.write().await,
SubscriptionType::BestBlocks => self.latest_block.write().await,
};
*latest = Arc::new(block);
*latest = block;
}

async fn latest_block(&self) -> Arc<SubstrateBlock> {
Expand Down Expand Up @@ -172,7 +172,7 @@ pub mod test {
impl BlockInfoProvider for MockBlockInfoProvider {
async fn update_latest(
&self,
_block: SubstrateBlock,
_block: Arc<SubstrateBlock>,
_subscription_type: SubscriptionType,
) {
}
Expand Down
19 changes: 9 additions & 10 deletions substrate/frame/revive/rpc/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use crate::{
LOG_TARGET,
};
use clap::Parser;
use futures::{pin_mut, FutureExt};
use futures::{future::BoxFuture, pin_mut, FutureExt};
use jsonrpsee::server::RpcModule;
use sc_cli::{PrometheusParams, RpcParams, SharedParams, Signals};
use sc_service::{
Expand Down Expand Up @@ -229,17 +229,16 @@ pub fn run(cmd: CliCommand) -> anyhow::Result<()> {
task_manager
.spawn_essential_handle()
.spawn("block-subscription", None, async move {
let fut1 = client.subscribe_and_cache_new_blocks(SubscriptionType::BestBlocks);
let fut2 = client.subscribe_and_cache_new_blocks(SubscriptionType::FinalizedBlocks);
let mut futures: Vec<BoxFuture<'_, Result<(), _>>> = vec![
Box::pin(client.subscribe_and_cache_new_blocks(SubscriptionType::BestBlocks)),
Box::pin(client.subscribe_and_cache_new_blocks(SubscriptionType::FinalizedBlocks)),
];

let res = if let Some(index_last_n_blocks) = index_last_n_blocks {
let fut3 = client.subscribe_and_cache_blocks(index_last_n_blocks);
tokio::try_join!(fut1, fut2, fut3).map(|_| ())
} else {
tokio::try_join!(fut1, fut2).map(|_| ())
};
if let Some(index_last_n_blocks) = index_last_n_blocks {
futures.push(Box::pin(client.subscribe_and_cache_blocks(index_last_n_blocks)));
}

if let Err(err) = res {
if let Err(err) = futures::future::try_join_all(futures).await {
panic!("Block subscription task failed: {err:?}",)
}
});
Expand Down
2 changes: 1 addition & 1 deletion substrate/frame/revive/rpc/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ impl Client {
.into_iter()
.unzip();

self.block_provider.update_latest(block, subscription_type).await;
self.block_provider.update_latest(Arc::new(block), subscription_type).await;
self.fee_history_provider.update_fee_history(&evm_block, &receipts).await;

// Only broadcast for best blocks to avoid duplicate notifications.
Expand Down