Skip to content

Commit

Permalink
minor updates to oracle code
Browse files Browse the repository at this point in the history
  • Loading branch information
Fraser999 committed Nov 1, 2024
1 parent 2193c19 commit e5164be
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion crates/astria-sequencer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ cnidarium = { git = "https://github.com/penumbra-zone/penumbra.git", tag = "v0.8
"metrics",
] }
ibc-proto = { version = "0.41.0", features = ["server"] }
# `is_sorted_by` is available in rust 1.81.0, but we haven't updated our msrv yet
# `is_sorted_by` is available in rust 1.82.0, but we haven't updated our msrv yet
is_sorted = "0.1.1"
matchit = "0.7.2"
tower = "0.4"
Expand Down
26 changes: 12 additions & 14 deletions crates/astria-sequencer/src/grpc/connect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,11 @@ impl OracleService for SequencerServer {
request: Request<GetPriceRequest>,
) -> Result<Response<GetPriceResponse>, Status> {
let request = request.into_inner();
let Ok(currency_pair) = request.currency_pair.parse() else {
return Err(Status::invalid_argument("currency pair is invalid"));
};

let currency_pair = request
.currency_pair
.parse()
.map_err(|e| Status::invalid_argument(format!("currency pair is invalid: {e:#}")))?;

let snapshot = self.storage.latest_snapshot();
let Some(state) = snapshot
Expand Down Expand Up @@ -217,19 +219,15 @@ impl OracleService for SequencerServer {
request: Request<GetPricesRequest>,
) -> Result<Response<GetPricesResponse>, Status> {
let request = request.into_inner();
let currency_pairs = match request
let currency_pairs = request
.currency_pair_ids
.into_iter()
.map(|s| CurrencyPair::from_str(&s))
.collect::<Result<Vec<_>, _>>()
{
Ok(currency_pairs) => currency_pairs,
Err(e) => {
return Err(Status::invalid_argument(format!(
"invalid currency pair id: {e:#}"
)));
}
};
.map(|s| {
CurrencyPair::from_str(&s).map_err(|e| {
Status::invalid_argument(format!("invalid currency pair id `{s}`: {e:#}"))
})
})
.collect::<Result<Vec<_>, _>>()?;

let snapshot = self.storage.latest_snapshot();
let Some(market_map) = snapshot.get_market_map().await.map_err(|e| {
Expand Down
7 changes: 6 additions & 1 deletion crates/astria-sequencer/src/proposal/commitment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,13 @@ pub(crate) struct GeneratedCommitments {
impl GeneratedCommitments {
/// The total size of the commitments in bytes.
pub(crate) const TOTAL_SIZE: usize = 64;
}

impl IntoIterator for GeneratedCommitments {
type IntoIter = std::array::IntoIter<Self::Item, 2>;
type Item = Bytes;

pub(crate) fn into_iter(self) -> impl Iterator<Item = Bytes> {
fn into_iter(self) -> Self::IntoIter {
[
self.rollup_datas_root.to_vec().into(),
self.rollup_ids_root.to_vec().into(),
Expand Down
3 changes: 0 additions & 3 deletions crates/astria-sequencer/src/service/consensus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -358,10 +358,7 @@ mod tests {
.handle_prepare_proposal(prepare_proposal)
.await
.unwrap();
// let mut expected_txs = vec![b"".to_vec().into()];
let commitments_and_txs: Vec<Bytes> = commitments.into_iter().chain(txs).collect();
// expected_txs.extend(commitments_and_txs.clone());

let expected_txs: Vec<Bytes> = std::iter::once(b"".to_vec().into())
.chain(commitments_and_txs.clone())
.collect();
Expand Down

0 comments on commit e5164be

Please sign in to comment.