Skip to content

Commit 3171ce9

Browse files
committed
thing: thing thing the thing
1 parent 2dffd30 commit 3171ce9

3 files changed

Lines changed: 20 additions & 27 deletions

File tree

src/quincey.rs

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,23 @@ pub enum QuinceyError {
2525

2626
/// Error contacting the remote quincey API.
2727
#[error("Error contacting quincey API: {0}")]
28-
Remote(#[from] reqwest::Error),
28+
Remote(reqwest::Error),
2929

3030
/// Error with the owned signet.
3131
#[error("Error with owned signet: {0}")]
3232
Owned(#[from] eyre::Report),
3333
}
3434

35+
impl From<reqwest::Error> for QuinceyError {
36+
fn from(err: reqwest::Error) -> Self {
37+
if err.status() == Some(reqwest::StatusCode::FORBIDDEN) {
38+
QuinceyError::NotOurSlot
39+
} else {
40+
QuinceyError::Remote(err)
41+
}
42+
}
43+
}
44+
3545
/// A quincey client for making requests to the Quincey API.
3646
#[derive(Debug, Clone)]
3747
pub enum Quincey {
@@ -89,23 +99,9 @@ impl Quincey {
8999

90100
let token = token.secret().await?;
91101

92-
let resp = client
93-
.post(url.clone())
94-
.json(sig_request)
95-
.bearer_auth(token)
96-
.send()
97-
.await
98-
.map_err(QuinceyError::Remote)?;
99-
100-
if resp.status() == reqwest::StatusCode::FORBIDDEN {
101-
return Err(QuinceyError::NotOurSlot);
102-
}
102+
let resp = client.post(url.clone()).json(sig_request).bearer_auth(token).send().await?;
103103

104-
resp.error_for_status()
105-
.map_err(QuinceyError::Remote)?
106-
.json::<SignResponse>()
107-
.await
108-
.map_err(QuinceyError::Remote)
104+
resp.error_for_status()?.json::<SignResponse>().await.map_err(QuinceyError::Remote)
109105
}
110106

111107
/// Get a signature for the provided request, by either using the owned

src/tasks/submit/flashbots.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ impl FlashbotsTask {
112112
);
113113

114114
let tx = prep.prep_transaction(sim_result.prev_host()).await?;
115+
115116
let sendable = self
116117
.host_provider()
117118
.fill(tx.into_request())

src/tasks/submit/prep.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -103,14 +103,13 @@ impl<'a> SubmitPrep<'a> {
103103
}
104104

105105
/// Encodes the rollup block into a sidecar.
106+
#[instrument(skip(self), level = "debug")]
106107
async fn build_sidecar(&self) -> eyre::Result<BlobTransactionSidecar> {
107-
let sidecar = self.block.encode_blob::<SimpleCoder>().build()?;
108-
109-
Ok(sidecar)
108+
self.block.encode_blob::<SimpleCoder>().build().map_err(Into::into)
110109
}
111110

112111
/// Build a signature and header input for the host chain transaction.
113-
async fn build_input(&self) -> eyre::Result<Vec<u8>> {
112+
async fn build_input(&self) -> eyre::Result<Bytes> {
114113
let (v, r, s) = self.quincey_signature().await?;
115114

116115
let header = Zenith::BlockHeader {
@@ -120,16 +119,14 @@ impl<'a> SubmitPrep<'a> {
120119
rewardAddress: self.sig_request().ru_reward_address,
121120
blockDataHash: *self.block.contents_hash(),
122121
};
123-
debug!(?header.hostBlockNumber, "built zenith block header");
124-
125-
let data = Zenith::submitBlockCall { header, v, r, s, _4: Bytes::new() }.abi_encode();
122+
let call = Zenith::submitBlockCall { header, v, r, s, _4: Bytes::new() };
126123

127-
Ok(data)
124+
Ok(call.abi_encode().into())
128125
}
129126

130127
/// Create a new transaction request for the host chain.
131128
async fn new_tx_request(&self) -> eyre::Result<TransactionRequest> {
132-
let nonce =
129+
let nonce: u64 =
133130
self.provider.get_transaction_count(self.provider.default_signer_address()).await?;
134131

135132
let (sidecar, input) = try_join!(self.build_sidecar(), self.build_input())?;
@@ -144,7 +141,6 @@ impl<'a> SubmitPrep<'a> {
144141
}
145142

146143
/// Prepares a transaction for submission to the host chain.
147-
#[instrument(skip_all, level = "debug")]
148144
pub async fn prep_transaction(self, prev_host: &Header) -> eyre::Result<Bumpable> {
149145
let req = self.new_tx_request().in_current_span().await?;
150146
Ok(Bumpable::new(req, prev_host))

0 commit comments

Comments
 (0)