Skip to content

Commit 1ee8ba5

Browse files
committed
Merge branch 'main' into 2091-map-proposal-elements-for-testing
2 parents e3ef626 + 2d58700 commit 1ee8ba5

File tree

7 files changed

+63
-23
lines changed

7 files changed

+63
-23
lines changed

catalyst-gateway/bin/src/db/index/block/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use super::{queries::FallibleQueryTasks, session::CassandraSession};
2323
pub(crate) async fn index_block(block: &MultiEraBlock) -> anyhow::Result<()> {
2424
// Get the session. This should never fail.
2525
let Some(session) = CassandraSession::get(block.is_immutable()) else {
26-
anyhow::bail!("Failed to get Index DB Session. Can not index block.");
26+
anyhow::bail!("Failed to get Index DB Session. Cannot index block.");
2727
};
2828

2929
let mut cert_index = CertInsertQuery::new();

catalyst-gateway/bin/src/db/index/block/rbac509/mod.rs

Lines changed: 56 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ pub(crate) mod insert_rbac509_invalid;
77

88
use std::sync::Arc;
99

10+
use anyhow::{bail, Context};
1011
use cardano_blockchain_types::{
1112
Cip0134Uri, MultiEraBlock, Slot, StakeAddress, TransactionId, TxnIndex,
1213
};
@@ -99,9 +100,21 @@ impl Rbac509InsertQuery {
99100
);
100101
}
101102

102-
let Some(catalyst_id) = catalyst_id(session, &cip509, txn_hash, slot, index).await else {
103-
error!("Unable to determine Catalyst id for registration: slot = {slot:?}, index = {index:?}, txn_hash = {txn_hash:?}");
104-
return;
103+
let catalyst_id = match catalyst_id(
104+
session,
105+
&cip509,
106+
txn_hash,
107+
slot,
108+
index,
109+
block.is_immutable(),
110+
)
111+
.await
112+
{
113+
Ok(v) => v,
114+
Err(e) => {
115+
error!("Unable to determine Catalyst id for registration: slot = {slot:?}, index = {index:?}, txn_hash = {txn_hash:?}: {e:?}");
116+
return;
117+
},
105118
};
106119

107120
let previous_transaction = cip509.previous_transaction();
@@ -199,29 +212,52 @@ impl Rbac509InsertQuery {
199212

200213
/// Returns a Catalyst ID of the given registration.
201214
async fn catalyst_id(
202-
session: &Arc<CassandraSession>, cip509: &Cip509, txn_hash: TransactionId, slot: Slot,
203-
index: TxnIndex,
204-
) -> Option<IdUri> {
205-
use crate::db::index::queries::rbac::get_catalyst_id_from_transaction_id::{
206-
cache_for_transaction_id, Query,
207-
};
215+
session: &Arc<CassandraSession>, cip509: &Cip509, txn_id: TransactionId, slot: Slot,
216+
index: TxnIndex, is_immutable: bool,
217+
) -> anyhow::Result<IdUri> {
218+
use crate::db::index::queries::rbac::get_catalyst_id_from_transaction_id::cache_for_transaction_id;
208219

209220
let id = match cip509.previous_transaction() {
210-
Some(previous) => {
211-
Query::get_latest(session, previous.into())
212-
.await
213-
.inspect_err(|e| error!("{e:?}"))
214-
.ok()
215-
.flatten()?
216-
.catalyst_id
217-
.into()
221+
Some(previous) => query_catalyst_id(session, previous, is_immutable).await?,
222+
None => {
223+
cip509
224+
.catalyst_id()
225+
.context("Empty Catalyst ID in root RBAC registration")?
226+
.as_short_id()
218227
},
219-
None => cip509.catalyst_id()?.as_short_id(),
220228
};
221229

222-
cache_for_transaction_id(txn_hash, id.clone(), slot, index);
230+
cache_for_transaction_id(txn_id, id.clone(), slot, index);
231+
232+
Ok(id)
233+
}
234+
235+
/// Queries a Catalyst ID from the database by the given transaction ID.
236+
async fn query_catalyst_id(
237+
session: &Arc<CassandraSession>, txn_id: TransactionId, is_immutable: bool,
238+
) -> anyhow::Result<IdUri> {
239+
use crate::db::index::queries::rbac::get_catalyst_id_from_transaction_id::Query;
223240

224-
Some(id)
241+
if let Some(q) = Query::get_latest(session, txn_id.into())
242+
.await
243+
.context("Failed to query Catalyst ID from transaction ID")?
244+
{
245+
Ok(q.catalyst_id.into())
246+
} else {
247+
if is_immutable {
248+
bail!("Unable to find Catalyst ID in the persistent DB");
249+
}
250+
251+
// If this block is a volatile/mutable one then try to look up a Catalyst ID in the
252+
// persistent database.
253+
let persistent_session =
254+
CassandraSession::get(true).context("Failed to get persistent DB session")?;
255+
Query::get_latest(&persistent_session, txn_id.into())
256+
.await
257+
.transpose()
258+
.context("Unable to find Catalyst ID in the persistent DB")?
259+
.map(|q| q.catalyst_id.into())
260+
}
225261
}
226262

227263
/// Returns stake addresses of the role 0.

catalyst_voices/apps/voices/integration_test/suites/proposals_test.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import '../pageobject/proposals_page.dart';
1111

1212
void main() async {
1313
late final GoRouter router;
14+
1415
setUpAll(() async {
1516
router = buildAppRouter();
1617
});

catalyst_voices/apps/voices/macos/Flutter/GeneratedPluginRegistrant.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import FlutterMacOS
66
import Foundation
77

8+
import file_picker
89
import file_selector_macos
910
import flutter_secure_storage_macos
1011
import package_info_plus
@@ -18,6 +19,7 @@ import video_player_avfoundation
1819
import webview_flutter_wkwebview
1920

2021
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
22+
FilePickerPlugin.register(with: registry.registrar(forPlugin: "FilePickerPlugin"))
2123
FileSelectorPlugin.register(with: registry.registrar(forPlugin: "FileSelectorPlugin"))
2224
FlutterSecureStoragePlugin.register(with: registry.registrar(forPlugin: "FlutterSecureStoragePlugin"))
2325
FPPPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FPPPackageInfoPlusPlugin"))

catalyst_voices/apps/voices/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ dependencies:
6363
flutter_web_plugins:
6464
sdk: flutter
6565
formz: ^0.7.0
66-
go_router: ^14.0.2
66+
go_router: ^14.8.0
6767
google_fonts: ^6.2.1
6868
intl: ^0.19.0
6969
lottie: ^3.3.1

catalyst_voices/melos.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ command:
126126
flutter_rust_bridge: 2.5.1
127127
flutter_secure_storage: ^9.2.2
128128
formz: ^0.7.0
129+
go_router: ^14.8.0
129130
intl: ^0.19.0
130131
logging: ^1.3.0
131132
lottie: ^3.3.1

catalyst_voices/utilities/poc_local_storage/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ dependencies:
1616
flutter_secure_storage: ^9.2.2
1717
flutter_web_plugins:
1818
sdk: flutter
19-
go_router: ^14.2.3
19+
go_router: ^14.8.0
2020
pointycastle: ^3.9.1
2121

2222
dev_dependencies:

0 commit comments

Comments
 (0)