Skip to content

Commit

Permalink
Merge branch 'refs/heads/next' into polydez-refactor-deltas-in-db
Browse files Browse the repository at this point in the history
# Conflicts:
#	crates/store/Cargo.toml
  • Loading branch information
polydez committed Dec 2, 2024
2 parents 8552b12 + 54095db commit 560d00d
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 16 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Enhancements

- Added `GetAccountProofs` endpoint (#506).
- Support Https in endpoint configuration (#556).

### Changes

Expand Down
16 changes: 8 additions & 8 deletions Cargo.lock

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

9 changes: 6 additions & 3 deletions bin/node/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ impl NodeConfig {
mod tests {
use figment::Jail;
use miden_node_store::config::StoreConfig;
use miden_node_utils::config::{load_config, Endpoint};
use miden_node_utils::config::{load_config, Endpoint, Protocol};

use super::NodeConfig;
use crate::{
Expand All @@ -93,10 +93,10 @@ mod tests {
verify_tx_proofs = true
[rpc]
endpoint = { host = "127.0.0.1", port = 8080 }
endpoint = { host = "127.0.0.1", port = 8080, protocol = "Http" }
[store]
endpoint = { host = "127.0.0.1", port = 8080 }
endpoint = { host = "127.0.0.1", port = 8080, protocol = "Https" }
database_filepath = "local.sqlite3"
genesis_filepath = "genesis.dat"
blockstore_dir = "blocks"
Expand All @@ -112,19 +112,22 @@ mod tests {
endpoint: Endpoint {
host: "127.0.0.1".to_string(),
port: 8080,
protocol: Protocol::default()
},
verify_tx_proofs: true
},
rpc: NormalizedRpcConfig {
endpoint: Endpoint {
host: "127.0.0.1".to_string(),
port: 8080,
protocol: Protocol::Http
},
},
store: StoreConfig {
endpoint: Endpoint {
host: "127.0.0.1".to_string(),
port: 8080,
protocol: Protocol::Https
},
database_filepath: "local.sqlite3".into(),
genesis_filepath: "genesis.dat".into(),
Expand Down
3 changes: 2 additions & 1 deletion crates/rpc/src/config.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::fmt::{Display, Formatter};

use miden_node_utils::config::{
Endpoint, DEFAULT_BLOCK_PRODUCER_PORT, DEFAULT_NODE_RPC_PORT, DEFAULT_STORE_PORT,
Endpoint, Protocol, DEFAULT_BLOCK_PRODUCER_PORT, DEFAULT_NODE_RPC_PORT, DEFAULT_STORE_PORT,
};
use serde::{Deserialize, Serialize};

Expand Down Expand Up @@ -39,6 +39,7 @@ impl Default for RpcConfig {
endpoint: Endpoint {
host: "0.0.0.0".to_string(),
port: DEFAULT_NODE_RPC_PORT,
protocol: Protocol::default(),
},
store_url: Endpoint::localhost(DEFAULT_STORE_PORT).to_string(),
block_producer_url: Endpoint::localhost(DEFAULT_BLOCK_PRODUCER_PORT).to_string(),
Expand Down
4 changes: 2 additions & 2 deletions crates/store/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ homepage.workspace = true
repository.workspace = true

[dependencies]
deadpool-sqlite = { version = "0.8", features = ["rt_tokio_1"] }
deadpool-sqlite = { version = "0.9.0", features = ["rt_tokio_1"] }
hex = { version = "0.4" }
miden-lib = { workspace = true }
miden-node-proto = { workspace = true }
miden-node-utils = { workspace = true }
miden-objects = { workspace = true }
num-derive = { version = "0.4" }
num-traits = { version = "0.2" }
rusqlite = { version = "0.31", features = ["array", "buildtime_bindgen", "bundled"] }
rusqlite = { version = "0.32.1", features = ["array", "buildtime_bindgen", "bundled"] }
rusqlite_migration = { version = "1.0" }
serde = { version = "1.0", features = ["derive"] }
thiserror = { workspace = true }
Expand Down
27 changes: 25 additions & 2 deletions crates/utils/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,31 @@ pub const DEFAULT_BLOCK_PRODUCER_PORT: u16 = 48046;
pub const DEFAULT_STORE_PORT: u16 = 28943;
pub const DEFAULT_FAUCET_SERVER_PORT: u16 = 8080;

#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Serialize, Deserialize, Default)]
pub enum Protocol {
#[default]
Http,
Https,
}
/// The `(host, port)` pair for the server's listening socket.
#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Serialize, Deserialize)]
pub struct Endpoint {
/// Host used by the store.
pub host: String,
/// Port number used by the store.
pub port: u16,
/// Protocol type: http or https.
#[serde(default)]
pub protocol: Protocol,
}

impl Endpoint {
pub fn localhost(port: u16) -> Self {
Endpoint { host: "localhost".to_string(), port }
Endpoint {
host: "localhost".to_string(),
port,
protocol: Protocol::default(),
}
}
}

Expand All @@ -41,7 +54,17 @@ impl ToSocketAddrs for Endpoint {

impl Display for Endpoint {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
f.write_fmt(format_args!("http://{}:{}", self.host, self.port))
let Endpoint { protocol, host, port } = self;
f.write_fmt(format_args!("{protocol}://{host}:{port}"))
}
}

impl Display for Protocol {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
match self {
Protocol::Http => f.write_str("http"),
Protocol::Https => f.write_str("https"),
}
}
}

Expand Down

0 comments on commit 560d00d

Please sign in to comment.