Skip to content

Commit ffc4025

Browse files
committed
Add TLS support
1 parent b4a0dca commit ffc4025

File tree

5 files changed

+157
-4
lines changed

5 files changed

+157
-4
lines changed

backend-rust/Cargo.lock

Lines changed: 136 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

backend-rust/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ rust_decimal = "1.35"
3434
iso8601-duration = { version = "0.2", features = ["chrono"] }
3535
tokio-util = "0.7"
3636
prometheus-client = "0.22"
37-
tonic = "0.10.2"
37+
tonic = { version = "0.10.2", features = ["tls-roots", "tls"]}
3838

3939
# Recommended by SQLx to speed up incremental builds
4040
[profile.dev.package.sqlx-macros]

backend-rust/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,3 +178,4 @@ cargo sqlx prepare
178178
```
179179

180180
This will generate type metadata for the queries in the `.sqlx` folder.
181+

backend-rust/migrations/0001_initialize.up.sql

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,6 @@ CREATE TABLE smart_contract_modules(
265265
deployment_transaction_index
266266
BIGINT
267267
NOT NULL,
268-
-- TODO: Would be nice to use BYTEA here (should be propagated to the front end).
269268
-- Embedded schema in the wasm module if present.
270269
schema TEXT
271270
);
@@ -280,7 +279,7 @@ CREATE TABLE contracts(
280279
sub_index
281280
BIGINT
282281
NOT NULL,
283-
-- TODO: It might be better to use `module_reference_index` which would save storage space but would require more work in inserting/querying by the indexer.
282+
-- Note: It might be better to use `module_reference_index` which would save storage space but would require more work in inserting/querying by the indexer.
284283
-- Module reference of the wasm module.
285284
module_reference
286285
CHAR(64)

backend-rust/src/indexer.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,24 @@ SELECT height FROM blocks ORDER BY height DESC LIMIT 1
130130
/// Run the service. This future will only stop when signaled by the
131131
/// `cancel_token`.
132132
pub async fn run(self, cancel_token: CancellationToken) -> anyhow::Result<()> {
133-
let traverse_config = TraverseConfig::new(self.endpoints, self.start_height.into())
133+
// Set up endpoints to the node.
134+
let mut endpoints_with_schema = Vec::new();
135+
for endpoint in self.endpoints {
136+
if endpoint
137+
.uri()
138+
.scheme()
139+
.map_or(false, |x| x == &concordium_rust_sdk::v2::Scheme::HTTPS)
140+
{
141+
let new_endpoint = endpoint
142+
.tls_config(tonic::transport::ClientTlsConfig::new())
143+
.context("Unable to construct TLS configuration for the Concordium node.")?;
144+
endpoints_with_schema.push(new_endpoint);
145+
} else {
146+
endpoints_with_schema.push(endpoint);
147+
}
148+
}
149+
150+
let traverse_config = TraverseConfig::new(endpoints_with_schema, self.start_height.into())
134151
.context("Failed setting up TraverseConfig")?
135152
.set_max_parallel(self.config.max_parallel_block_preprocessors)
136153
.set_max_behind(std::time::Duration::from_secs(self.config.node_max_behind));

0 commit comments

Comments
 (0)