Skip to content

Commit 4347bb1

Browse files
dylanlottprestwich
authored andcommitted
refactor sim_with_call function
1 parent a161e1b commit 4347bb1

File tree

1 file changed

+9
-17
lines changed

1 file changed

+9
-17
lines changed

src/tasks/submit.rs

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -128,23 +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!(
134-
error = ?maybe_error,
135-
"error in transaction simulation"
136-
);
137-
maybe_error?;
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");
138134
}
139135

140136
Ok(tx)
141137
}
142138

143139
/// Simulates the transaction with a call to the host provider to check for reverts.
144-
async fn sim_with_call(
145-
&self,
146-
tx: &TransactionRequest,
147-
) -> Option<Result<ControlFlow, eyre::Error>> {
140+
async fn sim_with_call(&self, tx: &TransactionRequest) -> eyre::Result<()> {
148141
if let Err(TransportError::ErrorResp(e)) =
149142
self.provider().call(tx.clone()).block(BlockNumberOrTag::Pending.into()).await
150143
{
@@ -154,23 +147,23 @@ impl SubmitTask {
154147
.unwrap_or_default()
155148
{
156149
debug!(%e, "incorrect host block");
157-
return Some(Ok(ControlFlow::Skip));
150+
bail!(e)
158151
}
159152

160153
if e.as_revert_data()
161154
.map(|data| data.starts_with(&Zenith::BadSignature::SELECTOR))
162155
.unwrap_or_default()
163156
{
164157
debug!(%e, "bad signature");
165-
return Some(Ok(ControlFlow::Skip));
158+
bail!(e)
166159
}
167160

168161
if e.as_revert_data()
169162
.map(|data| data.starts_with(&Zenith::OneRollupBlockPerHostBlock::SELECTOR))
170163
.unwrap_or_default()
171164
{
172165
debug!(%e, "one rollup block per host block");
173-
return Some(Ok(ControlFlow::Skip));
166+
bail!(e)
174167
}
175168

176169
error!(
@@ -179,11 +172,10 @@ impl SubmitTask {
179172
data = ?e.data,
180173
"unknown error in host transaction simulation call"
181174
);
182-
return Some(Ok(ControlFlow::Skip));
175+
bail!(e)
183176
}
184177

185-
debug!(?tx, "successfully simulated transaction request");
186-
None
178+
Ok(())
187179
}
188180

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

0 commit comments

Comments
 (0)