Skip to content

Commit 7bef0db

Browse files
bkchrdarkfriend77
authored andcommitted
Forward storage changes in manual seal (paritytech#7614)
This prevents nodes from executing the same block 2 times.
1 parent d6f2cde commit 7bef0db

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

client/consensus/manual-seal/src/lib.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,10 @@ pub async fn run_manual_seal<B, BI, CB, E, C, A, SC, CS>(
163163
C: HeaderBackend<B> + Finalizer<B, CB> + ProvideRuntimeApi<B> + 'static,
164164
CB: ClientBackend<B> + 'static,
165165
E: Environment<B> + 'static,
166-
E::Error: std::fmt::Display,
167-
<E::Proposer as Proposer<B>>::Error: std::fmt::Display,
166+
E::Proposer: Proposer<B, Transaction = TransactionFor<C, B>>,
168167
CS: Stream<Item=EngineCommand<<B as BlockT>::Hash>> + Unpin + 'static,
169168
SC: SelectChain<B> + 'static,
169+
TransactionFor<C, B>: 'static,
170170
{
171171
while let Some(command) = commands_stream.next().await {
172172
match command {
@@ -230,9 +230,9 @@ pub async fn run_instant_seal<B, BI, CB, E, C, A, SC>(
230230
C: HeaderBackend<B> + Finalizer<B, CB> + ProvideRuntimeApi<B> + 'static,
231231
CB: ClientBackend<B> + 'static,
232232
E: Environment<B> + 'static,
233-
E::Error: std::fmt::Display,
234-
<E::Proposer as Proposer<B>>::Error: std::fmt::Display,
235-
SC: SelectChain<B> + 'static
233+
E::Proposer: Proposer<B, Transaction = TransactionFor<C, B>>,
234+
SC: SelectChain<B> + 'static,
235+
TransactionFor<C, B>: 'static,
236236
{
237237
// instant-seal creates blocks as soon as transactions are imported
238238
// into the transaction pool.

client/consensus/manual-seal/src/seal_block.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,10 @@ pub async fn seal_block<B, BI, SC, C, E, P>(
8787
+ Send + Sync + 'static,
8888
C: HeaderBackend<B> + ProvideRuntimeApi<B>,
8989
E: Environment<B>,
90-
<E as Environment<B>>::Error: std::fmt::Display,
91-
<E::Proposer as Proposer<B>>::Error: std::fmt::Display,
90+
E::Proposer: Proposer<B, Transaction = TransactionFor<C, B>>,
9291
P: txpool::ChainApi<Block=B>,
9392
SC: SelectChain<B>,
93+
TransactionFor<C, B>: 'static,
9494
{
9595
let future = async {
9696
if pool.validated_pool().status().ready == 0 && !create_empty {
@@ -111,7 +111,7 @@ pub async fn seal_block<B, BI, SC, C, E, P>(
111111
};
112112

113113
let proposer = env.init(&parent)
114-
.map_err(|err| Error::StringError(format!("{}", err))).await?;
114+
.map_err(|err| Error::StringError(format!("{:?}", err))).await?;
115115
let id = inherent_data_provider.create_inherent_data()?;
116116
let inherents_len = id.len();
117117

@@ -122,7 +122,7 @@ pub async fn seal_block<B, BI, SC, C, E, P>(
122122
};
123123

124124
let proposal = proposer.propose(id.clone(), digest, Duration::from_secs(MAX_PROPOSAL_DURATION), false.into())
125-
.map_err(|err| Error::StringError(format!("{}", err))).await?;
125+
.map_err(|err| Error::StringError(format!("{:?}", err))).await?;
126126

127127
if proposal.block.extrinsics().len() == inherents_len && !create_empty {
128128
return Err(Error::EmptyTransactionPool)
@@ -133,6 +133,7 @@ pub async fn seal_block<B, BI, SC, C, E, P>(
133133
params.body = Some(body);
134134
params.finalized = finalize;
135135
params.fork_choice = Some(ForkChoiceStrategy::LongestChain);
136+
params.storage_changes = Some(proposal.storage_changes);
136137

137138
if let Some(digest_provider) = digest_provider {
138139
digest_provider.append_block_import(&parent, &mut params, &id)?;

0 commit comments

Comments
 (0)