Skip to content

Commit

Permalink
Merge pull request #674 from EspressoSystems/jb/sqlx
Browse files Browse the repository at this point in the history
Jb/sqlx
  • Loading branch information
jbearer authored Sep 10, 2024
2 parents 90e628f + 4ff0bed commit 60df4f9
Show file tree
Hide file tree
Showing 43 changed files with 6,273 additions and 5,476 deletions.
2 changes: 0 additions & 2 deletions .cargo/config

This file was deleted.

14 changes: 14 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright (c) 2022 Espresso Systems (espressosys.com)
# This file is part of the HotShot Query Service library.
#
# This program is free software: you can redistribute it and/or modify it under the terms of the GNU
# General Public License as published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
# You should have received a copy of the GNU General Public License along with this program. If not,
# see <https://www.gnu.org/licenses/>.

[net]
git-fetch-with-cli = true
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ toml = "0.8"
tracing = "0.1"
trait-variant = "0.1"
typenum = "1"
url = "2"
vbs = "0.1"
vec1 = "1.12"
url = "2"

# Dependencies enabled by feature "file-system-data-source".
atomic_store = { git = "https://github.com/EspressoSystems/atomicstore.git", tag = "0.1.4", optional = true }
Expand Down
46 changes: 6 additions & 40 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 16 additions & 15 deletions src/availability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,9 @@ where
mod test {
use super::*;
use crate::{
data_source::{storage::no_storage, ExtensibleDataSource},
data_source::{
storage::no_storage, ExtensibleDataSource, Transaction, VersionedDataSource,
},
status::StatusDataSource,
task::BackgroundTask,
testing::{
Expand All @@ -457,13 +459,12 @@ mod test {
setup_test,
},
types::HeightIndexed,
Error, Header,
ApiState, Error, Header,
};
use async_std::sync::RwLock;
use committable::Committable;
use futures::future::FutureExt;
use hotshot_example_types::state_types::{TestInstanceState, TestValidatedState};
use hotshot_types::data::Leaf;
use hotshot_types::{data::Leaf, simple_certificate::QuorumCertificate};
use portpicker::pick_unused_port;
use std::time::Duration;
use surf_disco::Client;
Expand Down Expand Up @@ -758,7 +759,7 @@ mod test {

// Start the web server.
let port = pick_unused_port().unwrap();
let mut app = App::<_, Error>::with_state(network.data_source());
let mut app = App::<_, Error>::with_state(ApiState::from(network.data_source()));
app.register_module(
"availability",
define_api(
Expand Down Expand Up @@ -853,23 +854,23 @@ mod test {
setup_test();

let dir = TempDir::with_prefix("test_availability_extensions").unwrap();
let mut data_source = ExtensibleDataSource::new(
let data_source = ExtensibleDataSource::new(
MockDataSource::create(dir.path(), Default::default())
.await
.unwrap(),
0,
);

// mock up some consensus data.
let leaf = Leaf::<MockTypes>::genesis(
&TestValidatedState::default(),
&TestInstanceState::default(),
)
.await;

let block = BlockQueryData::new(leaf.block_header().clone(), MockPayload::genesis());

data_source.insert_block(block.clone()).await.unwrap();
let leaf = Leaf::<MockTypes>::genesis(&Default::default(), &Default::default()).await;
let qc = QuorumCertificate::genesis(&Default::default(), &Default::default()).await;
let leaf = LeafQueryData::new(leaf, qc).unwrap();
let block = BlockQueryData::new(leaf.header().clone(), MockPayload::genesis());

let mut tx = data_source.write().await.unwrap();
tx.insert_leaf(leaf).await.unwrap();
tx.insert_block(block.clone()).await.unwrap();
tx.commit().await.unwrap();

// assert that the store has data before we move on to API requests
assert_eq!(
Expand Down
9 changes: 4 additions & 5 deletions src/availability/data_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use derivative::Derivative;
use derive_more::{Display, From};
use futures::stream::{BoxStream, Stream, StreamExt};
use hotshot_types::traits::node_implementation::NodeType;
use std::{cmp::Ordering, error::Error, fmt::Debug, ops::RangeBounds};
use std::{cmp::Ordering, ops::RangeBounds};

#[derive(Derivative, From, Display)]
#[derivative(Ord = "feature_allow_slow_enum")]
Expand Down Expand Up @@ -203,12 +203,11 @@ where

#[async_trait]
pub trait UpdateAvailabilityData<Types: NodeType> {
type Error: Error + Debug + Send + Sync + 'static;
async fn insert_leaf(&mut self, leaf: LeafQueryData<Types>) -> Result<(), Self::Error>;
async fn insert_block(&mut self, block: BlockQueryData<Types>) -> Result<(), Self::Error>;
async fn insert_leaf(&mut self, leaf: LeafQueryData<Types>) -> anyhow::Result<()>;
async fn insert_block(&mut self, block: BlockQueryData<Types>) -> anyhow::Result<()>;
async fn insert_vid(
&mut self,
common: VidCommonQueryData<Types>,
share: Option<VidShare>,
) -> Result<(), Self::Error>;
) -> anyhow::Result<()>;
}
Loading

0 comments on commit 60df4f9

Please sign in to comment.