Skip to content

Commit bfaf191

Browse files
committed
wip
1 parent f66678c commit bfaf191

8 files changed

Lines changed: 24 additions & 18 deletions

File tree

golem-api-grpc/proto/golem/worker/public_oplog.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@ message QueuedCardEventCard {
292292

293293
enum CardInstallFailure {
294294
CARD_INSTALL_FAILURE_UNSPECIFIED = 0;
295+
CARD_INSTALL_FAILURE_CARD_REVOKED = 1;
295296
CARD_INSTALL_FAILURE_NOT_FOUND = 2;
296297
CARD_INSTALL_FAILURE_RECIPIENT_MISMATCH = 3;
297298
CARD_INSTALL_FAILURE_NOT_PERMITTED = 4;

golem-api-grpc/proto/golem/worker/raw_oplog.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,7 @@ message RawQueuedCardEventCard {
334334

335335
enum RawCardInstallFailure {
336336
RAW_CARD_INSTALL_FAILURE_UNSPECIFIED = 0;
337+
RAW_CARD_INSTALL_FAILURE_CARD_REVOKED = 1;
337338
RAW_CARD_INSTALL_FAILURE_NOT_FOUND = 2;
338339
RAW_CARD_INSTALL_FAILURE_RECIPIENT_MISMATCH = 3;
339340
RAW_CARD_INSTALL_FAILURE_NOT_PERMITTED = 4;

golem-common/src/base_model/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -913,6 +913,7 @@ impl From<QueuedCardEvent> for PublicQueuedCardEvent {
913913
#[cfg_attr(feature = "full", derive(desert_rust::BinaryCodec))]
914914
#[cfg_attr(feature = "full", desert(evolution()))]
915915
pub enum CardInstallFailure {
916+
CardRevoked,
916917
NotFound,
917918
RecipientMismatch,
918919
NotPermitted,

golem-common/src/model/oplog/protobuf.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,9 @@ fn card_install_failure_from_proto(
162162
golem_api_grpc::proto::golem::worker::CardInstallFailure::Unspecified => {
163163
Err("Unspecified card install failure".to_string())
164164
}
165+
golem_api_grpc::proto::golem::worker::CardInstallFailure::CardRevoked => {
166+
Ok(CardInstallFailure::CardRevoked)
167+
}
165168
golem_api_grpc::proto::golem::worker::CardInstallFailure::NotFound => {
166169
Ok(CardInstallFailure::NotFound)
167170
}
@@ -178,6 +181,9 @@ fn card_install_failure_to_proto(
178181
value: CardInstallFailure,
179182
) -> golem_api_grpc::proto::golem::worker::CardInstallFailure {
180183
match value {
184+
CardInstallFailure::CardRevoked => {
185+
golem_api_grpc::proto::golem::worker::CardInstallFailure::CardRevoked
186+
}
181187
CardInstallFailure::NotFound => {
182188
golem_api_grpc::proto::golem::worker::CardInstallFailure::NotFound
183189
}
@@ -197,6 +203,9 @@ fn raw_card_install_failure_from_proto(
197203
golem_api_grpc::proto::golem::worker::RawCardInstallFailure::Unspecified => {
198204
Err("Unspecified raw card install failure".to_string())
199205
}
206+
golem_api_grpc::proto::golem::worker::RawCardInstallFailure::CardRevoked => {
207+
Ok(CardInstallFailure::CardRevoked)
208+
}
200209
golem_api_grpc::proto::golem::worker::RawCardInstallFailure::NotFound => {
201210
Ok(CardInstallFailure::NotFound)
202211
}
@@ -213,6 +222,9 @@ fn raw_card_install_failure_to_proto(
213222
value: CardInstallFailure,
214223
) -> golem_api_grpc::proto::golem::worker::RawCardInstallFailure {
215224
match value {
225+
CardInstallFailure::CardRevoked => {
226+
golem_api_grpc::proto::golem::worker::RawCardInstallFailure::CardRevoked
227+
}
216228
CardInstallFailure::NotFound => {
217229
golem_api_grpc::proto::golem::worker::RawCardInstallFailure::NotFound
218230
}

golem-worker-executor/src/durable_host/golem/v1x.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ fn card_install_failure_to_wit(
106106
failure: CardInstallFailure,
107107
) -> golem_api_1_x::host::CardInstallError {
108108
match failure {
109+
CardInstallFailure::CardRevoked => golem_api_1_x::host::CardInstallError::Revoked,
109110
CardInstallFailure::NotFound => golem_api_1_x::host::CardInstallError::NotFound,
110111
CardInstallFailure::RecipientMismatch | CardInstallFailure::NotPermitted => {
111112
golem_api_1_x::host::CardInstallError::NotPermitted

golem-worker-executor/src/durable_host/mod.rs

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -755,7 +755,10 @@ impl<Ctx: WorkerCtx> DurableWorkerCtx<Ctx> {
755755
.set_card_interest(self.owned_agent_id.clone(), &wallet_card_ids)
756756
.await;
757757

758-
let reason = CardInstallFailure::NotFound;
758+
let reason = match card_state {
759+
Some(CardState::Revoked) => CardInstallFailure::CardRevoked,
760+
_ => CardInstallFailure::NotFound,
761+
};
759762

760763
if let Some(queued_event_index) = queued_event_index {
761764
self.public_state
@@ -803,10 +806,6 @@ impl<Ctx: WorkerCtx> DurableWorkerCtx<Ctx> {
803806
}
804807

805808
if is_live {
806-
self.state
807-
.card_service
808-
.record_revoked_cards(&[card_id])
809-
.await;
810809
let wallet_card_ids = self
811810
.state
812811
.agent_wallet_cards
@@ -2665,7 +2664,7 @@ impl<Ctx: WorkerCtx> DurableWorkerCtx<Ctx> {
26652664
Ok(())
26662665
}
26672666

2668-
pub async fn update_state_to_new_component_revision(
2667+
async fn update_state_to_new_component_revision(
26692668
&mut self,
26702669
new_revision: ComponentRevision,
26712670
) -> Result<(), WorkerExecutorError> {
@@ -2755,16 +2754,6 @@ impl<Ctx: WorkerCtx> DurableWorkerCtx<Ctx> {
27552754
self.state.cached_agent_config_retry_policies = None;
27562755
self.state.agent_effective_surface = agent_effective_surface;
27572756
self.state.agent_wallet_cards = initial_wallet_cards;
2758-
let wallet_card_ids = self
2759-
.state
2760-
.agent_wallet_cards
2761-
.keys()
2762-
.copied()
2763-
.collect::<Vec<_>>();
2764-
self.state
2765-
.card_service
2766-
.set_card_interest(self.owned_agent_id.clone(), &wallet_card_ids)
2767-
.await;
27682757
};
27692758

27702759
self.state.component_metadata = new_metadata;

golem-worker-executor/src/model/public_oplog/wit.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ fn queued_card_event_to_wit(value: PublicQueuedCardEvent) -> oplog::PublicQueued
6565

6666
fn card_install_failure_to_wit(value: CardInstallFailure) -> oplog::CardInstallFailure {
6767
match value {
68+
CardInstallFailure::CardRevoked => oplog::CardInstallFailure::CardRevoked,
6869
CardInstallFailure::NotFound => oplog::CardInstallFailure::NotFound,
6970
CardInstallFailure::RecipientMismatch => oplog::CardInstallFailure::RecipientMismatch,
7071
CardInstallFailure::NotPermitted => oplog::CardInstallFailure::NotPermitted,
@@ -73,7 +74,7 @@ fn card_install_failure_to_wit(value: CardInstallFailure) -> oplog::CardInstallF
7374

7475
fn card_install_failure_from_wit(value: oplog::CardInstallFailure) -> CardInstallFailure {
7576
match value {
76-
oplog::CardInstallFailure::CardRevoked => CardInstallFailure::NotFound,
77+
oplog::CardInstallFailure::CardRevoked => CardInstallFailure::CardRevoked,
7778
oplog::CardInstallFailure::NotFound => CardInstallFailure::NotFound,
7879
oplog::CardInstallFailure::RecipientMismatch => CardInstallFailure::RecipientMismatch,
7980
oplog::CardInstallFailure::NotPermitted => CardInstallFailure::NotPermitted,

golem-worker-executor/src/worker/status.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3373,7 +3373,7 @@ mod test {
33733373
OplogEntry::card_install_failed(
33743374
OplogIndex::from_u64(1),
33753375
card_id,
3376-
CardInstallFailure::NotFound,
3376+
CardInstallFailure::CardRevoked,
33773377
),
33783378
),
33793379
]);

0 commit comments

Comments
 (0)