Skip to content

Commit 16729a8

Browse files
committed
refactor sim_with_call function
1 parent bd5807e commit 16729a8

File tree

1 file changed

+9
-16
lines changed

1 file changed

+9
-16
lines changed

src/tasks/submit.rs

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -128,22 +128,16 @@ impl SubmitTask {
128128
// Create the transaction request with the signature values
129129
let tx: TransactionRequest = self.new_tx_request(retry_count, resp, block).await?;
130130

131-
// Simulate the transaction with a call to the host provider
132-
if let Some(maybe_error) = self.sim_with_call(&tx).await {
133-
warn!(error = ?maybe_error, "error in transaction simulation");
134-
if let Err(e) = maybe_error {
135-
return Err(e);
136-
}
131+
// Simulate the transaction with a call to the host provider and report any errors
132+
if let Err(err) = self.sim_with_call(&tx).await {
133+
warn!(%err, "error in transaction simulation");
137134
}
138135

139136
Ok(tx)
140137
}
141138

142139
/// Simulates the transaction with a call to the host provider to check for reverts.
143-
async fn sim_with_call(
144-
&self,
145-
tx: &TransactionRequest,
146-
) -> Option<Result<ControlFlow, eyre::Error>> {
140+
async fn sim_with_call(&self, tx: &TransactionRequest) -> eyre::Result<()> {
147141
if let Err(TransportError::ErrorResp(e)) =
148142
self.provider().call(tx.clone()).block(BlockNumberOrTag::Pending.into()).await
149143
{
@@ -153,23 +147,23 @@ impl SubmitTask {
153147
.unwrap_or_default()
154148
{
155149
debug!(%e, "incorrect host block");
156-
return Some(Ok(ControlFlow::Skip));
150+
bail!(e)
157151
}
158152

159153
if e.as_revert_data()
160154
.map(|data| data.starts_with(&Zenith::BadSignature::SELECTOR))
161155
.unwrap_or_default()
162156
{
163157
debug!(%e, "bad signature");
164-
return Some(Ok(ControlFlow::Skip));
158+
bail!(e)
165159
}
166160

167161
if e.as_revert_data()
168162
.map(|data| data.starts_with(&Zenith::OneRollupBlockPerHostBlock::SELECTOR))
169163
.unwrap_or_default()
170164
{
171165
debug!(%e, "one rollup block per host block");
172-
return Some(Ok(ControlFlow::Skip));
166+
bail!(e)
173167
}
174168

175169
error!(
@@ -178,11 +172,10 @@ impl SubmitTask {
178172
data = ?e.data,
179173
"unknown error in host transaction simulation call"
180174
);
181-
return Some(Ok(ControlFlow::Skip));
175+
bail!(e)
182176
}
183177

184-
debug!(?tx, "successfully simulated transaction request");
185-
None
178+
Ok(())
186179
}
187180

188181
/// Creates a transaction request for the blob with the given header and signature values.

0 commit comments

Comments
 (0)